]>
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"); | |
648 | vty_out(vty, "%s\n", | |
649 | json_object_to_json_string_ext(json, | |
650 | JSON_C_TO_STRING_PRETTY)); | |
651 | json_object_free(json); | |
652 | } | |
ca61fd25 DS |
653 | else |
654 | vty_out(vty, "View/Vrf %s is unknown\n", | |
655 | vrf_name); | |
d62a17ae | 656 | *idx = 0; |
657 | return 0; | |
658 | } | |
659 | } | |
660 | } else { | |
661 | *bgp = bgp_get_default(); | |
662 | if (!*bgp) { | |
52e5b8c4 SP |
663 | if (use_json) { |
664 | json_object *json = NULL; | |
665 | json = json_object_new_object(); | |
666 | json_object_string_add( | |
667 | json, "warning", | |
668 | "Default BGP instance not found"); | |
669 | vty_out(vty, "%s\n", | |
670 | json_object_to_json_string_ext(json, | |
671 | JSON_C_TO_STRING_PRETTY)); | |
672 | json_object_free(json); | |
673 | } | |
ca61fd25 DS |
674 | else |
675 | vty_out(vty, | |
676 | "Default BGP instance not found\n"); | |
d62a17ae | 677 | *idx = 0; |
678 | return 0; | |
679 | } | |
680 | } | |
681 | ||
682 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
683 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
684 | ||
685 | *idx += 1; | |
686 | return *idx; | |
687 | } | |
688 | ||
28c6e247 | 689 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 690 | { |
691 | struct interface *ifp = NULL; | |
692 | ||
693 | if (su->sa.sa_family == AF_INET) | |
694 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
695 | else if (su->sa.sa_family == AF_INET6) | |
696 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
697 | su->sin6.sin6_scope_id, | |
698 | bgp->vrf_id); | |
699 | ||
700 | if (ifp) | |
3dc339cd | 701 | return true; |
d62a17ae | 702 | |
3dc339cd | 703 | return false; |
718e3744 | 704 | } |
705 | ||
28c6e247 IR |
706 | /* Utility function for looking up peer from VTY. */ |
707 | /* This is used only for configuration, so disallow if attempted on | |
708 | * a dynamic neighbor. | |
709 | */ | |
710 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
711 | { | |
712 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
713 | int ret; | |
714 | union sockunion su; | |
715 | struct peer *peer; | |
716 | ||
717 | if (!bgp) { | |
718 | return NULL; | |
719 | } | |
720 | ||
721 | ret = str2sockunion(ip_str, &su); | |
722 | if (ret < 0) { | |
723 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
724 | if (!peer) { | |
725 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
726 | == NULL) { | |
727 | vty_out(vty, | |
728 | "%% Malformed address or name: %s\n", | |
729 | ip_str); | |
730 | return NULL; | |
731 | } | |
732 | } | |
733 | } else { | |
734 | peer = peer_lookup(bgp, &su); | |
735 | if (!peer) { | |
736 | vty_out(vty, | |
737 | "%% Specify remote-as or peer-group commands first\n"); | |
738 | return NULL; | |
739 | } | |
740 | if (peer_dynamic_neighbor(peer)) { | |
741 | vty_out(vty, | |
742 | "%% Operation not allowed on a dynamic neighbor\n"); | |
743 | return NULL; | |
744 | } | |
745 | } | |
746 | return peer; | |
747 | } | |
748 | ||
718e3744 | 749 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
750 | /* This is used only for configuration, so disallow if attempted on |
751 | * a dynamic neighbor. | |
752 | */ | |
d62a17ae | 753 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
754 | { | |
755 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
756 | int ret; | |
757 | union sockunion su; | |
758 | struct peer *peer = NULL; | |
759 | struct peer_group *group = NULL; | |
760 | ||
761 | if (!bgp) { | |
762 | return NULL; | |
763 | } | |
764 | ||
765 | ret = str2sockunion(peer_str, &su); | |
766 | if (ret == 0) { | |
767 | /* IP address, locate peer. */ | |
768 | peer = peer_lookup(bgp, &su); | |
769 | } else { | |
770 | /* Not IP, could match either peer configured on interface or a | |
771 | * group. */ | |
772 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
773 | if (!peer) | |
774 | group = peer_group_lookup(bgp, peer_str); | |
775 | } | |
776 | ||
777 | if (peer) { | |
778 | if (peer_dynamic_neighbor(peer)) { | |
779 | vty_out(vty, | |
780 | "%% Operation not allowed on a dynamic neighbor\n"); | |
781 | return NULL; | |
782 | } | |
783 | ||
784 | return peer; | |
785 | } | |
786 | ||
787 | if (group) | |
788 | return group->conf; | |
789 | ||
790 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
791 | ||
792 | return NULL; | |
793 | } | |
794 | ||
795 | int bgp_vty_return(struct vty *vty, int ret) | |
796 | { | |
797 | const char *str = NULL; | |
798 | ||
799 | switch (ret) { | |
800 | case BGP_ERR_INVALID_VALUE: | |
801 | str = "Invalid value"; | |
802 | break; | |
803 | case BGP_ERR_INVALID_FLAG: | |
804 | str = "Invalid flag"; | |
805 | break; | |
806 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
807 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
808 | break; | |
809 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
810 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
811 | break; | |
812 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
813 | str = "Specify remote-as or peer-group remote AS first"; | |
814 | break; | |
815 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
816 | str = "Cannot change the peer-group. Deconfigure first"; | |
817 | break; | |
818 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
819 | str = "Peer is not a member of this peer-group"; | |
820 | break; | |
821 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
822 | str = "Prefix/distribute list can not co-exist"; | |
823 | break; | |
824 | case BGP_ERR_NOT_INTERNAL_PEER: | |
825 | str = "Invalid command. Not an internal neighbor"; | |
826 | break; | |
827 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
828 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
829 | break; | |
830 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
831 | str = "Local-AS allowed only for EBGP peers"; | |
832 | break; | |
833 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
834 | str = "Cannot have local-as same as BGP AS number"; | |
835 | break; | |
836 | case BGP_ERR_TCPSIG_FAILED: | |
837 | str = "Error while applying TCP-Sig to session(s)"; | |
838 | break; | |
839 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
840 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
841 | break; | |
842 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
843 | str = "ttl-security only allowed for EBGP peers"; | |
844 | break; | |
845 | case BGP_ERR_AS_OVERRIDE: | |
846 | str = "as-override cannot be configured for IBGP peers"; | |
847 | break; | |
848 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
849 | str = "Invalid limit for number of dynamic neighbors"; | |
850 | break; | |
851 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
852 | str = "Dynamic neighbor listen range already exists"; | |
853 | break; | |
854 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
855 | str = "Operation not allowed on a dynamic neighbor"; | |
856 | break; | |
857 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
858 | str = "Operation not allowed on a directly connected neighbor"; | |
859 | break; | |
860 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 861 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 862 | break; |
863 | case BGP_ERR_GR_INVALID_CMD: | |
864 | str = "The Graceful Restart command used is not valid at this moment."; | |
865 | break; | |
866 | case BGP_ERR_GR_OPERATION_FAILED: | |
867 | str = "The Graceful Restart Operation failed due to an err."; | |
868 | break; | |
d62a17ae | 869 | } |
870 | if (str) { | |
871 | vty_out(vty, "%% %s\n", str); | |
872 | return CMD_WARNING_CONFIG_FAILED; | |
873 | } | |
874 | return CMD_SUCCESS; | |
718e3744 | 875 | } |
876 | ||
7aafcaca | 877 | /* BGP clear sort. */ |
d62a17ae | 878 | enum clear_sort { |
879 | clear_all, | |
880 | clear_peer, | |
881 | clear_group, | |
882 | clear_external, | |
883 | clear_as | |
7aafcaca DS |
884 | }; |
885 | ||
1ca2fd11 IR |
886 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
887 | safi_t safi, int error) | |
d62a17ae | 888 | { |
889 | switch (error) { | |
890 | case BGP_ERR_AF_UNCONFIGURED: | |
1ca2fd11 IR |
891 | vty_out(vty, |
892 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
893 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 894 | break; |
895 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
1ca2fd11 IR |
896 | vty_out(vty, |
897 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
d62a17ae | 898 | peer->host); |
899 | break; | |
900 | default: | |
901 | break; | |
902 | } | |
7aafcaca DS |
903 | } |
904 | ||
dc912615 | 905 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 906 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
907 | { |
908 | int ret = 0; | |
2adac256 | 909 | struct peer_af *paf; |
dc912615 DS |
910 | |
911 | /* if afi/.safi not specified, spin thru all of them */ | |
912 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
913 | afi_t tmp_afi; | |
914 | safi_t tmp_safi; | |
0e5cdd59 DS |
915 | enum bgp_af_index index; |
916 | ||
917 | for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { | |
918 | paf = peer->peer_af_array[index]; | |
919 | if (!paf) | |
920 | continue; | |
dc912615 | 921 | |
2adac256 DA |
922 | if (paf && paf->subgroup) |
923 | SET_FLAG(paf->subgroup->sflags, | |
924 | SUBGRP_STATUS_FORCE_UPDATES); | |
925 | ||
0e5cdd59 DS |
926 | tmp_afi = paf->afi; |
927 | tmp_safi = paf->safi; | |
dc912615 DS |
928 | if (!peer->afc[tmp_afi][tmp_safi]) |
929 | continue; | |
930 | ||
931 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 932 | ret = peer_clear(peer, nnode); |
dc912615 DS |
933 | else |
934 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
935 | stype); | |
936 | } | |
937 | /* if afi specified and safi not, spin thru safis on this afi */ | |
938 | } else if (safi == SAFI_UNSPEC) { | |
939 | safi_t tmp_safi; | |
940 | ||
941 | for (tmp_safi = SAFI_UNICAST; | |
942 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
943 | if (!peer->afc[afi][tmp_safi]) | |
944 | continue; | |
945 | ||
2adac256 DA |
946 | paf = peer_af_find(peer, afi, tmp_safi); |
947 | if (paf && paf->subgroup) | |
948 | SET_FLAG(paf->subgroup->sflags, | |
949 | SUBGRP_STATUS_FORCE_UPDATES); | |
950 | ||
dc912615 | 951 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 952 | ret = peer_clear(peer, nnode); |
dc912615 DS |
953 | else |
954 | ret = peer_clear_soft(peer, afi, | |
955 | tmp_safi, stype); | |
956 | } | |
957 | /* both afi/safi specified, let the caller know if not defined */ | |
958 | } else { | |
959 | if (!peer->afc[afi][safi]) | |
960 | return 1; | |
961 | ||
2adac256 DA |
962 | paf = peer_af_find(peer, afi, safi); |
963 | if (paf && paf->subgroup) | |
964 | SET_FLAG(paf->subgroup->sflags, | |
965 | SUBGRP_STATUS_FORCE_UPDATES); | |
966 | ||
dc912615 | 967 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 968 | ret = peer_clear(peer, nnode); |
dc912615 DS |
969 | else |
970 | ret = peer_clear_soft(peer, afi, safi, stype); | |
971 | } | |
972 | ||
973 | return ret; | |
974 | } | |
975 | ||
7aafcaca | 976 | /* `clear ip bgp' functions. */ |
1ca2fd11 | 977 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 978 | enum clear_sort sort, enum bgp_clear_type stype, |
1ca2fd11 | 979 | const char *arg) |
d62a17ae | 980 | { |
dc912615 | 981 | int ret = 0; |
3ae8bfa5 | 982 | bool found = false; |
d62a17ae | 983 | struct peer *peer; |
dc95985f | 984 | |
985 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 986 | |
987 | /* Clear all neighbors. */ | |
988 | /* | |
989 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
990 | * nodes on the BGP instance as that may get freed if it is a |
991 | * doppelganger | |
d62a17ae | 992 | */ |
993 | if (sort == clear_all) { | |
994 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 995 | |
996 | bgp_peer_gr_flags_update(peer); | |
997 | ||
36235319 | 998 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 999 | gr_router_detected = true; |
1000 | ||
c368171c | 1001 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 1002 | stype); |
d62a17ae | 1003 | |
1004 | if (ret < 0) | |
1ca2fd11 | 1005 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
dc95985f | 1006 | } |
1007 | ||
36235319 QY |
1008 | if (gr_router_detected |
1009 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1010 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1011 | } else if (!gr_router_detected |
1012 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1013 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 1014 | } |
d62a17ae | 1015 | |
1016 | /* This is to apply read-only mode on this clear. */ | |
1017 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1018 | bgp->update_delay_over = 0; | |
1019 | ||
1020 | return CMD_SUCCESS; | |
7aafcaca DS |
1021 | } |
1022 | ||
3ae8bfa5 | 1023 | /* Clear specified neighbor. */ |
d62a17ae | 1024 | if (sort == clear_peer) { |
1025 | union sockunion su; | |
d62a17ae | 1026 | |
1027 | /* Make sockunion for lookup. */ | |
1028 | ret = str2sockunion(arg, &su); | |
1029 | if (ret < 0) { | |
1030 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1031 | if (!peer) { | |
1032 | peer = peer_lookup_by_hostname(bgp, arg); | |
1033 | if (!peer) { | |
1ca2fd11 IR |
1034 | vty_out(vty, |
1035 | "Malformed address or name: %s\n", | |
d62a17ae | 1036 | arg); |
1037 | return CMD_WARNING; | |
1038 | } | |
1039 | } | |
1040 | } else { | |
1041 | peer = peer_lookup(bgp, &su); | |
1042 | if (!peer) { | |
1ca2fd11 IR |
1043 | vty_out(vty, |
1044 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
1045 | arg); | |
d62a17ae | 1046 | return CMD_WARNING; |
1047 | } | |
1048 | } | |
7aafcaca | 1049 | |
dc95985f | 1050 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1051 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1052 | ||
dc912615 DS |
1053 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1054 | ||
1055 | /* if afi/safi not defined for this peer, let caller know */ | |
1056 | if (ret == 1) | |
3ae8bfa5 | 1057 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1058 | |
d62a17ae | 1059 | if (ret < 0) |
1ca2fd11 | 1060 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
7aafcaca | 1061 | |
d62a17ae | 1062 | return CMD_SUCCESS; |
7aafcaca | 1063 | } |
7aafcaca | 1064 | |
3ae8bfa5 | 1065 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1066 | if (sort == clear_group) { |
1067 | struct peer_group *group; | |
7aafcaca | 1068 | |
d62a17ae | 1069 | group = peer_group_lookup(bgp, arg); |
1070 | if (!group) { | |
1ca2fd11 | 1071 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); |
d62a17ae | 1072 | return CMD_WARNING; |
1073 | } | |
1074 | ||
1075 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1076 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1077 | |
d62a17ae | 1078 | if (ret < 0) |
1ca2fd11 | 1079 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1080 | else |
1081 | found = true; | |
d62a17ae | 1082 | } |
3ae8bfa5 PM |
1083 | |
1084 | if (!found) | |
1ca2fd11 IR |
1085 | vty_out(vty, |
1086 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 1087 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1088 | |
d62a17ae | 1089 | return CMD_SUCCESS; |
7aafcaca | 1090 | } |
7aafcaca | 1091 | |
3ae8bfa5 | 1092 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1093 | if (sort == clear_external) { |
1094 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1095 | if (peer->sort == BGP_PEER_IBGP) | |
1096 | continue; | |
7aafcaca | 1097 | |
dc95985f | 1098 | bgp_peer_gr_flags_update(peer); |
1099 | ||
36235319 | 1100 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1101 | gr_router_detected = true; |
dc95985f | 1102 | |
c368171c | 1103 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1104 | |
d62a17ae | 1105 | if (ret < 0) |
1ca2fd11 | 1106 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1107 | else |
1108 | found = true; | |
d62a17ae | 1109 | } |
3ae8bfa5 | 1110 | |
36235319 QY |
1111 | if (gr_router_detected |
1112 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1113 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1114 | } else if (!gr_router_detected |
1115 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1116 | bgp_zebra_send_capabilities(bgp, true); |
1117 | } | |
1118 | ||
3ae8bfa5 | 1119 | if (!found) |
1ca2fd11 IR |
1120 | vty_out(vty, |
1121 | "%%BGP: No external %s peer is configured\n", | |
1122 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 1123 | |
d62a17ae | 1124 | return CMD_SUCCESS; |
1125 | } | |
1126 | ||
3ae8bfa5 | 1127 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1128 | if (sort == clear_as) { |
3ae8bfa5 | 1129 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1130 | |
1131 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1132 | if (peer->as != as) | |
1133 | continue; | |
1134 | ||
dc95985f | 1135 | bgp_peer_gr_flags_update(peer); |
1136 | ||
36235319 | 1137 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1138 | gr_router_detected = true; |
dc95985f | 1139 | |
c368171c | 1140 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1141 | |
1142 | if (ret < 0) | |
1ca2fd11 | 1143 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1144 | else |
1145 | found = true; | |
d62a17ae | 1146 | } |
3ae8bfa5 | 1147 | |
36235319 QY |
1148 | if (gr_router_detected |
1149 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1150 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1151 | } else if (!gr_router_detected |
1152 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1153 | bgp_zebra_send_capabilities(bgp, true); |
1154 | } | |
1155 | ||
3ae8bfa5 | 1156 | if (!found) |
1ca2fd11 IR |
1157 | vty_out(vty, |
1158 | "%%BGP: No %s peer is configured with AS %s\n", | |
1159 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1160 | |
d62a17ae | 1161 | return CMD_SUCCESS; |
1162 | } | |
1163 | ||
1164 | return CMD_SUCCESS; | |
1165 | } | |
1166 | ||
1ca2fd11 IR |
1167 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, |
1168 | safi_t safi, enum clear_sort sort, | |
1169 | enum bgp_clear_type stype, const char *arg) | |
d62a17ae | 1170 | { |
1171 | struct bgp *bgp; | |
1172 | ||
1173 | /* BGP structure lookup. */ | |
1174 | if (name) { | |
1175 | bgp = bgp_lookup_by_name(name); | |
1176 | if (bgp == NULL) { | |
1ca2fd11 | 1177 | vty_out(vty, "Can't find BGP instance %s\n", name); |
d62a17ae | 1178 | return CMD_WARNING; |
1179 | } | |
1180 | } else { | |
1181 | bgp = bgp_get_default(); | |
1182 | if (bgp == NULL) { | |
1ca2fd11 | 1183 | vty_out(vty, "No BGP process is configured\n"); |
d62a17ae | 1184 | return CMD_WARNING; |
1185 | } | |
1186 | } | |
1187 | ||
1ca2fd11 | 1188 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); |
7aafcaca DS |
1189 | } |
1190 | ||
1191 | /* clear soft inbound */ | |
1ca2fd11 | 1192 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1193 | { |
99b3ebd3 NS |
1194 | afi_t afi; |
1195 | safi_t safi; | |
1196 | ||
1ca2fd11 IR |
1197 | FOREACH_AFI_SAFI (afi, safi) |
1198 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1199 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1200 | } |
1201 | ||
1202 | /* clear soft outbound */ | |
1ca2fd11 | 1203 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1204 | { |
99b3ebd3 NS |
1205 | afi_t afi; |
1206 | safi_t safi; | |
1207 | ||
1ca2fd11 IR |
1208 | FOREACH_AFI_SAFI (afi, safi) |
1209 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1210 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1211 | } |
1212 | ||
1213 | ||
f787d7a0 | 1214 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1215 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1216 | #endif |
1217 | ||
8029b216 AK |
1218 | DEFUN_HIDDEN (bgp_local_mac, |
1219 | bgp_local_mac_cmd, | |
093e3f23 | 1220 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1221 | BGP_STR |
1222 | "Local MAC config\n" | |
1223 | "VxLAN Network Identifier\n" | |
1224 | "VNI number\n" | |
1225 | "local mac\n" | |
1226 | "mac address\n" | |
1227 | "mac-mobility sequence\n" | |
1228 | "seq number\n") | |
1229 | { | |
1230 | int rv; | |
1231 | vni_t vni; | |
1232 | struct ethaddr mac; | |
1233 | struct ipaddr ip; | |
1234 | uint32_t seq; | |
1235 | struct bgp *bgp; | |
1236 | ||
1237 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1238 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1239 | vty_out(vty, "%% Malformed MAC address\n"); | |
1240 | return CMD_WARNING; | |
1241 | } | |
1242 | memset(&ip, 0, sizeof(ip)); | |
1243 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1244 | ||
1245 | bgp = bgp_get_default(); | |
1246 | if (!bgp) { | |
1247 | vty_out(vty, "Default BGP instance is not there\n"); | |
1248 | return CMD_WARNING; | |
1249 | } | |
1250 | ||
b5e140c8 AK |
1251 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1252 | zero_esi); | |
8029b216 AK |
1253 | if (rv < 0) { |
1254 | vty_out(vty, "Internal error\n"); | |
1255 | return CMD_WARNING; | |
1256 | } | |
1257 | ||
1258 | return CMD_SUCCESS; | |
1259 | } | |
1260 | ||
1261 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1262 | no_bgp_local_mac_cmd, | |
093e3f23 | 1263 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1264 | NO_STR |
1265 | BGP_STR | |
1266 | "Local MAC config\n" | |
1267 | "VxLAN Network Identifier\n" | |
1268 | "VNI number\n" | |
1269 | "local mac\n" | |
1270 | "mac address\n") | |
1271 | { | |
1272 | int rv; | |
1273 | vni_t vni; | |
1274 | struct ethaddr mac; | |
1275 | struct ipaddr ip; | |
1276 | struct bgp *bgp; | |
1277 | ||
1278 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1279 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1280 | vty_out(vty, "%% Malformed MAC address\n"); | |
1281 | return CMD_WARNING; | |
1282 | } | |
1283 | memset(&ip, 0, sizeof(ip)); | |
1284 | ||
1285 | bgp = bgp_get_default(); | |
1286 | if (!bgp) { | |
1287 | vty_out(vty, "Default BGP instance is not there\n"); | |
1288 | return CMD_WARNING; | |
1289 | } | |
1290 | ||
ec0ab544 | 1291 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1292 | if (rv < 0) { |
1293 | vty_out(vty, "Internal error\n"); | |
1294 | return CMD_WARNING; | |
1295 | } | |
1296 | ||
1297 | return CMD_SUCCESS; | |
1298 | } | |
1299 | ||
718e3744 | 1300 | DEFUN (no_synchronization, |
1301 | no_synchronization_cmd, | |
1302 | "no synchronization", | |
1303 | NO_STR | |
1304 | "Perform IGP synchronization\n") | |
1305 | { | |
d62a17ae | 1306 | return CMD_SUCCESS; |
718e3744 | 1307 | } |
1308 | ||
1309 | DEFUN (no_auto_summary, | |
1310 | no_auto_summary_cmd, | |
1311 | "no auto-summary", | |
1312 | NO_STR | |
1313 | "Enable automatic network number summarization\n") | |
1314 | { | |
d62a17ae | 1315 | return CMD_SUCCESS; |
718e3744 | 1316 | } |
3d515fd9 | 1317 | |
718e3744 | 1318 | /* "router bgp" commands. */ |
1ca2fd11 IR |
1319 | DEFUN_NOSH (router_bgp, |
1320 | router_bgp_cmd, | |
1321 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1322 | ROUTER_STR | |
1323 | BGP_STR | |
1324 | AS_STR | |
1325 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1326 | { |
d62a17ae | 1327 | int idx_asn = 2; |
1328 | int idx_view_vrf = 3; | |
1329 | int idx_vrf = 4; | |
1ca2fd11 IR |
1330 | int is_new_bgp = 0; |
1331 | int ret; | |
d62a17ae | 1332 | as_t as; |
1333 | struct bgp *bgp; | |
1334 | const char *name = NULL; | |
1335 | enum bgp_instance_type inst_type; | |
1336 | ||
1337 | // "router bgp" without an ASN | |
1338 | if (argc == 2) { | |
1339 | // Pending: Make VRF option available for ASN less config | |
1abef40f | 1340 | bgp = bgp_get_default(); |
d62a17ae | 1341 | |
1abef40f | 1342 | if (bgp == NULL) { |
d62a17ae | 1343 | vty_out(vty, "%% No BGP process is configured\n"); |
1344 | return CMD_WARNING_CONFIG_FAILED; | |
1345 | } | |
1346 | ||
1347 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1348 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1349 | return CMD_WARNING_CONFIG_FAILED; |
1350 | } | |
1351 | } | |
1352 | ||
1353 | // "router bgp X" | |
1354 | else { | |
ff8a8a7a | 1355 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1ca2fd11 | 1356 | |
d62a17ae | 1357 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1358 | if (argc > 3) { | |
1359 | name = argv[idx_vrf]->arg; | |
1360 | ||
9a8bdf1c PG |
1361 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1362 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1363 | name = NULL; | |
1364 | else | |
1365 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1ca2fd11 | 1366 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
d62a17ae | 1367 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
d62a17ae | 1368 | } |
1369 | ||
1ca2fd11 IR |
1370 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1371 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
3bd70bf8 | 1372 | |
1ca2fd11 IR |
1373 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
1374 | switch (ret) { | |
1375 | case BGP_ERR_AS_MISMATCH: | |
1376 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1377 | return CMD_WARNING_CONFIG_FAILED; | |
1378 | case BGP_ERR_INSTANCE_MISMATCH: | |
1379 | vty_out(vty, | |
1380 | "BGP instance name and AS number mismatch\n"); | |
1381 | vty_out(vty, | |
1382 | "BGP instance is already running; AS is %u\n", | |
1383 | as); | |
1384 | return CMD_WARNING_CONFIG_FAILED; | |
ff8a8a7a | 1385 | } |
1ca2fd11 IR |
1386 | |
1387 | /* | |
1388 | * If we just instantiated the default instance, complete | |
1389 | * any pending VRF-VPN leaking that was configured via | |
1390 | * earlier "router bgp X vrf FOO" blocks. | |
1391 | */ | |
1392 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1393 | vpn_leak_postchange_all(); | |
1394 | ||
1395 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1396 | bgp_vpn_leak_export(bgp); | |
1397 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1398 | */ | |
d62a17ae | 1399 | } |
1400 | ||
1ca2fd11 IR |
1401 | /* unset the auto created flag as the user config is now present */ |
1402 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1403 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1404 | ||
1405 | return CMD_SUCCESS; | |
718e3744 | 1406 | } |
1407 | ||
718e3744 | 1408 | /* "no router bgp" commands. */ |
1ca2fd11 IR |
1409 | DEFUN (no_router_bgp, |
1410 | no_router_bgp_cmd, | |
1411 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1412 | NO_STR | |
1413 | ROUTER_STR | |
1414 | BGP_STR | |
1415 | AS_STR | |
1416 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1417 | { |
4fd9919e | 1418 | int idx_asn = 3; |
d62a17ae | 1419 | int idx_vrf = 5; |
1ca2fd11 | 1420 | as_t as; |
4fd9919e | 1421 | struct bgp *bgp; |
d62a17ae | 1422 | const char *name = NULL; |
718e3744 | 1423 | |
d62a17ae | 1424 | // "no router bgp" without an ASN |
1425 | if (argc == 3) { | |
1426 | // Pending: Make VRF option available for ASN less config | |
8382083a | 1427 | bgp = bgp_get_default(); |
718e3744 | 1428 | |
8382083a | 1429 | if (bgp == NULL) { |
d62a17ae | 1430 | vty_out(vty, "%% No BGP process is configured\n"); |
1431 | return CMD_WARNING_CONFIG_FAILED; | |
1432 | } | |
7fb21a9f | 1433 | |
d62a17ae | 1434 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1435 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1436 | return CMD_WARNING_CONFIG_FAILED; |
1437 | } | |
4fd9919e | 1438 | |
4fd9919e IR |
1439 | if (bgp->l3vni) { |
1440 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1441 | bgp->l3vni); | |
1442 | return CMD_WARNING_CONFIG_FAILED; | |
1443 | } | |
d62a17ae | 1444 | } else { |
4fd9919e IR |
1445 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1446 | ||
1ca42c8d | 1447 | if (argc > 4) { |
d62a17ae | 1448 | name = argv[idx_vrf]->arg; |
1ca42c8d IR |
1449 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") |
1450 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1451 | name = NULL; | |
1452 | } | |
7fb21a9f | 1453 | |
4fd9919e IR |
1454 | /* Lookup bgp structure. */ |
1455 | bgp = bgp_lookup(as, name); | |
1456 | if (!bgp) { | |
1457 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1458 | return CMD_WARNING_CONFIG_FAILED; | |
1459 | } | |
1460 | ||
1461 | if (bgp->l3vni) { | |
1462 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1463 | bgp->l3vni); | |
1464 | return CMD_WARNING_CONFIG_FAILED; | |
1465 | } | |
1466 | ||
1467 | /* Cannot delete default instance if vrf instances exist */ | |
1468 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1469 | struct listnode *node; | |
1470 | struct bgp *tmp_bgp; | |
1471 | ||
1472 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1473 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1474 | continue; | |
1475 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1476 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1477 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1478 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1479 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1480 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1481 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1482 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1483 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1484 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1485 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1486 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1487 | (bgp == bgp_get_evpn() && | |
1488 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1489 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1490 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1491 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1492 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1493 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1494 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1495 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
1496 | (tmp_bgp->vnihash && hashcount(tmp_bgp->vnihash))) { | |
1497 | vty_out(vty, | |
1498 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1499 | return CMD_WARNING_CONFIG_FAILED; | |
1500 | } | |
1501 | } | |
1502 | } | |
d62a17ae | 1503 | } |
718e3744 | 1504 | |
1ca2fd11 | 1505 | bgp_delete(bgp); |
718e3744 | 1506 | |
1ca2fd11 | 1507 | return CMD_SUCCESS; |
718e3744 | 1508 | } |
1509 | ||
718e3744 | 1510 | |
ff8a8a7a CS |
1511 | /* BGP router-id. */ |
1512 | ||
1ca2fd11 IR |
1513 | DEFPY (bgp_router_id, |
1514 | bgp_router_id_cmd, | |
1515 | "bgp router-id A.B.C.D", | |
1516 | BGP_STR | |
1517 | "Override configured router identifier\n" | |
1518 | "Manually configured router identifier\n") | |
718e3744 | 1519 | { |
1ca2fd11 IR |
1520 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1521 | bgp_router_id_static_set(bgp, router_id); | |
1522 | return CMD_SUCCESS; | |
ff8a8a7a | 1523 | } |
718e3744 | 1524 | |
1ca2fd11 IR |
1525 | DEFPY (no_bgp_router_id, |
1526 | no_bgp_router_id_cmd, | |
1527 | "no bgp router-id [A.B.C.D]", | |
1528 | NO_STR | |
1529 | BGP_STR | |
1530 | "Override configured router identifier\n" | |
1531 | "Manually configured router identifier\n") | |
ff8a8a7a | 1532 | { |
1ca2fd11 | 1533 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1534 | |
1ca2fd11 IR |
1535 | if (router_id_str) { |
1536 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1537 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1538 | return CMD_WARNING_CONFIG_FAILED; | |
1539 | } | |
1540 | } | |
718e3744 | 1541 | |
1ca2fd11 IR |
1542 | router_id.s_addr = 0; |
1543 | bgp_router_id_static_set(bgp, router_id); | |
1544 | ||
1545 | return CMD_SUCCESS; | |
ff8a8a7a | 1546 | } |
6b0655a2 | 1547 | |
ed0e57e3 | 1548 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
b4ad2fae | 1549 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", |
ed0e57e3 DA |
1550 | NO_STR BGP_STR |
1551 | "Add community specific parameters\n" | |
1552 | "Create an alias for a community\n" | |
1553 | "Community (AA:BB or AA:BB:CC)\n" | |
1554 | "Alias name\n") | |
1555 | { | |
1556 | struct community_alias ca1; | |
1557 | struct community_alias ca2; | |
1558 | struct community_alias *lookup_community; | |
1559 | struct community_alias *lookup_alias; | |
1560 | ||
1561 | if (!community_str2com(community) && !lcommunity_str2com(community)) { | |
1562 | vty_out(vty, "Invalid community format\n"); | |
1563 | return CMD_WARNING; | |
1564 | } | |
1565 | ||
1566 | memset(&ca1, 0, sizeof(ca1)); | |
1567 | memset(&ca2, 0, sizeof(ca2)); | |
1568 | strlcpy(ca1.community, community, sizeof(ca1.community)); | |
b4ad2fae | 1569 | strlcpy(ca1.alias, alias_name, sizeof(ca1.alias)); |
ed0e57e3 DA |
1570 | |
1571 | lookup_community = bgp_ca_community_lookup(&ca1); | |
1572 | lookup_alias = bgp_ca_alias_lookup(&ca1); | |
1573 | ||
1574 | if (no) { | |
1575 | bgp_ca_alias_delete(&ca1); | |
1576 | bgp_ca_community_delete(&ca1); | |
1577 | } else { | |
1578 | if (lookup_alias) { | |
1579 | /* Lookup if community hash table has an item | |
1580 | * with the same alias name. | |
1581 | */ | |
1582 | strlcpy(ca2.community, lookup_alias->community, | |
1583 | sizeof(ca2.community)); | |
1584 | if (bgp_ca_community_lookup(&ca2)) { | |
1585 | vty_out(vty, | |
1586 | "community (%s) already has this alias (%s)\n", | |
1587 | lookup_alias->community, | |
1588 | lookup_alias->alias); | |
1589 | return CMD_WARNING; | |
1590 | } | |
1591 | bgp_ca_alias_delete(&ca1); | |
1592 | } | |
1593 | ||
1594 | if (lookup_community) | |
1595 | bgp_ca_community_delete(&ca1); | |
1596 | ||
1597 | bgp_ca_alias_insert(&ca1); | |
1598 | bgp_ca_community_insert(&ca1); | |
1599 | } | |
1600 | ||
1601 | return CMD_SUCCESS; | |
1602 | } | |
1603 | ||
9acb67cb DS |
1604 | DEFPY (bgp_global_suppress_fib_pending, |
1605 | bgp_global_suppress_fib_pending_cmd, | |
1606 | "[no] bgp suppress-fib-pending", | |
1607 | NO_STR | |
1608 | BGP_STR | |
1609 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1610 | { | |
1611 | bm_wait_for_fib_set(!no); | |
1612 | ||
1613 | return CMD_SUCCESS; | |
1614 | } | |
1615 | ||
c208c586 S |
1616 | DEFPY (bgp_suppress_fib_pending, |
1617 | bgp_suppress_fib_pending_cmd, | |
1618 | "[no] bgp suppress-fib-pending", | |
1619 | NO_STR | |
1620 | BGP_STR | |
1621 | "Advertise only routes that are programmed in kernel to peers\n") | |
1622 | { | |
1623 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1624 | ||
1625 | bgp_suppress_fib_pending_set(bgp, !no); | |
1626 | return CMD_SUCCESS; | |
1627 | } | |
1628 | ||
1629 | ||
718e3744 | 1630 | /* BGP Cluster ID. */ |
1ca2fd11 IR |
1631 | DEFUN (bgp_cluster_id, |
1632 | bgp_cluster_id_cmd, | |
1633 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1634 | BGP_STR | |
1635 | "Configure Route-Reflector Cluster-id\n" | |
1636 | "Route-Reflector Cluster-id in IP address format\n" | |
1637 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1638 | { |
1ca2fd11 | 1639 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1640 | int idx_ipv4 = 2; |
1ca2fd11 IR |
1641 | int ret; |
1642 | struct in_addr cluster; | |
1643 | ||
1644 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1645 | if (!ret) { | |
1646 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1647 | return CMD_WARNING_CONFIG_FAILED; | |
1648 | } | |
718e3744 | 1649 | |
1ca2fd11 IR |
1650 | bgp_cluster_id_set(bgp, &cluster); |
1651 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1652 | |
1ca2fd11 | 1653 | return CMD_SUCCESS; |
718e3744 | 1654 | } |
1655 | ||
1ca2fd11 IR |
1656 | DEFUN (no_bgp_cluster_id, |
1657 | no_bgp_cluster_id_cmd, | |
1658 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1659 | NO_STR | |
1660 | BGP_STR | |
1661 | "Configure Route-Reflector Cluster-id\n" | |
1662 | "Route-Reflector Cluster-id in IP address format\n" | |
1663 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1664 | { |
1ca2fd11 IR |
1665 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1666 | bgp_cluster_id_unset(bgp); | |
1667 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1668 | |
1ca2fd11 | 1669 | return CMD_SUCCESS; |
718e3744 | 1670 | } |
1671 | ||
c163f297 DS |
1672 | DEFPY (bgp_norib, |
1673 | bgp_norib_cmd, | |
1674 | "bgp no-rib", | |
1675 | BGP_STR | |
1676 | "Disable BGP route installation to RIB (Zebra)\n") | |
1677 | { | |
1678 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1679 | vty_out(vty, | |
1680 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1681 | return CMD_SUCCESS; | |
1682 | } | |
1683 | ||
1684 | bgp_option_norib_set_runtime(); | |
1685 | ||
1686 | return CMD_SUCCESS; | |
1687 | } | |
1688 | ||
1689 | DEFPY (no_bgp_norib, | |
1690 | no_bgp_norib_cmd, | |
1691 | "no bgp no-rib", | |
1692 | NO_STR | |
1693 | BGP_STR | |
1694 | "Disable BGP route installation to RIB (Zebra)\n") | |
1695 | { | |
1696 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1697 | vty_out(vty, | |
1698 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1699 | return CMD_SUCCESS; | |
1700 | } | |
1701 | ||
1702 | bgp_option_norib_unset_runtime(); | |
1703 | ||
1704 | return CMD_SUCCESS; | |
1705 | } | |
1706 | ||
e46723a5 DS |
1707 | DEFPY (no_bgp_send_extra_data, |
1708 | no_bgp_send_extra_data_cmd, | |
1709 | "[no] bgp send-extra-data zebra", | |
1710 | NO_STR | |
1711 | BGP_STR | |
1712 | "Extra data to Zebra for display/use\n" | |
1713 | "To zebra\n") | |
1714 | { | |
ec0acb80 DA |
1715 | if (no) |
1716 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1717 | else | |
1718 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1719 | |
1720 | return CMD_SUCCESS; | |
1721 | } | |
1722 | ||
1ca2fd11 IR |
1723 | DEFUN (bgp_confederation_identifier, |
1724 | bgp_confederation_identifier_cmd, | |
1725 | "bgp confederation identifier (1-4294967295)", | |
e9273987 | 1726 | BGP_STR |
1ca2fd11 IR |
1727 | "AS confederation parameters\n" |
1728 | "AS number\n" | |
1729 | "Set routing domain confederation AS\n") | |
718e3744 | 1730 | { |
1ca2fd11 | 1731 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1732 | int idx_number = 3; |
1ca2fd11 | 1733 | as_t as; |
718e3744 | 1734 | |
1ca2fd11 | 1735 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1736 | |
1ca2fd11 | 1737 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1738 | |
1ca2fd11 | 1739 | return CMD_SUCCESS; |
718e3744 | 1740 | } |
1741 | ||
1ca2fd11 IR |
1742 | DEFUN (no_bgp_confederation_identifier, |
1743 | no_bgp_confederation_identifier_cmd, | |
1744 | "no bgp confederation identifier [(1-4294967295)]", | |
1745 | NO_STR | |
e9273987 | 1746 | BGP_STR |
1ca2fd11 IR |
1747 | "AS confederation parameters\n" |
1748 | "AS number\n" | |
1749 | "Set routing domain confederation AS\n") | |
ff8a8a7a | 1750 | { |
1ca2fd11 IR |
1751 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1752 | bgp_confederation_id_unset(bgp); | |
1753 | ||
1754 | return CMD_SUCCESS; | |
ff8a8a7a CS |
1755 | } |
1756 | ||
1ca2fd11 IR |
1757 | DEFUN (bgp_confederation_peers, |
1758 | bgp_confederation_peers_cmd, | |
1759 | "bgp confederation peers (1-4294967295)...", | |
e9273987 | 1760 | BGP_STR |
1ca2fd11 IR |
1761 | "AS confederation parameters\n" |
1762 | "Peer ASs in BGP confederation\n" | |
1763 | AS_STR) | |
718e3744 | 1764 | { |
1ca2fd11 | 1765 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1766 | int idx_asn = 3; |
1ca2fd11 | 1767 | as_t as; |
d62a17ae | 1768 | int i; |
718e3744 | 1769 | |
1ca2fd11 IR |
1770 | for (i = idx_asn; i < argc; i++) { |
1771 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1772 | |
1ca2fd11 IR |
1773 | if (bgp->as == as) { |
1774 | vty_out(vty, | |
1775 | "%% Local member-AS not allowed in confed peer list\n"); | |
1776 | continue; | |
1777 | } | |
1778 | ||
1779 | bgp_confederation_peers_add(bgp, as); | |
1780 | } | |
1781 | return CMD_SUCCESS; | |
718e3744 | 1782 | } |
1783 | ||
1ca2fd11 IR |
1784 | DEFUN (no_bgp_confederation_peers, |
1785 | no_bgp_confederation_peers_cmd, | |
1786 | "no bgp confederation peers (1-4294967295)...", | |
1787 | NO_STR | |
e9273987 | 1788 | BGP_STR |
1ca2fd11 IR |
1789 | "AS confederation parameters\n" |
1790 | "Peer ASs in BGP confederation\n" | |
1791 | AS_STR) | |
718e3744 | 1792 | { |
1ca2fd11 | 1793 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1794 | int idx_asn = 4; |
1ca2fd11 | 1795 | as_t as; |
d62a17ae | 1796 | int i; |
718e3744 | 1797 | |
1ca2fd11 IR |
1798 | for (i = idx_asn; i < argc; i++) { |
1799 | as = strtoul(argv[i]->arg, NULL, 10); | |
ff8a8a7a | 1800 | |
1ca2fd11 IR |
1801 | bgp_confederation_peers_remove(bgp, as); |
1802 | } | |
1803 | return CMD_SUCCESS; | |
718e3744 | 1804 | } |
6b0655a2 | 1805 | |
5e242b0d DS |
1806 | /** |
1807 | * Central routine for maximum-paths configuration. | |
1808 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1809 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1810 | */ | |
585f1adc IR |
1811 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1812 | const char *mpaths, uint16_t options, | |
1813 | int set) | |
d62a17ae | 1814 | { |
585f1adc IR |
1815 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1816 | uint16_t maxpaths = 0; | |
d62a17ae | 1817 | int ret; |
585f1adc IR |
1818 | afi_t afi; |
1819 | safi_t safi; | |
1820 | ||
1821 | afi = bgp_node_afi(vty); | |
1822 | safi = bgp_node_safi(vty); | |
d62a17ae | 1823 | |
1824 | if (set) { | |
585f1adc | 1825 | maxpaths = strtol(mpaths, NULL, 10); |
d62a17ae | 1826 | if (maxpaths > multipath_num) { |
585f1adc | 1827 | vty_out(vty, |
d62a17ae | 1828 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1829 | maxpaths, multipath_num); | |
1830 | return CMD_WARNING_CONFIG_FAILED; | |
1831 | } | |
1832 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1833 | options); | |
1834 | } else | |
1835 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1836 | ||
1837 | if (ret < 0) { | |
585f1adc | 1838 | vty_out(vty, |
d62a17ae | 1839 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1840 | (set == 1) ? "" : "un", | |
1841 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1842 | maxpaths, afi, safi); | |
1843 | return CMD_WARNING_CONFIG_FAILED; | |
1844 | } | |
1845 | ||
1846 | bgp_recalculate_all_bestpaths(bgp); | |
1847 | ||
1848 | return CMD_SUCCESS; | |
165b5fff JB |
1849 | } |
1850 | ||
1ca2fd11 IR |
1851 | DEFUN (bgp_maxmed_admin, |
1852 | bgp_maxmed_admin_cmd, | |
1853 | "bgp max-med administrative ", | |
1854 | BGP_STR | |
1855 | "Advertise routes with max-med\n" | |
1856 | "Administratively applied, for an indefinite period\n") | |
abc920f8 | 1857 | { |
1ca2fd11 | 1858 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1859 | |
1ca2fd11 IR |
1860 | bgp->v_maxmed_admin = 1; |
1861 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
ff8a8a7a | 1862 | |
1ca2fd11 | 1863 | bgp_maxmed_update(bgp); |
abc920f8 | 1864 | |
1ca2fd11 | 1865 | return CMD_SUCCESS; |
ff8a8a7a CS |
1866 | } |
1867 | ||
1ca2fd11 IR |
1868 | DEFUN (bgp_maxmed_admin_medv, |
1869 | bgp_maxmed_admin_medv_cmd, | |
1870 | "bgp max-med administrative (0-4294967295)", | |
1871 | BGP_STR | |
1872 | "Advertise routes with max-med\n" | |
1873 | "Administratively applied, for an indefinite period\n" | |
1874 | "Max MED value to be used\n") | |
abc920f8 | 1875 | { |
1ca2fd11 | 1876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1877 | int idx_number = 3; |
abc920f8 | 1878 | |
1ca2fd11 IR |
1879 | bgp->v_maxmed_admin = 1; |
1880 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1881 | |
1ca2fd11 | 1882 | bgp_maxmed_update(bgp); |
abc920f8 | 1883 | |
1ca2fd11 | 1884 | return CMD_SUCCESS; |
abc920f8 DS |
1885 | } |
1886 | ||
1ca2fd11 IR |
1887 | DEFUN (no_bgp_maxmed_admin, |
1888 | no_bgp_maxmed_admin_cmd, | |
1889 | "no bgp max-med administrative [(0-4294967295)]", | |
1890 | NO_STR | |
1891 | BGP_STR | |
1892 | "Advertise routes with max-med\n" | |
1893 | "Administratively applied, for an indefinite period\n" | |
1894 | "Max MED value to be used\n") | |
abc920f8 | 1895 | { |
1ca2fd11 IR |
1896 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1897 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1898 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1899 | bgp_maxmed_update(bgp); | |
ff8a8a7a | 1900 | |
1ca2fd11 | 1901 | return CMD_SUCCESS; |
abc920f8 DS |
1902 | } |
1903 | ||
1ca2fd11 IR |
1904 | DEFUN (bgp_maxmed_onstartup, |
1905 | bgp_maxmed_onstartup_cmd, | |
1906 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1907 | BGP_STR | |
1908 | "Advertise routes with max-med\n" | |
1909 | "Effective on a startup\n" | |
1910 | "Time (seconds) period for max-med\n" | |
1911 | "Max MED value to be used\n") | |
abc920f8 | 1912 | { |
1ca2fd11 | 1913 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1914 | int idx = 0; |
4668a151 | 1915 | |
d62a17ae | 1916 | argv_find(argv, argc, "(5-86400)", &idx); |
1ca2fd11 | 1917 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 1918 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
1ca2fd11 | 1919 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 1920 | else |
1ca2fd11 | 1921 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 | 1922 | |
1ca2fd11 IR |
1923 | bgp_maxmed_update(bgp); |
1924 | ||
1925 | return CMD_SUCCESS; | |
abc920f8 DS |
1926 | } |
1927 | ||
1ca2fd11 IR |
1928 | DEFUN (no_bgp_maxmed_onstartup, |
1929 | no_bgp_maxmed_onstartup_cmd, | |
1930 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1931 | NO_STR | |
1932 | BGP_STR | |
1933 | "Advertise routes with max-med\n" | |
1934 | "Effective on a startup\n" | |
1935 | "Time (seconds) period for max-med\n" | |
1936 | "Max MED value to be used\n") | |
abc920f8 | 1937 | { |
1ca2fd11 IR |
1938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1939 | ||
1940 | /* Cancel max-med onstartup if its on */ | |
1941 | if (bgp->t_maxmed_onstartup) { | |
1942 | thread_cancel(&bgp->t_maxmed_onstartup); | |
1943 | bgp->maxmed_onstartup_over = 1; | |
1944 | } | |
abc920f8 | 1945 | |
1ca2fd11 IR |
1946 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1947 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1948 | |
1ca2fd11 IR |
1949 | bgp_maxmed_update(bgp); |
1950 | ||
1951 | return CMD_SUCCESS; | |
abc920f8 DS |
1952 | } |
1953 | ||
d70583f7 D |
1954 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1955 | uint16_t update_delay, | |
1956 | uint16_t establish_wait) | |
1957 | { | |
1958 | struct listnode *node, *nnode; | |
1959 | struct bgp *bgp; | |
1960 | bool vrf_cfg = false; | |
1961 | ||
1962 | /* | |
1963 | * See if update-delay is set per-vrf and warn user to delete it | |
1964 | * Note that we only need to check this if this is the first time | |
1965 | * setting the global config. | |
1966 | */ | |
1967 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1968 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1969 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1970 | vty_out(vty, | |
1971 | "%% update-delay configuration found in vrf %s\n", | |
1972 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1973 | ? VRF_DEFAULT_NAME | |
1974 | : bgp->name); | |
1975 | vrf_cfg = true; | |
1976 | } | |
1977 | } | |
1978 | } | |
1979 | ||
1980 | if (vrf_cfg) { | |
1981 | vty_out(vty, | |
1982 | "%%Failed: global update-delay config not permitted\n"); | |
1983 | return CMD_WARNING; | |
1984 | } | |
1985 | ||
1986 | if (!establish_wait) { /* update-delay <delay> */ | |
1987 | bm->v_update_delay = update_delay; | |
1988 | bm->v_establish_wait = bm->v_update_delay; | |
1989 | } else { | |
1990 | /* update-delay <delay> <establish-wait> */ | |
1991 | if (update_delay < establish_wait) { | |
1992 | vty_out(vty, | |
1993 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1994 | return CMD_WARNING_CONFIG_FAILED; | |
1995 | } | |
1996 | ||
1997 | bm->v_update_delay = update_delay; | |
1998 | bm->v_establish_wait = establish_wait; | |
1999 | } | |
2000 | ||
2001 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2002 | bgp->v_update_delay = bm->v_update_delay; | |
2003 | bgp->v_establish_wait = bm->v_establish_wait; | |
2004 | } | |
2005 | ||
2006 | return CMD_SUCCESS; | |
2007 | } | |
2008 | ||
2009 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2010 | { | |
2011 | struct listnode *node, *nnode; | |
2012 | struct bgp *bgp; | |
2013 | ||
2014 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2015 | bm->v_establish_wait = bm->v_update_delay; | |
2016 | ||
2017 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2018 | bgp->v_update_delay = bm->v_update_delay; | |
2019 | bgp->v_establish_wait = bm->v_establish_wait; | |
2020 | } | |
2021 | ||
2022 | return CMD_SUCCESS; | |
2023 | } | |
2024 | ||
2025 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2026 | uint16_t establish_wait) | |
f188f2c4 | 2027 | { |
d62a17ae | 2028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2029 | |
d70583f7 D |
2030 | /* if configured globally, per-instance config is not allowed */ |
2031 | if (bm->v_update_delay) { | |
2032 | vty_out(vty, | |
2033 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2034 | return CMD_WARNING_CONFIG_FAILED; | |
2035 | } | |
2036 | ||
f188f2c4 | 2037 | |
d70583f7 | 2038 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2039 | { |
2040 | bgp->v_update_delay = update_delay; | |
2041 | bgp->v_establish_wait = bgp->v_update_delay; | |
2042 | return CMD_SUCCESS; | |
2043 | } | |
f188f2c4 | 2044 | |
d62a17ae | 2045 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2046 | if (update_delay < establish_wait) { |
2047 | vty_out(vty, | |
2048 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2049 | return CMD_WARNING_CONFIG_FAILED; | |
2050 | } | |
f188f2c4 | 2051 | |
d62a17ae | 2052 | bgp->v_update_delay = update_delay; |
2053 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2054 | |
d62a17ae | 2055 | return CMD_SUCCESS; |
f188f2c4 DS |
2056 | } |
2057 | ||
d62a17ae | 2058 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2059 | { |
d62a17ae | 2060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2061 | |
d70583f7 D |
2062 | /* If configured globally, cannot remove from one bgp instance */ |
2063 | if (bm->v_update_delay) { | |
2064 | vty_out(vty, | |
2065 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2066 | return CMD_WARNING_CONFIG_FAILED; | |
2067 | } | |
d62a17ae | 2068 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2069 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2070 | |
d62a17ae | 2071 | return CMD_SUCCESS; |
f188f2c4 DS |
2072 | } |
2073 | ||
2b791107 | 2074 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2075 | { |
d70583f7 D |
2076 | /* If configured globally, no need to display per-instance value */ |
2077 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2078 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2079 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2080 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2081 | vty_out(vty, "\n"); | |
2082 | } | |
f188f2c4 DS |
2083 | } |
2084 | ||
d70583f7 D |
2085 | /* Global update-delay configuration */ |
2086 | DEFPY (bgp_global_update_delay, | |
2087 | bgp_global_update_delay_cmd, | |
2088 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2089 | BGP_STR | |
2090 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2091 | "Max delay in seconds\n" | |
2092 | "Establish wait in seconds\n") | |
2093 | { | |
2094 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2095 | } | |
f188f2c4 | 2096 | |
d70583f7 D |
2097 | /* Global update-delay deconfiguration */ |
2098 | DEFPY (no_bgp_global_update_delay, | |
2099 | no_bgp_global_update_delay_cmd, | |
2100 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2101 | NO_STR | |
2102 | BGP_STR | |
f188f2c4 | 2103 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2104 | "Max delay in seconds\n" |
2105 | "Establish wait in seconds\n") | |
f188f2c4 | 2106 | { |
d70583f7 | 2107 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2108 | } |
2109 | ||
d70583f7 D |
2110 | /* Update-delay configuration */ |
2111 | ||
2112 | DEFPY (bgp_update_delay, | |
2113 | bgp_update_delay_cmd, | |
2114 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2115 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2116 | "Max delay in seconds\n" |
2117 | "Establish wait in seconds\n") | |
f188f2c4 | 2118 | { |
d70583f7 | 2119 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2120 | } |
2121 | ||
2122 | /* Update-delay deconfiguration */ | |
d70583f7 | 2123 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2124 | no_bgp_update_delay_cmd, |
838758ac DW |
2125 | "no update-delay [(0-3600) [(1-3600)]]", |
2126 | NO_STR | |
f188f2c4 | 2127 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2128 | "Max delay in seconds\n" |
2129 | "Establish wait in seconds\n") | |
f188f2c4 | 2130 | { |
d62a17ae | 2131 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2132 | } |
2133 | ||
5e242b0d | 2134 | |
1ca2fd11 IR |
2135 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2136 | bool set) | |
cb1faec9 | 2137 | { |
1ca2fd11 IR |
2138 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2139 | ||
8fa7732f QY |
2140 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2141 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2142 | |
2143 | return CMD_SUCCESS; | |
2144 | } | |
2145 | ||
1ca2fd11 IR |
2146 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2147 | bool set) | |
555e09d4 | 2148 | { |
1ca2fd11 IR |
2149 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2150 | ||
8fa7732f QY |
2151 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2152 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2153 | |
d62a17ae | 2154 | return CMD_SUCCESS; |
cb1faec9 DS |
2155 | } |
2156 | ||
2b791107 | 2157 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2158 | { |
555e09d4 QY |
2159 | uint32_t quanta = |
2160 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2161 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2162 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2163 | } |
2164 | ||
555e09d4 QY |
2165 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2166 | { | |
2167 | uint32_t quanta = | |
2168 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2169 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2170 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2171 | } |
cb1faec9 | 2172 | |
8fa7732f QY |
2173 | /* Packet quanta configuration |
2174 | * | |
2175 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2176 | * thread. When changing these limits be careful to prevent stack overflow. | |
2177 | * | |
2178 | * Furthermore, the maximums used here should correspond to | |
2179 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2180 | */ | |
1ca2fd11 IR |
2181 | DEFPY (bgp_wpkt_quanta, |
2182 | bgp_wpkt_quanta_cmd, | |
2183 | "[no] write-quanta (1-64)$quanta", | |
2184 | NO_STR | |
2185 | "How many packets to write to peer socket per run\n" | |
2186 | "Number of packets\n") | |
2187 | { | |
2188 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2189 | } | |
cb1faec9 | 2190 | |
1ca2fd11 IR |
2191 | DEFPY (bgp_rpkt_quanta, |
2192 | bgp_rpkt_quanta_cmd, | |
2193 | "[no] read-quanta (1-10)$quanta", | |
2194 | NO_STR | |
2195 | "How many packets to read from peer socket per I/O cycle\n" | |
2196 | "Number of packets\n") | |
2197 | { | |
2198 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
555e09d4 QY |
2199 | } |
2200 | ||
2b791107 | 2201 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2202 | { |
37a333fe | 2203 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2204 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2205 | } |
2206 | ||
4668a151 | 2207 | |
1ca2fd11 IR |
2208 | DEFUN (bgp_coalesce_time, |
2209 | bgp_coalesce_time_cmd, | |
2210 | "coalesce-time (0-4294967295)", | |
2211 | "Subgroup coalesce timer\n" | |
2212 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2213 | { |
1ca2fd11 | 2214 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 2215 | |
1ca2fd11 | 2216 | int idx = 0; |
d62a17ae | 2217 | argv_find(argv, argc, "(0-4294967295)", &idx); |
1ca2fd11 IR |
2218 | bgp->heuristic_coalesce = false; |
2219 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2220 | return CMD_SUCCESS; | |
3f9c7369 DS |
2221 | } |
2222 | ||
1ca2fd11 IR |
2223 | DEFUN (no_bgp_coalesce_time, |
2224 | no_bgp_coalesce_time_cmd, | |
2225 | "no coalesce-time (0-4294967295)", | |
2226 | NO_STR | |
2227 | "Subgroup coalesce timer\n" | |
2228 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2229 | { |
1ca2fd11 | 2230 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 2231 | |
1ca2fd11 IR |
2232 | bgp->heuristic_coalesce = true; |
2233 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2234 | return CMD_SUCCESS; | |
3f9c7369 DS |
2235 | } |
2236 | ||
5e242b0d | 2237 | /* Maximum-paths configuration */ |
585f1adc IR |
2238 | DEFUN (bgp_maxpaths, |
2239 | bgp_maxpaths_cmd, | |
2240 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2241 | "Forward packets over multiple paths\n" | |
2242 | "Number of paths\n") | |
5e242b0d | 2243 | { |
d62a17ae | 2244 | int idx_number = 1; |
585f1adc IR |
2245 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, |
2246 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2247 | } |
2248 | ||
d62a17ae | 2249 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2250 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2251 | "Forward packets over multiple paths\n" | |
2252 | "Number of paths\n") | |
596c17ba | 2253 | |
585f1adc IR |
2254 | DEFUN (bgp_maxpaths_ibgp, |
2255 | bgp_maxpaths_ibgp_cmd, | |
2256 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2257 | "Forward packets over multiple paths\n" | |
2258 | "iBGP-multipath\n" | |
2259 | "Number of paths\n") | |
165b5fff | 2260 | { |
d62a17ae | 2261 | int idx_number = 2; |
585f1adc IR |
2262 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2263 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2264 | } |
165b5fff | 2265 | |
d62a17ae | 2266 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2267 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2268 | "Forward packets over multiple paths\n" | |
2269 | "iBGP-multipath\n" | |
2270 | "Number of paths\n") | |
596c17ba | 2271 | |
585f1adc IR |
2272 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2273 | bgp_maxpaths_ibgp_cluster_cmd, | |
2274 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2275 | "Forward packets over multiple paths\n" | |
2276 | "iBGP-multipath\n" | |
2277 | "Number of paths\n" | |
2278 | "Match the cluster length\n") | |
5e242b0d | 2279 | { |
d62a17ae | 2280 | int idx_number = 2; |
585f1adc IR |
2281 | return bgp_maxpaths_config_vty( |
2282 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
2283 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
2284 | } |
2285 | ||
d62a17ae | 2286 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2287 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2288 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2289 | "Forward packets over multiple paths\n" | |
2290 | "iBGP-multipath\n" | |
2291 | "Number of paths\n" | |
2292 | "Match the cluster length\n") | |
596c17ba | 2293 | |
585f1adc IR |
2294 | DEFUN (no_bgp_maxpaths, |
2295 | no_bgp_maxpaths_cmd, | |
2296 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2297 | NO_STR | |
2298 | "Forward packets over multiple paths\n" | |
2299 | "Number of paths\n") | |
165b5fff | 2300 | { |
585f1adc | 2301 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2302 | } |
2303 | ||
d62a17ae | 2304 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2305 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2306 | "Forward packets over multiple paths\n" |
2307 | "Number of paths\n") | |
596c17ba | 2308 | |
585f1adc IR |
2309 | DEFUN (no_bgp_maxpaths_ibgp, |
2310 | no_bgp_maxpaths_ibgp_cmd, | |
2311 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2312 | NO_STR | |
2313 | "Forward packets over multiple paths\n" | |
2314 | "iBGP-multipath\n" | |
2315 | "Number of paths\n" | |
2316 | "Match the cluster length\n") | |
165b5fff | 2317 | { |
585f1adc | 2318 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2319 | } |
2320 | ||
d62a17ae | 2321 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2322 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2323 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2324 | NO_STR | |
2325 | "Forward packets over multiple paths\n" | |
2326 | "iBGP-multipath\n" | |
2327 | "Number of paths\n" | |
2328 | "Match the cluster length\n") | |
596c17ba | 2329 | |
dd65f45e DL |
2330 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2331 | afi_t afi, safi_t safi) | |
165b5fff | 2332 | { |
00908b7a | 2333 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2334 | vty_out(vty, " maximum-paths %d\n", |
2335 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2336 | } | |
165b5fff | 2337 | |
00908b7a | 2338 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2339 | vty_out(vty, " maximum-paths ibgp %d", |
2340 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2341 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2342 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2343 | vty_out(vty, " equal-cluster-length"); | |
2344 | vty_out(vty, "\n"); | |
2345 | } | |
165b5fff | 2346 | } |
6b0655a2 | 2347 | |
718e3744 | 2348 | /* BGP timers. */ |
2349 | ||
1ca2fd11 IR |
2350 | DEFUN (bgp_timers, |
2351 | bgp_timers_cmd, | |
2352 | "timers bgp (0-65535) (0-65535)", | |
2353 | "Adjust routing timers\n" | |
2354 | "BGP timers\n" | |
2355 | "Keepalive interval\n" | |
2356 | "Holdtime\n") | |
718e3744 | 2357 | { |
1ca2fd11 | 2358 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2359 | int idx_number = 2; |
2360 | int idx_number_2 = 3; | |
1ca2fd11 IR |
2361 | unsigned long keepalive = 0; |
2362 | unsigned long holdtime = 0; | |
718e3744 | 2363 | |
1ca2fd11 IR |
2364 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
2365 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 2366 | |
1ca2fd11 IR |
2367 | /* Holdtime value check. */ |
2368 | if (holdtime < 3 && holdtime != 0) { | |
2369 | vty_out(vty, | |
2370 | "%% hold time value must be either 0 or greater than 3\n"); | |
2371 | return CMD_WARNING_CONFIG_FAILED; | |
2372 | } | |
718e3744 | 2373 | |
1ca2fd11 IR |
2374 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, |
2375 | BGP_DEFAULT_DELAYOPEN); | |
718e3744 | 2376 | |
1ca2fd11 | 2377 | return CMD_SUCCESS; |
718e3744 | 2378 | } |
2379 | ||
1ca2fd11 IR |
2380 | DEFUN (no_bgp_timers, |
2381 | no_bgp_timers_cmd, | |
2382 | "no timers bgp [(0-65535) (0-65535)]", | |
2383 | NO_STR | |
2384 | "Adjust routing timers\n" | |
2385 | "BGP timers\n" | |
2386 | "Keepalive interval\n" | |
2387 | "Holdtime\n") | |
718e3744 | 2388 | { |
1ca2fd11 IR |
2389 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2390 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2391 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
ff8a8a7a | 2392 | |
1ca2fd11 | 2393 | return CMD_SUCCESS; |
718e3744 | 2394 | } |
2395 | ||
b042667a TI |
2396 | /* BGP minimum holdtime. */ |
2397 | ||
2398 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2399 | "bgp minimum-holdtime (1-65535)", | |
2400 | "BGP specific commands\n" | |
2401 | "BGP minimum holdtime\n" | |
2402 | "Seconds\n") | |
2403 | { | |
2404 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2405 | int idx_number = 2; | |
2406 | unsigned long min_holdtime; | |
2407 | ||
2408 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2409 | ||
2410 | bgp->default_min_holdtime = min_holdtime; | |
2411 | ||
2412 | return CMD_SUCCESS; | |
2413 | } | |
2414 | ||
2415 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2416 | "no bgp minimum-holdtime [(1-65535)]", | |
2417 | NO_STR | |
2418 | "BGP specific commands\n" | |
2419 | "BGP minimum holdtime\n" | |
2420 | "Seconds\n") | |
2421 | { | |
2422 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2423 | ||
2424 | bgp->default_min_holdtime = 0; | |
2425 | ||
2426 | return CMD_SUCCESS; | |
2427 | } | |
ff8a8a7a | 2428 | |
1ca2fd11 IR |
2429 | DEFUN (bgp_client_to_client_reflection, |
2430 | bgp_client_to_client_reflection_cmd, | |
2431 | "bgp client-to-client reflection", | |
e9273987 | 2432 | BGP_STR |
1ca2fd11 IR |
2433 | "Configure client to client route reflection\n" |
2434 | "reflection of routes allowed\n") | |
718e3744 | 2435 | { |
1ca2fd11 IR |
2436 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2437 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2438 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2439 | |
1ca2fd11 | 2440 | return CMD_SUCCESS; |
718e3744 | 2441 | } |
2442 | ||
1ca2fd11 IR |
2443 | DEFUN (no_bgp_client_to_client_reflection, |
2444 | no_bgp_client_to_client_reflection_cmd, | |
2445 | "no bgp client-to-client reflection", | |
2446 | NO_STR | |
e9273987 | 2447 | BGP_STR |
1ca2fd11 IR |
2448 | "Configure client to client route reflection\n" |
2449 | "reflection of routes allowed\n") | |
718e3744 | 2450 | { |
1ca2fd11 IR |
2451 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2452 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2453 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2454 | |
1ca2fd11 | 2455 | return CMD_SUCCESS; |
718e3744 | 2456 | } |
2457 | ||
2458 | /* "bgp always-compare-med" configuration. */ | |
1ca2fd11 IR |
2459 | DEFUN (bgp_always_compare_med, |
2460 | bgp_always_compare_med_cmd, | |
2461 | "bgp always-compare-med", | |
e9273987 | 2462 | BGP_STR |
1ca2fd11 | 2463 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2464 | { |
1ca2fd11 IR |
2465 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2466 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2467 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2468 | |
1ca2fd11 | 2469 | return CMD_SUCCESS; |
718e3744 | 2470 | } |
2471 | ||
1ca2fd11 IR |
2472 | DEFUN (no_bgp_always_compare_med, |
2473 | no_bgp_always_compare_med_cmd, | |
2474 | "no bgp always-compare-med", | |
2475 | NO_STR | |
e9273987 | 2476 | BGP_STR |
1ca2fd11 | 2477 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2478 | { |
1ca2fd11 IR |
2479 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2480 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2481 | bgp_recalculate_all_bestpaths(bgp); | |
6b0655a2 | 2482 | |
1ca2fd11 | 2483 | return CMD_SUCCESS; |
2adac256 DA |
2484 | } |
2485 | ||
2adac256 | 2486 | |
1ca2fd11 IR |
2487 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, |
2488 | "bgp ebgp-requires-policy", | |
e9273987 | 2489 | BGP_STR |
1ca2fd11 | 2490 | "Require in and out policy for eBGP peers (RFC8212)\n") |
2adac256 | 2491 | { |
1ca2fd11 IR |
2492 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2493 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2494 | return CMD_SUCCESS; | |
2adac256 DA |
2495 | } |
2496 | ||
1ca2fd11 IR |
2497 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, |
2498 | "no bgp ebgp-requires-policy", | |
2499 | NO_STR | |
e9273987 | 2500 | BGP_STR |
1ca2fd11 | 2501 | "Require in and out policy for eBGP peers (RFC8212)\n") |
ff8a8a7a | 2502 | { |
1ca2fd11 IR |
2503 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2504 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2505 | return CMD_SUCCESS; | |
ff8a8a7a | 2506 | } |
9dac9fc8 | 2507 | |
1ca2fd11 IR |
2508 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, |
2509 | "bgp suppress-duplicates", | |
e9273987 | 2510 | BGP_STR |
1ca2fd11 | 2511 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2512 | { |
1ca2fd11 IR |
2513 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2514 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2515 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2516 | } |
2517 | ||
1ca2fd11 IR |
2518 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, |
2519 | "no bgp suppress-duplicates", | |
2520 | NO_STR | |
e9273987 | 2521 | BGP_STR |
1ca2fd11 | 2522 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2523 | { |
1ca2fd11 IR |
2524 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2525 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2526 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2527 | } |
2528 | ||
fb29348a DA |
2529 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2530 | "bgp reject-as-sets", | |
e9273987 | 2531 | BGP_STR |
fb29348a DA |
2532 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2533 | { | |
2534 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2535 | struct listnode *node, *nnode; | |
2536 | struct peer *peer; | |
2537 | ||
7f972cd8 | 2538 | bgp->reject_as_sets = true; |
fb29348a DA |
2539 | |
2540 | /* Reset existing BGP sessions to reject routes | |
2541 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2542 | */ | |
2543 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2544 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2545 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2546 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2547 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2548 | } | |
2549 | } | |
2550 | ||
2551 | return CMD_SUCCESS; | |
2552 | } | |
2553 | ||
2554 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2555 | "no bgp reject-as-sets", | |
2556 | NO_STR | |
e9273987 | 2557 | BGP_STR |
fb29348a DA |
2558 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2559 | { | |
2560 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2561 | struct listnode *node, *nnode; | |
2562 | struct peer *peer; | |
2563 | ||
7f972cd8 | 2564 | bgp->reject_as_sets = false; |
fb29348a DA |
2565 | |
2566 | /* Reset existing BGP sessions to reject routes | |
2567 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2568 | */ | |
2569 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2570 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2571 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2572 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2573 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2574 | } | |
2575 | } | |
2576 | ||
2577 | return CMD_SUCCESS; | |
2578 | } | |
9dac9fc8 | 2579 | |
718e3744 | 2580 | /* "bgp deterministic-med" configuration. */ |
1ca2fd11 | 2581 | DEFUN (bgp_deterministic_med, |
718e3744 | 2582 | bgp_deterministic_med_cmd, |
2583 | "bgp deterministic-med", | |
e9273987 | 2584 | BGP_STR |
718e3744 | 2585 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2586 | { | |
1ca2fd11 IR |
2587 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2588 | ||
2589 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2590 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2591 | bgp_recalculate_all_bestpaths(bgp); | |
2592 | } | |
7aafcaca | 2593 | |
1ca2fd11 | 2594 | return CMD_SUCCESS; |
718e3744 | 2595 | } |
2596 | ||
1ca2fd11 | 2597 | DEFUN (no_bgp_deterministic_med, |
718e3744 | 2598 | no_bgp_deterministic_med_cmd, |
2599 | "no bgp deterministic-med", | |
2600 | NO_STR | |
e9273987 | 2601 | BGP_STR |
718e3744 | 2602 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2603 | { | |
1ca2fd11 IR |
2604 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2605 | int bestpath_per_as_used; | |
2606 | afi_t afi; | |
2607 | safi_t safi; | |
2608 | struct peer *peer; | |
2609 | struct listnode *node, *nnode; | |
2610 | ||
2611 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2612 | bestpath_per_as_used = 0; | |
2613 | ||
2614 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2615 | FOREACH_AFI_SAFI (afi, safi) | |
2616 | if (bgp_addpath_dmed_required( | |
2617 | peer->addpath_type[afi][safi])) { | |
2618 | bestpath_per_as_used = 1; | |
2619 | break; | |
2620 | } | |
2621 | ||
2622 | if (bestpath_per_as_used) | |
2623 | break; | |
2624 | } | |
2625 | ||
2626 | if (bestpath_per_as_used) { | |
2627 | vty_out(vty, | |
2628 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2629 | return CMD_WARNING_CONFIG_FAILED; | |
2630 | } else { | |
2631 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2632 | bgp_recalculate_all_bestpaths(bgp); | |
2633 | } | |
2634 | } | |
d62a17ae | 2635 | |
1ca2fd11 | 2636 | return CMD_SUCCESS; |
718e3744 | 2637 | } |
538621f2 | 2638 | |
055679e9 | 2639 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2640 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2641 | bgp_graceful_restart_cmd, |
2642 | "bgp graceful-restart", | |
e9273987 | 2643 | BGP_STR |
2ba1fe69 | 2644 | GR_CMD |
055679e9 | 2645 | ) |
538621f2 | 2646 | { |
055679e9 | 2647 | int ret = BGP_GR_FAILURE; |
2648 | ||
2649 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2650 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2651 | |
d62a17ae | 2652 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2653 | |
2654 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2655 | ||
36235319 QY |
2656 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2657 | ret); | |
5cce3f05 | 2658 | |
055679e9 | 2659 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2660 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2661 | vty_out(vty, |
2662 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2663 | return bgp_vty_return(vty, ret); |
538621f2 | 2664 | } |
2665 | ||
2666 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2667 | no_bgp_graceful_restart_cmd, |
2668 | "no bgp graceful-restart", | |
2669 | NO_STR | |
e9273987 | 2670 | BGP_STR |
2ba1fe69 | 2671 | NO_GR_CMD |
055679e9 | 2672 | ) |
538621f2 | 2673 | { |
d62a17ae | 2674 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2675 | |
2676 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2677 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2678 | |
2679 | int ret = BGP_GR_FAILURE; | |
2680 | ||
2681 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2682 | ||
36235319 QY |
2683 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2684 | ret); | |
5cce3f05 | 2685 | |
055679e9 | 2686 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2687 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2688 | vty_out(vty, |
2689 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2690 | |
2691 | return bgp_vty_return(vty, ret); | |
538621f2 | 2692 | } |
2693 | ||
93406d87 | 2694 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2695 | bgp_graceful_restart_stalepath_time_cmd, |
2696 | "bgp graceful-restart stalepath-time (1-4095)", | |
e9273987 | 2697 | BGP_STR |
2ba1fe69 | 2698 | "Graceful restart capability parameters\n" |
2699 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2700 | "Delay value (seconds)\n") | |
93406d87 | 2701 | { |
d62a17ae | 2702 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2703 | int idx_number = 3; | |
d7c0a89a | 2704 | uint32_t stalepath; |
93406d87 | 2705 | |
d62a17ae | 2706 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2707 | bgp->stalepath_time = stalepath; | |
2708 | return CMD_SUCCESS; | |
93406d87 | 2709 | } |
2710 | ||
eb6f1b41 | 2711 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2712 | bgp_graceful_restart_restart_time_cmd, |
2713 | "bgp graceful-restart restart-time (1-4095)", | |
e9273987 | 2714 | BGP_STR |
2ba1fe69 | 2715 | "Graceful restart capability parameters\n" |
2716 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2717 | "Delay value (seconds)\n") | |
eb6f1b41 | 2718 | { |
d62a17ae | 2719 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2720 | int idx_number = 3; | |
d7c0a89a | 2721 | uint32_t restart; |
eb6f1b41 | 2722 | |
d62a17ae | 2723 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2724 | bgp->restart_time = restart; | |
2725 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2726 | } |
2727 | ||
cfd47646 | 2728 | DEFUN (bgp_graceful_restart_select_defer_time, |
2729 | bgp_graceful_restart_select_defer_time_cmd, | |
2730 | "bgp graceful-restart select-defer-time (0-3600)", | |
e9273987 | 2731 | BGP_STR |
cfd47646 | 2732 | "Graceful restart capability parameters\n" |
2733 | "Set the time to defer the BGP route selection after restart\n" | |
2734 | "Delay value (seconds, 0 - disable)\n") | |
2735 | { | |
2736 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2737 | int idx_number = 3; | |
2738 | uint32_t defer_time; | |
2739 | ||
2740 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2741 | bgp->select_defer_time = defer_time; | |
2742 | if (defer_time == 0) | |
892fedb6 | 2743 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2744 | else |
892fedb6 | 2745 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2746 | |
2747 | return CMD_SUCCESS; | |
2748 | } | |
2749 | ||
93406d87 | 2750 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2751 | no_bgp_graceful_restart_stalepath_time_cmd, |
2752 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2753 | NO_STR | |
e9273987 | 2754 | BGP_STR |
2ba1fe69 | 2755 | "Graceful restart capability parameters\n" |
2756 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2757 | "Delay value (seconds)\n") | |
93406d87 | 2758 | { |
d62a17ae | 2759 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2760 | |
d62a17ae | 2761 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2762 | return CMD_SUCCESS; | |
93406d87 | 2763 | } |
2764 | ||
eb6f1b41 | 2765 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2766 | no_bgp_graceful_restart_restart_time_cmd, |
2767 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2768 | NO_STR | |
e9273987 | 2769 | BGP_STR |
2ba1fe69 | 2770 | "Graceful restart capability parameters\n" |
2771 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2772 | "Delay value (seconds)\n") | |
eb6f1b41 | 2773 | { |
d62a17ae | 2774 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2775 | |
d62a17ae | 2776 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2777 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2778 | } |
2779 | ||
cfd47646 | 2780 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2781 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2782 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2783 | NO_STR | |
e9273987 | 2784 | BGP_STR |
cfd47646 | 2785 | "Graceful restart capability parameters\n" |
2786 | "Set the time to defer the BGP route selection after restart\n" | |
2787 | "Delay value (seconds)\n") | |
2788 | { | |
2789 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2790 | ||
2791 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2792 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2793 | |
2794 | return CMD_SUCCESS; | |
2795 | } | |
2796 | ||
43fc21b3 | 2797 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2798 | bgp_graceful_restart_preserve_fw_cmd, |
2799 | "bgp graceful-restart preserve-fw-state", | |
e9273987 | 2800 | BGP_STR |
2ba1fe69 | 2801 | "Graceful restart capability parameters\n" |
2802 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2803 | { |
d62a17ae | 2804 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2805 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2806 | return CMD_SUCCESS; |
43fc21b3 JC |
2807 | } |
2808 | ||
2809 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2810 | no_bgp_graceful_restart_preserve_fw_cmd, |
2811 | "no bgp graceful-restart preserve-fw-state", | |
2812 | NO_STR | |
e9273987 | 2813 | BGP_STR |
2ba1fe69 | 2814 | "Graceful restart capability parameters\n" |
2815 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2816 | { |
d62a17ae | 2817 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2818 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2819 | return CMD_SUCCESS; |
43fc21b3 JC |
2820 | } |
2821 | ||
055679e9 | 2822 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2823 | bgp_graceful_restart_disable_cmd, |
2824 | "bgp graceful-restart-disable", | |
e9273987 | 2825 | BGP_STR |
2ba1fe69 | 2826 | GR_DISABLE) |
055679e9 | 2827 | { |
2828 | int ret = BGP_GR_FAILURE; | |
2829 | ||
2830 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2831 | zlog_debug( | |
2ba1fe69 | 2832 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2833 | |
055679e9 | 2834 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2835 | ||
2836 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2837 | ||
dc95985f | 2838 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2839 | bgp->peer, ret); | |
5cce3f05 | 2840 | |
055679e9 | 2841 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2842 | zlog_debug( | |
2ba1fe69 | 2843 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2844 | vty_out(vty, |
2845 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2846 | ||
055679e9 | 2847 | return bgp_vty_return(vty, ret); |
2848 | } | |
2849 | ||
2850 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2851 | no_bgp_graceful_restart_disable_cmd, |
2852 | "no bgp graceful-restart-disable", | |
2853 | NO_STR | |
e9273987 | 2854 | BGP_STR |
2ba1fe69 | 2855 | NO_GR_DISABLE |
055679e9 | 2856 | ) |
2857 | { | |
2858 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2859 | ||
2860 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2861 | zlog_debug( | |
2ba1fe69 | 2862 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2863 | |
2864 | int ret = BGP_GR_FAILURE; | |
2865 | ||
2866 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2867 | ||
36235319 QY |
2868 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2869 | ret); | |
5cce3f05 | 2870 | |
055679e9 | 2871 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2872 | zlog_debug( | |
2ba1fe69 | 2873 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2874 | vty_out(vty, |
2875 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2876 | |
2877 | return bgp_vty_return(vty, ret); | |
2878 | } | |
2879 | ||
2880 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2881 | bgp_neighbor_graceful_restart_set_cmd, |
2882 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2883 | NEIGHBOR_STR | |
2884 | NEIGHBOR_ADDR_STR2 | |
2885 | GR_NEIGHBOR_CMD | |
055679e9 | 2886 | ) |
2887 | { | |
2888 | int idx_peer = 1; | |
2889 | struct peer *peer; | |
2890 | int ret = BGP_GR_FAILURE; | |
2891 | ||
dc95985f | 2892 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2893 | ||
055679e9 | 2894 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2895 | zlog_debug( | |
2ba1fe69 | 2896 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2897 | |
055679e9 | 2898 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2899 | if (!peer) | |
2900 | return CMD_WARNING_CONFIG_FAILED; | |
2901 | ||
2902 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2903 | ||
dc95985f | 2904 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2905 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2906 | |
2907 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2908 | zlog_debug( | |
2ba1fe69 | 2909 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2910 | vty_out(vty, |
2911 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2912 | |
2913 | return bgp_vty_return(vty, ret); | |
2914 | } | |
2915 | ||
2916 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2917 | no_bgp_neighbor_graceful_restart_set_cmd, |
2918 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2919 | NO_STR | |
2920 | NEIGHBOR_STR | |
2921 | NEIGHBOR_ADDR_STR2 | |
2922 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2923 | ) |
2924 | { | |
2925 | int idx_peer = 2; | |
2926 | int ret = BGP_GR_FAILURE; | |
2927 | struct peer *peer; | |
2928 | ||
dc95985f | 2929 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2930 | ||
055679e9 | 2931 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2932 | if (!peer) | |
2933 | return CMD_WARNING_CONFIG_FAILED; | |
2934 | ||
2935 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2936 | zlog_debug( | |
2ba1fe69 | 2937 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2938 | |
2939 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2940 | ||
dc95985f | 2941 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2942 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2943 | |
2944 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2945 | zlog_debug( | |
2ba1fe69 | 2946 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2947 | vty_out(vty, |
2948 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2949 | |
2950 | return bgp_vty_return(vty, ret); | |
2951 | } | |
2952 | ||
2953 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2954 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2955 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2956 | NEIGHBOR_STR | |
2957 | NEIGHBOR_ADDR_STR2 | |
2958 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2959 | ) |
2960 | { | |
2961 | int idx_peer = 1; | |
2962 | struct peer *peer; | |
2963 | int ret = BGP_GR_FAILURE; | |
2964 | ||
dc95985f | 2965 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2966 | ||
055679e9 | 2967 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2968 | zlog_debug( | |
2ba1fe69 | 2969 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2970 | |
055679e9 | 2971 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2972 | ||
055679e9 | 2973 | if (!peer) |
2974 | return CMD_WARNING_CONFIG_FAILED; | |
2975 | ||
2976 | ||
2977 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2978 | |
dc95985f | 2979 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2980 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2981 | |
055679e9 | 2982 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2983 | zlog_debug( | |
2ba1fe69 | 2984 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2985 | vty_out(vty, |
2986 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2987 | |
2988 | return bgp_vty_return(vty, ret); | |
2989 | } | |
2990 | ||
2991 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2992 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2993 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2994 | NO_STR | |
2995 | NEIGHBOR_STR | |
2996 | NEIGHBOR_ADDR_STR2 | |
2997 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2998 | ) |
2999 | { | |
3000 | int idx_peer = 2; | |
3001 | int ret = BGP_GR_FAILURE; | |
3002 | struct peer *peer; | |
3003 | ||
dc95985f | 3004 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3005 | ||
055679e9 | 3006 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3007 | if (!peer) | |
3008 | return CMD_WARNING_CONFIG_FAILED; | |
3009 | ||
3010 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3011 | zlog_debug( | |
2ba1fe69 | 3012 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3013 | |
36235319 | 3014 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3015 | |
dc95985f | 3016 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3017 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3018 | |
3019 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3020 | zlog_debug( | |
2ba1fe69 | 3021 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3022 | vty_out(vty, |
3023 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3024 | |
3025 | return bgp_vty_return(vty, ret); | |
3026 | } | |
3027 | ||
3028 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3029 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3030 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3031 | NEIGHBOR_STR | |
3032 | NEIGHBOR_ADDR_STR2 | |
3033 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3034 | ) |
3035 | { | |
3036 | int idx_peer = 1; | |
3037 | struct peer *peer; | |
3038 | int ret = BGP_GR_FAILURE; | |
3039 | ||
dc95985f | 3040 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3041 | ||
055679e9 | 3042 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3043 | zlog_debug( | |
2ba1fe69 | 3044 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3045 | |
3046 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3047 | if (!peer) | |
3048 | return CMD_WARNING_CONFIG_FAILED; | |
3049 | ||
36235319 | 3050 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3051 | |
3052 | if (peer->bgp->t_startup) | |
3053 | bgp_peer_gr_flags_update(peer); | |
3054 | ||
dc95985f | 3055 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3056 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3057 | ||
055679e9 | 3058 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3059 | zlog_debug( | |
2ba1fe69 | 3060 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3061 | vty_out(vty, |
3062 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3063 | |
3064 | return bgp_vty_return(vty, ret); | |
3065 | } | |
3066 | ||
3067 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3068 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3070 | NO_STR | |
3071 | NEIGHBOR_STR | |
3072 | NEIGHBOR_ADDR_STR2 | |
3073 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3074 | ) |
3075 | { | |
3076 | int idx_peer = 2; | |
3077 | int ret = BGP_GR_FAILURE; | |
3078 | struct peer *peer; | |
3079 | ||
dc95985f | 3080 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3081 | ||
055679e9 | 3082 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3083 | if (!peer) | |
3084 | return CMD_WARNING_CONFIG_FAILED; | |
3085 | ||
3086 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3087 | zlog_debug( | |
2ba1fe69 | 3088 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3089 | |
3090 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3091 | ||
dc95985f | 3092 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3093 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3094 | |
3095 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3096 | zlog_debug( | |
2ba1fe69 | 3097 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3098 | vty_out(vty, |
3099 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3100 | |
3101 | return bgp_vty_return(vty, ret); | |
3102 | } | |
3103 | ||
d6e3c15b | 3104 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3105 | bgp_graceful_restart_disable_eor_cmd, | |
3106 | "bgp graceful-restart disable-eor", | |
e9273987 | 3107 | BGP_STR |
d6e3c15b | 3108 | "Graceful restart configuration parameters\n" |
3109 | "Disable EOR Check\n") | |
3110 | { | |
3111 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3112 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3113 | |
d6e3c15b | 3114 | return CMD_SUCCESS; |
3115 | } | |
3116 | ||
3117 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3118 | no_bgp_graceful_restart_disable_eor_cmd, | |
3119 | "no bgp graceful-restart disable-eor", | |
3120 | NO_STR | |
e9273987 | 3121 | BGP_STR |
d6e3c15b | 3122 | "Graceful restart configuration parameters\n" |
3123 | "Disable EOR Check\n") | |
3124 | { | |
3125 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3126 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3127 | |
3128 | return CMD_SUCCESS; | |
3129 | } | |
3130 | ||
3131 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3132 | bgp_graceful_restart_rib_stale_time_cmd, | |
3133 | "bgp graceful-restart rib-stale-time (1-3600)", | |
e9273987 | 3134 | BGP_STR |
dc95985f | 3135 | "Graceful restart configuration parameters\n" |
3136 | "Specify the stale route removal timer in rib\n" | |
3137 | "Delay value (seconds)\n") | |
3138 | { | |
3139 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3140 | int idx_number = 3; | |
3141 | uint32_t stale_time; | |
3142 | ||
3143 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3144 | bgp->rib_stale_time = stale_time; | |
3145 | /* Send the stale timer update message to RIB */ | |
3146 | if (bgp_zebra_stale_timer_update(bgp)) | |
3147 | return CMD_WARNING; | |
3148 | ||
3149 | return CMD_SUCCESS; | |
3150 | } | |
3151 | ||
3152 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3153 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3154 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3155 | NO_STR | |
e9273987 | 3156 | BGP_STR |
dc95985f | 3157 | "Graceful restart configuration parameters\n" |
3158 | "Specify the stale route removal timer in rib\n" | |
3159 | "Delay value (seconds)\n") | |
3160 | { | |
3161 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3162 | ||
3163 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3164 | /* Send the stale timer update message to RIB */ | |
3165 | if (bgp_zebra_stale_timer_update(bgp)) | |
3166 | return CMD_WARNING; | |
3167 | ||
d6e3c15b | 3168 | return CMD_SUCCESS; |
3169 | } | |
3170 | ||
1ca2fd11 IR |
3171 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3172 | struct bgp *bgp) | |
05bd726c | 3173 | { |
3174 | bgp_static_redo_import_check(bgp); | |
3175 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3176 | bgp_clear_star_soft_out(vty, bgp->name); |
3177 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3178 | } |
3179 | ||
3180 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3181 | { | |
3182 | struct listnode *node, *nnode; | |
3183 | struct bgp *bgp; | |
3184 | bool vrf_cfg = false; | |
3185 | ||
3186 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3187 | return CMD_SUCCESS; | |
3188 | ||
3189 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3190 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3191 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3192 | vty_out(vty, | |
3193 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3194 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3195 | VRF_DEFAULT_NAME : bgp->name); | |
3196 | vrf_cfg = true; | |
3197 | } | |
3198 | } | |
3199 | ||
3200 | if (vrf_cfg) { | |
3201 | vty_out(vty, | |
3202 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3203 | return CMD_WARNING; | |
3204 | } | |
3205 | ||
3206 | /* Set flag globally */ | |
3207 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3208 | ||
3209 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3210 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3211 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3212 | |
3213 | return CMD_SUCCESS; | |
3214 | } | |
3215 | ||
3216 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3217 | { | |
3218 | struct listnode *node, *nnode; | |
3219 | struct bgp *bgp; | |
3220 | ||
3221 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3222 | return CMD_SUCCESS; | |
3223 | ||
3224 | /* Unset flag globally */ | |
3225 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3226 | ||
3227 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3228 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3229 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3230 | |
3231 | return CMD_SUCCESS; | |
3232 | } | |
3233 | ||
7f323236 DW |
3234 | /* "bgp graceful-shutdown" configuration */ |
3235 | DEFUN (bgp_graceful_shutdown, | |
3236 | bgp_graceful_shutdown_cmd, | |
3237 | "bgp graceful-shutdown", | |
3238 | BGP_STR | |
3239 | "Graceful shutdown parameters\n") | |
3240 | { | |
05bd726c | 3241 | if (vty->node == CONFIG_NODE) |
3242 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3243 | ||
1ca2fd11 | 3244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3245 | |
1ca2fd11 IR |
3246 | /* if configured globally, per-instance config is not allowed */ |
3247 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3248 | vty_out(vty, | |
3249 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3250 | return CMD_WARNING_CONFIG_FAILED; | |
3251 | } | |
3252 | ||
3253 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3254 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3255 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3256 | } | |
3257 | ||
3258 | return CMD_SUCCESS; | |
7f323236 DW |
3259 | } |
3260 | ||
1ca2fd11 | 3261 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3262 | no_bgp_graceful_shutdown_cmd, |
3263 | "no bgp graceful-shutdown", | |
3264 | NO_STR | |
3265 | BGP_STR | |
3266 | "Graceful shutdown parameters\n") | |
3267 | { | |
05bd726c | 3268 | if (vty->node == CONFIG_NODE) |
3269 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3270 | ||
1ca2fd11 | 3271 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3272 | |
1ca2fd11 IR |
3273 | /* If configured globally, cannot remove from one bgp instance */ |
3274 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3275 | vty_out(vty, | |
3276 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3277 | return CMD_WARNING_CONFIG_FAILED; | |
3278 | } | |
7f323236 | 3279 | |
1ca2fd11 IR |
3280 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3281 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3282 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3283 | } | |
3284 | ||
3285 | return CMD_SUCCESS; | |
7f323236 DW |
3286 | } |
3287 | ||
718e3744 | 3288 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3289 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3290 | bgp_fast_external_failover_cmd, |
3291 | "bgp fast-external-failover", | |
3292 | BGP_STR | |
3293 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3294 | { | |
1ca2fd11 IR |
3295 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3296 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3297 | return CMD_SUCCESS; | |
718e3744 | 3298 | } |
3299 | ||
1ca2fd11 | 3300 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3301 | no_bgp_fast_external_failover_cmd, |
3302 | "no bgp fast-external-failover", | |
3303 | NO_STR | |
3304 | BGP_STR | |
3305 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3306 | { | |
1ca2fd11 IR |
3307 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3308 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3309 | return CMD_SUCCESS; | |
718e3744 | 3310 | } |
6b0655a2 | 3311 | |
718e3744 | 3312 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3313 | DEFUN (bgp_bestpath_compare_router_id, |
3314 | bgp_bestpath_compare_router_id_cmd, | |
3315 | "bgp bestpath compare-routerid", | |
e9273987 | 3316 | BGP_STR |
1ca2fd11 IR |
3317 | "Change the default bestpath selection\n" |
3318 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3319 | { |
1ca2fd11 IR |
3320 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3321 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3322 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3323 | |
1ca2fd11 | 3324 | return CMD_SUCCESS; |
718e3744 | 3325 | } |
3326 | ||
1ca2fd11 IR |
3327 | DEFUN (no_bgp_bestpath_compare_router_id, |
3328 | no_bgp_bestpath_compare_router_id_cmd, | |
3329 | "no bgp bestpath compare-routerid", | |
3330 | NO_STR | |
e9273987 | 3331 | BGP_STR |
1ca2fd11 IR |
3332 | "Change the default bestpath selection\n" |
3333 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3334 | { |
1ca2fd11 IR |
3335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3336 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3337 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3338 | |
1ca2fd11 | 3339 | return CMD_SUCCESS; |
718e3744 | 3340 | } |
6b0655a2 | 3341 | |
718e3744 | 3342 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3343 | DEFUN (bgp_bestpath_aspath_ignore, |
3344 | bgp_bestpath_aspath_ignore_cmd, | |
3345 | "bgp bestpath as-path ignore", | |
e9273987 | 3346 | BGP_STR |
1ca2fd11 IR |
3347 | "Change the default bestpath selection\n" |
3348 | "AS-path attribute\n" | |
3349 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3350 | { |
1ca2fd11 IR |
3351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3352 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3353 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3354 | |
1ca2fd11 | 3355 | return CMD_SUCCESS; |
718e3744 | 3356 | } |
3357 | ||
1ca2fd11 IR |
3358 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3359 | no_bgp_bestpath_aspath_ignore_cmd, | |
3360 | "no bgp bestpath as-path ignore", | |
3361 | NO_STR | |
e9273987 | 3362 | BGP_STR |
1ca2fd11 IR |
3363 | "Change the default bestpath selection\n" |
3364 | "AS-path attribute\n" | |
3365 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3366 | { |
1ca2fd11 IR |
3367 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3368 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3369 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3370 | |
1ca2fd11 | 3371 | return CMD_SUCCESS; |
718e3744 | 3372 | } |
6b0655a2 | 3373 | |
6811845b | 3374 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3375 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3376 | bgp_bestpath_aspath_confed_cmd, |
3377 | "bgp bestpath as-path confed", | |
e9273987 | 3378 | BGP_STR |
6811845b | 3379 | "Change the default bestpath selection\n" |
3380 | "AS-path attribute\n" | |
3381 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3382 | { | |
1ca2fd11 IR |
3383 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3384 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3385 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3386 | |
1ca2fd11 | 3387 | return CMD_SUCCESS; |
6811845b | 3388 | } |
3389 | ||
1ca2fd11 | 3390 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3391 | no_bgp_bestpath_aspath_confed_cmd, |
3392 | "no bgp bestpath as-path confed", | |
3393 | NO_STR | |
e9273987 | 3394 | BGP_STR |
6811845b | 3395 | "Change the default bestpath selection\n" |
3396 | "AS-path attribute\n" | |
3397 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3398 | { | |
1ca2fd11 IR |
3399 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3400 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3401 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3402 | |
1ca2fd11 | 3403 | return CMD_SUCCESS; |
6811845b | 3404 | } |
6b0655a2 | 3405 | |
2fdd455c | 3406 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3407 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3408 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3409 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3410 | BGP_STR |
16fc1eec DS |
3411 | "Change the default bestpath selection\n" |
3412 | "AS-path attribute\n" | |
3413 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3414 | "Generate an AS_SET\n" |
16fc1eec DS |
3415 | "Do not generate an AS_SET\n") |
3416 | { | |
1ca2fd11 | 3417 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3418 | int idx = 0; |
1ca2fd11 | 3419 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3420 | |
1ca2fd11 IR |
3421 | /* no-as-set is now the default behavior so we can silently |
3422 | * ignore it */ | |
d62a17ae | 3423 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3424 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3425 | else |
1ca2fd11 | 3426 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3427 | |
1ca2fd11 IR |
3428 | bgp_recalculate_all_bestpaths(bgp); |
3429 | ||
3430 | return CMD_SUCCESS; | |
16fc1eec DS |
3431 | } |
3432 | ||
1ca2fd11 | 3433 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3434 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3435 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3436 | NO_STR |
e9273987 | 3437 | BGP_STR |
16fc1eec DS |
3438 | "Change the default bestpath selection\n" |
3439 | "AS-path attribute\n" | |
3440 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3441 | "Generate an AS_SET\n" |
16fc1eec DS |
3442 | "Do not generate an AS_SET\n") |
3443 | { | |
1ca2fd11 IR |
3444 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3445 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3446 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3447 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3448 | |
1ca2fd11 | 3449 | return CMD_SUCCESS; |
2fdd455c | 3450 | } |
6b0655a2 | 3451 | |
ee88563a JM |
3452 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3453 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3454 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3455 | "bgp bestpath peer-type multipath-relax", | |
3456 | BGP_STR | |
3457 | "Change the default bestpath selection\n" | |
3458 | "Peer type\n" | |
3459 | "Allow load sharing across routes learned from different peer types\n") | |
3460 | { | |
3461 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3462 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3463 | bgp_recalculate_all_bestpaths(bgp); | |
3464 | ||
3465 | return CMD_SUCCESS; | |
3466 | } | |
3467 | ||
3468 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3469 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3470 | "no bgp bestpath peer-type multipath-relax", | |
3471 | NO_STR BGP_STR | |
3472 | "Change the default bestpath selection\n" | |
3473 | "Peer type\n" | |
3474 | "Allow load sharing across routes learned from different peer types\n") | |
3475 | { | |
3476 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3477 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3478 | bgp_recalculate_all_bestpaths(bgp); | |
3479 | ||
3480 | return CMD_SUCCESS; | |
3481 | } | |
3482 | ||
848973c7 | 3483 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3484 | DEFUN (bgp_log_neighbor_changes, |
3485 | bgp_log_neighbor_changes_cmd, | |
3486 | "bgp log-neighbor-changes", | |
e9273987 | 3487 | BGP_STR |
1ca2fd11 | 3488 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3489 | { |
1ca2fd11 IR |
3490 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3491 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3492 | return CMD_SUCCESS; | |
848973c7 | 3493 | } |
3494 | ||
1ca2fd11 IR |
3495 | DEFUN (no_bgp_log_neighbor_changes, |
3496 | no_bgp_log_neighbor_changes_cmd, | |
3497 | "no bgp log-neighbor-changes", | |
3498 | NO_STR | |
e9273987 | 3499 | BGP_STR |
1ca2fd11 | 3500 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3501 | { |
1ca2fd11 IR |
3502 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3503 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3504 | return CMD_SUCCESS; | |
848973c7 | 3505 | } |
6b0655a2 | 3506 | |
718e3744 | 3507 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3508 | DEFUN (bgp_bestpath_med, |
718e3744 | 3509 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3510 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3511 | BGP_STR |
718e3744 | 3512 | "Change the default bestpath selection\n" |
3513 | "MED attribute\n" | |
3514 | "Compare MED among confederation paths\n" | |
838758ac DW |
3515 | "Treat missing MED as the least preferred one\n" |
3516 | "Treat missing MED as the least preferred one\n" | |
3517 | "Compare MED among confederation paths\n") | |
718e3744 | 3518 | { |
1ca2fd11 | 3519 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3520 | |
1ca2fd11 | 3521 | int idx = 0; |
d62a17ae | 3522 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3523 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3524 | idx = 0; |
3525 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3526 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3527 | |
1ca2fd11 | 3528 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3529 | |
1ca2fd11 | 3530 | return CMD_SUCCESS; |
718e3744 | 3531 | } |
3532 | ||
1ca2fd11 | 3533 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3534 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3535 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3536 | NO_STR |
e9273987 | 3537 | BGP_STR |
718e3744 | 3538 | "Change the default bestpath selection\n" |
3539 | "MED attribute\n" | |
3540 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3541 | "Treat missing MED as the least preferred one\n" |
3542 | "Treat missing MED as the least preferred one\n" | |
3543 | "Compare MED among confederation paths\n") | |
718e3744 | 3544 | { |
1ca2fd11 | 3545 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3546 | |
1ca2fd11 | 3547 | int idx = 0; |
d62a17ae | 3548 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3549 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3550 | idx = 0; |
3551 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3552 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3553 | ||
3554 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3555 | |
1ca2fd11 | 3556 | return CMD_SUCCESS; |
718e3744 | 3557 | } |
3558 | ||
f7e1c681 | 3559 | /* "bgp bestpath bandwidth" configuration. */ |
3560 | DEFPY (bgp_bestpath_bw, | |
3561 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3562 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3563 | BGP_STR |
f7e1c681 | 3564 | "Change the default bestpath selection\n" |
3565 | "Link Bandwidth attribute\n" | |
3566 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3567 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3568 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3569 | { | |
3570 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3571 | afi_t afi; | |
3572 | safi_t safi; | |
3573 | ||
ad36d216 DS |
3574 | if (!bw_cfg) { |
3575 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3576 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3577 | } |
ad36d216 DS |
3578 | if (!strcmp(bw_cfg, "ignore")) |
3579 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3580 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3581 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3582 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3583 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3584 | else | |
3585 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3586 | |
3587 | /* This config is used in route install, so redo that. */ | |
3588 | FOREACH_AFI_SAFI (afi, safi) { | |
3589 | if (!bgp_fibupd_safi(safi)) | |
3590 | continue; | |
3591 | bgp_zebra_announce_table(bgp, afi, safi); | |
3592 | } | |
3593 | ||
3594 | return CMD_SUCCESS; | |
3595 | } | |
3596 | ||
ad36d216 DS |
3597 | DEFPY (no_bgp_bestpath_bw, |
3598 | no_bgp_bestpath_bw_cmd, | |
3599 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3600 | NO_STR | |
e9273987 | 3601 | BGP_STR |
ad36d216 DS |
3602 | "Change the default bestpath selection\n" |
3603 | "Link Bandwidth attribute\n" | |
3604 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3605 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3606 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3607 | { | |
3608 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3609 | afi_t afi; | |
3610 | safi_t safi; | |
3611 | ||
3612 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3613 | ||
3614 | /* This config is used in route install, so redo that. */ | |
3615 | FOREACH_AFI_SAFI (afi, safi) { | |
3616 | if (!bgp_fibupd_safi(safi)) | |
3617 | continue; | |
3618 | bgp_zebra_announce_table(bgp, afi, safi); | |
3619 | } | |
3620 | return CMD_SUCCESS; | |
3621 | } | |
3622 | ||
b16bcbba | 3623 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3624 | "[no] bgp default <ipv4-unicast|" |
3625 | "ipv4-multicast|" | |
3626 | "ipv4-vpn|" | |
3627 | "ipv4-labeled-unicast|" | |
3628 | "ipv4-flowspec|" | |
3629 | "ipv6-unicast|" | |
3630 | "ipv6-multicast|" | |
3631 | "ipv6-vpn|" | |
3632 | "ipv6-labeled-unicast|" | |
3633 | "ipv6-flowspec|" | |
3634 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3635 | NO_STR |
e9273987 | 3636 | BGP_STR |
e84c59af | 3637 | "Configure BGP defaults\n" |
b16bcbba | 3638 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3639 | "Activate ipv4-multicast for a peer by default\n" |
3640 | "Activate ipv4-vpn for a peer by default\n" | |
3641 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3642 | "Activate ipv4-flowspec for a peer by default\n" | |
3643 | "Activate ipv6-unicast for a peer by default\n" | |
3644 | "Activate ipv6-multicast for a peer by default\n" | |
3645 | "Activate ipv6-vpn for a peer by default\n" | |
3646 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3647 | "Activate ipv6-flowspec for a peer by default\n" | |
3648 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3649 | { |
3650 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3651 | char afi_safi_str[strlen(afi_safi) + 1]; |
3652 | char *afi_safi_str_tok; | |
e84c59af | 3653 | |
b16bcbba TA |
3654 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
3655 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3656 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3657 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 3658 | safi_t safi; |
e84c59af | 3659 | |
38d11af5 TA |
3660 | if (strmatch(safi_str, "labeled")) |
3661 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3662 | else | |
3663 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba TA |
3664 | |
3665 | if (no) | |
3666 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
3667 | else { |
3668 | if ((safi == SAFI_LABELED_UNICAST | |
3669 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3670 | || (safi == SAFI_UNICAST | |
3671 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3672 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3673 | else | |
3674 | bgp->default_af[afi][safi] = true; | |
3675 | } | |
718e3744 | 3676 | |
d62a17ae | 3677 | return CMD_SUCCESS; |
718e3744 | 3678 | } |
6b0655a2 | 3679 | |
04b6bdc0 | 3680 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 3681 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
3682 | bgp_default_show_hostname_cmd, |
3683 | "bgp default show-hostname", | |
e9273987 | 3684 | BGP_STR |
04b6bdc0 | 3685 | "Configure BGP defaults\n" |
0437e105 | 3686 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3687 | { |
1ca2fd11 IR |
3688 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3689 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3690 | return CMD_SUCCESS; | |
ff8a8a7a CS |
3691 | } |
3692 | ||
1ca2fd11 IR |
3693 | DEFUN (no_bgp_default_show_hostname, |
3694 | no_bgp_default_show_hostname_cmd, | |
3695 | "no bgp default show-hostname", | |
3696 | NO_STR | |
e9273987 | 3697 | BGP_STR |
1ca2fd11 IR |
3698 | "Configure BGP defaults\n" |
3699 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 3700 | { |
1ca2fd11 IR |
3701 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3702 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3703 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3704 | } |
3705 | ||
aef999a2 | 3706 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
3707 | DEFUN (bgp_default_show_nexthop_hostname, |
3708 | bgp_default_show_nexthop_hostname_cmd, | |
3709 | "bgp default show-nexthop-hostname", | |
e9273987 | 3710 | BGP_STR |
1d80f243 IR |
3711 | "Configure BGP defaults\n" |
3712 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3713 | { |
1ca2fd11 IR |
3714 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3715 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3716 | return CMD_SUCCESS; | |
aef999a2 DA |
3717 | } |
3718 | ||
3719 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3720 | no_bgp_default_show_nexthop_hostname_cmd, | |
3721 | "no bgp default show-nexthop-hostname", | |
3722 | NO_STR | |
e9273987 | 3723 | BGP_STR |
aef999a2 DA |
3724 | "Configure BGP defaults\n" |
3725 | "Show hostname for nexthop in certain command outputs\n") | |
3726 | { | |
1ca2fd11 IR |
3727 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3728 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3729 | return CMD_SUCCESS; | |
aef999a2 DA |
3730 | } |
3731 | ||
8233ef81 | 3732 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
3733 | DEFUN (bgp_network_import_check, |
3734 | bgp_network_import_check_cmd, | |
3735 | "bgp network import-check", | |
e9273987 | 3736 | BGP_STR |
1ca2fd11 IR |
3737 | "BGP network command\n" |
3738 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3739 | { |
1ca2fd11 IR |
3740 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3741 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3742 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3743 | bgp_static_redo_import_check(bgp); | |
3744 | } | |
078430f6 | 3745 | |
1ca2fd11 | 3746 | return CMD_SUCCESS; |
718e3744 | 3747 | } |
3748 | ||
d62a17ae | 3749 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3750 | "bgp network import-check exact", | |
e9273987 | 3751 | BGP_STR |
d62a17ae | 3752 | "BGP network command\n" |
3753 | "Check BGP network route exists in IGP\n" | |
3754 | "Match route precisely\n") | |
8233ef81 | 3755 | |
1ca2fd11 IR |
3756 | DEFUN (no_bgp_network_import_check, |
3757 | no_bgp_network_import_check_cmd, | |
3758 | "no bgp network import-check", | |
3759 | NO_STR | |
e9273987 | 3760 | BGP_STR |
1ca2fd11 IR |
3761 | "BGP network command\n" |
3762 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3763 | { |
1ca2fd11 IR |
3764 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3765 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3766 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3767 | bgp_static_redo_import_check(bgp); | |
3768 | } | |
6b0655a2 | 3769 | |
1ca2fd11 | 3770 | return CMD_SUCCESS; |
ff8a8a7a | 3771 | } |
718e3744 | 3772 | |
1ca2fd11 IR |
3773 | DEFUN (bgp_default_local_preference, |
3774 | bgp_default_local_preference_cmd, | |
3775 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 3776 | BGP_STR |
1ca2fd11 IR |
3777 | "Configure BGP defaults\n" |
3778 | "local preference (higher=more preferred)\n" | |
3779 | "Configure default local preference value\n") | |
ff8a8a7a | 3780 | { |
1ca2fd11 | 3781 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3782 | int idx_number = 3; |
1ca2fd11 | 3783 | uint32_t local_pref; |
718e3744 | 3784 | |
1ca2fd11 | 3785 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3786 | |
1ca2fd11 IR |
3787 | bgp_default_local_preference_set(bgp, local_pref); |
3788 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3789 | |
1ca2fd11 | 3790 | return CMD_SUCCESS; |
718e3744 | 3791 | } |
3792 | ||
1ca2fd11 IR |
3793 | DEFUN (no_bgp_default_local_preference, |
3794 | no_bgp_default_local_preference_cmd, | |
3795 | "no bgp default local-preference [(0-4294967295)]", | |
3796 | NO_STR | |
e9273987 | 3797 | BGP_STR |
1ca2fd11 IR |
3798 | "Configure BGP defaults\n" |
3799 | "local preference (higher=more preferred)\n" | |
3800 | "Configure default local preference value\n") | |
ff8a8a7a | 3801 | { |
1ca2fd11 IR |
3802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3803 | bgp_default_local_preference_unset(bgp); | |
3804 | bgp_clear_star_soft_in(vty, bgp->name); | |
3805 | ||
3806 | return CMD_SUCCESS; | |
ff8a8a7a | 3807 | } |
6b0655a2 | 3808 | |
ff8a8a7a | 3809 | |
1ca2fd11 IR |
3810 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3811 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3812 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 3813 | BGP_STR |
1ca2fd11 IR |
3814 | "Configure BGP defaults\n" |
3815 | "subgroup-pkt-queue-max\n" | |
3816 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3817 | { |
1ca2fd11 | 3818 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3819 | int idx_number = 3; |
1ca2fd11 | 3820 | uint32_t max_size; |
3f9c7369 | 3821 | |
1ca2fd11 | 3822 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3823 | |
1ca2fd11 | 3824 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 3825 | |
1ca2fd11 | 3826 | return CMD_SUCCESS; |
8bd9d948 DS |
3827 | } |
3828 | ||
1ca2fd11 IR |
3829 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
3830 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3831 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3832 | NO_STR | |
e9273987 | 3833 | BGP_STR |
1ca2fd11 IR |
3834 | "Configure BGP defaults\n" |
3835 | "subgroup-pkt-queue-max\n" | |
3836 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 3837 | { |
1ca2fd11 IR |
3838 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3839 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3840 | return CMD_SUCCESS; | |
ff8a8a7a | 3841 | } |
813d4307 | 3842 | |
8bd9d948 | 3843 | |
1ca2fd11 IR |
3844 | DEFUN (bgp_rr_allow_outbound_policy, |
3845 | bgp_rr_allow_outbound_policy_cmd, | |
3846 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 3847 | BGP_STR |
1ca2fd11 IR |
3848 | "Allow modifications made by out route-map\n" |
3849 | "on ibgp neighbors\n") | |
ff8a8a7a | 3850 | { |
1ca2fd11 | 3851 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3852 | |
1ca2fd11 IR |
3853 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3854 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3855 | update_group_announce_rrclients(bgp); | |
3856 | bgp_clear_star_soft_out(vty, bgp->name); | |
3857 | } | |
8bd9d948 | 3858 | |
1ca2fd11 IR |
3859 | return CMD_SUCCESS; |
3860 | } | |
ff8a8a7a | 3861 | |
1ca2fd11 IR |
3862 | DEFUN (no_bgp_rr_allow_outbound_policy, |
3863 | no_bgp_rr_allow_outbound_policy_cmd, | |
3864 | "no bgp route-reflector allow-outbound-policy", | |
3865 | NO_STR | |
e9273987 | 3866 | BGP_STR |
1ca2fd11 IR |
3867 | "Allow modifications made by out route-map\n" |
3868 | "on ibgp neighbors\n") | |
8bd9d948 | 3869 | { |
1ca2fd11 | 3870 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3871 | |
1ca2fd11 IR |
3872 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3873 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3874 | update_group_announce_rrclients(bgp); | |
3875 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 3876 | } |
8bd9d948 | 3877 | |
1ca2fd11 | 3878 | return CMD_SUCCESS; |
8bd9d948 DS |
3879 | } |
3880 | ||
1ca2fd11 IR |
3881 | DEFUN (bgp_listen_limit, |
3882 | bgp_listen_limit_cmd, | |
3883 | "bgp listen limit (1-65535)", | |
e9273987 | 3884 | BGP_STR |
1ca2fd11 IR |
3885 | "BGP Dynamic Neighbors listen commands\n" |
3886 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3887 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3888 | { |
1ca2fd11 | 3889 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3890 | int idx_number = 3; |
1ca2fd11 IR |
3891 | int listen_limit; |
3892 | ||
3893 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 3894 | |
1ca2fd11 | 3895 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3896 | |
1ca2fd11 | 3897 | return CMD_SUCCESS; |
f14e6fdb DS |
3898 | } |
3899 | ||
1ca2fd11 IR |
3900 | DEFUN (no_bgp_listen_limit, |
3901 | no_bgp_listen_limit_cmd, | |
3902 | "no bgp listen limit [(1-65535)]", | |
3903 | NO_STR | |
e9273987 | 3904 | BGP_STR |
1ca2fd11 IR |
3905 | "BGP Dynamic Neighbors listen commands\n" |
3906 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3907 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3908 | { |
1ca2fd11 IR |
3909 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3910 | bgp_listen_limit_unset(bgp); | |
3911 | return CMD_SUCCESS; | |
f14e6fdb DS |
3912 | } |
3913 | ||
3914 | ||
20eb8864 | 3915 | /* |
3916 | * Check if this listen range is already configured. Check for exact | |
3917 | * match or overlap based on input. | |
3918 | */ | |
d62a17ae | 3919 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3920 | struct prefix *range, int exact) | |
3921 | { | |
3922 | struct listnode *node, *nnode; | |
3923 | struct listnode *node1, *nnode1; | |
3924 | struct peer_group *group; | |
3925 | struct prefix *lr; | |
3926 | afi_t afi; | |
3927 | int match; | |
3928 | ||
3929 | afi = family2afi(range->family); | |
3930 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3931 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3932 | lr)) { | |
3933 | if (exact) | |
3934 | match = prefix_same(range, lr); | |
3935 | else | |
3936 | match = (prefix_match(range, lr) | |
3937 | || prefix_match(lr, range)); | |
3938 | if (match) | |
3939 | return group; | |
3940 | } | |
3941 | } | |
3942 | ||
3943 | return NULL; | |
20eb8864 | 3944 | } |
3945 | ||
f14e6fdb DS |
3946 | DEFUN (bgp_listen_range, |
3947 | bgp_listen_range_cmd, | |
d7b9898c | 3948 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 3949 | BGP_STR |
d7fa34c1 QY |
3950 | "Configure BGP dynamic neighbors listen range\n" |
3951 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3952 | NEIGHBOR_ADDR_STR |
3953 | "Member of the peer-group\n" | |
3954 | "Peer-group name\n") | |
f14e6fdb | 3955 | { |
d62a17ae | 3956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3957 | struct prefix range; | |
3958 | struct peer_group *group, *existing_group; | |
3959 | afi_t afi; | |
3960 | int ret; | |
3961 | int idx = 0; | |
3962 | ||
3963 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3964 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3965 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3966 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3967 | char *peergroup = argv[idx]->arg; |
3968 | ||
3969 | /* Convert IP prefix string to struct prefix. */ | |
3970 | ret = str2prefix(prefix, &range); | |
3971 | if (!ret) { | |
3972 | vty_out(vty, "%% Malformed listen range\n"); | |
3973 | return CMD_WARNING_CONFIG_FAILED; | |
3974 | } | |
3975 | ||
3976 | afi = family2afi(range.family); | |
3977 | ||
3978 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3979 | vty_out(vty, | |
3980 | "%% Malformed listen range (link-local address)\n"); | |
3981 | return CMD_WARNING_CONFIG_FAILED; | |
3982 | } | |
3983 | ||
3984 | apply_mask(&range); | |
3985 | ||
3986 | /* Check if same listen range is already configured. */ | |
3987 | existing_group = listen_range_exists(bgp, &range, 1); | |
3988 | if (existing_group) { | |
3989 | if (strcmp(existing_group->name, peergroup) == 0) | |
3990 | return CMD_SUCCESS; | |
3991 | else { | |
3992 | vty_out(vty, | |
3993 | "%% Same listen range is attached to peer-group %s\n", | |
3994 | existing_group->name); | |
3995 | return CMD_WARNING_CONFIG_FAILED; | |
3996 | } | |
3997 | } | |
3998 | ||
3999 | /* Check if an overlapping listen range exists. */ | |
4000 | if (listen_range_exists(bgp, &range, 0)) { | |
4001 | vty_out(vty, | |
4002 | "%% Listen range overlaps with existing listen range\n"); | |
4003 | return CMD_WARNING_CONFIG_FAILED; | |
4004 | } | |
4005 | ||
4006 | group = peer_group_lookup(bgp, peergroup); | |
4007 | if (!group) { | |
4008 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4009 | return CMD_WARNING_CONFIG_FAILED; | |
4010 | } | |
4011 | ||
4012 | ret = peer_group_listen_range_add(group, &range); | |
4013 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4014 | } |
4015 | ||
4016 | DEFUN (no_bgp_listen_range, | |
4017 | no_bgp_listen_range_cmd, | |
d7b9898c | 4018 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4019 | NO_STR |
e9273987 | 4020 | BGP_STR |
d7fa34c1 QY |
4021 | "Unconfigure BGP dynamic neighbors listen range\n" |
4022 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4023 | NEIGHBOR_ADDR_STR | |
4024 | "Member of the peer-group\n" | |
4025 | "Peer-group name\n") | |
f14e6fdb | 4026 | { |
d62a17ae | 4027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4028 | struct prefix range; | |
4029 | struct peer_group *group; | |
4030 | afi_t afi; | |
4031 | int ret; | |
4032 | int idx = 0; | |
4033 | ||
4034 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4035 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4036 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4037 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4038 | char *peergroup = argv[idx]->arg; |
4039 | ||
4040 | /* Convert IP prefix string to struct prefix. */ | |
4041 | ret = str2prefix(prefix, &range); | |
4042 | if (!ret) { | |
4043 | vty_out(vty, "%% Malformed listen range\n"); | |
4044 | return CMD_WARNING_CONFIG_FAILED; | |
4045 | } | |
4046 | ||
4047 | afi = family2afi(range.family); | |
4048 | ||
4049 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4050 | vty_out(vty, | |
4051 | "%% Malformed listen range (link-local address)\n"); | |
4052 | return CMD_WARNING_CONFIG_FAILED; | |
4053 | } | |
4054 | ||
4055 | apply_mask(&range); | |
4056 | ||
4057 | group = peer_group_lookup(bgp, peergroup); | |
4058 | if (!group) { | |
4059 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4060 | return CMD_WARNING_CONFIG_FAILED; | |
4061 | } | |
4062 | ||
4063 | ret = peer_group_listen_range_del(group, &range); | |
4064 | return bgp_vty_return(vty, ret); | |
4065 | } | |
4066 | ||
2b791107 | 4067 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4068 | { |
4069 | struct peer_group *group; | |
4070 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4071 | struct prefix *range; | |
4072 | afi_t afi; | |
d62a17ae | 4073 | |
4074 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4075 | vty_out(vty, " bgp listen limit %d\n", | |
4076 | bgp->dynamic_neighbors_limit); | |
4077 | ||
4078 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4079 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4080 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4081 | nrnode, range)) { | |
d62a17ae | 4082 | vty_out(vty, |
2dbe669b DA |
4083 | " bgp listen range %pFX peer-group %s\n", |
4084 | range, group->name); | |
d62a17ae | 4085 | } |
4086 | } | |
4087 | } | |
f14e6fdb DS |
4088 | } |
4089 | ||
4090 | ||
1ca2fd11 IR |
4091 | DEFUN (bgp_disable_connected_route_check, |
4092 | bgp_disable_connected_route_check_cmd, | |
4093 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4094 | BGP_STR |
1ca2fd11 | 4095 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4096 | { |
1ca2fd11 IR |
4097 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4098 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4099 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4100 | |
1ca2fd11 | 4101 | return CMD_SUCCESS; |
907f92c8 DS |
4102 | } |
4103 | ||
1ca2fd11 IR |
4104 | DEFUN (no_bgp_disable_connected_route_check, |
4105 | no_bgp_disable_connected_route_check_cmd, | |
4106 | "no bgp disable-ebgp-connected-route-check", | |
4107 | NO_STR | |
e9273987 | 4108 | BGP_STR |
1ca2fd11 | 4109 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4110 | { |
1ca2fd11 IR |
4111 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4112 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4113 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4114 | |
1ca2fd11 | 4115 | return CMD_SUCCESS; |
d62a17ae | 4116 | } |
4117 | ||
4118 | ||
28c6e247 IR |
4119 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4120 | const char *as_str) | |
4121 | { | |
4122 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4123 | int ret; | |
4124 | as_t as; | |
4125 | int as_type = AS_SPECIFIED; | |
4126 | union sockunion su; | |
4127 | ||
4128 | if (as_str[0] == 'i') { | |
4129 | as = 0; | |
4130 | as_type = AS_INTERNAL; | |
4131 | } else if (as_str[0] == 'e') { | |
4132 | as = 0; | |
4133 | as_type = AS_EXTERNAL; | |
4134 | } else { | |
4135 | /* Get AS number. */ | |
4136 | as = strtoul(as_str, NULL, 10); | |
4137 | } | |
4138 | ||
4139 | /* If peer is peer group or interface peer, call proper function. */ | |
4140 | ret = str2sockunion(peer_str, &su); | |
4141 | if (ret < 0) { | |
4142 | struct peer *peer; | |
4143 | ||
4144 | /* Check if existing interface peer */ | |
4145 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4146 | ||
4147 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4148 | ||
4149 | /* if not interface peer, check peer-group settings */ | |
4150 | if (ret < 0 && !peer) { | |
4151 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4152 | if (ret < 0) { | |
4153 | vty_out(vty, | |
4154 | "%% Create the peer-group or interface first\n"); | |
4155 | return CMD_WARNING_CONFIG_FAILED; | |
4156 | } | |
4157 | return CMD_SUCCESS; | |
4158 | } | |
4159 | } else { | |
4160 | if (peer_address_self_check(bgp, &su)) { | |
4161 | vty_out(vty, | |
4162 | "%% Can not configure the local system as neighbor\n"); | |
4163 | return CMD_WARNING_CONFIG_FAILED; | |
4164 | } | |
4165 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4166 | } | |
4167 | ||
4168 | /* This peer belongs to peer group. */ | |
4169 | switch (ret) { | |
4170 | case BGP_ERR_PEER_GROUP_MEMBER: | |
4171 | vty_out(vty, | |
4172 | "%% Peer-group member cannot override remote-as of peer-group\n"); | |
4173 | return CMD_WARNING_CONFIG_FAILED; | |
4174 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
4175 | vty_out(vty, | |
4176 | "%% Peer-group members must be all internal or all external\n"); | |
4177 | return CMD_WARNING_CONFIG_FAILED; | |
4178 | } | |
4179 | return bgp_vty_return(vty, ret); | |
4180 | } | |
4181 | ||
1ca2fd11 IR |
4182 | DEFUN (bgp_default_shutdown, |
4183 | bgp_default_shutdown_cmd, | |
4184 | "[no] bgp default shutdown", | |
4185 | NO_STR | |
4186 | BGP_STR | |
4187 | "Configure BGP defaults\n" | |
4188 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4189 | { |
1ca2fd11 IR |
4190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4191 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4192 | return CMD_SUCCESS; | |
f26845f9 QY |
4193 | } |
4194 | ||
736b68f3 DS |
4195 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4196 | BGP_STR | |
9ddf4b81 | 4197 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4198 | "Add a shutdown message (RFC 8203)\n" |
4199 | "Shutdown message\n") | |
9cf59432 | 4200 | { |
736b68f3 | 4201 | char *msgstr = NULL; |
8389c83a | 4202 | |
9cf59432 DS |
4203 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4204 | ||
8389c83a | 4205 | if (argc > 3) |
f80e35b6 | 4206 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4207 | |
4208 | bgp_shutdown_enable(bgp, msgstr); | |
4209 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4210 | |
4211 | return CMD_SUCCESS; | |
4212 | } | |
4213 | ||
736b68f3 | 4214 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4215 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4216 | { |
4217 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4218 | ||
4219 | bgp_shutdown_enable(bgp, NULL); | |
4220 | ||
4221 | return CMD_SUCCESS; | |
4222 | } | |
8389c83a | 4223 | |
736b68f3 | 4224 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4225 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4226 | { |
4227 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4228 | ||
4229 | bgp_shutdown_disable(bgp); | |
4230 | ||
4231 | return CMD_SUCCESS; | |
4232 | } | |
4233 | ||
9ddf4b81 | 4234 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4235 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4236 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4237 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4238 | |
28c6e247 IR |
4239 | DEFUN (neighbor_remote_as, |
4240 | neighbor_remote_as_cmd, | |
4241 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4242 | NEIGHBOR_STR | |
4243 | NEIGHBOR_ADDR_STR2 | |
4244 | "Specify a BGP neighbor\n" | |
4245 | AS_STR | |
4246 | "Internal BGP peer\n" | |
4247 | "External BGP peer\n") | |
718e3744 | 4248 | { |
d62a17ae | 4249 | int idx_peer = 1; |
4250 | int idx_remote_as = 3; | |
28c6e247 IR |
4251 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4252 | argv[idx_remote_as]->arg); | |
d62a17ae | 4253 | } |
f852eb98 PG |
4254 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4255 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4256 | * when nexthop becomes unreachable | |
4257 | */ | |
4258 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4259 | BGP_STR "Fast convergence for bgp sessions\n") | |
4260 | { | |
4261 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4262 | bgp->fast_convergence = true; | |
4263 | ||
4264 | return CMD_SUCCESS; | |
4265 | } | |
4266 | ||
4267 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4268 | "no bgp fast-convergence", | |
4269 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4270 | { | |
4271 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4272 | bgp->fast_convergence = false; | |
4273 | ||
4274 | return CMD_SUCCESS; | |
4275 | } | |
d62a17ae | 4276 | |
28c6e247 IR |
4277 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4278 | int v6only, | |
4279 | const char *peer_group_name, | |
4280 | const char *as_str) | |
d62a17ae | 4281 | { |
28c6e247 IR |
4282 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4283 | as_t as = 0; | |
4284 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4285 | struct peer *peer; |
4286 | struct peer_group *group; | |
4287 | int ret = 0; | |
d62a17ae | 4288 | |
4289 | group = peer_group_lookup(bgp, conf_if); | |
4290 | ||
4291 | if (group) { | |
28c6e247 IR |
4292 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4293 | return CMD_WARNING_CONFIG_FAILED; | |
4294 | } | |
4295 | ||
4296 | if (as_str) { | |
4297 | if (as_str[0] == 'i') { | |
4298 | as_type = AS_INTERNAL; | |
4299 | } else if (as_str[0] == 'e') { | |
4300 | as_type = AS_EXTERNAL; | |
4301 | } else { | |
4302 | /* Get AS number. */ | |
4303 | as = strtoul(as_str, NULL, 10); | |
4304 | as_type = AS_SPECIFIED; | |
4305 | } | |
d62a17ae | 4306 | } |
4307 | ||
4308 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4309 | if (peer) { | |
28c6e247 | 4310 | if (as_str) |
e84c59af | 4311 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4312 | } else { |
e84c59af DA |
4313 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
4314 | NULL); | |
d62a17ae | 4315 | |
4316 | if (!peer) { | |
28c6e247 IR |
4317 | vty_out(vty, "%% BGP failed to create peer\n"); |
4318 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4319 | } |
4320 | ||
4321 | if (v6only) | |
527de3dc | 4322 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4323 | |
4324 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4325 | * this | |
4326 | * any unnumbered peer in order to not worry about run-time | |
4327 | * transitions | |
4328 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4329 | * address | |
4330 | * gets deleted later etc.) | |
4331 | */ | |
4332 | if (peer->ifp) | |
4333 | bgp_zebra_initiate_radv(bgp, peer); | |
4334 | } | |
4335 | ||
4336 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4337 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4338 | if (v6only) | |
527de3dc | 4339 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4340 | else |
527de3dc | 4341 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4342 | |
4343 | /* v6only flag changed. Reset bgp seesion */ | |
4344 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4345 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4346 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4347 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4348 | } else | |
4349 | bgp_session_reset(peer); | |
4350 | } | |
4351 | ||
9fb964de PM |
4352 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4353 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4354 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4355 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4356 | } |
d62a17ae | 4357 | |
4358 | if (peer_group_name) { | |
4359 | group = peer_group_lookup(bgp, peer_group_name); | |
4360 | if (!group) { | |
28c6e247 IR |
4361 | vty_out(vty, "%% Configure the peer-group first\n"); |
4362 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4363 | } |
4364 | ||
8395c1f8 | 4365 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4366 | } |
4367 | ||
28c6e247 | 4368 | return bgp_vty_return(vty, ret); |
a80beece DS |
4369 | } |
4370 | ||
28c6e247 IR |
4371 | DEFUN (neighbor_interface_config, |
4372 | neighbor_interface_config_cmd, | |
4373 | "neighbor WORD interface [peer-group PGNAME]", | |
4374 | NEIGHBOR_STR | |
4375 | "Interface name or neighbor tag\n" | |
4376 | "Enable BGP on interface\n" | |
4377 | "Member of the peer-group\n" | |
4378 | "Peer-group name\n") | |
4c48cf63 | 4379 | { |
d62a17ae | 4380 | int idx_word = 1; |
4381 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4382 | |
d62a17ae | 4383 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4384 | return peer_conf_interface_get( |
4385 | vty, argv[idx_word]->arg, 0, | |
4386 | argv[idx_peer_group_word]->arg, NULL); | |
4387 | else | |
4388 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4389 | NULL, NULL); | |
4c48cf63 DW |
4390 | } |
4391 | ||
28c6e247 IR |
4392 | DEFUN (neighbor_interface_config_v6only, |
4393 | neighbor_interface_config_v6only_cmd, | |
4394 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4395 | NEIGHBOR_STR | |
4396 | "Interface name or neighbor tag\n" | |
4397 | "Enable BGP on interface\n" | |
4398 | "Enable BGP with v6 link-local only\n" | |
4399 | "Member of the peer-group\n" | |
4400 | "Peer-group name\n") | |
4c48cf63 | 4401 | { |
d62a17ae | 4402 | int idx_word = 1; |
4403 | int idx_peer_group_word = 5; | |
31500417 | 4404 | |
d62a17ae | 4405 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4406 | return peer_conf_interface_get( |
4407 | vty, argv[idx_word]->arg, 1, | |
4408 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4409 | |
28c6e247 | 4410 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4411 | } |
4412 | ||
a80beece | 4413 | |
28c6e247 IR |
4414 | DEFUN (neighbor_interface_config_remote_as, |
4415 | neighbor_interface_config_remote_as_cmd, | |
4416 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4417 | NEIGHBOR_STR | |
4418 | "Interface name or neighbor tag\n" | |
4419 | "Enable BGP on interface\n" | |
4420 | "Specify a BGP neighbor\n" | |
4421 | AS_STR | |
4422 | "Internal BGP peer\n" | |
4423 | "External BGP peer\n") | |
b3a39dc5 | 4424 | { |
d62a17ae | 4425 | int idx_word = 1; |
4426 | int idx_remote_as = 4; | |
28c6e247 IR |
4427 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4428 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4429 | } |
4430 | ||
28c6e247 IR |
4431 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4432 | neighbor_interface_v6only_config_remote_as_cmd, | |
4433 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4434 | NEIGHBOR_STR | |
4435 | "Interface name or neighbor tag\n" | |
4436 | "Enable BGP with v6 link-local only\n" | |
4437 | "Enable BGP on interface\n" | |
4438 | "Specify a BGP neighbor\n" | |
4439 | AS_STR | |
4440 | "Internal BGP peer\n" | |
4441 | "External BGP peer\n") | |
b3a39dc5 | 4442 | { |
d62a17ae | 4443 | int idx_word = 1; |
4444 | int idx_remote_as = 5; | |
28c6e247 IR |
4445 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4446 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4447 | } |
4448 | ||
28c6e247 IR |
4449 | DEFUN (neighbor_peer_group, |
4450 | neighbor_peer_group_cmd, | |
4451 | "neighbor WORD peer-group", | |
4452 | NEIGHBOR_STR | |
4453 | "Interface name or neighbor tag\n" | |
4454 | "Configure peer-group\n") | |
718e3744 | 4455 | { |
28c6e247 | 4456 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4457 | int idx_word = 1; |
28c6e247 IR |
4458 | struct peer *peer; |
4459 | struct peer_group *group; | |
718e3744 | 4460 | |
28c6e247 IR |
4461 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4462 | if (peer) { | |
4463 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4464 | return CMD_WARNING_CONFIG_FAILED; | |
4465 | } | |
718e3744 | 4466 | |
28c6e247 IR |
4467 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4468 | if (!group) { | |
4469 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4470 | return CMD_WARNING_CONFIG_FAILED; | |
4471 | } | |
718e3744 | 4472 | |
28c6e247 | 4473 | return CMD_SUCCESS; |
718e3744 | 4474 | } |
4475 | ||
1d80f243 IR |
4476 | DEFUN (no_neighbor, |
4477 | no_neighbor_cmd, | |
4478 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4479 | NO_STR | |
4480 | NEIGHBOR_STR | |
4481 | NEIGHBOR_ADDR_STR2 | |
4482 | "Specify a BGP neighbor\n" | |
4483 | AS_STR | |
4484 | "Internal BGP peer\n" | |
4485 | "External BGP peer\n") | |
718e3744 | 4486 | { |
28c6e247 | 4487 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4488 | int idx_peer = 2; |
28c6e247 | 4489 | int ret; |
d62a17ae | 4490 | union sockunion su; |
28c6e247 IR |
4491 | struct peer_group *group; |
4492 | struct peer *peer; | |
4493 | struct peer *other; | |
d62a17ae | 4494 | |
28c6e247 IR |
4495 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4496 | if (ret < 0) { | |
4497 | /* look up for neighbor by interface name config. */ | |
4498 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4499 | if (peer) { | |
4500 | /* Request zebra to terminate IPv6 RAs on this | |
4501 | * interface. */ | |
4502 | if (peer->ifp) | |
4503 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4504 | peer_notify_unconfig(peer); | |
4505 | peer_delete(peer); | |
4506 | return CMD_SUCCESS; | |
d62a17ae | 4507 | } |
28c6e247 IR |
4508 | |
4509 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4510 | if (group) { | |
4511 | peer_group_notify_unconfig(group); | |
4512 | peer_group_delete(group); | |
4e2786df | 4513 | } else { |
28c6e247 | 4514 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4515 | return CMD_WARNING_CONFIG_FAILED; |
4516 | } | |
28c6e247 IR |
4517 | } else { |
4518 | peer = peer_lookup(bgp, &su); | |
4519 | if (peer) { | |
4520 | if (peer_dynamic_neighbor(peer)) { | |
4521 | vty_out(vty, | |
4522 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4523 | return CMD_WARNING_CONFIG_FAILED; | |
4524 | } | |
d62a17ae | 4525 | |
28c6e247 | 4526 | other = peer->doppelganger; |
f4b8ec07 | 4527 | |
28c6e247 IR |
4528 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4529 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4530 | |
28c6e247 IR |
4531 | peer_notify_unconfig(peer); |
4532 | peer_delete(peer); | |
4533 | if (other && other->status != Deleted) { | |
4534 | peer_notify_unconfig(other); | |
4535 | peer_delete(other); | |
4536 | } | |
4537 | } | |
4538 | } | |
4539 | ||
4540 | return CMD_SUCCESS; | |
a80beece DS |
4541 | } |
4542 | ||
28c6e247 IR |
4543 | DEFUN (no_neighbor_interface_config, |
4544 | no_neighbor_interface_config_cmd, | |
4545 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4546 | NO_STR | |
4547 | NEIGHBOR_STR | |
4548 | "Interface name\n" | |
4549 | "Configure BGP on interface\n" | |
4550 | "Enable BGP with v6 link-local only\n" | |
4551 | "Member of the peer-group\n" | |
4552 | "Peer-group name\n" | |
4553 | "Specify a BGP neighbor\n" | |
4554 | AS_STR | |
4555 | "Internal BGP peer\n" | |
4556 | "External BGP peer\n") | |
718e3744 | 4557 | { |
28c6e247 | 4558 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4559 | int idx_word = 2; |
28c6e247 | 4560 | struct peer *peer; |
718e3744 | 4561 | |
28c6e247 IR |
4562 | /* look up for neighbor by interface name config. */ |
4563 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4564 | if (peer) { | |
4565 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4566 | if (peer->ifp) | |
4567 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4568 | peer_notify_unconfig(peer); | |
4569 | peer_delete(peer); | |
4570 | } else { | |
4571 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4572 | return CMD_WARNING_CONFIG_FAILED; | |
4573 | } | |
4574 | return CMD_SUCCESS; | |
718e3744 | 4575 | } |
4576 | ||
28c6e247 IR |
4577 | DEFUN (no_neighbor_peer_group, |
4578 | no_neighbor_peer_group_cmd, | |
4579 | "no neighbor WORD peer-group", | |
4580 | NO_STR | |
4581 | NEIGHBOR_STR | |
4582 | "Neighbor tag\n" | |
4583 | "Configure peer-group\n") | |
718e3744 | 4584 | { |
28c6e247 IR |
4585 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4586 | int idx_word = 2; | |
4587 | struct peer_group *group; | |
f4b8ec07 | 4588 | |
28c6e247 IR |
4589 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4590 | if (group) { | |
4591 | peer_group_notify_unconfig(group); | |
4592 | peer_group_delete(group); | |
f4b8ec07 | 4593 | } else { |
28c6e247 | 4594 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4595 | return CMD_WARNING_CONFIG_FAILED; |
4596 | } | |
28c6e247 IR |
4597 | return CMD_SUCCESS; |
4598 | } | |
f4b8ec07 | 4599 | |
28c6e247 IR |
4600 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4601 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4602 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4603 | NO_STR | |
4604 | NEIGHBOR_STR | |
4605 | "Interface name or neighbor tag\n" | |
4606 | "Specify a BGP neighbor\n" | |
4607 | AS_STR | |
4608 | "Internal BGP peer\n" | |
4609 | "External BGP peer\n") | |
4610 | { | |
4611 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4612 | int idx_word = 2; | |
4613 | struct peer_group *group; | |
4614 | struct peer *peer; | |
f4b8ec07 | 4615 | |
28c6e247 IR |
4616 | /* look up for neighbor by interface name config. */ |
4617 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4618 | if (peer) { | |
4619 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4620 | return CMD_SUCCESS; | |
4621 | } | |
f4b8ec07 | 4622 | |
28c6e247 IR |
4623 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4624 | if (group) | |
4625 | peer_group_remote_as_delete(group); | |
4626 | else { | |
4627 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4628 | return CMD_WARNING_CONFIG_FAILED; | |
4629 | } | |
4630 | return CMD_SUCCESS; | |
718e3744 | 4631 | } |
6b0655a2 | 4632 | |
28c6e247 IR |
4633 | DEFUN (neighbor_local_as, |
4634 | neighbor_local_as_cmd, | |
4635 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4636 | NEIGHBOR_STR | |
4637 | NEIGHBOR_ADDR_STR2 | |
4638 | "Specify a local-as number\n" | |
4639 | "AS number used as local AS\n") | |
718e3744 | 4640 | { |
d62a17ae | 4641 | int idx_peer = 1; |
4642 | int idx_number = 3; | |
28c6e247 IR |
4643 | struct peer *peer; |
4644 | int ret; | |
4645 | as_t as; | |
718e3744 | 4646 | |
28c6e247 IR |
4647 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4648 | if (!peer) | |
d62a17ae | 4649 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4650 | |
28c6e247 IR |
4651 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4652 | ret = peer_local_as_set(peer, as, 0, 0); | |
4653 | return bgp_vty_return(vty, ret); | |
718e3744 | 4654 | } |
4655 | ||
28c6e247 IR |
4656 | DEFUN (neighbor_local_as_no_prepend, |
4657 | neighbor_local_as_no_prepend_cmd, | |
4658 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4659 | NEIGHBOR_STR | |
4660 | NEIGHBOR_ADDR_STR2 | |
4661 | "Specify a local-as number\n" | |
4662 | "AS number used as local AS\n" | |
4663 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4664 | { |
d62a17ae | 4665 | int idx_peer = 1; |
4666 | int idx_number = 3; | |
28c6e247 IR |
4667 | struct peer *peer; |
4668 | int ret; | |
4669 | as_t as; | |
718e3744 | 4670 | |
28c6e247 IR |
4671 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4672 | if (!peer) | |
d62a17ae | 4673 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4674 | |
28c6e247 IR |
4675 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4676 | ret = peer_local_as_set(peer, as, 1, 0); | |
4677 | return bgp_vty_return(vty, ret); | |
718e3744 | 4678 | } |
4679 | ||
28c6e247 IR |
4680 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4681 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4682 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4683 | NEIGHBOR_STR | |
4684 | NEIGHBOR_ADDR_STR2 | |
4685 | "Specify a local-as number\n" | |
4686 | "AS number used as local AS\n" | |
4687 | "Do not prepend local-as to updates from ebgp peers\n" | |
4688 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4689 | { |
d62a17ae | 4690 | int idx_peer = 1; |
4691 | int idx_number = 3; | |
28c6e247 IR |
4692 | struct peer *peer; |
4693 | int ret; | |
4694 | as_t as; | |
9d3f9705 | 4695 | |
28c6e247 IR |
4696 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4697 | if (!peer) | |
d62a17ae | 4698 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4699 | |
28c6e247 IR |
4700 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4701 | ret = peer_local_as_set(peer, as, 1, 1); | |
4702 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4703 | } |
4704 | ||
28c6e247 IR |
4705 | DEFUN (no_neighbor_local_as, |
4706 | no_neighbor_local_as_cmd, | |
4707 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4708 | NO_STR | |
4709 | NEIGHBOR_STR | |
4710 | NEIGHBOR_ADDR_STR2 | |
4711 | "Specify a local-as number\n" | |
4712 | "AS number used as local AS\n" | |
4713 | "Do not prepend local-as to updates from ebgp peers\n" | |
4714 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4715 | { |
d62a17ae | 4716 | int idx_peer = 2; |
28c6e247 IR |
4717 | struct peer *peer; |
4718 | int ret; | |
718e3744 | 4719 | |
28c6e247 IR |
4720 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4721 | if (!peer) | |
d62a17ae | 4722 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4723 | |
28c6e247 IR |
4724 | ret = peer_local_as_unset(peer); |
4725 | return bgp_vty_return(vty, ret); | |
718e3744 | 4726 | } |
4727 | ||
718e3744 | 4728 | |
3f9c7369 DS |
4729 | DEFUN (neighbor_solo, |
4730 | neighbor_solo_cmd, | |
9ccf14f7 | 4731 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4732 | NEIGHBOR_STR |
4733 | NEIGHBOR_ADDR_STR2 | |
4734 | "Solo peer - part of its own update group\n") | |
4735 | { | |
d62a17ae | 4736 | int idx_peer = 1; |
4737 | struct peer *peer; | |
4738 | int ret; | |
3f9c7369 | 4739 | |
d62a17ae | 4740 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4741 | if (!peer) | |
4742 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4743 | |
d62a17ae | 4744 | ret = update_group_adjust_soloness(peer, 1); |
4745 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4746 | } |
4747 | ||
4748 | DEFUN (no_neighbor_solo, | |
4749 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4750 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4751 | NO_STR |
4752 | NEIGHBOR_STR | |
4753 | NEIGHBOR_ADDR_STR2 | |
4754 | "Solo peer - part of its own update group\n") | |
4755 | { | |
d62a17ae | 4756 | int idx_peer = 2; |
4757 | struct peer *peer; | |
4758 | int ret; | |
3f9c7369 | 4759 | |
d62a17ae | 4760 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4761 | if (!peer) | |
4762 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4763 | |
d62a17ae | 4764 | ret = update_group_adjust_soloness(peer, 0); |
4765 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4766 | } |
4767 | ||
28c6e247 IR |
4768 | DEFUN (neighbor_password, |
4769 | neighbor_password_cmd, | |
4770 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4771 | NEIGHBOR_STR | |
4772 | NEIGHBOR_ADDR_STR2 | |
4773 | "Set a password\n" | |
4774 | "The password\n") | |
0df7c91f | 4775 | { |
d62a17ae | 4776 | int idx_peer = 1; |
4777 | int idx_line = 3; | |
28c6e247 IR |
4778 | struct peer *peer; |
4779 | int ret; | |
0df7c91f | 4780 | |
28c6e247 IR |
4781 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4782 | if (!peer) | |
d62a17ae | 4783 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4784 | |
28c6e247 IR |
4785 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4786 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4787 | } |
4788 | ||
28c6e247 IR |
4789 | DEFUN (no_neighbor_password, |
4790 | no_neighbor_password_cmd, | |
4791 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4792 | NO_STR | |
4793 | NEIGHBOR_STR | |
4794 | NEIGHBOR_ADDR_STR2 | |
4795 | "Set a password\n" | |
4796 | "The password\n") | |
0df7c91f | 4797 | { |
d62a17ae | 4798 | int idx_peer = 2; |
28c6e247 IR |
4799 | struct peer *peer; |
4800 | int ret; | |
0df7c91f | 4801 | |
28c6e247 IR |
4802 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4803 | if (!peer) | |
d62a17ae | 4804 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4805 | |
28c6e247 IR |
4806 | ret = peer_password_unset(peer); |
4807 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4808 | } |
6b0655a2 | 4809 | |
28c6e247 IR |
4810 | DEFUN (neighbor_activate, |
4811 | neighbor_activate_cmd, | |
4812 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4813 | NEIGHBOR_STR | |
4814 | NEIGHBOR_ADDR_STR2 | |
4815 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4816 | { |
d62a17ae | 4817 | int idx_peer = 1; |
28c6e247 IR |
4818 | int ret; |
4819 | struct peer *peer; | |
56ceae84 | 4820 | |
28c6e247 IR |
4821 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4822 | if (!peer) | |
d62a17ae | 4823 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4824 | |
28c6e247 IR |
4825 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4826 | return bgp_vty_return(vty, ret); | |
718e3744 | 4827 | } |
4828 | ||
d62a17ae | 4829 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4830 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4831 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4832 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4833 | |
28c6e247 IR |
4834 | DEFUN (no_neighbor_activate, |
4835 | no_neighbor_activate_cmd, | |
4836 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4837 | NO_STR | |
4838 | NEIGHBOR_STR | |
4839 | NEIGHBOR_ADDR_STR2 | |
4840 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4841 | { |
d62a17ae | 4842 | int idx_peer = 2; |
28c6e247 IR |
4843 | int ret; |
4844 | struct peer *peer; | |
f4b8ec07 | 4845 | |
28c6e247 IR |
4846 | /* Lookup peer. */ |
4847 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4848 | if (!peer) | |
d62a17ae | 4849 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4850 | |
28c6e247 IR |
4851 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4852 | return bgp_vty_return(vty, ret); | |
718e3744 | 4853 | } |
6b0655a2 | 4854 | |
d62a17ae | 4855 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4856 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4857 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4858 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4859 | |
28c6e247 IR |
4860 | DEFUN (neighbor_set_peer_group, |
4861 | neighbor_set_peer_group_cmd, | |
4862 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4863 | NEIGHBOR_STR | |
4864 | NEIGHBOR_ADDR_STR2 | |
4865 | "Member of the peer-group\n" | |
4866 | "Peer-group name\n") | |
718e3744 | 4867 | { |
28c6e247 | 4868 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4869 | int idx_peer = 1; |
4870 | int idx_word = 3; | |
28c6e247 IR |
4871 | int ret; |
4872 | as_t as; | |
4873 | union sockunion su; | |
4874 | struct peer *peer; | |
4875 | struct peer_group *group; | |
4876 | ||
4877 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4878 | if (ret < 0) { | |
4879 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4880 | if (!peer) { | |
4881 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4882 | argv[idx_peer]->arg); | |
4883 | return CMD_WARNING_CONFIG_FAILED; | |
4884 | } | |
4885 | } else { | |
4886 | if (peer_address_self_check(bgp, &su)) { | |
4887 | vty_out(vty, | |
4888 | "%% Can not configure the local system as neighbor\n"); | |
4889 | return CMD_WARNING_CONFIG_FAILED; | |
4890 | } | |
2a059a54 | 4891 | |
28c6e247 IR |
4892 | /* Disallow for dynamic neighbor. */ |
4893 | peer = peer_lookup(bgp, &su); | |
4894 | if (peer && peer_dynamic_neighbor(peer)) { | |
4895 | vty_out(vty, | |
4896 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4897 | return CMD_WARNING_CONFIG_FAILED; | |
4898 | } | |
4899 | } | |
4900 | ||
4901 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4902 | if (!group) { | |
4903 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 4904 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 4905 | } |
d62a17ae | 4906 | |
28c6e247 | 4907 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 4908 | |
28c6e247 IR |
4909 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { |
4910 | vty_out(vty, | |
4911 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4912 | as); | |
4913 | return CMD_WARNING_CONFIG_FAILED; | |
4914 | } | |
4915 | ||
4916 | return bgp_vty_return(vty, ret); | |
d62a17ae | 4917 | } |
4918 | ||
4919 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4920 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4921 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4922 | "Member of the peer-group\n" | |
4923 | "Peer-group name\n") | |
596c17ba | 4924 | |
28c6e247 IR |
4925 | DEFUN (no_neighbor_set_peer_group, |
4926 | no_neighbor_set_peer_group_cmd, | |
4927 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4928 | NO_STR | |
4929 | NEIGHBOR_STR | |
4930 | NEIGHBOR_ADDR_STR2 | |
4931 | "Member of the peer-group\n" | |
4932 | "Peer-group name\n") | |
718e3744 | 4933 | { |
28c6e247 | 4934 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4935 | int idx_peer = 2; |
28c6e247 IR |
4936 | int idx_word = 4; |
4937 | int ret; | |
4938 | struct peer *peer; | |
4939 | struct peer_group *group; | |
d62a17ae | 4940 | |
28c6e247 IR |
4941 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
4942 | if (!peer) | |
d62a17ae | 4943 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 4944 | |
28c6e247 IR |
4945 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4946 | if (!group) { | |
4947 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4948 | return CMD_WARNING_CONFIG_FAILED; | |
4949 | } | |
718e3744 | 4950 | |
28c6e247 IR |
4951 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4952 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4953 | ||
4954 | peer_notify_unconfig(peer); | |
4955 | ret = peer_delete(peer); | |
4956 | ||
4957 | return bgp_vty_return(vty, ret); | |
718e3744 | 4958 | } |
6b0655a2 | 4959 | |
d62a17ae | 4960 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 4961 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4962 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4963 | "Member of the peer-group\n" | |
4964 | "Peer-group name\n") | |
596c17ba | 4965 | |
d62a17ae | 4966 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4967 | uint32_t flag, int set) |
718e3744 | 4968 | { |
d62a17ae | 4969 | int ret; |
4970 | struct peer *peer; | |
718e3744 | 4971 | |
d62a17ae | 4972 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4973 | if (!peer) | |
4974 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4975 | |
7ebe625c QY |
4976 | /* |
4977 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4978 | * we should not accept disable-connected-check. | |
4979 | */ | |
4980 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4981 | vty_out(vty, | |
3efd0893 | 4982 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4983 | ip_str); |
4984 | return CMD_WARNING_CONFIG_FAILED; | |
4985 | } | |
4986 | ||
d62a17ae | 4987 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4988 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4989 | |
d62a17ae | 4990 | if (set) |
4991 | ret = peer_flag_set(peer, flag); | |
4992 | else | |
4993 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4994 | |
d62a17ae | 4995 | return bgp_vty_return(vty, ret); |
718e3744 | 4996 | } |
4997 | ||
47cbc09b | 4998 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4999 | { |
d62a17ae | 5000 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 5001 | } |
5002 | ||
d62a17ae | 5003 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5004 | uint32_t flag) |
718e3744 | 5005 | { |
d62a17ae | 5006 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 5007 | } |
5008 | ||
5009 | /* neighbor passive. */ | |
28c6e247 IR |
5010 | DEFUN (neighbor_passive, |
5011 | neighbor_passive_cmd, | |
5012 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5013 | NEIGHBOR_STR | |
5014 | NEIGHBOR_ADDR_STR2 | |
5015 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5016 | { |
d62a17ae | 5017 | int idx_peer = 1; |
28c6e247 | 5018 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5019 | } |
5020 | ||
28c6e247 IR |
5021 | DEFUN (no_neighbor_passive, |
5022 | no_neighbor_passive_cmd, | |
5023 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5024 | NO_STR | |
5025 | NEIGHBOR_STR | |
5026 | NEIGHBOR_ADDR_STR2 | |
5027 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5028 | { |
d62a17ae | 5029 | int idx_peer = 2; |
28c6e247 | 5030 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5031 | } |
6b0655a2 | 5032 | |
718e3744 | 5033 | /* neighbor shutdown. */ |
28c6e247 IR |
5034 | DEFUN (neighbor_shutdown_msg, |
5035 | neighbor_shutdown_msg_cmd, | |
5036 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5037 | NEIGHBOR_STR | |
5038 | NEIGHBOR_ADDR_STR2 | |
5039 | "Administratively shut down this neighbor\n" | |
5040 | "Add a shutdown message (RFC 8203)\n" | |
5041 | "Shutdown message\n") | |
718e3744 | 5042 | { |
d62a17ae | 5043 | int idx_peer = 1; |
73d70fa6 | 5044 | |
d62a17ae | 5045 | if (argc >= 5) { |
28c6e247 IR |
5046 | struct peer *peer = |
5047 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 5048 | char *message; |
73d70fa6 | 5049 | |
28c6e247 IR |
5050 | if (!peer) |
5051 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5052 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
5053 | peer_tx_shutdown_message_set(peer, message); |
5054 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 5055 | } |
73d70fa6 | 5056 | |
28c6e247 | 5057 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5058 | } |
5059 | ||
1d80f243 | 5060 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5061 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5062 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5063 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5064 | |
28c6e247 IR |
5065 | DEFUN (no_neighbor_shutdown_msg, |
5066 | no_neighbor_shutdown_msg_cmd, | |
5067 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5068 | NO_STR | |
5069 | NEIGHBOR_STR | |
5070 | NEIGHBOR_ADDR_STR2 | |
5071 | "Administratively shut down this neighbor\n" | |
5072 | "Remove a shutdown message (RFC 8203)\n" | |
5073 | "Shutdown message\n") | |
718e3744 | 5074 | { |
d62a17ae | 5075 | int idx_peer = 2; |
73d70fa6 | 5076 | |
28c6e247 IR |
5077 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5078 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5079 | } |
6b0655a2 | 5080 | |
1d80f243 | 5081 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5082 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5083 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5084 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5085 | |
8336c896 DA |
5086 | DEFUN(neighbor_shutdown_rtt, |
5087 | neighbor_shutdown_rtt_cmd, | |
5088 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5089 | NEIGHBOR_STR | |
5090 | NEIGHBOR_ADDR_STR2 | |
5091 | "Administratively shut down this neighbor\n" | |
5092 | "Shutdown if round-trip-time is higher than expected\n" | |
5093 | "Round-trip-time in milliseconds\n" | |
5094 | "Specify the number of keepalives before shutdown\n" | |
5095 | "The number of keepalives with higher RTT to shutdown\n") | |
5096 | { | |
5097 | int idx_peer = 1; | |
5098 | int idx_rtt = 4; | |
5099 | int idx_count = 0; | |
5100 | struct peer *peer; | |
5101 | ||
5102 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5103 | ||
5104 | if (!peer) | |
5105 | return CMD_WARNING_CONFIG_FAILED; | |
5106 | ||
5107 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5108 | ||
5109 | if (argv_find(argv, argc, "count", &idx_count)) | |
5110 | peer->rtt_keepalive_conf = | |
5111 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5112 | ||
5113 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5114 | PEER_FLAG_RTT_SHUTDOWN); | |
5115 | } | |
5116 | ||
5117 | DEFUN(no_neighbor_shutdown_rtt, | |
5118 | no_neighbor_shutdown_rtt_cmd, | |
5119 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5120 | NO_STR | |
5121 | NEIGHBOR_STR | |
5122 | NEIGHBOR_ADDR_STR2 | |
5123 | "Administratively shut down this neighbor\n" | |
5124 | "Shutdown if round-trip-time is higher than expected\n" | |
5125 | "Round-trip-time in milliseconds\n" | |
5126 | "Specify the number of keepalives before shutdown\n" | |
5127 | "The number of keepalives with higher RTT to shutdown\n") | |
5128 | { | |
5129 | int idx_peer = 2; | |
5130 | struct peer *peer; | |
5131 | ||
5132 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5133 | ||
5134 | if (!peer) | |
5135 | return CMD_WARNING_CONFIG_FAILED; | |
5136 | ||
5137 | peer->rtt_expected = 0; | |
5138 | peer->rtt_keepalive_conf = 1; | |
5139 | ||
5140 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5141 | PEER_FLAG_RTT_SHUTDOWN); | |
5142 | } | |
5143 | ||
718e3744 | 5144 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5145 | DEFUN (neighbor_capability_dynamic, |
5146 | neighbor_capability_dynamic_cmd, | |
5147 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5148 | NEIGHBOR_STR | |
5149 | NEIGHBOR_ADDR_STR2 | |
5150 | "Advertise capability to the peer\n" | |
5151 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5152 | { |
d62a17ae | 5153 | int idx_peer = 1; |
28c6e247 IR |
5154 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5155 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5156 | } |
5157 | ||
28c6e247 IR |
5158 | DEFUN (no_neighbor_capability_dynamic, |
5159 | no_neighbor_capability_dynamic_cmd, | |
5160 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5161 | NO_STR | |
5162 | NEIGHBOR_STR | |
5163 | NEIGHBOR_ADDR_STR2 | |
5164 | "Advertise capability to the peer\n" | |
5165 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5166 | { |
d62a17ae | 5167 | int idx_peer = 2; |
28c6e247 IR |
5168 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5169 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5170 | } |
6b0655a2 | 5171 | |
718e3744 | 5172 | /* neighbor dont-capability-negotiate */ |
5173 | DEFUN (neighbor_dont_capability_negotiate, | |
5174 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5175 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5176 | NEIGHBOR_STR |
5177 | NEIGHBOR_ADDR_STR2 | |
5178 | "Do not perform capability negotiation\n") | |
5179 | { | |
d62a17ae | 5180 | int idx_peer = 1; |
5181 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5182 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5183 | } |
5184 | ||
5185 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5186 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5187 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5188 | NO_STR |
5189 | NEIGHBOR_STR | |
5190 | NEIGHBOR_ADDR_STR2 | |
5191 | "Do not perform capability negotiation\n") | |
5192 | { | |
28c6e247 IR |
5193 | int idx_peer = 2; |
5194 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5195 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5196 | } |
5197 | ||
28c6e247 IR |
5198 | /* neighbor capability extended next hop encoding */ |
5199 | DEFUN (neighbor_capability_enhe, | |
5200 | neighbor_capability_enhe_cmd, | |
5201 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5202 | NEIGHBOR_STR | |
5203 | NEIGHBOR_ADDR_STR2 | |
5204 | "Advertise capability to the peer\n" | |
5205 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5206 | { |
28c6e247 IR |
5207 | int idx_peer = 1; |
5208 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5209 | PEER_FLAG_CAPABILITY_ENHE); | |
5210 | } | |
f4b8ec07 | 5211 | |
28c6e247 IR |
5212 | DEFUN (no_neighbor_capability_enhe, |
5213 | no_neighbor_capability_enhe_cmd, | |
5214 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5215 | NO_STR | |
5216 | NEIGHBOR_STR | |
5217 | NEIGHBOR_ADDR_STR2 | |
5218 | "Advertise capability to the peer\n" | |
5219 | "Advertise extended next-hop capability to the peer\n") | |
5220 | { | |
5221 | int idx_peer = 2; | |
5222 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5223 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5224 | } |
5225 | ||
d62a17ae | 5226 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5227 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5228 | int set) |
718e3744 | 5229 | { |
d62a17ae | 5230 | int ret; |
5231 | struct peer *peer; | |
718e3744 | 5232 | |
d62a17ae | 5233 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5234 | if (!peer) | |
5235 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5236 | |
d62a17ae | 5237 | if (set) |
5238 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5239 | else | |
5240 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5241 | |
d62a17ae | 5242 | return bgp_vty_return(vty, ret); |
718e3744 | 5243 | } |
5244 | ||
d62a17ae | 5245 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5246 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5247 | { |
d62a17ae | 5248 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5249 | } |
5250 | ||
d62a17ae | 5251 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5252 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5253 | { |
d62a17ae | 5254 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5255 | } |
6b0655a2 | 5256 | |
718e3744 | 5257 | /* neighbor capability orf prefix-list. */ |
5258 | DEFUN (neighbor_capability_orf_prefix, | |
5259 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5260 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5261 | NEIGHBOR_STR |
5262 | NEIGHBOR_ADDR_STR2 | |
5263 | "Advertise capability to the peer\n" | |
5264 | "Advertise ORF capability to the peer\n" | |
5265 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5266 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5267 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5268 | "Capability to SEND the ORF to this neighbor\n") | |
5269 | { | |
d62a17ae | 5270 | int idx_send_recv = 5; |
db45f64d DS |
5271 | char *peer_str = argv[1]->arg; |
5272 | struct peer *peer; | |
5273 | afi_t afi = bgp_node_afi(vty); | |
5274 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5275 | |
db45f64d DS |
5276 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5277 | if (!peer) | |
d62a17ae | 5278 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5279 | |
db45f64d DS |
5280 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5281 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5282 | PEER_FLAG_ORF_PREFIX_SM); | |
5283 | ||
5284 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5285 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5286 | PEER_FLAG_ORF_PREFIX_RM); | |
5287 | ||
5288 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5289 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5290 | PEER_FLAG_ORF_PREFIX_SM) | |
5291 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5292 | PEER_FLAG_ORF_PREFIX_RM); | |
5293 | ||
5294 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5295 | } |
5296 | ||
5297 | ALIAS_HIDDEN( | |
5298 | neighbor_capability_orf_prefix, | |
5299 | neighbor_capability_orf_prefix_hidden_cmd, | |
5300 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5301 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5302 | "Advertise capability to the peer\n" | |
5303 | "Advertise ORF capability to the peer\n" | |
5304 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5305 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5306 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5307 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5308 | |
718e3744 | 5309 | DEFUN (no_neighbor_capability_orf_prefix, |
5310 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5311 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5312 | NO_STR |
5313 | NEIGHBOR_STR | |
5314 | NEIGHBOR_ADDR_STR2 | |
5315 | "Advertise capability to the peer\n" | |
5316 | "Advertise ORF capability to the peer\n" | |
5317 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5318 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5319 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5320 | "Capability to SEND the ORF to this neighbor\n") | |
5321 | { | |
d62a17ae | 5322 | int idx_send_recv = 6; |
db45f64d DS |
5323 | char *peer_str = argv[2]->arg; |
5324 | struct peer *peer; | |
5325 | afi_t afi = bgp_node_afi(vty); | |
5326 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5327 | |
db45f64d DS |
5328 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5329 | if (!peer) | |
d62a17ae | 5330 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5331 | |
db45f64d DS |
5332 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5333 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5334 | PEER_FLAG_ORF_PREFIX_SM); | |
5335 | ||
5336 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5337 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5338 | PEER_FLAG_ORF_PREFIX_RM); | |
5339 | ||
5340 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5341 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5342 | PEER_FLAG_ORF_PREFIX_SM) | |
5343 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5344 | PEER_FLAG_ORF_PREFIX_RM); | |
5345 | ||
5346 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5347 | } |
5348 | ||
5349 | ALIAS_HIDDEN( | |
5350 | no_neighbor_capability_orf_prefix, | |
5351 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5352 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5353 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5354 | "Advertise capability to the peer\n" | |
5355 | "Advertise ORF capability to the peer\n" | |
5356 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5357 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5358 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5359 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5360 | |
718e3744 | 5361 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5362 | DEFUN (neighbor_nexthop_self, |
5363 | neighbor_nexthop_self_cmd, | |
5364 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5365 | NEIGHBOR_STR | |
5366 | NEIGHBOR_ADDR_STR2 | |
5367 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5368 | { |
d62a17ae | 5369 | int idx_peer = 1; |
28c6e247 IR |
5370 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5371 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5372 | } |
9e7a53c1 | 5373 | |
d62a17ae | 5374 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5375 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5376 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5377 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5378 | |
f4b8ec07 | 5379 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5380 | DEFUN (neighbor_nexthop_self_force, |
5381 | neighbor_nexthop_self_force_cmd, | |
5382 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5383 | NEIGHBOR_STR | |
5384 | NEIGHBOR_ADDR_STR2 | |
5385 | "Disable the next hop calculation for this neighbor\n" | |
5386 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5387 | { |
5388 | int idx_peer = 1; | |
28c6e247 IR |
5389 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5390 | bgp_node_safi(vty), | |
5391 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5392 | } |
5393 | ||
d62a17ae | 5394 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5395 | neighbor_nexthop_self_force_hidden_cmd, | |
5396 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5397 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5398 | "Disable the next hop calculation for this neighbor\n" | |
5399 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5400 | |
1bc4e531 DA |
5401 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5402 | neighbor_nexthop_self_all_hidden_cmd, | |
5403 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5404 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5405 | "Disable the next hop calculation for this neighbor\n" | |
5406 | "Set the next hop to self for reflected routes\n") | |
5407 | ||
28c6e247 IR |
5408 | DEFUN (no_neighbor_nexthop_self, |
5409 | no_neighbor_nexthop_self_cmd, | |
5410 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5411 | NO_STR | |
5412 | NEIGHBOR_STR | |
5413 | NEIGHBOR_ADDR_STR2 | |
5414 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5415 | { |
d62a17ae | 5416 | int idx_peer = 2; |
28c6e247 IR |
5417 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5418 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5419 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5420 | } |
6b0655a2 | 5421 | |
d62a17ae | 5422 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5423 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5424 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5425 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5426 | |
28c6e247 IR |
5427 | DEFUN (no_neighbor_nexthop_self_force, |
5428 | no_neighbor_nexthop_self_force_cmd, | |
5429 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5430 | NO_STR | |
5431 | NEIGHBOR_STR | |
5432 | NEIGHBOR_ADDR_STR2 | |
5433 | "Disable the next hop calculation for this neighbor\n" | |
5434 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5435 | { |
d62a17ae | 5436 | int idx_peer = 2; |
28c6e247 IR |
5437 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5438 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5439 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5440 | } |
a538debe | 5441 | |
d62a17ae | 5442 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5443 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5445 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5446 | "Disable the next hop calculation for this neighbor\n" | |
5447 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5448 | |
1bc4e531 DA |
5449 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5450 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5451 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5452 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5453 | "Disable the next hop calculation for this neighbor\n" | |
5454 | "Set the next hop to self for reflected routes\n") | |
5455 | ||
c7122e14 | 5456 | /* neighbor as-override */ |
28c6e247 IR |
5457 | DEFUN (neighbor_as_override, |
5458 | neighbor_as_override_cmd, | |
5459 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5460 | NEIGHBOR_STR | |
5461 | NEIGHBOR_ADDR_STR2 | |
5462 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5463 | { |
d62a17ae | 5464 | int idx_peer = 1; |
28c6e247 IR |
5465 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5466 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5467 | } |
5468 | ||
d62a17ae | 5469 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5470 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5471 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5472 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5473 | |
28c6e247 IR |
5474 | DEFUN (no_neighbor_as_override, |
5475 | no_neighbor_as_override_cmd, | |
5476 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5477 | NO_STR | |
5478 | NEIGHBOR_STR | |
5479 | NEIGHBOR_ADDR_STR2 | |
5480 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5481 | { |
d62a17ae | 5482 | int idx_peer = 2; |
28c6e247 IR |
5483 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5484 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5485 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5486 | } |
5487 | ||
d62a17ae | 5488 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5489 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5490 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5491 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5492 | |
718e3744 | 5493 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5494 | DEFUN (neighbor_remove_private_as, |
5495 | neighbor_remove_private_as_cmd, | |
5496 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5497 | NEIGHBOR_STR | |
5498 | NEIGHBOR_ADDR_STR2 | |
5499 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5500 | { |
d62a17ae | 5501 | int idx_peer = 1; |
28c6e247 IR |
5502 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5503 | bgp_node_safi(vty), | |
5504 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5505 | } |
5506 | ||
d62a17ae | 5507 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5508 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5509 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5510 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5511 | |
28c6e247 IR |
5512 | DEFUN (neighbor_remove_private_as_all, |
5513 | neighbor_remove_private_as_all_cmd, | |
5514 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5515 | NEIGHBOR_STR | |
5516 | NEIGHBOR_ADDR_STR2 | |
5517 | "Remove private ASNs in outbound updates\n" | |
5518 | "Apply to all AS numbers\n") | |
5000f21c | 5519 | { |
d62a17ae | 5520 | int idx_peer = 1; |
28c6e247 IR |
5521 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5522 | bgp_node_safi(vty), | |
5523 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5524 | } |
5525 | ||
d62a17ae | 5526 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5527 | neighbor_remove_private_as_all_hidden_cmd, | |
5528 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5529 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5530 | "Remove private ASNs in outbound updates\n" | |
5531 | "Apply to all AS numbers") | |
596c17ba | 5532 | |
28c6e247 IR |
5533 | DEFUN (neighbor_remove_private_as_replace_as, |
5534 | neighbor_remove_private_as_replace_as_cmd, | |
5535 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5536 | NEIGHBOR_STR | |
5537 | NEIGHBOR_ADDR_STR2 | |
5538 | "Remove private ASNs in outbound updates\n" | |
5539 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5540 | { |
d62a17ae | 5541 | int idx_peer = 1; |
28c6e247 IR |
5542 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5543 | bgp_node_safi(vty), | |
5544 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5545 | } |
5546 | ||
d62a17ae | 5547 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5548 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5549 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5550 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5551 | "Remove private ASNs in outbound updates\n" | |
5552 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5553 | |
28c6e247 IR |
5554 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5555 | neighbor_remove_private_as_all_replace_as_cmd, | |
5556 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5557 | NEIGHBOR_STR | |
5558 | NEIGHBOR_ADDR_STR2 | |
5559 | "Remove private ASNs in outbound updates\n" | |
5560 | "Apply to all AS numbers\n" | |
5561 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5562 | { |
d62a17ae | 5563 | int idx_peer = 1; |
28c6e247 IR |
5564 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5565 | bgp_node_safi(vty), | |
5566 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5567 | } |
5568 | ||
d62a17ae | 5569 | ALIAS_HIDDEN( |
5570 | neighbor_remove_private_as_all_replace_as, | |
5571 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5572 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5573 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5574 | "Remove private ASNs in outbound updates\n" | |
5575 | "Apply to all AS numbers\n" | |
5576 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5577 | |
28c6e247 IR |
5578 | DEFUN (no_neighbor_remove_private_as, |
5579 | no_neighbor_remove_private_as_cmd, | |
5580 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5581 | NO_STR | |
5582 | NEIGHBOR_STR | |
5583 | NEIGHBOR_ADDR_STR2 | |
5584 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5585 | { |
d62a17ae | 5586 | int idx_peer = 2; |
28c6e247 IR |
5587 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5588 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5589 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5590 | } |
6b0655a2 | 5591 | |
d62a17ae | 5592 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5593 | no_neighbor_remove_private_as_hidden_cmd, | |
5594 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5595 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5596 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5597 | |
28c6e247 IR |
5598 | DEFUN (no_neighbor_remove_private_as_all, |
5599 | no_neighbor_remove_private_as_all_cmd, | |
5600 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5601 | NO_STR | |
5602 | NEIGHBOR_STR | |
5603 | NEIGHBOR_ADDR_STR2 | |
5604 | "Remove private ASNs in outbound updates\n" | |
5605 | "Apply to all AS numbers\n") | |
88b8ed8d | 5606 | { |
d62a17ae | 5607 | int idx_peer = 2; |
28c6e247 IR |
5608 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5609 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5610 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5611 | } |
5000f21c | 5612 | |
d62a17ae | 5613 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5614 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5615 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5616 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5617 | "Remove private ASNs in outbound updates\n" | |
5618 | "Apply to all AS numbers\n") | |
596c17ba | 5619 | |
28c6e247 IR |
5620 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5621 | no_neighbor_remove_private_as_replace_as_cmd, | |
5622 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5623 | NO_STR | |
5624 | NEIGHBOR_STR | |
5625 | NEIGHBOR_ADDR_STR2 | |
5626 | "Remove private ASNs in outbound updates\n" | |
5627 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5628 | { |
d62a17ae | 5629 | int idx_peer = 2; |
28c6e247 IR |
5630 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5631 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5632 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5633 | } |
5000f21c | 5634 | |
d62a17ae | 5635 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5636 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5637 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5638 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5639 | "Remove private ASNs in outbound updates\n" | |
5640 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5641 | |
28c6e247 IR |
5642 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5643 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5644 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5645 | NO_STR | |
5646 | NEIGHBOR_STR | |
5647 | NEIGHBOR_ADDR_STR2 | |
5648 | "Remove private ASNs in outbound updates\n" | |
5649 | "Apply to all AS numbers\n" | |
5650 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5651 | { |
d62a17ae | 5652 | int idx_peer = 2; |
28c6e247 IR |
5653 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5654 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5655 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5656 | } |
5000f21c | 5657 | |
d62a17ae | 5658 | ALIAS_HIDDEN( |
5659 | no_neighbor_remove_private_as_all_replace_as, | |
5660 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5661 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5662 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5663 | "Remove private ASNs in outbound updates\n" | |
5664 | "Apply to all AS numbers\n" | |
5665 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5666 | |
5000f21c | 5667 | |
718e3744 | 5668 | /* neighbor send-community. */ |
28c6e247 IR |
5669 | DEFUN (neighbor_send_community, |
5670 | neighbor_send_community_cmd, | |
5671 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5672 | NEIGHBOR_STR | |
5673 | NEIGHBOR_ADDR_STR2 | |
5674 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5675 | { |
d62a17ae | 5676 | int idx_peer = 1; |
27c05d4d | 5677 | |
f63d4054 IR |
5678 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5679 | bgp_node_safi(vty), | |
5680 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5681 | } |
5682 | ||
d62a17ae | 5683 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5684 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5685 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5686 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5687 | |
28c6e247 IR |
5688 | DEFUN (no_neighbor_send_community, |
5689 | no_neighbor_send_community_cmd, | |
5690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5691 | NO_STR | |
5692 | NEIGHBOR_STR | |
5693 | NEIGHBOR_ADDR_STR2 | |
5694 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5695 | { |
d62a17ae | 5696 | int idx_peer = 2; |
27c05d4d | 5697 | |
f63d4054 IR |
5698 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5699 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5700 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5701 | } |
6b0655a2 | 5702 | |
d62a17ae | 5703 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5704 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5705 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5706 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5707 | |
718e3744 | 5708 | /* neighbor send-community extended. */ |
28c6e247 IR |
5709 | DEFUN (neighbor_send_community_type, |
5710 | neighbor_send_community_type_cmd, | |
5711 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5712 | NEIGHBOR_STR | |
5713 | NEIGHBOR_ADDR_STR2 | |
5714 | "Send Community attribute to this neighbor\n" | |
5715 | "Send Standard and Extended Community attributes\n" | |
5716 | "Send Standard, Large and Extended Community attributes\n" | |
5717 | "Send Extended Community attributes\n" | |
5718 | "Send Standard Community attributes\n" | |
5719 | "Send Large Community attributes\n") | |
718e3744 | 5720 | { |
27c05d4d | 5721 | const char *type = argv[argc - 1]->text; |
db45f64d | 5722 | char *peer_str = argv[1]->arg; |
28c6e247 | 5723 | struct peer *peer; |
db45f64d | 5724 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 5725 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 5726 | |
28c6e247 IR |
5727 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5728 | if (!peer) | |
5729 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 5730 | |
28c6e247 IR |
5731 | if (strmatch(type, "standard")) |
5732 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5733 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5734 | |
28c6e247 IR |
5735 | if (strmatch(type, "extended")) |
5736 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5737 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5738 | |
28c6e247 IR |
5739 | if (strmatch(type, "large")) |
5740 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5741 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 5742 | |
28c6e247 IR |
5743 | if (strmatch(type, "both")) { |
5744 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5745 | PEER_FLAG_SEND_COMMUNITY) | |
5746 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5747 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5748 | } |
28c6e247 IR |
5749 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
5750 | PEER_FLAG_SEND_COMMUNITY) | |
5751 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5752 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5753 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5754 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5755 | } |
5756 | ||
5757 | ALIAS_HIDDEN( | |
5758 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5759 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5760 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5761 | "Send Community attribute to this neighbor\n" | |
5762 | "Send Standard and Extended Community attributes\n" | |
5763 | "Send Standard, Large and Extended Community attributes\n" | |
5764 | "Send Extended Community attributes\n" | |
5765 | "Send Standard Community attributes\n" | |
5766 | "Send Large Community attributes\n") | |
596c17ba | 5767 | |
28c6e247 IR |
5768 | DEFUN (no_neighbor_send_community_type, |
5769 | no_neighbor_send_community_type_cmd, | |
5770 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5771 | NO_STR | |
5772 | NEIGHBOR_STR | |
5773 | NEIGHBOR_ADDR_STR2 | |
5774 | "Send Community attribute to this neighbor\n" | |
5775 | "Send Standard and Extended Community attributes\n" | |
5776 | "Send Standard, Large and Extended Community attributes\n" | |
5777 | "Send Extended Community attributes\n" | |
5778 | "Send Standard Community attributes\n" | |
5779 | "Send Large Community attributes\n") | |
718e3744 | 5780 | { |
d62a17ae | 5781 | const char *type = argv[argc - 1]->text; |
db45f64d | 5782 | char *peer_str = argv[2]->arg; |
28c6e247 | 5783 | struct peer *peer; |
db45f64d DS |
5784 | afi_t afi = bgp_node_afi(vty); |
5785 | safi_t safi = bgp_node_safi(vty); | |
5786 | ||
28c6e247 IR |
5787 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5788 | if (!peer) | |
f4b8ec07 CS |
5789 | return CMD_WARNING_CONFIG_FAILED; |
5790 | ||
28c6e247 IR |
5791 | if (strmatch(type, "standard")) |
5792 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5793 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5794 | |
28c6e247 IR |
5795 | if (strmatch(type, "extended")) |
5796 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5797 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5798 | |
28c6e247 IR |
5799 | if (strmatch(type, "large")) |
5800 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5801 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
5802 | |
5803 | if (strmatch(type, "both")) { | |
db45f64d | 5804 | |
28c6e247 IR |
5805 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5806 | PEER_FLAG_SEND_COMMUNITY) | |
5807 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5808 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5809 | } |
5810 | ||
28c6e247 IR |
5811 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5812 | PEER_FLAG_SEND_COMMUNITY) | |
5813 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5814 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5815 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5816 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5817 | } |
5818 | ||
5819 | ALIAS_HIDDEN( | |
5820 | no_neighbor_send_community_type, | |
5821 | no_neighbor_send_community_type_hidden_cmd, | |
5822 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5823 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5824 | "Send Community attribute to this neighbor\n" | |
5825 | "Send Standard and Extended Community attributes\n" | |
5826 | "Send Standard, Large and Extended Community attributes\n" | |
5827 | "Send Extended Community attributes\n" | |
5828 | "Send Standard Community attributes\n" | |
5829 | "Send Large Community attributes\n") | |
596c17ba | 5830 | |
718e3744 | 5831 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
5832 | DEFUN (neighbor_soft_reconfiguration, |
5833 | neighbor_soft_reconfiguration_cmd, | |
5834 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5835 | NEIGHBOR_STR | |
5836 | NEIGHBOR_ADDR_STR2 | |
5837 | "Per neighbor soft reconfiguration\n" | |
5838 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5839 | { |
d62a17ae | 5840 | int idx_peer = 1; |
28c6e247 IR |
5841 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5842 | bgp_node_safi(vty), | |
5843 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5844 | } |
5845 | ||
d62a17ae | 5846 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5847 | neighbor_soft_reconfiguration_hidden_cmd, | |
5848 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5849 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5850 | "Per neighbor soft reconfiguration\n" | |
5851 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5852 | |
28c6e247 IR |
5853 | DEFUN (no_neighbor_soft_reconfiguration, |
5854 | no_neighbor_soft_reconfiguration_cmd, | |
5855 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5856 | NO_STR | |
5857 | NEIGHBOR_STR | |
5858 | NEIGHBOR_ADDR_STR2 | |
5859 | "Per neighbor soft reconfiguration\n" | |
5860 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5861 | { |
d62a17ae | 5862 | int idx_peer = 2; |
28c6e247 IR |
5863 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5864 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5865 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5866 | } |
6b0655a2 | 5867 | |
d62a17ae | 5868 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5869 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5870 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5871 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5872 | "Per neighbor soft reconfiguration\n" | |
5873 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5874 | |
28c6e247 IR |
5875 | DEFUN (neighbor_route_reflector_client, |
5876 | neighbor_route_reflector_client_cmd, | |
5877 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5878 | NEIGHBOR_STR | |
5879 | NEIGHBOR_ADDR_STR2 | |
5880 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5881 | { |
d62a17ae | 5882 | int idx_peer = 1; |
28c6e247 | 5883 | struct peer *peer; |
718e3744 | 5884 | |
5885 | ||
28c6e247 IR |
5886 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5887 | if (!peer) | |
d62a17ae | 5888 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5889 | |
28c6e247 IR |
5890 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5891 | bgp_node_safi(vty), | |
5892 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5893 | } |
5894 | ||
d62a17ae | 5895 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5896 | neighbor_route_reflector_client_hidden_cmd, | |
5897 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5898 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5899 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5900 | |
28c6e247 IR |
5901 | DEFUN (no_neighbor_route_reflector_client, |
5902 | no_neighbor_route_reflector_client_cmd, | |
5903 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5904 | NO_STR | |
5905 | NEIGHBOR_STR | |
5906 | NEIGHBOR_ADDR_STR2 | |
5907 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5908 | { |
d62a17ae | 5909 | int idx_peer = 2; |
28c6e247 IR |
5910 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5911 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5912 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5913 | } |
6b0655a2 | 5914 | |
d62a17ae | 5915 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5916 | no_neighbor_route_reflector_client_hidden_cmd, | |
5917 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5918 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5919 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5920 | |
718e3744 | 5921 | /* neighbor route-server-client. */ |
28c6e247 IR |
5922 | DEFUN (neighbor_route_server_client, |
5923 | neighbor_route_server_client_cmd, | |
5924 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5925 | NEIGHBOR_STR | |
5926 | NEIGHBOR_ADDR_STR2 | |
5927 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 5928 | { |
d62a17ae | 5929 | int idx_peer = 1; |
28c6e247 | 5930 | struct peer *peer; |
f4b8ec07 | 5931 | |
28c6e247 IR |
5932 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5933 | if (!peer) | |
d62a17ae | 5934 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
5935 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5936 | bgp_node_safi(vty), | |
5937 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5938 | } |
5939 | ||
d62a17ae | 5940 | ALIAS_HIDDEN(neighbor_route_server_client, |
5941 | neighbor_route_server_client_hidden_cmd, | |
5942 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5943 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5944 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5945 | |
28c6e247 IR |
5946 | DEFUN (no_neighbor_route_server_client, |
5947 | no_neighbor_route_server_client_cmd, | |
5948 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5949 | NO_STR | |
5950 | NEIGHBOR_STR | |
5951 | NEIGHBOR_ADDR_STR2 | |
5952 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5953 | { |
d62a17ae | 5954 | int idx_peer = 2; |
28c6e247 IR |
5955 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5956 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5957 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5958 | } |
6b0655a2 | 5959 | |
d62a17ae | 5960 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5961 | no_neighbor_route_server_client_hidden_cmd, | |
5962 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5963 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5964 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5965 | |
fee0f4c6 | 5966 | DEFUN (neighbor_nexthop_local_unchanged, |
5967 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5968 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5969 | NEIGHBOR_STR |
5970 | NEIGHBOR_ADDR_STR2 | |
5971 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5972 | "Leave link-local nexthop unchanged for this peer\n") | |
5973 | { | |
d62a17ae | 5974 | int idx_peer = 1; |
5975 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5976 | bgp_node_safi(vty), | |
5977 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5978 | } |
6b0655a2 | 5979 | |
fee0f4c6 | 5980 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5981 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5982 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5983 | NO_STR |
5984 | NEIGHBOR_STR | |
5985 | NEIGHBOR_ADDR_STR2 | |
5986 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5987 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5988 | { |
d62a17ae | 5989 | int idx_peer = 2; |
5990 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5991 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5992 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5993 | } |
6b0655a2 | 5994 | |
28c6e247 IR |
5995 | DEFUN (neighbor_attr_unchanged, |
5996 | neighbor_attr_unchanged_cmd, | |
5997 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5998 | NEIGHBOR_STR | |
5999 | NEIGHBOR_ADDR_STR2 | |
6000 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6001 | "As-path attribute\n" | |
6002 | "Nexthop attribute\n" | |
6003 | "Med attribute\n") | |
718e3744 | 6004 | { |
d62a17ae | 6005 | int idx = 0; |
8eeb0335 | 6006 | char *peer_str = argv[1]->arg; |
28c6e247 | 6007 | struct peer *peer; |
db45f64d DS |
6008 | bool aspath = false; |
6009 | bool nexthop = false; | |
6010 | bool med = false; | |
8eeb0335 DW |
6011 | afi_t afi = bgp_node_afi(vty); |
6012 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6013 | int ret = 0; |
f4b8ec07 | 6014 | |
28c6e247 IR |
6015 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6016 | if (!peer) | |
8eeb0335 | 6017 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6018 | |
6019 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6020 | aspath = true; |
6021 | ||
d62a17ae | 6022 | idx = 0; |
6023 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6024 | nexthop = true; |
6025 | ||
d62a17ae | 6026 | idx = 0; |
6027 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6028 | med = true; |
d62a17ae | 6029 | |
8eeb0335 | 6030 | /* no flags means all of them! */ |
db45f64d | 6031 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6032 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6033 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6034 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6035 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6036 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6037 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6038 | } else { |
28c6e247 IR |
6039 | if (!aspath) { |
6040 | if (peer_af_flag_check(peer, afi, safi, | |
6041 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6042 | ret |= peer_af_flag_unset_vty( | |
6043 | vty, peer_str, afi, safi, | |
6044 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6045 | } | |
6046 | } else | |
6047 | ret |= peer_af_flag_set_vty( | |
6048 | vty, peer_str, afi, safi, | |
6049 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6050 | ||
6051 | if (!nexthop) { | |
6052 | if (peer_af_flag_check(peer, afi, safi, | |
6053 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6054 | ret |= peer_af_flag_unset_vty( | |
6055 | vty, peer_str, afi, safi, | |
6056 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6057 | } | |
6058 | } else | |
6059 | ret |= peer_af_flag_set_vty( | |
6060 | vty, peer_str, afi, safi, | |
6061 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6062 | ||
6063 | if (!med) { | |
6064 | if (peer_af_flag_check(peer, afi, safi, | |
6065 | PEER_FLAG_MED_UNCHANGED)) { | |
6066 | ret |= peer_af_flag_unset_vty( | |
6067 | vty, peer_str, afi, safi, | |
6068 | PEER_FLAG_MED_UNCHANGED); | |
6069 | } | |
6070 | } else | |
6071 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6072 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6073 | } |
6074 | ||
28c6e247 | 6075 | return ret; |
d62a17ae | 6076 | } |
6077 | ||
6078 | ALIAS_HIDDEN( | |
6079 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6080 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6081 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6082 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6083 | "As-path attribute\n" | |
6084 | "Nexthop attribute\n" | |
6085 | "Med attribute\n") | |
596c17ba | 6086 | |
28c6e247 IR |
6087 | DEFUN (no_neighbor_attr_unchanged, |
6088 | no_neighbor_attr_unchanged_cmd, | |
6089 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6090 | NO_STR | |
6091 | NEIGHBOR_STR | |
6092 | NEIGHBOR_ADDR_STR2 | |
6093 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6094 | "As-path attribute\n" | |
6095 | "Nexthop attribute\n" | |
6096 | "Med attribute\n") | |
718e3744 | 6097 | { |
d62a17ae | 6098 | int idx = 0; |
db45f64d | 6099 | char *peer_str = argv[2]->arg; |
28c6e247 | 6100 | struct peer *peer; |
db45f64d DS |
6101 | bool aspath = false; |
6102 | bool nexthop = false; | |
6103 | bool med = false; | |
6104 | afi_t afi = bgp_node_afi(vty); | |
6105 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6106 | int ret = 0; |
f4b8ec07 | 6107 | |
28c6e247 IR |
6108 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6109 | if (!peer) | |
db45f64d | 6110 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6111 | |
6112 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6113 | aspath = true; |
6114 | ||
d62a17ae | 6115 | idx = 0; |
6116 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6117 | nexthop = true; |
6118 | ||
d62a17ae | 6119 | idx = 0; |
6120 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6121 | med = true; |
d62a17ae | 6122 | |
28c6e247 IR |
6123 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6124 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6125 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6126 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6127 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6128 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6129 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6130 | |
6131 | if (aspath) | |
28c6e247 IR |
6132 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6133 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6134 | |
6135 | if (nexthop) | |
28c6e247 IR |
6136 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6137 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6138 | |
db45f64d | 6139 | if (med) |
28c6e247 IR |
6140 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6141 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6142 | |
28c6e247 | 6143 | return ret; |
d62a17ae | 6144 | } |
6145 | ||
6146 | ALIAS_HIDDEN( | |
6147 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6148 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6149 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6150 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6151 | "As-path attribute\n" | |
6152 | "Nexthop attribute\n" | |
6153 | "Med attribute\n") | |
718e3744 | 6154 | |
28c6e247 IR |
6155 | /* EBGP multihop configuration. */ |
6156 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6157 | const char *ttl_str) | |
718e3744 | 6158 | { |
28c6e247 IR |
6159 | struct peer *peer; |
6160 | unsigned int ttl; | |
718e3744 | 6161 | |
28c6e247 IR |
6162 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6163 | if (!peer) | |
d62a17ae | 6164 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6165 | |
28c6e247 IR |
6166 | if (peer->conf_if) |
6167 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6168 | ||
6169 | if (!ttl_str) | |
6170 | ttl = MAXTTL; | |
6171 | else | |
6172 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6173 | |
28c6e247 | 6174 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6175 | } |
6176 | ||
28c6e247 | 6177 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6178 | { |
28c6e247 | 6179 | struct peer *peer; |
718e3744 | 6180 | |
28c6e247 IR |
6181 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6182 | if (!peer) | |
d62a17ae | 6183 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6184 | |
28c6e247 | 6185 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6186 | } |
6187 | ||
28c6e247 IR |
6188 | /* neighbor ebgp-multihop. */ |
6189 | DEFUN (neighbor_ebgp_multihop, | |
6190 | neighbor_ebgp_multihop_cmd, | |
6191 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6192 | NEIGHBOR_STR | |
6193 | NEIGHBOR_ADDR_STR2 | |
6194 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6195 | { |
28c6e247 IR |
6196 | int idx_peer = 1; |
6197 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6198 | } | |
f4b8ec07 | 6199 | |
28c6e247 IR |
6200 | DEFUN (neighbor_ebgp_multihop_ttl, |
6201 | neighbor_ebgp_multihop_ttl_cmd, | |
6202 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6203 | NEIGHBOR_STR | |
6204 | NEIGHBOR_ADDR_STR2 | |
6205 | "Allow EBGP neighbors not on directly connected networks\n" | |
6206 | "maximum hop count\n") | |
6207 | { | |
6208 | int idx_peer = 1; | |
6209 | int idx_number = 3; | |
6210 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6211 | argv[idx_number]->arg); | |
6212 | } | |
f4b8ec07 | 6213 | |
28c6e247 IR |
6214 | DEFUN (no_neighbor_ebgp_multihop, |
6215 | no_neighbor_ebgp_multihop_cmd, | |
6216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6217 | NO_STR | |
6218 | NEIGHBOR_STR | |
6219 | NEIGHBOR_ADDR_STR2 | |
6220 | "Allow EBGP neighbors not on directly connected networks\n" | |
6221 | "maximum hop count\n") | |
6222 | { | |
6223 | int idx_peer = 2; | |
6224 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6225 | } |
6226 | ||
6b0655a2 | 6227 | |
6ffd2079 | 6228 | /* disable-connected-check */ |
28c6e247 IR |
6229 | DEFUN (neighbor_disable_connected_check, |
6230 | neighbor_disable_connected_check_cmd, | |
6231 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6232 | NEIGHBOR_STR | |
6233 | NEIGHBOR_ADDR_STR2 | |
6234 | "one-hop away EBGP peer using loopback address\n" | |
6235 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6236 | { |
d62a17ae | 6237 | int idx_peer = 1; |
28c6e247 IR |
6238 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6239 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6240 | } |
6241 | ||
28c6e247 IR |
6242 | DEFUN (no_neighbor_disable_connected_check, |
6243 | no_neighbor_disable_connected_check_cmd, | |
6244 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6245 | NO_STR | |
6246 | NEIGHBOR_STR | |
6247 | NEIGHBOR_ADDR_STR2 | |
6248 | "one-hop away EBGP peer using loopback address\n" | |
6249 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6250 | { |
d62a17ae | 6251 | int idx_peer = 2; |
28c6e247 IR |
6252 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6253 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6254 | } |
6255 | ||
7ab294ea DA |
6256 | /* disable-link-bw-encoding-ieee */ |
6257 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6258 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6259 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6260 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6261 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6262 | { |
6263 | int idx_peer = 1; | |
6264 | ||
6265 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6266 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6267 | } | |
6268 | ||
7ab294ea DA |
6269 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6270 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6271 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6272 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6273 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6274 | { |
6275 | int idx_peer = 2; | |
6276 | ||
6277 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6278 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6279 | } | |
6280 | ||
47cbc09b PM |
6281 | |
6282 | /* enforce-first-as */ | |
28c6e247 IR |
6283 | DEFUN (neighbor_enforce_first_as, |
6284 | neighbor_enforce_first_as_cmd, | |
6285 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6286 | NEIGHBOR_STR | |
6287 | NEIGHBOR_ADDR_STR2 | |
6288 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6289 | { |
6290 | int idx_peer = 1; | |
f4b8ec07 | 6291 | |
28c6e247 IR |
6292 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6293 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6294 | } |
6295 | ||
28c6e247 IR |
6296 | DEFUN (no_neighbor_enforce_first_as, |
6297 | no_neighbor_enforce_first_as_cmd, | |
6298 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6299 | NO_STR | |
6300 | NEIGHBOR_STR | |
6301 | NEIGHBOR_ADDR_STR2 | |
6302 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6303 | { |
6304 | int idx_peer = 2; | |
f4b8ec07 | 6305 | |
28c6e247 IR |
6306 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6307 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6308 | } |
6309 | ||
6310 | ||
28c6e247 IR |
6311 | DEFUN (neighbor_description, |
6312 | neighbor_description_cmd, | |
6313 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6314 | NEIGHBOR_STR | |
6315 | NEIGHBOR_ADDR_STR2 | |
6316 | "Neighbor specific description\n" | |
6317 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6318 | { |
d62a17ae | 6319 | int idx_peer = 1; |
6320 | int idx_line = 3; | |
28c6e247 | 6321 | struct peer *peer; |
d62a17ae | 6322 | char *str; |
718e3744 | 6323 | |
28c6e247 IR |
6324 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6325 | if (!peer) | |
d62a17ae | 6326 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6327 | |
d62a17ae | 6328 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6329 | |
28c6e247 | 6330 | peer_description_set(peer, str); |
718e3744 | 6331 | |
d62a17ae | 6332 | XFREE(MTYPE_TMP, str); |
718e3744 | 6333 | |
28c6e247 | 6334 | return CMD_SUCCESS; |
718e3744 | 6335 | } |
6336 | ||
28c6e247 IR |
6337 | DEFUN (no_neighbor_description, |
6338 | no_neighbor_description_cmd, | |
6339 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6340 | NO_STR | |
6341 | NEIGHBOR_STR | |
6342 | NEIGHBOR_ADDR_STR2 | |
6343 | "Neighbor specific description\n") | |
718e3744 | 6344 | { |
d62a17ae | 6345 | int idx_peer = 2; |
28c6e247 | 6346 | struct peer *peer; |
f4b8ec07 | 6347 | |
28c6e247 IR |
6348 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6349 | if (!peer) | |
d62a17ae | 6350 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6351 | |
28c6e247 | 6352 | peer_description_unset(peer); |
718e3744 | 6353 | |
28c6e247 | 6354 | return CMD_SUCCESS; |
718e3744 | 6355 | } |
6356 | ||
1d80f243 | 6357 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6358 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6359 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6360 | "Neighbor specific description\n" | |
6361 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6362 | |
28c6e247 IR |
6363 | /* Neighbor update-source. */ |
6364 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6365 | const char *source_str) | |
6366 | { | |
6367 | struct peer *peer; | |
6368 | struct prefix p; | |
6369 | union sockunion su; | |
6370 | ||
6371 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6372 | if (!peer) | |
6373 | return CMD_WARNING_CONFIG_FAILED; | |
6374 | ||
6375 | if (peer->conf_if) | |
6376 | return CMD_WARNING; | |
6377 | ||
6378 | if (source_str) { | |
6379 | if (str2sockunion(source_str, &su) == 0) | |
6380 | peer_update_source_addr_set(peer, &su); | |
6381 | else { | |
6382 | if (str2prefix(source_str, &p)) { | |
6383 | vty_out(vty, | |
6384 | "%% Invalid update-source, remove prefix length \n"); | |
6385 | return CMD_WARNING_CONFIG_FAILED; | |
6386 | } else | |
6387 | peer_update_source_if_set(peer, source_str); | |
6388 | } | |
6389 | } else | |
6390 | peer_update_source_unset(peer); | |
6391 | ||
6392 | return CMD_SUCCESS; | |
6393 | } | |
6394 | ||
d62a17ae | 6395 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6396 | "IPv4 address\n" \ | |
6397 | "IPv6 address\n" \ | |
6398 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6399 | |
28c6e247 IR |
6400 | DEFUN (neighbor_update_source, |
6401 | neighbor_update_source_cmd, | |
6402 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6403 | NEIGHBOR_STR | |
6404 | NEIGHBOR_ADDR_STR2 | |
6405 | "Source of routing updates\n" | |
6406 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6407 | { |
d62a17ae | 6408 | int idx_peer = 1; |
6409 | int idx_peer_2 = 3; | |
28c6e247 | 6410 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6411 | argv[idx_peer_2]->arg); |
718e3744 | 6412 | } |
6413 | ||
28c6e247 IR |
6414 | DEFUN (no_neighbor_update_source, |
6415 | no_neighbor_update_source_cmd, | |
6416 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6417 | NO_STR | |
6418 | NEIGHBOR_STR | |
6419 | NEIGHBOR_ADDR_STR2 | |
6420 | "Source of routing updates\n" | |
6421 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6422 | { |
d62a17ae | 6423 | int idx_peer = 2; |
28c6e247 | 6424 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6425 | } |
6b0655a2 | 6426 | |
d62a17ae | 6427 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6428 | afi_t afi, safi_t safi, | |
6429 | const char *rmap, int set) | |
718e3744 | 6430 | { |
d62a17ae | 6431 | int ret; |
6432 | struct peer *peer; | |
80912664 | 6433 | struct route_map *route_map = NULL; |
718e3744 | 6434 | |
d62a17ae | 6435 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6436 | if (!peer) | |
6437 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6438 | |
1de27621 | 6439 | if (set) { |
80912664 DS |
6440 | if (rmap) |
6441 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6442 | ret = peer_default_originate_set(peer, afi, safi, |
6443 | rmap, route_map); | |
6444 | } else | |
d62a17ae | 6445 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6446 | |
d62a17ae | 6447 | return bgp_vty_return(vty, ret); |
718e3744 | 6448 | } |
6449 | ||
6450 | /* neighbor default-originate. */ | |
6451 | DEFUN (neighbor_default_originate, | |
6452 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6453 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6454 | NEIGHBOR_STR |
6455 | NEIGHBOR_ADDR_STR2 | |
6456 | "Originate default route to this neighbor\n") | |
6457 | { | |
d62a17ae | 6458 | int idx_peer = 1; |
6459 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6460 | bgp_node_afi(vty), | |
6461 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6462 | } |
6463 | ||
d62a17ae | 6464 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6465 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6466 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6467 | "Originate default route to this neighbor\n") | |
596c17ba | 6468 | |
718e3744 | 6469 | DEFUN (neighbor_default_originate_rmap, |
6470 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 6471 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 6472 | NEIGHBOR_STR |
6473 | NEIGHBOR_ADDR_STR2 | |
6474 | "Originate default route to this neighbor\n" | |
6475 | "Route-map to specify criteria to originate default\n" | |
6476 | "route-map name\n") | |
6477 | { | |
d62a17ae | 6478 | int idx_peer = 1; |
6479 | int idx_word = 4; | |
6480 | return peer_default_originate_set_vty( | |
6481 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6482 | argv[idx_word]->arg, 1); | |
718e3744 | 6483 | } |
6484 | ||
d62a17ae | 6485 | ALIAS_HIDDEN( |
6486 | neighbor_default_originate_rmap, | |
6487 | neighbor_default_originate_rmap_hidden_cmd, | |
6488 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6489 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6490 | "Originate default route to this neighbor\n" | |
6491 | "Route-map to specify criteria to originate default\n" | |
6492 | "route-map name\n") | |
596c17ba | 6493 | |
718e3744 | 6494 | DEFUN (no_neighbor_default_originate, |
6495 | no_neighbor_default_originate_cmd, | |
a636c635 | 6496 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 6497 | NO_STR |
6498 | NEIGHBOR_STR | |
6499 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6500 | "Originate default route to this neighbor\n" |
6501 | "Route-map to specify criteria to originate default\n" | |
6502 | "route-map name\n") | |
718e3744 | 6503 | { |
d62a17ae | 6504 | int idx_peer = 2; |
6505 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6506 | bgp_node_afi(vty), | |
6507 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6508 | } |
6509 | ||
d62a17ae | 6510 | ALIAS_HIDDEN( |
6511 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
6512 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6513 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6514 | "Originate default route to this neighbor\n" | |
6515 | "Route-map to specify criteria to originate default\n" | |
6516 | "route-map name\n") | |
596c17ba | 6517 | |
6b0655a2 | 6518 | |
28c6e247 IR |
6519 | /* Set neighbor's BGP port. */ |
6520 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6521 | const char *port_str) | |
718e3744 | 6522 | { |
28c6e247 IR |
6523 | struct peer *peer; |
6524 | uint16_t port; | |
6525 | struct servent *sp; | |
6526 | ||
6527 | peer = peer_lookup_vty(vty, ip_str); | |
6528 | if (!peer) | |
6529 | return CMD_WARNING_CONFIG_FAILED; | |
6530 | ||
6531 | if (!port_str) { | |
6532 | sp = getservbyname("bgp", "tcp"); | |
6533 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6534 | } else { | |
6535 | port = strtoul(port_str, NULL, 10); | |
6536 | } | |
718e3744 | 6537 | |
28c6e247 | 6538 | peer_port_set(peer, port); |
718e3744 | 6539 | |
28c6e247 IR |
6540 | return CMD_SUCCESS; |
6541 | } | |
f4b8ec07 | 6542 | |
28c6e247 IR |
6543 | /* Set specified peer's BGP port. */ |
6544 | DEFUN (neighbor_port, | |
6545 | neighbor_port_cmd, | |
6546 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
6547 | NEIGHBOR_STR | |
6548 | NEIGHBOR_ADDR_STR | |
6549 | "Neighbor's BGP port\n" | |
6550 | "TCP port number\n") | |
6551 | { | |
6552 | int idx_ip = 1; | |
6553 | int idx_number = 3; | |
6554 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6555 | argv[idx_number]->arg); | |
f4b8ec07 | 6556 | } |
6b0655a2 | 6557 | |
28c6e247 IR |
6558 | DEFUN (no_neighbor_port, |
6559 | no_neighbor_port_cmd, | |
6560 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
6561 | NO_STR | |
6562 | NEIGHBOR_STR | |
6563 | NEIGHBOR_ADDR_STR | |
6564 | "Neighbor's BGP port\n" | |
6565 | "TCP port number\n") | |
718e3744 | 6566 | { |
f4b8ec07 | 6567 | int idx_ip = 2; |
28c6e247 IR |
6568 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
6569 | } | |
6570 | ||
6571 | ||
6572 | /* neighbor weight. */ | |
6573 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
6574 | safi_t safi, const char *weight_str) | |
6575 | { | |
6576 | int ret; | |
6577 | struct peer *peer; | |
6578 | unsigned long weight; | |
718e3744 | 6579 | |
28c6e247 IR |
6580 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6581 | if (!peer) | |
6582 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6583 | |
28c6e247 | 6584 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 6585 | |
28c6e247 IR |
6586 | ret = peer_weight_set(peer, afi, safi, weight); |
6587 | return bgp_vty_return(vty, ret); | |
718e3744 | 6588 | } |
6589 | ||
28c6e247 IR |
6590 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6591 | safi_t safi) | |
718e3744 | 6592 | { |
28c6e247 IR |
6593 | int ret; |
6594 | struct peer *peer; | |
f4b8ec07 | 6595 | |
28c6e247 IR |
6596 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6597 | if (!peer) | |
d62a17ae | 6598 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6599 | |
28c6e247 IR |
6600 | ret = peer_weight_unset(peer, afi, safi); |
6601 | return bgp_vty_return(vty, ret); | |
6602 | } | |
f4b8ec07 | 6603 | |
28c6e247 IR |
6604 | DEFUN (neighbor_weight, |
6605 | neighbor_weight_cmd, | |
6606 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6607 | NEIGHBOR_STR | |
6608 | NEIGHBOR_ADDR_STR2 | |
6609 | "Set default weight for routes from this neighbor\n" | |
6610 | "default weight\n") | |
6611 | { | |
6612 | int idx_peer = 1; | |
6613 | int idx_number = 3; | |
6614 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6615 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 6616 | } |
6617 | ||
d62a17ae | 6618 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
6619 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6620 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6621 | "Set default weight for routes from this neighbor\n" | |
6622 | "default weight\n") | |
596c17ba | 6623 | |
28c6e247 IR |
6624 | DEFUN (no_neighbor_weight, |
6625 | no_neighbor_weight_cmd, | |
6626 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6627 | NO_STR | |
6628 | NEIGHBOR_STR | |
6629 | NEIGHBOR_ADDR_STR2 | |
6630 | "Set default weight for routes from this neighbor\n" | |
6631 | "default weight\n") | |
718e3744 | 6632 | { |
d62a17ae | 6633 | int idx_peer = 2; |
28c6e247 IR |
6634 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
6635 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 6636 | } |
6637 | ||
d62a17ae | 6638 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
6639 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6640 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6641 | "Set default weight for routes from this neighbor\n" | |
6642 | "default weight\n") | |
596c17ba | 6643 | |
6b0655a2 | 6644 | |
718e3744 | 6645 | /* Override capability negotiation. */ |
c36bc05f IR |
6646 | DEFUN (neighbor_override_capability, |
6647 | neighbor_override_capability_cmd, | |
6648 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6649 | NEIGHBOR_STR | |
6650 | NEIGHBOR_ADDR_STR2 | |
6651 | "Override capability negotiation result\n") | |
718e3744 | 6652 | { |
d62a17ae | 6653 | int idx_peer = 1; |
c36bc05f IR |
6654 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6655 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6656 | } |
6657 | ||
c36bc05f IR |
6658 | DEFUN (no_neighbor_override_capability, |
6659 | no_neighbor_override_capability_cmd, | |
6660 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6661 | NO_STR | |
6662 | NEIGHBOR_STR | |
6663 | NEIGHBOR_ADDR_STR2 | |
6664 | "Override capability negotiation result\n") | |
718e3744 | 6665 | { |
d62a17ae | 6666 | int idx_peer = 2; |
c36bc05f IR |
6667 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6668 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6669 | } |
6b0655a2 | 6670 | |
c36bc05f IR |
6671 | DEFUN (neighbor_strict_capability, |
6672 | neighbor_strict_capability_cmd, | |
6673 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6674 | NEIGHBOR_STR | |
6675 | NEIGHBOR_ADDR_STR2 | |
6676 | "Strict capability negotiation match\n") | |
718e3744 | 6677 | { |
9fb964de PM |
6678 | int idx_peer = 1; |
6679 | ||
c36bc05f IR |
6680 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6681 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6682 | } |
6683 | ||
c36bc05f IR |
6684 | DEFUN (no_neighbor_strict_capability, |
6685 | no_neighbor_strict_capability_cmd, | |
6686 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6687 | NO_STR | |
6688 | NEIGHBOR_STR | |
6689 | NEIGHBOR_ADDR_STR2 | |
6690 | "Strict capability negotiation match\n") | |
718e3744 | 6691 | { |
9fb964de | 6692 | int idx_peer = 2; |
8611c7f3 | 6693 | |
c36bc05f IR |
6694 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6695 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6696 | } |
6b0655a2 | 6697 | |
28c6e247 IR |
6698 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6699 | const char *keep_str, const char *hold_str) | |
718e3744 | 6700 | { |
28c6e247 IR |
6701 | int ret; |
6702 | struct peer *peer; | |
6703 | uint32_t keepalive; | |
6704 | uint32_t holdtime; | |
718e3744 | 6705 | |
28c6e247 IR |
6706 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6707 | if (!peer) | |
d62a17ae | 6708 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6709 | |
28c6e247 IR |
6710 | keepalive = strtoul(keep_str, NULL, 10); |
6711 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6712 | |
28c6e247 | 6713 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6714 | |
28c6e247 | 6715 | return bgp_vty_return(vty, ret); |
718e3744 | 6716 | } |
6b0655a2 | 6717 | |
28c6e247 | 6718 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6719 | { |
28c6e247 IR |
6720 | int ret; |
6721 | struct peer *peer; | |
718e3744 | 6722 | |
28c6e247 IR |
6723 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6724 | if (!peer) | |
d62a17ae | 6725 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6726 | |
28c6e247 | 6727 | ret = peer_timers_unset(peer); |
718e3744 | 6728 | |
28c6e247 | 6729 | return bgp_vty_return(vty, ret); |
718e3744 | 6730 | } |
6b0655a2 | 6731 | |
28c6e247 IR |
6732 | DEFUN (neighbor_timers, |
6733 | neighbor_timers_cmd, | |
6734 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
6735 | NEIGHBOR_STR | |
6736 | NEIGHBOR_ADDR_STR2 | |
6737 | "BGP per neighbor timers\n" | |
6738 | "Keepalive interval\n" | |
6739 | "Holdtime\n") | |
718e3744 | 6740 | { |
f4b8ec07 | 6741 | int idx_peer = 1; |
28c6e247 IR |
6742 | int idx_number = 3; |
6743 | int idx_number_2 = 4; | |
6744 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6745 | argv[idx_number]->arg, | |
6746 | argv[idx_number_2]->arg); | |
6747 | } | |
6748 | ||
6749 | DEFUN (no_neighbor_timers, | |
6750 | no_neighbor_timers_cmd, | |
6751 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
6752 | NO_STR | |
6753 | NEIGHBOR_STR | |
6754 | NEIGHBOR_ADDR_STR2 | |
6755 | "BGP per neighbor timers\n" | |
6756 | "Keepalive interval\n" | |
6757 | "Holdtime\n") | |
6758 | { | |
6759 | int idx_peer = 2; | |
6760 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
6761 | } | |
6762 | ||
6763 | ||
6764 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
6765 | const char *time_str) | |
6766 | { | |
6767 | int ret; | |
6768 | struct peer *peer; | |
6769 | uint32_t connect; | |
718e3744 | 6770 | |
28c6e247 IR |
6771 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6772 | if (!peer) | |
d62a17ae | 6773 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6774 | |
28c6e247 IR |
6775 | connect = strtoul(time_str, NULL, 10); |
6776 | ||
6777 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 6778 | |
28c6e247 | 6779 | return bgp_vty_return(vty, ret); |
718e3744 | 6780 | } |
6781 | ||
28c6e247 | 6782 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6783 | { |
28c6e247 IR |
6784 | int ret; |
6785 | struct peer *peer; | |
718e3744 | 6786 | |
28c6e247 IR |
6787 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6788 | if (!peer) | |
d62a17ae | 6789 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6790 | |
28c6e247 IR |
6791 | ret = peer_timers_connect_unset(peer); |
6792 | ||
6793 | return bgp_vty_return(vty, ret); | |
6794 | } | |
6795 | ||
6796 | DEFUN (neighbor_timers_connect, | |
6797 | neighbor_timers_connect_cmd, | |
6798 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
6799 | NEIGHBOR_STR | |
6800 | NEIGHBOR_ADDR_STR2 | |
6801 | "BGP per neighbor timers\n" | |
6802 | "BGP connect timer\n" | |
6803 | "Connect timer\n") | |
6804 | { | |
6805 | int idx_peer = 1; | |
6806 | int idx_number = 4; | |
6807 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6808 | argv[idx_number]->arg); | |
6809 | } | |
718e3744 | 6810 | |
28c6e247 IR |
6811 | DEFUN (no_neighbor_timers_connect, |
6812 | no_neighbor_timers_connect_cmd, | |
6813 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
6814 | NO_STR | |
6815 | NEIGHBOR_STR | |
6816 | NEIGHBOR_ADDR_STR2 | |
6817 | "BGP per neighbor timers\n" | |
6818 | "BGP connect timer\n" | |
6819 | "Connect timer\n") | |
6820 | { | |
6821 | int idx_peer = 2; | |
6822 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6823 | } |
6824 | ||
d43114f3 DS |
6825 | DEFPY (neighbor_timers_delayopen, |
6826 | neighbor_timers_delayopen_cmd, | |
6827 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
6828 | NEIGHBOR_STR | |
6829 | NEIGHBOR_ADDR_STR2 | |
6830 | "BGP per neighbor timers\n" | |
6831 | "RFC 4271 DelayOpenTimer\n" | |
6832 | "DelayOpenTime timer interval\n") | |
6833 | { | |
6834 | struct peer *peer; | |
6835 | ||
6836 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6837 | if (!peer) | |
6838 | return CMD_WARNING_CONFIG_FAILED; | |
6839 | ||
6840 | if (!interval) { | |
6841 | if (peer_timers_delayopen_unset(peer)) | |
6842 | return CMD_WARNING_CONFIG_FAILED; | |
6843 | } else { | |
6844 | if (peer_timers_delayopen_set(peer, interval)) | |
6845 | return CMD_WARNING_CONFIG_FAILED; | |
6846 | } | |
6847 | ||
6848 | return CMD_SUCCESS; | |
6849 | } | |
6850 | ||
6851 | DEFPY (no_neighbor_timers_delayopen, | |
6852 | no_neighbor_timers_delayopen_cmd, | |
6853 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
6854 | NO_STR | |
6855 | NEIGHBOR_STR | |
6856 | NEIGHBOR_ADDR_STR2 | |
6857 | "BGP per neighbor timers\n" | |
6858 | "RFC 4271 DelayOpenTimer\n" | |
6859 | "DelayOpenTime timer interval\n") | |
6860 | { | |
6861 | struct peer *peer; | |
6862 | ||
6863 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6864 | if (!peer) | |
6865 | return CMD_WARNING_CONFIG_FAILED; | |
6866 | ||
6867 | if (peer_timers_delayopen_unset(peer)) | |
6868 | return CMD_WARNING_CONFIG_FAILED; | |
6869 | ||
6870 | return CMD_SUCCESS; | |
6871 | } | |
6872 | ||
28c6e247 IR |
6873 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6874 | const char *time_str, int set) | |
718e3744 | 6875 | { |
28c6e247 IR |
6876 | int ret; |
6877 | struct peer *peer; | |
6878 | uint32_t routeadv = 0; | |
718e3744 | 6879 | |
28c6e247 IR |
6880 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6881 | if (!peer) | |
d62a17ae | 6882 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6883 | |
28c6e247 IR |
6884 | if (time_str) |
6885 | routeadv = strtoul(time_str, NULL, 10); | |
6886 | ||
6887 | if (set) | |
6888 | ret = peer_advertise_interval_set(peer, routeadv); | |
6889 | else | |
6890 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6891 | |
28c6e247 | 6892 | return bgp_vty_return(vty, ret); |
718e3744 | 6893 | } |
6894 | ||
28c6e247 IR |
6895 | DEFUN (neighbor_advertise_interval, |
6896 | neighbor_advertise_interval_cmd, | |
6897 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
6898 | NEIGHBOR_STR | |
6899 | NEIGHBOR_ADDR_STR2 | |
6900 | "Minimum interval between sending BGP routing updates\n" | |
6901 | "time in seconds\n") | |
718e3744 | 6902 | { |
28c6e247 IR |
6903 | int idx_peer = 1; |
6904 | int idx_number = 3; | |
6905 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6906 | argv[idx_number]->arg, 1); | |
6907 | } | |
f4b8ec07 | 6908 | |
28c6e247 IR |
6909 | DEFUN (no_neighbor_advertise_interval, |
6910 | no_neighbor_advertise_interval_cmd, | |
6911 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
6912 | NO_STR | |
6913 | NEIGHBOR_STR | |
6914 | NEIGHBOR_ADDR_STR2 | |
6915 | "Minimum interval between sending BGP routing updates\n" | |
6916 | "time in seconds\n") | |
6917 | { | |
6918 | int idx_peer = 2; | |
6919 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6920 | } |
6921 | ||
6b0655a2 | 6922 | |
518f0eb1 DS |
6923 | /* Time to wait before processing route-map updates */ |
6924 | DEFUN (bgp_set_route_map_delay_timer, | |
6925 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6926 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6927 | SET_STR |
6928 | "BGP route-map delay timer\n" | |
6929 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6930 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6931 | { |
d62a17ae | 6932 | int idx_number = 3; |
d7c0a89a | 6933 | uint32_t rmap_delay_timer; |
d62a17ae | 6934 | |
6935 | if (argv[idx_number]->arg) { | |
6936 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6937 | bm->rmap_update_timer = rmap_delay_timer; | |
6938 | ||
6939 | /* if the dynamic update handling is being disabled, and a timer | |
6940 | * is | |
6941 | * running, stop the timer and act as if the timer has already | |
6942 | * fired. | |
6943 | */ | |
6944 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6945 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6946 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6947 | NULL, 0); | |
6948 | } | |
6949 | return CMD_SUCCESS; | |
6950 | } else { | |
6951 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6952 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6953 | } |
518f0eb1 DS |
6954 | } |
6955 | ||
6956 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6957 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6958 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6959 | NO_STR |
3a2d747c | 6960 | BGP_STR |
518f0eb1 | 6961 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6962 | "Reset to default time to wait for processing route-map changes\n" |
6963 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6964 | { |
518f0eb1 | 6965 | |
d62a17ae | 6966 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6967 | |
d62a17ae | 6968 | return CMD_SUCCESS; |
518f0eb1 DS |
6969 | } |
6970 | ||
28c6e247 IR |
6971 | /* neighbor interface */ |
6972 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
6973 | const char *str) | |
718e3744 | 6974 | { |
28c6e247 | 6975 | struct peer *peer; |
718e3744 | 6976 | |
28c6e247 IR |
6977 | peer = peer_lookup_vty(vty, ip_str); |
6978 | if (!peer || peer->conf_if) { | |
6979 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6980 | return CMD_WARNING_CONFIG_FAILED; | |
6981 | } | |
718e3744 | 6982 | |
28c6e247 IR |
6983 | if (str) |
6984 | peer_interface_set(peer, str); | |
6985 | else | |
6986 | peer_interface_unset(peer); | |
718e3744 | 6987 | |
28c6e247 | 6988 | return CMD_SUCCESS; |
718e3744 | 6989 | } |
6990 | ||
28c6e247 IR |
6991 | DEFUN (neighbor_interface, |
6992 | neighbor_interface_cmd, | |
6993 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
6994 | NEIGHBOR_STR | |
6995 | NEIGHBOR_ADDR_STR | |
6996 | "Interface\n" | |
6997 | "Interface name\n") | |
718e3744 | 6998 | { |
28c6e247 IR |
6999 | int idx_ip = 1; |
7000 | int idx_word = 3; | |
294d8425 | 7001 | |
28c6e247 IR |
7002 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7003 | } | |
f4b8ec07 | 7004 | |
28c6e247 IR |
7005 | DEFUN (no_neighbor_interface, |
7006 | no_neighbor_interface_cmd, | |
294d8425 | 7007 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7008 | NO_STR |
7009 | NEIGHBOR_STR | |
294d8425 | 7010 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7011 | "Interface\n" |
7012 | "Interface name\n") | |
7013 | { | |
7014 | int idx_peer = 2; | |
294d8425 | 7015 | |
28c6e247 | 7016 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7017 | } |
6b0655a2 | 7018 | |
718e3744 | 7019 | DEFUN (neighbor_distribute_list, |
7020 | neighbor_distribute_list_cmd, | |
7e869991 | 7021 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list WORD <in|out>", |
718e3744 | 7022 | NEIGHBOR_STR |
7023 | NEIGHBOR_ADDR_STR2 | |
7024 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7025 | "IP Access-list name\n" |
7026 | "Filter incoming updates\n" | |
7027 | "Filter outgoing updates\n") | |
7028 | { | |
d62a17ae | 7029 | int idx_peer = 1; |
7030 | int idx_acl = 3; | |
7031 | int direct, ret; | |
7032 | struct peer *peer; | |
a8206004 | 7033 | |
d62a17ae | 7034 | const char *pstr = argv[idx_peer]->arg; |
7035 | const char *acl = argv[idx_acl]->arg; | |
7036 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7037 | |
d62a17ae | 7038 | peer = peer_and_group_lookup_vty(vty, pstr); |
7039 | if (!peer) | |
7040 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7041 | |
d62a17ae | 7042 | /* Check filter direction. */ |
7043 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7044 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7045 | direct, acl); | |
a8206004 | 7046 | |
d62a17ae | 7047 | return bgp_vty_return(vty, ret); |
718e3744 | 7048 | } |
7049 | ||
d62a17ae | 7050 | ALIAS_HIDDEN( |
7051 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
7e869991 | 7052 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list WORD <in|out>", |
d62a17ae | 7053 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7054 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7055 | "IP Access-list name\n" |
7056 | "Filter incoming updates\n" | |
7057 | "Filter outgoing updates\n") | |
596c17ba | 7058 | |
718e3744 | 7059 | DEFUN (no_neighbor_distribute_list, |
7060 | no_neighbor_distribute_list_cmd, | |
7e869991 | 7061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list WORD <in|out>", |
718e3744 | 7062 | NO_STR |
7063 | NEIGHBOR_STR | |
7064 | NEIGHBOR_ADDR_STR2 | |
7065 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7066 | "IP Access-list name\n" |
7067 | "Filter incoming updates\n" | |
7068 | "Filter outgoing updates\n") | |
7069 | { | |
d62a17ae | 7070 | int idx_peer = 2; |
7071 | int direct, ret; | |
7072 | struct peer *peer; | |
a8206004 | 7073 | |
d62a17ae | 7074 | const char *pstr = argv[idx_peer]->arg; |
7075 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7076 | |
d62a17ae | 7077 | peer = peer_and_group_lookup_vty(vty, pstr); |
7078 | if (!peer) | |
7079 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7080 | |
d62a17ae | 7081 | /* Check filter direction. */ |
7082 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7083 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7084 | direct); | |
a8206004 | 7085 | |
d62a17ae | 7086 | return bgp_vty_return(vty, ret); |
718e3744 | 7087 | } |
6b0655a2 | 7088 | |
d62a17ae | 7089 | ALIAS_HIDDEN( |
7090 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
7e869991 | 7091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list WORD <in|out>", |
d62a17ae | 7092 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7093 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7094 | "IP Access-list name\n" |
7095 | "Filter incoming updates\n" | |
7096 | "Filter outgoing updates\n") | |
596c17ba | 7097 | |
718e3744 | 7098 | /* Set prefix list to the peer. */ |
642ef664 IR |
7099 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7100 | afi_t afi, safi_t safi, | |
7101 | const char *name_str, | |
7102 | const char *direct_str) | |
718e3744 | 7103 | { |
642ef664 IR |
7104 | int ret; |
7105 | int direct = FILTER_IN; | |
7106 | struct peer *peer; | |
718e3744 | 7107 | |
642ef664 IR |
7108 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7109 | if (!peer) | |
d62a17ae | 7110 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7111 | |
642ef664 IR |
7112 | /* Check filter direction. */ |
7113 | if (strncmp(direct_str, "i", 1) == 0) | |
7114 | direct = FILTER_IN; | |
7115 | else if (strncmp(direct_str, "o", 1) == 0) | |
7116 | direct = FILTER_OUT; | |
718e3744 | 7117 | |
642ef664 | 7118 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7119 | |
642ef664 IR |
7120 | return bgp_vty_return(vty, ret); |
7121 | } | |
7122 | ||
7123 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7124 | afi_t afi, safi_t safi, | |
7125 | const char *direct_str) | |
7126 | { | |
7127 | int ret; | |
7128 | struct peer *peer; | |
7129 | int direct = FILTER_IN; | |
7130 | ||
7131 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7132 | if (!peer) | |
7133 | return CMD_WARNING_CONFIG_FAILED; | |
7134 | ||
7135 | /* Check filter direction. */ | |
7136 | if (strncmp(direct_str, "i", 1) == 0) | |
7137 | direct = FILTER_IN; | |
7138 | else if (strncmp(direct_str, "o", 1) == 0) | |
7139 | direct = FILTER_OUT; | |
7140 | ||
7141 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7142 | ||
7143 | return bgp_vty_return(vty, ret); | |
7144 | } | |
7145 | ||
7146 | DEFUN (neighbor_prefix_list, | |
7147 | neighbor_prefix_list_cmd, | |
7148 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7149 | NEIGHBOR_STR | |
7150 | NEIGHBOR_ADDR_STR2 | |
7151 | "Filter updates to/from this neighbor\n" | |
7152 | "Name of a prefix list\n" | |
7153 | "Filter incoming updates\n" | |
7154 | "Filter outgoing updates\n") | |
7155 | { | |
7156 | int idx_peer = 1; | |
7157 | int idx_word = 3; | |
7158 | int idx_in_out = 4; | |
7159 | return peer_prefix_list_set_vty( | |
7160 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7161 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7162 | } |
7163 | ||
d62a17ae | 7164 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7165 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7166 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7167 | "Filter updates to/from this neighbor\n" | |
7168 | "Name of a prefix list\n" | |
7169 | "Filter incoming updates\n" | |
7170 | "Filter outgoing updates\n") | |
596c17ba | 7171 | |
642ef664 IR |
7172 | DEFUN (no_neighbor_prefix_list, |
7173 | no_neighbor_prefix_list_cmd, | |
7174 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7175 | NO_STR | |
7176 | NEIGHBOR_STR | |
7177 | NEIGHBOR_ADDR_STR2 | |
7178 | "Filter updates to/from this neighbor\n" | |
7179 | "Name of a prefix list\n" | |
7180 | "Filter incoming updates\n" | |
7181 | "Filter outgoing updates\n") | |
7182 | { | |
7183 | int idx_peer = 2; | |
7184 | int idx_in_out = 5; | |
7185 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7186 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7187 | argv[idx_in_out]->arg); | |
7188 | } | |
7189 | ||
7190 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7191 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7192 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7193 | "Filter updates to/from this neighbor\n" | |
7194 | "Name of a prefix list\n" | |
7195 | "Filter incoming updates\n" | |
7196 | "Filter outgoing updates\n") | |
7197 | ||
d62a17ae | 7198 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7199 | safi_t safi, const char *name_str, | |
7200 | const char *direct_str) | |
718e3744 | 7201 | { |
d62a17ae | 7202 | int ret; |
7203 | struct peer *peer; | |
7204 | int direct = FILTER_IN; | |
718e3744 | 7205 | |
d62a17ae | 7206 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7207 | if (!peer) | |
7208 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7209 | |
d62a17ae | 7210 | /* Check filter direction. */ |
7211 | if (strncmp(direct_str, "i", 1) == 0) | |
7212 | direct = FILTER_IN; | |
7213 | else if (strncmp(direct_str, "o", 1) == 0) | |
7214 | direct = FILTER_OUT; | |
718e3744 | 7215 | |
d62a17ae | 7216 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7217 | |
d62a17ae | 7218 | return bgp_vty_return(vty, ret); |
718e3744 | 7219 | } |
7220 | ||
d62a17ae | 7221 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7222 | safi_t safi, const char *direct_str) | |
718e3744 | 7223 | { |
d62a17ae | 7224 | int ret; |
7225 | struct peer *peer; | |
7226 | int direct = FILTER_IN; | |
718e3744 | 7227 | |
d62a17ae | 7228 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7229 | if (!peer) | |
7230 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7231 | |
d62a17ae | 7232 | /* Check filter direction. */ |
7233 | if (strncmp(direct_str, "i", 1) == 0) | |
7234 | direct = FILTER_IN; | |
7235 | else if (strncmp(direct_str, "o", 1) == 0) | |
7236 | direct = FILTER_OUT; | |
718e3744 | 7237 | |
d62a17ae | 7238 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7239 | |
d62a17ae | 7240 | return bgp_vty_return(vty, ret); |
718e3744 | 7241 | } |
7242 | ||
7243 | DEFUN (neighbor_filter_list, | |
7244 | neighbor_filter_list_cmd, | |
9ccf14f7 | 7245 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7246 | NEIGHBOR_STR |
7247 | NEIGHBOR_ADDR_STR2 | |
7248 | "Establish BGP filters\n" | |
7249 | "AS path access-list name\n" | |
7250 | "Filter incoming routes\n" | |
7251 | "Filter outgoing routes\n") | |
7252 | { | |
d62a17ae | 7253 | int idx_peer = 1; |
7254 | int idx_word = 3; | |
7255 | int idx_in_out = 4; | |
7256 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7257 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7258 | argv[idx_in_out]->arg); | |
718e3744 | 7259 | } |
7260 | ||
d62a17ae | 7261 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
7262 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7263 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7264 | "Establish BGP filters\n" | |
7265 | "AS path access-list name\n" | |
7266 | "Filter incoming routes\n" | |
7267 | "Filter outgoing routes\n") | |
596c17ba | 7268 | |
718e3744 | 7269 | DEFUN (no_neighbor_filter_list, |
7270 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 7271 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7272 | NO_STR |
7273 | NEIGHBOR_STR | |
7274 | NEIGHBOR_ADDR_STR2 | |
7275 | "Establish BGP filters\n" | |
7276 | "AS path access-list name\n" | |
7277 | "Filter incoming routes\n" | |
7278 | "Filter outgoing routes\n") | |
7279 | { | |
d62a17ae | 7280 | int idx_peer = 2; |
7281 | int idx_in_out = 5; | |
7282 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7283 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7284 | argv[idx_in_out]->arg); | |
718e3744 | 7285 | } |
6b0655a2 | 7286 | |
d62a17ae | 7287 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
7288 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7289 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7290 | "Establish BGP filters\n" | |
7291 | "AS path access-list name\n" | |
7292 | "Filter incoming routes\n" | |
7293 | "Filter outgoing routes\n") | |
596c17ba | 7294 | |
7f7940e6 MK |
7295 | /* Set advertise-map to the peer. */ |
7296 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7297 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7298 | const char *advertise_str, |
7299 | const char *condition_str, bool condition, | |
7300 | bool set) | |
7f7940e6 MK |
7301 | { |
7302 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7303 | struct peer *peer; | |
7304 | struct route_map *advertise_map; | |
7305 | struct route_map *condition_map; | |
7306 | ||
7307 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7308 | if (!peer) | |
7309 | return ret; | |
7310 | ||
7311 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7312 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7313 | ||
cf2ad4d8 MK |
7314 | if (set) |
7315 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7316 | advertise_map, condition_str, | |
7317 | condition_map, condition); | |
7318 | else | |
7319 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7320 | advertise_map, condition_str, | |
7321 | condition_map, condition); | |
7f7940e6 MK |
7322 | |
7323 | return bgp_vty_return(vty, ret); | |
7324 | } | |
7325 | ||
389e4f92 QY |
7326 | DEFPY (bgp_condadv_period, |
7327 | bgp_condadv_period_cmd, | |
7328 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7329 | NO_STR | |
7330 | BGP_STR | |
7331 | "Conditional advertisement settings\n" | |
7332 | "Set period to rescan BGP table to check if condition is met\n" | |
7333 | "Period between BGP table scans, in seconds; default 60\n") | |
7334 | { | |
7335 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7336 | ||
7337 | bgp->condition_check_period = | |
7338 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7339 | ||
7340 | return CMD_SUCCESS; | |
7341 | } | |
7342 | ||
cf2ad4d8 | 7343 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7344 | neighbor_advertise_map_cmd, |
52b84062 | 7345 | "[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 | 7346 | NO_STR |
7f7940e6 MK |
7347 | NEIGHBOR_STR |
7348 | NEIGHBOR_ADDR_STR2 | |
7349 | "Route-map to conditionally advertise routes\n" | |
7350 | "Name of advertise map\n" | |
7351 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7352 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7353 | "Name of the exist or non exist map\n") |
7f7940e6 | 7354 | { |
7f7940e6 MK |
7355 | bool condition = CONDITION_EXIST; |
7356 | ||
52b84062 | 7357 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7358 | condition = CONDITION_NON_EXIST; |
7359 | ||
52b84062 MK |
7360 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7361 | bgp_node_safi(vty), advertise_str, | |
7362 | condition_str, condition, !no); | |
7f7940e6 MK |
7363 | } |
7364 | ||
7365 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 7366 | "[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 |
7367 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7368 | "Route-map to conditionally advertise routes\n" | |
7369 | "Name of advertise map\n" | |
7370 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7371 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7372 | "Name of the exist or non exist map\n") |
7f7940e6 | 7373 | |
718e3744 | 7374 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7375 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7376 | afi_t afi, safi_t safi, const char *name_str, | |
7377 | const char *direct_str) | |
718e3744 | 7378 | { |
0ea8d871 IR |
7379 | int ret; |
7380 | struct peer *peer; | |
7381 | int direct = RMAP_IN; | |
7382 | struct route_map *route_map; | |
718e3744 | 7383 | |
0ea8d871 IR |
7384 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7385 | if (!peer) | |
d62a17ae | 7386 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7387 | |
0ea8d871 IR |
7388 | /* Check filter direction. */ |
7389 | if (strncmp(direct_str, "in", 2) == 0) | |
7390 | direct = RMAP_IN; | |
7391 | else if (strncmp(direct_str, "o", 1) == 0) | |
7392 | direct = RMAP_OUT; | |
718e3744 | 7393 | |
0ea8d871 IR |
7394 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7395 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7396 | |
0ea8d871 IR |
7397 | return bgp_vty_return(vty, ret); |
7398 | } | |
7399 | ||
7400 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7401 | afi_t afi, safi_t safi, | |
7402 | const char *direct_str) | |
7403 | { | |
7404 | int ret; | |
7405 | struct peer *peer; | |
7406 | int direct = RMAP_IN; | |
7407 | ||
7408 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7409 | if (!peer) | |
7410 | return CMD_WARNING_CONFIG_FAILED; | |
7411 | ||
7412 | /* Check filter direction. */ | |
7413 | if (strncmp(direct_str, "in", 2) == 0) | |
7414 | direct = RMAP_IN; | |
7415 | else if (strncmp(direct_str, "o", 1) == 0) | |
7416 | direct = RMAP_OUT; | |
7417 | ||
7418 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7419 | ||
7420 | return bgp_vty_return(vty, ret); | |
7421 | } | |
7422 | ||
7423 | DEFUN (neighbor_route_map, | |
7424 | neighbor_route_map_cmd, | |
7425 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7426 | NEIGHBOR_STR | |
7427 | NEIGHBOR_ADDR_STR2 | |
7428 | "Apply route map to neighbor\n" | |
7429 | "Name of route map\n" | |
7430 | "Apply map to incoming routes\n" | |
7431 | "Apply map to outbound routes\n") | |
7432 | { | |
7433 | int idx_peer = 1; | |
7434 | int idx_word = 3; | |
7435 | int idx_in_out = 4; | |
7436 | return peer_route_map_set_vty( | |
7437 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7438 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7439 | } |
7440 | ||
d6d7ed37 IR |
7441 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7442 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7443 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7444 | "Apply route map to neighbor\n" | |
7445 | "Name of route map\n" | |
7446 | "Apply map to incoming routes\n" | |
7447 | "Apply map to outbound routes\n") | |
7448 | ||
0ea8d871 IR |
7449 | DEFUN (no_neighbor_route_map, |
7450 | no_neighbor_route_map_cmd, | |
7451 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7452 | NO_STR | |
7453 | NEIGHBOR_STR | |
7454 | NEIGHBOR_ADDR_STR2 | |
7455 | "Apply route map to neighbor\n" | |
7456 | "Name of route map\n" | |
7457 | "Apply map to incoming routes\n" | |
7458 | "Apply map to outbound routes\n") | |
7459 | { | |
7460 | int idx_peer = 2; | |
7461 | int idx_in_out = 5; | |
7462 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7463 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7464 | argv[idx_in_out]->arg); | |
7465 | } | |
7466 | ||
7467 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
d6d7ed37 IR |
7468 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
7469 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7470 | "Apply route map to neighbor\n" | |
7471 | "Name of route map\n" | |
7472 | "Apply map to incoming routes\n" | |
7473 | "Apply map to outbound routes\n") | |
7474 | ||
718e3744 | 7475 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7476 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7477 | afi_t afi, safi_t safi, | |
7478 | const char *name_str) | |
718e3744 | 7479 | { |
d62a17ae | 7480 | int ret; |
7481 | struct peer *peer; | |
1de27621 | 7482 | struct route_map *route_map; |
718e3744 | 7483 | |
d62a17ae | 7484 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7485 | if (!peer) | |
7486 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7487 | |
1de27621 DA |
7488 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7489 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7490 | |
d62a17ae | 7491 | return bgp_vty_return(vty, ret); |
718e3744 | 7492 | } |
7493 | ||
7494 | /* Unset route-map from the peer. */ | |
d62a17ae | 7495 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7496 | afi_t afi, safi_t safi) | |
718e3744 | 7497 | { |
d62a17ae | 7498 | int ret; |
7499 | struct peer *peer; | |
718e3744 | 7500 | |
d62a17ae | 7501 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7502 | if (!peer) | |
7503 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7504 | |
d62a17ae | 7505 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7506 | |
d62a17ae | 7507 | return bgp_vty_return(vty, ret); |
718e3744 | 7508 | } |
7509 | ||
7510 | DEFUN (neighbor_unsuppress_map, | |
7511 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7512 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7513 | NEIGHBOR_STR |
7514 | NEIGHBOR_ADDR_STR2 | |
7515 | "Route-map to selectively unsuppress suppressed routes\n" | |
7516 | "Name of route map\n") | |
7517 | { | |
d62a17ae | 7518 | int idx_peer = 1; |
7519 | int idx_word = 3; | |
7520 | return peer_unsuppress_map_set_vty( | |
7521 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7522 | argv[idx_word]->arg); | |
718e3744 | 7523 | } |
7524 | ||
d62a17ae | 7525 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7526 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7527 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7528 | "Route-map to selectively unsuppress suppressed routes\n" | |
7529 | "Name of route map\n") | |
596c17ba | 7530 | |
718e3744 | 7531 | DEFUN (no_neighbor_unsuppress_map, |
7532 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7533 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7534 | NO_STR |
7535 | NEIGHBOR_STR | |
7536 | NEIGHBOR_ADDR_STR2 | |
7537 | "Route-map to selectively unsuppress suppressed routes\n" | |
7538 | "Name of route map\n") | |
7539 | { | |
d62a17ae | 7540 | int idx_peer = 2; |
7541 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7542 | bgp_node_afi(vty), | |
7543 | bgp_node_safi(vty)); | |
718e3744 | 7544 | } |
6b0655a2 | 7545 | |
d62a17ae | 7546 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
7547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7548 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7549 | "Route-map to selectively unsuppress suppressed routes\n" | |
7550 | "Name of route map\n") | |
596c17ba | 7551 | |
7e62b792 IR |
7552 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
7553 | afi_t afi, safi_t safi, | |
7554 | const char *num_str, | |
7555 | const char *threshold_str, int warning, | |
7556 | const char *restart_str, | |
7557 | const char *force_str) | |
7558 | { | |
7559 | int ret; | |
7560 | struct peer *peer; | |
7561 | uint32_t max; | |
7562 | uint8_t threshold; | |
7563 | uint16_t restart; | |
7564 | ||
7565 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7566 | if (!peer) | |
7567 | return CMD_WARNING_CONFIG_FAILED; | |
7568 | ||
7569 | max = strtoul(num_str, NULL, 10); | |
7570 | if (threshold_str) | |
7571 | threshold = atoi(threshold_str); | |
7572 | else | |
7573 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
7574 | ||
7575 | if (restart_str) | |
7576 | restart = atoi(restart_str); | |
7577 | else | |
7578 | restart = 0; | |
7579 | ||
7580 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
7581 | restart, force_str ? true : false); | |
7582 | ||
7583 | return bgp_vty_return(vty, ret); | |
7584 | } | |
7585 | ||
7586 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
7587 | afi_t afi, safi_t safi) | |
7588 | { | |
7589 | int ret; | |
7590 | struct peer *peer; | |
7591 | ||
7592 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7593 | if (!peer) | |
7594 | return CMD_WARNING_CONFIG_FAILED; | |
7595 | ||
7596 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
7597 | ||
7598 | return bgp_vty_return(vty, ret); | |
7599 | } | |
7600 | ||
fde246e8 | 7601 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
7602 | DEFUN(neighbor_maximum_prefix_out, |
7603 | neighbor_maximum_prefix_out_cmd, | |
7604 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7605 | NEIGHBOR_STR | |
7606 | NEIGHBOR_ADDR_STR2 | |
7607 | "Maximum number of prefixes to be sent to this peer\n" | |
7608 | "Maximum no. of prefix limit\n") | |
fde246e8 DA |
7609 | { |
7610 | int idx_peer = 1; | |
7611 | int idx_number = 3; | |
7e62b792 IR |
7612 | struct peer *peer; |
7613 | uint32_t max; | |
fde246e8 DA |
7614 | afi_t afi = bgp_node_afi(vty); |
7615 | safi_t safi = bgp_node_safi(vty); | |
7616 | ||
7e62b792 IR |
7617 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7618 | if (!peer) | |
fde246e8 DA |
7619 | return CMD_WARNING_CONFIG_FAILED; |
7620 | ||
7e62b792 | 7621 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 7622 | |
7e62b792 IR |
7623 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7624 | peer->pmax_out[afi][safi] = max; | |
fde246e8 | 7625 | |
7e62b792 | 7626 | return CMD_SUCCESS; |
fde246e8 DA |
7627 | } |
7628 | ||
1d80f243 IR |
7629 | DEFUN(no_neighbor_maximum_prefix_out, |
7630 | no_neighbor_maximum_prefix_out_cmd, | |
7631 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
7632 | NO_STR | |
7633 | NEIGHBOR_STR | |
7634 | NEIGHBOR_ADDR_STR2 | |
7635 | "Maximum number of prefixes to be sent to this peer\n") | |
fde246e8 DA |
7636 | { |
7637 | int idx_peer = 2; | |
7e62b792 | 7638 | struct peer *peer; |
fde246e8 DA |
7639 | afi_t afi = bgp_node_afi(vty); |
7640 | safi_t safi = bgp_node_safi(vty); | |
7641 | ||
7e62b792 IR |
7642 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7643 | if (!peer) | |
fde246e8 DA |
7644 | return CMD_WARNING_CONFIG_FAILED; |
7645 | ||
7e62b792 IR |
7646 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7647 | peer->pmax_out[afi][safi] = 0; | |
fde246e8 | 7648 | |
7e62b792 | 7649 | return CMD_SUCCESS; |
fde246e8 DA |
7650 | } |
7651 | ||
9cbd06e0 DA |
7652 | /* Maximum number of prefix configuration. Prefix count is different |
7653 | for each peer configuration. So this configuration can be set for | |
718e3744 | 7654 | each peer configuration. */ |
1d80f243 IR |
7655 | DEFUN (neighbor_maximum_prefix, |
7656 | neighbor_maximum_prefix_cmd, | |
7657 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
7658 | NEIGHBOR_STR | |
7659 | NEIGHBOR_ADDR_STR2 | |
7660 | "Maximum number of prefix accept from this peer\n" | |
7661 | "maximum no. of prefix limit\n" | |
7662 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7663 | { |
d62a17ae | 7664 | int idx_peer = 1; |
7665 | int idx_number = 3; | |
9cbd06e0 | 7666 | int idx_force = 0; |
7e62b792 | 7667 | char *force = NULL; |
9cbd06e0 DA |
7668 | |
7669 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7670 | force = argv[idx_force]->arg; |
9cbd06e0 | 7671 | |
7e62b792 IR |
7672 | return peer_maximum_prefix_set_vty( |
7673 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7674 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 7675 | } |
7676 | ||
d62a17ae | 7677 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 7678 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 7679 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7680 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7681 | "maximum no. of prefix limit\n" |
7682 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7683 | |
1d80f243 IR |
7684 | DEFUN (neighbor_maximum_prefix_threshold, |
7685 | neighbor_maximum_prefix_threshold_cmd, | |
7686 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
7687 | NEIGHBOR_STR | |
7688 | NEIGHBOR_ADDR_STR2 | |
7689 | "Maximum number of prefix accept from this peer\n" | |
7690 | "maximum no. of prefix limit\n" | |
7691 | "Threshold value (%) at which to generate a warning msg\n" | |
7692 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7693 | { |
d62a17ae | 7694 | int idx_peer = 1; |
7695 | int idx_number = 3; | |
7696 | int idx_number_2 = 4; | |
9cbd06e0 | 7697 | int idx_force = 0; |
7e62b792 | 7698 | char *force = NULL; |
9cbd06e0 DA |
7699 | |
7700 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7701 | force = argv[idx_force]->arg; |
9cbd06e0 | 7702 | |
7e62b792 IR |
7703 | return peer_maximum_prefix_set_vty( |
7704 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7705 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 7706 | } |
e0701b79 | 7707 | |
d62a17ae | 7708 | ALIAS_HIDDEN( |
7709 | neighbor_maximum_prefix_threshold, | |
7710 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 7711 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 7712 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7713 | "Maximum number of prefix accept from this peer\n" | |
7714 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7715 | "Threshold value (%) at which to generate a warning msg\n" |
7716 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7717 | |
1d80f243 IR |
7718 | DEFUN (neighbor_maximum_prefix_warning, |
7719 | neighbor_maximum_prefix_warning_cmd, | |
7720 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
7721 | NEIGHBOR_STR | |
7722 | NEIGHBOR_ADDR_STR2 | |
7723 | "Maximum number of prefix accept from this peer\n" | |
7724 | "maximum no. of prefix limit\n" | |
7725 | "Only give warning message when limit is exceeded\n" | |
7726 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7727 | { |
d62a17ae | 7728 | int idx_peer = 1; |
7729 | int idx_number = 3; | |
9cbd06e0 | 7730 | int idx_force = 0; |
7e62b792 | 7731 | char *force = NULL; |
9cbd06e0 DA |
7732 | |
7733 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7734 | force = argv[idx_force]->arg; |
9cbd06e0 | 7735 | |
7e62b792 IR |
7736 | return peer_maximum_prefix_set_vty( |
7737 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7738 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 7739 | } |
7740 | ||
d62a17ae | 7741 | ALIAS_HIDDEN( |
7742 | neighbor_maximum_prefix_warning, | |
7743 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 7744 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 7745 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7746 | "Maximum number of prefix accept from this peer\n" | |
7747 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7748 | "Only give warning message when limit is exceeded\n" |
7749 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7750 | |
1d80f243 IR |
7751 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
7752 | neighbor_maximum_prefix_threshold_warning_cmd, | |
7753 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
7754 | NEIGHBOR_STR | |
7755 | NEIGHBOR_ADDR_STR2 | |
7756 | "Maximum number of prefix accept from this peer\n" | |
7757 | "maximum no. of prefix limit\n" | |
7758 | "Threshold value (%) at which to generate a warning msg\n" | |
7759 | "Only give warning message when limit is exceeded\n" | |
7760 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7761 | { |
d62a17ae | 7762 | int idx_peer = 1; |
7763 | int idx_number = 3; | |
7764 | int idx_number_2 = 4; | |
9cbd06e0 | 7765 | int idx_force = 0; |
7e62b792 | 7766 | char *force = NULL; |
9cbd06e0 DA |
7767 | |
7768 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7769 | force = argv[idx_force]->arg; |
9cbd06e0 | 7770 | |
7e62b792 IR |
7771 | return peer_maximum_prefix_set_vty( |
7772 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7773 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 7774 | } |
7775 | ||
d62a17ae | 7776 | ALIAS_HIDDEN( |
7777 | neighbor_maximum_prefix_threshold_warning, | |
7778 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 7779 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 7780 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7781 | "Maximum number of prefix accept from this peer\n" | |
7782 | "maximum no. of prefix limit\n" | |
7783 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7784 | "Only give warning message when limit is exceeded\n" |
7785 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7786 | |
1d80f243 IR |
7787 | DEFUN (neighbor_maximum_prefix_restart, |
7788 | neighbor_maximum_prefix_restart_cmd, | |
7789 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
7790 | NEIGHBOR_STR | |
7791 | NEIGHBOR_ADDR_STR2 | |
7792 | "Maximum number of prefix accept from this peer\n" | |
7793 | "maximum no. of prefix limit\n" | |
7794 | "Restart bgp connection after limit is exceeded\n" | |
7795 | "Restart interval in minutes\n" | |
7796 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7797 | { |
d62a17ae | 7798 | int idx_peer = 1; |
7799 | int idx_number = 3; | |
7800 | int idx_number_2 = 5; | |
9cbd06e0 | 7801 | int idx_force = 0; |
7e62b792 | 7802 | char *force = NULL; |
9cbd06e0 DA |
7803 | |
7804 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7805 | force = argv[idx_force]->arg; |
9cbd06e0 | 7806 | |
7e62b792 IR |
7807 | return peer_maximum_prefix_set_vty( |
7808 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7809 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 7810 | } |
7811 | ||
d62a17ae | 7812 | ALIAS_HIDDEN( |
7813 | neighbor_maximum_prefix_restart, | |
7814 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 7815 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 7816 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7817 | "Maximum number of prefix accept from this peer\n" | |
7818 | "maximum no. of prefix limit\n" | |
7819 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7820 | "Restart interval in minutes\n" |
7821 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7822 | |
1d80f243 IR |
7823 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
7824 | neighbor_maximum_prefix_threshold_restart_cmd, | |
7825 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
7826 | NEIGHBOR_STR | |
7827 | NEIGHBOR_ADDR_STR2 | |
7828 | "Maximum number of prefixes to accept from this peer\n" | |
7829 | "maximum no. of prefix limit\n" | |
7830 | "Threshold value (%) at which to generate a warning msg\n" | |
7831 | "Restart bgp connection after limit is exceeded\n" | |
7832 | "Restart interval in minutes\n" | |
7833 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7834 | { |
d62a17ae | 7835 | int idx_peer = 1; |
7836 | int idx_number = 3; | |
7837 | int idx_number_2 = 4; | |
7838 | int idx_number_3 = 6; | |
9cbd06e0 | 7839 | int idx_force = 0; |
7e62b792 | 7840 | char *force = NULL; |
9cbd06e0 DA |
7841 | |
7842 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7843 | force = argv[idx_force]->arg; |
9cbd06e0 | 7844 | |
7e62b792 IR |
7845 | return peer_maximum_prefix_set_vty( |
7846 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7847 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
7848 | argv[idx_number_3]->arg, force); | |
d62a17ae | 7849 | } |
7850 | ||
7851 | ALIAS_HIDDEN( | |
7852 | neighbor_maximum_prefix_threshold_restart, | |
7853 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7854 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7855 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7856 | "Maximum number of prefixes to accept from this peer\n" | |
7857 | "maximum no. of prefix limit\n" | |
7858 | "Threshold value (%) at which to generate a warning msg\n" | |
7859 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7860 | "Restart interval in minutes\n" |
7861 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7862 | |
1d80f243 IR |
7863 | DEFUN (no_neighbor_maximum_prefix, |
7864 | no_neighbor_maximum_prefix_cmd, | |
7865 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
7866 | NO_STR | |
7867 | NEIGHBOR_STR | |
7868 | NEIGHBOR_ADDR_STR2 | |
7869 | "Maximum number of prefixes to accept from this peer\n" | |
7870 | "maximum no. of prefix limit\n" | |
7871 | "Threshold value (%) at which to generate a warning msg\n" | |
7872 | "Restart bgp connection after limit is exceeded\n" | |
7873 | "Restart interval in minutes\n" | |
7874 | "Only give warning message when limit is exceeded\n" | |
7875 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7876 | { |
d62a17ae | 7877 | int idx_peer = 2; |
7e62b792 IR |
7878 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
7879 | bgp_node_afi(vty), | |
7880 | bgp_node_safi(vty)); | |
718e3744 | 7881 | } |
e52702f2 | 7882 | |
d62a17ae | 7883 | ALIAS_HIDDEN( |
7884 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7885 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7886 | NO_STR NEIGHBOR_STR 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" | |
9cbd06e0 DA |
7892 | "Only give warning message when limit is exceeded\n" |
7893 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7894 | |
718e3744 | 7895 | |
718e3744 | 7896 | /* "neighbor allowas-in" */ |
7897 | DEFUN (neighbor_allowas_in, | |
7898 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7899 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7900 | NEIGHBOR_STR |
7901 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7902 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7903 | "Number of occurrences of AS number\n" |
fd8503f5 | 7904 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7905 | { |
d62a17ae | 7906 | int idx_peer = 1; |
7907 | int idx_number_origin = 3; | |
7908 | int ret; | |
7909 | int origin = 0; | |
7910 | struct peer *peer; | |
7911 | int allow_num = 0; | |
7912 | ||
7913 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7914 | if (!peer) | |
7915 | return CMD_WARNING_CONFIG_FAILED; | |
7916 | ||
7917 | if (argc <= idx_number_origin) | |
7918 | allow_num = 3; | |
7919 | else { | |
7920 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7921 | origin = 1; | |
7922 | else | |
7923 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7924 | } | |
7925 | ||
7926 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7927 | allow_num, origin); | |
7928 | ||
7929 | return bgp_vty_return(vty, ret); | |
7930 | } | |
7931 | ||
7932 | ALIAS_HIDDEN( | |
7933 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7934 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7935 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7936 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7937 | "Number of occurrences of AS number\n" |
d62a17ae | 7938 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7939 | |
718e3744 | 7940 | DEFUN (no_neighbor_allowas_in, |
7941 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7942 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7943 | NO_STR |
7944 | NEIGHBOR_STR | |
7945 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7946 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7947 | "Number of occurrences of AS number\n" |
fd8503f5 | 7948 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7949 | { |
d62a17ae | 7950 | int idx_peer = 2; |
7951 | int ret; | |
7952 | struct peer *peer; | |
718e3744 | 7953 | |
d62a17ae | 7954 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7955 | if (!peer) | |
7956 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7957 | |
d62a17ae | 7958 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7959 | bgp_node_safi(vty)); | |
718e3744 | 7960 | |
d62a17ae | 7961 | return bgp_vty_return(vty, ret); |
718e3744 | 7962 | } |
6b0655a2 | 7963 | |
d62a17ae | 7964 | ALIAS_HIDDEN( |
7965 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7966 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7967 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7968 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7969 | "Number of occurrences of AS number\n" |
d62a17ae | 7970 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7971 | |
28c6e247 IR |
7972 | DEFUN (neighbor_ttl_security, |
7973 | neighbor_ttl_security_cmd, | |
7974 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
7975 | NEIGHBOR_STR | |
7976 | NEIGHBOR_ADDR_STR2 | |
7977 | "BGP ttl-security parameters\n" | |
7978 | "Specify the maximum number of hops to the BGP peer\n" | |
7979 | "Number of hops to BGP peer\n") | |
fa411a21 | 7980 | { |
d62a17ae | 7981 | int idx_peer = 1; |
7982 | int idx_number = 4; | |
28c6e247 IR |
7983 | struct peer *peer; |
7984 | int gtsm_hops; | |
d62a17ae | 7985 | |
28c6e247 IR |
7986 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7987 | if (!peer) | |
d62a17ae | 7988 | return CMD_WARNING_CONFIG_FAILED; |
7989 | ||
28c6e247 IR |
7990 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
7991 | ||
7992 | /* | |
7993 | * If 'neighbor swpX', then this is for directly connected peers, | |
7994 | * we should not accept a ttl-security hops value greater than 1. | |
7995 | */ | |
7996 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
7997 | vty_out(vty, | |
7998 | "%s is directly connected peer, hops cannot exceed 1\n", | |
7999 | argv[idx_peer]->arg); | |
8000 | return CMD_WARNING_CONFIG_FAILED; | |
8001 | } | |
7ebe625c | 8002 | |
28c6e247 | 8003 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8004 | } |
8005 | ||
1d80f243 IR |
8006 | DEFUN (no_neighbor_ttl_security, |
8007 | no_neighbor_ttl_security_cmd, | |
8008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8009 | NO_STR | |
8010 | NEIGHBOR_STR | |
8011 | NEIGHBOR_ADDR_STR2 | |
8012 | "BGP ttl-security parameters\n" | |
8013 | "Specify the maximum number of hops to the BGP peer\n" | |
8014 | "Number of hops to BGP peer\n") | |
fa411a21 | 8015 | { |
d62a17ae | 8016 | int idx_peer = 2; |
28c6e247 | 8017 | struct peer *peer; |
fa411a21 | 8018 | |
28c6e247 IR |
8019 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8020 | if (!peer) | |
d62a17ae | 8021 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8022 | |
28c6e247 | 8023 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8024 | } |
6b0655a2 | 8025 | |
7c0e4312 DA |
8026 | /* disable-addpath-rx */ |
8027 | DEFUN(neighbor_disable_addpath_rx, | |
8028 | neighbor_disable_addpath_rx_cmd, | |
8029 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8030 | NEIGHBOR_STR | |
8031 | NEIGHBOR_ADDR_STR2 | |
8032 | "Do not accept additional paths\n") | |
8033 | { | |
8034 | char *peer_str = argv[1]->arg; | |
8035 | struct peer *peer; | |
8036 | afi_t afi = bgp_node_afi(vty); | |
8037 | safi_t safi = bgp_node_safi(vty); | |
8038 | ||
8039 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8040 | if (!peer) | |
8041 | return CMD_WARNING_CONFIG_FAILED; | |
8042 | ||
8043 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8044 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8045 | } | |
8046 | ||
8047 | DEFUN(no_neighbor_disable_addpath_rx, | |
8048 | no_neighbor_disable_addpath_rx_cmd, | |
8049 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8050 | NO_STR | |
8051 | NEIGHBOR_STR | |
8052 | NEIGHBOR_ADDR_STR2 | |
8053 | "Do not accept additional paths\n") | |
8054 | { | |
8055 | char *peer_str = argv[2]->arg; | |
8056 | struct peer *peer; | |
8057 | afi_t afi = bgp_node_afi(vty); | |
8058 | safi_t safi = bgp_node_safi(vty); | |
8059 | ||
8060 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8061 | if (!peer) | |
8062 | return CMD_WARNING_CONFIG_FAILED; | |
8063 | ||
8064 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8065 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8066 | } | |
8067 | ||
adbac85e DW |
8068 | DEFUN (neighbor_addpath_tx_all_paths, |
8069 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8070 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8071 | NEIGHBOR_STR |
8072 | NEIGHBOR_ADDR_STR2 | |
8073 | "Use addpath to advertise all paths to a neighbor\n") | |
8074 | { | |
d62a17ae | 8075 | int idx_peer = 1; |
8076 | struct peer *peer; | |
adbac85e | 8077 | |
d62a17ae | 8078 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8079 | if (!peer) | |
8080 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8081 | |
dcc68b5e MS |
8082 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8083 | BGP_ADDPATH_ALL); | |
8084 | return CMD_SUCCESS; | |
adbac85e DW |
8085 | } |
8086 | ||
d62a17ae | 8087 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8088 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8089 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8090 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8091 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8092 | |
adbac85e DW |
8093 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8094 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8095 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8096 | NO_STR |
8097 | NEIGHBOR_STR | |
8098 | NEIGHBOR_ADDR_STR2 | |
8099 | "Use addpath to advertise all paths to a neighbor\n") | |
8100 | { | |
d62a17ae | 8101 | int idx_peer = 2; |
dcc68b5e MS |
8102 | struct peer *peer; |
8103 | ||
8104 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8105 | if (!peer) | |
8106 | return CMD_WARNING_CONFIG_FAILED; | |
8107 | ||
8108 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8109 | != BGP_ADDPATH_ALL) { | |
8110 | vty_out(vty, | |
8111 | "%% Peer not currently configured to transmit all paths."); | |
8112 | return CMD_WARNING_CONFIG_FAILED; | |
8113 | } | |
8114 | ||
8115 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8116 | BGP_ADDPATH_NONE); | |
8117 | ||
8118 | return CMD_SUCCESS; | |
adbac85e DW |
8119 | } |
8120 | ||
d62a17ae | 8121 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8122 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8123 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8124 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8125 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8126 | |
06370dac DW |
8127 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8128 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8129 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8130 | NEIGHBOR_STR |
8131 | NEIGHBOR_ADDR_STR2 | |
8132 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8133 | { | |
d62a17ae | 8134 | int idx_peer = 1; |
8135 | struct peer *peer; | |
06370dac | 8136 | |
d62a17ae | 8137 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8138 | if (!peer) | |
8139 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8140 | |
dcc68b5e MS |
8141 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8142 | BGP_ADDPATH_BEST_PER_AS); | |
8143 | ||
8144 | return CMD_SUCCESS; | |
06370dac DW |
8145 | } |
8146 | ||
d62a17ae | 8147 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8148 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8149 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8150 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8151 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8152 | |
06370dac DW |
8153 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8154 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8155 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8156 | NO_STR |
8157 | NEIGHBOR_STR | |
8158 | NEIGHBOR_ADDR_STR2 | |
8159 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8160 | { | |
d62a17ae | 8161 | int idx_peer = 2; |
dcc68b5e MS |
8162 | struct peer *peer; |
8163 | ||
8164 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8165 | if (!peer) | |
8166 | return CMD_WARNING_CONFIG_FAILED; | |
8167 | ||
8168 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8169 | != BGP_ADDPATH_BEST_PER_AS) { | |
8170 | vty_out(vty, | |
8171 | "%% Peer not currently configured to transmit all best path per as."); | |
8172 | return CMD_WARNING_CONFIG_FAILED; | |
8173 | } | |
8174 | ||
8175 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8176 | BGP_ADDPATH_NONE); | |
8177 | ||
8178 | return CMD_SUCCESS; | |
06370dac DW |
8179 | } |
8180 | ||
d62a17ae | 8181 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8182 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8184 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8185 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8186 | |
2b31007c RZ |
8187 | DEFPY( |
8188 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8189 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8190 | NEIGHBOR_STR | |
8191 | NEIGHBOR_ADDR_STR2 | |
8192 | "Detect AS loops before sending to neighbor\n") | |
8193 | { | |
8194 | struct peer *peer; | |
8195 | ||
8196 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8197 | if (!peer) | |
8198 | return CMD_WARNING_CONFIG_FAILED; | |
8199 | ||
8200 | peer->as_path_loop_detection = true; | |
8201 | ||
8202 | return CMD_SUCCESS; | |
8203 | } | |
8204 | ||
8205 | DEFPY( | |
8206 | no_neighbor_aspath_loop_detection, | |
8207 | no_neighbor_aspath_loop_detection_cmd, | |
8208 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8209 | NO_STR | |
8210 | NEIGHBOR_STR | |
8211 | NEIGHBOR_ADDR_STR2 | |
8212 | "Detect AS loops before sending to neighbor\n") | |
8213 | { | |
8214 | struct peer *peer; | |
8215 | ||
8216 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8217 | if (!peer) | |
8218 | return CMD_WARNING_CONFIG_FAILED; | |
8219 | ||
8220 | peer->as_path_loop_detection = false; | |
8221 | ||
8222 | return CMD_SUCCESS; | |
8223 | } | |
8224 | ||
b9c7bc5a | 8225 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8226 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8227 | { |
b9c7bc5a PZ |
8228 | struct ecommunity *ecom = NULL; |
8229 | struct ecommunity *ecomadd; | |
ddb5b488 | 8230 | |
b9c7bc5a | 8231 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8232 | if (is_rt6) |
8233 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8234 | ECOMMUNITY_ROUTE_TARGET, | |
8235 | 0); | |
8236 | else | |
8237 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8238 | ECOMMUNITY_ROUTE_TARGET, | |
8239 | 0); | |
b9c7bc5a PZ |
8240 | if (!ecomadd) { |
8241 | vty_out(vty, "Malformed community-list value\n"); | |
8242 | if (ecom) | |
8243 | ecommunity_free(&ecom); | |
8244 | return CMD_WARNING_CONFIG_FAILED; | |
8245 | } | |
ddb5b488 | 8246 | |
b9c7bc5a PZ |
8247 | if (ecom) { |
8248 | ecommunity_merge(ecom, ecomadd); | |
8249 | ecommunity_free(&ecomadd); | |
8250 | } else { | |
8251 | ecom = ecomadd; | |
8252 | } | |
8253 | } | |
8254 | ||
8255 | if (*list) { | |
8256 | ecommunity_free(&*list); | |
ddb5b488 | 8257 | } |
b9c7bc5a PZ |
8258 | *list = ecom; |
8259 | ||
8260 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8261 | } |
8262 | ||
0ca70ba5 DS |
8263 | /* |
8264 | * v2vimport is true if we are handling a `import vrf ...` command | |
8265 | */ | |
8266 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8267 | { |
0ca70ba5 DS |
8268 | afi_t afi; |
8269 | ||
ddb5b488 | 8270 | switch (vty->node) { |
b9c7bc5a | 8271 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8272 | afi = AFI_IP; |
8273 | break; | |
b9c7bc5a | 8274 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8275 | afi = AFI_IP6; |
8276 | break; | |
ddb5b488 PZ |
8277 | default: |
8278 | vty_out(vty, | |
b9c7bc5a | 8279 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8280 | return AFI_MAX; |
ddb5b488 | 8281 | } |
69b07479 | 8282 | |
0ca70ba5 DS |
8283 | if (!v2vimport) { |
8284 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8285 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8286 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8287 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8288 | vty_out(vty, | |
8289 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8290 | return AFI_MAX; | |
8291 | } | |
8292 | } else { | |
8293 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8294 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8295 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8296 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8297 | vty_out(vty, | |
8298 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8299 | return AFI_MAX; | |
8300 | } | |
8301 | } | |
8302 | return afi; | |
ddb5b488 PZ |
8303 | } |
8304 | ||
585f1adc IR |
8305 | DEFPY (af_rd_vpn_export, |
8306 | af_rd_vpn_export_cmd, | |
8307 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8308 | NO_STR | |
8309 | "Specify route distinguisher\n" | |
8310 | "Between current address-family and vpn\n" | |
8311 | "For routes leaked from current address-family to vpn\n" | |
8312 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8313 | { |
585f1adc IR |
8314 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8315 | struct prefix_rd prd; | |
8316 | int ret; | |
ddb5b488 | 8317 | afi_t afi; |
b9c7bc5a | 8318 | int idx = 0; |
585f1adc | 8319 | bool yes = true; |
b9c7bc5a | 8320 | |
585f1adc IR |
8321 | if (argv_find(argv, argc, "no", &idx)) |
8322 | yes = false; | |
ddb5b488 | 8323 | |
585f1adc IR |
8324 | if (yes) { |
8325 | ret = str2prefix_rd(rd_str, &prd); | |
8326 | if (!ret) { | |
8327 | vty_out(vty, "%% Malformed rd\n"); | |
8328 | return CMD_WARNING_CONFIG_FAILED; | |
8329 | } | |
8330 | } | |
ddb5b488 | 8331 | |
585f1adc IR |
8332 | afi = vpn_policy_getafi(vty, bgp, false); |
8333 | if (afi == AFI_MAX) | |
8334 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8335 | |
585f1adc IR |
8336 | /* |
8337 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8338 | */ | |
8339 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8340 | bgp_get_default(), bgp); | |
ddb5b488 | 8341 | |
585f1adc IR |
8342 | if (yes) { |
8343 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8344 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8345 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8346 | } else { | |
8347 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8348 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8349 | } | |
69b07479 | 8350 | |
585f1adc IR |
8351 | /* post-change: re-export vpn routes */ |
8352 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8353 | bgp_get_default(), bgp); | |
8354 | ||
8355 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8356 | } |
8357 | ||
b9c7bc5a PZ |
8358 | ALIAS (af_rd_vpn_export, |
8359 | af_no_rd_vpn_export_cmd, | |
8360 | "no rd vpn export", | |
ddb5b488 | 8361 | NO_STR |
b9c7bc5a PZ |
8362 | "Specify route distinguisher\n" |
8363 | "Between current address-family and vpn\n" | |
8364 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8365 | |
b9c7bc5a PZ |
8366 | DEFPY (af_label_vpn_export, |
8367 | af_label_vpn_export_cmd, | |
e70e9f8e | 8368 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8369 | NO_STR |
ddb5b488 | 8370 | "label value for VRF\n" |
b9c7bc5a PZ |
8371 | "Between current address-family and vpn\n" |
8372 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8373 | "Label Value <0-1048575>\n" |
8374 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8375 | { |
8376 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8377 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8378 | afi_t afi; |
b9c7bc5a | 8379 | int idx = 0; |
c6423c31 | 8380 | bool yes = true; |
b9c7bc5a PZ |
8381 | |
8382 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8383 | yes = false; |
ddb5b488 | 8384 | |
21a16cc2 PZ |
8385 | /* If "no ...", squash trailing parameter */ |
8386 | if (!yes) | |
8387 | label_auto = NULL; | |
8388 | ||
e70e9f8e PZ |
8389 | if (yes) { |
8390 | if (!label_auto) | |
8391 | label = label_val; /* parser should force unsigned */ | |
8392 | } | |
ddb5b488 | 8393 | |
0ca70ba5 | 8394 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8395 | if (afi == AFI_MAX) |
8396 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8397 | |
e70e9f8e | 8398 | |
69b07479 DS |
8399 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8400 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8401 | /* no change */ | |
8402 | return CMD_SUCCESS; | |
e70e9f8e | 8403 | |
69b07479 DS |
8404 | /* |
8405 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8406 | */ | |
8407 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8408 | bgp_get_default(), bgp); | |
8409 | ||
8410 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8411 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8412 | ||
8413 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8414 | ||
8415 | /* | |
8416 | * label has previously been automatically | |
8417 | * assigned by labelpool: release it | |
8418 | * | |
8419 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8420 | * means the automatic assignment is in flight | |
8421 | * and therefore the labelpool callback must | |
8422 | * detect that the auto label is not needed. | |
8423 | */ | |
8424 | ||
8425 | bgp_lp_release(LP_TYPE_VRF, | |
8426 | &bgp->vpn_policy[afi], | |
8427 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8428 | } |
69b07479 DS |
8429 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8430 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8431 | } | |
ddb5b488 | 8432 | |
69b07479 DS |
8433 | bgp->vpn_policy[afi].tovpn_label = label; |
8434 | if (label_auto) { | |
8435 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8436 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8437 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8438 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8439 | } |
8440 | ||
69b07479 DS |
8441 | /* post-change: re-export vpn routes */ |
8442 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8443 | bgp_get_default(), bgp); | |
8444 | ||
0d020cd6 | 8445 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
8446 | return CMD_SUCCESS; |
8447 | } | |
8448 | ||
b72c9e14 HS |
8449 | DEFPY (af_sid_vpn_export, |
8450 | af_sid_vpn_export_cmd, | |
8451 | "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>", | |
8452 | NO_STR | |
8453 | "sid value for VRF\n" | |
8454 | "Between current address-family and vpn\n" | |
8455 | "For routes leaked from current address-family to vpn\n" | |
8456 | "Sid allocation index\n" | |
8457 | "Automatically assign a label\n") | |
8458 | { | |
8459 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8460 | afi_t afi; | |
8461 | int debug = 0; | |
8462 | int idx = 0; | |
8463 | bool yes = true; | |
8464 | ||
8465 | if (argv_find(argv, argc, "no", &idx)) | |
8466 | yes = false; | |
8467 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
8468 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
8469 | ||
8470 | afi = vpn_policy_getafi(vty, bgp, false); | |
8471 | if (afi == AFI_MAX) | |
8472 | return CMD_WARNING_CONFIG_FAILED; | |
8473 | ||
8474 | if (!yes) { | |
8475 | /* implement me */ | |
8476 | vty_out(vty, "It's not implemented"); | |
8477 | return CMD_WARNING_CONFIG_FAILED; | |
8478 | } | |
8479 | ||
8480 | /* skip when it's already configured */ | |
8481 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
8482 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8483 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
8484 | return CMD_SUCCESS; | |
8485 | ||
7de4c885 HS |
8486 | /* |
8487 | * mode change between sid_idx and sid_auto isn't supported. | |
8488 | * user must negate sid vpn export when they want to change the mode | |
8489 | */ | |
b72c9e14 HS |
8490 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
8491 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8492 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
8493 | vty_out(vty, "it's already configured as %s.\n", | |
8494 | sid_auto ? "auto-mode" : "idx-mode"); | |
8495 | return CMD_WARNING_CONFIG_FAILED; | |
8496 | } | |
8497 | ||
8498 | /* pre-change */ | |
8499 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8500 | bgp_get_default(), bgp); | |
8501 | ||
8502 | if (sid_auto) { | |
8503 | /* SID allocation auto-mode */ | |
8504 | if (debug) | |
8505 | zlog_debug("%s: auto sid alloc.", __func__); | |
8506 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8507 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
8508 | } else { | |
8509 | /* SID allocation index-mode */ | |
8510 | if (debug) | |
8511 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
8512 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
8513 | } | |
8514 | ||
8515 | /* post-change */ | |
8516 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8517 | bgp_get_default(), bgp); | |
8518 | return CMD_SUCCESS; | |
8519 | } | |
8520 | ||
b9c7bc5a PZ |
8521 | ALIAS (af_label_vpn_export, |
8522 | af_no_label_vpn_export_cmd, | |
8523 | "no label vpn export", | |
8524 | NO_STR | |
8525 | "label value for VRF\n" | |
8526 | "Between current address-family and vpn\n" | |
8527 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8528 | |
585f1adc | 8529 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 8530 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 8531 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 8532 | NO_STR |
ddb5b488 | 8533 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
8534 | "Between current address-family and vpn\n" |
8535 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8536 | "IPv4 prefix\n" |
8537 | "IPv6 prefix\n") | |
8538 | { | |
585f1adc | 8539 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 8540 | afi_t afi; |
ddb5b488 PZ |
8541 | struct prefix p; |
8542 | ||
8c85ca28 QY |
8543 | if (!no) { |
8544 | if (!nexthop_su) { | |
8545 | vty_out(vty, "%% Nexthop required\n"); | |
8546 | return CMD_WARNING_CONFIG_FAILED; | |
8547 | } | |
8c85ca28 | 8548 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
8549 | return CMD_WARNING_CONFIG_FAILED; |
8550 | } | |
ddb5b488 | 8551 | |
585f1adc IR |
8552 | afi = vpn_policy_getafi(vty, bgp, false); |
8553 | if (afi == AFI_MAX) | |
8554 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8555 | |
585f1adc IR |
8556 | /* |
8557 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8558 | */ | |
8559 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8560 | bgp_get_default(), bgp); | |
ddb5b488 | 8561 | |
585f1adc IR |
8562 | if (!no) { |
8563 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
8564 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8565 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8566 | } else { | |
8567 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8568 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8569 | } | |
69b07479 | 8570 | |
585f1adc IR |
8571 | /* post-change: re-export vpn routes */ |
8572 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8573 | bgp_get_default(), bgp); | |
37a87b8f | 8574 | |
585f1adc | 8575 | return CMD_SUCCESS; |
ddb5b488 PZ |
8576 | } |
8577 | ||
b9c7bc5a | 8578 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 8579 | { |
b9c7bc5a PZ |
8580 | if (!strcmp(dstr, "import")) { |
8581 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8582 | } else if (!strcmp(dstr, "export")) { | |
8583 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8584 | } else if (!strcmp(dstr, "both")) { | |
8585 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8586 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8587 | } else { | |
8588 | vty_out(vty, "%% direction parse error\n"); | |
8589 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8590 | } |
ddb5b488 PZ |
8591 | return CMD_SUCCESS; |
8592 | } | |
8593 | ||
b9c7bc5a PZ |
8594 | DEFPY (af_rt_vpn_imexport, |
8595 | af_rt_vpn_imexport_cmd, | |
8596 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8597 | NO_STR | |
8598 | "Specify route target list\n" | |
ddb5b488 | 8599 | "Specify route target list\n" |
b9c7bc5a PZ |
8600 | "Between current address-family and vpn\n" |
8601 | "For routes leaked from vpn to current address-family: match any\n" | |
8602 | "For routes leaked from current address-family to vpn: set\n" | |
8603 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
8604 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
8605 | { | |
8606 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8607 | int ret; | |
8608 | struct ecommunity *ecom = NULL; | |
8609 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8610 | vpn_policy_direction_t dir; |
8611 | afi_t afi; | |
8612 | int idx = 0; | |
c6423c31 | 8613 | bool yes = true; |
ddb5b488 | 8614 | |
b9c7bc5a | 8615 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8616 | yes = false; |
b9c7bc5a | 8617 | |
0ca70ba5 | 8618 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8619 | if (afi == AFI_MAX) |
8620 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8621 | |
b9c7bc5a | 8622 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8623 | if (ret != CMD_SUCCESS) |
8624 | return ret; | |
8625 | ||
b9c7bc5a PZ |
8626 | if (yes) { |
8627 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8628 | vty_out(vty, "%% Missing RTLIST\n"); | |
8629 | return CMD_WARNING_CONFIG_FAILED; | |
8630 | } | |
c6423c31 | 8631 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
8632 | if (ret != CMD_SUCCESS) { |
8633 | return ret; | |
8634 | } | |
ddb5b488 PZ |
8635 | } |
8636 | ||
69b07479 DS |
8637 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8638 | if (!dodir[dir]) | |
ddb5b488 | 8639 | continue; |
ddb5b488 | 8640 | |
69b07479 | 8641 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8642 | |
69b07479 DS |
8643 | if (yes) { |
8644 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8645 | ecommunity_free( | |
8646 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8647 | bgp->vpn_policy[afi].rtlist[dir] = | |
8648 | ecommunity_dup(ecom); | |
8649 | } else { | |
8650 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8651 | ecommunity_free( | |
8652 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8653 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 8654 | } |
69b07479 DS |
8655 | |
8656 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 8657 | } |
69b07479 | 8658 | |
d555f3e9 PZ |
8659 | if (ecom) |
8660 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
8661 | |
8662 | return CMD_SUCCESS; | |
8663 | } | |
8664 | ||
b9c7bc5a PZ |
8665 | ALIAS (af_rt_vpn_imexport, |
8666 | af_no_rt_vpn_imexport_cmd, | |
8667 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
8668 | NO_STR |
8669 | "Specify route target list\n" | |
b9c7bc5a PZ |
8670 | "Specify route target list\n" |
8671 | "Between current address-family and vpn\n" | |
8672 | "For routes leaked from vpn to current address-family\n" | |
8673 | "For routes leaked from current address-family to vpn\n" | |
8674 | "both import and export\n") | |
8675 | ||
585f1adc | 8676 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
8677 | af_route_map_vpn_imexport_cmd, |
8678 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8679 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8680 | NO_STR | |
ddb5b488 | 8681 | "Specify route map\n" |
b9c7bc5a PZ |
8682 | "Between current address-family and vpn\n" |
8683 | "For routes leaked from vpn to current address-family\n" | |
8684 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8685 | "name of route-map\n") |
8686 | { | |
585f1adc IR |
8687 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8688 | int ret; | |
8689 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
8690 | vpn_policy_direction_t dir; | |
ddb5b488 | 8691 | afi_t afi; |
ddb5b488 | 8692 | int idx = 0; |
585f1adc | 8693 | bool yes = true; |
ddb5b488 | 8694 | |
585f1adc IR |
8695 | if (argv_find(argv, argc, "no", &idx)) |
8696 | yes = false; | |
ddb5b488 | 8697 | |
585f1adc IR |
8698 | afi = vpn_policy_getafi(vty, bgp, false); |
8699 | if (afi == AFI_MAX) | |
8700 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8701 | |
585f1adc IR |
8702 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
8703 | if (ret != CMD_SUCCESS) | |
8704 | return ret; | |
ddb5b488 | 8705 | |
585f1adc IR |
8706 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8707 | if (!dodir[dir]) | |
8708 | continue; | |
69b07479 | 8709 | |
585f1adc IR |
8710 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
8711 | ||
8712 | if (yes) { | |
8713 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8714 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8715 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8716 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8717 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8718 | bgp->vpn_policy[afi].rmap[dir] = | |
8719 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8720 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8721 | return CMD_SUCCESS; | |
8722 | } else { | |
8723 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8724 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8725 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8726 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8727 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8728 | } | |
8729 | ||
8730 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8731 | } | |
ddb5b488 | 8732 | |
585f1adc | 8733 | return CMD_SUCCESS; |
ddb5b488 PZ |
8734 | } |
8735 | ||
b9c7bc5a PZ |
8736 | ALIAS (af_route_map_vpn_imexport, |
8737 | af_no_route_map_vpn_imexport_cmd, | |
8738 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
8739 | NO_STR |
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") | |
8744 | ||
bb4f6190 | 8745 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 8746 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
8747 | "Import routes from another VRF\n" |
8748 | "Vrf routes being filtered\n" | |
8749 | "Specify route map\n" | |
8750 | "name of route-map\n") | |
8751 | { | |
8752 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
8753 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
8754 | afi_t afi; | |
bb4f6190 DS |
8755 | struct bgp *bgp_default; |
8756 | ||
0ca70ba5 | 8757 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
8758 | if (afi == AFI_MAX) |
8759 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
8760 | |
8761 | bgp_default = bgp_get_default(); | |
8762 | if (!bgp_default) { | |
8763 | int32_t ret; | |
8764 | as_t as = bgp->as; | |
8765 | ||
8766 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8767 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8768 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
8769 | |
8770 | if (ret) { | |
8771 | vty_out(vty, | |
8772 | "VRF default is not configured as a bgp instance\n"); | |
8773 | return CMD_WARNING; | |
8774 | } | |
8775 | } | |
8776 | ||
69b07479 | 8777 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 8778 | |
ae6a6fb4 DS |
8779 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
8780 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8781 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8782 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8783 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8784 | bgp->vpn_policy[afi].rmap[dir] = | |
8785 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8786 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8787 | return CMD_SUCCESS; | |
8788 | ||
8789 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8790 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 8791 | |
69b07479 DS |
8792 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8793 | ||
bb4f6190 DS |
8794 | return CMD_SUCCESS; |
8795 | } | |
8796 | ||
ae6a6fb4 DS |
8797 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
8798 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
8799 | NO_STR |
8800 | "Import routes from another VRF\n" | |
8801 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
8802 | "Specify route map\n" |
8803 | "name of route-map\n") | |
8804 | { | |
8805 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8806 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8807 | afi_t afi; | |
8808 | ||
8809 | afi = vpn_policy_getafi(vty, bgp, true); | |
8810 | if (afi == AFI_MAX) | |
8811 | return CMD_WARNING_CONFIG_FAILED; | |
8812 | ||
8813 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8814 | ||
8815 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8816 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8817 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8818 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8819 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8820 | ||
8821 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
8822 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8823 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8824 | ||
8825 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8826 | ||
8827 | return CMD_SUCCESS; | |
8828 | } | |
bb4f6190 | 8829 | |
585f1adc IR |
8830 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
8831 | "[no] import vrf VIEWVRFNAME$import_name", | |
8832 | NO_STR | |
8833 | "Import routes from another VRF\n" | |
8834 | "VRF to import from\n" | |
8835 | "The name of the VRF\n") | |
12a844a5 | 8836 | { |
585f1adc IR |
8837 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8838 | struct listnode *node; | |
8839 | struct bgp *vrf_bgp, *bgp_default; | |
8840 | int32_t ret = 0; | |
8841 | as_t as = bgp->as; | |
8842 | bool remove = false; | |
8843 | int32_t idx = 0; | |
8844 | char *vname; | |
8845 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
8846 | safi_t safi; |
8847 | afi_t afi; | |
8848 | ||
867f0cca | 8849 | if (import_name == NULL) { |
8850 | vty_out(vty, "%% Missing import name\n"); | |
8851 | return CMD_WARNING; | |
8852 | } | |
8853 | ||
ae6a6fb4 DS |
8854 | if (strcmp(import_name, "route-map") == 0) { |
8855 | vty_out(vty, "%% Must include route-map name\n"); | |
8856 | return CMD_WARNING; | |
8857 | } | |
8858 | ||
585f1adc IR |
8859 | if (argv_find(argv, argc, "no", &idx)) |
8860 | remove = true; | |
8861 | ||
8862 | afi = vpn_policy_getafi(vty, bgp, true); | |
8863 | if (afi == AFI_MAX) | |
8864 | return CMD_WARNING_CONFIG_FAILED; | |
8865 | ||
12a844a5 DS |
8866 | safi = bgp_node_safi(vty); |
8867 | ||
585f1adc IR |
8868 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
8869 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
8870 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
8871 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
8872 | remove ? "unimport" : "import", import_name); | |
8873 | return CMD_WARNING; | |
8874 | } | |
25679caa | 8875 | |
585f1adc IR |
8876 | bgp_default = bgp_get_default(); |
8877 | if (!bgp_default) { | |
8878 | /* Auto-create assuming the same AS */ | |
8879 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
8880 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 8881 | |
585f1adc IR |
8882 | if (ret) { |
8883 | vty_out(vty, | |
8884 | "VRF default is not configured as a bgp instance\n"); | |
8885 | return CMD_WARNING; | |
8886 | } | |
8887 | } | |
12a844a5 | 8888 | |
585f1adc IR |
8889 | vrf_bgp = bgp_lookup_by_name(import_name); |
8890 | if (!vrf_bgp) { | |
8891 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
8892 | vrf_bgp = bgp_default; | |
8893 | else | |
8894 | /* Auto-create assuming the same AS */ | |
8895 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
8896 | ||
8897 | if (ret) { | |
8898 | vty_out(vty, | |
8899 | "VRF %s is not configured as a bgp instance\n", | |
8900 | import_name); | |
8901 | return CMD_WARNING; | |
8902 | } | |
8903 | } | |
8904 | ||
8905 | if (remove) { | |
8906 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
8907 | } else { | |
8908 | /* Already importing from "import_vrf"? */ | |
8909 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
8910 | vname)) { | |
8911 | if (strcmp(vname, import_name) == 0) | |
8912 | return CMD_WARNING; | |
8913 | } | |
8914 | ||
8915 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
8916 | } | |
8917 | ||
8918 | return CMD_SUCCESS; | |
12a844a5 DS |
8919 | } |
8920 | ||
b9c7bc5a | 8921 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 8922 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
8923 | bgp_imexport_vpn_cmd, |
8924 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
8925 | NO_STR |
8926 | "Import routes to this address-family\n" | |
8927 | "Export routes from this address-family\n" | |
8928 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 8929 | { |
585f1adc IR |
8930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8931 | int previous_state; | |
37a87b8f | 8932 | afi_t afi; |
585f1adc IR |
8933 | safi_t safi; |
8934 | int idx = 0; | |
8935 | bool yes = true; | |
8936 | int flag; | |
8937 | vpn_policy_direction_t dir; | |
8938 | ||
8939 | if (argv_find(argv, argc, "no", &idx)) | |
8940 | yes = false; | |
8941 | ||
8942 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
8943 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
8944 | ||
8945 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
8946 | return CMD_WARNING_CONFIG_FAILED; | |
8947 | } | |
ddb5b488 | 8948 | |
b9c7bc5a PZ |
8949 | afi = bgp_node_afi(vty); |
8950 | safi = bgp_node_safi(vty); | |
585f1adc IR |
8951 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
8952 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
8953 | return CMD_WARNING_CONFIG_FAILED; | |
8954 | } | |
ddb5b488 | 8955 | |
b9c7bc5a | 8956 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
8957 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
8958 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 8959 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
8960 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
8961 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
8962 | } else { |
8963 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
8964 | return CMD_WARNING_CONFIG_FAILED; | |
8965 | } | |
8966 | ||
585f1adc | 8967 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 8968 | |
585f1adc IR |
8969 | if (yes) { |
8970 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
8971 | if (!previous_state) { | |
8972 | /* trigger export current vrf */ | |
8973 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8974 | } | |
8975 | } else { | |
8976 | if (previous_state) { | |
8977 | /* trigger un-export current vrf */ | |
8978 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8979 | } | |
8980 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
8981 | } | |
37a87b8f | 8982 | |
1ca2fd11 IR |
8983 | hook_call(bgp_snmp_init_stats, bgp); |
8984 | ||
585f1adc | 8985 | return CMD_SUCCESS; |
ddb5b488 PZ |
8986 | } |
8987 | ||
301ad80a PG |
8988 | DEFPY (af_routetarget_import, |
8989 | af_routetarget_import_cmd, | |
9a659715 | 8990 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
8991 | NO_STR |
8992 | "Specify route target list\n" | |
8993 | "Specify route target list\n" | |
9a659715 PG |
8994 | "Specify route target list\n" |
8995 | "Specify route target list\n" | |
301ad80a PG |
8996 | "Flow-spec redirect type route target\n" |
8997 | "Import routes to this address-family\n" | |
9a659715 | 8998 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
8999 | { |
9000 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9001 | int ret; | |
9002 | struct ecommunity *ecom = NULL; | |
301ad80a | 9003 | afi_t afi; |
9a659715 | 9004 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9005 | bool yes = true; |
9006 | bool rt6 = false; | |
301ad80a PG |
9007 | |
9008 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9009 | yes = false; |
301ad80a | 9010 | |
9a659715 PG |
9011 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9012 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9013 | rt6 = true; |
301ad80a | 9014 | |
0ca70ba5 | 9015 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9016 | if (afi == AFI_MAX) |
9017 | return CMD_WARNING_CONFIG_FAILED; | |
9018 | ||
9a659715 PG |
9019 | if (rt6 && afi != AFI_IP6) |
9020 | return CMD_WARNING_CONFIG_FAILED; | |
9021 | ||
301ad80a PG |
9022 | if (yes) { |
9023 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9024 | vty_out(vty, "%% Missing RTLIST\n"); | |
9025 | return CMD_WARNING_CONFIG_FAILED; | |
9026 | } | |
9a659715 | 9027 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9028 | if (ret != CMD_SUCCESS) |
9029 | return ret; | |
9030 | } | |
69b07479 DS |
9031 | |
9032 | if (yes) { | |
9033 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9034 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9035 | .import_redirect_rtlist); |
69b07479 DS |
9036 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9037 | ecommunity_dup(ecom); | |
9038 | } else { | |
9039 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9040 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9041 | .import_redirect_rtlist); |
69b07479 | 9042 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9043 | } |
69b07479 | 9044 | |
301ad80a PG |
9045 | if (ecom) |
9046 | ecommunity_free(&ecom); | |
9047 | ||
9048 | return CMD_SUCCESS; | |
9049 | } | |
9050 | ||
505e5056 | 9051 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9052 | address_family_ipv4_safi_cmd, |
9053 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9054 | "Enter Address Family command mode\n" | |
9055 | "Address Family\n" | |
9056 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9057 | { |
f51bae9c | 9058 | |
d62a17ae | 9059 | if (argc == 3) { |
585f1adc IR |
9060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9061 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9062 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9063 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9064 | && safi != SAFI_EVPN) { |
31947174 MK |
9065 | vty_out(vty, |
9066 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9067 | return CMD_WARNING_CONFIG_FAILED; |
9068 | } | |
585f1adc IR |
9069 | vty->node = bgp_node_type(AFI_IP, safi); |
9070 | } else | |
9071 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9072 | |
d62a17ae | 9073 | return CMD_SUCCESS; |
718e3744 | 9074 | } |
9075 | ||
505e5056 | 9076 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9077 | address_family_ipv6_safi_cmd, |
9078 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9079 | "Enter Address Family command mode\n" | |
9080 | "Address Family\n" | |
9081 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9082 | { |
d62a17ae | 9083 | if (argc == 3) { |
585f1adc IR |
9084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9085 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9086 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9087 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9088 | && safi != SAFI_EVPN) { |
31947174 MK |
9089 | vty_out(vty, |
9090 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9091 | return CMD_WARNING_CONFIG_FAILED; |
9092 | } | |
585f1adc IR |
9093 | vty->node = bgp_node_type(AFI_IP6, safi); |
9094 | } else | |
9095 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9096 | |
d62a17ae | 9097 | return CMD_SUCCESS; |
25ffbdc1 | 9098 | } |
718e3744 | 9099 | |
d6902373 | 9100 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9101 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9102 | address_family_vpnv4_cmd, |
8334fd5a | 9103 | "address-family vpnv4 [unicast]", |
718e3744 | 9104 | "Enter Address Family command mode\n" |
8c3deaae | 9105 | "Address Family\n" |
3a2d747c | 9106 | "Address Family modifier\n") |
718e3744 | 9107 | { |
d62a17ae | 9108 | vty->node = BGP_VPNV4_NODE; |
9109 | return CMD_SUCCESS; | |
718e3744 | 9110 | } |
9111 | ||
505e5056 | 9112 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9113 | address_family_vpnv6_cmd, |
8334fd5a | 9114 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9115 | "Enter Address Family command mode\n" |
8c3deaae | 9116 | "Address Family\n" |
3a2d747c | 9117 | "Address Family modifier\n") |
8ecd3266 | 9118 | { |
d62a17ae | 9119 | vty->node = BGP_VPNV6_NODE; |
9120 | return CMD_SUCCESS; | |
8ecd3266 | 9121 | } |
64e4a6c5 | 9122 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9123 | |
505e5056 | 9124 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9125 | address_family_evpn_cmd, |
7111c1a0 | 9126 | "address-family l2vpn evpn", |
4e0b7b6d | 9127 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9128 | "Address Family\n" |
9129 | "Address Family modifier\n") | |
4e0b7b6d | 9130 | { |
2131d5cf | 9131 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9132 | vty->node = BGP_EVPN_NODE; |
9133 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9134 | } |
9135 | ||
bfaab44d HS |
9136 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9137 | bgp_segment_routing_srv6_cmd, | |
9138 | "segment-routing srv6", | |
9139 | "Segment-Routing configuration\n" | |
9140 | "Segment-Routing SRv6 configuration\n") | |
9141 | { | |
9142 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9143 | bgp->srv6_enabled = true; |
bfaab44d HS |
9144 | vty->node = BGP_SRV6_NODE; |
9145 | return CMD_SUCCESS; | |
9146 | } | |
9147 | ||
0249b8b6 HS |
9148 | DEFUN (no_bgp_segment_routing_srv6, |
9149 | no_bgp_segment_routing_srv6_cmd, | |
9150 | "no segment-routing srv6", | |
9151 | NO_STR | |
9152 | "Segment-Routing configuration\n" | |
9153 | "Segment-Routing SRv6 configuration\n") | |
9154 | { | |
9155 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9156 | ||
9157 | if (strlen(bgp->srv6_locator_name) > 0) | |
9158 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9159 | return CMD_WARNING_CONFIG_FAILED; | |
9160 | ||
9161 | bgp->srv6_enabled = false; | |
9162 | return CMD_SUCCESS; | |
9163 | } | |
9164 | ||
a0281b2e HS |
9165 | DEFPY (bgp_srv6_locator, |
9166 | bgp_srv6_locator_cmd, | |
9167 | "locator NAME$name", | |
9168 | "Specify SRv6 locator\n" | |
9169 | "Specify SRv6 locator\n") | |
9170 | { | |
9171 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9172 | int ret; |
a0281b2e HS |
9173 | |
9174 | if (strlen(bgp->srv6_locator_name) > 0 | |
9175 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9176 | vty_out(vty, "srv6 locator is already configured\n"); | |
9177 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9178 | } |
9179 | ||
9180 | snprintf(bgp->srv6_locator_name, | |
9181 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9182 | |
7de4c885 | 9183 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9184 | if (ret < 0) |
9185 | return CMD_WARNING_CONFIG_FAILED; | |
9186 | ||
9187 | return CMD_SUCCESS; | |
9188 | } | |
9189 | ||
0249b8b6 HS |
9190 | DEFPY (no_bgp_srv6_locator, |
9191 | no_bgp_srv6_locator_cmd, | |
9192 | "no locator NAME$name", | |
9193 | NO_STR | |
9194 | "Specify SRv6 locator\n" | |
9195 | "Specify SRv6 locator\n") | |
9196 | { | |
9197 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9198 | ||
9199 | /* when locator isn't configured, do nothing */ | |
9200 | if (strlen(bgp->srv6_locator_name) < 1) | |
9201 | return CMD_SUCCESS; | |
9202 | ||
9203 | /* name validation */ | |
9204 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9205 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9206 | return CMD_WARNING_CONFIG_FAILED; | |
9207 | } | |
9208 | ||
9209 | /* unset locator */ | |
9210 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9211 | return CMD_WARNING_CONFIG_FAILED; | |
9212 | ||
9213 | return CMD_SUCCESS; | |
9214 | } | |
9215 | ||
ea372e81 HS |
9216 | DEFPY (show_bgp_srv6, |
9217 | show_bgp_srv6_cmd, | |
9218 | "show bgp segment-routing srv6", | |
9219 | SHOW_STR | |
9220 | BGP_STR | |
9221 | "BGP Segment Routing\n" | |
9222 | "BGP Segment Routing SRv6\n") | |
9223 | { | |
9224 | struct bgp *bgp; | |
9225 | struct listnode *node; | |
9226 | struct prefix_ipv6 *chunk; | |
9227 | struct bgp_srv6_function *func; | |
9228 | struct in6_addr *tovpn4_sid; | |
9229 | struct in6_addr *tovpn6_sid; | |
9230 | char buf[256]; | |
9231 | char buf_tovpn4_sid[256]; | |
9232 | char buf_tovpn6_sid[256]; | |
9233 | ||
9234 | bgp = bgp_get_default(); | |
96db4340 | 9235 | if (!bgp) |
ea372e81 HS |
9236 | return CMD_SUCCESS; |
9237 | ||
9238 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9239 | vty_out(vty, "locator_chunks:\n"); | |
9240 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { | |
9241 | prefix2str(chunk, buf, sizeof(buf)); | |
9242 | vty_out(vty, "- %s\n", buf); | |
9243 | } | |
9244 | ||
9245 | vty_out(vty, "functions:\n"); | |
9246 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
9247 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
9248 | vty_out(vty, "- sid: %s\n", buf); | |
9249 | vty_out(vty, " locator: %s\n", func->locator_name); | |
9250 | } | |
9251 | ||
9252 | vty_out(vty, "bgps:\n"); | |
9253 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9254 | vty_out(vty, "- name: %s\n", | |
9255 | bgp->name ? bgp->name : "default"); | |
9256 | ||
9257 | tovpn4_sid = bgp->vpn_policy[AFI_IP].tovpn_sid; | |
9258 | tovpn6_sid = bgp->vpn_policy[AFI_IP6].tovpn_sid; | |
9259 | if (tovpn4_sid) | |
9260 | inet_ntop(AF_INET6, tovpn4_sid, buf_tovpn4_sid, | |
9261 | sizeof(buf_tovpn4_sid)); | |
9262 | if (tovpn6_sid) | |
9263 | inet_ntop(AF_INET6, tovpn6_sid, buf_tovpn6_sid, | |
9264 | sizeof(buf_tovpn6_sid)); | |
9265 | ||
9266 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %s\n", | |
9267 | tovpn4_sid ? buf_tovpn4_sid : "none"); | |
9268 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %s\n", | |
9269 | tovpn6_sid ? buf_tovpn6_sid : "none"); | |
9270 | } | |
9271 | ||
9272 | return CMD_SUCCESS; | |
9273 | } | |
9274 | ||
505e5056 | 9275 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9276 | exit_address_family_cmd, |
9277 | "exit-address-family", | |
9278 | "Exit from Address Family configuration mode\n") | |
9279 | { | |
d62a17ae | 9280 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9281 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9282 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9283 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9284 | || vty->node == BGP_EVPN_NODE |
9285 | || vty->node == BGP_FLOWSPECV4_NODE | |
9286 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9287 | vty->node = BGP_NODE; |
9288 | return CMD_SUCCESS; | |
718e3744 | 9289 | } |
6b0655a2 | 9290 | |
8ad7271d | 9291 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9292 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9293 | const char *ip_str, afi_t afi, safi_t safi, | |
9294 | struct prefix_rd *prd) | |
9295 | { | |
9296 | int ret; | |
9297 | struct prefix match; | |
9bcb3eef DS |
9298 | struct bgp_dest *dest; |
9299 | struct bgp_dest *rm; | |
d62a17ae | 9300 | struct bgp *bgp; |
9301 | struct bgp_table *table; | |
9302 | struct bgp_table *rib; | |
9303 | ||
9304 | /* BGP structure lookup. */ | |
9305 | if (view_name) { | |
9306 | bgp = bgp_lookup_by_name(view_name); | |
9307 | if (bgp == NULL) { | |
9308 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9309 | view_name); | |
9310 | return CMD_WARNING; | |
9311 | } | |
9312 | } else { | |
9313 | bgp = bgp_get_default(); | |
9314 | if (bgp == NULL) { | |
9315 | vty_out(vty, "%% No BGP process is configured\n"); | |
9316 | return CMD_WARNING; | |
9317 | } | |
9318 | } | |
9319 | ||
9320 | /* Check IP address argument. */ | |
9321 | ret = str2prefix(ip_str, &match); | |
9322 | if (!ret) { | |
9323 | vty_out(vty, "%% address is malformed\n"); | |
9324 | return CMD_WARNING; | |
9325 | } | |
9326 | ||
9327 | match.family = afi2family(afi); | |
9328 | rib = bgp->rib[afi][safi]; | |
9329 | ||
9330 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9331 | for (dest = bgp_table_top(rib); dest; |
9332 | dest = bgp_route_next(dest)) { | |
9333 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9334 | |
9bcb3eef | 9335 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9336 | continue; |
9337 | ||
9bcb3eef | 9338 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9339 | if (table == NULL) |
9340 | continue; | |
9341 | ||
4953391b DA |
9342 | rm = bgp_node_match(table, &match); |
9343 | if (rm != NULL) { | |
b54892e0 | 9344 | const struct prefix *rm_p = |
9bcb3eef | 9345 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9346 | |
9347 | if (rm_p->prefixlen == match.prefixlen) { | |
9348 | SET_FLAG(rm->flags, | |
9349 | BGP_NODE_USER_CLEAR); | |
9350 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9351 | } |
9bcb3eef | 9352 | bgp_dest_unlock_node(rm); |
d62a17ae | 9353 | } |
9354 | } | |
9355 | } else { | |
4953391b DA |
9356 | dest = bgp_node_match(rib, &match); |
9357 | if (dest != NULL) { | |
9bcb3eef | 9358 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 9359 | |
9bcb3eef DS |
9360 | if (dest_p->prefixlen == match.prefixlen) { |
9361 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9362 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9363 | } |
9bcb3eef | 9364 | bgp_dest_unlock_node(dest); |
d62a17ae | 9365 | } |
9366 | } | |
9367 | ||
9368 | return CMD_SUCCESS; | |
8ad7271d DS |
9369 | } |
9370 | ||
b09b5ae0 | 9371 | /* one clear bgp command to rule them all */ |
718e3744 | 9372 | DEFUN (clear_ip_bgp_all, |
9373 | clear_ip_bgp_all_cmd, | |
453c92f6 | 9374 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 9375 | CLEAR_STR |
9376 | IP_STR | |
9377 | BGP_STR | |
838758ac | 9378 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9379 | BGP_AFI_HELP_STR |
fd5e7b70 | 9380 | "Address Family\n" |
510afcd6 | 9381 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9382 | "Address Family modifier\n" |
b09b5ae0 | 9383 | "Clear all peers\n" |
453c92f6 | 9384 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9385 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9386 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9387 | "Clear peers with the AS number\n" |
9388 | "Clear all external peers\n" | |
718e3744 | 9389 | "Clear all members of peer-group\n" |
b09b5ae0 | 9390 | "BGP peer-group name\n" |
b09b5ae0 DW |
9391 | BGP_SOFT_STR |
9392 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9393 | BGP_SOFT_OUT_STR |
9394 | BGP_SOFT_IN_STR | |
9395 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 9396 | BGP_SOFT_OUT_STR) |
718e3744 | 9397 | { |
d62a17ae | 9398 | char *vrf = NULL; |
9399 | ||
dc912615 DS |
9400 | afi_t afi = AFI_UNSPEC; |
9401 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9402 | enum clear_sort clr_sort = clear_peer; |
9403 | enum bgp_clear_type clr_type; | |
9404 | char *clr_arg = NULL; | |
9405 | ||
9406 | int idx = 0; | |
9407 | ||
9408 | /* clear [ip] bgp */ | |
9409 | if (argv_find(argv, argc, "ip", &idx)) | |
9410 | afi = AFI_IP; | |
9411 | ||
9a8bdf1c PG |
9412 | /* [<vrf> VIEWVRFNAME] */ |
9413 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9414 | vrf = argv[idx + 1]->arg; | |
9415 | idx += 2; | |
9416 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9417 | vrf = NULL; | |
9418 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9419 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9420 | vrf = argv[idx + 1]->arg; |
9421 | idx += 2; | |
9422 | } | |
d62a17ae | 9423 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9424 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9425 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9426 | ||
d7b9898c | 9427 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9428 | if (argv_find(argv, argc, "*", &idx)) { |
9429 | clr_sort = clear_all; | |
9430 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9431 | clr_sort = clear_peer; | |
9432 | clr_arg = argv[idx]->arg; | |
9433 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9434 | clr_sort = clear_peer; | |
9435 | clr_arg = argv[idx]->arg; | |
9436 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9437 | clr_sort = clear_group; | |
9438 | idx++; | |
9439 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9440 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9441 | clr_sort = clear_peer; |
9442 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9443 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9444 | clr_sort = clear_peer; | |
9445 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9446 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9447 | clr_sort = clear_as; | |
9448 | clr_arg = argv[idx]->arg; | |
9449 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9450 | clr_sort = clear_external; | |
9451 | } | |
9452 | ||
9453 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
9454 | if (argv_find(argv, argc, "soft", &idx)) { | |
9455 | if (argv_find(argv, argc, "in", &idx) | |
9456 | || argv_find(argv, argc, "out", &idx)) | |
9457 | clr_type = strmatch(argv[idx]->text, "in") | |
9458 | ? BGP_CLEAR_SOFT_IN | |
9459 | : BGP_CLEAR_SOFT_OUT; | |
9460 | else | |
9461 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9462 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9463 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9464 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9465 | : BGP_CLEAR_SOFT_IN; | |
9466 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9467 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9468 | } else | |
9469 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9470 | ||
1ca2fd11 | 9471 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 9472 | } |
01080f7c | 9473 | |
8ad7271d DS |
9474 | DEFUN (clear_ip_bgp_prefix, |
9475 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9476 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9477 | CLEAR_STR |
9478 | IP_STR | |
9479 | BGP_STR | |
838758ac | 9480 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9481 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9482 | "IPv4 prefix\n") |
8ad7271d | 9483 | { |
d62a17ae | 9484 | char *vrf = NULL; |
9485 | char *prefix = NULL; | |
8ad7271d | 9486 | |
d62a17ae | 9487 | int idx = 0; |
01080f7c | 9488 | |
d62a17ae | 9489 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9490 | if (argv_find(argv, argc, "vrf", &idx)) { |
9491 | vrf = argv[idx + 1]->arg; | |
9492 | idx += 2; | |
9493 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9494 | vrf = NULL; | |
9495 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9496 | /* [<view> VIEWVRFNAME] */ | |
9497 | vrf = argv[idx + 1]->arg; | |
9498 | idx += 2; | |
9499 | } | |
0c7b1b01 | 9500 | |
d62a17ae | 9501 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9502 | |
d62a17ae | 9503 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9504 | } |
8ad7271d | 9505 | |
b09b5ae0 DW |
9506 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9507 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9508 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9509 | CLEAR_STR |
3a2d747c | 9510 | IP_STR |
718e3744 | 9511 | BGP_STR |
8c3deaae | 9512 | "Address Family\n" |
46f296b4 | 9513 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9514 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9515 | "IPv6 prefix\n") |
718e3744 | 9516 | { |
9b475e76 PG |
9517 | int idx_safi = 0; |
9518 | int idx_ipv6_prefix = 0; | |
9519 | safi_t safi = SAFI_UNICAST; | |
9520 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9521 | argv[idx_ipv6_prefix]->arg : NULL; | |
9522 | ||
9523 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9524 | return bgp_clear_prefix( |
9b475e76 PG |
9525 | vty, NULL, prefix, AFI_IP6, |
9526 | safi, NULL); | |
838758ac | 9527 | } |
01080f7c | 9528 | |
b09b5ae0 DW |
9529 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9530 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9531 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9532 | CLEAR_STR |
3a2d747c | 9533 | IP_STR |
718e3744 | 9534 | BGP_STR |
838758ac | 9535 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9536 | "Address Family\n" |
46f296b4 | 9537 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9538 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9539 | "IPv6 prefix\n") |
718e3744 | 9540 | { |
9b475e76 | 9541 | int idx_safi = 0; |
9a8bdf1c | 9542 | int idx_vrfview = 0; |
9b475e76 PG |
9543 | int idx_ipv6_prefix = 0; |
9544 | safi_t safi = SAFI_UNICAST; | |
9545 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9546 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9547 | char *vrfview = NULL; |
9b475e76 | 9548 | |
9a8bdf1c PG |
9549 | /* [<view|vrf> VIEWVRFNAME] */ |
9550 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9551 | vrfview = argv[idx_vrfview + 1]->arg; | |
9552 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9553 | vrfview = NULL; | |
9554 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9555 | /* [<view> VIEWVRFNAME] */ | |
9556 | vrfview = argv[idx_vrfview + 1]->arg; | |
9557 | } | |
9b475e76 PG |
9558 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9559 | ||
d62a17ae | 9560 | return bgp_clear_prefix( |
9b475e76 PG |
9561 | vty, vrfview, prefix, |
9562 | AFI_IP6, safi, NULL); | |
718e3744 | 9563 | } |
9564 | ||
b09b5ae0 DW |
9565 | DEFUN (show_bgp_views, |
9566 | show_bgp_views_cmd, | |
d6e3c605 | 9567 | "show [ip] bgp views", |
b09b5ae0 | 9568 | SHOW_STR |
d6e3c605 | 9569 | IP_STR |
01080f7c | 9570 | BGP_STR |
b09b5ae0 | 9571 | "Show the defined BGP views\n") |
01080f7c | 9572 | { |
d62a17ae | 9573 | struct list *inst = bm->bgp; |
9574 | struct listnode *node; | |
9575 | struct bgp *bgp; | |
01080f7c | 9576 | |
d62a17ae | 9577 | vty_out(vty, "Defined BGP views:\n"); |
9578 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9579 | /* Skip VRFs. */ | |
9580 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9581 | continue; | |
9582 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9583 | bgp->as); | |
9584 | } | |
e52702f2 | 9585 | |
d62a17ae | 9586 | return CMD_SUCCESS; |
e0081f70 ML |
9587 | } |
9588 | ||
8386ac43 | 9589 | DEFUN (show_bgp_vrfs, |
9590 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9591 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9592 | SHOW_STR |
d6e3c605 | 9593 | IP_STR |
8386ac43 | 9594 | BGP_STR |
9595 | "Show BGP VRFs\n" | |
9973d184 | 9596 | JSON_STR) |
8386ac43 | 9597 | { |
fe1dc5a3 | 9598 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9599 | struct list *inst = bm->bgp; |
9600 | struct listnode *node; | |
9601 | struct bgp *bgp; | |
9f049418 | 9602 | bool uj = use_json(argc, argv); |
d62a17ae | 9603 | json_object *json = NULL; |
9604 | json_object *json_vrfs = NULL; | |
9605 | int count = 0; | |
d62a17ae | 9606 | |
d62a17ae | 9607 | if (uj) { |
9608 | json = json_object_new_object(); | |
9609 | json_vrfs = json_object_new_object(); | |
9610 | } | |
9611 | ||
9612 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9613 | const char *name, *type; | |
9614 | struct peer *peer; | |
7fe96307 | 9615 | struct listnode *node2, *nnode2; |
d62a17ae | 9616 | int peers_cfg, peers_estb; |
9617 | json_object *json_vrf = NULL; | |
d62a17ae | 9618 | |
9619 | /* Skip Views. */ | |
9620 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9621 | continue; | |
9622 | ||
9623 | count++; | |
efb4077a | 9624 | if (!uj && count == 1) { |
fe1dc5a3 | 9625 | vty_out(vty, |
efb4077a | 9626 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9627 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9628 | "#PeersEstb", "Name"); |
9629 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9630 | "L3-VNI", "RouterMAC", "Interface"); | |
9631 | } | |
d62a17ae | 9632 | |
9633 | peers_cfg = peers_estb = 0; | |
9634 | if (uj) | |
9635 | json_vrf = json_object_new_object(); | |
9636 | ||
9637 | ||
7fe96307 | 9638 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9639 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9640 | continue; | |
9641 | peers_cfg++; | |
feb17238 | 9642 | if (peer_established(peer)) |
d62a17ae | 9643 | peers_estb++; |
9644 | } | |
9645 | ||
9646 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 9647 | name = VRF_DEFAULT_NAME; |
d62a17ae | 9648 | type = "DFLT"; |
9649 | } else { | |
9650 | name = bgp->name; | |
9651 | type = "VRF"; | |
9652 | } | |
9653 | ||
a8bf7d9c | 9654 | |
d62a17ae | 9655 | if (uj) { |
a4d82a8a PZ |
9656 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9657 | ? -1 | |
9658 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
9659 | char buf[BUFSIZ] = {0}; |
9660 | ||
d62a17ae | 9661 | json_object_string_add(json_vrf, "type", type); |
9662 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
9663 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
9664 | inet_ntop(AF_INET, |
9665 | &bgp->router_id, buf, | |
9666 | sizeof(buf))); | |
d62a17ae | 9667 | json_object_int_add(json_vrf, "numConfiguredPeers", |
9668 | peers_cfg); | |
9669 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9670 | peers_estb); | |
9671 | ||
fe1dc5a3 | 9672 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
9673 | json_object_string_add( |
9674 | json_vrf, "rmac", | |
9675 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
9676 | json_object_string_add(json_vrf, "interface", |
9677 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9678 | bgp->vrf_id)); | |
d62a17ae | 9679 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 9680 | } else { |
23d0a753 | 9681 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
9682 | type, |
9683 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9684 | : (int)bgp->vrf_id, | |
23d0a753 | 9685 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
9686 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
9687 | bgp->l3vni, | |
9688 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9689 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9690 | bgp->vrf_id)); | |
9691 | } | |
d62a17ae | 9692 | } |
9693 | ||
9694 | if (uj) { | |
9695 | json_object_object_add(json, "vrfs", json_vrfs); | |
9696 | ||
9697 | json_object_int_add(json, "totalVrfs", count); | |
9698 | ||
996c9314 LB |
9699 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9700 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9701 | json_object_free(json); |
9702 | } else { | |
9703 | if (count) | |
9704 | vty_out(vty, | |
9705 | "\nTotal number of VRFs (including default): %d\n", | |
9706 | count); | |
9707 | } | |
9708 | ||
9709 | return CMD_SUCCESS; | |
8386ac43 | 9710 | } |
9711 | ||
48ecf8f5 DS |
9712 | DEFUN (show_bgp_mac_hash, |
9713 | show_bgp_mac_hash_cmd, | |
9714 | "show bgp mac hash", | |
9715 | SHOW_STR | |
9716 | BGP_STR | |
9717 | "Mac Address\n" | |
9718 | "Mac Address database\n") | |
9719 | { | |
9720 | bgp_mac_dump_table(vty); | |
9721 | ||
9722 | return CMD_SUCCESS; | |
9723 | } | |
acf71666 | 9724 | |
e3b78da8 | 9725 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 9726 | { |
0291c246 | 9727 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 9728 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 9729 | |
23d0a753 | 9730 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
9731 | } |
9732 | ||
9733 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9734 | { | |
9735 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 9736 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
9737 | |
9738 | vty_out(vty, "Tunnel-ip database:\n"); | |
9739 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 9740 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
9741 | vty); |
9742 | } | |
9743 | ||
15c81ca4 DS |
9744 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
9745 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9746 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
9747 | "martian next-hops\n" |
9748 | "martian next-hop database\n") | |
acf71666 | 9749 | { |
0291c246 | 9750 | struct bgp *bgp = NULL; |
15c81ca4 | 9751 | int idx = 0; |
9a8bdf1c PG |
9752 | char *name = NULL; |
9753 | ||
9754 | /* [<vrf> VIEWVRFNAME] */ | |
9755 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9756 | name = argv[idx + 1]->arg; | |
9757 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9758 | name = NULL; | |
9759 | } else if (argv_find(argv, argc, "view", &idx)) | |
9760 | /* [<view> VIEWVRFNAME] */ | |
9761 | name = argv[idx + 1]->arg; | |
9762 | if (name) | |
9763 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
9764 | else |
9765 | bgp = bgp_get_default(); | |
acf71666 | 9766 | |
acf71666 MK |
9767 | if (!bgp) { |
9768 | vty_out(vty, "%% No BGP process is configured\n"); | |
9769 | return CMD_WARNING; | |
9770 | } | |
9771 | bgp_show_martian_nexthops(vty, bgp); | |
9772 | ||
9773 | return CMD_SUCCESS; | |
9774 | } | |
9775 | ||
f412b39a | 9776 | DEFUN (show_bgp_memory, |
4bf6a362 | 9777 | show_bgp_memory_cmd, |
7fa12b13 | 9778 | "show [ip] bgp memory", |
4bf6a362 | 9779 | SHOW_STR |
3a2d747c | 9780 | IP_STR |
4bf6a362 PJ |
9781 | BGP_STR |
9782 | "Global BGP memory statistics\n") | |
9783 | { | |
d62a17ae | 9784 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
9785 | unsigned long count; | |
9786 | ||
9787 | /* RIB related usage stats */ | |
9788 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9789 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9790 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 9791 | count * sizeof(struct bgp_dest))); |
d62a17ae | 9792 | |
9793 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9794 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
9795 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 9796 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 9797 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
9798 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
9799 | count, | |
4b7e6066 DS |
9800 | mtype_memstr( |
9801 | memstrbuf, sizeof(memstrbuf), | |
9802 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 9803 | |
9804 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
9805 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
9806 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9807 | count * sizeof(struct bgp_static))); | |
9808 | ||
9809 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
9810 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
9811 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9812 | count * sizeof(struct bpacket))); | |
9813 | ||
9814 | /* Adj-In/Out */ | |
9815 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
9816 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
9817 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9818 | count * sizeof(struct bgp_adj_in))); | |
9819 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
9820 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
9821 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9822 | count * sizeof(struct bgp_adj_out))); | |
9823 | ||
9824 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
9825 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
9826 | count, | |
9827 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9828 | count * sizeof(struct bgp_nexthop_cache))); | |
9829 | ||
9830 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
9831 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
9832 | count, | |
9833 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9834 | count * sizeof(struct bgp_damp_info))); | |
9835 | ||
9836 | /* Attributes */ | |
9837 | count = attr_count(); | |
9838 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
9839 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9840 | count * sizeof(struct attr))); | |
9841 | ||
9842 | if ((count = attr_unknown_count())) | |
9843 | vty_out(vty, "%ld unknown attributes\n", count); | |
9844 | ||
9845 | /* AS_PATH attributes */ | |
9846 | count = aspath_count(); | |
9847 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
9848 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9849 | count * sizeof(struct aspath))); | |
9850 | ||
9851 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
9852 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
9853 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9854 | count * sizeof(struct assegment))); | |
9855 | ||
9856 | /* Other attributes */ | |
9857 | if ((count = community_count())) | |
9858 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9859 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9860 | count * sizeof(struct community))); | |
d62a17ae | 9861 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
9862 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9863 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9864 | count * sizeof(struct ecommunity))); | |
d62a17ae | 9865 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
9866 | vty_out(vty, | |
9867 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
9868 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9869 | count * sizeof(struct lcommunity))); | |
d62a17ae | 9870 | |
9871 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
9872 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
9873 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9874 | count * sizeof(struct cluster_list))); | |
9875 | ||
9876 | /* Peer related usage */ | |
9877 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
9878 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
9879 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9880 | count * sizeof(struct peer))); | |
9881 | ||
9882 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
9883 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
9884 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9885 | count * sizeof(struct peer_group))); | |
9886 | ||
9887 | /* Other */ | |
d62a17ae | 9888 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
9889 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
9890 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9891 | count * sizeof(regex_t))); | |
d62a17ae | 9892 | return CMD_SUCCESS; |
4bf6a362 | 9893 | } |
fee0f4c6 | 9894 | |
57a9c8a8 DS |
9895 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
9896 | { | |
9897 | json_object *bestpath = json_object_new_object(); | |
9898 | ||
892fedb6 | 9899 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
9900 | json_object_string_add(bestpath, "asPath", "ignore"); |
9901 | ||
892fedb6 | 9902 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
9903 | json_object_string_add(bestpath, "asPath", "confed"); |
9904 | ||
892fedb6 DA |
9905 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
9906 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 9907 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9908 | "as-set"); |
9909 | else | |
a4d82a8a | 9910 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9911 | "true"); |
9912 | } else | |
a4d82a8a | 9913 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 9914 | |
ee88563a JM |
9915 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
9916 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
9917 | ||
892fedb6 | 9918 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 9919 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
9920 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
9921 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
9922 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 9923 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 9924 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
9925 | json_object_string_add(bestpath, "med", |
9926 | "missing-as-worst"); | |
9927 | else | |
9928 | json_object_string_add(bestpath, "med", "true"); | |
9929 | } | |
9930 | ||
9931 | json_object_object_add(json, "bestPath", bestpath); | |
9932 | } | |
9933 | ||
3577f1c5 DD |
9934 | /* Print the error code/subcode for why the peer is down */ |
9935 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
9936 | json_object *json_peer, bool use_json) | |
9937 | { | |
9938 | const char *code_str; | |
9939 | const char *subcode_str; | |
9940 | ||
9941 | if (use_json) { | |
9942 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9943 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9944 | char errorcodesubcode_hexstr[5]; | |
9945 | char errorcodesubcode_str[256]; | |
9946 | ||
9947 | code_str = bgp_notify_code_str(peer->notify.code); | |
9948 | subcode_str = bgp_notify_subcode_str( | |
9949 | peer->notify.code, | |
9950 | peer->notify.subcode); | |
9951 | ||
772270f3 QY |
9952 | snprintf(errorcodesubcode_hexstr, |
9953 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
9954 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
9955 | json_object_string_add(json_peer, |
9956 | "lastErrorCodeSubcode", | |
9957 | errorcodesubcode_hexstr); | |
9958 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9959 | code_str, subcode_str); | |
9960 | json_object_string_add(json_peer, | |
9961 | "lastNotificationReason", | |
9962 | errorcodesubcode_str); | |
9963 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9964 | && peer->notify.code == BGP_NOTIFY_CEASE | |
9965 | && (peer->notify.subcode | |
9966 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9967 | || peer->notify.subcode | |
9968 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9969 | && peer->notify.length) { | |
9970 | char msgbuf[1024]; | |
9971 | const char *msg_str; | |
9972 | ||
9973 | msg_str = bgp_notify_admin_message( | |
9974 | msgbuf, sizeof(msgbuf), | |
9975 | (uint8_t *)peer->notify.data, | |
9976 | peer->notify.length); | |
9977 | if (msg_str) | |
9978 | json_object_string_add( | |
9979 | json_peer, | |
9980 | "lastShutdownDescription", | |
9981 | msg_str); | |
9982 | } | |
9983 | ||
c258527b | 9984 | } |
3577f1c5 DD |
9985 | json_object_string_add(json_peer, "lastResetDueTo", |
9986 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
9987 | json_object_int_add(json_peer, "lastResetCode", |
9988 | peer->last_reset); | |
3577f1c5 DD |
9989 | } else { |
9990 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9991 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9992 | code_str = bgp_notify_code_str(peer->notify.code); | |
9993 | subcode_str = | |
9994 | bgp_notify_subcode_str(peer->notify.code, | |
9995 | peer->notify.subcode); | |
9996 | vty_out(vty, " Notification %s (%s%s)\n", | |
9997 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9998 | ? "sent" | |
9999 | : "received", | |
10000 | code_str, subcode_str); | |
10001 | } else { | |
e91c24c8 | 10002 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10003 | peer_down_str[(int)peer->last_reset]); |
10004 | } | |
10005 | } | |
10006 | } | |
10007 | ||
10008 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10009 | safi_t safi) | |
10010 | { | |
feb17238 | 10011 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10012 | } |
10013 | ||
10014 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10015 | struct peer *peer, json_object *json_peer, | |
10016 | int max_neighbor_width, bool use_json) | |
10017 | { | |
10018 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10019 | int len; | |
10020 | ||
10021 | if (use_json) { | |
10022 | if (peer_dynamic_neighbor(peer)) | |
10023 | json_object_boolean_true_add(json_peer, | |
10024 | "dynamicPeer"); | |
10025 | if (peer->hostname) | |
10026 | json_object_string_add(json_peer, "hostname", | |
10027 | peer->hostname); | |
10028 | ||
10029 | if (peer->domainname) | |
10030 | json_object_string_add(json_peer, "domainname", | |
10031 | peer->domainname); | |
10032 | json_object_int_add(json_peer, "connectionsEstablished", | |
10033 | peer->established); | |
10034 | json_object_int_add(json_peer, "connectionsDropped", | |
10035 | peer->dropped); | |
10036 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10037 | use_json, json_peer); | |
feb17238 | 10038 | if (peer_established(peer)) |
3577f1c5 DD |
10039 | json_object_string_add(json_peer, "lastResetDueTo", |
10040 | "AFI/SAFI Not Negotiated"); | |
10041 | else | |
10042 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10043 | } else { | |
10044 | dn_flag[1] = '\0'; | |
10045 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10046 | if (peer->hostname | |
892fedb6 | 10047 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10048 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10049 | peer->hostname, peer->host); | |
10050 | else | |
10051 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10052 | ||
10053 | /* pad the neighbor column with spaces */ | |
10054 | if (len < max_neighbor_width) | |
10055 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10056 | " "); | |
e91c24c8 | 10057 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10058 | peer->dropped, |
10059 | peer_uptime(peer->uptime, timebuf, | |
10060 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10061 | if (peer_established(peer)) |
3577f1c5 DD |
10062 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10063 | else | |
10064 | bgp_show_peer_reset(vty, peer, NULL, | |
10065 | false); | |
10066 | } | |
10067 | } | |
c258527b | 10068 | |
565e9ddd | 10069 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10070 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10071 | { | |
10072 | static char stripped[BUFSIZ]; | |
cb75bb31 DA |
10073 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; |
10074 | ||
cb75bb31 DA |
10075 | strlcpy(stripped, desc, len + 1); |
10076 | ||
10077 | return stripped; | |
10078 | } | |
3577f1c5 | 10079 | |
8c1d4cd5 LS |
10080 | /* Determine whether var peer should be filtered out of the summary. */ |
10081 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10082 | struct peer *fpeer, int as_type, | |
10083 | as_t as) | |
10084 | { | |
10085 | ||
10086 | /* filter neighbor XXXX */ | |
10087 | if (fpeer && fpeer != peer) | |
10088 | return true; | |
10089 | ||
10090 | /* filter remote-as (internal|external) */ | |
10091 | if (as_type != AS_UNSPECIFIED) { | |
10092 | if (peer->as_type == AS_SPECIFIED) { | |
10093 | if (as_type == AS_INTERNAL) { | |
10094 | if (peer->as != peer->local_as) | |
10095 | return true; | |
10096 | } else if (peer->as == peer->local_as) | |
10097 | return true; | |
10098 | } else if (as_type != peer->as_type) | |
10099 | return true; | |
10100 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10101 | return true; | |
10102 | ||
10103 | return false; | |
10104 | } | |
10105 | ||
565e9ddd DA |
10106 | /* Show BGP peer's summary information. |
10107 | * | |
10108 | * Peer's description is stripped according to if `wide` option is given | |
10109 | * or not. | |
10110 | * | |
10111 | * When adding new columns to `show bgp summary` output, please make | |
10112 | * sure `Desc` is the lastest column to show because it can contain | |
10113 | * whitespaces and the whole output will be tricky. | |
10114 | */ | |
d62a17ae | 10115 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10116 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10117 | uint16_t show_flags) |
d62a17ae | 10118 | { |
10119 | struct peer *peer; | |
10120 | struct listnode *node, *nnode; | |
10121 | unsigned int count = 0, dn_count = 0; | |
10122 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10123 | char neighbor_buf[VTY_BUFSIZ]; | |
10124 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10125 | int len, failed_count = 0; |
ce1944f0 | 10126 | unsigned int filtered_count = 0; |
d62a17ae | 10127 | int max_neighbor_width = 0; |
10128 | int pfx_rcd_safi; | |
3c13337d | 10129 | json_object *json = NULL; |
d62a17ae | 10130 | json_object *json_peer = NULL; |
10131 | json_object *json_peers = NULL; | |
50e05855 | 10132 | struct peer_af *paf; |
d3ada366 | 10133 | struct bgp_filter *filter; |
85eeb029 DA |
10134 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10135 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10136 | bool show_established = | |
10137 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10138 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10139 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10140 | |
10141 | /* labeled-unicast routes are installed in the unicast table so in order | |
10142 | * to | |
10143 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10144 | */ | |
3577f1c5 | 10145 | |
d62a17ae | 10146 | if (safi == SAFI_LABELED_UNICAST) |
10147 | pfx_rcd_safi = SAFI_UNICAST; | |
10148 | else | |
10149 | pfx_rcd_safi = safi; | |
10150 | ||
10151 | if (use_json) { | |
3c13337d | 10152 | json = json_object_new_object(); |
d62a17ae | 10153 | json_peers = json_object_new_object(); |
3577f1c5 | 10154 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10155 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10156 | as_type, as)) { | |
ce1944f0 | 10157 | filtered_count++; |
8c1d4cd5 LS |
10158 | count++; |
10159 | continue; | |
10160 | } | |
10161 | ||
3577f1c5 DD |
10162 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10163 | continue; | |
10164 | ||
10165 | if (peer->afc[afi][safi]) { | |
10166 | /* See if we have at least a single failed peer */ | |
10167 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10168 | failed_count++; | |
10169 | count++; | |
10170 | } | |
10171 | if (peer_dynamic_neighbor(peer)) | |
10172 | dn_count++; | |
10173 | } | |
c258527b | 10174 | |
d62a17ae | 10175 | } else { |
10176 | /* Loop over all neighbors that will be displayed to determine | |
10177 | * how many | |
10178 | * characters are needed for the Neighbor column | |
10179 | */ | |
10180 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10181 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10182 | as_type, as)) { | |
ce1944f0 | 10183 | filtered_count++; |
8c1d4cd5 LS |
10184 | count++; |
10185 | continue; | |
10186 | } | |
10187 | ||
d62a17ae | 10188 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10189 | continue; | |
10190 | ||
10191 | if (peer->afc[afi][safi]) { | |
10192 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10193 | if (peer_dynamic_neighbor(peer)) | |
10194 | dn_flag[0] = '*'; | |
10195 | ||
10196 | if (peer->hostname | |
892fedb6 DA |
10197 | && CHECK_FLAG(bgp->flags, |
10198 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10199 | snprintf(neighbor_buf, |
10200 | sizeof(neighbor_buf), | |
10201 | "%s%s(%s) ", dn_flag, | |
10202 | peer->hostname, peer->host); | |
d62a17ae | 10203 | else |
772270f3 QY |
10204 | snprintf(neighbor_buf, |
10205 | sizeof(neighbor_buf), "%s%s ", | |
10206 | dn_flag, peer->host); | |
d62a17ae | 10207 | |
10208 | len = strlen(neighbor_buf); | |
10209 | ||
10210 | if (len > max_neighbor_width) | |
10211 | max_neighbor_width = len; | |
c258527b | 10212 | |
3577f1c5 DD |
10213 | /* See if we have at least a single failed peer */ |
10214 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10215 | failed_count++; | |
10216 | count++; | |
d62a17ae | 10217 | } |
10218 | } | |
f933309e | 10219 | |
d62a17ae | 10220 | /* Originally we displayed the Neighbor column as 16 |
10221 | * characters wide so make that the default | |
10222 | */ | |
10223 | if (max_neighbor_width < neighbor_col_default_width) | |
10224 | max_neighbor_width = neighbor_col_default_width; | |
10225 | } | |
f933309e | 10226 | |
3577f1c5 DD |
10227 | if (show_failed && !failed_count) { |
10228 | if (use_json) { | |
10229 | json_object_int_add(json, "failedPeersCount", 0); | |
10230 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10231 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
10232 | |
10233 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
10234 | json, JSON_C_TO_STRING_PRETTY)); | |
10235 | json_object_free(json); | |
10236 | } else { | |
10237 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
10238 | } |
10239 | return CMD_SUCCESS; | |
10240 | } | |
c258527b | 10241 | |
3577f1c5 | 10242 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 10243 | filtered_count = 0; |
d62a17ae | 10244 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10245 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10246 | continue; | |
10247 | ||
ea47320b DL |
10248 | if (!peer->afc[afi][safi]) |
10249 | continue; | |
d62a17ae | 10250 | |
ea47320b DL |
10251 | if (!count) { |
10252 | unsigned long ents; | |
10253 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10254 | int64_t vrf_id_ui; |
d62a17ae | 10255 | |
a4d82a8a PZ |
10256 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10257 | ? -1 | |
10258 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10259 | |
10260 | /* Usage summary and header */ | |
10261 | if (use_json) { | |
23d0a753 DA |
10262 | char buf[BUFSIZ] = {0}; |
10263 | ||
ea47320b DL |
10264 | json_object_string_add( |
10265 | json, "routerId", | |
23d0a753 DA |
10266 | inet_ntop(AF_INET, &bgp->router_id, buf, |
10267 | sizeof(buf))); | |
60466a63 QY |
10268 | json_object_int_add(json, "as", bgp->as); |
10269 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10270 | json_object_string_add( |
10271 | json, "vrfName", | |
10272 | (bgp->inst_type | |
10273 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10274 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10275 | : bgp->name); |
10276 | } else { | |
10277 | vty_out(vty, | |
23d0a753 DA |
10278 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10279 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10280 | bgp->vrf_id == VRF_UNKNOWN |
10281 | ? -1 | |
10282 | : (int)bgp->vrf_id); | |
ea47320b DL |
10283 | vty_out(vty, "\n"); |
10284 | } | |
d62a17ae | 10285 | |
ea47320b | 10286 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10287 | if (use_json) { |
ea47320b | 10288 | json_object_int_add( |
60466a63 | 10289 | json, "updateDelayLimit", |
ea47320b | 10290 | bgp->v_update_delay); |
d62a17ae | 10291 | |
ea47320b DL |
10292 | if (bgp->v_update_delay |
10293 | != bgp->v_establish_wait) | |
d62a17ae | 10294 | json_object_int_add( |
10295 | json, | |
ea47320b DL |
10296 | "updateDelayEstablishWait", |
10297 | bgp->v_establish_wait); | |
d62a17ae | 10298 | |
60466a63 | 10299 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10300 | json_object_string_add( |
10301 | json, | |
10302 | "updateDelayFirstNeighbor", | |
10303 | bgp->update_delay_begin_time); | |
10304 | json_object_boolean_true_add( | |
10305 | json, | |
10306 | "updateDelayInProgress"); | |
10307 | } else { | |
10308 | if (bgp->update_delay_over) { | |
d62a17ae | 10309 | json_object_string_add( |
10310 | json, | |
10311 | "updateDelayFirstNeighbor", | |
10312 | bgp->update_delay_begin_time); | |
ea47320b | 10313 | json_object_string_add( |
d62a17ae | 10314 | json, |
ea47320b DL |
10315 | "updateDelayBestpathResumed", |
10316 | bgp->update_delay_end_time); | |
10317 | json_object_string_add( | |
d62a17ae | 10318 | json, |
ea47320b DL |
10319 | "updateDelayZebraUpdateResume", |
10320 | bgp->update_delay_zebra_resume_time); | |
10321 | json_object_string_add( | |
10322 | json, | |
10323 | "updateDelayPeerUpdateResume", | |
10324 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10325 | } |
ea47320b DL |
10326 | } |
10327 | } else { | |
10328 | vty_out(vty, | |
10329 | "Read-only mode update-delay limit: %d seconds\n", | |
10330 | bgp->v_update_delay); | |
10331 | if (bgp->v_update_delay | |
10332 | != bgp->v_establish_wait) | |
d62a17ae | 10333 | vty_out(vty, |
ea47320b DL |
10334 | " Establish wait: %d seconds\n", |
10335 | bgp->v_establish_wait); | |
d62a17ae | 10336 | |
60466a63 | 10337 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10338 | vty_out(vty, |
10339 | " First neighbor established: %s\n", | |
10340 | bgp->update_delay_begin_time); | |
10341 | vty_out(vty, | |
10342 | " Delay in progress\n"); | |
10343 | } else { | |
10344 | if (bgp->update_delay_over) { | |
d62a17ae | 10345 | vty_out(vty, |
10346 | " First neighbor established: %s\n", | |
10347 | bgp->update_delay_begin_time); | |
10348 | vty_out(vty, | |
ea47320b DL |
10349 | " Best-paths resumed: %s\n", |
10350 | bgp->update_delay_end_time); | |
10351 | vty_out(vty, | |
10352 | " zebra update resumed: %s\n", | |
10353 | bgp->update_delay_zebra_resume_time); | |
10354 | vty_out(vty, | |
10355 | " peers update resumed: %s\n", | |
10356 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10357 | } |
10358 | } | |
10359 | } | |
ea47320b | 10360 | } |
d62a17ae | 10361 | |
ea47320b DL |
10362 | if (use_json) { |
10363 | if (bgp_maxmed_onstartup_configured(bgp) | |
10364 | && bgp->maxmed_active) | |
10365 | json_object_boolean_true_add( | |
60466a63 | 10366 | json, "maxMedOnStartup"); |
ea47320b DL |
10367 | if (bgp->v_maxmed_admin) |
10368 | json_object_boolean_true_add( | |
60466a63 | 10369 | json, "maxMedAdministrative"); |
d62a17ae | 10370 | |
ea47320b DL |
10371 | json_object_int_add( |
10372 | json, "tableVersion", | |
60466a63 | 10373 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10374 | |
60466a63 QY |
10375 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10376 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10377 | json_object_int_add( |
10378 | json, "ribMemory", | |
9bcb3eef | 10379 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10380 | |
210ec2a0 | 10381 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10382 | json_object_int_add(json, "peerCount", ents); |
10383 | json_object_int_add(json, "peerMemory", | |
10384 | ents * sizeof(struct peer)); | |
d62a17ae | 10385 | |
ea47320b DL |
10386 | if ((ents = listcount(bgp->group))) { |
10387 | json_object_int_add( | |
60466a63 | 10388 | json, "peerGroupCount", ents); |
ea47320b DL |
10389 | json_object_int_add( |
10390 | json, "peerGroupMemory", | |
996c9314 LB |
10391 | ents * sizeof(struct |
10392 | peer_group)); | |
ea47320b | 10393 | } |
d62a17ae | 10394 | |
ea47320b DL |
10395 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10396 | BGP_CONFIG_DAMPENING)) | |
10397 | json_object_boolean_true_add( | |
60466a63 | 10398 | json, "dampeningEnabled"); |
ea47320b | 10399 | } else { |
96c81f66 LS |
10400 | if (!show_terse) { |
10401 | if (bgp_maxmed_onstartup_configured(bgp) | |
10402 | && bgp->maxmed_active) | |
10403 | vty_out(vty, | |
10404 | "Max-med on-startup active\n"); | |
10405 | if (bgp->v_maxmed_admin) | |
10406 | vty_out(vty, | |
10407 | "Max-med administrative active\n"); | |
d62a17ae | 10408 | |
96c81f66 LS |
10409 | vty_out(vty, |
10410 | "BGP table version %" PRIu64 | |
10411 | "\n", | |
10412 | bgp_table_version( | |
10413 | bgp->rib[afi][safi])); | |
ea47320b | 10414 | |
96c81f66 LS |
10415 | ents = bgp_table_count( |
10416 | bgp->rib[afi][safi]); | |
d62a17ae | 10417 | vty_out(vty, |
96c81f66 | 10418 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 10419 | ents, |
10420 | mtype_memstr( | |
10421 | memstrbuf, | |
10422 | sizeof(memstrbuf), | |
96c81f66 LS |
10423 | ents |
10424 | * sizeof( | |
10425 | struct | |
10426 | bgp_dest))); | |
d62a17ae | 10427 | |
96c81f66 LS |
10428 | /* Peer related usage */ |
10429 | ents = bgp->af_peer_count[afi][safi]; | |
10430 | vty_out(vty, | |
10431 | "Peers %ld, using %s of memory\n", | |
10432 | ents, | |
10433 | mtype_memstr( | |
10434 | memstrbuf, | |
10435 | sizeof(memstrbuf), | |
10436 | ents | |
10437 | * sizeof( | |
10438 | struct | |
10439 | peer))); | |
d62a17ae | 10440 | |
96c81f66 LS |
10441 | if ((ents = listcount(bgp->group))) |
10442 | vty_out(vty, | |
10443 | "Peer groups %ld, using %s of memory\n", | |
10444 | ents, | |
10445 | mtype_memstr( | |
10446 | memstrbuf, | |
10447 | sizeof(memstrbuf), | |
10448 | ents | |
10449 | * sizeof( | |
10450 | struct | |
10451 | peer_group))); | |
10452 | ||
10453 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
10454 | BGP_CONFIG_DAMPENING)) | |
10455 | vty_out(vty, | |
10456 | "Dampening enabled.\n"); | |
10457 | } | |
10458 | if (show_failed) { | |
10459 | vty_out(vty, "\n"); | |
10460 | ||
10461 | /* Subtract 8 here because 'Neighbor' is | |
10462 | * 8 characters */ | |
10463 | vty_out(vty, "Neighbor"); | |
10464 | vty_out(vty, "%*s", | |
10465 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
10466 | vty_out(vty, |
10467 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 10468 | } |
d62a17ae | 10469 | } |
ea47320b | 10470 | } |
d62a17ae | 10471 | |
d55811cc | 10472 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10473 | filter = &peer->filter[afi][safi]; |
db92d226 | 10474 | |
ea47320b | 10475 | count++; |
3577f1c5 DD |
10476 | /* Works for both failed & successful cases */ |
10477 | if (peer_dynamic_neighbor(peer)) | |
10478 | dn_count++; | |
d62a17ae | 10479 | |
ea47320b | 10480 | if (use_json) { |
3577f1c5 | 10481 | json_peer = NULL; |
8c1d4cd5 | 10482 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10483 | as_type, as)) { |
10484 | filtered_count++; | |
8c1d4cd5 | 10485 | continue; |
ce1944f0 | 10486 | } |
3577f1c5 DD |
10487 | if (show_failed && |
10488 | bgp_has_peer_failed(peer, afi, safi)) { | |
10489 | json_peer = json_object_new_object(); | |
10490 | bgp_show_failed_summary(vty, bgp, peer, | |
10491 | json_peer, 0, use_json); | |
10492 | } else if (!show_failed) { | |
10b49f14 | 10493 | if (show_established |
ce1944f0 LS |
10494 | && bgp_has_peer_failed(peer, afi, safi)) { |
10495 | filtered_count++; | |
10b49f14 | 10496 | continue; |
ce1944f0 | 10497 | } |
10b49f14 | 10498 | |
3577f1c5 DD |
10499 | json_peer = json_object_new_object(); |
10500 | if (peer_dynamic_neighbor(peer)) { | |
10501 | json_object_boolean_true_add(json_peer, | |
10502 | "dynamicPeer"); | |
10503 | } | |
d62a17ae | 10504 | |
3577f1c5 DD |
10505 | if (peer->hostname) |
10506 | json_object_string_add(json_peer, "hostname", | |
10507 | peer->hostname); | |
10508 | ||
10509 | if (peer->domainname) | |
10510 | json_object_string_add(json_peer, "domainname", | |
10511 | peer->domainname); | |
10512 | ||
10513 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
10514 | json_object_int_add( |
10515 | json_peer, "localAs", | |
10516 | peer->change_local_as | |
10517 | ? peer->change_local_as | |
10518 | : peer->local_as); | |
3577f1c5 DD |
10519 | json_object_int_add(json_peer, "version", 4); |
10520 | json_object_int_add(json_peer, "msgRcvd", | |
10521 | PEER_TOTAL_RX(peer)); | |
10522 | json_object_int_add(json_peer, "msgSent", | |
10523 | PEER_TOTAL_TX(peer)); | |
10524 | ||
43aa5965 QY |
10525 | atomic_size_t outq_count, inq_count; |
10526 | outq_count = atomic_load_explicit( | |
10527 | &peer->obuf->count, | |
10528 | memory_order_relaxed); | |
10529 | inq_count = atomic_load_explicit( | |
10530 | &peer->ibuf->count, | |
10531 | memory_order_relaxed); | |
10532 | ||
3577f1c5 DD |
10533 | json_object_int_add(json_peer, "tableVersion", |
10534 | peer->version[afi][safi]); | |
10535 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
10536 | outq_count); |
10537 | json_object_int_add(json_peer, "inq", | |
10538 | inq_count); | |
3577f1c5 DD |
10539 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
10540 | use_json, json_peer); | |
10541 | ||
3577f1c5 DD |
10542 | json_object_int_add(json_peer, "pfxRcd", |
10543 | peer->pcount[afi][pfx_rcd_safi]); | |
10544 | ||
3577f1c5 | 10545 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
10546 | json_object_int_add( |
10547 | json_peer, "pfxSnt", | |
10548 | (PAF_SUBGRP(paf))->scount); | |
10549 | else | |
10550 | json_object_int_add(json_peer, "pfxSnt", | |
10551 | 0); | |
0e1f8ab5 DA |
10552 | |
10553 | /* BGP FSM state */ | |
cb9196e7 | 10554 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10555 | || CHECK_FLAG(peer->bgp->flags, |
10556 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
10557 | json_object_string_add(json_peer, |
10558 | "state", | |
3577f1c5 DD |
10559 | "Idle (Admin)"); |
10560 | else if (peer->afc_recv[afi][safi]) | |
10561 | json_object_string_add( | |
0e1f8ab5 DA |
10562 | json_peer, "state", |
10563 | lookup_msg(bgp_status_msg, | |
10564 | peer->status, NULL)); | |
10565 | else if (CHECK_FLAG( | |
10566 | peer->sflags, | |
10567 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10568 | json_object_string_add(json_peer, | |
10569 | "state", | |
3577f1c5 DD |
10570 | "Idle (PfxCt)"); |
10571 | else | |
10572 | json_object_string_add( | |
0e1f8ab5 DA |
10573 | json_peer, "state", |
10574 | lookup_msg(bgp_status_msg, | |
10575 | peer->status, NULL)); | |
10576 | ||
10577 | /* BGP peer state */ | |
10578 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10579 | || CHECK_FLAG(peer->bgp->flags, | |
10580 | BGP_FLAG_SHUTDOWN)) | |
10581 | json_object_string_add(json_peer, | |
10582 | "peerState", | |
10583 | "Admin"); | |
10584 | else if (CHECK_FLAG( | |
10585 | peer->sflags, | |
10586 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10587 | json_object_string_add(json_peer, | |
10588 | "peerState", | |
10589 | "PfxCt"); | |
10590 | else if (CHECK_FLAG(peer->flags, | |
10591 | PEER_FLAG_PASSIVE)) | |
10592 | json_object_string_add(json_peer, | |
10593 | "peerState", | |
10594 | "Passive"); | |
10595 | else if (CHECK_FLAG(peer->sflags, | |
10596 | PEER_STATUS_NSF_WAIT)) | |
10597 | json_object_string_add(json_peer, | |
10598 | "peerState", | |
10599 | "NSF passive"); | |
10600 | else if (CHECK_FLAG( | |
10601 | peer->bgp->flags, | |
10602 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10603 | && (!bgp_inbound_policy_exists(peer, | |
10604 | filter) | |
10605 | || !bgp_outbound_policy_exists( | |
10606 | peer, filter))) | |
10607 | json_object_string_add(json_peer, | |
10608 | "peerState", | |
10609 | "Policy"); | |
10610 | else | |
10611 | json_object_string_add( | |
10612 | json_peer, "peerState", "OK"); | |
10613 | ||
200116db DD |
10614 | json_object_int_add(json_peer, "connectionsEstablished", |
10615 | peer->established); | |
10616 | json_object_int_add(json_peer, "connectionsDropped", | |
10617 | peer->dropped); | |
aa72bd7e PG |
10618 | if (peer->desc) |
10619 | json_object_string_add( | |
10620 | json_peer, "desc", peer->desc); | |
b4e9dcba | 10621 | } |
3577f1c5 DD |
10622 | /* Avoid creating empty peer dicts in JSON */ |
10623 | if (json_peer == NULL) | |
10624 | continue; | |
ea47320b DL |
10625 | |
10626 | if (peer->conf_if) | |
60466a63 | 10627 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10628 | "interface"); |
10629 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10630 | json_object_string_add(json_peer, "idType", |
10631 | "ipv4"); | |
ea47320b | 10632 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10633 | json_object_string_add(json_peer, "idType", |
10634 | "ipv6"); | |
ea47320b DL |
10635 | json_object_object_add(json_peers, peer->host, |
10636 | json_peer); | |
10637 | } else { | |
8c1d4cd5 | 10638 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10639 | as_type, as)) { |
10640 | filtered_count++; | |
8c1d4cd5 | 10641 | continue; |
ce1944f0 | 10642 | } |
3577f1c5 DD |
10643 | if (show_failed && |
10644 | bgp_has_peer_failed(peer, afi, safi)) { | |
10645 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10646 | max_neighbor_width, | |
10647 | use_json); | |
10648 | } else if (!show_failed) { | |
10b49f14 | 10649 | if (show_established |
ce1944f0 LS |
10650 | && bgp_has_peer_failed(peer, afi, safi)) { |
10651 | filtered_count++; | |
10b49f14 | 10652 | continue; |
ce1944f0 | 10653 | } |
96c81f66 LS |
10654 | |
10655 | if ((count - filtered_count) == 1) { | |
10656 | /* display headline before the first | |
10657 | * neighbor line */ | |
10658 | vty_out(vty, "\n"); | |
10659 | ||
10660 | /* Subtract 8 here because 'Neighbor' is | |
10661 | * 8 characters */ | |
10662 | vty_out(vty, "Neighbor"); | |
10663 | vty_out(vty, "%*s", | |
10664 | max_neighbor_width - 8, " "); | |
10665 | vty_out(vty, | |
10666 | show_wide | |
10667 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
10668 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
10669 | } | |
10670 | ||
3577f1c5 DD |
10671 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10672 | if (peer_dynamic_neighbor(peer)) { | |
10673 | dn_flag[0] = '*'; | |
10674 | } | |
d62a17ae | 10675 | |
3577f1c5 | 10676 | if (peer->hostname |
892fedb6 DA |
10677 | && CHECK_FLAG(bgp->flags, |
10678 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10679 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10680 | peer->hostname, |
10681 | peer->host); | |
d62a17ae | 10682 | else |
3577f1c5 DD |
10683 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10684 | ||
10685 | /* pad the neighbor column with spaces */ | |
10686 | if (len < max_neighbor_width) | |
10687 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10688 | " "); | |
10689 | ||
43aa5965 QY |
10690 | atomic_size_t outq_count, inq_count; |
10691 | outq_count = atomic_load_explicit( | |
10692 | &peer->obuf->count, | |
10693 | memory_order_relaxed); | |
10694 | inq_count = atomic_load_explicit( | |
10695 | &peer->ibuf->count, | |
10696 | memory_order_relaxed); | |
10697 | ||
85eeb029 DA |
10698 | if (show_wide) |
10699 | vty_out(vty, | |
10700 | "4 %10u %10u %9u %9u %8" PRIu64 | |
10701 | " %4zu %4zu %8s", | |
10702 | peer->as, | |
10703 | peer->change_local_as | |
10704 | ? peer->change_local_as | |
10705 | : peer->local_as, | |
10706 | PEER_TOTAL_RX(peer), | |
10707 | PEER_TOTAL_TX(peer), | |
10708 | peer->version[afi][safi], | |
10709 | inq_count, outq_count, | |
10710 | peer_uptime(peer->uptime, | |
10711 | timebuf, | |
10712 | BGP_UPTIME_LEN, 0, | |
10713 | NULL)); | |
10714 | else | |
10715 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
10716 | " %4zu %4zu %8s", | |
10717 | peer->as, PEER_TOTAL_RX(peer), | |
10718 | PEER_TOTAL_TX(peer), | |
10719 | peer->version[afi][safi], | |
10720 | inq_count, outq_count, | |
10721 | peer_uptime(peer->uptime, | |
10722 | timebuf, | |
10723 | BGP_UPTIME_LEN, 0, | |
10724 | NULL)); | |
3577f1c5 | 10725 | |
feb17238 | 10726 | if (peer_established(peer)) { |
d3ada366 DA |
10727 | if (peer->afc_recv[afi][safi]) { |
10728 | if (CHECK_FLAG( | |
10729 | bgp->flags, | |
10730 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10731 | && !bgp_inbound_policy_exists( | |
10732 | peer, filter)) | |
10733 | vty_out(vty, " %12s", | |
10734 | "(Policy)"); | |
10735 | else | |
10736 | vty_out(vty, | |
6cde4b45 | 10737 | " %12u", |
d3ada366 DA |
10738 | peer->pcount |
10739 | [afi] | |
10740 | [pfx_rcd_safi]); | |
10741 | } else { | |
749d0f27 | 10742 | vty_out(vty, " NoNeg"); |
d3ada366 | 10743 | } |
db92d226 | 10744 | |
d3ada366 DA |
10745 | if (paf && PAF_SUBGRP(paf)) { |
10746 | if (CHECK_FLAG( | |
10747 | bgp->flags, | |
10748 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10749 | && !bgp_outbound_policy_exists( | |
10750 | peer, filter)) | |
10751 | vty_out(vty, " %8s", | |
10752 | "(Policy)"); | |
10753 | else | |
10754 | vty_out(vty, | |
6cde4b45 | 10755 | " %8u", |
d3ada366 DA |
10756 | (PAF_SUBGRP( |
10757 | paf)) | |
10758 | ->scount); | |
749d0f27 DA |
10759 | } else { |
10760 | vty_out(vty, " NoNeg"); | |
d3ada366 | 10761 | } |
db92d226 | 10762 | } else { |
736b68f3 DS |
10763 | if (CHECK_FLAG(peer->flags, |
10764 | PEER_FLAG_SHUTDOWN) | |
10765 | || CHECK_FLAG(peer->bgp->flags, | |
10766 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10767 | vty_out(vty, " Idle (Admin)"); |
10768 | else if (CHECK_FLAG( | |
10769 | peer->sflags, | |
10770 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10771 | vty_out(vty, " Idle (PfxCt)"); | |
10772 | else | |
10773 | vty_out(vty, " %12s", | |
10774 | lookup_msg(bgp_status_msg, | |
10775 | peer->status, NULL)); | |
db92d226 | 10776 | |
6cde4b45 | 10777 | vty_out(vty, " %8u", 0); |
3577f1c5 | 10778 | } |
565e9ddd DA |
10779 | /* Make sure `Desc` column is the lastest in |
10780 | * the output. | |
10781 | */ | |
aa72bd7e | 10782 | if (peer->desc) |
cb75bb31 DA |
10783 | vty_out(vty, " %s", |
10784 | bgp_peer_description_stripped( | |
85eeb029 DA |
10785 | peer->desc, |
10786 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
10787 | else |
10788 | vty_out(vty, " N/A"); | |
3577f1c5 | 10789 | vty_out(vty, "\n"); |
d62a17ae | 10790 | } |
3577f1c5 | 10791 | |
d62a17ae | 10792 | } |
10793 | } | |
f933309e | 10794 | |
d62a17ae | 10795 | if (use_json) { |
10796 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 10797 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
10798 | json_object_int_add(json, "displayedPeers", |
10799 | count - filtered_count); | |
d62a17ae | 10800 | json_object_int_add(json, "totalPeers", count); |
10801 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10802 | ||
3577f1c5 DD |
10803 | if (!show_failed) |
10804 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 10805 | |
996c9314 LB |
10806 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10807 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10808 | json_object_free(json); |
10809 | } else { | |
ce1944f0 | 10810 | if (count) { |
96c81f66 LS |
10811 | if (filtered_count == count) |
10812 | vty_out(vty, "\n%% No matching neighbor\n"); | |
10813 | else { | |
10814 | if (show_failed) | |
10815 | vty_out(vty, "\nDisplayed neighbors %d", | |
10816 | failed_count); | |
10817 | else if (as_type != AS_UNSPECIFIED || as | |
10818 | || fpeer || show_established) | |
ce1944f0 LS |
10819 | vty_out(vty, "\nDisplayed neighbors %d", |
10820 | count - filtered_count); | |
96c81f66 LS |
10821 | |
10822 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
10823 | count); | |
ce1944f0 | 10824 | } |
ce1944f0 | 10825 | } else { |
d6ceaca3 | 10826 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 10827 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10828 | } |
b05a1c8b | 10829 | |
d6ceaca3 | 10830 | if (dn_count) { |
d62a17ae | 10831 | vty_out(vty, "* - dynamic neighbor\n"); |
10832 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10833 | dn_count, bgp->dynamic_neighbors_limit); | |
10834 | } | |
10835 | } | |
1ff9a340 | 10836 | |
d62a17ae | 10837 | return CMD_SUCCESS; |
718e3744 | 10838 | } |
10839 | ||
d62a17ae | 10840 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 10841 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 10842 | as_t as, uint16_t show_flags) |
d62a17ae | 10843 | { |
10844 | int is_first = 1; | |
10845 | int afi_wildcard = (afi == AFI_MAX); | |
10846 | int safi_wildcard = (safi == SAFI_MAX); | |
10847 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 10848 | bool nbr_output = false; |
85eeb029 | 10849 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10850 | |
10851 | if (use_json && is_wildcard) | |
10852 | vty_out(vty, "{\n"); | |
10853 | if (afi_wildcard) | |
10854 | afi = 1; /* AFI_IP */ | |
10855 | while (afi < AFI_MAX) { | |
10856 | if (safi_wildcard) | |
10857 | safi = 1; /* SAFI_UNICAST */ | |
10858 | while (safi < SAFI_MAX) { | |
318cac96 | 10859 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 10860 | nbr_output = true; |
f86897b9 | 10861 | |
d62a17ae | 10862 | if (is_wildcard) { |
10863 | /* | |
10864 | * So limit output to those afi/safi | |
10865 | * pairs that | |
10866 | * actualy have something interesting in | |
10867 | * them | |
10868 | */ | |
10869 | if (use_json) { | |
d62a17ae | 10870 | if (!is_first) |
10871 | vty_out(vty, ",\n"); | |
10872 | else | |
10873 | is_first = 0; | |
10874 | ||
10875 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
10876 | get_afi_safi_str(afi, |
10877 | safi, | |
10878 | true)); | |
d62a17ae | 10879 | } else { |
6cac2fcc LS |
10880 | vty_out(vty, |
10881 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
10882 | get_afi_safi_str(afi, |
10883 | safi, | |
6cac2fcc LS |
10884 | false), |
10885 | bgp->name_pretty); | |
d62a17ae | 10886 | } |
10887 | } | |
8c1d4cd5 LS |
10888 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
10889 | as_type, as, show_flags); | |
d62a17ae | 10890 | } |
10891 | safi++; | |
d62a17ae | 10892 | if (!safi_wildcard) |
10893 | safi = SAFI_MAX; | |
10894 | } | |
10895 | afi++; | |
ee851c8c | 10896 | if (!afi_wildcard) |
d62a17ae | 10897 | afi = AFI_MAX; |
10898 | } | |
10899 | ||
10900 | if (use_json && is_wildcard) | |
10901 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
10902 | else if (!nbr_output) { |
10903 | if (use_json) | |
10904 | vty_out(vty, "{}\n"); | |
10905 | else | |
6cac2fcc LS |
10906 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
10907 | bgp->name_pretty); | |
ca61fd25 | 10908 | } |
d62a17ae | 10909 | } |
10910 | ||
10911 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
10912 | safi_t safi, |
10913 | const char *neighbor, | |
10914 | int as_type, as_t as, | |
96c81f66 | 10915 | uint16_t show_flags) |
d62a17ae | 10916 | { |
10917 | struct listnode *node, *nnode; | |
10918 | struct bgp *bgp; | |
8c1d4cd5 | 10919 | struct peer *fpeer = NULL; |
d62a17ae | 10920 | int is_first = 1; |
9f049418 | 10921 | bool nbr_output = false; |
85eeb029 | 10922 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10923 | |
10924 | if (use_json) | |
10925 | vty_out(vty, "{\n"); | |
10926 | ||
10927 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10928 | nbr_output = true; |
d62a17ae | 10929 | if (use_json) { |
d62a17ae | 10930 | if (!is_first) |
10931 | vty_out(vty, ",\n"); | |
10932 | else | |
10933 | is_first = 0; | |
10934 | ||
10935 | vty_out(vty, "\"%s\":", | |
10936 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10937 | ? VRF_DEFAULT_NAME |
d62a17ae | 10938 | : bgp->name); |
d62a17ae | 10939 | } |
8c1d4cd5 LS |
10940 | if (neighbor) { |
10941 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10942 | use_json); | |
10943 | if (!fpeer) | |
10944 | continue; | |
10945 | } | |
10946 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
10947 | as, show_flags); | |
d62a17ae | 10948 | } |
10949 | ||
10950 | if (use_json) | |
10951 | vty_out(vty, "}\n"); | |
9f049418 DS |
10952 | else if (!nbr_output) |
10953 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 10954 | } |
10955 | ||
10956 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 10957 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 10958 | as_t as, uint16_t show_flags) |
d62a17ae | 10959 | { |
10960 | struct bgp *bgp; | |
85eeb029 | 10961 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 10962 | struct peer *fpeer = NULL; |
d62a17ae | 10963 | |
10964 | if (name) { | |
10965 | if (strmatch(name, "all")) { | |
85eeb029 | 10966 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
10967 | neighbor, as_type, |
10968 | as, show_flags); | |
d62a17ae | 10969 | return CMD_SUCCESS; |
10970 | } else { | |
10971 | bgp = bgp_lookup_by_name(name); | |
10972 | ||
10973 | if (!bgp) { | |
10974 | if (use_json) | |
10975 | vty_out(vty, "{}\n"); | |
10976 | else | |
10977 | vty_out(vty, | |
ca61fd25 | 10978 | "%% BGP instance not found\n"); |
d62a17ae | 10979 | return CMD_WARNING; |
10980 | } | |
10981 | ||
8c1d4cd5 LS |
10982 | if (neighbor) { |
10983 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10984 | use_json); | |
10985 | if (!fpeer) | |
10986 | return CMD_WARNING; | |
10987 | } | |
10988 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
10989 | as_type, as, show_flags); | |
d62a17ae | 10990 | return CMD_SUCCESS; |
10991 | } | |
10992 | } | |
10993 | ||
10994 | bgp = bgp_get_default(); | |
10995 | ||
8c1d4cd5 LS |
10996 | if (bgp) { |
10997 | if (neighbor) { | |
10998 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10999 | use_json); | |
11000 | if (!fpeer) | |
11001 | return CMD_WARNING; | |
11002 | } | |
11003 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11004 | as, show_flags); | |
11005 | } else { | |
ca61fd25 DS |
11006 | if (use_json) |
11007 | vty_out(vty, "{}\n"); | |
11008 | else | |
11009 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11010 | return CMD_WARNING; |
11011 | } | |
d62a17ae | 11012 | |
11013 | return CMD_SUCCESS; | |
4fb25c53 DW |
11014 | } |
11015 | ||
716b2d8a | 11016 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11017 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11018 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11019 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11020 | "]] [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 |
11021 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11022 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11023 | "Display the entries for all address families\n" | |
11024 | "Summary of BGP neighbor status\n" | |
11025 | "Show only sessions in Established state\n" | |
11026 | "Show only sessions not in Established state\n" | |
11027 | "Show only the specified neighbor session\n" | |
11028 | "Neighbor to display information about\n" | |
11029 | "Neighbor to display information about\n" | |
11030 | "Neighbor on BGP configured interface\n" | |
11031 | "Show only the specified remote AS sessions\n" | |
11032 | "AS number\n" | |
11033 | "Internal (iBGP) AS sessions\n" | |
11034 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11035 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11036 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11037 | { |
d62a17ae | 11038 | char *vrf = NULL; |
11039 | afi_t afi = AFI_MAX; | |
11040 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11041 | as_t as = 0; /* 0 means AS filter not set */ |
11042 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11043 | uint16_t show_flags = 0; |
d62a17ae | 11044 | |
11045 | int idx = 0; | |
11046 | ||
11047 | /* show [ip] bgp */ | |
96f3485c | 11048 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11049 | afi = AFI_IP; |
9a8bdf1c PG |
11050 | /* [<vrf> VIEWVRFNAME] */ |
11051 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11052 | vrf = argv[idx + 1]->arg; | |
11053 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11054 | vrf = NULL; | |
11055 | } else if (argv_find(argv, argc, "view", &idx)) | |
11056 | /* [<view> VIEWVRFNAME] */ | |
11057 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11058 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11059 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11060 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11061 | } | |
11062 | ||
3577f1c5 | 11063 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11064 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11065 | ||
10b49f14 | 11066 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11067 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11068 | ||
8c1d4cd5 LS |
11069 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11070 | if (argv[idx + 1]->arg[0] == 'i') | |
11071 | as_type = AS_INTERNAL; | |
11072 | else if (argv[idx + 1]->arg[0] == 'e') | |
11073 | as_type = AS_EXTERNAL; | |
11074 | else | |
11075 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11076 | } | |
11077 | ||
96c81f66 LS |
11078 | if (argv_find(argv, argc, "terse", &idx)) |
11079 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11080 | ||
85eeb029 DA |
11081 | if (argv_find(argv, argc, "wide", &idx)) |
11082 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11083 | ||
11084 | if (argv_find(argv, argc, "json", &idx)) | |
11085 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11086 | |
8c1d4cd5 LS |
11087 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11088 | show_flags); | |
d62a17ae | 11089 | } |
11090 | ||
5cb5f4d0 | 11091 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11092 | { |
5cb5f4d0 DD |
11093 | if (for_json) |
11094 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11095 | else |
5cb5f4d0 | 11096 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11097 | } |
11098 | ||
d62a17ae | 11099 | |
11100 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11101 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11102 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11103 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11104 | bool use_json, json_object *json_pref) |
d62a17ae | 11105 | { |
11106 | /* Send-Mode */ | |
11107 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11108 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11109 | if (use_json) { | |
11110 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11111 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11112 | json_object_string_add(json_pref, "sendMode", | |
11113 | "advertisedAndReceived"); | |
11114 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11115 | json_object_string_add(json_pref, "sendMode", | |
11116 | "advertised"); | |
11117 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11118 | json_object_string_add(json_pref, "sendMode", | |
11119 | "received"); | |
11120 | } else { | |
11121 | vty_out(vty, " Send-mode: "); | |
11122 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11123 | vty_out(vty, "advertised"); | |
11124 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11125 | vty_out(vty, "%sreceived", | |
11126 | CHECK_FLAG(p->af_cap[afi][safi], | |
11127 | adv_smcap) | |
11128 | ? ", " | |
11129 | : ""); | |
11130 | vty_out(vty, "\n"); | |
11131 | } | |
11132 | } | |
11133 | ||
11134 | /* Receive-Mode */ | |
11135 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11136 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11137 | if (use_json) { | |
11138 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11139 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11140 | json_object_string_add(json_pref, "recvMode", | |
11141 | "advertisedAndReceived"); | |
11142 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11143 | json_object_string_add(json_pref, "recvMode", | |
11144 | "advertised"); | |
11145 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11146 | json_object_string_add(json_pref, "recvMode", | |
11147 | "received"); | |
11148 | } else { | |
11149 | vty_out(vty, " Receive-mode: "); | |
11150 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11151 | vty_out(vty, "advertised"); | |
11152 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11153 | vty_out(vty, "%sreceived", | |
11154 | CHECK_FLAG(p->af_cap[afi][safi], | |
11155 | adv_rmcap) | |
11156 | ? ", " | |
11157 | : ""); | |
11158 | vty_out(vty, "\n"); | |
11159 | } | |
11160 | } | |
11161 | } | |
11162 | ||
13909c4f DS |
11163 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11164 | struct peer *p, | |
11165 | bool use_json, | |
11166 | json_object *json) | |
2986cac2 | 11167 | { |
08c2d52a | 11168 | bool rbit_status = false; |
2986cac2 | 11169 | |
11170 | if (!use_json) | |
a53ca37b | 11171 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11172 | |
13909c4f DS |
11173 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11174 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11175 | && (peer_established(p))) { |
2986cac2 | 11176 | |
11177 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11178 | rbit_status = true; |
2986cac2 | 11179 | else |
08c2d52a | 11180 | rbit_status = false; |
2986cac2 | 11181 | } |
11182 | ||
11183 | if (rbit_status) { | |
11184 | if (use_json) | |
13909c4f | 11185 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11186 | else |
11187 | vty_out(vty, "True\n"); | |
11188 | } else { | |
11189 | if (use_json) | |
13909c4f | 11190 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11191 | else |
11192 | vty_out(vty, "False\n"); | |
11193 | } | |
11194 | } | |
11195 | ||
13909c4f DS |
11196 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11197 | struct peer *peer, | |
11198 | bool use_json, | |
11199 | json_object *json) | |
2986cac2 | 11200 | { |
2bb5d39b | 11201 | const char *mode = "NotApplicable"; |
2986cac2 | 11202 | |
11203 | if (!use_json) | |
a53ca37b | 11204 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11205 | |
13909c4f | 11206 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11207 | && (peer_established(peer))) { |
2986cac2 | 11208 | |
13909c4f DS |
11209 | if ((peer->nsf_af_count == 0) |
11210 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11211 | |
2986cac2 | 11212 | mode = "Disable"; |
11213 | ||
13909c4f DS |
11214 | } else if (peer->nsf_af_count == 0 |
11215 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11216 | |
2986cac2 | 11217 | mode = "Helper"; |
11218 | ||
13909c4f DS |
11219 | } else if (peer->nsf_af_count != 0 |
11220 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11221 | |
2986cac2 | 11222 | mode = "Restart"; |
2986cac2 | 11223 | } |
11224 | } | |
11225 | ||
11226 | if (use_json) { | |
13909c4f | 11227 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11228 | } else |
11229 | vty_out(vty, mode, "\n"); | |
11230 | } | |
11231 | ||
13909c4f DS |
11232 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11233 | struct peer *p, | |
11234 | bool use_json, | |
11235 | json_object *json) | |
2986cac2 | 11236 | { |
11237 | const char *mode = "Invalid"; | |
11238 | ||
11239 | if (!use_json) | |
a53ca37b | 11240 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11241 | |
11242 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11243 | mode = "Helper"; | |
11244 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11245 | mode = "Restart"; | |
11246 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11247 | mode = "Disable"; | |
2ba1fe69 | 11248 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11249 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11250 | mode = "Helper*"; | |
11251 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11252 | mode = "Restart*"; | |
11253 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11254 | mode = "Disable*"; | |
11255 | else | |
11256 | mode = "Invalid*"; | |
2ba1fe69 | 11257 | } |
2986cac2 | 11258 | |
11259 | if (use_json) { | |
13909c4f | 11260 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11261 | } else { |
11262 | vty_out(vty, mode, "\n"); | |
11263 | } | |
11264 | } | |
11265 | ||
13909c4f DS |
11266 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11267 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11268 | { |
2ba1fe69 | 11269 | afi_t afi; |
11270 | safi_t safi; | |
2986cac2 | 11271 | json_object *json_afi_safi = NULL; |
11272 | json_object *json_timer = NULL; | |
11273 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11274 | bool eor_flag = false; |
2986cac2 | 11275 | |
11276 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11277 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
11278 | if (!peer->afc[afi][safi]) |
11279 | continue; | |
2986cac2 | 11280 | |
13909c4f DS |
11281 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11282 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11283 | continue; | |
9e3b51a7 | 11284 | |
13909c4f DS |
11285 | if (use_json) { |
11286 | json_afi_safi = json_object_new_object(); | |
11287 | json_endofrib_status = json_object_new_object(); | |
11288 | json_timer = json_object_new_object(); | |
11289 | } | |
2986cac2 | 11290 | |
13909c4f DS |
11291 | if (peer->eor_stime[afi][safi] |
11292 | >= peer->pkt_stime[afi][safi]) | |
11293 | eor_flag = true; | |
11294 | else | |
11295 | eor_flag = false; | |
2986cac2 | 11296 | |
13909c4f | 11297 | if (!use_json) { |
a53ca37b | 11298 | vty_out(vty, " %s:\n", |
13909c4f | 11299 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 11300 | |
a53ca37b | 11301 | vty_out(vty, " F bit: "); |
698ba8d0 | 11302 | } |
2986cac2 | 11303 | |
13909c4f DS |
11304 | if (peer->nsf[afi][safi] |
11305 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
11306 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11307 | |
13909c4f DS |
11308 | if (use_json) { |
11309 | json_object_boolean_true_add( | |
2986cac2 | 11310 | json_afi_safi, "fBit"); |
13909c4f DS |
11311 | } else |
11312 | vty_out(vty, "True\n"); | |
11313 | } else { | |
11314 | if (use_json) | |
11315 | json_object_boolean_false_add( | |
11316 | json_afi_safi, "fBit"); | |
11317 | else | |
11318 | vty_out(vty, "False\n"); | |
11319 | } | |
2986cac2 | 11320 | |
13909c4f | 11321 | if (!use_json) |
a53ca37b | 11322 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 11323 | |
13909c4f DS |
11324 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11325 | PEER_STATUS_EOR_SEND)) { | |
11326 | if (use_json) { | |
11327 | json_object_boolean_true_add( | |
2986cac2 | 11328 | json_endofrib_status, |
13909c4f | 11329 | "endOfRibSend"); |
9e3b51a7 | 11330 | |
13909c4f DS |
11331 | PRINT_EOR_JSON(eor_flag); |
11332 | } else { | |
11333 | vty_out(vty, "Yes\n"); | |
11334 | vty_out(vty, | |
a53ca37b | 11335 | " End-of-RIB sent after update: "); |
2986cac2 | 11336 | |
13909c4f DS |
11337 | PRINT_EOR(eor_flag); |
11338 | } | |
11339 | } else { | |
11340 | if (use_json) { | |
11341 | json_object_boolean_false_add( | |
2986cac2 | 11342 | json_endofrib_status, |
13909c4f DS |
11343 | "endOfRibSend"); |
11344 | json_object_boolean_false_add( | |
9e3b51a7 | 11345 | json_endofrib_status, |
13909c4f DS |
11346 | "endOfRibSentAfterUpdate"); |
11347 | } else { | |
11348 | vty_out(vty, "No\n"); | |
11349 | vty_out(vty, | |
a53ca37b | 11350 | " End-of-RIB sent after update: "); |
13909c4f | 11351 | vty_out(vty, "No\n"); |
2986cac2 | 11352 | } |
13909c4f | 11353 | } |
2986cac2 | 11354 | |
a53ca37b DA |
11355 | if (!use_json) |
11356 | vty_out(vty, " End-of-RIB received: "); | |
11357 | ||
11358 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11359 | PEER_STATUS_EOR_RECEIVED)) { | |
11360 | if (use_json) | |
11361 | json_object_boolean_true_add( | |
11362 | json_endofrib_status, | |
11363 | "endOfRibRecv"); | |
11364 | else | |
11365 | vty_out(vty, "Yes\n"); | |
11366 | } else { | |
11367 | if (use_json) | |
11368 | json_object_boolean_false_add( | |
11369 | json_endofrib_status, | |
11370 | "endOfRibRecv"); | |
11371 | else | |
11372 | vty_out(vty, "No\n"); | |
11373 | } | |
11374 | ||
13909c4f DS |
11375 | if (use_json) { |
11376 | json_object_int_add(json_timer, | |
11377 | "stalePathTimer", | |
11378 | peer->bgp->stalepath_time); | |
2986cac2 | 11379 | |
13909c4f DS |
11380 | if (peer->t_gr_stale != NULL) { |
11381 | json_object_int_add( | |
2986cac2 | 11382 | json_timer, |
11383 | "stalePathTimerRemaining", | |
11384 | thread_timer_remain_second( | |
13909c4f DS |
11385 | peer->t_gr_stale)); |
11386 | } | |
3a75afa4 | 11387 | |
13909c4f DS |
11388 | /* Display Configured Selection |
11389 | * Deferral only when when | |
11390 | * Gr mode is enabled. | |
11391 | */ | |
11392 | if (CHECK_FLAG(peer->flags, | |
11393 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11394 | json_object_int_add( | |
3a75afa4 | 11395 | json_timer, |
2986cac2 | 11396 | "selectionDeferralTimer", |
11397 | peer->bgp->stalepath_time); | |
13909c4f | 11398 | } |
2986cac2 | 11399 | |
13909c4f DS |
11400 | if (peer->bgp->gr_info[afi][safi] |
11401 | .t_select_deferral | |
11402 | != NULL) { | |
2986cac2 | 11403 | |
13909c4f | 11404 | json_object_int_add( |
2986cac2 | 11405 | json_timer, |
11406 | "selectionDeferralTimerRemaining", | |
11407 | thread_timer_remain_second( | |
13909c4f DS |
11408 | peer->bgp |
11409 | ->gr_info[afi] | |
11410 | [safi] | |
11411 | .t_select_deferral)); | |
11412 | } | |
11413 | } else { | |
a53ca37b | 11414 | vty_out(vty, " Timers:\n"); |
13909c4f | 11415 | vty_out(vty, |
a53ca37b DA |
11416 | " Configured Stale Path Time(sec): %u\n", |
11417 | peer->bgp->stalepath_time); | |
2986cac2 | 11418 | |
a53ca37b | 11419 | if (peer->t_gr_stale != NULL) |
2986cac2 | 11420 | vty_out(vty, |
a53ca37b | 11421 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 11422 | thread_timer_remain_second( |
13909c4f | 11423 | peer->t_gr_stale)); |
13909c4f DS |
11424 | /* Display Configured Selection |
11425 | * Deferral only when when | |
11426 | * Gr mode is enabled. | |
11427 | */ | |
11428 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 11429 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 11430 | vty_out(vty, |
a53ca37b | 11431 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 11432 | peer->bgp->select_defer_time); |
2986cac2 | 11433 | |
13909c4f DS |
11434 | if (peer->bgp->gr_info[afi][safi] |
11435 | .t_select_deferral | |
a53ca37b | 11436 | != NULL) |
13909c4f | 11437 | vty_out(vty, |
a53ca37b | 11438 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 11439 | thread_timer_remain_second( |
13909c4f DS |
11440 | peer->bgp |
11441 | ->gr_info[afi] | |
11442 | [safi] | |
11443 | .t_select_deferral)); | |
2986cac2 | 11444 | } |
13909c4f DS |
11445 | if (use_json) { |
11446 | json_object_object_add(json_afi_safi, | |
11447 | "endOfRibStatus", | |
11448 | json_endofrib_status); | |
11449 | json_object_object_add(json_afi_safi, "timers", | |
11450 | json_timer); | |
11451 | json_object_object_add( | |
11452 | json, get_afi_safi_str(afi, safi, true), | |
11453 | json_afi_safi); | |
11454 | } | |
2986cac2 | 11455 | } |
11456 | } | |
11457 | } | |
11458 | ||
36235319 QY |
11459 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11460 | struct peer *p, | |
11461 | bool use_json, | |
11462 | json_object *json) | |
2986cac2 | 11463 | { |
11464 | if (use_json) { | |
11465 | json_object *json_timer = NULL; | |
11466 | ||
11467 | json_timer = json_object_new_object(); | |
11468 | ||
13909c4f DS |
11469 | json_object_int_add(json_timer, "configuredRestartTimer", |
11470 | p->bgp->restart_time); | |
2986cac2 | 11471 | |
13909c4f DS |
11472 | json_object_int_add(json_timer, "receivedRestartTimer", |
11473 | p->v_gr_restart); | |
2986cac2 | 11474 | |
13909c4f DS |
11475 | if (p->t_gr_restart != NULL) |
11476 | json_object_int_add( | |
11477 | json_timer, "restartTimerRemaining", | |
11478 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11479 | |
11480 | json_object_object_add(json, "timers", json_timer); | |
11481 | } else { | |
11482 | ||
a53ca37b DA |
11483 | vty_out(vty, " Timers:\n"); |
11484 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11485 | p->bgp->restart_time); |
2986cac2 | 11486 | |
a53ca37b | 11487 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11488 | p->v_gr_restart); |
11489 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11490 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11491 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11492 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11493 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11494 | thread_timer_remain_second(p->t_gr_restart)); |
11495 | } | |
2986cac2 | 11496 | } |
11497 | } | |
11498 | ||
11499 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11500 | bool use_json, json_object *json) |
2986cac2 | 11501 | { |
11502 | char buf[SU_ADDRSTRLEN] = {0}; | |
11503 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11504 | /* '*' + v6 address of neighbor */ |
11505 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11506 | |
2986cac2 | 11507 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11508 | dn_flag[0] = '*'; | |
11509 | ||
11510 | if (p->conf_if) { | |
11511 | if (use_json) | |
13909c4f DS |
11512 | json_object_string_add( |
11513 | json, "neighborAddr", | |
2986cac2 | 11514 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11515 | ? "none" |
11516 | : sockunion2str(&p->su, buf, | |
11517 | SU_ADDRSTRLEN)); | |
2986cac2 | 11518 | else |
13909c4f | 11519 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11520 | BGP_PEER_SU_UNSPEC(p) |
11521 | ? "none" | |
11522 | : sockunion2str(&p->su, buf, | |
11523 | SU_ADDRSTRLEN)); | |
11524 | } else { | |
772270f3 QY |
11525 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11526 | p->host); | |
2986cac2 | 11527 | |
11528 | if (use_json) | |
36235319 QY |
11529 | json_object_string_add(json, "neighborAddr", |
11530 | neighborAddr); | |
2986cac2 | 11531 | else |
36235319 | 11532 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11533 | } |
11534 | ||
11535 | /* more gr info in new format */ | |
11536 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11537 | } | |
11538 | ||
d62a17ae | 11539 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11540 | safi_t safi, bool use_json, |
d62a17ae | 11541 | json_object *json_neigh) |
11542 | { | |
0291c246 MK |
11543 | struct bgp_filter *filter; |
11544 | struct peer_af *paf; | |
11545 | char orf_pfx_name[BUFSIZ]; | |
11546 | int orf_pfx_count; | |
11547 | json_object *json_af = NULL; | |
11548 | json_object *json_prefA = NULL; | |
11549 | json_object *json_prefB = NULL; | |
11550 | json_object *json_addr = NULL; | |
fa36596c | 11551 | json_object *json_advmap = NULL; |
d62a17ae | 11552 | |
11553 | if (use_json) { | |
11554 | json_addr = json_object_new_object(); | |
11555 | json_af = json_object_new_object(); | |
11556 | filter = &p->filter[afi][safi]; | |
11557 | ||
11558 | if (peer_group_active(p)) | |
11559 | json_object_string_add(json_addr, "peerGroupMember", | |
11560 | p->group->name); | |
11561 | ||
11562 | paf = peer_af_find(p, afi, safi); | |
11563 | if (paf && PAF_SUBGRP(paf)) { | |
11564 | json_object_int_add(json_addr, "updateGroupId", | |
11565 | PAF_UPDGRP(paf)->id); | |
11566 | json_object_int_add(json_addr, "subGroupId", | |
11567 | PAF_SUBGRP(paf)->id); | |
11568 | json_object_int_add(json_addr, "packetQueueLength", | |
11569 | bpacket_queue_virtual_length(paf)); | |
11570 | } | |
11571 | ||
11572 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11573 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11574 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11575 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11576 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11577 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11578 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11579 | json_object_int_add(json_af, "orfType", | |
11580 | ORF_TYPE_PREFIX); | |
11581 | json_prefA = json_object_new_object(); | |
11582 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11583 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11584 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11585 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11586 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11587 | use_json, json_prefA); | |
11588 | json_object_object_add(json_af, "orfPrefixList", | |
11589 | json_prefA); | |
11590 | } | |
11591 | ||
11592 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11593 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11594 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11595 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11596 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11597 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11598 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11599 | json_object_int_add(json_af, "orfOldType", | |
11600 | ORF_TYPE_PREFIX_OLD); | |
11601 | json_prefB = json_object_new_object(); | |
11602 | bgp_show_peer_afi_orf_cap( | |
11603 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11604 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11605 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11606 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11607 | json_prefB); | |
11608 | json_object_object_add(json_af, "orfOldPrefixList", | |
11609 | json_prefB); | |
11610 | } | |
11611 | ||
11612 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11613 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11614 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11615 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11616 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11617 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11618 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11619 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11620 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11621 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11622 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11623 | json_object_object_add(json_addr, "afDependentCap", | |
11624 | json_af); | |
11625 | else | |
11626 | json_object_free(json_af); | |
11627 | ||
772270f3 QY |
11628 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11629 | p->host, afi, safi); | |
d62a17ae | 11630 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11631 | NULL, afi, orf_pfx_name, use_json); | |
11632 | ||
11633 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11634 | PEER_STATUS_ORF_PREFIX_SEND) | |
11635 | || orf_pfx_count) { | |
11636 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11637 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11638 | json_object_boolean_true_add(json_neigh, | |
11639 | "orfSent"); | |
11640 | if (orf_pfx_count) | |
11641 | json_object_int_add(json_addr, "orfRecvCounter", | |
11642 | orf_pfx_count); | |
11643 | } | |
11644 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11645 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11646 | json_object_string_add( | |
11647 | json_addr, "orfFirstUpdate", | |
11648 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11649 | ||
11650 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11651 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11652 | json_object_boolean_true_add(json_addr, | |
11653 | "routeReflectorClient"); | |
11654 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11655 | PEER_FLAG_RSERVER_CLIENT)) | |
11656 | json_object_boolean_true_add(json_addr, | |
11657 | "routeServerClient"); | |
11658 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11659 | json_object_boolean_true_add(json_addr, | |
11660 | "inboundSoftConfigPermit"); | |
11661 | ||
11662 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11663 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11664 | json_object_boolean_true_add( | |
11665 | json_addr, | |
11666 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11667 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11668 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11669 | json_object_boolean_true_add( | |
11670 | json_addr, | |
11671 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11672 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11673 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11674 | json_object_boolean_true_add( | |
11675 | json_addr, | |
11676 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11677 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11678 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11679 | json_object_boolean_true_add( | |
11680 | json_addr, | |
11681 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11682 | ||
dcc68b5e MS |
11683 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11684 | json_object_boolean_true_add( | |
11685 | json_addr, | |
11686 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11687 | ->type_json_name); | |
d62a17ae | 11688 | |
11689 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11690 | json_object_string_add(json_addr, | |
11691 | "overrideASNsInOutboundUpdates", | |
11692 | "ifAspathEqualRemoteAs"); | |
11693 | ||
11694 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11695 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11696 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11697 | json_object_boolean_true_add(json_addr, | |
11698 | "routerAlwaysNextHop"); | |
11699 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11700 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11701 | json_object_boolean_true_add( | |
11702 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11703 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11704 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11705 | json_object_boolean_true_add( | |
11706 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11707 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11708 | json_object_boolean_true_add( | |
11709 | json_addr, "unchangedMedPropogatedToNbr"); | |
11710 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11711 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11712 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11713 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11714 | PEER_FLAG_SEND_COMMUNITY) | |
11715 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11716 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11717 | json_object_string_add(json_addr, | |
11718 | "commAttriSentToNbr", | |
11719 | "extendedAndStandard"); | |
11720 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11721 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11722 | json_object_string_add(json_addr, | |
11723 | "commAttriSentToNbr", | |
11724 | "extended"); | |
11725 | else | |
11726 | json_object_string_add(json_addr, | |
11727 | "commAttriSentToNbr", | |
11728 | "standard"); | |
11729 | } | |
11730 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11731 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11732 | if (p->default_rmap[afi][safi].name) | |
11733 | json_object_string_add( | |
11734 | json_addr, "defaultRouteMap", | |
11735 | p->default_rmap[afi][safi].name); | |
11736 | ||
11737 | if (paf && PAF_SUBGRP(paf) | |
11738 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11739 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11740 | json_object_boolean_true_add(json_addr, | |
11741 | "defaultSent"); | |
11742 | else | |
11743 | json_object_boolean_true_add(json_addr, | |
11744 | "defaultNotSent"); | |
11745 | } | |
11746 | ||
dff8f48d | 11747 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11748 | if (is_evpn_enabled()) |
60466a63 QY |
11749 | json_object_boolean_true_add( |
11750 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11751 | } |
11752 | ||
d62a17ae | 11753 | if (filter->plist[FILTER_IN].name |
11754 | || filter->dlist[FILTER_IN].name | |
11755 | || filter->aslist[FILTER_IN].name | |
11756 | || filter->map[RMAP_IN].name) | |
11757 | json_object_boolean_true_add(json_addr, | |
11758 | "inboundPathPolicyConfig"); | |
11759 | if (filter->plist[FILTER_OUT].name | |
11760 | || filter->dlist[FILTER_OUT].name | |
11761 | || filter->aslist[FILTER_OUT].name | |
11762 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11763 | json_object_boolean_true_add( | |
11764 | json_addr, "outboundPathPolicyConfig"); | |
11765 | ||
11766 | /* prefix-list */ | |
11767 | if (filter->plist[FILTER_IN].name) | |
11768 | json_object_string_add(json_addr, | |
11769 | "incomingUpdatePrefixFilterList", | |
11770 | filter->plist[FILTER_IN].name); | |
11771 | if (filter->plist[FILTER_OUT].name) | |
11772 | json_object_string_add(json_addr, | |
11773 | "outgoingUpdatePrefixFilterList", | |
11774 | filter->plist[FILTER_OUT].name); | |
11775 | ||
11776 | /* distribute-list */ | |
11777 | if (filter->dlist[FILTER_IN].name) | |
11778 | json_object_string_add( | |
11779 | json_addr, "incomingUpdateNetworkFilterList", | |
11780 | filter->dlist[FILTER_IN].name); | |
11781 | if (filter->dlist[FILTER_OUT].name) | |
11782 | json_object_string_add( | |
11783 | json_addr, "outgoingUpdateNetworkFilterList", | |
11784 | filter->dlist[FILTER_OUT].name); | |
11785 | ||
11786 | /* filter-list. */ | |
11787 | if (filter->aslist[FILTER_IN].name) | |
11788 | json_object_string_add(json_addr, | |
11789 | "incomingUpdateAsPathFilterList", | |
11790 | filter->aslist[FILTER_IN].name); | |
11791 | if (filter->aslist[FILTER_OUT].name) | |
11792 | json_object_string_add(json_addr, | |
11793 | "outgoingUpdateAsPathFilterList", | |
11794 | filter->aslist[FILTER_OUT].name); | |
11795 | ||
11796 | /* route-map. */ | |
11797 | if (filter->map[RMAP_IN].name) | |
11798 | json_object_string_add( | |
11799 | json_addr, "routeMapForIncomingAdvertisements", | |
11800 | filter->map[RMAP_IN].name); | |
11801 | if (filter->map[RMAP_OUT].name) | |
11802 | json_object_string_add( | |
11803 | json_addr, "routeMapForOutgoingAdvertisements", | |
11804 | filter->map[RMAP_OUT].name); | |
11805 | ||
9dac9fc8 | 11806 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11807 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11808 | && !bgp_inbound_policy_exists(p, filter)) |
11809 | json_object_string_add( | |
11810 | json_addr, "inboundEbgpRequiresPolicy", | |
11811 | "Inbound updates discarded due to missing policy"); | |
11812 | ||
11813 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11814 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11815 | && (!bgp_outbound_policy_exists(p, filter))) |
11816 | json_object_string_add( | |
11817 | json_addr, "outboundEbgpRequiresPolicy", | |
11818 | "Outbound updates discarded due to missing policy"); | |
11819 | ||
d62a17ae | 11820 | /* unsuppress-map */ |
11821 | if (filter->usmap.name) | |
11822 | json_object_string_add(json_addr, | |
11823 | "selectiveUnsuppressRouteMap", | |
11824 | filter->usmap.name); | |
11825 | ||
fa36596c MK |
11826 | /* advertise-map */ |
11827 | if (filter->advmap.aname) { | |
11828 | json_advmap = json_object_new_object(); | |
11829 | json_object_string_add(json_advmap, "condition", | |
11830 | filter->advmap.condition | |
11831 | ? "EXIST" | |
11832 | : "NON_EXIST"); | |
11833 | json_object_string_add(json_advmap, "conditionMap", | |
11834 | filter->advmap.cname); | |
11835 | json_object_string_add(json_advmap, "advertiseMap", | |
11836 | filter->advmap.aname); | |
11837 | json_object_string_add(json_advmap, "advertiseStatus", | |
11838 | filter->advmap.update_type | |
11839 | == ADVERTISE | |
11840 | ? "Advertise" | |
11841 | : "Withdraw"); | |
11842 | json_object_object_add(json_addr, "advertiseMap", | |
11843 | json_advmap); | |
11844 | } | |
11845 | ||
d62a17ae | 11846 | /* Receive prefix count */ |
11847 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11848 | p->pcount[afi][safi]); | |
50e05855 AD |
11849 | if (paf && PAF_SUBGRP(paf)) |
11850 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11851 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11852 | |
fde246e8 DA |
11853 | /* Maximum prefix */ |
11854 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11855 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11856 | p->pmax_out[afi][safi]); | |
11857 | ||
d62a17ae | 11858 | /* Maximum prefix */ |
11859 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11860 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11861 | p->pmax[afi][safi]); | |
11862 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11863 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11864 | json_object_boolean_true_add( | |
11865 | json_addr, "prefixAllowedMaxWarning"); | |
11866 | json_object_int_add(json_addr, | |
11867 | "prefixAllowedWarningThresh", | |
11868 | p->pmax_threshold[afi][safi]); | |
11869 | if (p->pmax_restart[afi][safi]) | |
11870 | json_object_int_add( | |
11871 | json_addr, | |
11872 | "prefixAllowedRestartIntervalMsecs", | |
11873 | p->pmax_restart[afi][safi] * 60000); | |
11874 | } | |
2986cac2 | 11875 | json_object_object_add(json_neigh, |
36235319 | 11876 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 11877 | json_addr); |
11878 | ||
11879 | } else { | |
11880 | filter = &p->filter[afi][safi]; | |
11881 | ||
11882 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 11883 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11884 | |
11885 | if (peer_group_active(p)) | |
11886 | vty_out(vty, " %s peer-group member\n", | |
11887 | p->group->name); | |
11888 | ||
11889 | paf = peer_af_find(p, afi, safi); | |
11890 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 11891 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 11892 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
11893 | vty_out(vty, " Packet Queue length %d\n", | |
11894 | bpacket_queue_virtual_length(paf)); | |
11895 | } else { | |
11896 | vty_out(vty, " Not part of any update group\n"); | |
11897 | } | |
11898 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11899 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11900 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11901 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11902 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11903 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11904 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11905 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11906 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11907 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11908 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11909 | vty_out(vty, " AF-dependant capabilities:\n"); | |
11910 | ||
11911 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11912 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11913 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11914 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11915 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11916 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11917 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11918 | vty_out(vty, | |
11919 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11920 | ORF_TYPE_PREFIX); | |
11921 | bgp_show_peer_afi_orf_cap( | |
11922 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11923 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11924 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11925 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
11926 | } | |
11927 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11928 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11929 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11930 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11931 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11932 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11933 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11934 | vty_out(vty, | |
11935 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11936 | ORF_TYPE_PREFIX_OLD); | |
11937 | bgp_show_peer_afi_orf_cap( | |
11938 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11939 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11940 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11941 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
11942 | } | |
11943 | ||
772270f3 QY |
11944 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11945 | p->host, afi, safi); | |
d62a17ae | 11946 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11947 | NULL, afi, orf_pfx_name, use_json); | |
11948 | ||
11949 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11950 | PEER_STATUS_ORF_PREFIX_SEND) | |
11951 | || orf_pfx_count) { | |
11952 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
11953 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11954 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11955 | vty_out(vty, " sent;"); | |
11956 | if (orf_pfx_count) | |
11957 | vty_out(vty, " received (%d entries)", | |
11958 | orf_pfx_count); | |
11959 | vty_out(vty, "\n"); | |
11960 | } | |
11961 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11962 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11963 | vty_out(vty, | |
11964 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
11965 | ||
11966 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11967 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11968 | vty_out(vty, " Route-Reflector Client\n"); | |
11969 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11970 | PEER_FLAG_RSERVER_CLIENT)) | |
11971 | vty_out(vty, " Route-Server Client\n"); | |
11972 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11973 | vty_out(vty, | |
11974 | " Inbound soft reconfiguration allowed\n"); | |
11975 | ||
11976 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11977 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11978 | vty_out(vty, | |
11979 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
11980 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11981 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11982 | vty_out(vty, | |
11983 | " Private AS numbers replaced in updates to this neighbor\n"); | |
11984 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11985 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11986 | vty_out(vty, | |
11987 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
11988 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11989 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11990 | vty_out(vty, | |
11991 | " Private AS numbers removed in updates to this neighbor\n"); | |
11992 | ||
dcc68b5e MS |
11993 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11994 | vty_out(vty, " %s\n", | |
11995 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11996 | ->human_description); | |
d62a17ae | 11997 | |
11998 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11999 | vty_out(vty, | |
12000 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12001 | ||
12002 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12003 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12004 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12005 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12006 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12007 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12008 | vty_out(vty, | |
12009 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12010 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12011 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12012 | vty_out(vty, | |
12013 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12014 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12015 | vty_out(vty, | |
12016 | " MED is propagated unchanged to this neighbor\n"); | |
12017 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12018 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12019 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12020 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12021 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12022 | vty_out(vty, | |
12023 | " Community attribute sent to this neighbor"); | |
12024 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12025 | PEER_FLAG_SEND_COMMUNITY) | |
12026 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12027 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12028 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12029 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12030 | vty_out(vty, "(all)\n"); | |
12031 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12032 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12033 | vty_out(vty, "(large)\n"); | |
12034 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12035 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12036 | vty_out(vty, "(extended)\n"); | |
12037 | else | |
12038 | vty_out(vty, "(standard)\n"); | |
12039 | } | |
12040 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12041 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12042 | vty_out(vty, " Default information originate,"); | |
12043 | ||
12044 | if (p->default_rmap[afi][safi].name) | |
12045 | vty_out(vty, " default route-map %s%s,", | |
12046 | p->default_rmap[afi][safi].map ? "*" | |
12047 | : "", | |
12048 | p->default_rmap[afi][safi].name); | |
12049 | if (paf && PAF_SUBGRP(paf) | |
12050 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12051 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12052 | vty_out(vty, " default sent\n"); | |
12053 | else | |
12054 | vty_out(vty, " default not sent\n"); | |
12055 | } | |
12056 | ||
dff8f48d MK |
12057 | /* advertise-vni-all */ |
12058 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12059 | if (is_evpn_enabled()) |
dff8f48d MK |
12060 | vty_out(vty, " advertise-all-vni\n"); |
12061 | } | |
12062 | ||
d62a17ae | 12063 | if (filter->plist[FILTER_IN].name |
12064 | || filter->dlist[FILTER_IN].name | |
12065 | || filter->aslist[FILTER_IN].name | |
12066 | || filter->map[RMAP_IN].name) | |
12067 | vty_out(vty, " Inbound path policy configured\n"); | |
12068 | if (filter->plist[FILTER_OUT].name | |
12069 | || filter->dlist[FILTER_OUT].name | |
12070 | || filter->aslist[FILTER_OUT].name | |
12071 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12072 | vty_out(vty, " Outbound path policy configured\n"); | |
12073 | ||
12074 | /* prefix-list */ | |
12075 | if (filter->plist[FILTER_IN].name) | |
12076 | vty_out(vty, | |
12077 | " Incoming update prefix filter list is %s%s\n", | |
12078 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12079 | filter->plist[FILTER_IN].name); | |
12080 | if (filter->plist[FILTER_OUT].name) | |
12081 | vty_out(vty, | |
12082 | " Outgoing update prefix filter list is %s%s\n", | |
12083 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12084 | filter->plist[FILTER_OUT].name); | |
12085 | ||
12086 | /* distribute-list */ | |
12087 | if (filter->dlist[FILTER_IN].name) | |
12088 | vty_out(vty, | |
12089 | " Incoming update network filter list is %s%s\n", | |
12090 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12091 | filter->dlist[FILTER_IN].name); | |
12092 | if (filter->dlist[FILTER_OUT].name) | |
12093 | vty_out(vty, | |
12094 | " Outgoing update network filter list is %s%s\n", | |
12095 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12096 | filter->dlist[FILTER_OUT].name); | |
12097 | ||
12098 | /* filter-list. */ | |
12099 | if (filter->aslist[FILTER_IN].name) | |
12100 | vty_out(vty, | |
12101 | " Incoming update AS path filter list is %s%s\n", | |
12102 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12103 | filter->aslist[FILTER_IN].name); | |
12104 | if (filter->aslist[FILTER_OUT].name) | |
12105 | vty_out(vty, | |
12106 | " Outgoing update AS path filter list is %s%s\n", | |
12107 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12108 | filter->aslist[FILTER_OUT].name); | |
12109 | ||
12110 | /* route-map. */ | |
12111 | if (filter->map[RMAP_IN].name) | |
12112 | vty_out(vty, | |
12113 | " Route map for incoming advertisements is %s%s\n", | |
12114 | filter->map[RMAP_IN].map ? "*" : "", | |
12115 | filter->map[RMAP_IN].name); | |
12116 | if (filter->map[RMAP_OUT].name) | |
12117 | vty_out(vty, | |
12118 | " Route map for outgoing advertisements is %s%s\n", | |
12119 | filter->map[RMAP_OUT].map ? "*" : "", | |
12120 | filter->map[RMAP_OUT].name); | |
12121 | ||
9dac9fc8 | 12122 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12123 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12124 | && !bgp_inbound_policy_exists(p, filter)) |
12125 | vty_out(vty, | |
12126 | " Inbound updates discarded due to missing policy\n"); | |
12127 | ||
12128 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12129 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12130 | && !bgp_outbound_policy_exists(p, filter)) |
12131 | vty_out(vty, | |
12132 | " Outbound updates discarded due to missing policy\n"); | |
12133 | ||
d62a17ae | 12134 | /* unsuppress-map */ |
12135 | if (filter->usmap.name) | |
12136 | vty_out(vty, | |
12137 | " Route map for selective unsuppress is %s%s\n", | |
12138 | filter->usmap.map ? "*" : "", | |
12139 | filter->usmap.name); | |
12140 | ||
7f7940e6 MK |
12141 | /* advertise-map */ |
12142 | if (filter->advmap.aname && filter->advmap.cname) | |
12143 | vty_out(vty, | |
12144 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12145 | filter->advmap.condition ? "EXIST" | |
12146 | : "NON_EXIST", | |
12147 | filter->advmap.cmap ? "*" : "", | |
12148 | filter->advmap.cname, | |
12149 | filter->advmap.amap ? "*" : "", | |
12150 | filter->advmap.aname, | |
fa36596c | 12151 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12152 | ? "Advertise" |
12153 | : "Withdraw"); | |
7f7940e6 | 12154 | |
d62a17ae | 12155 | /* Receive prefix count */ |
6cde4b45 | 12156 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12157 | p->pcount[afi][safi]); |
d62a17ae | 12158 | |
fde246e8 DA |
12159 | /* maximum-prefix-out */ |
12160 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12161 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12162 | vty_out(vty, | |
6cde4b45 | 12163 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12164 | p->pmax_out[afi][safi]); |
12165 | ||
d62a17ae | 12166 | /* Maximum prefix */ |
12167 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12168 | vty_out(vty, |
6cde4b45 | 12169 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12170 | p->pmax[afi][safi], |
12171 | CHECK_FLAG(p->af_flags[afi][safi], | |
12172 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12173 | ? " (warning-only)" | |
12174 | : ""); | |
12175 | vty_out(vty, " Threshold for warning message %d%%", | |
12176 | p->pmax_threshold[afi][safi]); | |
12177 | if (p->pmax_restart[afi][safi]) | |
12178 | vty_out(vty, ", restart interval %d min", | |
12179 | p->pmax_restart[afi][safi]); | |
12180 | vty_out(vty, "\n"); | |
12181 | } | |
12182 | ||
12183 | vty_out(vty, "\n"); | |
12184 | } | |
12185 | } | |
12186 | ||
9f049418 | 12187 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12188 | json_object *json) |
718e3744 | 12189 | { |
d62a17ae | 12190 | struct bgp *bgp; |
12191 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12192 | char timebuf[BGP_UPTIME_LEN]; | |
12193 | char dn_flag[2]; | |
d62a17ae | 12194 | afi_t afi; |
12195 | safi_t safi; | |
d7c0a89a QY |
12196 | uint16_t i; |
12197 | uint8_t *msg; | |
d62a17ae | 12198 | json_object *json_neigh = NULL; |
12199 | time_t epoch_tbuf; | |
4ab46701 | 12200 | uint32_t sync_tcp_mss; |
718e3744 | 12201 | |
d62a17ae | 12202 | bgp = p->bgp; |
12203 | ||
12204 | if (use_json) | |
12205 | json_neigh = json_object_new_object(); | |
12206 | ||
12207 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12208 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12209 | dn_flag[0] = '*'; | |
12210 | ||
12211 | if (!use_json) { | |
12212 | if (p->conf_if) /* Configured interface name. */ | |
12213 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12214 | BGP_PEER_SU_UNSPEC(p) | |
12215 | ? "None" | |
12216 | : sockunion2str(&p->su, buf, | |
12217 | SU_ADDRSTRLEN)); | |
12218 | else /* Configured IP address. */ | |
12219 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12220 | p->host); | |
12221 | } | |
12222 | ||
12223 | if (use_json) { | |
12224 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12225 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12226 | "none"); | |
12227 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12228 | json_object_string_add( | |
12229 | json_neigh, "bgpNeighborAddr", | |
12230 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12231 | ||
12232 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12233 | ||
12234 | if (p->change_local_as) | |
12235 | json_object_int_add(json_neigh, "localAs", | |
12236 | p->change_local_as); | |
12237 | else | |
12238 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12239 | ||
12240 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12241 | json_object_boolean_true_add(json_neigh, | |
12242 | "localAsNoPrepend"); | |
12243 | ||
12244 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12245 | json_object_boolean_true_add(json_neigh, | |
12246 | "localAsReplaceAs"); | |
12247 | } else { | |
12248 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12249 | || (p->as_type == AS_INTERNAL)) | |
12250 | vty_out(vty, "remote AS %u, ", p->as); | |
12251 | else | |
12252 | vty_out(vty, "remote AS Unspecified, "); | |
12253 | vty_out(vty, "local AS %u%s%s, ", | |
12254 | p->change_local_as ? p->change_local_as : p->local_as, | |
12255 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12256 | ? " no-prepend" | |
12257 | : "", | |
12258 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12259 | ? " replace-as" | |
12260 | : ""); | |
12261 | } | |
faa16034 DS |
12262 | /* peer type internal or confed-internal */ |
12263 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12264 | if (use_json) { |
12265 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12266 | json_object_boolean_true_add( | |
12267 | json_neigh, "nbrConfedInternalLink"); | |
12268 | else | |
12269 | json_object_boolean_true_add(json_neigh, | |
12270 | "nbrInternalLink"); | |
12271 | } else { | |
12272 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12273 | vty_out(vty, "confed-internal link\n"); | |
12274 | else | |
12275 | vty_out(vty, "internal link\n"); | |
12276 | } | |
faa16034 DS |
12277 | /* peer type external or confed-external */ |
12278 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12279 | if (use_json) { |
12280 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12281 | json_object_boolean_true_add( | |
12282 | json_neigh, "nbrConfedExternalLink"); | |
12283 | else | |
12284 | json_object_boolean_true_add(json_neigh, | |
12285 | "nbrExternalLink"); | |
12286 | } else { | |
12287 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12288 | vty_out(vty, "confed-external link\n"); | |
12289 | else | |
12290 | vty_out(vty, "external link\n"); | |
12291 | } | |
faa16034 DS |
12292 | } else { |
12293 | if (use_json) | |
12294 | json_object_boolean_true_add(json_neigh, | |
12295 | "nbrUnspecifiedLink"); | |
12296 | else | |
12297 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12298 | } |
12299 | ||
12300 | /* Description. */ | |
12301 | if (p->desc) { | |
12302 | if (use_json) | |
12303 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12304 | else | |
12305 | vty_out(vty, " Description: %s\n", p->desc); | |
12306 | } | |
12307 | ||
12308 | if (p->hostname) { | |
12309 | if (use_json) { | |
12310 | if (p->hostname) | |
12311 | json_object_string_add(json_neigh, "hostname", | |
12312 | p->hostname); | |
12313 | ||
12314 | if (p->domainname) | |
12315 | json_object_string_add(json_neigh, "domainname", | |
12316 | p->domainname); | |
12317 | } else { | |
12318 | if (p->domainname && (p->domainname[0] != '\0')) | |
12319 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12320 | p->domainname); | |
12321 | else | |
12322 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12323 | } | |
12324 | } | |
12325 | ||
12326 | /* Peer-group */ | |
12327 | if (p->group) { | |
12328 | if (use_json) { | |
12329 | json_object_string_add(json_neigh, "peerGroup", | |
12330 | p->group->name); | |
12331 | ||
12332 | if (dn_flag[0]) { | |
12333 | struct prefix prefix, *range = NULL; | |
12334 | ||
0154d8ce DS |
12335 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12336 | range = peer_group_lookup_dynamic_neighbor_range( | |
12337 | p->group, &prefix); | |
d62a17ae | 12338 | |
12339 | if (range) { | |
12340 | prefix2str(range, buf1, sizeof(buf1)); | |
12341 | json_object_string_add( | |
12342 | json_neigh, | |
12343 | "peerSubnetRangeGroup", buf1); | |
12344 | } | |
12345 | } | |
12346 | } else { | |
12347 | vty_out(vty, | |
12348 | " Member of peer-group %s for session parameters\n", | |
12349 | p->group->name); | |
12350 | ||
12351 | if (dn_flag[0]) { | |
12352 | struct prefix prefix, *range = NULL; | |
12353 | ||
0154d8ce DS |
12354 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12355 | range = peer_group_lookup_dynamic_neighbor_range( | |
12356 | p->group, &prefix); | |
d62a17ae | 12357 | |
12358 | if (range) { | |
d62a17ae | 12359 | vty_out(vty, |
1b78780b DL |
12360 | " Belongs to the subnet range group: %pFX\n", |
12361 | range); | |
d62a17ae | 12362 | } |
12363 | } | |
12364 | } | |
12365 | } | |
12366 | ||
12367 | if (use_json) { | |
12368 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12369 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12370 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12371 | json_object_boolean_true_add(json_neigh, |
12372 | "adminShutDown"); | |
12373 | ||
12374 | /* BGP Version. */ | |
12375 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
12376 | json_object_string_add( | |
12377 | json_neigh, "remoteRouterId", | |
12378 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
12379 | json_object_string_add( |
12380 | json_neigh, "localRouterId", | |
12381 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12382 | sizeof(buf1))); | |
d62a17ae | 12383 | |
12384 | /* Confederation */ | |
12385 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12386 | && bgp_confederation_peers_check(bgp, p->as)) | |
12387 | json_object_boolean_true_add(json_neigh, | |
12388 | "nbrCommonAdmin"); | |
12389 | ||
12390 | /* Status. */ | |
12391 | json_object_string_add( | |
12392 | json_neigh, "bgpState", | |
12393 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12394 | ||
feb17238 | 12395 | if (peer_established(p)) { |
d62a17ae | 12396 | time_t uptime; |
d62a17ae | 12397 | |
12398 | uptime = bgp_clock(); | |
12399 | uptime -= p->uptime; | |
d62a17ae | 12400 | epoch_tbuf = time(NULL) - uptime; |
12401 | ||
d3c7efed DS |
12402 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12403 | uptime * 1000); | |
d62a17ae | 12404 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12405 | peer_uptime(p->uptime, timebuf, | |
12406 | BGP_UPTIME_LEN, 0, | |
12407 | NULL)); | |
12408 | json_object_int_add(json_neigh, | |
12409 | "bgpTimerUpEstablishedEpoch", | |
12410 | epoch_tbuf); | |
12411 | } | |
12412 | ||
12413 | else if (p->status == Active) { | |
12414 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12415 | json_object_string_add(json_neigh, "bgpStateIs", | |
12416 | "passive"); | |
12417 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12418 | json_object_string_add(json_neigh, "bgpStateIs", | |
12419 | "passiveNSF"); | |
12420 | } | |
12421 | ||
12422 | /* read timer */ | |
12423 | time_t uptime; | |
a2700b50 | 12424 | struct tm tm; |
d62a17ae | 12425 | |
12426 | uptime = bgp_clock(); | |
12427 | uptime -= p->readtime; | |
a2700b50 MS |
12428 | gmtime_r(&uptime, &tm); |
12429 | ||
d62a17ae | 12430 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12431 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12432 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12433 | |
12434 | uptime = bgp_clock(); | |
12435 | uptime -= p->last_write; | |
a2700b50 MS |
12436 | gmtime_r(&uptime, &tm); |
12437 | ||
d62a17ae | 12438 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12439 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12440 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12441 | |
12442 | uptime = bgp_clock(); | |
12443 | uptime -= p->update_time; | |
a2700b50 MS |
12444 | gmtime_r(&uptime, &tm); |
12445 | ||
d62a17ae | 12446 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12447 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12448 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12449 | |
12450 | /* Configured timer values. */ | |
12451 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12452 | p->v_holdtime * 1000); | |
12453 | json_object_int_add(json_neigh, | |
12454 | "bgpTimerKeepAliveIntervalMsecs", | |
12455 | p->v_keepalive * 1000); | |
d43114f3 DS |
12456 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
12457 | json_object_int_add(json_neigh, | |
12458 | "bgpTimerDelayOpenTimeMsecs", | |
12459 | p->v_delayopen * 1000); | |
12460 | } | |
12461 | ||
4ab46701 AR |
12462 | /* Configured and Synced tcp-mss value for peer */ |
12463 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12464 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12465 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
12466 | p->tcp_mss); | |
12467 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
12468 | sync_tcp_mss); | |
12469 | } | |
12470 | ||
b90a8e13 | 12471 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12472 | json_object_int_add(json_neigh, |
12473 | "bgpTimerConfiguredHoldTimeMsecs", | |
12474 | p->holdtime * 1000); | |
12475 | json_object_int_add( | |
12476 | json_neigh, | |
12477 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12478 | p->keepalive * 1000); | |
5d5393b9 DL |
12479 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12480 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12481 | json_object_int_add(json_neigh, |
12482 | "bgpTimerConfiguredHoldTimeMsecs", | |
12483 | bgp->default_holdtime); | |
12484 | json_object_int_add( | |
12485 | json_neigh, | |
12486 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12487 | bgp->default_keepalive); | |
d62a17ae | 12488 | } |
12489 | } else { | |
12490 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12491 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12492 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12493 | vty_out(vty, " Administratively shut down\n"); |
12494 | ||
12495 | /* BGP Version. */ | |
12496 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12497 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12498 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12499 | vty_out(vty, ", local router ID %s\n", |
12500 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12501 | sizeof(buf1))); | |
d62a17ae | 12502 | |
12503 | /* Confederation */ | |
12504 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12505 | && bgp_confederation_peers_check(bgp, p->as)) | |
12506 | vty_out(vty, | |
12507 | " Neighbor under common administration\n"); | |
12508 | ||
12509 | /* Status. */ | |
12510 | vty_out(vty, " BGP state = %s", | |
12511 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12512 | ||
feb17238 | 12513 | if (peer_established(p)) |
d62a17ae | 12514 | vty_out(vty, ", up for %8s", |
12515 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12516 | 0, NULL)); | |
12517 | ||
12518 | else if (p->status == Active) { | |
12519 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12520 | vty_out(vty, " (passive)"); | |
12521 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12522 | vty_out(vty, " (NSF passive)"); | |
12523 | } | |
12524 | vty_out(vty, "\n"); | |
12525 | ||
12526 | /* read timer */ | |
12527 | vty_out(vty, " Last read %s", | |
12528 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12529 | NULL)); | |
12530 | vty_out(vty, ", Last write %s\n", | |
12531 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12532 | NULL)); | |
12533 | ||
12534 | /* Configured timer values. */ | |
12535 | vty_out(vty, | |
12536 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12537 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12538 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12539 | vty_out(vty, " Configured hold time is %d", |
12540 | p->holdtime); | |
12541 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12542 | p->keepalive); | |
5d5393b9 DL |
12543 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12544 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12545 | vty_out(vty, " Configured hold time is %d", |
12546 | bgp->default_holdtime); | |
12547 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12548 | bgp->default_keepalive); | |
d62a17ae | 12549 | } |
d43114f3 DS |
12550 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
12551 | vty_out(vty, | |
12552 | " Configured DelayOpenTime is %d seconds\n", | |
12553 | p->delayopen); | |
4ab46701 AR |
12554 | |
12555 | /* Configured and synced tcp-mss value for peer */ | |
12556 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12557 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12558 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
12559 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
12560 | } | |
d62a17ae | 12561 | } |
12562 | /* Capability. */ | |
feb17238 | 12563 | if (peer_established(p)) { |
d62a17ae | 12564 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] |
12565 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
12566 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
12567 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
12568 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
12569 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
12570 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
12571 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
12572 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
12573 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
12574 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
12575 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 12576 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
12577 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 12578 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
12579 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 12580 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
12581 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 12582 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
12583 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
12584 | if (use_json) { | |
12585 | json_object *json_cap = NULL; | |
12586 | ||
12587 | json_cap = json_object_new_object(); | |
12588 | ||
12589 | /* AS4 */ | |
12590 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12591 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12592 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
12593 | && CHECK_FLAG(p->cap, | |
12594 | PEER_CAP_AS4_RCV)) | |
12595 | json_object_string_add( | |
12596 | json_cap, "4byteAs", | |
12597 | "advertisedAndReceived"); | |
12598 | else if (CHECK_FLAG(p->cap, | |
12599 | PEER_CAP_AS4_ADV)) | |
12600 | json_object_string_add( | |
12601 | json_cap, "4byteAs", | |
12602 | "advertised"); | |
12603 | else if (CHECK_FLAG(p->cap, | |
12604 | PEER_CAP_AS4_RCV)) | |
12605 | json_object_string_add( | |
12606 | json_cap, "4byteAs", | |
12607 | "received"); | |
12608 | } | |
12609 | ||
ef56aee4 DA |
12610 | /* Extended Message Support */ |
12611 | if (CHECK_FLAG(p->cap, | |
12612 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
12613 | && CHECK_FLAG( | |
12614 | p->cap, | |
12615 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12616 | json_object_string_add( | |
12617 | json_cap, "extendedMessage", | |
12618 | "advertisedAndReceived"); | |
12619 | else if (CHECK_FLAG( | |
12620 | p->cap, | |
12621 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
12622 | json_object_string_add( | |
12623 | json_cap, "extendedMessage", | |
12624 | "advertised"); | |
12625 | else if (CHECK_FLAG( | |
12626 | p->cap, | |
12627 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12628 | json_object_string_add( | |
12629 | json_cap, "extendedMessage", | |
12630 | "received"); | |
12631 | ||
d62a17ae | 12632 | /* AddPath */ |
12633 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12634 | || CHECK_FLAG(p->cap, | |
12635 | PEER_CAP_ADDPATH_ADV)) { | |
12636 | json_object *json_add = NULL; | |
12637 | const char *print_store; | |
12638 | ||
12639 | json_add = json_object_new_object(); | |
12640 | ||
05c7a1cc QY |
12641 | FOREACH_AFI_SAFI (afi, safi) { |
12642 | json_object *json_sub = NULL; | |
12643 | json_sub = | |
12644 | json_object_new_object(); | |
5cb5f4d0 DD |
12645 | print_store = get_afi_safi_str( |
12646 | afi, safi, true); | |
d62a17ae | 12647 | |
05c7a1cc QY |
12648 | if (CHECK_FLAG( |
12649 | p->af_cap[afi] | |
12650 | [safi], | |
12651 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12652 | || CHECK_FLAG( | |
12653 | p->af_cap[afi] | |
12654 | [safi], | |
12655 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 12656 | if (CHECK_FLAG( |
12657 | p->af_cap | |
12658 | [afi] | |
12659 | [safi], | |
12660 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 12661 | && CHECK_FLAG( |
d62a17ae | 12662 | p->af_cap |
12663 | [afi] | |
12664 | [safi], | |
05c7a1cc QY |
12665 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12666 | json_object_boolean_true_add( | |
12667 | json_sub, | |
12668 | "txAdvertisedAndReceived"); | |
12669 | else if ( | |
12670 | CHECK_FLAG( | |
12671 | p->af_cap | |
12672 | [afi] | |
12673 | [safi], | |
12674 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12675 | json_object_boolean_true_add( | |
12676 | json_sub, | |
12677 | "txAdvertised"); | |
12678 | else if ( | |
12679 | CHECK_FLAG( | |
12680 | p->af_cap | |
12681 | [afi] | |
12682 | [safi], | |
12683 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12684 | json_object_boolean_true_add( | |
12685 | json_sub, | |
12686 | "txReceived"); | |
12687 | } | |
d62a17ae | 12688 | |
05c7a1cc QY |
12689 | if (CHECK_FLAG( |
12690 | p->af_cap[afi] | |
12691 | [safi], | |
12692 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12693 | || CHECK_FLAG( | |
12694 | p->af_cap[afi] | |
12695 | [safi], | |
12696 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 12697 | if (CHECK_FLAG( |
12698 | p->af_cap | |
12699 | [afi] | |
12700 | [safi], | |
12701 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 12702 | && CHECK_FLAG( |
d62a17ae | 12703 | p->af_cap |
12704 | [afi] | |
12705 | [safi], | |
12706 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
12707 | json_object_boolean_true_add( |
12708 | json_sub, | |
12709 | "rxAdvertisedAndReceived"); | |
12710 | else if ( | |
12711 | CHECK_FLAG( | |
12712 | p->af_cap | |
12713 | [afi] | |
12714 | [safi], | |
12715 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12716 | json_object_boolean_true_add( | |
12717 | json_sub, | |
12718 | "rxAdvertised"); | |
12719 | else if ( | |
12720 | CHECK_FLAG( | |
12721 | p->af_cap | |
12722 | [afi] | |
12723 | [safi], | |
12724 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12725 | json_object_boolean_true_add( | |
12726 | json_sub, | |
12727 | "rxReceived"); | |
d62a17ae | 12728 | } |
12729 | ||
05c7a1cc QY |
12730 | if (CHECK_FLAG( |
12731 | p->af_cap[afi] | |
12732 | [safi], | |
12733 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12734 | || CHECK_FLAG( | |
12735 | p->af_cap[afi] | |
12736 | [safi], | |
12737 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
12738 | || CHECK_FLAG( | |
12739 | p->af_cap[afi] | |
12740 | [safi], | |
12741 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12742 | || CHECK_FLAG( | |
12743 | p->af_cap[afi] | |
12744 | [safi], | |
12745 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12746 | json_object_object_add( | |
12747 | json_add, | |
12748 | print_store, | |
12749 | json_sub); | |
12750 | else | |
12751 | json_object_free( | |
12752 | json_sub); | |
12753 | } | |
12754 | ||
d62a17ae | 12755 | json_object_object_add( |
12756 | json_cap, "addPath", json_add); | |
12757 | } | |
12758 | ||
12759 | /* Dynamic */ | |
12760 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12761 | || CHECK_FLAG(p->cap, | |
12762 | PEER_CAP_DYNAMIC_ADV)) { | |
12763 | if (CHECK_FLAG(p->cap, | |
12764 | PEER_CAP_DYNAMIC_ADV) | |
12765 | && CHECK_FLAG(p->cap, | |
12766 | PEER_CAP_DYNAMIC_RCV)) | |
12767 | json_object_string_add( | |
12768 | json_cap, "dynamic", | |
12769 | "advertisedAndReceived"); | |
12770 | else if (CHECK_FLAG( | |
12771 | p->cap, | |
12772 | PEER_CAP_DYNAMIC_ADV)) | |
12773 | json_object_string_add( | |
12774 | json_cap, "dynamic", | |
12775 | "advertised"); | |
12776 | else if (CHECK_FLAG( | |
12777 | p->cap, | |
12778 | PEER_CAP_DYNAMIC_RCV)) | |
12779 | json_object_string_add( | |
12780 | json_cap, "dynamic", | |
12781 | "received"); | |
12782 | } | |
12783 | ||
12784 | /* Extended nexthop */ | |
12785 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12786 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12787 | json_object *json_nxt = NULL; | |
12788 | const char *print_store; | |
12789 | ||
12790 | ||
12791 | if (CHECK_FLAG(p->cap, | |
12792 | PEER_CAP_ENHE_ADV) | |
12793 | && CHECK_FLAG(p->cap, | |
12794 | PEER_CAP_ENHE_RCV)) | |
12795 | json_object_string_add( | |
12796 | json_cap, | |
12797 | "extendedNexthop", | |
12798 | "advertisedAndReceived"); | |
12799 | else if (CHECK_FLAG(p->cap, | |
12800 | PEER_CAP_ENHE_ADV)) | |
12801 | json_object_string_add( | |
12802 | json_cap, | |
12803 | "extendedNexthop", | |
12804 | "advertised"); | |
12805 | else if (CHECK_FLAG(p->cap, | |
12806 | PEER_CAP_ENHE_RCV)) | |
12807 | json_object_string_add( | |
12808 | json_cap, | |
12809 | "extendedNexthop", | |
12810 | "received"); | |
12811 | ||
12812 | if (CHECK_FLAG(p->cap, | |
12813 | PEER_CAP_ENHE_RCV)) { | |
12814 | json_nxt = | |
12815 | json_object_new_object(); | |
12816 | ||
12817 | for (safi = SAFI_UNICAST; | |
12818 | safi < SAFI_MAX; safi++) { | |
12819 | if (CHECK_FLAG( | |
12820 | p->af_cap | |
12821 | [AFI_IP] | |
12822 | [safi], | |
12823 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 12824 | print_store = get_afi_safi_str( |
d62a17ae | 12825 | AFI_IP, |
5cb5f4d0 | 12826 | safi, true); |
d62a17ae | 12827 | json_object_string_add( |
12828 | json_nxt, | |
12829 | print_store, | |
54f29523 | 12830 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12831 | } |
12832 | } | |
12833 | json_object_object_add( | |
12834 | json_cap, | |
12835 | "extendedNexthopFamililesByPeer", | |
12836 | json_nxt); | |
12837 | } | |
12838 | } | |
12839 | ||
12840 | /* Route Refresh */ | |
12841 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12842 | || CHECK_FLAG(p->cap, | |
12843 | PEER_CAP_REFRESH_NEW_RCV) | |
12844 | || CHECK_FLAG(p->cap, | |
12845 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12846 | if (CHECK_FLAG(p->cap, | |
12847 | PEER_CAP_REFRESH_ADV) | |
12848 | && (CHECK_FLAG( | |
12849 | p->cap, | |
12850 | PEER_CAP_REFRESH_NEW_RCV) | |
12851 | || CHECK_FLAG( | |
12852 | p->cap, | |
12853 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12854 | if (CHECK_FLAG( | |
12855 | p->cap, | |
12856 | PEER_CAP_REFRESH_OLD_RCV) | |
12857 | && CHECK_FLAG( | |
12858 | p->cap, | |
12859 | PEER_CAP_REFRESH_NEW_RCV)) | |
12860 | json_object_string_add( | |
12861 | json_cap, | |
12862 | "routeRefresh", | |
12863 | "advertisedAndReceivedOldNew"); | |
12864 | else { | |
12865 | if (CHECK_FLAG( | |
12866 | p->cap, | |
12867 | PEER_CAP_REFRESH_OLD_RCV)) | |
12868 | json_object_string_add( | |
12869 | json_cap, | |
12870 | "routeRefresh", | |
12871 | "advertisedAndReceivedOld"); | |
12872 | else | |
12873 | json_object_string_add( | |
12874 | json_cap, | |
12875 | "routeRefresh", | |
12876 | "advertisedAndReceivedNew"); | |
12877 | } | |
12878 | } else if ( | |
12879 | CHECK_FLAG( | |
12880 | p->cap, | |
12881 | PEER_CAP_REFRESH_ADV)) | |
12882 | json_object_string_add( | |
12883 | json_cap, | |
12884 | "routeRefresh", | |
12885 | "advertised"); | |
12886 | else if ( | |
12887 | CHECK_FLAG( | |
12888 | p->cap, | |
12889 | PEER_CAP_REFRESH_NEW_RCV) | |
12890 | || CHECK_FLAG( | |
12891 | p->cap, | |
12892 | PEER_CAP_REFRESH_OLD_RCV)) | |
12893 | json_object_string_add( | |
12894 | json_cap, | |
12895 | "routeRefresh", | |
12896 | "received"); | |
12897 | } | |
12898 | ||
9af52ccf DA |
12899 | /* Enhanced Route Refresh */ |
12900 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
12901 | || CHECK_FLAG(p->cap, | |
12902 | PEER_CAP_ENHANCED_RR_RCV)) { | |
12903 | if (CHECK_FLAG(p->cap, | |
12904 | PEER_CAP_ENHANCED_RR_ADV) | |
12905 | && CHECK_FLAG( | |
12906 | p->cap, | |
12907 | PEER_CAP_ENHANCED_RR_RCV)) | |
12908 | json_object_string_add( | |
12909 | json_cap, | |
12910 | "enhancedRouteRefresh", | |
12911 | "advertisedAndReceived"); | |
12912 | else if ( | |
12913 | CHECK_FLAG( | |
12914 | p->cap, | |
12915 | PEER_CAP_ENHANCED_RR_ADV)) | |
12916 | json_object_string_add( | |
12917 | json_cap, | |
12918 | "enhancedRouteRefresh", | |
12919 | "advertised"); | |
12920 | else if ( | |
12921 | CHECK_FLAG( | |
12922 | p->cap, | |
12923 | PEER_CAP_ENHANCED_RR_RCV)) | |
12924 | json_object_string_add( | |
12925 | json_cap, | |
12926 | "enhancedRouteRefresh", | |
12927 | "received"); | |
12928 | } | |
12929 | ||
d62a17ae | 12930 | /* Multiprotocol Extensions */ |
12931 | json_object *json_multi = NULL; | |
12932 | json_multi = json_object_new_object(); | |
12933 | ||
05c7a1cc QY |
12934 | FOREACH_AFI_SAFI (afi, safi) { |
12935 | if (p->afc_adv[afi][safi] | |
12936 | || p->afc_recv[afi][safi]) { | |
12937 | json_object *json_exten = NULL; | |
12938 | json_exten = | |
12939 | json_object_new_object(); | |
12940 | ||
d62a17ae | 12941 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
12942 | && p->afc_recv[afi][safi]) |
12943 | json_object_boolean_true_add( | |
12944 | json_exten, | |
12945 | "advertisedAndReceived"); | |
12946 | else if (p->afc_adv[afi][safi]) | |
12947 | json_object_boolean_true_add( | |
12948 | json_exten, | |
12949 | "advertised"); | |
12950 | else if (p->afc_recv[afi][safi]) | |
12951 | json_object_boolean_true_add( | |
12952 | json_exten, | |
12953 | "received"); | |
d62a17ae | 12954 | |
05c7a1cc QY |
12955 | json_object_object_add( |
12956 | json_multi, | |
5cb5f4d0 DD |
12957 | get_afi_safi_str(afi, |
12958 | safi, | |
12959 | true), | |
05c7a1cc | 12960 | json_exten); |
d62a17ae | 12961 | } |
12962 | } | |
12963 | json_object_object_add( | |
12964 | json_cap, "multiprotocolExtensions", | |
12965 | json_multi); | |
12966 | ||
d77114b7 | 12967 | /* Hostname capabilities */ |
60466a63 | 12968 | json_object *json_hname = NULL; |
d77114b7 MK |
12969 | |
12970 | json_hname = json_object_new_object(); | |
12971 | ||
12972 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
12973 | json_object_string_add( | |
60466a63 QY |
12974 | json_hname, "advHostName", |
12975 | bgp->peer_self->hostname | |
12976 | ? bgp->peer_self | |
12977 | ->hostname | |
d77114b7 MK |
12978 | : "n/a"); |
12979 | json_object_string_add( | |
60466a63 QY |
12980 | json_hname, "advDomainName", |
12981 | bgp->peer_self->domainname | |
12982 | ? bgp->peer_self | |
12983 | ->domainname | |
d77114b7 MK |
12984 | : "n/a"); |
12985 | } | |
12986 | ||
12987 | ||
12988 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
12989 | json_object_string_add( | |
60466a63 QY |
12990 | json_hname, "rcvHostName", |
12991 | p->hostname ? p->hostname | |
12992 | : "n/a"); | |
d77114b7 | 12993 | json_object_string_add( |
60466a63 QY |
12994 | json_hname, "rcvDomainName", |
12995 | p->domainname ? p->domainname | |
12996 | : "n/a"); | |
d77114b7 MK |
12997 | } |
12998 | ||
60466a63 | 12999 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
13000 | json_hname); |
13001 | ||
d62a17ae | 13002 | /* Gracefull Restart */ |
13003 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
13004 | || CHECK_FLAG(p->cap, | |
13005 | PEER_CAP_RESTART_ADV)) { | |
13006 | if (CHECK_FLAG(p->cap, | |
13007 | PEER_CAP_RESTART_ADV) | |
13008 | && CHECK_FLAG(p->cap, | |
13009 | PEER_CAP_RESTART_RCV)) | |
13010 | json_object_string_add( | |
13011 | json_cap, | |
13012 | "gracefulRestart", | |
13013 | "advertisedAndReceived"); | |
13014 | else if (CHECK_FLAG( | |
13015 | p->cap, | |
13016 | PEER_CAP_RESTART_ADV)) | |
13017 | json_object_string_add( | |
13018 | json_cap, | |
13019 | "gracefulRestartCapability", | |
13020 | "advertised"); | |
13021 | else if (CHECK_FLAG( | |
13022 | p->cap, | |
13023 | PEER_CAP_RESTART_RCV)) | |
13024 | json_object_string_add( | |
13025 | json_cap, | |
13026 | "gracefulRestartCapability", | |
13027 | "received"); | |
13028 | ||
13029 | if (CHECK_FLAG(p->cap, | |
13030 | PEER_CAP_RESTART_RCV)) { | |
13031 | int restart_af_count = 0; | |
13032 | json_object *json_restart = | |
13033 | NULL; | |
13034 | json_restart = | |
13035 | json_object_new_object(); | |
13036 | ||
13037 | json_object_int_add( | |
13038 | json_cap, | |
13039 | "gracefulRestartRemoteTimerMsecs", | |
13040 | p->v_gr_restart * 1000); | |
13041 | ||
05c7a1cc QY |
13042 | FOREACH_AFI_SAFI (afi, safi) { |
13043 | if (CHECK_FLAG( | |
13044 | p->af_cap | |
13045 | [afi] | |
13046 | [safi], | |
13047 | PEER_CAP_RESTART_AF_RCV)) { | |
13048 | json_object * | |
13049 | json_sub = | |
13050 | NULL; | |
13051 | json_sub = | |
13052 | json_object_new_object(); | |
13053 | ||
d62a17ae | 13054 | if (CHECK_FLAG( |
13055 | p->af_cap | |
13056 | [afi] | |
13057 | [safi], | |
05c7a1cc QY |
13058 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13059 | json_object_boolean_true_add( | |
13060 | json_sub, | |
13061 | "preserved"); | |
13062 | restart_af_count++; | |
13063 | json_object_object_add( | |
13064 | json_restart, | |
5cb5f4d0 | 13065 | get_afi_safi_str( |
05c7a1cc | 13066 | afi, |
5cb5f4d0 DD |
13067 | safi, |
13068 | true), | |
05c7a1cc | 13069 | json_sub); |
d62a17ae | 13070 | } |
13071 | } | |
13072 | if (!restart_af_count) { | |
13073 | json_object_string_add( | |
13074 | json_cap, | |
13075 | "addressFamiliesByPeer", | |
13076 | "none"); | |
13077 | json_object_free( | |
13078 | json_restart); | |
13079 | } else | |
13080 | json_object_object_add( | |
13081 | json_cap, | |
13082 | "addressFamiliesByPeer", | |
13083 | json_restart); | |
13084 | } | |
13085 | } | |
13086 | json_object_object_add(json_neigh, | |
13087 | "neighborCapabilities", | |
13088 | json_cap); | |
13089 | } else { | |
13090 | vty_out(vty, " Neighbor capabilities:\n"); | |
13091 | ||
13092 | /* AS4 */ | |
13093 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13094 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13095 | vty_out(vty, " 4 Byte AS:"); | |
13096 | if (CHECK_FLAG(p->cap, | |
13097 | PEER_CAP_AS4_ADV)) | |
13098 | vty_out(vty, " advertised"); | |
13099 | if (CHECK_FLAG(p->cap, | |
13100 | PEER_CAP_AS4_RCV)) | |
13101 | vty_out(vty, " %sreceived", | |
13102 | CHECK_FLAG( | |
13103 | p->cap, | |
13104 | PEER_CAP_AS4_ADV) | |
13105 | ? "and " | |
13106 | : ""); | |
13107 | vty_out(vty, "\n"); | |
13108 | } | |
13109 | ||
ef56aee4 DA |
13110 | /* Extended Message Support */ |
13111 | if (CHECK_FLAG(p->cap, | |
13112 | PEER_CAP_EXTENDED_MESSAGE_RCV) | |
13113 | || CHECK_FLAG( | |
13114 | p->cap, | |
13115 | PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13116 | vty_out(vty, " Extended Message:"); | |
13117 | if (CHECK_FLAG( | |
13118 | p->cap, | |
13119 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13120 | vty_out(vty, " advertised"); | |
13121 | if (CHECK_FLAG( | |
13122 | p->cap, | |
13123 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13124 | vty_out(vty, " %sreceived", | |
13125 | CHECK_FLAG( | |
13126 | p->cap, | |
13127 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13128 | ? "and " | |
13129 | : ""); | |
13130 | vty_out(vty, "\n"); | |
13131 | } | |
13132 | ||
d62a17ae | 13133 | /* AddPath */ |
13134 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13135 | || CHECK_FLAG(p->cap, | |
13136 | PEER_CAP_ADDPATH_ADV)) { | |
13137 | vty_out(vty, " AddPath:\n"); | |
13138 | ||
05c7a1cc QY |
13139 | FOREACH_AFI_SAFI (afi, safi) { |
13140 | if (CHECK_FLAG( | |
13141 | p->af_cap[afi] | |
13142 | [safi], | |
13143 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13144 | || CHECK_FLAG( | |
13145 | p->af_cap[afi] | |
13146 | [safi], | |
13147 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13148 | vty_out(vty, | |
13149 | " %s: TX ", | |
5cb5f4d0 | 13150 | get_afi_safi_str( |
05c7a1cc | 13151 | afi, |
5cb5f4d0 DD |
13152 | safi, |
13153 | false)); | |
05c7a1cc | 13154 | |
d62a17ae | 13155 | if (CHECK_FLAG( |
13156 | p->af_cap | |
13157 | [afi] | |
13158 | [safi], | |
05c7a1cc | 13159 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 13160 | vty_out(vty, |
34c71a4d | 13161 | "advertised"); |
d62a17ae | 13162 | |
05c7a1cc QY |
13163 | if (CHECK_FLAG( |
13164 | p->af_cap | |
13165 | [afi] | |
13166 | [safi], | |
13167 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13168 | vty_out(vty, | |
13169 | "%sreceived", | |
13170 | CHECK_FLAG( | |
13171 | p->af_cap | |
13172 | [afi] | |
13173 | [safi], | |
13174 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13175 | ? " and " | |
13176 | : ""); | |
d62a17ae | 13177 | |
05c7a1cc QY |
13178 | vty_out(vty, "\n"); |
13179 | } | |
d62a17ae | 13180 | |
05c7a1cc QY |
13181 | if (CHECK_FLAG( |
13182 | p->af_cap[afi] | |
13183 | [safi], | |
13184 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13185 | || CHECK_FLAG( | |
13186 | p->af_cap[afi] | |
13187 | [safi], | |
13188 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13189 | vty_out(vty, | |
13190 | " %s: RX ", | |
5cb5f4d0 | 13191 | get_afi_safi_str( |
05c7a1cc | 13192 | afi, |
5cb5f4d0 DD |
13193 | safi, |
13194 | false)); | |
d62a17ae | 13195 | |
13196 | if (CHECK_FLAG( | |
13197 | p->af_cap | |
13198 | [afi] | |
13199 | [safi], | |
05c7a1cc | 13200 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 13201 | vty_out(vty, |
34c71a4d | 13202 | "advertised"); |
d62a17ae | 13203 | |
05c7a1cc QY |
13204 | if (CHECK_FLAG( |
13205 | p->af_cap | |
13206 | [afi] | |
13207 | [safi], | |
13208 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 13209 | vty_out(vty, |
05c7a1cc QY |
13210 | "%sreceived", |
13211 | CHECK_FLAG( | |
13212 | p->af_cap | |
13213 | [afi] | |
13214 | [safi], | |
13215 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13216 | ? " and " | |
13217 | : ""); | |
13218 | ||
13219 | vty_out(vty, "\n"); | |
d62a17ae | 13220 | } |
05c7a1cc | 13221 | } |
d62a17ae | 13222 | } |
13223 | ||
13224 | /* Dynamic */ | |
13225 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13226 | || CHECK_FLAG(p->cap, | |
13227 | PEER_CAP_DYNAMIC_ADV)) { | |
13228 | vty_out(vty, " Dynamic:"); | |
13229 | if (CHECK_FLAG(p->cap, | |
13230 | PEER_CAP_DYNAMIC_ADV)) | |
13231 | vty_out(vty, " advertised"); | |
13232 | if (CHECK_FLAG(p->cap, | |
13233 | PEER_CAP_DYNAMIC_RCV)) | |
13234 | vty_out(vty, " %sreceived", | |
13235 | CHECK_FLAG( | |
13236 | p->cap, | |
13237 | PEER_CAP_DYNAMIC_ADV) | |
13238 | ? "and " | |
13239 | : ""); | |
13240 | vty_out(vty, "\n"); | |
13241 | } | |
13242 | ||
13243 | /* Extended nexthop */ | |
13244 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13245 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13246 | vty_out(vty, " Extended nexthop:"); | |
13247 | if (CHECK_FLAG(p->cap, | |
13248 | PEER_CAP_ENHE_ADV)) | |
13249 | vty_out(vty, " advertised"); | |
13250 | if (CHECK_FLAG(p->cap, | |
13251 | PEER_CAP_ENHE_RCV)) | |
13252 | vty_out(vty, " %sreceived", | |
13253 | CHECK_FLAG( | |
13254 | p->cap, | |
13255 | PEER_CAP_ENHE_ADV) | |
13256 | ? "and " | |
13257 | : ""); | |
13258 | vty_out(vty, "\n"); | |
13259 | ||
13260 | if (CHECK_FLAG(p->cap, | |
13261 | PEER_CAP_ENHE_RCV)) { | |
13262 | vty_out(vty, | |
13263 | " Address families by peer:\n "); | |
13264 | for (safi = SAFI_UNICAST; | |
13265 | safi < SAFI_MAX; safi++) | |
13266 | if (CHECK_FLAG( | |
13267 | p->af_cap | |
13268 | [AFI_IP] | |
13269 | [safi], | |
13270 | PEER_CAP_ENHE_AF_RCV)) | |
13271 | vty_out(vty, | |
13272 | " %s\n", | |
5cb5f4d0 | 13273 | get_afi_safi_str( |
d62a17ae | 13274 | AFI_IP, |
5cb5f4d0 DD |
13275 | safi, |
13276 | false)); | |
d62a17ae | 13277 | } |
13278 | } | |
13279 | ||
13280 | /* Route Refresh */ | |
13281 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13282 | || CHECK_FLAG(p->cap, | |
13283 | PEER_CAP_REFRESH_NEW_RCV) | |
13284 | || CHECK_FLAG(p->cap, | |
13285 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13286 | vty_out(vty, " Route refresh:"); | |
13287 | if (CHECK_FLAG(p->cap, | |
13288 | PEER_CAP_REFRESH_ADV)) | |
13289 | vty_out(vty, " advertised"); | |
13290 | if (CHECK_FLAG(p->cap, | |
13291 | PEER_CAP_REFRESH_NEW_RCV) | |
13292 | || CHECK_FLAG( | |
13293 | p->cap, | |
13294 | PEER_CAP_REFRESH_OLD_RCV)) | |
13295 | vty_out(vty, " %sreceived(%s)", | |
13296 | CHECK_FLAG( | |
13297 | p->cap, | |
13298 | PEER_CAP_REFRESH_ADV) | |
13299 | ? "and " | |
13300 | : "", | |
13301 | (CHECK_FLAG( | |
13302 | p->cap, | |
13303 | PEER_CAP_REFRESH_OLD_RCV) | |
13304 | && CHECK_FLAG( | |
13305 | p->cap, | |
13306 | PEER_CAP_REFRESH_NEW_RCV)) | |
13307 | ? "old & new" | |
13308 | : CHECK_FLAG( | |
13309 | p->cap, | |
13310 | PEER_CAP_REFRESH_OLD_RCV) | |
13311 | ? "old" | |
13312 | : "new"); | |
13313 | ||
13314 | vty_out(vty, "\n"); | |
13315 | } | |
13316 | ||
9af52ccf DA |
13317 | /* Enhanced Route Refresh */ |
13318 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
13319 | || CHECK_FLAG(p->cap, | |
13320 | PEER_CAP_ENHANCED_RR_RCV)) { | |
13321 | vty_out(vty, | |
13322 | " Enhanced Route Refresh:"); | |
13323 | if (CHECK_FLAG( | |
13324 | p->cap, | |
13325 | PEER_CAP_ENHANCED_RR_ADV)) | |
13326 | vty_out(vty, " advertised"); | |
13327 | if (CHECK_FLAG( | |
13328 | p->cap, | |
13329 | PEER_CAP_ENHANCED_RR_RCV)) | |
13330 | vty_out(vty, " %sreceived", | |
13331 | CHECK_FLAG( | |
13332 | p->cap, | |
13333 | PEER_CAP_REFRESH_ADV) | |
13334 | ? "and " | |
13335 | : ""); | |
13336 | vty_out(vty, "\n"); | |
13337 | } | |
13338 | ||
d62a17ae | 13339 | /* Multiprotocol Extensions */ |
05c7a1cc QY |
13340 | FOREACH_AFI_SAFI (afi, safi) |
13341 | if (p->afc_adv[afi][safi] | |
13342 | || p->afc_recv[afi][safi]) { | |
13343 | vty_out(vty, | |
13344 | " Address Family %s:", | |
5cb5f4d0 DD |
13345 | get_afi_safi_str( |
13346 | afi, | |
13347 | safi, | |
13348 | false)); | |
05c7a1cc | 13349 | if (p->afc_adv[afi][safi]) |
d62a17ae | 13350 | vty_out(vty, |
05c7a1cc QY |
13351 | " advertised"); |
13352 | if (p->afc_recv[afi][safi]) | |
13353 | vty_out(vty, | |
13354 | " %sreceived", | |
13355 | p->afc_adv[afi] | |
13356 | [safi] | |
13357 | ? "and " | |
13358 | : ""); | |
13359 | vty_out(vty, "\n"); | |
13360 | } | |
d62a17ae | 13361 | |
13362 | /* Hostname capability */ | |
60466a63 | 13363 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
13364 | |
13365 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
13366 | vty_out(vty, |
13367 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
13368 | bgp->peer_self->hostname |
13369 | ? bgp->peer_self | |
13370 | ->hostname | |
d77114b7 | 13371 | : "n/a", |
60466a63 QY |
13372 | bgp->peer_self->domainname |
13373 | ? bgp->peer_self | |
13374 | ->domainname | |
d77114b7 MK |
13375 | : "n/a"); |
13376 | } else { | |
13377 | vty_out(vty, " not advertised"); | |
d62a17ae | 13378 | } |
13379 | ||
d77114b7 | 13380 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
13381 | vty_out(vty, |
13382 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
13383 | p->hostname ? p->hostname |
13384 | : "n/a", | |
13385 | p->domainname ? p->domainname | |
13386 | : "n/a"); | |
d77114b7 MK |
13387 | } else { |
13388 | vty_out(vty, " not received"); | |
13389 | } | |
13390 | ||
13391 | vty_out(vty, "\n"); | |
13392 | ||
61bfbd51 | 13393 | /* Graceful Restart */ |
d62a17ae | 13394 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
13395 | || CHECK_FLAG(p->cap, | |
13396 | PEER_CAP_RESTART_ADV)) { | |
13397 | vty_out(vty, | |
61bfbd51 | 13398 | " Graceful Restart Capability:"); |
d62a17ae | 13399 | if (CHECK_FLAG(p->cap, |
13400 | PEER_CAP_RESTART_ADV)) | |
13401 | vty_out(vty, " advertised"); | |
13402 | if (CHECK_FLAG(p->cap, | |
13403 | PEER_CAP_RESTART_RCV)) | |
13404 | vty_out(vty, " %sreceived", | |
13405 | CHECK_FLAG( | |
13406 | p->cap, | |
13407 | PEER_CAP_RESTART_ADV) | |
13408 | ? "and " | |
13409 | : ""); | |
13410 | vty_out(vty, "\n"); | |
13411 | ||
13412 | if (CHECK_FLAG(p->cap, | |
13413 | PEER_CAP_RESTART_RCV)) { | |
13414 | int restart_af_count = 0; | |
13415 | ||
13416 | vty_out(vty, | |
13417 | " Remote Restart timer is %d seconds\n", | |
13418 | p->v_gr_restart); | |
13419 | vty_out(vty, | |
13420 | " Address families by peer:\n "); | |
13421 | ||
05c7a1cc QY |
13422 | FOREACH_AFI_SAFI (afi, safi) |
13423 | if (CHECK_FLAG( | |
13424 | p->af_cap | |
13425 | [afi] | |
13426 | [safi], | |
13427 | PEER_CAP_RESTART_AF_RCV)) { | |
13428 | vty_out(vty, | |
13429 | "%s%s(%s)", | |
13430 | restart_af_count | |
13431 | ? ", " | |
13432 | : "", | |
5cb5f4d0 | 13433 | get_afi_safi_str( |
05c7a1cc | 13434 | afi, |
5cb5f4d0 DD |
13435 | safi, |
13436 | false), | |
05c7a1cc QY |
13437 | CHECK_FLAG( |
13438 | p->af_cap | |
13439 | [afi] | |
13440 | [safi], | |
13441 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13442 | ? "preserved" | |
13443 | : "not preserved"); | |
13444 | restart_af_count++; | |
13445 | } | |
d62a17ae | 13446 | if (!restart_af_count) |
13447 | vty_out(vty, "none"); | |
13448 | vty_out(vty, "\n"); | |
13449 | } | |
2986cac2 | 13450 | } /* Gracefull Restart */ |
d62a17ae | 13451 | } |
13452 | } | |
13453 | } | |
13454 | ||
13455 | /* graceful restart information */ | |
d62a17ae | 13456 | json_object *json_grace = NULL; |
13457 | json_object *json_grace_send = NULL; | |
13458 | json_object *json_grace_recv = NULL; | |
13459 | int eor_send_af_count = 0; | |
13460 | int eor_receive_af_count = 0; | |
13461 | ||
13462 | if (use_json) { | |
13463 | json_grace = json_object_new_object(); | |
13464 | json_grace_send = json_object_new_object(); | |
13465 | json_grace_recv = json_object_new_object(); | |
13466 | ||
feb17238 | 13467 | if ((peer_established(p)) |
36235319 | 13468 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
05c7a1cc QY |
13469 | FOREACH_AFI_SAFI (afi, safi) { |
13470 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 13471 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
13472 | json_object_boolean_true_add( |
13473 | json_grace_send, | |
5cb5f4d0 DD |
13474 | get_afi_safi_str(afi, |
13475 | safi, | |
13476 | true)); | |
05c7a1cc | 13477 | eor_send_af_count++; |
d62a17ae | 13478 | } |
13479 | } | |
05c7a1cc QY |
13480 | FOREACH_AFI_SAFI (afi, safi) { |
13481 | if (CHECK_FLAG( | |
36235319 QY |
13482 | p->af_sflags[afi][safi], |
13483 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
13484 | json_object_boolean_true_add( |
13485 | json_grace_recv, | |
5cb5f4d0 DD |
13486 | get_afi_safi_str(afi, |
13487 | safi, | |
13488 | true)); | |
05c7a1cc | 13489 | eor_receive_af_count++; |
d62a17ae | 13490 | } |
13491 | } | |
13492 | } | |
36235319 QY |
13493 | json_object_object_add(json_grace, "endOfRibSend", |
13494 | json_grace_send); | |
13495 | json_object_object_add(json_grace, "endOfRibRecv", | |
13496 | json_grace_recv); | |
d62a17ae | 13497 | |
d62a17ae | 13498 | |
13499 | if (p->t_gr_restart) | |
13500 | json_object_int_add(json_grace, | |
13501 | "gracefulRestartTimerMsecs", | |
13502 | thread_timer_remain_second( | |
13503 | p->t_gr_restart) | |
13504 | * 1000); | |
13505 | ||
13506 | if (p->t_gr_stale) | |
13507 | json_object_int_add( | |
13508 | json_grace, | |
13509 | "gracefulStalepathTimerMsecs", | |
13510 | thread_timer_remain_second( | |
13511 | p->t_gr_stale) | |
13512 | * 1000); | |
2986cac2 | 13513 | /* more gr info in new format */ |
13514 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 13515 | json_grace); |
d62a17ae | 13516 | json_object_object_add( |
13517 | json_neigh, "gracefulRestartInfo", json_grace); | |
13518 | } else { | |
2089dd80 | 13519 | vty_out(vty, " Graceful restart information:\n"); |
feb17238 | 13520 | if ((peer_established(p)) |
36235319 | 13521 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
2986cac2 | 13522 | |
d62a17ae | 13523 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
13524 | FOREACH_AFI_SAFI (afi, safi) { |
13525 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13526 | PEER_STATUS_EOR_SEND)) { | |
13527 | vty_out(vty, "%s%s", | |
13528 | eor_send_af_count ? ", " | |
13529 | : "", | |
36235319 QY |
13530 | get_afi_safi_str( |
13531 | afi, safi, | |
13532 | false)); | |
05c7a1cc | 13533 | eor_send_af_count++; |
d62a17ae | 13534 | } |
13535 | } | |
13536 | vty_out(vty, "\n"); | |
13537 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
13538 | FOREACH_AFI_SAFI (afi, safi) { |
13539 | if (CHECK_FLAG( | |
13540 | p->af_sflags[afi][safi], | |
13541 | PEER_STATUS_EOR_RECEIVED)) { | |
13542 | vty_out(vty, "%s%s", | |
13543 | eor_receive_af_count | |
13544 | ? ", " | |
13545 | : "", | |
5cb5f4d0 DD |
13546 | get_afi_safi_str(afi, |
13547 | safi, | |
13548 | false)); | |
05c7a1cc | 13549 | eor_receive_af_count++; |
d62a17ae | 13550 | } |
13551 | } | |
13552 | vty_out(vty, "\n"); | |
13553 | } | |
13554 | ||
13555 | if (p->t_gr_restart) | |
13556 | vty_out(vty, | |
13557 | " The remaining time of restart timer is %ld\n", | |
13558 | thread_timer_remain_second( | |
13559 | p->t_gr_restart)); | |
13560 | ||
13561 | if (p->t_gr_stale) | |
13562 | vty_out(vty, | |
13563 | " The remaining time of stalepath timer is %ld\n", | |
13564 | thread_timer_remain_second( | |
13565 | p->t_gr_stale)); | |
2986cac2 | 13566 | |
13567 | /* more gr info in new format */ | |
13568 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 13569 | } |
2986cac2 | 13570 | |
d62a17ae | 13571 | if (use_json) { |
13572 | json_object *json_stat = NULL; | |
13573 | json_stat = json_object_new_object(); | |
13574 | /* Packet counts. */ | |
43aa5965 QY |
13575 | |
13576 | atomic_size_t outq_count, inq_count; | |
13577 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13578 | memory_order_relaxed); | |
13579 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13580 | memory_order_relaxed); | |
13581 | ||
13582 | json_object_int_add(json_stat, "depthInq", | |
13583 | (unsigned long)inq_count); | |
d62a17ae | 13584 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13585 | (unsigned long)outq_count); |
0112e9e0 QY |
13586 | json_object_int_add(json_stat, "opensSent", |
13587 | atomic_load_explicit(&p->open_out, | |
13588 | memory_order_relaxed)); | |
13589 | json_object_int_add(json_stat, "opensRecv", | |
13590 | atomic_load_explicit(&p->open_in, | |
13591 | memory_order_relaxed)); | |
d62a17ae | 13592 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13593 | atomic_load_explicit(&p->notify_out, |
13594 | memory_order_relaxed)); | |
d62a17ae | 13595 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13596 | atomic_load_explicit(&p->notify_in, |
13597 | memory_order_relaxed)); | |
13598 | json_object_int_add(json_stat, "updatesSent", | |
13599 | atomic_load_explicit(&p->update_out, | |
13600 | memory_order_relaxed)); | |
13601 | json_object_int_add(json_stat, "updatesRecv", | |
13602 | atomic_load_explicit(&p->update_in, | |
13603 | memory_order_relaxed)); | |
d62a17ae | 13604 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13605 | atomic_load_explicit(&p->keepalive_out, |
13606 | memory_order_relaxed)); | |
d62a17ae | 13607 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13608 | atomic_load_explicit(&p->keepalive_in, |
13609 | memory_order_relaxed)); | |
d62a17ae | 13610 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13611 | atomic_load_explicit(&p->refresh_out, |
13612 | memory_order_relaxed)); | |
d62a17ae | 13613 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13614 | atomic_load_explicit(&p->refresh_in, |
13615 | memory_order_relaxed)); | |
d62a17ae | 13616 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13617 | atomic_load_explicit(&p->dynamic_cap_out, |
13618 | memory_order_relaxed)); | |
d62a17ae | 13619 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13620 | atomic_load_explicit(&p->dynamic_cap_in, |
13621 | memory_order_relaxed)); | |
13622 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13623 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13624 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13625 | } else { | |
43aa5965 QY |
13626 | atomic_size_t outq_count, inq_count; |
13627 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13628 | memory_order_relaxed); | |
13629 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13630 | memory_order_relaxed); | |
13631 | ||
d62a17ae | 13632 | /* Packet counts. */ |
13633 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13634 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13635 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13636 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
13637 | vty_out(vty, " Opens: %10d %10d\n", |
13638 | atomic_load_explicit(&p->open_out, | |
13639 | memory_order_relaxed), | |
13640 | atomic_load_explicit(&p->open_in, | |
13641 | memory_order_relaxed)); | |
13642 | vty_out(vty, " Notifications: %10d %10d\n", | |
13643 | atomic_load_explicit(&p->notify_out, | |
13644 | memory_order_relaxed), | |
13645 | atomic_load_explicit(&p->notify_in, | |
13646 | memory_order_relaxed)); | |
13647 | vty_out(vty, " Updates: %10d %10d\n", | |
13648 | atomic_load_explicit(&p->update_out, | |
13649 | memory_order_relaxed), | |
13650 | atomic_load_explicit(&p->update_in, | |
13651 | memory_order_relaxed)); | |
13652 | vty_out(vty, " Keepalives: %10d %10d\n", | |
13653 | atomic_load_explicit(&p->keepalive_out, | |
13654 | memory_order_relaxed), | |
13655 | atomic_load_explicit(&p->keepalive_in, | |
13656 | memory_order_relaxed)); | |
13657 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
13658 | atomic_load_explicit(&p->refresh_out, | |
13659 | memory_order_relaxed), | |
13660 | atomic_load_explicit(&p->refresh_in, | |
13661 | memory_order_relaxed)); | |
d62a17ae | 13662 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
13663 | atomic_load_explicit(&p->dynamic_cap_out, |
13664 | memory_order_relaxed), | |
13665 | atomic_load_explicit(&p->dynamic_cap_in, | |
13666 | memory_order_relaxed)); | |
13667 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
13668 | PEER_TOTAL_RX(p)); | |
d62a17ae | 13669 | } |
13670 | ||
13671 | if (use_json) { | |
13672 | /* advertisement-interval */ | |
13673 | json_object_int_add(json_neigh, | |
13674 | "minBtwnAdvertisementRunsTimerMsecs", | |
13675 | p->v_routeadv * 1000); | |
13676 | ||
13677 | /* Update-source. */ | |
13678 | if (p->update_if || p->update_source) { | |
13679 | if (p->update_if) | |
13680 | json_object_string_add(json_neigh, | |
13681 | "updateSource", | |
13682 | p->update_if); | |
13683 | else if (p->update_source) | |
13684 | json_object_string_add( | |
13685 | json_neigh, "updateSource", | |
13686 | sockunion2str(p->update_source, buf1, | |
13687 | SU_ADDRSTRLEN)); | |
13688 | } | |
13689 | } else { | |
13690 | /* advertisement-interval */ | |
13691 | vty_out(vty, | |
13692 | " Minimum time between advertisement runs is %d seconds\n", | |
13693 | p->v_routeadv); | |
13694 | ||
13695 | /* Update-source. */ | |
13696 | if (p->update_if || p->update_source) { | |
13697 | vty_out(vty, " Update source is "); | |
13698 | if (p->update_if) | |
13699 | vty_out(vty, "%s", p->update_if); | |
13700 | else if (p->update_source) | |
13701 | vty_out(vty, "%s", | |
13702 | sockunion2str(p->update_source, buf1, | |
13703 | SU_ADDRSTRLEN)); | |
13704 | vty_out(vty, "\n"); | |
13705 | } | |
13706 | ||
13707 | vty_out(vty, "\n"); | |
13708 | } | |
13709 | ||
13710 | /* Address Family Information */ | |
13711 | json_object *json_hold = NULL; | |
13712 | ||
13713 | if (use_json) | |
13714 | json_hold = json_object_new_object(); | |
13715 | ||
05c7a1cc QY |
13716 | FOREACH_AFI_SAFI (afi, safi) |
13717 | if (p->afc[afi][safi]) | |
13718 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13719 | json_hold); | |
d62a17ae | 13720 | |
13721 | if (use_json) { | |
13722 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13723 | json_hold); | |
13724 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13725 | p->established); | |
13726 | json_object_int_add(json_neigh, "connectionsDropped", | |
13727 | p->dropped); | |
13728 | } else | |
13729 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13730 | p->established, p->dropped); | |
13731 | ||
13732 | if (!p->last_reset) { | |
13733 | if (use_json) | |
13734 | json_object_string_add(json_neigh, "lastReset", | |
13735 | "never"); | |
13736 | else | |
13737 | vty_out(vty, " Last reset never\n"); | |
13738 | } else { | |
13739 | if (use_json) { | |
13740 | time_t uptime; | |
a2700b50 | 13741 | struct tm tm; |
d62a17ae | 13742 | |
13743 | uptime = bgp_clock(); | |
13744 | uptime -= p->resettime; | |
a2700b50 MS |
13745 | gmtime_r(&uptime, &tm); |
13746 | ||
d62a17ae | 13747 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13748 | (tm.tm_sec * 1000) |
13749 | + (tm.tm_min * 60000) | |
13750 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13751 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13752 | } else { |
13753 | vty_out(vty, " Last reset %s, ", | |
13754 | peer_uptime(p->resettime, timebuf, | |
13755 | BGP_UPTIME_LEN, 0, NULL)); | |
13756 | ||
3577f1c5 | 13757 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13758 | if (p->last_reset_cause_size) { |
13759 | msg = p->last_reset_cause; | |
13760 | vty_out(vty, | |
13761 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13762 | for (i = 1; i <= p->last_reset_cause_size; | |
13763 | i++) { | |
13764 | vty_out(vty, "%02X", *msg++); | |
13765 | ||
13766 | if (i != p->last_reset_cause_size) { | |
13767 | if (i % 16 == 0) { | |
13768 | vty_out(vty, "\n "); | |
13769 | } else if (i % 4 == 0) { | |
13770 | vty_out(vty, " "); | |
13771 | } | |
13772 | } | |
13773 | } | |
13774 | vty_out(vty, "\n"); | |
13775 | } | |
13776 | } | |
13777 | } | |
13778 | ||
13779 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13780 | if (use_json) | |
13781 | json_object_boolean_true_add(json_neigh, | |
13782 | "prefixesConfigExceedMax"); | |
13783 | else | |
13784 | vty_out(vty, | |
13785 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13786 | ||
13787 | if (p->t_pmax_restart) { | |
13788 | if (use_json) { | |
13789 | json_object_boolean_true_add( | |
13790 | json_neigh, "reducePrefixNumFrom"); | |
13791 | json_object_int_add(json_neigh, | |
13792 | "restartInTimerMsec", | |
13793 | thread_timer_remain_second( | |
13794 | p->t_pmax_restart) | |
13795 | * 1000); | |
13796 | } else | |
13797 | vty_out(vty, | |
13798 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13799 | p->host, thread_timer_remain_second( |
13800 | p->t_pmax_restart)); | |
d62a17ae | 13801 | } else { |
13802 | if (use_json) | |
13803 | json_object_boolean_true_add( | |
13804 | json_neigh, | |
13805 | "reducePrefixNumAndClearIpBgp"); | |
13806 | else | |
13807 | vty_out(vty, | |
13808 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13809 | p->host); | |
13810 | } | |
13811 | } | |
13812 | ||
13813 | /* EBGP Multihop and GTSM */ | |
13814 | if (p->sort != BGP_PEER_IBGP) { | |
13815 | if (use_json) { | |
e2521429 | 13816 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13817 | json_object_int_add(json_neigh, |
13818 | "externalBgpNbrMaxHopsAway", | |
13819 | p->gtsm_hops); | |
c8d6f0d6 | 13820 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13821 | json_object_int_add(json_neigh, |
13822 | "externalBgpNbrMaxHopsAway", | |
13823 | p->ttl); | |
13824 | } else { | |
e2521429 | 13825 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13826 | vty_out(vty, |
13827 | " External BGP neighbor may be up to %d hops away.\n", | |
13828 | p->gtsm_hops); | |
c8d6f0d6 | 13829 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13830 | vty_out(vty, |
13831 | " External BGP neighbor may be up to %d hops away.\n", | |
13832 | p->ttl); | |
13833 | } | |
13834 | } else { | |
e2521429 | 13835 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 13836 | if (use_json) |
13837 | json_object_int_add(json_neigh, | |
13838 | "internalBgpNbrMaxHopsAway", | |
13839 | p->gtsm_hops); | |
13840 | else | |
13841 | vty_out(vty, | |
13842 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13843 | p->gtsm_hops); | |
13844 | } | |
13845 | } | |
13846 | ||
13847 | /* Local address. */ | |
13848 | if (p->su_local) { | |
13849 | if (use_json) { | |
13850 | json_object_string_add(json_neigh, "hostLocal", | |
13851 | sockunion2str(p->su_local, buf1, | |
13852 | SU_ADDRSTRLEN)); | |
13853 | json_object_int_add(json_neigh, "portLocal", | |
13854 | ntohs(p->su_local->sin.sin_port)); | |
13855 | } else | |
13856 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13857 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13858 | ntohs(p->su_local->sin.sin_port)); | |
13859 | } | |
13860 | ||
13861 | /* Remote address. */ | |
13862 | if (p->su_remote) { | |
13863 | if (use_json) { | |
13864 | json_object_string_add(json_neigh, "hostForeign", | |
13865 | sockunion2str(p->su_remote, buf1, | |
13866 | SU_ADDRSTRLEN)); | |
13867 | json_object_int_add(json_neigh, "portForeign", | |
13868 | ntohs(p->su_remote->sin.sin_port)); | |
13869 | } else | |
13870 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13871 | sockunion2str(p->su_remote, buf1, | |
13872 | SU_ADDRSTRLEN), | |
13873 | ntohs(p->su_remote->sin.sin_port)); | |
13874 | } | |
13875 | ||
13876 | /* Nexthop display. */ | |
13877 | if (p->su_local) { | |
13878 | if (use_json) { | |
13879 | json_object_string_add(json_neigh, "nexthop", | |
13880 | inet_ntop(AF_INET, | |
13881 | &p->nexthop.v4, buf1, | |
13882 | sizeof(buf1))); | |
13883 | json_object_string_add(json_neigh, "nexthopGlobal", | |
13884 | inet_ntop(AF_INET6, | |
13885 | &p->nexthop.v6_global, | |
13886 | buf1, sizeof(buf1))); | |
13887 | json_object_string_add(json_neigh, "nexthopLocal", | |
13888 | inet_ntop(AF_INET6, | |
13889 | &p->nexthop.v6_local, | |
13890 | buf1, sizeof(buf1))); | |
13891 | if (p->shared_network) | |
13892 | json_object_string_add(json_neigh, | |
13893 | "bgpConnection", | |
13894 | "sharedNetwork"); | |
13895 | else | |
13896 | json_object_string_add(json_neigh, | |
13897 | "bgpConnection", | |
13898 | "nonSharedNetwork"); | |
13899 | } else { | |
13900 | vty_out(vty, "Nexthop: %s\n", | |
13901 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13902 | sizeof(buf1))); | |
13903 | vty_out(vty, "Nexthop global: %s\n", | |
13904 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13905 | sizeof(buf1))); | |
13906 | vty_out(vty, "Nexthop local: %s\n", | |
13907 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13908 | sizeof(buf1))); | |
13909 | vty_out(vty, "BGP connection: %s\n", | |
13910 | p->shared_network ? "shared network" | |
13911 | : "non shared network"); | |
13912 | } | |
13913 | } | |
13914 | ||
13915 | /* Timer information. */ | |
13916 | if (use_json) { | |
13917 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13918 | p->v_connect); | |
feb17238 | 13919 | if (peer_established(p) && p->rtt) |
d62a17ae | 13920 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
13921 | p->rtt); | |
13922 | if (p->t_start) | |
13923 | json_object_int_add( | |
13924 | json_neigh, "nextStartTimerDueInMsecs", | |
13925 | thread_timer_remain_second(p->t_start) * 1000); | |
13926 | if (p->t_connect) | |
13927 | json_object_int_add( | |
13928 | json_neigh, "nextConnectTimerDueInMsecs", | |
13929 | thread_timer_remain_second(p->t_connect) | |
13930 | * 1000); | |
13931 | if (p->t_routeadv) { | |
13932 | json_object_int_add(json_neigh, "mraiInterval", | |
13933 | p->v_routeadv); | |
13934 | json_object_int_add( | |
13935 | json_neigh, "mraiTimerExpireInMsecs", | |
13936 | thread_timer_remain_second(p->t_routeadv) | |
13937 | * 1000); | |
13938 | } | |
13939 | if (p->password) | |
13940 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13941 | 1); | |
13942 | ||
13943 | if (p->t_read) | |
13944 | json_object_string_add(json_neigh, "readThread", "on"); | |
13945 | else | |
13946 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13947 | |
13948 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13949 | json_object_string_add(json_neigh, "writeThread", "on"); |
13950 | else | |
13951 | json_object_string_add(json_neigh, "writeThread", | |
13952 | "off"); | |
13953 | } else { | |
13954 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13955 | p->v_connect); | |
feb17238 | 13956 | if (peer_established(p) && p->rtt) |
d62a17ae | 13957 | vty_out(vty, "Estimated round trip time: %d ms\n", |
13958 | p->rtt); | |
13959 | if (p->t_start) | |
13960 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13961 | thread_timer_remain_second(p->t_start)); | |
13962 | if (p->t_connect) | |
13963 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13964 | thread_timer_remain_second(p->t_connect)); | |
13965 | if (p->t_routeadv) | |
13966 | vty_out(vty, | |
13967 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13968 | p->v_routeadv, | |
13969 | thread_timer_remain_second(p->t_routeadv)); | |
13970 | if (p->password) | |
13971 | vty_out(vty, "Peer Authentication Enabled\n"); | |
13972 | ||
cac9e917 | 13973 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
13974 | p->t_read ? "on" : "off", |
13975 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
13976 | ? "on" | |
cac9e917 | 13977 | : "off", p->fd); |
d62a17ae | 13978 | } |
13979 | ||
13980 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
13981 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
13982 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
13983 | ||
13984 | if (!use_json) | |
13985 | vty_out(vty, "\n"); | |
13986 | ||
13987 | /* BFD information. */ | |
21bfce98 RZ |
13988 | if (p->bfd_config) |
13989 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 13990 | |
13991 | if (use_json) { | |
13992 | if (p->conf_if) /* Configured interface name. */ | |
13993 | json_object_object_add(json, p->conf_if, json_neigh); | |
13994 | else /* Configured IP address. */ | |
13995 | json_object_object_add(json, p->host, json_neigh); | |
13996 | } | |
13997 | } | |
13998 | ||
36235319 QY |
13999 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14000 | enum show_type type, | |
14001 | union sockunion *su, | |
14002 | const char *conf_if, afi_t afi, | |
74a630b6 | 14003 | bool use_json) |
2986cac2 | 14004 | { |
14005 | struct listnode *node, *nnode; | |
14006 | struct peer *peer; | |
14007 | int find = 0; | |
14008 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14009 | json_object *json = NULL; |
2986cac2 | 14010 | json_object *json_neighbor = NULL; |
14011 | ||
74a630b6 NT |
14012 | if (use_json) { |
14013 | json = json_object_new_object(); | |
14014 | json_neighbor = json_object_new_object(); | |
14015 | } | |
14016 | ||
2986cac2 | 14017 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14018 | ||
14019 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14020 | continue; | |
14021 | ||
14022 | if ((peer->afc[afi][safi]) == 0) | |
14023 | continue; | |
14024 | ||
2ba1fe69 | 14025 | if (type == show_all) { |
2986cac2 | 14026 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14027 | json_neighbor); |
2986cac2 | 14028 | |
74a630b6 | 14029 | if (use_json) { |
13909c4f DS |
14030 | json_object_object_add(json, peer->host, |
14031 | json_neighbor); | |
74a630b6 NT |
14032 | json_neighbor = NULL; |
14033 | } | |
2986cac2 | 14034 | |
2ba1fe69 | 14035 | } else if (type == show_peer) { |
2986cac2 | 14036 | if (conf_if) { |
14037 | if ((peer->conf_if | |
13909c4f DS |
14038 | && !strcmp(peer->conf_if, conf_if)) |
14039 | || (peer->hostname | |
2986cac2 | 14040 | && !strcmp(peer->hostname, conf_if))) { |
14041 | find = 1; | |
13909c4f DS |
14042 | bgp_show_peer_gr_status(vty, peer, |
14043 | use_json, | |
14044 | json_neighbor); | |
2986cac2 | 14045 | } |
14046 | } else { | |
14047 | if (sockunion_same(&peer->su, su)) { | |
14048 | find = 1; | |
13909c4f DS |
14049 | bgp_show_peer_gr_status(vty, peer, |
14050 | use_json, | |
14051 | json_neighbor); | |
2986cac2 | 14052 | } |
14053 | } | |
13909c4f DS |
14054 | if (use_json && find) |
14055 | json_object_object_add(json, peer->host, | |
14056 | json_neighbor); | |
2986cac2 | 14057 | } |
14058 | ||
74a630b6 NT |
14059 | if (find) { |
14060 | json_neighbor = NULL; | |
2986cac2 | 14061 | break; |
74a630b6 | 14062 | } |
2986cac2 | 14063 | } |
14064 | ||
14065 | if (type == show_peer && !find) { | |
14066 | if (use_json) | |
13909c4f | 14067 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14068 | else |
14069 | vty_out(vty, "%% No such neighbor\n"); | |
14070 | } | |
14071 | if (use_json) { | |
13909c4f DS |
14072 | vty_out(vty, "%s\n", |
14073 | json_object_to_json_string_ext( | |
14074 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
14075 | |
14076 | if (json_neighbor) | |
14077 | json_object_free(json_neighbor); | |
14078 | json_object_free(json); | |
2986cac2 | 14079 | } else { |
14080 | vty_out(vty, "\n"); | |
14081 | } | |
14082 | ||
14083 | return CMD_SUCCESS; | |
14084 | } | |
14085 | ||
d62a17ae | 14086 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14087 | enum show_type type, union sockunion *su, | |
9f049418 | 14088 | const char *conf_if, bool use_json, |
d62a17ae | 14089 | json_object *json) |
14090 | { | |
14091 | struct listnode *node, *nnode; | |
14092 | struct peer *peer; | |
14093 | int find = 0; | |
9f049418 | 14094 | bool nbr_output = false; |
d1927ebe AS |
14095 | afi_t afi = AFI_MAX; |
14096 | safi_t safi = SAFI_MAX; | |
14097 | ||
14098 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14099 | afi = AFI_IP; | |
14100 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14101 | afi = AFI_IP6; | |
14102 | } | |
d62a17ae | 14103 | |
14104 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14105 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14106 | continue; | |
14107 | ||
14108 | switch (type) { | |
14109 | case show_all: | |
14110 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14111 | nbr_output = true; |
d62a17ae | 14112 | break; |
14113 | case show_peer: | |
14114 | if (conf_if) { | |
14115 | if ((peer->conf_if | |
14116 | && !strcmp(peer->conf_if, conf_if)) | |
14117 | || (peer->hostname | |
14118 | && !strcmp(peer->hostname, conf_if))) { | |
14119 | find = 1; | |
14120 | bgp_show_peer(vty, peer, use_json, | |
14121 | json); | |
14122 | } | |
14123 | } else { | |
14124 | if (sockunion_same(&peer->su, su)) { | |
14125 | find = 1; | |
14126 | bgp_show_peer(vty, peer, use_json, | |
14127 | json); | |
14128 | } | |
14129 | } | |
14130 | break; | |
d1927ebe AS |
14131 | case show_ipv4_peer: |
14132 | case show_ipv6_peer: | |
14133 | FOREACH_SAFI (safi) { | |
14134 | if (peer->afc[afi][safi]) { | |
14135 | if (conf_if) { | |
14136 | if ((peer->conf_if | |
14137 | && !strcmp(peer->conf_if, conf_if)) | |
14138 | || (peer->hostname | |
14139 | && !strcmp(peer->hostname, conf_if))) { | |
14140 | find = 1; | |
14141 | bgp_show_peer(vty, peer, use_json, | |
14142 | json); | |
14143 | break; | |
14144 | } | |
14145 | } else { | |
14146 | if (sockunion_same(&peer->su, su)) { | |
14147 | find = 1; | |
14148 | bgp_show_peer(vty, peer, use_json, | |
14149 | json); | |
14150 | break; | |
14151 | } | |
14152 | } | |
14153 | } | |
14154 | } | |
14155 | break; | |
14156 | case show_ipv4_all: | |
14157 | case show_ipv6_all: | |
14158 | FOREACH_SAFI (safi) { | |
14159 | if (peer->afc[afi][safi]) { | |
14160 | bgp_show_peer(vty, peer, use_json, json); | |
14161 | nbr_output = true; | |
14162 | break; | |
14163 | } | |
14164 | } | |
14165 | break; | |
d62a17ae | 14166 | } |
14167 | } | |
14168 | ||
d1927ebe AS |
14169 | if ((type == show_peer || type == show_ipv4_peer || |
14170 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14171 | if (use_json) |
14172 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14173 | else | |
88b7d255 | 14174 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14175 | } |
14176 | ||
d1927ebe AS |
14177 | if (type != show_peer && type != show_ipv4_peer && |
14178 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14179 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14180 | |
d62a17ae | 14181 | if (use_json) { |
996c9314 LB |
14182 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14183 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14184 | } else { |
14185 | vty_out(vty, "\n"); | |
14186 | } | |
14187 | ||
14188 | return CMD_SUCCESS; | |
14189 | } | |
14190 | ||
36235319 QY |
14191 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14192 | enum show_type type, | |
14193 | const char *ip_str, | |
14194 | afi_t afi, bool use_json) | |
2986cac2 | 14195 | { |
14196 | ||
14197 | int ret; | |
14198 | struct bgp *bgp; | |
14199 | union sockunion su; | |
2986cac2 | 14200 | |
14201 | bgp = bgp_get_default(); | |
14202 | ||
13909c4f DS |
14203 | if (!bgp) |
14204 | return; | |
2986cac2 | 14205 | |
13909c4f DS |
14206 | if (!use_json) |
14207 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14208 | NULL); | |
2986cac2 | 14209 | |
13909c4f DS |
14210 | if (ip_str) { |
14211 | ret = str2sockunion(ip_str, &su); | |
14212 | if (ret < 0) | |
13909c4f | 14213 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14214 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14215 | else | |
14216 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14217 | NULL, afi, use_json); | |
13909c4f DS |
14218 | } else |
14219 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14220 | afi, use_json); |
2986cac2 | 14221 | } |
14222 | ||
d62a17ae | 14223 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14224 | enum show_type type, |
14225 | const char *ip_str, | |
9f049418 | 14226 | bool use_json) |
d62a17ae | 14227 | { |
0291c246 MK |
14228 | struct listnode *node, *nnode; |
14229 | struct bgp *bgp; | |
71aedaa3 | 14230 | union sockunion su; |
0291c246 | 14231 | json_object *json = NULL; |
71aedaa3 | 14232 | int ret, is_first = 1; |
9f049418 | 14233 | bool nbr_output = false; |
d62a17ae | 14234 | |
14235 | if (use_json) | |
14236 | vty_out(vty, "{\n"); | |
14237 | ||
14238 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14239 | nbr_output = true; |
d62a17ae | 14240 | if (use_json) { |
14241 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14242 | flog_err( |
e50f7cfd | 14243 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14244 | "Unable to allocate memory for JSON object"); |
14245 | vty_out(vty, | |
14246 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14247 | return; | |
14248 | } | |
14249 | ||
14250 | json_object_int_add(json, "vrfId", | |
14251 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14252 | ? -1 |
14253 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14254 | json_object_string_add( |
14255 | json, "vrfName", | |
14256 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14257 | ? VRF_DEFAULT_NAME |
d62a17ae | 14258 | : bgp->name); |
14259 | ||
14260 | if (!is_first) | |
14261 | vty_out(vty, ",\n"); | |
14262 | else | |
14263 | is_first = 0; | |
14264 | ||
14265 | vty_out(vty, "\"%s\":", | |
14266 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14267 | ? VRF_DEFAULT_NAME |
d62a17ae | 14268 | : bgp->name); |
14269 | } else { | |
14270 | vty_out(vty, "\nInstance %s:\n", | |
14271 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14272 | ? VRF_DEFAULT_NAME |
d62a17ae | 14273 | : bgp->name); |
14274 | } | |
71aedaa3 | 14275 | |
d1927ebe AS |
14276 | if (type == show_peer || type == show_ipv4_peer || |
14277 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14278 | ret = str2sockunion(ip_str, &su); |
14279 | if (ret < 0) | |
14280 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14281 | use_json, json); | |
14282 | else | |
14283 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14284 | use_json, json); | |
14285 | } else { | |
d1927ebe | 14286 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14287 | use_json, json); |
14288 | } | |
b77004d6 | 14289 | json_object_free(json); |
121067e9 | 14290 | json = NULL; |
d62a17ae | 14291 | } |
14292 | ||
3e78a6ce | 14293 | if (use_json) |
d62a17ae | 14294 | vty_out(vty, "}\n"); |
9f049418 DS |
14295 | else if (!nbr_output) |
14296 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14297 | } |
14298 | ||
14299 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14300 | enum show_type type, const char *ip_str, | |
9f049418 | 14301 | bool use_json) |
d62a17ae | 14302 | { |
14303 | int ret; | |
14304 | struct bgp *bgp; | |
14305 | union sockunion su; | |
14306 | json_object *json = NULL; | |
14307 | ||
14308 | if (name) { | |
14309 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14310 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14311 | use_json); | |
d62a17ae | 14312 | return CMD_SUCCESS; |
14313 | } else { | |
14314 | bgp = bgp_lookup_by_name(name); | |
14315 | if (!bgp) { | |
14316 | if (use_json) { | |
14317 | json = json_object_new_object(); | |
d62a17ae | 14318 | vty_out(vty, "%s\n", |
14319 | json_object_to_json_string_ext( | |
14320 | json, | |
14321 | JSON_C_TO_STRING_PRETTY)); | |
14322 | json_object_free(json); | |
14323 | } else | |
14324 | vty_out(vty, | |
9f049418 | 14325 | "%% BGP instance not found\n"); |
d62a17ae | 14326 | |
14327 | return CMD_WARNING; | |
14328 | } | |
14329 | } | |
14330 | } else { | |
14331 | bgp = bgp_get_default(); | |
14332 | } | |
14333 | ||
14334 | if (bgp) { | |
14335 | json = json_object_new_object(); | |
14336 | if (ip_str) { | |
14337 | ret = str2sockunion(ip_str, &su); | |
14338 | if (ret < 0) | |
14339 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14340 | use_json, json); | |
14341 | else | |
14342 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14343 | use_json, json); | |
14344 | } else { | |
14345 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14346 | json); | |
14347 | } | |
14348 | json_object_free(json); | |
ca61fd25 DS |
14349 | } else { |
14350 | if (use_json) | |
14351 | vty_out(vty, "{}\n"); | |
14352 | else | |
14353 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14354 | } |
14355 | ||
14356 | return CMD_SUCCESS; | |
4fb25c53 DW |
14357 | } |
14358 | ||
2986cac2 | 14359 | |
14360 | ||
14361 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14362 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14363 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14364 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14365 | SHOW_STR | |
14366 | BGP_STR | |
14367 | IP_STR | |
14368 | IPV6_STR | |
14369 | NEIGHBOR_STR | |
14370 | "Neighbor to display information about\n" | |
14371 | "Neighbor to display information about\n" | |
14372 | "Neighbor on BGP configured interface\n" | |
14373 | GR_SHOW | |
14374 | JSON_STR) | |
14375 | { | |
14376 | char *sh_arg = NULL; | |
14377 | enum show_type sh_type; | |
14378 | int idx = 0; | |
14379 | afi_t afi = AFI_MAX; | |
2986cac2 | 14380 | bool uj = use_json(argc, argv); |
14381 | ||
36235319 | 14382 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14383 | afi = AFI_MAX; |
14384 | ||
14385 | idx++; | |
14386 | ||
14387 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14388 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14389 | || argv_find(argv, argc, "WORD", &idx)) { | |
14390 | sh_type = show_peer; | |
14391 | sh_arg = argv[idx]->arg; | |
14392 | } else | |
14393 | sh_type = show_all; | |
14394 | ||
14395 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14396 | return CMD_SUCCESS; | |
14397 | ||
14398 | ||
36235319 QY |
14399 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14400 | afi, uj); | |
2986cac2 | 14401 | } |
14402 | ||
716b2d8a | 14403 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14404 | DEFUN (show_ip_bgp_neighbors, |
14405 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14406 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14407 | SHOW_STR |
14408 | IP_STR | |
14409 | BGP_STR | |
f2a8972b | 14410 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14411 | "Address Family\n" |
14412 | "Address Family\n" | |
718e3744 | 14413 | "Detailed information on TCP and BGP neighbor connections\n" |
14414 | "Neighbor to display information about\n" | |
a80beece | 14415 | "Neighbor to display information about\n" |
91d37724 | 14416 | "Neighbor on BGP configured interface\n" |
9973d184 | 14417 | JSON_STR) |
718e3744 | 14418 | { |
d62a17ae | 14419 | char *vrf = NULL; |
14420 | char *sh_arg = NULL; | |
14421 | enum show_type sh_type; | |
d1927ebe | 14422 | afi_t afi = AFI_MAX; |
718e3744 | 14423 | |
9f049418 | 14424 | bool uj = use_json(argc, argv); |
718e3744 | 14425 | |
d62a17ae | 14426 | int idx = 0; |
718e3744 | 14427 | |
9a8bdf1c PG |
14428 | /* [<vrf> VIEWVRFNAME] */ |
14429 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14430 | vrf = argv[idx + 1]->arg; | |
14431 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14432 | vrf = NULL; | |
14433 | } else if (argv_find(argv, argc, "view", &idx)) | |
14434 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14435 | vrf = argv[idx + 1]->arg; |
718e3744 | 14436 | |
d62a17ae | 14437 | idx++; |
d1927ebe AS |
14438 | |
14439 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14440 | sh_type = show_ipv4_all; | |
14441 | afi = AFI_IP; | |
14442 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14443 | sh_type = show_ipv6_all; | |
14444 | afi = AFI_IP6; | |
14445 | } else { | |
14446 | sh_type = show_all; | |
14447 | } | |
14448 | ||
d62a17ae | 14449 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14450 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14451 | || argv_find(argv, argc, "WORD", &idx)) { | |
14452 | sh_type = show_peer; | |
14453 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14454 | } |
14455 | ||
14456 | if (sh_type == show_peer && afi == AFI_IP) { | |
14457 | sh_type = show_ipv4_peer; | |
14458 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14459 | sh_type = show_ipv6_peer; | |
14460 | } | |
856ca177 | 14461 | |
d62a17ae | 14462 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14463 | } |
14464 | ||
716b2d8a | 14465 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14466 | paths' and `show ip mbgp paths'. Those functions results are the |
14467 | same.*/ | |
f412b39a | 14468 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14469 | show_ip_bgp_paths_cmd, |
46f296b4 | 14470 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14471 | SHOW_STR |
14472 | IP_STR | |
14473 | BGP_STR | |
46f296b4 | 14474 | BGP_SAFI_HELP_STR |
718e3744 | 14475 | "Path information\n") |
14476 | { | |
d62a17ae | 14477 | vty_out(vty, "Address Refcnt Path\n"); |
14478 | aspath_print_all_vty(vty); | |
14479 | return CMD_SUCCESS; | |
718e3744 | 14480 | } |
14481 | ||
718e3744 | 14482 | #include "hash.h" |
14483 | ||
e3b78da8 | 14484 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14485 | struct vty *vty) |
718e3744 | 14486 | { |
d62a17ae | 14487 | struct community *com; |
718e3744 | 14488 | |
e3b78da8 | 14489 | com = (struct community *)bucket->data; |
3f65c5b1 | 14490 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14491 | community_str(com, false)); |
718e3744 | 14492 | } |
14493 | ||
14494 | /* Show BGP's community internal data. */ | |
f412b39a | 14495 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14496 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14497 | "show [ip] bgp community-info", |
718e3744 | 14498 | SHOW_STR |
14499 | IP_STR | |
14500 | BGP_STR | |
14501 | "List all bgp community information\n") | |
14502 | { | |
d62a17ae | 14503 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14504 | |
d62a17ae | 14505 | hash_iterate(community_hash(), |
e3b78da8 | 14506 | (void (*)(struct hash_bucket *, |
d62a17ae | 14507 | void *))community_show_all_iterator, |
14508 | vty); | |
718e3744 | 14509 | |
d62a17ae | 14510 | return CMD_SUCCESS; |
718e3744 | 14511 | } |
14512 | ||
e3b78da8 | 14513 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14514 | struct vty *vty) |
57d187bc | 14515 | { |
d62a17ae | 14516 | struct lcommunity *lcom; |
57d187bc | 14517 | |
e3b78da8 | 14518 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14519 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14520 | lcommunity_str(lcom, false)); |
57d187bc JS |
14521 | } |
14522 | ||
14523 | /* Show BGP's community internal data. */ | |
14524 | DEFUN (show_ip_bgp_lcommunity_info, | |
14525 | show_ip_bgp_lcommunity_info_cmd, | |
14526 | "show ip bgp large-community-info", | |
14527 | SHOW_STR | |
14528 | IP_STR | |
14529 | BGP_STR | |
14530 | "List all bgp large-community information\n") | |
14531 | { | |
d62a17ae | 14532 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14533 | |
d62a17ae | 14534 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14535 | (void (*)(struct hash_bucket *, |
d62a17ae | 14536 | void *))lcommunity_show_all_iterator, |
14537 | vty); | |
57d187bc | 14538 | |
d62a17ae | 14539 | return CMD_SUCCESS; |
57d187bc | 14540 | } |
2986cac2 | 14541 | /* Graceful Restart */ |
14542 | ||
14543 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14544 | struct bgp *bgp, |
14545 | bool use_json, | |
14546 | json_object *json) | |
2986cac2 | 14547 | { |
57d187bc JS |
14548 | |
14549 | ||
2986cac2 | 14550 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14551 | ||
7318ae88 | 14552 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14553 | |
14554 | switch (bgp_global_gr_mode) { | |
14555 | ||
14556 | case GLOBAL_HELPER: | |
13909c4f | 14557 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14558 | break; |
14559 | ||
14560 | case GLOBAL_GR: | |
13909c4f | 14561 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14562 | break; |
14563 | ||
14564 | case GLOBAL_DISABLE: | |
13909c4f | 14565 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14566 | break; |
14567 | ||
14568 | case GLOBAL_INVALID: | |
2986cac2 | 14569 | vty_out(vty, |
2ba1fe69 | 14570 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14571 | break; |
14572 | } | |
14573 | vty_out(vty, "\n"); | |
14574 | } | |
14575 | ||
36235319 QY |
14576 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14577 | enum show_type type, | |
14578 | const char *ip_str, | |
14579 | afi_t afi, bool use_json) | |
2986cac2 | 14580 | { |
14581 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14582 | afi = AFI_IP; | |
14583 | ||
14584 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14585 | ||
36235319 QY |
14586 | bgp_show_neighbor_graceful_restart_vty( |
14587 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14588 | afi++; |
14589 | } | |
14590 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14591 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14592 | use_json); | |
2986cac2 | 14593 | } else { |
14594 | return CMD_ERR_INCOMPLETE; | |
14595 | } | |
14596 | ||
14597 | return CMD_SUCCESS; | |
14598 | } | |
14599 | /* Graceful Restart */ | |
14600 | ||
f412b39a | 14601 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14602 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14603 | "show [ip] bgp attribute-info", |
718e3744 | 14604 | SHOW_STR |
14605 | IP_STR | |
14606 | BGP_STR | |
14607 | "List all bgp attribute information\n") | |
14608 | { | |
d62a17ae | 14609 | attr_show_all(vty); |
14610 | return CMD_SUCCESS; | |
718e3744 | 14611 | } |
6b0655a2 | 14612 | |
03915806 CS |
14613 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14614 | afi_t afi, safi_t safi, | |
14615 | bool use_json, json_object *json) | |
53089bec | 14616 | { |
14617 | struct bgp *bgp; | |
14618 | struct listnode *node; | |
14619 | char *vname; | |
14620 | char buf1[INET6_ADDRSTRLEN]; | |
14621 | char *ecom_str; | |
14622 | vpn_policy_direction_t dir; | |
14623 | ||
03915806 | 14624 | if (json) { |
b46dfd20 DS |
14625 | json_object *json_import_vrfs = NULL; |
14626 | json_object *json_export_vrfs = NULL; | |
14627 | ||
b46dfd20 DS |
14628 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14629 | ||
53089bec | 14630 | if (!bgp) { |
b46dfd20 DS |
14631 | vty_out(vty, "%s\n", |
14632 | json_object_to_json_string_ext( | |
14633 | json, | |
14634 | JSON_C_TO_STRING_PRETTY)); | |
14635 | json_object_free(json); | |
14636 | ||
53089bec | 14637 | return CMD_WARNING; |
14638 | } | |
b46dfd20 | 14639 | |
94d4c685 DS |
14640 | /* Provide context for the block */ |
14641 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14642 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14643 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14644 | |
b46dfd20 DS |
14645 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14646 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14647 | json_object_string_add(json, "importFromVrfs", "none"); | |
14648 | json_object_string_add(json, "importRts", "none"); | |
14649 | } else { | |
6ce24e52 DS |
14650 | json_import_vrfs = json_object_new_array(); |
14651 | ||
b46dfd20 DS |
14652 | for (ALL_LIST_ELEMENTS_RO( |
14653 | bgp->vpn_policy[afi].import_vrf, | |
14654 | node, vname)) | |
14655 | json_object_array_add(json_import_vrfs, | |
14656 | json_object_new_string(vname)); | |
14657 | ||
b20875ea CS |
14658 | json_object_object_add(json, "importFromVrfs", |
14659 | json_import_vrfs); | |
b46dfd20 | 14660 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14661 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14662 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14663 | bgp->vpn_policy[afi].rtlist[dir], |
14664 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14665 | json_object_string_add(json, "importRts", |
14666 | ecom_str); | |
14667 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14668 | } else | |
14669 | json_object_string_add(json, "importRts", | |
14670 | "none"); | |
b46dfd20 DS |
14671 | } |
14672 | ||
14673 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14674 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14675 | json_object_string_add(json, "exportToVrfs", "none"); | |
14676 | json_object_string_add(json, "routeDistinguisher", | |
14677 | "none"); | |
14678 | json_object_string_add(json, "exportRts", "none"); | |
14679 | } else { | |
6ce24e52 DS |
14680 | json_export_vrfs = json_object_new_array(); |
14681 | ||
b46dfd20 DS |
14682 | for (ALL_LIST_ELEMENTS_RO( |
14683 | bgp->vpn_policy[afi].export_vrf, | |
14684 | node, vname)) | |
14685 | json_object_array_add(json_export_vrfs, | |
14686 | json_object_new_string(vname)); | |
14687 | json_object_object_add(json, "exportToVrfs", | |
14688 | json_export_vrfs); | |
14689 | json_object_string_add(json, "routeDistinguisher", | |
14690 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14691 | buf1, RD_ADDRSTRLEN)); | |
14692 | ||
14693 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14694 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14695 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14696 | bgp->vpn_policy[afi].rtlist[dir], |
14697 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14698 | json_object_string_add(json, "exportRts", |
14699 | ecom_str); | |
14700 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14701 | } else | |
14702 | json_object_string_add(json, "exportRts", | |
14703 | "none"); | |
b46dfd20 DS |
14704 | } |
14705 | ||
03915806 CS |
14706 | if (use_json) { |
14707 | vty_out(vty, "%s\n", | |
14708 | json_object_to_json_string_ext(json, | |
b46dfd20 | 14709 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
14710 | json_object_free(json); |
14711 | } | |
53089bec | 14712 | } else { |
b46dfd20 DS |
14713 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14714 | ||
53089bec | 14715 | if (!bgp) { |
b46dfd20 | 14716 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14717 | return CMD_WARNING; |
14718 | } | |
53089bec | 14719 | |
b46dfd20 DS |
14720 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14721 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14722 | vty_out(vty, | |
14723 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14724 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14725 | else { |
14726 | vty_out(vty, | |
14727 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14728 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14729 | |
14730 | for (ALL_LIST_ELEMENTS_RO( | |
14731 | bgp->vpn_policy[afi].import_vrf, | |
14732 | node, vname)) | |
14733 | vty_out(vty, " %s\n", vname); | |
14734 | ||
14735 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14736 | ecom_str = NULL; |
14737 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14738 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14739 | bgp->vpn_policy[afi].rtlist[dir], |
14740 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14741 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14742 | |
b20875ea CS |
14743 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14744 | } else | |
14745 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14746 | } |
53089bec | 14747 | |
b46dfd20 DS |
14748 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14749 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14750 | vty_out(vty, | |
14751 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14752 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14753 | else { |
14754 | vty_out(vty, | |
04c9077f | 14755 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14756 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14757 | |
14758 | for (ALL_LIST_ELEMENTS_RO( | |
14759 | bgp->vpn_policy[afi].export_vrf, | |
14760 | node, vname)) | |
14761 | vty_out(vty, " %s\n", vname); | |
14762 | ||
14763 | vty_out(vty, "RD: %s\n", | |
14764 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14765 | buf1, RD_ADDRSTRLEN)); | |
14766 | ||
14767 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14768 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14769 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14770 | bgp->vpn_policy[afi].rtlist[dir], |
14771 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14772 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14773 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14774 | } else | |
14775 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14776 | } |
53089bec | 14777 | } |
14778 | ||
14779 | return CMD_SUCCESS; | |
14780 | } | |
14781 | ||
03915806 CS |
14782 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14783 | safi_t safi, bool use_json) | |
14784 | { | |
14785 | struct listnode *node, *nnode; | |
14786 | struct bgp *bgp; | |
14787 | char *vrf_name = NULL; | |
14788 | json_object *json = NULL; | |
14789 | json_object *json_vrf = NULL; | |
14790 | json_object *json_vrfs = NULL; | |
14791 | ||
14792 | if (use_json) { | |
14793 | json = json_object_new_object(); | |
14794 | json_vrfs = json_object_new_object(); | |
14795 | } | |
14796 | ||
14797 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14798 | ||
14799 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14800 | vrf_name = bgp->name; | |
14801 | ||
14802 | if (use_json) { | |
14803 | json_vrf = json_object_new_object(); | |
14804 | } else { | |
14805 | vty_out(vty, "\nInstance %s:\n", | |
14806 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14807 | ? VRF_DEFAULT_NAME : bgp->name); | |
14808 | } | |
14809 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14810 | if (use_json) { | |
14811 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14812 | json_object_object_add(json_vrfs, | |
14813 | VRF_DEFAULT_NAME, json_vrf); | |
14814 | else | |
14815 | json_object_object_add(json_vrfs, vrf_name, | |
14816 | json_vrf); | |
14817 | } | |
14818 | } | |
14819 | ||
14820 | if (use_json) { | |
14821 | json_object_object_add(json, "vrfs", json_vrfs); | |
14822 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
14823 | JSON_C_TO_STRING_PRETTY)); | |
14824 | json_object_free(json); | |
14825 | } | |
14826 | ||
14827 | return CMD_SUCCESS; | |
14828 | } | |
14829 | ||
53089bec | 14830 | /* "show [ip] bgp route-leak" command. */ |
14831 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14832 | show_ip_bgp_route_leak_cmd, |
14833 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14834 | SHOW_STR |
14835 | IP_STR | |
14836 | BGP_STR | |
14837 | BGP_INSTANCE_HELP_STR | |
14838 | BGP_AFI_HELP_STR | |
14839 | BGP_SAFI_HELP_STR | |
14840 | "Route leaking information\n" | |
14841 | JSON_STR) | |
53089bec | 14842 | { |
14843 | char *vrf = NULL; | |
14844 | afi_t afi = AFI_MAX; | |
14845 | safi_t safi = SAFI_MAX; | |
14846 | ||
9f049418 | 14847 | bool uj = use_json(argc, argv); |
53089bec | 14848 | int idx = 0; |
03915806 | 14849 | json_object *json = NULL; |
53089bec | 14850 | |
14851 | /* show [ip] bgp */ | |
14852 | if (argv_find(argv, argc, "ip", &idx)) { | |
14853 | afi = AFI_IP; | |
14854 | safi = SAFI_UNICAST; | |
14855 | } | |
14856 | /* [vrf VIEWVRFNAME] */ | |
14857 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14858 | vty_out(vty, |
14859 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14860 | return CMD_WARNING; |
14861 | } | |
14862 | ||
9a8bdf1c PG |
14863 | if (argv_find(argv, argc, "vrf", &idx)) { |
14864 | vrf = argv[idx + 1]->arg; | |
14865 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14866 | vrf = NULL; | |
14867 | } | |
53089bec | 14868 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14869 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14870 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14871 | } | |
14872 | ||
14873 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14874 | vty_out(vty, |
14875 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14876 | return CMD_WARNING; |
14877 | } | |
14878 | ||
03915806 CS |
14879 | if (vrf && strmatch(vrf, "all")) |
14880 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14881 | ||
14882 | if (uj) | |
14883 | json = json_object_new_object(); | |
14884 | ||
14885 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14886 | } |
14887 | ||
d62a17ae | 14888 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14889 | safi_t safi) | |
f186de26 | 14890 | { |
d62a17ae | 14891 | struct listnode *node, *nnode; |
14892 | struct bgp *bgp; | |
f186de26 | 14893 | |
d62a17ae | 14894 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
14895 | vty_out(vty, "\nInstance %s:\n", | |
14896 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14897 | ? VRF_DEFAULT_NAME |
d62a17ae | 14898 | : bgp->name); |
14899 | update_group_show(bgp, afi, safi, vty, 0); | |
14900 | } | |
f186de26 | 14901 | } |
14902 | ||
d62a17ae | 14903 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14904 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14905 | { |
d62a17ae | 14906 | struct bgp *bgp; |
4fb25c53 | 14907 | |
d62a17ae | 14908 | if (name) { |
14909 | if (strmatch(name, "all")) { | |
14910 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14911 | return CMD_SUCCESS; | |
14912 | } else { | |
14913 | bgp = bgp_lookup_by_name(name); | |
14914 | } | |
14915 | } else { | |
14916 | bgp = bgp_get_default(); | |
14917 | } | |
4fb25c53 | 14918 | |
d62a17ae | 14919 | if (bgp) |
14920 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14921 | return CMD_SUCCESS; | |
4fb25c53 DW |
14922 | } |
14923 | ||
8fe8a7f6 DS |
14924 | DEFUN (show_ip_bgp_updgrps, |
14925 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14926 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14927 | SHOW_STR |
14928 | IP_STR | |
14929 | BGP_STR | |
14930 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14931 | BGP_AFI_HELP_STR |
9bedbb1e | 14932 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14933 | "Detailed info about dynamic update groups\n" |
14934 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14935 | { |
d62a17ae | 14936 | char *vrf = NULL; |
14937 | afi_t afi = AFI_IP6; | |
14938 | safi_t safi = SAFI_UNICAST; | |
14939 | uint64_t subgrp_id = 0; | |
14940 | ||
14941 | int idx = 0; | |
14942 | ||
14943 | /* show [ip] bgp */ | |
14944 | if (argv_find(argv, argc, "ip", &idx)) | |
14945 | afi = AFI_IP; | |
9a8bdf1c PG |
14946 | /* [<vrf> VIEWVRFNAME] */ |
14947 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14948 | vrf = argv[idx + 1]->arg; | |
14949 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14950 | vrf = NULL; | |
14951 | } else if (argv_find(argv, argc, "view", &idx)) | |
14952 | /* [<view> VIEWVRFNAME] */ | |
14953 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14954 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14955 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14956 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14957 | } | |
5bf15956 | 14958 | |
d62a17ae | 14959 | /* get subgroup id, if provided */ |
14960 | idx = argc - 1; | |
14961 | if (argv[idx]->type == VARIABLE_TKN) | |
14962 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14963 | |
d62a17ae | 14964 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14965 | } |
14966 | ||
f186de26 | 14967 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14968 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 14969 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 14970 | SHOW_STR |
716b2d8a | 14971 | IP_STR |
f186de26 | 14972 | BGP_STR |
14973 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 14974 | "Detailed info about dynamic update groups\n") |
f186de26 | 14975 | { |
d62a17ae | 14976 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
14977 | return CMD_SUCCESS; | |
f186de26 | 14978 | } |
14979 | ||
43d3f4fc DS |
14980 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
14981 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
14982 | "show [ip] bgp l2vpn evpn update-groups", | |
14983 | SHOW_STR | |
14984 | IP_STR | |
14985 | BGP_STR | |
14986 | "l2vpn address family\n" | |
14987 | "evpn sub-address family\n" | |
14988 | "Detailed info about dynamic update groups\n") | |
14989 | { | |
14990 | char *vrf = NULL; | |
14991 | uint64_t subgrp_id = 0; | |
14992 | ||
14993 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
14994 | return CMD_SUCCESS; | |
14995 | } | |
14996 | ||
5bf15956 DW |
14997 | DEFUN (show_bgp_updgrps_stats, |
14998 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 14999 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15000 | SHOW_STR |
716b2d8a | 15001 | IP_STR |
3f9c7369 | 15002 | BGP_STR |
0c7b1b01 | 15003 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15004 | "Statistics\n") |
15005 | { | |
d62a17ae | 15006 | struct bgp *bgp; |
3f9c7369 | 15007 | |
d62a17ae | 15008 | bgp = bgp_get_default(); |
15009 | if (bgp) | |
15010 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15011 | |
d62a17ae | 15012 | return CMD_SUCCESS; |
3f9c7369 DS |
15013 | } |
15014 | ||
8386ac43 | 15015 | DEFUN (show_bgp_instance_updgrps_stats, |
15016 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15017 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15018 | SHOW_STR |
716b2d8a | 15019 | IP_STR |
8386ac43 | 15020 | BGP_STR |
15021 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15022 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15023 | "Statistics\n") |
15024 | { | |
d62a17ae | 15025 | int idx_word = 3; |
15026 | struct bgp *bgp; | |
8386ac43 | 15027 | |
d62a17ae | 15028 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15029 | if (bgp) | |
15030 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15031 | |
d62a17ae | 15032 | return CMD_SUCCESS; |
8386ac43 | 15033 | } |
15034 | ||
d62a17ae | 15035 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15036 | afi_t afi, safi_t safi, | |
15037 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15038 | { |
d62a17ae | 15039 | struct bgp *bgp; |
8386ac43 | 15040 | |
d62a17ae | 15041 | if (name) |
15042 | bgp = bgp_lookup_by_name(name); | |
15043 | else | |
15044 | bgp = bgp_get_default(); | |
8386ac43 | 15045 | |
d62a17ae | 15046 | if (bgp) { |
15047 | if (!strcmp(what, "advertise-queue")) | |
15048 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15049 | subgrp_id); | |
15050 | else if (!strcmp(what, "advertised-routes")) | |
15051 | update_group_show_advertised(bgp, afi, safi, vty, | |
15052 | subgrp_id); | |
15053 | else if (!strcmp(what, "packet-queue")) | |
15054 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15055 | subgrp_id); | |
15056 | } | |
3f9c7369 DS |
15057 | } |
15058 | ||
dc64bdec QY |
15059 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15060 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15061 | "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", | |
15062 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15063 | BGP_SAFI_HELP_STR | |
15064 | "Detailed info about dynamic update groups\n" | |
15065 | "Specific subgroup to display info for\n" | |
15066 | "Advertisement queue\n" | |
15067 | "Announced routes\n" | |
15068 | "Packet queue\n") | |
3f9c7369 | 15069 | { |
dc64bdec QY |
15070 | uint64_t subgrp_id = 0; |
15071 | afi_t afiz; | |
15072 | safi_t safiz; | |
15073 | if (sgid) | |
15074 | subgrp_id = strtoull(sgid, NULL, 10); | |
15075 | ||
15076 | if (!ip && !afi) | |
15077 | afiz = AFI_IP6; | |
15078 | if (!ip && afi) | |
15079 | afiz = bgp_vty_afi_from_str(afi); | |
15080 | if (ip && !afi) | |
15081 | afiz = AFI_IP; | |
15082 | if (ip && afi) { | |
15083 | afiz = bgp_vty_afi_from_str(afi); | |
15084 | if (afiz != AFI_IP) | |
15085 | vty_out(vty, | |
15086 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15087 | return CMD_WARNING; | |
15088 | } | |
d62a17ae | 15089 | |
dc64bdec | 15090 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15091 | |
dc64bdec | 15092 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15093 | return CMD_SUCCESS; |
15094 | } | |
15095 | ||
6f4eacf3 DA |
15096 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15097 | json_object *json) | |
d62a17ae | 15098 | { |
15099 | struct listnode *node, *nnode; | |
15100 | struct prefix *range; | |
15101 | struct peer *conf; | |
15102 | struct peer *peer; | |
d62a17ae | 15103 | afi_t afi; |
15104 | safi_t safi; | |
15105 | const char *peer_status; | |
d62a17ae | 15106 | int lr_count; |
15107 | int dynamic; | |
6f4eacf3 DA |
15108 | bool af_cfgd; |
15109 | json_object *json_peer_group = NULL; | |
15110 | json_object *json_peer_group_afc = NULL; | |
15111 | json_object *json_peer_group_members = NULL; | |
15112 | json_object *json_peer_group_dynamic = NULL; | |
15113 | json_object *json_peer_group_dynamic_af = NULL; | |
15114 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15115 | |
15116 | conf = group->conf; | |
15117 | ||
6f4eacf3 DA |
15118 | if (json) { |
15119 | json_peer_group = json_object_new_object(); | |
15120 | json_peer_group_afc = json_object_new_array(); | |
15121 | } | |
15122 | ||
d62a17ae | 15123 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15124 | if (json) |
15125 | json_object_int_add(json_peer_group, "remoteAs", | |
15126 | conf->as); | |
15127 | else | |
15128 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15129 | group->name, conf->as); | |
d62a17ae | 15130 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15131 | if (json) |
15132 | json_object_int_add(json_peer_group, "remoteAs", | |
15133 | group->bgp->as); | |
15134 | else | |
15135 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15136 | group->name, group->bgp->as); | |
d62a17ae | 15137 | } else { |
6f4eacf3 DA |
15138 | if (!json) |
15139 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15140 | } |
f14e6fdb | 15141 | |
6f4eacf3 DA |
15142 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15143 | if (json) | |
15144 | json_object_string_add(json_peer_group, "type", | |
15145 | "internal"); | |
15146 | else | |
15147 | vty_out(vty, " Peer-group type is internal\n"); | |
15148 | } else { | |
15149 | if (json) | |
15150 | json_object_string_add(json_peer_group, "type", | |
15151 | "external"); | |
15152 | else | |
15153 | vty_out(vty, " Peer-group type is external\n"); | |
15154 | } | |
d62a17ae | 15155 | |
15156 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15157 | if (!json) |
15158 | vty_out(vty, " Configured address-families:"); | |
15159 | ||
05c7a1cc QY |
15160 | FOREACH_AFI_SAFI (afi, safi) { |
15161 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15162 | af_cfgd = true; |
15163 | if (json) | |
15164 | json_object_array_add( | |
15165 | json_peer_group_afc, | |
15166 | json_object_new_string(get_afi_safi_str( | |
15167 | afi, safi, false))); | |
15168 | else | |
15169 | vty_out(vty, " %s;", | |
15170 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15171 | } |
05c7a1cc | 15172 | } |
6f4eacf3 DA |
15173 | |
15174 | if (json) { | |
15175 | json_object_object_add(json_peer_group, | |
15176 | "addressFamiliesConfigured", | |
15177 | json_peer_group_afc); | |
15178 | } else { | |
15179 | if (!af_cfgd) | |
15180 | vty_out(vty, " none\n"); | |
15181 | else | |
15182 | vty_out(vty, "\n"); | |
15183 | } | |
d62a17ae | 15184 | |
15185 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15186 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15187 | lr_count = listcount(group->listen_range[afi]); |
15188 | if (lr_count) { | |
6f4eacf3 DA |
15189 | if (json) { |
15190 | if (!json_peer_group_dynamic) | |
15191 | json_peer_group_dynamic = | |
15192 | json_object_new_object(); | |
15193 | ||
15194 | json_peer_group_dynamic_af = | |
15195 | json_object_new_object(); | |
15196 | json_peer_group_ranges = | |
15197 | json_object_new_array(); | |
15198 | json_object_int_add(json_peer_group_dynamic_af, | |
15199 | "count", lr_count); | |
15200 | } else { | |
15201 | vty_out(vty, " %d %s listen range(s)\n", | |
15202 | lr_count, afi2str(afi)); | |
15203 | } | |
d62a17ae | 15204 | |
15205 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15206 | nnode, range)) { |
15207 | if (json) { | |
15208 | char buf[BUFSIZ]; | |
15209 | ||
15210 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15211 | range); | |
15212 | ||
15213 | json_object_array_add( | |
15214 | json_peer_group_ranges, | |
15215 | json_object_new_string(buf)); | |
15216 | } else { | |
15217 | vty_out(vty, " %pFX\n", range); | |
15218 | } | |
15219 | } | |
15220 | ||
15221 | if (json) { | |
15222 | json_object_object_add( | |
15223 | json_peer_group_dynamic_af, "ranges", | |
15224 | json_peer_group_ranges); | |
15225 | ||
15226 | json_object_object_add( | |
15227 | json_peer_group_dynamic, afi2str(afi), | |
15228 | json_peer_group_dynamic_af); | |
15229 | } | |
d62a17ae | 15230 | } |
15231 | } | |
f14e6fdb | 15232 | |
6f4eacf3 DA |
15233 | if (json_peer_group_dynamic) |
15234 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15235 | json_peer_group_dynamic); | |
15236 | ||
d62a17ae | 15237 | /* Display group members and their status */ |
15238 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
15239 | if (json) |
15240 | json_peer_group_members = json_object_new_object(); | |
15241 | else | |
15242 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 15243 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
15244 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15245 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15246 | peer_status = "Idle (Admin)"; |
15247 | else if (CHECK_FLAG(peer->sflags, | |
15248 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15249 | peer_status = "Idle (PfxCt)"; | |
15250 | else | |
15251 | peer_status = lookup_msg(bgp_status_msg, | |
15252 | peer->status, NULL); | |
15253 | ||
15254 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
15255 | |
15256 | if (json) { | |
15257 | json_object *json_peer_group_member = | |
15258 | json_object_new_object(); | |
15259 | ||
15260 | json_object_string_add(json_peer_group_member, | |
15261 | "status", peer_status); | |
15262 | ||
15263 | if (dynamic) | |
15264 | json_object_boolean_true_add( | |
15265 | json_peer_group_member, | |
15266 | "dynamic"); | |
15267 | ||
15268 | json_object_object_add(json_peer_group_members, | |
15269 | peer->host, | |
15270 | json_peer_group_member); | |
15271 | } else { | |
15272 | vty_out(vty, " %s %s %s \n", peer->host, | |
15273 | dynamic ? "(dynamic)" : "", | |
15274 | peer_status); | |
15275 | } | |
d62a17ae | 15276 | } |
6f4eacf3 DA |
15277 | if (json) |
15278 | json_object_object_add(json_peer_group, "members", | |
15279 | json_peer_group_members); | |
d62a17ae | 15280 | } |
f14e6fdb | 15281 | |
6f4eacf3 DA |
15282 | if (json) |
15283 | json_object_object_add(json, group->name, json_peer_group); | |
15284 | ||
d62a17ae | 15285 | return CMD_SUCCESS; |
15286 | } | |
15287 | ||
ff9959b0 | 15288 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 15289 | const char *group_name, bool uj) |
d62a17ae | 15290 | { |
ff9959b0 | 15291 | struct bgp *bgp; |
d62a17ae | 15292 | struct listnode *node, *nnode; |
15293 | struct peer_group *group; | |
ff9959b0 | 15294 | bool found = false; |
6f4eacf3 DA |
15295 | json_object *json = NULL; |
15296 | ||
15297 | if (uj) | |
15298 | json = json_object_new_object(); | |
ff9959b0 QY |
15299 | |
15300 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15301 | ||
15302 | if (!bgp) { | |
6f4eacf3 DA |
15303 | if (uj) { |
15304 | vty_out(vty, "%s\n", | |
15305 | json_object_to_json_string_ext( | |
15306 | json, JSON_C_TO_STRING_PRETTY)); | |
15307 | json_object_free(json); | |
15308 | } else { | |
15309 | vty_out(vty, "%% BGP instance not found\n"); | |
15310 | } | |
15311 | ||
ff9959b0 QY |
15312 | return CMD_WARNING; |
15313 | } | |
d62a17ae | 15314 | |
15315 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15316 | if (group_name) { |
15317 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 15318 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
15319 | found = true; |
15320 | break; | |
d62a17ae | 15321 | } |
ff9959b0 | 15322 | } else { |
6f4eacf3 | 15323 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 15324 | } |
f14e6fdb | 15325 | } |
f14e6fdb | 15326 | |
6f4eacf3 | 15327 | if (group_name && !found && !uj) |
d62a17ae | 15328 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15329 | |
6f4eacf3 DA |
15330 | if (uj) { |
15331 | vty_out(vty, "%s\n", | |
15332 | json_object_to_json_string_ext( | |
15333 | json, JSON_C_TO_STRING_PRETTY)); | |
15334 | json_object_free(json); | |
15335 | } | |
15336 | ||
d62a17ae | 15337 | return CMD_SUCCESS; |
f14e6fdb DS |
15338 | } |
15339 | ||
6f4eacf3 DA |
15340 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
15341 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
15342 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
15343 | "Detailed information on BGP peer groups\n" | |
15344 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 15345 | { |
d62a17ae | 15346 | char *vrf, *pg; |
d62a17ae | 15347 | int idx = 0; |
6f4eacf3 | 15348 | bool uj = use_json(argc, argv); |
f14e6fdb | 15349 | |
a4d82a8a PZ |
15350 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15351 | : NULL; | |
d62a17ae | 15352 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15353 | |
6f4eacf3 | 15354 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 15355 | } |
3f9c7369 | 15356 | |
d6e3c605 | 15357 | |
718e3744 | 15358 | /* Redistribute VTY commands. */ |
15359 | ||
585f1adc IR |
15360 | DEFUN (bgp_redistribute_ipv4, |
15361 | bgp_redistribute_ipv4_cmd, | |
15362 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15363 | "Redistribute information from another routing protocol\n" | |
15364 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15365 | { |
585f1adc | 15366 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15367 | int idx_protocol = 1; |
585f1adc | 15368 | int type; |
37a87b8f | 15369 | |
585f1adc IR |
15370 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15371 | if (type < 0) { | |
15372 | vty_out(vty, "%% Invalid route type\n"); | |
15373 | return CMD_WARNING_CONFIG_FAILED; | |
15374 | } | |
7f323236 | 15375 | |
585f1adc IR |
15376 | bgp_redist_add(bgp, AFI_IP, type, 0); |
15377 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 15378 | } |
15379 | ||
d62a17ae | 15380 | ALIAS_HIDDEN( |
15381 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15382 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15383 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15384 | |
585f1adc IR |
15385 | DEFUN (bgp_redistribute_ipv4_rmap, |
15386 | bgp_redistribute_ipv4_rmap_cmd, | |
15387 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15388 | "Redistribute information from another routing protocol\n" | |
15389 | FRR_IP_REDIST_HELP_STR_BGPD | |
15390 | "Route map reference\n" | |
15391 | "Pointer to route-map entries\n") | |
718e3744 | 15392 | { |
585f1adc | 15393 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15394 | int idx_protocol = 1; |
15395 | int idx_word = 3; | |
585f1adc IR |
15396 | int type; |
15397 | struct bgp_redist *red; | |
15398 | bool changed; | |
15399 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
15400 | vty, argv[idx_word]->arg); | |
15401 | ||
15402 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15403 | if (type < 0) { | |
15404 | vty_out(vty, "%% Invalid route type\n"); | |
15405 | return CMD_WARNING_CONFIG_FAILED; | |
15406 | } | |
37a87b8f | 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 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 15412 | } |
15413 | ||
d62a17ae | 15414 | ALIAS_HIDDEN( |
15415 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15416 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15417 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15418 | "Route map reference\n" | |
15419 | "Pointer to route-map entries\n") | |
596c17ba | 15420 | |
585f1adc IR |
15421 | DEFUN (bgp_redistribute_ipv4_metric, |
15422 | bgp_redistribute_ipv4_metric_cmd, | |
15423 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15424 | "Redistribute information from another routing protocol\n" | |
15425 | FRR_IP_REDIST_HELP_STR_BGPD | |
15426 | "Metric for redistributed routes\n" | |
15427 | "Default metric\n") | |
718e3744 | 15428 | { |
585f1adc | 15429 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15430 | int idx_protocol = 1; |
15431 | int idx_number = 3; | |
585f1adc IR |
15432 | int type; |
15433 | uint32_t metric; | |
15434 | struct bgp_redist *red; | |
15435 | bool changed; | |
15436 | ||
15437 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15438 | if (type < 0) { | |
15439 | vty_out(vty, "%% Invalid route type\n"); | |
15440 | return CMD_WARNING_CONFIG_FAILED; | |
15441 | } | |
15442 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15443 | |
585f1adc IR |
15444 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15445 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15446 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15447 | } |
15448 | ||
15449 | ALIAS_HIDDEN( | |
15450 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15451 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15452 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15453 | "Metric for redistributed routes\n" | |
15454 | "Default metric\n") | |
596c17ba | 15455 | |
585f1adc IR |
15456 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
15457 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15458 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15459 | "Redistribute information from another routing protocol\n" | |
15460 | FRR_IP_REDIST_HELP_STR_BGPD | |
15461 | "Route map reference\n" | |
15462 | "Pointer to route-map entries\n" | |
15463 | "Metric for redistributed routes\n" | |
15464 | "Default metric\n") | |
718e3744 | 15465 | { |
585f1adc | 15466 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15467 | int idx_protocol = 1; |
15468 | int idx_word = 3; | |
15469 | int idx_number = 5; | |
585f1adc IR |
15470 | int type; |
15471 | uint32_t metric; | |
15472 | struct bgp_redist *red; | |
15473 | bool changed; | |
15474 | struct route_map *route_map = | |
15475 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15476 | ||
15477 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15478 | if (type < 0) { | |
15479 | vty_out(vty, "%% Invalid route type\n"); | |
15480 | return CMD_WARNING_CONFIG_FAILED; | |
15481 | } | |
15482 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15483 | |
585f1adc IR |
15484 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15485 | changed = | |
15486 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15487 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15488 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15489 | } |
15490 | ||
15491 | ALIAS_HIDDEN( | |
15492 | bgp_redistribute_ipv4_rmap_metric, | |
15493 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15494 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15495 | " route-map WORD metric (0-4294967295)", | |
15496 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15497 | "Route map reference\n" | |
15498 | "Pointer to route-map entries\n" | |
15499 | "Metric for redistributed routes\n" | |
15500 | "Default metric\n") | |
596c17ba | 15501 | |
585f1adc IR |
15502 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
15503 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15504 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15505 | "Redistribute information from another routing protocol\n" | |
15506 | FRR_IP_REDIST_HELP_STR_BGPD | |
15507 | "Metric for redistributed routes\n" | |
15508 | "Default metric\n" | |
15509 | "Route map reference\n" | |
15510 | "Pointer to route-map entries\n") | |
718e3744 | 15511 | { |
585f1adc | 15512 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15513 | int idx_protocol = 1; |
37a87b8f | 15514 | int idx_number = 3; |
585f1adc IR |
15515 | int idx_word = 5; |
15516 | int type; | |
15517 | uint32_t metric; | |
15518 | struct bgp_redist *red; | |
15519 | bool changed; | |
15520 | struct route_map *route_map = | |
15521 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15522 | ||
15523 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15524 | if (type < 0) { | |
15525 | vty_out(vty, "%% Invalid route type\n"); | |
15526 | return CMD_WARNING_CONFIG_FAILED; | |
15527 | } | |
15528 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15529 | |
585f1adc IR |
15530 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15531 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15532 | changed |= | |
15533 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15534 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15535 | } |
15536 | ||
15537 | ALIAS_HIDDEN( | |
15538 | bgp_redistribute_ipv4_metric_rmap, | |
15539 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15540 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15541 | " metric (0-4294967295) route-map WORD", | |
15542 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15543 | "Metric for redistributed routes\n" | |
15544 | "Default metric\n" | |
15545 | "Route map reference\n" | |
15546 | "Pointer to route-map entries\n") | |
596c17ba | 15547 | |
585f1adc IR |
15548 | DEFUN (bgp_redistribute_ipv4_ospf, |
15549 | bgp_redistribute_ipv4_ospf_cmd, | |
15550 | "redistribute <ospf|table> (1-65535)", | |
15551 | "Redistribute information from another routing protocol\n" | |
15552 | "Open Shortest Path First (OSPFv2)\n" | |
15553 | "Non-main Kernel Routing Table\n" | |
15554 | "Instance ID/Table ID\n") | |
7c8ff89e | 15555 | { |
585f1adc IR |
15556 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15557 | int idx_ospf_table = 1; | |
d62a17ae | 15558 | int idx_number = 2; |
585f1adc IR |
15559 | unsigned short instance; |
15560 | unsigned short protocol; | |
7c8ff89e | 15561 | |
585f1adc | 15562 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 15563 | |
585f1adc IR |
15564 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15565 | protocol = ZEBRA_ROUTE_OSPF; | |
15566 | else | |
15567 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 15568 | |
585f1adc IR |
15569 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15570 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
15571 | } |
15572 | ||
d62a17ae | 15573 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15574 | "redistribute <ospf|table> (1-65535)", | |
15575 | "Redistribute information from another routing protocol\n" | |
15576 | "Open Shortest Path First (OSPFv2)\n" | |
15577 | "Non-main Kernel Routing Table\n" | |
15578 | "Instance ID/Table ID\n") | |
596c17ba | 15579 | |
585f1adc IR |
15580 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
15581 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15582 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15583 | "Redistribute information from another routing protocol\n" | |
15584 | "Open Shortest Path First (OSPFv2)\n" | |
15585 | "Non-main Kernel Routing Table\n" | |
15586 | "Instance ID/Table ID\n" | |
15587 | "Route map reference\n" | |
15588 | "Pointer to route-map entries\n") | |
7c8ff89e | 15589 | { |
585f1adc IR |
15590 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15591 | int idx_ospf_table = 1; | |
d62a17ae | 15592 | int idx_number = 2; |
15593 | int idx_word = 4; | |
585f1adc IR |
15594 | struct bgp_redist *red; |
15595 | unsigned short instance; | |
15596 | int protocol; | |
15597 | bool changed; | |
15598 | struct route_map *route_map = | |
15599 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15600 | ||
15601 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15602 | protocol = ZEBRA_ROUTE_OSPF; | |
15603 | else | |
15604 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15605 | |
585f1adc IR |
15606 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15607 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15608 | changed = | |
15609 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15610 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15611 | } |
15612 | ||
15613 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15614 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15615 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15616 | "Redistribute information from another routing protocol\n" | |
15617 | "Open Shortest Path First (OSPFv2)\n" | |
15618 | "Non-main Kernel Routing Table\n" | |
15619 | "Instance ID/Table ID\n" | |
15620 | "Route map reference\n" | |
15621 | "Pointer to route-map entries\n") | |
596c17ba | 15622 | |
585f1adc IR |
15623 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
15624 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15625 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15626 | "Redistribute information from another routing protocol\n" | |
15627 | "Open Shortest Path First (OSPFv2)\n" | |
15628 | "Non-main Kernel Routing Table\n" | |
15629 | "Instance ID/Table ID\n" | |
15630 | "Metric for redistributed routes\n" | |
15631 | "Default metric\n") | |
7c8ff89e | 15632 | { |
585f1adc IR |
15633 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15634 | int idx_ospf_table = 1; | |
d62a17ae | 15635 | int idx_number = 2; |
15636 | int idx_number_2 = 4; | |
585f1adc IR |
15637 | uint32_t metric; |
15638 | struct bgp_redist *red; | |
15639 | unsigned short instance; | |
15640 | int protocol; | |
15641 | bool changed; | |
15642 | ||
15643 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15644 | protocol = ZEBRA_ROUTE_OSPF; | |
15645 | else | |
15646 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15647 | |
585f1adc IR |
15648 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15649 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15650 | |
585f1adc IR |
15651 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15652 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15653 | metric); | |
15654 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15655 | } |
15656 | ||
15657 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15658 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15659 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15660 | "Redistribute information from another routing protocol\n" | |
15661 | "Open Shortest Path First (OSPFv2)\n" | |
15662 | "Non-main Kernel Routing Table\n" | |
15663 | "Instance ID/Table ID\n" | |
15664 | "Metric for redistributed routes\n" | |
15665 | "Default metric\n") | |
596c17ba | 15666 | |
585f1adc IR |
15667 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
15668 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15669 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15670 | "Redistribute information from another routing protocol\n" | |
15671 | "Open Shortest Path First (OSPFv2)\n" | |
15672 | "Non-main Kernel Routing Table\n" | |
15673 | "Instance ID/Table ID\n" | |
15674 | "Route map reference\n" | |
15675 | "Pointer to route-map entries\n" | |
15676 | "Metric for redistributed routes\n" | |
15677 | "Default metric\n") | |
7c8ff89e | 15678 | { |
585f1adc IR |
15679 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15680 | int idx_ospf_table = 1; | |
d62a17ae | 15681 | int idx_number = 2; |
15682 | int idx_word = 4; | |
15683 | int idx_number_2 = 6; | |
585f1adc IR |
15684 | uint32_t metric; |
15685 | struct bgp_redist *red; | |
15686 | unsigned short instance; | |
15687 | int protocol; | |
15688 | bool changed; | |
15689 | struct route_map *route_map = | |
15690 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15691 | ||
15692 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15693 | protocol = ZEBRA_ROUTE_OSPF; | |
15694 | else | |
15695 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15696 | |
585f1adc IR |
15697 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15698 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15699 | |
585f1adc IR |
15700 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15701 | changed = | |
15702 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15703 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15704 | metric); | |
15705 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15706 | } |
15707 | ||
15708 | ALIAS_HIDDEN( | |
15709 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15710 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15711 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15712 | "Redistribute information from another routing protocol\n" | |
15713 | "Open Shortest Path First (OSPFv2)\n" | |
15714 | "Non-main Kernel Routing Table\n" | |
15715 | "Instance ID/Table ID\n" | |
15716 | "Route map reference\n" | |
15717 | "Pointer to route-map entries\n" | |
15718 | "Metric for redistributed routes\n" | |
15719 | "Default metric\n") | |
596c17ba | 15720 | |
585f1adc IR |
15721 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
15722 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15723 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15724 | "Redistribute information from another routing protocol\n" | |
15725 | "Open Shortest Path First (OSPFv2)\n" | |
15726 | "Non-main Kernel Routing Table\n" | |
15727 | "Instance ID/Table ID\n" | |
15728 | "Metric for redistributed routes\n" | |
15729 | "Default metric\n" | |
15730 | "Route map reference\n" | |
15731 | "Pointer to route-map entries\n") | |
7c8ff89e | 15732 | { |
585f1adc IR |
15733 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15734 | int idx_ospf_table = 1; | |
d62a17ae | 15735 | int idx_number = 2; |
15736 | int idx_number_2 = 4; | |
15737 | int idx_word = 6; | |
585f1adc IR |
15738 | uint32_t metric; |
15739 | struct bgp_redist *red; | |
15740 | unsigned short instance; | |
15741 | int protocol; | |
15742 | bool changed; | |
15743 | struct route_map *route_map = | |
15744 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15745 | ||
15746 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15747 | protocol = ZEBRA_ROUTE_OSPF; | |
15748 | else | |
15749 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15750 | |
585f1adc IR |
15751 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15752 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15753 | |
585f1adc IR |
15754 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15755 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15756 | metric); | |
15757 | changed |= | |
15758 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15759 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15760 | } |
15761 | ||
15762 | ALIAS_HIDDEN( | |
15763 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15764 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15765 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15766 | "Redistribute information from another routing protocol\n" | |
15767 | "Open Shortest Path First (OSPFv2)\n" | |
15768 | "Non-main Kernel Routing Table\n" | |
15769 | "Instance ID/Table ID\n" | |
15770 | "Metric for redistributed routes\n" | |
15771 | "Default metric\n" | |
15772 | "Route map reference\n" | |
15773 | "Pointer to route-map entries\n") | |
596c17ba | 15774 | |
585f1adc IR |
15775 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
15776 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15777 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15778 | NO_STR | |
15779 | "Redistribute information from another routing protocol\n" | |
15780 | "Open Shortest Path First (OSPFv2)\n" | |
15781 | "Non-main Kernel Routing Table\n" | |
15782 | "Instance ID/Table ID\n" | |
15783 | "Metric for redistributed routes\n" | |
15784 | "Default metric\n" | |
15785 | "Route map reference\n" | |
15786 | "Pointer to route-map entries\n") | |
7c8ff89e | 15787 | { |
585f1adc IR |
15788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15789 | int idx_ospf_table = 2; | |
d62a17ae | 15790 | int idx_number = 3; |
585f1adc IR |
15791 | unsigned short instance; |
15792 | int protocol; | |
37a87b8f | 15793 | |
585f1adc IR |
15794 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15795 | protocol = ZEBRA_ROUTE_OSPF; | |
15796 | else | |
15797 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15798 | |
585f1adc IR |
15799 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15800 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 15801 | } |
15802 | ||
15803 | ALIAS_HIDDEN( | |
15804 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 15805 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15806 | NO_STR |
15807 | "Redistribute information from another routing protocol\n" | |
15808 | "Open Shortest Path First (OSPFv2)\n" | |
15809 | "Non-main Kernel Routing Table\n" | |
15810 | "Instance ID/Table ID\n" | |
15811 | "Metric for redistributed routes\n" | |
15812 | "Default metric\n" | |
15813 | "Route map reference\n" | |
15814 | "Pointer to route-map entries\n") | |
596c17ba | 15815 | |
585f1adc IR |
15816 | DEFUN (no_bgp_redistribute_ipv4, |
15817 | no_bgp_redistribute_ipv4_cmd, | |
15818 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15819 | NO_STR | |
15820 | "Redistribute information from another routing protocol\n" | |
15821 | FRR_IP_REDIST_HELP_STR_BGPD | |
15822 | "Metric for redistributed routes\n" | |
15823 | "Default metric\n" | |
15824 | "Route map reference\n" | |
15825 | "Pointer to route-map entries\n") | |
718e3744 | 15826 | { |
585f1adc | 15827 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15828 | int idx_protocol = 2; |
585f1adc | 15829 | int type; |
d62a17ae | 15830 | |
585f1adc IR |
15831 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15832 | if (type < 0) { | |
15833 | vty_out(vty, "%% Invalid route type\n"); | |
15834 | return CMD_WARNING_CONFIG_FAILED; | |
15835 | } | |
15836 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 15837 | } |
15838 | ||
15839 | ALIAS_HIDDEN( | |
15840 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15841 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 15842 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15843 | NO_STR |
15844 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15845 | "Metric for redistributed routes\n" | |
15846 | "Default metric\n" | |
15847 | "Route map reference\n" | |
15848 | "Pointer to route-map entries\n") | |
596c17ba | 15849 | |
585f1adc IR |
15850 | DEFUN (bgp_redistribute_ipv6, |
15851 | bgp_redistribute_ipv6_cmd, | |
15852 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15853 | "Redistribute information from another routing protocol\n" | |
15854 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15855 | { |
585f1adc | 15856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15857 | int idx_protocol = 1; |
585f1adc | 15858 | int type; |
718e3744 | 15859 | |
585f1adc IR |
15860 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15861 | if (type < 0) { | |
15862 | vty_out(vty, "%% Invalid route type\n"); | |
15863 | return CMD_WARNING_CONFIG_FAILED; | |
15864 | } | |
718e3744 | 15865 | |
585f1adc IR |
15866 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
15867 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 15868 | } |
15869 | ||
585f1adc IR |
15870 | DEFUN (bgp_redistribute_ipv6_rmap, |
15871 | bgp_redistribute_ipv6_rmap_cmd, | |
15872 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15873 | "Redistribute information from another routing protocol\n" | |
15874 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15875 | "Route map reference\n" | |
15876 | "Pointer to route-map entries\n") | |
718e3744 | 15877 | { |
585f1adc | 15878 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15879 | int idx_protocol = 1; |
15880 | int idx_word = 3; | |
585f1adc IR |
15881 | int type; |
15882 | struct bgp_redist *red; | |
15883 | bool changed; | |
15884 | struct route_map *route_map = | |
15885 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15886 | ||
15887 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15888 | if (type < 0) { | |
15889 | vty_out(vty, "%% Invalid route type\n"); | |
15890 | return CMD_WARNING_CONFIG_FAILED; | |
15891 | } | |
37a87b8f | 15892 | |
585f1adc IR |
15893 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15894 | changed = | |
15895 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15896 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15897 | } |
15898 | ||
585f1adc | 15899 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 15900 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 15901 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 15902 | "Redistribute information from another routing protocol\n" |
ab0181ee | 15903 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 15904 | "Metric for redistributed routes\n" |
15905 | "Default metric\n") | |
15906 | { | |
585f1adc | 15907 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15908 | int idx_protocol = 1; |
15909 | int idx_number = 3; | |
585f1adc IR |
15910 | int type; |
15911 | uint32_t metric; | |
15912 | struct bgp_redist *red; | |
15913 | bool changed; | |
15914 | ||
15915 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15916 | if (type < 0) { | |
15917 | vty_out(vty, "%% Invalid route type\n"); | |
15918 | return CMD_WARNING_CONFIG_FAILED; | |
15919 | } | |
15920 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15921 | |
585f1adc IR |
15922 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15923 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
15924 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15925 | } |
15926 | ||
585f1adc IR |
15927 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
15928 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
15929 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15930 | "Redistribute information from another routing protocol\n" | |
15931 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15932 | "Route map reference\n" | |
15933 | "Pointer to route-map entries\n" | |
15934 | "Metric for redistributed routes\n" | |
15935 | "Default metric\n") | |
718e3744 | 15936 | { |
585f1adc | 15937 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15938 | int idx_protocol = 1; |
15939 | int idx_word = 3; | |
15940 | int idx_number = 5; | |
585f1adc IR |
15941 | int type; |
15942 | uint32_t metric; | |
15943 | struct bgp_redist *red; | |
15944 | bool changed; | |
15945 | struct route_map *route_map = | |
15946 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15947 | ||
15948 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15949 | if (type < 0) { | |
15950 | vty_out(vty, "%% Invalid route type\n"); | |
15951 | return CMD_WARNING_CONFIG_FAILED; | |
15952 | } | |
15953 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15954 | |
585f1adc IR |
15955 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15956 | changed = | |
15957 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15958 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
15959 | metric); | |
15960 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15961 | } |
15962 | ||
585f1adc IR |
15963 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
15964 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
15965 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15966 | "Redistribute information from another routing protocol\n" | |
15967 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15968 | "Metric for redistributed routes\n" | |
15969 | "Default metric\n" | |
15970 | "Route map reference\n" | |
15971 | "Pointer to route-map entries\n") | |
718e3744 | 15972 | { |
585f1adc | 15973 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15974 | int idx_protocol = 1; |
37a87b8f | 15975 | int idx_number = 3; |
585f1adc IR |
15976 | int idx_word = 5; |
15977 | int type; | |
15978 | uint32_t metric; | |
15979 | struct bgp_redist *red; | |
15980 | bool changed; | |
15981 | struct route_map *route_map = | |
15982 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15983 | ||
15984 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15985 | if (type < 0) { | |
15986 | vty_out(vty, "%% Invalid route type\n"); | |
15987 | return CMD_WARNING_CONFIG_FAILED; | |
15988 | } | |
15989 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15990 | |
585f1adc IR |
15991 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
15992 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
15993 | metric); | |
15994 | changed |= | |
15995 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15996 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 15997 | } |
15998 | ||
585f1adc IR |
15999 | DEFUN (no_bgp_redistribute_ipv6, |
16000 | no_bgp_redistribute_ipv6_cmd, | |
16001 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
16002 | NO_STR | |
16003 | "Redistribute information from another routing protocol\n" | |
16004 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16005 | "Metric for redistributed routes\n" | |
16006 | "Default metric\n" | |
16007 | "Route map reference\n" | |
16008 | "Pointer to route-map entries\n") | |
718e3744 | 16009 | { |
585f1adc | 16010 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16011 | int idx_protocol = 2; |
585f1adc | 16012 | int type; |
37a87b8f | 16013 | |
585f1adc IR |
16014 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16015 | if (type < 0) { | |
16016 | vty_out(vty, "%% Invalid route type\n"); | |
16017 | return CMD_WARNING_CONFIG_FAILED; | |
16018 | } | |
718e3744 | 16019 | |
585f1adc | 16020 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 16021 | } |
16022 | ||
4ab46701 AR |
16023 | /* Neighbor update tcp-mss. */ |
16024 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16025 | const char *tcp_mss_str) | |
16026 | { | |
16027 | struct peer *peer; | |
16028 | uint32_t tcp_mss_val = 0; | |
16029 | ||
16030 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16031 | if (!peer) | |
16032 | return CMD_WARNING_CONFIG_FAILED; | |
16033 | ||
16034 | if (tcp_mss_str) { | |
16035 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16036 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16037 | } else { | |
16038 | peer_tcp_mss_unset(peer); | |
16039 | } | |
16040 | ||
16041 | return CMD_SUCCESS; | |
16042 | } | |
16043 | ||
16044 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16045 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16046 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16047 | "TCP max segment size\n" | |
16048 | "TCP MSS value\n") | |
16049 | { | |
16050 | int peer_index = 1; | |
16051 | int mss_index = 3; | |
16052 | ||
16053 | vty_out(vty, | |
16054 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16055 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16056 | argv[mss_index]->arg); | |
16057 | } | |
16058 | ||
16059 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16061 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16062 | "TCP max segment size\n" | |
16063 | "TCP MSS value\n") | |
16064 | { | |
16065 | int peer_index = 2; | |
16066 | ||
16067 | vty_out(vty, | |
16068 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16069 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16070 | } | |
16071 | ||
dd65f45e DL |
16072 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16073 | afi_t afi, safi_t safi) | |
d62a17ae | 16074 | { |
16075 | int i; | |
16076 | ||
16077 | /* Unicast redistribution only. */ | |
16078 | if (safi != SAFI_UNICAST) | |
2b791107 | 16079 | return; |
d62a17ae | 16080 | |
16081 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16082 | /* Redistribute BGP does not make sense. */ | |
16083 | if (i != ZEBRA_ROUTE_BGP) { | |
16084 | struct list *red_list; | |
16085 | struct listnode *node; | |
16086 | struct bgp_redist *red; | |
16087 | ||
16088 | red_list = bgp->redist[afi][i]; | |
16089 | if (!red_list) | |
16090 | continue; | |
16091 | ||
16092 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16093 | /* "redistribute" configuration. */ |
16094 | vty_out(vty, " redistribute %s", | |
16095 | zebra_route_string(i)); | |
16096 | if (red->instance) | |
16097 | vty_out(vty, " %d", red->instance); | |
16098 | if (red->redist_metric_flag) | |
16099 | vty_out(vty, " metric %u", | |
16100 | red->redist_metric); | |
16101 | if (red->rmap.name) | |
16102 | vty_out(vty, " route-map %s", | |
16103 | red->rmap.name); | |
16104 | vty_out(vty, "\n"); | |
16105 | } | |
16106 | } | |
16107 | } | |
718e3744 | 16108 | } |
6b0655a2 | 16109 | |
dd65f45e DL |
16110 | /* peer-group helpers for config-write */ |
16111 | ||
16112 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16113 | { | |
16114 | if (!peer_group_active(peer)) { | |
16115 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16116 | return !CHECK_FLAG(peer->flags, flag); | |
16117 | else | |
16118 | return !!CHECK_FLAG(peer->flags, flag); | |
16119 | } | |
16120 | ||
16121 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16122 | } | |
16123 | ||
16124 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16125 | uint32_t flag) | |
16126 | { | |
16127 | if (!peer_group_active(peer)) { | |
16128 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16129 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16130 | else | |
16131 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16132 | } | |
16133 | ||
16134 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16135 | } | |
16136 | ||
16137 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16138 | uint8_t type, int direct) | |
16139 | { | |
16140 | struct bgp_filter *filter; | |
16141 | ||
16142 | if (peer_group_active(peer)) | |
16143 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16144 | type); | |
16145 | ||
16146 | filter = &peer->filter[afi][safi]; | |
16147 | switch (type) { | |
16148 | case PEER_FT_DISTRIBUTE_LIST: | |
16149 | return !!(filter->dlist[direct].name); | |
16150 | case PEER_FT_FILTER_LIST: | |
16151 | return !!(filter->aslist[direct].name); | |
16152 | case PEER_FT_PREFIX_LIST: | |
16153 | return !!(filter->plist[direct].name); | |
16154 | case PEER_FT_ROUTE_MAP: | |
16155 | return !!(filter->map[direct].name); | |
16156 | case PEER_FT_UNSUPPRESS_MAP: | |
16157 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16158 | case PEER_FT_ADVERTISE_MAP: |
16159 | return !!(filter->advmap.aname | |
16160 | && ((filter->advmap.condition == direct) | |
16161 | && filter->advmap.cname)); | |
dd65f45e DL |
16162 | default: |
16163 | return false; | |
16164 | } | |
16165 | } | |
16166 | ||
16167 | /* Return true if the addpath type is set for peer and different from | |
16168 | * peer-group. | |
16169 | */ | |
3dc339cd DA |
16170 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16171 | safi_t safi) | |
dd65f45e DL |
16172 | { |
16173 | enum bgp_addpath_strat type, g_type; | |
16174 | ||
16175 | type = peer->addpath_type[afi][safi]; | |
16176 | ||
16177 | if (type != BGP_ADDPATH_NONE) { | |
16178 | if (peer_group_active(peer)) { | |
16179 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16180 | ||
16181 | if (type != g_type) | |
3dc339cd | 16182 | return true; |
dd65f45e | 16183 | else |
3dc339cd | 16184 | return false; |
dd65f45e DL |
16185 | } |
16186 | ||
3dc339cd | 16187 | return true; |
dd65f45e DL |
16188 | } |
16189 | ||
3dc339cd | 16190 | return false; |
dd65f45e DL |
16191 | } |
16192 | ||
b9c7bc5a | 16193 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16194 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16195 | afi_t afi) |
16196 | { | |
b9c7bc5a | 16197 | int indent = 2; |
53970de3 | 16198 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16199 | |
8a066a70 | 16200 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16201 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16202 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16203 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16204 | bgp->vpn_policy[afi] | |
bb4f6190 | 16205 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16206 | else |
16207 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16208 | bgp->vpn_policy[afi] | |
16209 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16210 | } | |
12a844a5 DS |
16211 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16212 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16213 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16214 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16215 | return; | |
16216 | ||
e70e9f8e PZ |
16217 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16218 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16219 | ||
16220 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16221 | ||
16222 | } else { | |
16223 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16224 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16225 | bgp->vpn_policy[afi].tovpn_label); | |
16226 | } | |
ddb5b488 | 16227 | } |
53970de3 RS |
16228 | |
16229 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16230 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16231 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16232 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16233 | } else if (tovpn_sid_index != 0) { | |
16234 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16235 | tovpn_sid_index); | |
16236 | } | |
16237 | ||
ddb5b488 PZ |
16238 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16239 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16240 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16241 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16242 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16243 | sizeof(buf))); | |
16244 | } | |
16245 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16246 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16247 | ||
16248 | char buf[PREFIX_STRLEN]; | |
16249 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16250 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16251 | sizeof(buf))) { | |
16252 | ||
b9c7bc5a PZ |
16253 | vty_out(vty, "%*snexthop vpn export %s\n", |
16254 | indent, "", buf); | |
ddb5b488 PZ |
16255 | } |
16256 | } | |
16257 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16258 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16259 | && ecommunity_cmp( | |
16260 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16261 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16262 | ||
16263 | char *b = ecommunity_ecom2str( | |
16264 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16265 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16266 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16267 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16268 | } else { | |
16269 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16270 | char *b = ecommunity_ecom2str( | |
16271 | bgp->vpn_policy[afi] | |
16272 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16273 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16274 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16275 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16276 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16277 | } | |
16278 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16279 | char *b = ecommunity_ecom2str( | |
16280 | bgp->vpn_policy[afi] | |
16281 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16282 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16283 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16284 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16285 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16286 | } | |
16287 | } | |
bb4f6190 DS |
16288 | |
16289 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16290 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16291 | bgp->vpn_policy[afi] |
16292 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16293 | |
301ad80a PG |
16294 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16295 | char *b = ecommunity_ecom2str( | |
16296 | bgp->vpn_policy[afi] | |
16297 | .import_redirect_rtlist, | |
16298 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16299 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16300 | |
9a659715 PG |
16301 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16302 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16303 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16304 | indent, "", b); |
16305 | else | |
16306 | vty_out(vty, "%*srt redirect import %s\n", | |
16307 | indent, "", b); | |
301ad80a PG |
16308 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16309 | } | |
ddb5b488 PZ |
16310 | } |
16311 | ||
dd65f45e DL |
16312 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16313 | afi_t afi, safi_t safi) | |
16314 | { | |
16315 | struct bgp_filter *filter; | |
16316 | char *addr; | |
16317 | ||
16318 | addr = peer->host; | |
16319 | filter = &peer->filter[afi][safi]; | |
16320 | ||
16321 | /* distribute-list. */ | |
16322 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16323 | FILTER_IN)) | |
16324 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16325 | filter->dlist[FILTER_IN].name); | |
16326 | ||
16327 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16328 | FILTER_OUT)) | |
16329 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16330 | filter->dlist[FILTER_OUT].name); | |
16331 | ||
16332 | /* prefix-list. */ | |
16333 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16334 | FILTER_IN)) | |
16335 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16336 | filter->plist[FILTER_IN].name); | |
16337 | ||
16338 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16339 | FILTER_OUT)) | |
16340 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16341 | filter->plist[FILTER_OUT].name); | |
16342 | ||
16343 | /* route-map. */ | |
16344 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16345 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16346 | filter->map[RMAP_IN].name); | |
16347 | ||
16348 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16349 | RMAP_OUT)) | |
16350 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16351 | filter->map[RMAP_OUT].name); | |
16352 | ||
16353 | /* unsuppress-map */ | |
16354 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16355 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16356 | filter->usmap.name); | |
16357 | ||
7f7940e6 MK |
16358 | /* advertise-map : always applied in OUT direction*/ |
16359 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16360 | CONDITION_NON_EXIST)) | |
16361 | vty_out(vty, | |
16362 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16363 | addr, filter->advmap.aname, filter->advmap.cname); | |
16364 | ||
16365 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16366 | CONDITION_EXIST)) | |
16367 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16368 | addr, filter->advmap.aname, filter->advmap.cname); | |
16369 | ||
dd65f45e DL |
16370 | /* filter-list. */ |
16371 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16372 | FILTER_IN)) | |
16373 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16374 | filter->aslist[FILTER_IN].name); | |
16375 | ||
16376 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16377 | FILTER_OUT)) | |
16378 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16379 | filter->aslist[FILTER_OUT].name); | |
16380 | } | |
16381 | ||
16382 | /* BGP peer configuration display function. */ | |
16383 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16384 | struct peer *peer) | |
16385 | { | |
16386 | struct peer *g_peer = NULL; | |
16387 | char buf[SU_ADDRSTRLEN]; | |
16388 | char *addr; | |
16389 | int if_pg_printed = false; | |
16390 | int if_ras_printed = false; | |
16391 | ||
16392 | /* Skip dynamic neighbors. */ | |
16393 | if (peer_dynamic_neighbor(peer)) | |
16394 | return; | |
16395 | ||
16396 | if (peer->conf_if) | |
16397 | addr = peer->conf_if; | |
16398 | else | |
16399 | addr = peer->host; | |
16400 | ||
16401 | /************************************ | |
16402 | ****** Global to the neighbor ****** | |
16403 | ************************************/ | |
16404 | if (peer->conf_if) { | |
16405 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16406 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16407 | else | |
16408 | vty_out(vty, " neighbor %s interface", addr); | |
16409 | ||
16410 | if (peer_group_active(peer)) { | |
16411 | vty_out(vty, " peer-group %s", peer->group->name); | |
16412 | if_pg_printed = true; | |
16413 | } else if (peer->as_type == AS_SPECIFIED) { | |
16414 | vty_out(vty, " remote-as %u", peer->as); | |
16415 | if_ras_printed = true; | |
16416 | } else if (peer->as_type == AS_INTERNAL) { | |
16417 | vty_out(vty, " remote-as internal"); | |
16418 | if_ras_printed = true; | |
16419 | } else if (peer->as_type == AS_EXTERNAL) { | |
16420 | vty_out(vty, " remote-as external"); | |
16421 | if_ras_printed = true; | |
16422 | } | |
16423 | ||
16424 | vty_out(vty, "\n"); | |
16425 | } | |
16426 | ||
16427 | /* remote-as and peer-group */ | |
16428 | /* peer is a member of a peer-group */ | |
16429 | if (peer_group_active(peer)) { | |
16430 | g_peer = peer->group->conf; | |
16431 | ||
16432 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16433 | if (peer->as_type == AS_SPECIFIED) { | |
16434 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16435 | addr, peer->as); | |
16436 | } else if (peer->as_type == AS_INTERNAL) { | |
16437 | vty_out(vty, | |
16438 | " neighbor %s remote-as internal\n", | |
16439 | addr); | |
16440 | } else if (peer->as_type == AS_EXTERNAL) { | |
16441 | vty_out(vty, | |
16442 | " neighbor %s remote-as external\n", | |
16443 | addr); | |
16444 | } | |
16445 | } | |
16446 | ||
16447 | /* For swpX peers we displayed the peer-group | |
16448 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16449 | if (!if_pg_printed) | |
16450 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16451 | peer->group->name); | |
16452 | } | |
16453 | ||
16454 | /* peer is NOT a member of a peer-group */ | |
16455 | else { | |
16456 | /* peer is a peer-group, declare the peer-group */ | |
16457 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16458 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16459 | } | |
16460 | ||
16461 | if (!if_ras_printed) { | |
16462 | if (peer->as_type == AS_SPECIFIED) { | |
16463 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16464 | addr, peer->as); | |
16465 | } else if (peer->as_type == AS_INTERNAL) { | |
16466 | vty_out(vty, | |
16467 | " neighbor %s remote-as internal\n", | |
16468 | addr); | |
16469 | } else if (peer->as_type == AS_EXTERNAL) { | |
16470 | vty_out(vty, | |
16471 | " neighbor %s remote-as external\n", | |
16472 | addr); | |
16473 | } | |
16474 | } | |
16475 | } | |
16476 | ||
16477 | /* local-as */ | |
16478 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16479 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16480 | peer->change_local_as); | |
16481 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16482 | vty_out(vty, " no-prepend"); | |
16483 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16484 | vty_out(vty, " replace-as"); | |
16485 | vty_out(vty, "\n"); | |
16486 | } | |
16487 | ||
16488 | /* description */ | |
16489 | if (peer->desc) { | |
16490 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16491 | } | |
16492 | ||
16493 | /* shutdown */ | |
16494 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16495 | if (peer->tx_shutdown_message) | |
16496 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16497 | peer->tx_shutdown_message); | |
16498 | else | |
16499 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16500 | } | |
16501 | ||
8336c896 DA |
16502 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16503 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16504 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16505 | ||
dd65f45e | 16506 | /* bfd */ |
21bfce98 RZ |
16507 | if (peer->bfd_config) |
16508 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
16509 | |
16510 | /* password */ | |
16511 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16512 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16513 | peer->password); | |
16514 | ||
16515 | /* neighbor solo */ | |
16516 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16517 | if (!peer_group_active(peer)) { | |
16518 | vty_out(vty, " neighbor %s solo\n", addr); | |
16519 | } | |
16520 | } | |
16521 | ||
16522 | /* BGP port */ | |
16523 | if (peer->port != BGP_PORT_DEFAULT) { | |
16524 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16525 | } | |
16526 | ||
16527 | /* Local interface name */ | |
16528 | if (peer->ifname) { | |
16529 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16530 | } | |
16531 | ||
4ab46701 AR |
16532 | /* TCP max segment size */ |
16533 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
16534 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
16535 | ||
dd65f45e DL |
16536 | /* passive */ |
16537 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16538 | vty_out(vty, " neighbor %s passive\n", addr); | |
16539 | ||
16540 | /* ebgp-multihop */ | |
16541 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16542 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16543 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16544 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16545 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16546 | peer->ttl); | |
16547 | } | |
16548 | } | |
16549 | ||
16550 | /* ttl-security hops */ | |
e2521429 | 16551 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16552 | if (!peer_group_active(peer) |
16553 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16554 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16555 | addr, peer->gtsm_hops); | |
16556 | } | |
16557 | } | |
16558 | ||
16559 | /* disable-connected-check */ | |
16560 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16561 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16562 | ||
27aa23a4 DA |
16563 | /* link-bw-encoding-ieee */ |
16564 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
16565 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
16566 | addr); | |
16567 | ||
dd65f45e DL |
16568 | /* enforce-first-as */ |
16569 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16570 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16571 | ||
16572 | /* update-source */ | |
16573 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16574 | if (peer->update_source) | |
16575 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16576 | sockunion2str(peer->update_source, buf, | |
16577 | SU_ADDRSTRLEN)); | |
16578 | else if (peer->update_if) | |
16579 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16580 | peer->update_if); | |
16581 | } | |
16582 | ||
16583 | /* advertisement-interval */ | |
16584 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16585 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16586 | peer->routeadv); | |
16587 | ||
16588 | /* timers */ | |
16589 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16590 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16591 | peer->keepalive, peer->holdtime); | |
16592 | ||
16593 | /* timers connect */ | |
16594 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16595 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16596 | peer->connect); | |
5d5393b9 DL |
16597 | /* need special-case handling for changed default values due to |
16598 | * config profile / version (because there is no "timers bgp connect" | |
16599 | * command, we need to save this per-peer :/) | |
16600 | */ | |
16601 | else if (!peer_group_active(peer) && !peer->connect && | |
16602 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16603 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16604 | peer->bgp->default_connect_retry); | |
dd65f45e | 16605 | |
d43114f3 DS |
16606 | /* timers delayopen */ |
16607 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
16608 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16609 | peer->delayopen); | |
16610 | /* Save config even though flag is not set if default values have been | |
16611 | * changed | |
16612 | */ | |
16613 | else if (!peer_group_active(peer) && !peer->delayopen | |
16614 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
16615 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16616 | peer->bgp->default_delayopen); | |
16617 | ||
dd65f45e DL |
16618 | /* capability dynamic */ |
16619 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16620 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16621 | ||
16622 | /* capability extended-nexthop */ | |
16623 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16624 | if (!peer->conf_if) { | |
16625 | if (CHECK_FLAG(peer->flags_invert, | |
16626 | PEER_FLAG_CAPABILITY_ENHE)) | |
16627 | vty_out(vty, | |
16628 | " no neighbor %s capability extended-nexthop\n", | |
16629 | addr); | |
16630 | else | |
16631 | vty_out(vty, | |
16632 | " neighbor %s capability extended-nexthop\n", | |
16633 | addr); | |
16634 | } | |
16635 | } | |
16636 | ||
16637 | /* dont-capability-negotiation */ | |
16638 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16639 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16640 | ||
16641 | /* override-capability */ | |
16642 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16643 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16644 | ||
16645 | /* strict-capability-match */ | |
16646 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16647 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16648 | ||
16649 | /* Sender side AS path loop detection. */ | |
16650 | if (peer->as_path_loop_detection) | |
16651 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16652 | addr); | |
cfd47646 | 16653 | |
16654 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16655 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16656 | |
16657 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16658 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16659 | vty_out(vty, |
16660 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16661 | } else if (CHECK_FLAG( |
16662 | peer->peer_gr_new_status_flag, | |
16663 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16664 | vty_out(vty, |
16665 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16666 | } else if ( |
16667 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16668 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16669 | && !(CHECK_FLAG( | |
16670 | peer->peer_gr_new_status_flag, | |
16671 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16672 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16673 | addr); | |
cfd47646 | 16674 | } |
16675 | } | |
dd65f45e DL |
16676 | } |
16677 | ||
16678 | /* BGP peer configuration display function. */ | |
16679 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16680 | struct peer *peer, afi_t afi, safi_t safi) | |
16681 | { | |
16682 | struct peer *g_peer = NULL; | |
16683 | char *addr; | |
16684 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16685 | ||
16686 | /* Skip dynamic neighbors. */ | |
16687 | if (peer_dynamic_neighbor(peer)) | |
16688 | return; | |
16689 | ||
16690 | if (peer->conf_if) | |
16691 | addr = peer->conf_if; | |
16692 | else | |
16693 | addr = peer->host; | |
16694 | ||
16695 | /************************************ | |
16696 | ****** Per AF to the neighbor ****** | |
16697 | ************************************/ | |
16698 | if (peer_group_active(peer)) { | |
16699 | g_peer = peer->group->conf; | |
16700 | ||
16701 | /* If the peer-group is active but peer is not, print a 'no | |
16702 | * activate' */ | |
16703 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16704 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16705 | } | |
16706 | ||
16707 | /* If the peer-group is not active but peer is, print an | |
16708 | 'activate' */ | |
16709 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16710 | vty_out(vty, " neighbor %s activate\n", addr); | |
16711 | } | |
16712 | } else { | |
16713 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
16714 | if (safi == SAFI_ENCAP) |
16715 | vty_out(vty, " neighbor %s activate\n", addr); | |
16716 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
16717 | vty_out(vty, " neighbor %s activate\n", addr); |
16718 | } else { | |
38d11af5 TA |
16719 | if (bgp->default_af[afi][safi]) |
16720 | vty_out(vty, " no neighbor %s activate\n", | |
16721 | addr); | |
dd65f45e DL |
16722 | } |
16723 | } | |
16724 | ||
16725 | /* addpath TX knobs */ | |
16726 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16727 | switch (peer->addpath_type[afi][safi]) { | |
16728 | case BGP_ADDPATH_ALL: | |
16729 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16730 | addr); | |
16731 | break; | |
16732 | case BGP_ADDPATH_BEST_PER_AS: | |
16733 | vty_out(vty, | |
16734 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16735 | addr); | |
16736 | break; | |
16737 | case BGP_ADDPATH_MAX: | |
16738 | case BGP_ADDPATH_NONE: | |
16739 | break; | |
16740 | } | |
16741 | } | |
16742 | ||
7c0e4312 DA |
16743 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
16744 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
16745 | ||
dd65f45e DL |
16746 | /* ORF capability. */ |
16747 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16748 | || peergroup_af_flag_check(peer, afi, safi, | |
16749 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16750 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16751 | ||
16752 | if (peergroup_af_flag_check(peer, afi, safi, | |
16753 | PEER_FLAG_ORF_PREFIX_SM) | |
16754 | && peergroup_af_flag_check(peer, afi, safi, | |
16755 | PEER_FLAG_ORF_PREFIX_RM)) | |
16756 | vty_out(vty, " both"); | |
16757 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16758 | PEER_FLAG_ORF_PREFIX_SM)) | |
16759 | vty_out(vty, " send"); | |
16760 | else | |
16761 | vty_out(vty, " receive"); | |
16762 | vty_out(vty, "\n"); | |
16763 | } | |
16764 | ||
dd65f45e DL |
16765 | /* Route reflector client. */ |
16766 | if (peergroup_af_flag_check(peer, afi, safi, | |
16767 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16768 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16769 | } | |
16770 | ||
16771 | /* next-hop-self force */ | |
16772 | if (peergroup_af_flag_check(peer, afi, safi, | |
16773 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16774 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16775 | } | |
16776 | ||
16777 | /* next-hop-self */ | |
16778 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16779 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16780 | } | |
16781 | ||
16782 | /* remove-private-AS */ | |
16783 | if (peergroup_af_flag_check(peer, afi, safi, | |
16784 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16785 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16786 | addr); | |
16787 | } | |
16788 | ||
16789 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16790 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16791 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16792 | addr); | |
16793 | } | |
16794 | ||
16795 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16796 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16797 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16798 | } | |
16799 | ||
16800 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16801 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16802 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16803 | } | |
16804 | ||
16805 | /* as-override */ | |
16806 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16807 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16808 | } | |
16809 | ||
16810 | /* send-community print. */ | |
16811 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16812 | PEER_FLAG_SEND_COMMUNITY); | |
16813 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16814 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16815 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16816 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16817 | ||
16818 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16819 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16820 | } else { | |
16821 | if (flag_scomm) | |
16822 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16823 | if (flag_secomm) | |
16824 | vty_out(vty, | |
16825 | " no neighbor %s send-community extended\n", | |
16826 | addr); | |
16827 | ||
16828 | if (flag_slcomm) | |
16829 | vty_out(vty, " no neighbor %s send-community large\n", | |
16830 | addr); | |
16831 | } | |
16832 | ||
16833 | /* Default information */ | |
16834 | if (peergroup_af_flag_check(peer, afi, safi, | |
16835 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16836 | vty_out(vty, " neighbor %s default-originate", addr); | |
16837 | ||
16838 | if (peer->default_rmap[afi][safi].name) | |
16839 | vty_out(vty, " route-map %s", | |
16840 | peer->default_rmap[afi][safi].name); | |
16841 | ||
16842 | vty_out(vty, "\n"); | |
16843 | } | |
16844 | ||
16845 | /* Soft reconfiguration inbound. */ | |
16846 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16847 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16848 | addr); | |
16849 | } | |
16850 | ||
16851 | /* maximum-prefix. */ | |
16852 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16853 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16854 | peer->pmax[afi][safi]); |
16855 | ||
16856 | if (peer->pmax_threshold[afi][safi] | |
16857 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16858 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16859 | if (peer_af_flag_check(peer, afi, safi, | |
16860 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16861 | vty_out(vty, " warning-only"); | |
16862 | if (peer->pmax_restart[afi][safi]) | |
16863 | vty_out(vty, " restart %u", | |
16864 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16865 | if (peer_af_flag_check(peer, afi, safi, |
16866 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16867 | vty_out(vty, " force"); | |
dd65f45e DL |
16868 | |
16869 | vty_out(vty, "\n"); | |
16870 | } | |
16871 | ||
fde246e8 DA |
16872 | /* maximum-prefix-out */ |
16873 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16874 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16875 | addr, peer->pmax_out[afi][safi]); |
16876 | ||
dd65f45e DL |
16877 | /* Route server client. */ |
16878 | if (peergroup_af_flag_check(peer, afi, safi, | |
16879 | PEER_FLAG_RSERVER_CLIENT)) { | |
16880 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16881 | } | |
16882 | ||
16883 | /* Nexthop-local unchanged. */ | |
16884 | if (peergroup_af_flag_check(peer, afi, safi, | |
16885 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16886 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16887 | } | |
16888 | ||
16889 | /* allowas-in <1-10> */ | |
16890 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
16891 | if (peer_af_flag_check(peer, afi, safi, | |
16892 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
16893 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
16894 | } else if (peer->allowas_in[afi][safi] == 3) { | |
16895 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
16896 | } else { | |
16897 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
16898 | peer->allowas_in[afi][safi]); | |
16899 | } | |
16900 | } | |
16901 | ||
16902 | /* weight */ | |
16903 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
16904 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
16905 | peer->weight[afi][safi]); | |
16906 | ||
16907 | /* Filter. */ | |
16908 | bgp_config_write_filter(vty, peer, afi, safi); | |
16909 | ||
16910 | /* atribute-unchanged. */ | |
16911 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
16912 | || (safi != SAFI_EVPN | |
16913 | && peer_af_flag_check(peer, afi, safi, | |
16914 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
16915 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
16916 | ||
16917 | if (!peer_group_active(peer) | |
16918 | || peergroup_af_flag_check(peer, afi, safi, | |
16919 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16920 | || peergroup_af_flag_check(peer, afi, safi, | |
16921 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16922 | || peergroup_af_flag_check(peer, afi, safi, | |
16923 | PEER_FLAG_MED_UNCHANGED)) { | |
16924 | ||
16925 | vty_out(vty, | |
16926 | " neighbor %s attribute-unchanged%s%s%s\n", | |
16927 | addr, | |
16928 | peer_af_flag_check(peer, afi, safi, | |
16929 | PEER_FLAG_AS_PATH_UNCHANGED) | |
16930 | ? " as-path" | |
16931 | : "", | |
16932 | peer_af_flag_check(peer, afi, safi, | |
16933 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
16934 | ? " next-hop" | |
16935 | : "", | |
16936 | peer_af_flag_check(peer, afi, safi, | |
16937 | PEER_FLAG_MED_UNCHANGED) | |
16938 | ? " med" | |
16939 | : ""); | |
16940 | } | |
16941 | } | |
16942 | } | |
16943 | ||
16944 | /* Address family based peer configuration display. */ | |
16945 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
16946 | safi_t safi) | |
16947 | { | |
16948 | struct peer *peer; | |
16949 | struct peer_group *group; | |
16950 | struct listnode *node, *nnode; | |
16951 | ||
16952 | ||
16953 | vty_frame(vty, " !\n address-family "); | |
16954 | if (afi == AFI_IP) { | |
16955 | if (safi == SAFI_UNICAST) | |
16956 | vty_frame(vty, "ipv4 unicast"); | |
16957 | else if (safi == SAFI_LABELED_UNICAST) | |
16958 | vty_frame(vty, "ipv4 labeled-unicast"); | |
16959 | else if (safi == SAFI_MULTICAST) | |
16960 | vty_frame(vty, "ipv4 multicast"); | |
16961 | else if (safi == SAFI_MPLS_VPN) | |
16962 | vty_frame(vty, "ipv4 vpn"); | |
16963 | else if (safi == SAFI_ENCAP) | |
16964 | vty_frame(vty, "ipv4 encap"); | |
16965 | else if (safi == SAFI_FLOWSPEC) | |
16966 | vty_frame(vty, "ipv4 flowspec"); | |
16967 | } else if (afi == AFI_IP6) { | |
16968 | if (safi == SAFI_UNICAST) | |
16969 | vty_frame(vty, "ipv6 unicast"); | |
16970 | else if (safi == SAFI_LABELED_UNICAST) | |
16971 | vty_frame(vty, "ipv6 labeled-unicast"); | |
16972 | else if (safi == SAFI_MULTICAST) | |
16973 | vty_frame(vty, "ipv6 multicast"); | |
16974 | else if (safi == SAFI_MPLS_VPN) | |
16975 | vty_frame(vty, "ipv6 vpn"); | |
16976 | else if (safi == SAFI_ENCAP) | |
16977 | vty_frame(vty, "ipv6 encap"); | |
16978 | else if (safi == SAFI_FLOWSPEC) | |
16979 | vty_frame(vty, "ipv6 flowspec"); | |
16980 | } else if (afi == AFI_L2VPN) { | |
16981 | if (safi == SAFI_EVPN) | |
16982 | vty_frame(vty, "l2vpn evpn"); | |
16983 | } | |
16984 | vty_frame(vty, "\n"); | |
16985 | ||
16986 | bgp_config_write_distance(vty, bgp, afi, safi); | |
16987 | ||
16988 | bgp_config_write_network(vty, bgp, afi, safi); | |
16989 | ||
16990 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
16991 | ||
8a4e7fe6 DA |
16992 | /* BGP flag dampening. */ |
16993 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 16994 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 16995 | |
dd65f45e DL |
16996 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
16997 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
16998 | ||
16999 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17000 | /* Do not display doppelganger peers */ |
17001 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17002 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17003 | } | |
17004 | ||
17005 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17006 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17007 | ||
17008 | if (safi == SAFI_EVPN) | |
17009 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17010 | ||
17011 | if (safi == SAFI_FLOWSPEC) | |
17012 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17013 | ||
17014 | if (safi == SAFI_UNICAST) { | |
17015 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17016 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17017 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17018 | ||
17019 | vty_out(vty, " export vpn\n"); | |
17020 | } | |
17021 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17022 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17023 | ||
17024 | vty_out(vty, " import vpn\n"); | |
17025 | } | |
17026 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17027 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17028 | char *name; | |
17029 | ||
17030 | for (ALL_LIST_ELEMENTS_RO( | |
17031 | bgp->vpn_policy[afi].import_vrf, node, | |
17032 | name)) | |
17033 | vty_out(vty, " import vrf %s\n", name); | |
17034 | } | |
17035 | } | |
17036 | ||
17037 | vty_endframe(vty, " exit-address-family\n"); | |
17038 | } | |
17039 | ||
17040 | int bgp_config_write(struct vty *vty) | |
17041 | { | |
17042 | struct bgp *bgp; | |
17043 | struct peer_group *group; | |
17044 | struct peer *peer; | |
17045 | struct listnode *node, *nnode; | |
17046 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17047 | afi_t afi; |
17048 | safi_t safi; | |
dd65f45e DL |
17049 | |
17050 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17051 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17052 | bm->rmap_update_timer); | |
17053 | ||
d70583f7 D |
17054 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17055 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17056 | if (bm->v_update_delay != bm->v_establish_wait) | |
17057 | vty_out(vty, " %d", bm->v_establish_wait); | |
17058 | vty_out(vty, "\n"); | |
17059 | } | |
17060 | ||
9acb67cb DS |
17061 | if (bm->wait_for_fib) |
17062 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17063 | ||
05bd726c | 17064 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17065 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17066 | ||
c163f297 DS |
17067 | /* No-RIB (Zebra) option flag configuration */ |
17068 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17069 | vty_out(vty, "bgp no-rib\n"); | |
17070 | ||
ec0acb80 | 17071 | if (!CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
e46723a5 DS |
17072 | vty_out(vty, "no bgp send-extra-data zebra\n"); |
17073 | ||
dd65f45e DL |
17074 | /* BGP configuration. */ |
17075 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17076 | ||
17077 | /* skip all auto created vrf as they dont have user config */ | |
17078 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17079 | continue; | |
17080 | ||
17081 | /* Router bgp ASN */ | |
17082 | vty_out(vty, "router bgp %u", bgp->as); | |
17083 | ||
17084 | if (bgp->name) | |
17085 | vty_out(vty, " %s %s", | |
17086 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17087 | ? "view" : "vrf", bgp->name); | |
17088 | vty_out(vty, "\n"); | |
17089 | ||
17090 | /* BGP fast-external-failover. */ | |
17091 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17092 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17093 | ||
17094 | /* BGP router ID. */ | |
3a6290bd | 17095 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17096 | vty_out(vty, " bgp router-id %pI4\n", |
17097 | &bgp->router_id_static); | |
dd65f45e | 17098 | |
c208c586 S |
17099 | /* Suppress fib pending */ |
17100 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17101 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17102 | ||
dd65f45e | 17103 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17104 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17105 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17106 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17107 | CHECK_FLAG(bgp->flags, |
17108 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17109 | ? "" |
17110 | : "no "); | |
17111 | ||
17112 | /* BGP configuration. */ | |
892fedb6 | 17113 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17114 | vty_out(vty, " bgp always-compare-med\n"); |
17115 | ||
17116 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17117 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17118 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17119 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17120 | CHECK_FLAG(bgp->flags, | |
17121 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17122 | ? "" | |
17123 | : "no "); | |
dd65f45e DL |
17124 | |
17125 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17126 | if (bgp->reject_as_sets) |
dd65f45e DL |
17127 | vty_out(vty, " bgp reject-as-sets\n"); |
17128 | ||
2adac256 DA |
17129 | /* Suppress duplicate updates if the route actually not changed |
17130 | */ | |
17131 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17132 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17133 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17134 | CHECK_FLAG(bgp->flags, | |
17135 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17136 | ? "" | |
17137 | : "no "); | |
17138 | ||
b16bcbba TA |
17139 | /* BGP default <afi>-<safi> */ |
17140 | FOREACH_AFI_SAFI (afi, safi) { | |
17141 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17142 | if (!bgp->default_af[afi][safi]) | |
17143 | vty_out(vty, " no bgp default %s\n", | |
17144 | get_bgp_default_af_flag(afi, | |
17145 | safi)); | |
17146 | } else if (bgp->default_af[afi][safi]) | |
17147 | vty_out(vty, " bgp default %s\n", | |
17148 | get_bgp_default_af_flag(afi, safi)); | |
17149 | } | |
e84c59af | 17150 | |
dd65f45e DL |
17151 | /* BGP default local-preference. */ |
17152 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17153 | vty_out(vty, " bgp default local-preference %u\n", | |
17154 | bgp->default_local_pref); | |
17155 | ||
17156 | /* BGP default show-hostname */ | |
892fedb6 | 17157 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17158 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17159 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17160 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17161 | ? "" |
17162 | : "no "); | |
17163 | ||
aef999a2 DA |
17164 | /* BGP default show-nexthop-hostname */ |
17165 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17166 | != SAVE_BGP_SHOW_HOSTNAME) | |
17167 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17168 | CHECK_FLAG(bgp->flags, | |
17169 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17170 | ? "" | |
17171 | : "no "); | |
17172 | ||
dd65f45e DL |
17173 | /* BGP default subgroup-pkt-queue-max. */ |
17174 | if (bgp->default_subgroup_pkt_queue_max | |
17175 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17176 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17177 | bgp->default_subgroup_pkt_queue_max); | |
17178 | ||
17179 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17180 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17181 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17182 | ||
17183 | /* BGP cluster ID. */ | |
17184 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17185 | vty_out(vty, " bgp cluster-id %pI4\n", |
17186 | &bgp->cluster_id); | |
dd65f45e DL |
17187 | |
17188 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17189 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17190 | vty_out(vty, |
17191 | " bgp disable-ebgp-connected-route-check\n"); | |
17192 | ||
17193 | /* Confederation identifier*/ | |
17194 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17195 | vty_out(vty, " bgp confederation identifier %u\n", | |
17196 | bgp->confed_id); | |
17197 | ||
17198 | /* Confederation peer */ | |
17199 | if (bgp->confed_peers_cnt > 0) { | |
17200 | int i; | |
17201 | ||
17202 | vty_out(vty, " bgp confederation peers"); | |
17203 | ||
17204 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17205 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17206 | ||
17207 | vty_out(vty, "\n"); | |
17208 | } | |
17209 | ||
17210 | /* BGP deterministic-med. */ | |
892fedb6 | 17211 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17212 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17213 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17214 | CHECK_FLAG(bgp->flags, |
17215 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17216 | ? "" |
17217 | : "no "); | |
17218 | ||
17219 | /* BGP update-delay. */ | |
17220 | bgp_config_write_update_delay(vty, bgp); | |
17221 | ||
17222 | if (bgp->v_maxmed_onstartup | |
17223 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17224 | vty_out(vty, " bgp max-med on-startup %u", | |
17225 | bgp->v_maxmed_onstartup); | |
17226 | if (bgp->maxmed_onstartup_value | |
17227 | != BGP_MAXMED_VALUE_DEFAULT) | |
17228 | vty_out(vty, " %u", | |
17229 | bgp->maxmed_onstartup_value); | |
17230 | vty_out(vty, "\n"); | |
17231 | } | |
17232 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17233 | vty_out(vty, " bgp max-med administrative"); | |
17234 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17235 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17236 | vty_out(vty, "\n"); | |
17237 | } | |
17238 | ||
17239 | /* write quanta */ | |
17240 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17241 | /* read quanta */ | |
17242 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17243 | ||
17244 | /* coalesce time */ | |
17245 | bgp_config_write_coalesce_time(vty, bgp); | |
17246 | ||
05bd726c | 17247 | /* BGP per-instance graceful-shutdown */ |
17248 | /* BGP-wide settings and per-instance settings are mutually | |
17249 | * exclusive. | |
17250 | */ | |
17251 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17252 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17253 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17254 | ||
dd65f45e DL |
17255 | /* BGP graceful-restart. */ |
17256 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17257 | vty_out(vty, | |
17258 | " bgp graceful-restart stalepath-time %u\n", | |
17259 | bgp->stalepath_time); | |
cfd47646 | 17260 | |
dd65f45e DL |
17261 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17262 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17263 | bgp->restart_time); | |
cfd47646 | 17264 | |
17265 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17266 | vty_out(vty, | |
17267 | " bgp graceful-restart select-defer-time %u\n", | |
17268 | bgp->select_defer_time); | |
17269 | ||
17270 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17271 | vty_out(vty, " bgp graceful-restart\n"); |
17272 | ||
cfd47646 | 17273 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17274 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17275 | ||
dd65f45e | 17276 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17277 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17278 | vty_out(vty, |
17279 | " bgp graceful-restart preserve-fw-state\n"); | |
17280 | ||
dc95985f | 17281 | /* Stale timer for RIB */ |
17282 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17283 | vty_out(vty, | |
17284 | " bgp graceful-restart rib-stale-time %u\n", | |
17285 | bgp->rib_stale_time); | |
17286 | ||
dd65f45e | 17287 | /* BGP bestpath method. */ |
892fedb6 | 17288 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17289 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17290 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17291 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17292 | ||
892fedb6 DA |
17293 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17294 | if (CHECK_FLAG(bgp->flags, | |
17295 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17296 | vty_out(vty, |
17297 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17298 | } else { | |
17299 | vty_out(vty, | |
17300 | " bgp bestpath as-path multipath-relax\n"); | |
17301 | } | |
17302 | } | |
17303 | ||
892fedb6 | 17304 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17305 | vty_out(vty, |
17306 | " bgp route-reflector allow-outbound-policy\n"); | |
17307 | } | |
892fedb6 | 17308 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17309 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17310 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17311 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17312 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17313 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17314 | vty_out(vty, " confed"); |
892fedb6 DA |
17315 | if (CHECK_FLAG(bgp->flags, |
17316 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17317 | vty_out(vty, " missing-as-worst"); |
17318 | vty_out(vty, "\n"); | |
17319 | } | |
17320 | ||
ee88563a JM |
17321 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
17322 | vty_out(vty, | |
17323 | " bgp bestpath peer-type multipath-relax\n"); | |
17324 | ||
f7e1c681 | 17325 | /* Link bandwidth handling. */ |
17326 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17327 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17328 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17329 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17330 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17331 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17332 | ||
dd65f45e | 17333 | /* BGP network import check. */ |
892fedb6 | 17334 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17335 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17336 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17337 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17338 | ? "" |
17339 | : "no "); | |
17340 | ||
17341 | /* BGP timers configuration. */ | |
5d5393b9 | 17342 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 17343 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
17344 | vty_out(vty, " timers bgp %u %u\n", |
17345 | bgp->default_keepalive, bgp->default_holdtime); | |
17346 | ||
b042667a TI |
17347 | /* BGP minimum holdtime configuration. */ |
17348 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
17349 | && bgp->default_min_holdtime != 0) | |
17350 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
17351 | bgp->default_min_holdtime); | |
17352 | ||
389e4f92 QY |
17353 | /* Conditional advertisement timer configuration */ |
17354 | if (bgp->condition_check_period | |
17355 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
17356 | vty_out(vty, | |
17357 | " bgp conditional-advertisement timer %u\n", | |
17358 | bgp->condition_check_period); | |
17359 | ||
dd65f45e DL |
17360 | /* peer-group */ |
17361 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17362 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17363 | } | |
17364 | ||
17365 | /* Normal neighbor configuration. */ | |
17366 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17367 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17368 | bgp_config_write_peer_global(vty, bgp, peer); | |
17369 | } | |
17370 | ||
17371 | /* listen range and limit for dynamic BGP neighbors */ | |
17372 | bgp_config_write_listen(vty, bgp); | |
17373 | ||
17374 | /* | |
17375 | * BGP default autoshutdown neighbors | |
17376 | * | |
17377 | * This must be placed after any peer and peer-group | |
17378 | * configuration, to avoid setting all peers to shutdown after | |
17379 | * a daemon restart, which is undesired behavior. (see #2286) | |
17380 | */ | |
17381 | if (bgp->autoshutdown) | |
17382 | vty_out(vty, " bgp default shutdown\n"); | |
17383 | ||
9cf59432 DS |
17384 | /* BGP instance administrative shutdown */ |
17385 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17386 | vty_out(vty, " bgp shutdown\n"); | |
17387 | ||
f852eb98 PG |
17388 | if (bgp->fast_convergence) |
17389 | vty_out(vty, " bgp fast-convergence\n"); | |
17390 | ||
a0281b2e HS |
17391 | if (bgp->srv6_enabled) { |
17392 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 17393 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
17394 | vty_out(vty, " locator %s\n", |
17395 | bgp->srv6_locator_name); | |
ff7c3ee1 | 17396 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
17397 | } |
17398 | ||
17399 | ||
dd65f45e DL |
17400 | /* IPv4 unicast configuration. */ |
17401 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17402 | ||
17403 | /* IPv4 multicast configuration. */ | |
17404 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17405 | ||
17406 | /* IPv4 labeled-unicast configuration. */ | |
17407 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17408 | ||
17409 | /* IPv4 VPN configuration. */ | |
17410 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17411 | ||
17412 | /* ENCAPv4 configuration. */ | |
17413 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17414 | ||
17415 | /* FLOWSPEC v4 configuration. */ | |
17416 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17417 | ||
17418 | /* IPv6 unicast configuration. */ | |
17419 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17420 | ||
17421 | /* IPv6 multicast configuration. */ | |
17422 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17423 | ||
17424 | /* IPv6 labeled-unicast configuration. */ | |
17425 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17426 | SAFI_LABELED_UNICAST); | |
17427 | ||
17428 | /* IPv6 VPN configuration. */ | |
17429 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17430 | ||
17431 | /* ENCAPv6 configuration. */ | |
17432 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17433 | ||
17434 | /* FLOWSPEC v6 configuration. */ | |
17435 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17436 | ||
17437 | /* EVPN configuration. */ | |
17438 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17439 | ||
17440 | hook_call(bgp_inst_config_write, bgp, vty); | |
17441 | ||
49e5a4a0 | 17442 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17443 | bgp_rfapi_cfg_write(vty, bgp); |
17444 | #endif | |
17445 | ||
07679ad9 | 17446 | vty_out(vty, "exit\n"); |
dd65f45e DL |
17447 | vty_out(vty, "!\n"); |
17448 | } | |
17449 | return 0; | |
17450 | } | |
17451 | ||
ddb5b488 | 17452 | |
718e3744 | 17453 | /* BGP node structure. */ |
d62a17ae | 17454 | static struct cmd_node bgp_node = { |
f4b8291f | 17455 | .name = "bgp", |
62b346ee | 17456 | .node = BGP_NODE, |
24389580 | 17457 | .parent_node = CONFIG_NODE, |
62b346ee | 17458 | .prompt = "%s(config-router)# ", |
612c2c15 | 17459 | .config_write = bgp_config_write, |
718e3744 | 17460 | }; |
17461 | ||
d62a17ae | 17462 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17463 | .name = "bgp ipv4 unicast", |
62b346ee | 17464 | .node = BGP_IPV4_NODE, |
24389580 | 17465 | .parent_node = BGP_NODE, |
62b346ee | 17466 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17467 | }; |
17468 | ||
d62a17ae | 17469 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17470 | .name = "bgp ipv4 multicast", |
62b346ee | 17471 | .node = BGP_IPV4M_NODE, |
24389580 | 17472 | .parent_node = BGP_NODE, |
62b346ee | 17473 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17474 | }; |
17475 | ||
d62a17ae | 17476 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17477 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17478 | .node = BGP_IPV4L_NODE, |
24389580 | 17479 | .parent_node = BGP_NODE, |
62b346ee | 17480 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17481 | }; |
17482 | ||
d62a17ae | 17483 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 17484 | .name = "bgp ipv6 unicast", |
62b346ee | 17485 | .node = BGP_IPV6_NODE, |
24389580 | 17486 | .parent_node = BGP_NODE, |
62b346ee | 17487 | .prompt = "%s(config-router-af)# ", |
718e3744 | 17488 | }; |
17489 | ||
d62a17ae | 17490 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17491 | .name = "bgp ipv6 multicast", |
62b346ee | 17492 | .node = BGP_IPV6M_NODE, |
24389580 | 17493 | .parent_node = BGP_NODE, |
62b346ee | 17494 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 17495 | }; |
17496 | ||
d62a17ae | 17497 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17498 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17499 | .node = BGP_IPV6L_NODE, |
24389580 | 17500 | .parent_node = BGP_NODE, |
62b346ee | 17501 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
17502 | }; |
17503 | ||
62b346ee | 17504 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17505 | .name = "bgp vpnv4", |
62b346ee | 17506 | .node = BGP_VPNV4_NODE, |
24389580 | 17507 | .parent_node = BGP_NODE, |
62b346ee | 17508 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17509 | }; |
6b0655a2 | 17510 | |
62b346ee | 17511 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17512 | .name = "bgp vpnv6", |
62b346ee | 17513 | .node = BGP_VPNV6_NODE, |
24389580 | 17514 | .parent_node = BGP_NODE, |
62b346ee | 17515 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17516 | }; |
8ecd3266 | 17517 | |
62b346ee | 17518 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17519 | .name = "bgp evpn", |
62b346ee | 17520 | .node = BGP_EVPN_NODE, |
24389580 | 17521 | .parent_node = BGP_NODE, |
62b346ee | 17522 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 17523 | }; |
4e0b7b6d | 17524 | |
62b346ee | 17525 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17526 | .name = "bgp evpn vni", |
62b346ee | 17527 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17528 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17529 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17530 | }; |
90e60aa7 | 17531 | |
62b346ee | 17532 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17533 | .name = "bgp ipv4 flowspec", |
62b346ee | 17534 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17535 | .parent_node = BGP_NODE, |
62b346ee | 17536 | .prompt = "%s(config-router-af)# ", |
62b346ee | 17537 | }; |
7c40bf39 | 17538 | |
62b346ee | 17539 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17540 | .name = "bgp ipv6 flowspec", |
62b346ee | 17541 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17542 | .parent_node = BGP_NODE, |
62b346ee | 17543 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 17544 | }; |
7c40bf39 | 17545 | |
bfaab44d HS |
17546 | static struct cmd_node bgp_srv6_node = { |
17547 | .name = "bgp srv6", | |
17548 | .node = BGP_SRV6_NODE, | |
17549 | .parent_node = BGP_NODE, | |
17550 | .prompt = "%s(config-router-srv6)# ", | |
17551 | }; | |
17552 | ||
d62a17ae | 17553 | static void community_list_vty(void); |
1f8ae70b | 17554 | |
d62a17ae | 17555 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 17556 | { |
d62a17ae | 17557 | struct bgp *bgp; |
17558 | struct peer *peer; | |
d62a17ae | 17559 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17560 | |
d62a17ae | 17561 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17562 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17563 | /* only provide suggestions on the appropriate input | |
17564 | * token type, | |
17565 | * they'll otherwise show up multiple times */ | |
17566 | enum cmd_token_type match_type; | |
17567 | char *name = peer->host; | |
d48ed3e0 | 17568 | |
d62a17ae | 17569 | if (peer->conf_if) { |
17570 | match_type = VARIABLE_TKN; | |
17571 | name = peer->conf_if; | |
17572 | } else if (strchr(peer->host, ':')) | |
17573 | match_type = IPV6_TKN; | |
17574 | else | |
17575 | match_type = IPV4_TKN; | |
d48ed3e0 | 17576 | |
d62a17ae | 17577 | if (token->type != match_type) |
17578 | continue; | |
d48ed3e0 | 17579 | |
d62a17ae | 17580 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17581 | } | |
d62a17ae | 17582 | } |
b8a815e5 DL |
17583 | } |
17584 | ||
17585 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 17586 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17587 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17588 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17589 | {.completions = NULL}}; |
17590 | ||
47a306a0 DS |
17591 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17592 | { | |
17593 | struct bgp *bgp; | |
17594 | struct peer_group *group; | |
17595 | struct listnode *lnbgp, *lnpeer; | |
17596 | ||
17597 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17598 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17599 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
17600 | group->name)); | |
17601 | } | |
17602 | } | |
17603 | ||
17604 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17605 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17606 | {.completions = NULL} }; | |
17607 | ||
d62a17ae | 17608 | void bgp_vty_init(void) |
17609 | { | |
17610 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17611 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17612 | |
17613 | /* Install bgp top node. */ | |
612c2c15 DL |
17614 | install_node(&bgp_node); |
17615 | install_node(&bgp_ipv4_unicast_node); | |
17616 | install_node(&bgp_ipv4_multicast_node); | |
17617 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17618 | install_node(&bgp_ipv6_unicast_node); | |
17619 | install_node(&bgp_ipv6_multicast_node); | |
17620 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17621 | install_node(&bgp_vpnv4_node); | |
17622 | install_node(&bgp_vpnv6_node); | |
17623 | install_node(&bgp_evpn_node); | |
17624 | install_node(&bgp_evpn_vni_node); | |
17625 | install_node(&bgp_flowspecv4_node); | |
17626 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 17627 | install_node(&bgp_srv6_node); |
d62a17ae | 17628 | |
17629 | /* Install default VTY commands to new nodes. */ | |
17630 | install_default(BGP_NODE); | |
17631 | install_default(BGP_IPV4_NODE); | |
17632 | install_default(BGP_IPV4M_NODE); | |
17633 | install_default(BGP_IPV4L_NODE); | |
17634 | install_default(BGP_IPV6_NODE); | |
17635 | install_default(BGP_IPV6M_NODE); | |
17636 | install_default(BGP_IPV6L_NODE); | |
17637 | install_default(BGP_VPNV4_NODE); | |
17638 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17639 | install_default(BGP_FLOWSPECV4_NODE); |
17640 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17641 | install_default(BGP_EVPN_NODE); |
17642 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 17643 | install_default(BGP_SRV6_NODE); |
d62a17ae | 17644 | |
8029b216 AK |
17645 | /* "bgp local-mac" hidden commands. */ |
17646 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17647 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17648 | ||
9acb67cb DS |
17649 | /* "bgp suppress-fib-pending" global */ |
17650 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
17651 | ||
d62a17ae | 17652 | /* bgp route-map delay-timer commands. */ |
17653 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17654 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17655 | ||
f852eb98 PG |
17656 | /* bgp fast-convergence command */ |
17657 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
17658 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
17659 | ||
d70583f7 D |
17660 | /* global bgp update-delay command */ |
17661 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17662 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17663 | ||
05bd726c | 17664 | /* global bgp graceful-shutdown command */ |
17665 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17666 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17667 | ||
d62a17ae | 17668 | /* Dummy commands (Currently not supported) */ |
17669 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17670 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17671 | ||
17672 | /* "router bgp" commands. */ | |
17673 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17674 | ||
17675 | /* "no router bgp" commands. */ | |
17676 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17677 | ||
17678 | /* "bgp router-id" commands. */ | |
17679 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17680 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17681 | ||
c208c586 S |
17682 | /* "bgp suppress-fib-pending" command */ |
17683 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17684 | ||
d62a17ae | 17685 | /* "bgp cluster-id" commands. */ |
17686 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17687 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17688 | ||
c163f297 DS |
17689 | /* "bgp no-rib" commands. */ |
17690 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17691 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17692 | ||
e46723a5 DS |
17693 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
17694 | ||
d62a17ae | 17695 | /* "bgp confederation" commands. */ |
17696 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17697 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17698 | ||
17699 | /* "bgp confederation peers" commands. */ | |
17700 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17701 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17702 | ||
17703 | /* bgp max-med command */ | |
17704 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17705 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17706 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17707 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17708 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17709 | ||
17710 | /* bgp disable-ebgp-connected-nh-check */ | |
17711 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17712 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17713 | ||
17714 | /* bgp update-delay command */ | |
17715 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17716 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17717 | |
17718 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17719 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17720 | |
17721 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17722 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17723 | ||
17724 | /* "maximum-paths" commands. */ | |
17725 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17726 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17727 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17728 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17729 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17730 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17731 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17732 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17733 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17734 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17735 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17736 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17737 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17738 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17739 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17740 | ||
39edabac PG |
17741 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17742 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17743 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17744 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17745 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17746 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17747 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17748 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17749 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17750 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17751 | ||
17752 | /* "timers bgp" commands. */ | |
17753 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17754 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17755 | ||
b042667a TI |
17756 | /* "minimum-holdtime" commands. */ |
17757 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
17758 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
17759 | ||
d62a17ae | 17760 | /* route-map delay-timer commands - per instance for backwards compat. |
17761 | */ | |
17762 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17763 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17764 | ||
17765 | /* "bgp client-to-client reflection" commands */ | |
17766 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17767 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17768 | ||
17769 | /* "bgp always-compare-med" commands */ | |
17770 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17771 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17772 | ||
9dac9fc8 DA |
17773 | /* bgp ebgp-requires-policy */ |
17774 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17775 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17776 | ||
2adac256 DA |
17777 | /* bgp suppress-duplicates */ |
17778 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
17779 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
17780 | ||
fb29348a DA |
17781 | /* bgp reject-as-sets */ |
17782 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17783 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17784 | ||
d62a17ae | 17785 | /* "bgp deterministic-med" commands */ |
17786 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17787 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17788 | ||
055679e9 | 17789 | /* "bgp graceful-restart" command */ |
36235319 QY |
17790 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17791 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17792 | |
17793 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17794 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17795 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17796 | |
17797 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17798 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17799 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17800 | |
17801 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17802 | install_element(BGP_NODE, | |
17803 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17804 | install_element(BGP_NODE, | |
17805 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17806 | ||
17807 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17808 | install_element(BGP_NODE, | |
17809 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17810 | install_element(BGP_NODE, | |
17811 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17812 | ||
d62a17ae | 17813 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17814 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17815 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17816 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17817 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17818 | install_element(BGP_NODE, |
17819 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17820 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17821 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17822 | ||
d6e3c15b | 17823 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17824 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17825 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17826 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17827 | |
7f323236 DW |
17828 | /* "bgp graceful-shutdown" commands */ |
17829 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17830 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17831 | ||
d62a17ae | 17832 | /* "bgp fast-external-failover" commands */ |
17833 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17834 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17835 | ||
d62a17ae | 17836 | /* "bgp bestpath compare-routerid" commands */ |
17837 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17838 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17839 | ||
17840 | /* "bgp bestpath as-path ignore" commands */ | |
17841 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17842 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17843 | ||
17844 | /* "bgp bestpath as-path confed" commands */ | |
17845 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17846 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17847 | ||
17848 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17849 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17850 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17851 | ||
ee88563a JM |
17852 | /* "bgp bestpath peer-type multipath-relax" commands */ |
17853 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
17854 | install_element(BGP_NODE, | |
17855 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
17856 | ||
d62a17ae | 17857 | /* "bgp log-neighbor-changes" commands */ |
17858 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17859 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17860 | ||
17861 | /* "bgp bestpath med" commands */ | |
17862 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17863 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17864 | ||
f7e1c681 | 17865 | /* "bgp bestpath bandwidth" commands */ |
17866 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17867 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17868 | |
b16bcbba TA |
17869 | /* "no bgp default <afi>-<safi>" commands. */ |
17870 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 17871 | |
d62a17ae | 17872 | /* "bgp network import-check" commands. */ |
17873 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
17874 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
17875 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
17876 | ||
17877 | /* "bgp default local-preference" commands. */ | |
17878 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
17879 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
17880 | ||
17881 | /* bgp default show-hostname */ | |
17882 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
17883 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
17884 | ||
aef999a2 DA |
17885 | /* bgp default show-nexthop-hostname */ |
17886 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
17887 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
17888 | ||
d62a17ae | 17889 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
17890 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
17891 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
17892 | ||
17893 | /* bgp ibgp-allow-policy-mods command */ | |
17894 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
17895 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
17896 | ||
17897 | /* "bgp listen limit" commands. */ | |
17898 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
17899 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
17900 | ||
17901 | /* "bgp listen range" commands. */ | |
17902 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
17903 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
17904 | ||
8175f54a | 17905 | /* "bgp default shutdown" command */ |
f26845f9 | 17906 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
17907 | |
17908 | /* "bgp shutdown" commands */ | |
17909 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 17910 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 17911 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 17912 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 17913 | |
d62a17ae | 17914 | /* "neighbor remote-as" commands. */ |
17915 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
17916 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
17917 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
17918 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
17919 | install_element(BGP_NODE, | |
17920 | &neighbor_interface_v6only_config_remote_as_cmd); | |
17921 | install_element(BGP_NODE, &no_neighbor_cmd); | |
17922 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
17923 | ||
17924 | /* "neighbor peer-group" commands. */ | |
17925 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
17926 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
17927 | install_element(BGP_NODE, | |
17928 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
17929 | ||
17930 | /* "neighbor local-as" commands. */ | |
17931 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
17932 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
17933 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
17934 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
17935 | ||
17936 | /* "neighbor solo" commands. */ | |
17937 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
17938 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
17939 | ||
17940 | /* "neighbor password" commands. */ | |
17941 | install_element(BGP_NODE, &neighbor_password_cmd); | |
17942 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
17943 | ||
17944 | /* "neighbor activate" commands. */ | |
17945 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
17946 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
17947 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
17948 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
17949 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
17950 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
17951 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
17952 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
17953 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 17954 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
17955 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 17956 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
17957 | ||
17958 | /* "no neighbor activate" commands. */ | |
17959 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
17960 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
17961 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
17962 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
17963 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
17964 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
17965 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
17966 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
17967 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 17968 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
17969 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 17970 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
17971 | ||
17972 | /* "neighbor peer-group" set commands. */ | |
17973 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
17974 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17975 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17976 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17977 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17978 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17979 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
17980 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17981 | install_element(BGP_FLOWSPECV4_NODE, |
17982 | &neighbor_set_peer_group_hidden_cmd); | |
17983 | install_element(BGP_FLOWSPECV6_NODE, | |
17984 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17985 | |
17986 | /* "no neighbor peer-group unset" commands. */ | |
17987 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
17988 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17989 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17990 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17991 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17992 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17993 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
17994 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 17995 | install_element(BGP_FLOWSPECV4_NODE, |
17996 | &no_neighbor_set_peer_group_hidden_cmd); | |
17997 | install_element(BGP_FLOWSPECV6_NODE, | |
17998 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 17999 | |
18000 | /* "neighbor softreconfiguration inbound" commands.*/ | |
18001 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
18002 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
18003 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18004 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18005 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18006 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18007 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18008 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18009 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18010 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18011 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18012 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18013 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18014 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18015 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18016 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18017 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18018 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 18019 | install_element(BGP_FLOWSPECV4_NODE, |
18020 | &neighbor_soft_reconfiguration_cmd); | |
18021 | install_element(BGP_FLOWSPECV4_NODE, | |
18022 | &no_neighbor_soft_reconfiguration_cmd); | |
18023 | install_element(BGP_FLOWSPECV6_NODE, | |
18024 | &neighbor_soft_reconfiguration_cmd); | |
18025 | install_element(BGP_FLOWSPECV6_NODE, | |
18026 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
18027 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
18028 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 18029 | |
18030 | /* "neighbor attribute-unchanged" commands. */ | |
18031 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
18032 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
18033 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
18034 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18035 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
18036 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18037 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
18038 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18039 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
18040 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18041 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
18042 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18043 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
18044 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18045 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18046 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18047 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18048 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18049 | ||
18050 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
18051 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
18052 | ||
b8ad84d2 PG |
18053 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
18054 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18055 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
18056 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18057 | ||
d62a17ae | 18058 | /* "nexthop-local unchanged" commands */ |
18059 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
18060 | install_element(BGP_IPV6_NODE, | |
18061 | &no_neighbor_nexthop_local_unchanged_cmd); | |
18062 | ||
18063 | /* "neighbor next-hop-self" commands. */ | |
18064 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
18065 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
18066 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
18067 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18068 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
18069 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
18070 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
18071 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
18072 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
18073 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18074 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
18075 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
18076 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
18077 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
18078 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
18079 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18080 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
18081 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
18082 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
18083 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 18084 | |
18085 | /* "neighbor next-hop-self force" commands. */ | |
18086 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
18087 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
18088 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18089 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18090 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
18091 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18092 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18093 | install_element(BGP_IPV4_NODE, | |
18094 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18095 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
18096 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18097 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18098 | install_element(BGP_IPV4M_NODE, | |
18099 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18100 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
18101 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18102 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18103 | install_element(BGP_IPV4L_NODE, | |
18104 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18105 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
18106 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18107 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18108 | install_element(BGP_IPV6_NODE, | |
18109 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18110 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
18111 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18112 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18113 | install_element(BGP_IPV6M_NODE, | |
18114 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18115 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
18116 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18117 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18118 | install_element(BGP_IPV6L_NODE, | |
18119 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18120 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
18121 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18122 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18123 | install_element(BGP_VPNV4_NODE, | |
18124 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18125 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
18126 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18127 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18128 | install_element(BGP_VPNV6_NODE, | |
18129 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
18130 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
18131 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 18132 | |
18133 | /* "neighbor as-override" commands. */ | |
18134 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18135 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18136 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18137 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18138 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18139 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18140 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18141 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18142 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18143 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18144 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18145 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18146 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18147 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18148 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18149 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18150 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18151 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18152 | ||
18153 | /* "neighbor remove-private-AS" commands. */ | |
18154 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18155 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18156 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18157 | install_element(BGP_NODE, | |
18158 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18159 | install_element(BGP_NODE, | |
18160 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18161 | install_element(BGP_NODE, | |
18162 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18163 | install_element(BGP_NODE, | |
18164 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18165 | install_element( | |
18166 | BGP_NODE, | |
18167 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18168 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18169 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18170 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18171 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18172 | install_element(BGP_IPV4_NODE, | |
18173 | &neighbor_remove_private_as_replace_as_cmd); | |
18174 | install_element(BGP_IPV4_NODE, | |
18175 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18176 | install_element(BGP_IPV4_NODE, | |
18177 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18178 | install_element(BGP_IPV4_NODE, | |
18179 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18180 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18181 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18182 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18183 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18184 | install_element(BGP_IPV4M_NODE, | |
18185 | &neighbor_remove_private_as_replace_as_cmd); | |
18186 | install_element(BGP_IPV4M_NODE, | |
18187 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18188 | install_element(BGP_IPV4M_NODE, | |
18189 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18190 | install_element(BGP_IPV4M_NODE, | |
18191 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18192 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18193 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18194 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18195 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18196 | install_element(BGP_IPV4L_NODE, | |
18197 | &neighbor_remove_private_as_replace_as_cmd); | |
18198 | install_element(BGP_IPV4L_NODE, | |
18199 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18200 | install_element(BGP_IPV4L_NODE, | |
18201 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18202 | install_element(BGP_IPV4L_NODE, | |
18203 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18204 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
18205 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18206 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18207 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18208 | install_element(BGP_IPV6_NODE, | |
18209 | &neighbor_remove_private_as_replace_as_cmd); | |
18210 | install_element(BGP_IPV6_NODE, | |
18211 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18212 | install_element(BGP_IPV6_NODE, | |
18213 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18214 | install_element(BGP_IPV6_NODE, | |
18215 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18216 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
18217 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
18218 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
18219 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18220 | install_element(BGP_IPV6M_NODE, | |
18221 | &neighbor_remove_private_as_replace_as_cmd); | |
18222 | install_element(BGP_IPV6M_NODE, | |
18223 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18224 | install_element(BGP_IPV6M_NODE, | |
18225 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18226 | install_element(BGP_IPV6M_NODE, | |
18227 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18228 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
18229 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
18230 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
18231 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18232 | install_element(BGP_IPV6L_NODE, | |
18233 | &neighbor_remove_private_as_replace_as_cmd); | |
18234 | install_element(BGP_IPV6L_NODE, | |
18235 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18236 | install_element(BGP_IPV6L_NODE, | |
18237 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18238 | install_element(BGP_IPV6L_NODE, | |
18239 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18240 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
18241 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18242 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18243 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18244 | install_element(BGP_VPNV4_NODE, | |
18245 | &neighbor_remove_private_as_replace_as_cmd); | |
18246 | install_element(BGP_VPNV4_NODE, | |
18247 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18248 | install_element(BGP_VPNV4_NODE, | |
18249 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18250 | install_element(BGP_VPNV4_NODE, | |
18251 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18252 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
18253 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18254 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18255 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18256 | install_element(BGP_VPNV6_NODE, | |
18257 | &neighbor_remove_private_as_replace_as_cmd); | |
18258 | install_element(BGP_VPNV6_NODE, | |
18259 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18260 | install_element(BGP_VPNV6_NODE, | |
18261 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18262 | install_element(BGP_VPNV6_NODE, | |
18263 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18264 | ||
18265 | /* "neighbor send-community" commands.*/ | |
18266 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
18267 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
18268 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
18269 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
18270 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
18271 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
18272 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
18273 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
18274 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
18275 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
18276 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
18277 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
18278 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
18279 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
18280 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
18281 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
18282 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
18283 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
18284 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
18285 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
18286 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
18287 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
18288 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
18289 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
18290 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
18291 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
18292 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
18293 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
18294 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
18295 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
18296 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
18297 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
18298 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
18299 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18300 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18301 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18302 | ||
18303 | /* "neighbor route-reflector" commands.*/ | |
18304 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18305 | install_element(BGP_NODE, | |
18306 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18307 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18308 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18309 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18310 | install_element(BGP_IPV4M_NODE, | |
18311 | &no_neighbor_route_reflector_client_cmd); | |
18312 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18313 | install_element(BGP_IPV4L_NODE, | |
18314 | &no_neighbor_route_reflector_client_cmd); | |
18315 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18316 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18317 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18318 | install_element(BGP_IPV6M_NODE, | |
18319 | &no_neighbor_route_reflector_client_cmd); | |
18320 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18321 | install_element(BGP_IPV6L_NODE, | |
18322 | &no_neighbor_route_reflector_client_cmd); | |
18323 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18324 | install_element(BGP_VPNV4_NODE, | |
18325 | &no_neighbor_route_reflector_client_cmd); | |
18326 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18327 | install_element(BGP_VPNV6_NODE, | |
18328 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18329 | install_element(BGP_FLOWSPECV4_NODE, |
18330 | &neighbor_route_reflector_client_cmd); | |
18331 | install_element(BGP_FLOWSPECV4_NODE, | |
18332 | &no_neighbor_route_reflector_client_cmd); | |
18333 | install_element(BGP_FLOWSPECV6_NODE, | |
18334 | &neighbor_route_reflector_client_cmd); | |
18335 | install_element(BGP_FLOWSPECV6_NODE, | |
18336 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18337 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18338 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18339 | ||
18340 | /* "neighbor route-server" commands.*/ | |
18341 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18342 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18343 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18344 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18345 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18346 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18347 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18348 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18349 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18350 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18351 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18352 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18353 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18354 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18355 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18356 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18357 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18358 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18359 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18360 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18361 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18362 | install_element(BGP_FLOWSPECV4_NODE, | |
18363 | &no_neighbor_route_server_client_cmd); | |
18364 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18365 | install_element(BGP_FLOWSPECV6_NODE, | |
18366 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18367 | |
7c0e4312 DA |
18368 | /* "neighbor disable-addpath-rx" commands. */ |
18369 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18370 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18371 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18372 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18373 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18374 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18375 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18376 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18377 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18378 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18379 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18380 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18381 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18382 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18383 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18384 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18385 | ||
d62a17ae | 18386 | /* "neighbor addpath-tx-all-paths" commands.*/ |
18387 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18388 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18389 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18390 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18391 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18392 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18393 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18394 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18395 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18396 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18397 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18398 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18399 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18400 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18401 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18402 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18403 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18404 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18405 | ||
18406 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18407 | install_element(BGP_NODE, | |
18408 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18409 | install_element(BGP_NODE, | |
18410 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18411 | install_element(BGP_IPV4_NODE, | |
18412 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18413 | install_element(BGP_IPV4_NODE, | |
18414 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18415 | install_element(BGP_IPV4M_NODE, | |
18416 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18417 | install_element(BGP_IPV4M_NODE, | |
18418 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18419 | install_element(BGP_IPV4L_NODE, | |
18420 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18421 | install_element(BGP_IPV4L_NODE, | |
18422 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18423 | install_element(BGP_IPV6_NODE, | |
18424 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18425 | install_element(BGP_IPV6_NODE, | |
18426 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18427 | install_element(BGP_IPV6M_NODE, | |
18428 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18429 | install_element(BGP_IPV6M_NODE, | |
18430 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18431 | install_element(BGP_IPV6L_NODE, | |
18432 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18433 | install_element(BGP_IPV6L_NODE, | |
18434 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18435 | install_element(BGP_VPNV4_NODE, | |
18436 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18437 | install_element(BGP_VPNV4_NODE, | |
18438 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18439 | install_element(BGP_VPNV6_NODE, | |
18440 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18441 | install_element(BGP_VPNV6_NODE, | |
18442 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18443 | ||
2b31007c RZ |
18444 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18445 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18446 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18447 | ||
d62a17ae | 18448 | /* "neighbor passive" commands. */ |
18449 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18450 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18451 | ||
18452 | ||
18453 | /* "neighbor shutdown" commands. */ | |
18454 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18455 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18456 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18457 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18458 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18459 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18460 | |
18461 | /* "neighbor capability extended-nexthop" commands.*/ | |
18462 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18463 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18464 | ||
18465 | /* "neighbor capability orf prefix-list" commands.*/ | |
18466 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18467 | install_element(BGP_NODE, | |
18468 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18469 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18470 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18471 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18472 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18473 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18474 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18475 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18476 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18477 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18478 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18479 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18480 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18481 | ||
18482 | /* "neighbor capability dynamic" commands.*/ | |
18483 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18484 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18485 | ||
18486 | /* "neighbor dont-capability-negotiate" commands. */ | |
18487 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18488 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18489 | ||
18490 | /* "neighbor ebgp-multihop" commands. */ | |
18491 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18492 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18493 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18494 | ||
18495 | /* "neighbor disable-connected-check" commands. */ | |
18496 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18497 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18498 | ||
7ab294ea DA |
18499 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
18500 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
18501 | install_element(BGP_NODE, | |
18502 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 18503 | |
47cbc09b PM |
18504 | /* "neighbor enforce-first-as" commands. */ |
18505 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18506 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18507 | ||
d62a17ae | 18508 | /* "neighbor description" commands. */ |
18509 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18510 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18511 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18512 | |
18513 | /* "neighbor update-source" commands. "*/ | |
18514 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18515 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18516 | ||
18517 | /* "neighbor default-originate" commands. */ | |
18518 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18519 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18520 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18521 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18522 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18523 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18524 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18525 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18526 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18527 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18528 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18529 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18530 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18531 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18532 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18533 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18534 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18535 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18536 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18537 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18538 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18539 | ||
18540 | /* "neighbor port" commands. */ | |
18541 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18542 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18543 | ||
18544 | /* "neighbor weight" commands. */ | |
18545 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18546 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18547 | ||
18548 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18549 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18550 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18551 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18552 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18553 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18554 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18555 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18556 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18557 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18558 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18559 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18560 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18561 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18562 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18563 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18564 | ||
18565 | /* "neighbor override-capability" commands. */ | |
18566 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18567 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18568 | ||
18569 | /* "neighbor strict-capability-match" commands. */ | |
18570 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18571 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18572 | ||
18573 | /* "neighbor timers" commands. */ | |
18574 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18575 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18576 | ||
18577 | /* "neighbor timers connect" commands. */ | |
18578 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18579 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18580 | ||
d43114f3 DS |
18581 | /* "neighbor timers delayopen" commands. */ |
18582 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
18583 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
18584 | ||
d62a17ae | 18585 | /* "neighbor advertisement-interval" commands. */ |
18586 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18587 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18588 | ||
18589 | /* "neighbor interface" commands. */ | |
18590 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18591 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18592 | ||
18593 | /* "neighbor distribute" commands. */ | |
18594 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18595 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18596 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18597 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18598 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18599 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18600 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18601 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18602 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18603 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18604 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18605 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18606 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18607 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18608 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18609 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18610 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18611 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18612 | ||
18613 | /* "neighbor prefix-list" commands. */ | |
18614 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 18615 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 18616 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18617 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18618 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18619 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18620 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18621 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18622 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18623 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18624 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18625 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18626 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18627 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18628 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18629 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18630 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18631 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18632 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18633 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18634 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18635 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18636 | |
18637 | /* "neighbor filter-list" commands. */ | |
18638 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18639 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18640 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18641 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18642 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18643 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18644 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18645 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18646 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18647 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18648 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18649 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18650 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18651 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18652 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18653 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18654 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18655 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18656 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18657 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18658 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18659 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18660 | |
18661 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
18662 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
18663 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 18664 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18665 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18666 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18667 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18668 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18669 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18670 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18671 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18672 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18673 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18674 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18675 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18676 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18677 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18678 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18679 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18680 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18681 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18682 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18683 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 18684 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18685 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18686 | |
18687 | /* "neighbor unsuppress-map" commands. */ | |
18688 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18689 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18690 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18691 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18692 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18693 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18694 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18695 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18696 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18697 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18698 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18699 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18700 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18701 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18702 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18703 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18704 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18705 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18706 | ||
7f7940e6 | 18707 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 18708 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 18709 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 18710 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18711 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18712 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18713 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18714 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18715 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18716 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18717 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18718 | |
fde246e8 DA |
18719 | /* neighbor maximum-prefix-out commands. */ |
18720 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18721 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18722 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18723 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18724 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18725 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18726 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18727 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18728 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18729 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18730 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18731 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18732 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18733 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18734 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18735 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18736 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18737 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18738 | ||
d62a17ae | 18739 | /* "neighbor maximum-prefix" commands. */ |
18740 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18741 | install_element(BGP_NODE, | |
18742 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18743 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18744 | install_element(BGP_NODE, | |
18745 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18746 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18747 | install_element(BGP_NODE, | |
18748 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18749 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18750 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18751 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18752 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18753 | install_element(BGP_IPV4_NODE, | |
18754 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18755 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18756 | install_element(BGP_IPV4_NODE, | |
18757 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18758 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18759 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18760 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18761 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18762 | install_element(BGP_IPV4M_NODE, | |
18763 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18764 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18765 | install_element(BGP_IPV4M_NODE, | |
18766 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18767 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18768 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18769 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18770 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18771 | install_element(BGP_IPV4L_NODE, | |
18772 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18773 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18774 | install_element(BGP_IPV4L_NODE, | |
18775 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18776 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18777 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18778 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18779 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18780 | install_element(BGP_IPV6_NODE, | |
18781 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18782 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18783 | install_element(BGP_IPV6_NODE, | |
18784 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18785 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18786 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18787 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18788 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18789 | install_element(BGP_IPV6M_NODE, | |
18790 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18791 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18792 | install_element(BGP_IPV6M_NODE, | |
18793 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18794 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18795 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18796 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18797 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18798 | install_element(BGP_IPV6L_NODE, | |
18799 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18800 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18801 | install_element(BGP_IPV6L_NODE, | |
18802 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18803 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18804 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18805 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18806 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18807 | install_element(BGP_VPNV4_NODE, | |
18808 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18809 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18810 | install_element(BGP_VPNV4_NODE, | |
18811 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18812 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18813 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18814 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18815 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18816 | install_element(BGP_VPNV6_NODE, | |
18817 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18818 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18819 | install_element(BGP_VPNV6_NODE, | |
18820 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18821 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18822 | ||
18823 | /* "neighbor allowas-in" */ | |
18824 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18825 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18826 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18827 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18828 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18829 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18830 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18831 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18832 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18833 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18834 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18835 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18836 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18837 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18838 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18839 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18840 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18841 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18842 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18843 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18844 | ||
18845 | /* address-family commands. */ | |
18846 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18847 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18848 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18849 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18850 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18851 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18852 | |
d62a17ae | 18853 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18854 | ||
18855 | /* "exit-address-family" command. */ | |
18856 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18857 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18858 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18859 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18860 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18861 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18862 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18863 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18864 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18865 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18866 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18867 | ||
18868 | /* "clear ip bgp commands" */ | |
18869 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
18870 | ||
18871 | /* clear ip bgp prefix */ | |
18872 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
18873 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
18874 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
18875 | ||
18876 | /* "show [ip] bgp summary" commands. */ | |
18877 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 18878 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 18879 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 18880 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 18881 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
18882 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 18883 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
18884 | ||
18885 | /* "show [ip] bgp neighbors" commands. */ | |
18886 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
18887 | ||
36235319 | 18888 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 18889 | |
d62a17ae | 18890 | /* "show [ip] bgp peer-group" commands. */ |
18891 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
18892 | ||
18893 | /* "show [ip] bgp paths" commands. */ | |
18894 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
18895 | ||
18896 | /* "show [ip] bgp community" commands. */ | |
18897 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
18898 | ||
18899 | /* "show ip bgp large-community" commands. */ | |
18900 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
18901 | /* "show [ip] bgp attribute-info" commands. */ | |
18902 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 18903 | /* "show [ip] bgp route-leak" command */ |
18904 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 18905 | |
18906 | /* "redistribute" commands. */ | |
18907 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
18908 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
18909 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
18910 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
18911 | install_element(BGP_NODE, | |
18912 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
18913 | install_element(BGP_NODE, | |
18914 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
18915 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18916 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
18917 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
18918 | install_element(BGP_NODE, | |
18919 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
18920 | install_element(BGP_NODE, | |
18921 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
18922 | install_element(BGP_NODE, | |
18923 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
18924 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
18925 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
18926 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
18927 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
18928 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
18929 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
18930 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
18931 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
18932 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
18933 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
18934 | install_element(BGP_IPV4_NODE, | |
18935 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
18936 | install_element(BGP_IPV4_NODE, | |
18937 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
18938 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
18939 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
18940 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
18941 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
18942 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
18943 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
18944 | ||
b9c7bc5a PZ |
18945 | /* import|export vpn [route-map WORD] */ |
18946 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
18947 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 18948 | |
12a844a5 DS |
18949 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
18950 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
18951 | ||
d62a17ae | 18952 | /* ttl_security commands */ |
18953 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
18954 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
18955 | ||
18956 | /* "show [ip] bgp memory" commands. */ | |
18957 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
18958 | ||
acf71666 MK |
18959 | /* "show bgp martian next-hop" */ |
18960 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
18961 | ||
48ecf8f5 DS |
18962 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
18963 | ||
d62a17ae | 18964 | /* "show [ip] bgp views" commands. */ |
18965 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
18966 | ||
18967 | /* "show [ip] bgp vrfs" commands. */ | |
18968 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
18969 | ||
18970 | /* Community-list. */ | |
18971 | community_list_vty(); | |
ddb5b488 | 18972 | |
ed0e57e3 DA |
18973 | community_alias_vty(); |
18974 | ||
ddb5b488 | 18975 | /* vpn-policy commands */ |
b9c7bc5a PZ |
18976 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
18977 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
18978 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
18979 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
18980 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
18981 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
18982 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
18983 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
18984 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
18985 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
18986 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
18987 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 18988 | |
301ad80a PG |
18989 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
18990 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
18991 | ||
b9c7bc5a PZ |
18992 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
18993 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
18994 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
18995 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
18996 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
18997 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
18998 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
18999 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19000 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
19001 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
19002 | |
19003 | /* tcp-mss command */ | |
19004 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
19005 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
19006 | |
19007 | /* srv6 commands */ | |
ea372e81 | 19008 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 19009 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 19010 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 19011 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 19012 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
19013 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
19014 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
718e3744 | 19015 | } |
6b0655a2 | 19016 | |
718e3744 | 19017 | #include "memory.h" |
19018 | #include "bgp_regex.h" | |
19019 | #include "bgp_clist.h" | |
19020 | #include "bgp_ecommunity.h" | |
19021 | ||
19022 | /* VTY functions. */ | |
19023 | ||
19024 | /* Direction value to string conversion. */ | |
d62a17ae | 19025 | static const char *community_direct_str(int direct) |
19026 | { | |
19027 | switch (direct) { | |
19028 | case COMMUNITY_DENY: | |
19029 | return "deny"; | |
19030 | case COMMUNITY_PERMIT: | |
19031 | return "permit"; | |
19032 | default: | |
19033 | return "unknown"; | |
19034 | } | |
718e3744 | 19035 | } |
19036 | ||
19037 | /* Display error string. */ | |
d62a17ae | 19038 | static void community_list_perror(struct vty *vty, int ret) |
19039 | { | |
19040 | switch (ret) { | |
19041 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
19042 | vty_out(vty, "%% Can't find community-list\n"); | |
19043 | break; | |
19044 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
19045 | vty_out(vty, "%% Malformed community-list value\n"); | |
19046 | break; | |
19047 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
19048 | vty_out(vty, | |
19049 | "%% Community name conflict, previously defined as standard community\n"); | |
19050 | break; | |
19051 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
19052 | vty_out(vty, | |
19053 | "%% Community name conflict, previously defined as expanded community\n"); | |
19054 | break; | |
19055 | } | |
718e3744 | 19056 | } |
19057 | ||
5bf15956 DW |
19058 | /* "community-list" keyword help string. */ |
19059 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
19060 | ||
7336e101 SP |
19061 | /*community-list standard */ |
19062 | DEFUN (community_list_standard, | |
19063 | bgp_community_list_standard_cmd, | |
a08032fe | 19064 | "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19065 | BGP_STR |
718e3744 | 19066 | COMMUNITY_LIST_STR |
19067 | "Community list number (standard)\n" | |
5bf15956 | 19068 | "Add an standard community-list entry\n" |
718e3744 | 19069 | "Community list name\n" |
2f8cc0e5 DA |
19070 | "Sequence number of an entry\n" |
19071 | "Sequence number\n" | |
718e3744 | 19072 | "Specify community to reject\n" |
19073 | "Specify community to accept\n" | |
19074 | COMMUNITY_VAL_STR) | |
19075 | { | |
d62a17ae | 19076 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19077 | char *seq = NULL; |
d62a17ae | 19078 | int direct = 0; |
19079 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 19080 | int idx = 0; |
7336e101 | 19081 | |
a08032fe | 19082 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19083 | if (idx) |
19084 | seq = argv[idx]->arg; | |
19085 | ||
19086 | idx = 0; | |
d62a17ae | 19087 | argv_find(argv, argc, "(1-99)", &idx); |
19088 | argv_find(argv, argc, "WORD", &idx); | |
19089 | cl_name_or_number = argv[idx]->arg; | |
19090 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19091 | : COMMUNITY_DENY; | |
19092 | argv_find(argv, argc, "AA:NN", &idx); | |
19093 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19094 | |
2f8cc0e5 DA |
19095 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19096 | direct, style); | |
42f914d4 | 19097 | |
d62a17ae | 19098 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19099 | |
d62a17ae | 19100 | if (ret < 0) { |
19101 | /* Display error string. */ | |
19102 | community_list_perror(vty, ret); | |
19103 | return CMD_WARNING_CONFIG_FAILED; | |
19104 | } | |
42f914d4 | 19105 | |
d62a17ae | 19106 | return CMD_SUCCESS; |
718e3744 | 19107 | } |
19108 | ||
7336e101 SP |
19109 | DEFUN (no_community_list_standard_all, |
19110 | no_bgp_community_list_standard_all_cmd, | |
a08032fe | 19111 | "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19112 | NO_STR |
19113 | BGP_STR | |
19114 | COMMUNITY_LIST_STR | |
19115 | "Community list number (standard)\n" | |
19116 | "Add an standard community-list entry\n" | |
19117 | "Community list name\n" | |
2f8cc0e5 DA |
19118 | "Sequence number of an entry\n" |
19119 | "Sequence number\n" | |
7336e101 SP |
19120 | "Specify community to reject\n" |
19121 | "Specify community to accept\n" | |
19122 | COMMUNITY_VAL_STR) | |
718e3744 | 19123 | { |
d62a17ae | 19124 | char *cl_name_or_number = NULL; |
174b5cb9 | 19125 | char *str = NULL; |
d62a17ae | 19126 | int direct = 0; |
19127 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 19128 | char *seq = NULL; |
d62a17ae | 19129 | int idx = 0; |
7336e101 | 19130 | |
a08032fe | 19131 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19132 | if (idx) |
19133 | seq = argv[idx]->arg; | |
19134 | ||
19135 | idx = 0; | |
174b5cb9 DA |
19136 | argv_find(argv, argc, "permit", &idx); |
19137 | argv_find(argv, argc, "deny", &idx); | |
19138 | ||
19139 | if (idx) { | |
19140 | direct = argv_find(argv, argc, "permit", &idx) | |
19141 | ? COMMUNITY_PERMIT | |
19142 | : COMMUNITY_DENY; | |
19143 | ||
19144 | idx = 0; | |
19145 | argv_find(argv, argc, "AA:NN", &idx); | |
19146 | str = argv_concat(argv, argc, idx); | |
19147 | } | |
19148 | ||
19149 | idx = 0; | |
d62a17ae | 19150 | argv_find(argv, argc, "(1-99)", &idx); |
19151 | argv_find(argv, argc, "WORD", &idx); | |
19152 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 19153 | |
2f8cc0e5 | 19154 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19155 | direct, style); |
42f914d4 | 19156 | |
d62a17ae | 19157 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19158 | |
d62a17ae | 19159 | if (ret < 0) { |
19160 | community_list_perror(vty, ret); | |
19161 | return CMD_WARNING_CONFIG_FAILED; | |
19162 | } | |
42f914d4 | 19163 | |
d62a17ae | 19164 | return CMD_SUCCESS; |
718e3744 | 19165 | } |
7336e101 | 19166 | |
174b5cb9 DA |
19167 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
19168 | "no bgp community-list <(1-99)|standard WORD>", | |
19169 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
19170 | "Community list number (standard)\n" | |
19171 | "Add an standard community-list entry\n" | |
19172 | "Community list name\n") | |
19173 | ||
7336e101 SP |
19174 | /*community-list expanded */ |
19175 | DEFUN (community_list_expanded_all, | |
19176 | bgp_community_list_expanded_all_cmd, | |
a08032fe | 19177 | "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19178 | BGP_STR |
19179 | COMMUNITY_LIST_STR | |
718e3744 | 19180 | "Community list number (expanded)\n" |
5bf15956 | 19181 | "Add an expanded community-list entry\n" |
718e3744 | 19182 | "Community list name\n" |
2f8cc0e5 DA |
19183 | "Sequence number of an entry\n" |
19184 | "Sequence number\n" | |
718e3744 | 19185 | "Specify community to reject\n" |
19186 | "Specify community to accept\n" | |
19187 | COMMUNITY_VAL_STR) | |
19188 | { | |
d62a17ae | 19189 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19190 | char *seq = NULL; |
d62a17ae | 19191 | int direct = 0; |
19192 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19193 | int idx = 0; |
7b9a4750 | 19194 | |
a08032fe | 19195 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19196 | if (idx) |
19197 | seq = argv[idx]->arg; | |
19198 | ||
19199 | idx = 0; | |
19200 | ||
d62a17ae | 19201 | argv_find(argv, argc, "(100-500)", &idx); |
19202 | argv_find(argv, argc, "WORD", &idx); | |
19203 | cl_name_or_number = argv[idx]->arg; | |
19204 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19205 | : COMMUNITY_DENY; | |
19206 | argv_find(argv, argc, "AA:NN", &idx); | |
19207 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19208 | |
2f8cc0e5 DA |
19209 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19210 | direct, style); | |
42f914d4 | 19211 | |
d62a17ae | 19212 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19213 | |
d62a17ae | 19214 | if (ret < 0) { |
19215 | /* Display error string. */ | |
19216 | community_list_perror(vty, ret); | |
19217 | return CMD_WARNING_CONFIG_FAILED; | |
19218 | } | |
42f914d4 | 19219 | |
d62a17ae | 19220 | return CMD_SUCCESS; |
718e3744 | 19221 | } |
19222 | ||
7336e101 SP |
19223 | DEFUN (no_community_list_expanded_all, |
19224 | no_bgp_community_list_expanded_all_cmd, | |
a08032fe | 19225 | "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19226 | NO_STR |
19227 | BGP_STR | |
19228 | COMMUNITY_LIST_STR | |
19229 | "Community list number (expanded)\n" | |
19230 | "Add an expanded community-list entry\n" | |
19231 | "Community list name\n" | |
2f8cc0e5 DA |
19232 | "Sequence number of an entry\n" |
19233 | "Sequence number\n" | |
7336e101 SP |
19234 | "Specify community to reject\n" |
19235 | "Specify community to accept\n" | |
19236 | COMMUNITY_VAL_STR) | |
718e3744 | 19237 | { |
d62a17ae | 19238 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19239 | char *seq = NULL; |
174b5cb9 | 19240 | char *str = NULL; |
d62a17ae | 19241 | int direct = 0; |
19242 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19243 | int idx = 0; |
174b5cb9 | 19244 | |
a08032fe | 19245 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19246 | if (idx) |
19247 | seq = argv[idx]->arg; | |
19248 | ||
19249 | idx = 0; | |
174b5cb9 DA |
19250 | argv_find(argv, argc, "permit", &idx); |
19251 | argv_find(argv, argc, "deny", &idx); | |
19252 | ||
19253 | if (idx) { | |
19254 | direct = argv_find(argv, argc, "permit", &idx) | |
19255 | ? COMMUNITY_PERMIT | |
19256 | : COMMUNITY_DENY; | |
19257 | ||
19258 | idx = 0; | |
19259 | argv_find(argv, argc, "AA:NN", &idx); | |
19260 | str = argv_concat(argv, argc, idx); | |
7336e101 | 19261 | } |
174b5cb9 DA |
19262 | |
19263 | idx = 0; | |
d62a17ae | 19264 | argv_find(argv, argc, "(100-500)", &idx); |
19265 | argv_find(argv, argc, "WORD", &idx); | |
19266 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 19267 | |
2f8cc0e5 | 19268 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19269 | direct, style); |
42f914d4 | 19270 | |
d62a17ae | 19271 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19272 | |
d62a17ae | 19273 | if (ret < 0) { |
19274 | community_list_perror(vty, ret); | |
19275 | return CMD_WARNING_CONFIG_FAILED; | |
19276 | } | |
42f914d4 | 19277 | |
d62a17ae | 19278 | return CMD_SUCCESS; |
718e3744 | 19279 | } |
19280 | ||
36d4bb44 EB |
19281 | ALIAS(no_community_list_expanded_all, |
19282 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 19283 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 19284 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
19285 | "Community list number (expanded)\n" |
19286 | "Add an expanded community-list entry\n" | |
19287 | "Community list name\n") | |
19288 | ||
8d9b8ed9 PM |
19289 | /* Return configuration string of community-list entry. */ |
19290 | static const char *community_list_config_str(struct community_entry *entry) | |
19291 | { | |
19292 | const char *str; | |
19293 | ||
19294 | if (entry->any) | |
19295 | str = ""; | |
19296 | else { | |
19297 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
19298 | str = community_str(entry->u.com, false); | |
19299 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
19300 | str = lcommunity_str(entry->u.lcom, false); | |
19301 | else | |
19302 | str = entry->config; | |
19303 | } | |
19304 | return str; | |
19305 | } | |
19306 | ||
d62a17ae | 19307 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19308 | { |
d62a17ae | 19309 | struct community_entry *entry; |
718e3744 | 19310 | |
d62a17ae | 19311 | for (entry = list->head; entry; entry = entry->next) { |
19312 | if (entry == list->head) { | |
19313 | if (all_digit(list->name)) | |
19314 | vty_out(vty, "Community %s list %s\n", | |
19315 | entry->style == COMMUNITY_LIST_STANDARD | |
19316 | ? "standard" | |
19317 | : "(expanded) access", | |
19318 | list->name); | |
19319 | else | |
19320 | vty_out(vty, "Named Community %s list %s\n", | |
19321 | entry->style == COMMUNITY_LIST_STANDARD | |
19322 | ? "standard" | |
19323 | : "expanded", | |
19324 | list->name); | |
19325 | } | |
19326 | if (entry->any) | |
19327 | vty_out(vty, " %s\n", | |
19328 | community_direct_str(entry->direct)); | |
19329 | else | |
19330 | vty_out(vty, " %s %s\n", | |
19331 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19332 | community_list_config_str(entry)); |
d62a17ae | 19333 | } |
718e3744 | 19334 | } |
19335 | ||
7336e101 SP |
19336 | DEFUN (show_community_list, |
19337 | show_bgp_community_list_cmd, | |
19338 | "show bgp community-list", | |
718e3744 | 19339 | SHOW_STR |
7336e101 | 19340 | BGP_STR |
718e3744 | 19341 | "List community-list\n") |
19342 | { | |
d62a17ae | 19343 | struct community_list *list; |
19344 | struct community_list_master *cm; | |
718e3744 | 19345 | |
d62a17ae | 19346 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19347 | if (!cm) | |
19348 | return CMD_SUCCESS; | |
718e3744 | 19349 | |
d62a17ae | 19350 | for (list = cm->num.head; list; list = list->next) |
19351 | community_list_show(vty, list); | |
718e3744 | 19352 | |
d62a17ae | 19353 | for (list = cm->str.head; list; list = list->next) |
19354 | community_list_show(vty, list); | |
718e3744 | 19355 | |
d62a17ae | 19356 | return CMD_SUCCESS; |
718e3744 | 19357 | } |
19358 | ||
7336e101 SP |
19359 | DEFUN (show_community_list_arg, |
19360 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 19361 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
19362 | SHOW_STR |
19363 | BGP_STR | |
718e3744 | 19364 | "List community-list\n" |
19365 | "Community-list number\n" | |
960b69b9 | 19366 | "Community-list name\n" |
19367 | "Detailed information on community-list\n") | |
718e3744 | 19368 | { |
d62a17ae | 19369 | int idx_comm_list = 3; |
19370 | struct community_list *list; | |
718e3744 | 19371 | |
e237b0d2 | 19372 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19373 | COMMUNITY_LIST_MASTER); |
19374 | if (!list) { | |
19375 | vty_out(vty, "%% Can't find community-list\n"); | |
19376 | return CMD_WARNING; | |
19377 | } | |
718e3744 | 19378 | |
d62a17ae | 19379 | community_list_show(vty, list); |
718e3744 | 19380 | |
d62a17ae | 19381 | return CMD_SUCCESS; |
718e3744 | 19382 | } |
6b0655a2 | 19383 | |
57d187bc JS |
19384 | /* |
19385 | * Large Community code. | |
19386 | */ | |
d62a17ae | 19387 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19388 | struct cmd_token **argv, int style, | |
19389 | int reject_all_digit_name) | |
19390 | { | |
19391 | int ret; | |
19392 | int direct; | |
19393 | char *str; | |
19394 | int idx = 0; | |
19395 | char *cl_name; | |
2f8cc0e5 DA |
19396 | char *seq = NULL; |
19397 | ||
a08032fe | 19398 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19399 | seq = argv[idx]->arg; |
d62a17ae | 19400 | |
2f8cc0e5 | 19401 | idx = 0; |
d62a17ae | 19402 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19403 | : COMMUNITY_DENY; | |
19404 | ||
19405 | /* All digit name check. */ | |
19406 | idx = 0; | |
19407 | argv_find(argv, argc, "WORD", &idx); | |
19408 | argv_find(argv, argc, "(1-99)", &idx); | |
19409 | argv_find(argv, argc, "(100-500)", &idx); | |
19410 | cl_name = argv[idx]->arg; | |
19411 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19412 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19413 | return CMD_WARNING_CONFIG_FAILED; | |
19414 | } | |
19415 | ||
19416 | idx = 0; | |
19417 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19418 | argv_find(argv, argc, "LINE", &idx); | |
19419 | /* Concat community string argument. */ | |
19420 | if (idx) | |
19421 | str = argv_concat(argv, argc, idx); | |
19422 | else | |
19423 | str = NULL; | |
19424 | ||
2f8cc0e5 | 19425 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19426 | |
19427 | /* Free temporary community list string allocated by | |
19428 | argv_concat(). */ | |
0a22ddfb | 19429 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19430 | |
19431 | if (ret < 0) { | |
19432 | community_list_perror(vty, ret); | |
19433 | return CMD_WARNING_CONFIG_FAILED; | |
19434 | } | |
19435 | return CMD_SUCCESS; | |
19436 | } | |
19437 | ||
19438 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19439 | struct cmd_token **argv, int style) | |
19440 | { | |
19441 | int ret; | |
19442 | int direct = 0; | |
19443 | char *str = NULL; | |
19444 | int idx = 0; | |
2f8cc0e5 | 19445 | char *seq = NULL; |
d62a17ae | 19446 | |
a08032fe | 19447 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19448 | seq = argv[idx]->arg; |
d62a17ae | 19449 | |
2f8cc0e5 | 19450 | idx = 0; |
d62a17ae | 19451 | argv_find(argv, argc, "permit", &idx); |
19452 | argv_find(argv, argc, "deny", &idx); | |
19453 | ||
19454 | if (idx) { | |
19455 | /* Check the list direct. */ | |
19456 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19457 | direct = COMMUNITY_PERMIT; | |
19458 | else | |
19459 | direct = COMMUNITY_DENY; | |
19460 | ||
19461 | idx = 0; | |
19462 | argv_find(argv, argc, "LINE", &idx); | |
19463 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19464 | /* Concat community string argument. */ | |
19465 | str = argv_concat(argv, argc, idx); | |
19466 | } | |
19467 | ||
19468 | idx = 0; | |
19469 | argv_find(argv, argc, "(1-99)", &idx); | |
19470 | argv_find(argv, argc, "(100-500)", &idx); | |
19471 | argv_find(argv, argc, "WORD", &idx); | |
19472 | ||
19473 | /* Unset community list. */ | |
2f8cc0e5 | 19474 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19475 | style); |
19476 | ||
19477 | /* Free temporary community list string allocated by | |
19478 | argv_concat(). */ | |
0a22ddfb | 19479 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19480 | |
19481 | if (ret < 0) { | |
19482 | community_list_perror(vty, ret); | |
19483 | return CMD_WARNING_CONFIG_FAILED; | |
19484 | } | |
19485 | ||
19486 | return CMD_SUCCESS; | |
57d187bc JS |
19487 | } |
19488 | ||
19489 | /* "large-community-list" keyword help string. */ | |
19490 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19491 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19492 | ||
7336e101 SP |
19493 | DEFUN (lcommunity_list_standard, |
19494 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19495 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19496 | BGP_STR |
19497 | LCOMMUNITY_LIST_STR | |
19498 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19499 | "Sequence number of an entry\n" |
19500 | "Sequence number\n" | |
7336e101 SP |
19501 | "Specify large community to reject\n" |
19502 | "Specify large community to accept\n" | |
19503 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19504 | { |
d62a17ae | 19505 | return lcommunity_list_set_vty(vty, argc, argv, |
19506 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19507 | } |
19508 | ||
7336e101 SP |
19509 | DEFUN (lcommunity_list_expanded, |
19510 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19511 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19512 | BGP_STR |
19513 | LCOMMUNITY_LIST_STR | |
19514 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19515 | "Sequence number of an entry\n" |
19516 | "Sequence number\n" | |
7336e101 SP |
19517 | "Specify large community to reject\n" |
19518 | "Specify large community to accept\n" | |
19519 | "An ordered list as a regular-expression\n") | |
57d187bc | 19520 | { |
d62a17ae | 19521 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19522 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19523 | } |
19524 | ||
7336e101 SP |
19525 | DEFUN (lcommunity_list_name_standard, |
19526 | bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 19527 | "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19528 | BGP_STR |
19529 | LCOMMUNITY_LIST_STR | |
19530 | "Specify standard large-community-list\n" | |
19531 | "Large Community list name\n" | |
2f8cc0e5 DA |
19532 | "Sequence number of an entry\n" |
19533 | "Sequence number\n" | |
7336e101 SP |
19534 | "Specify large community to reject\n" |
19535 | "Specify large community to accept\n" | |
19536 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19537 | { |
d62a17ae | 19538 | return lcommunity_list_set_vty(vty, argc, argv, |
19539 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19540 | } |
19541 | ||
7336e101 SP |
19542 | DEFUN (lcommunity_list_name_expanded, |
19543 | bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 19544 | "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19545 | BGP_STR |
19546 | LCOMMUNITY_LIST_STR | |
19547 | "Specify expanded large-community-list\n" | |
19548 | "Large Community list name\n" | |
2f8cc0e5 DA |
19549 | "Sequence number of an entry\n" |
19550 | "Sequence number\n" | |
7336e101 SP |
19551 | "Specify large community to reject\n" |
19552 | "Specify large community to accept\n" | |
19553 | "An ordered list as a regular-expression\n") | |
57d187bc | 19554 | { |
d62a17ae | 19555 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19556 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19557 | } |
19558 | ||
4378f57c DA |
19559 | DEFUN (no_lcommunity_list_all, |
19560 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
19561 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
19562 | NO_STR | |
19563 | BGP_STR | |
19564 | LCOMMUNITY_LIST_STR | |
19565 | "Large Community list number (standard)\n" | |
19566 | "Large Community list number (expanded)\n" | |
19567 | "Large Community list name\n") | |
57d187bc | 19568 | { |
7336e101 SP |
19569 | return lcommunity_list_unset_vty(vty, argc, argv, |
19570 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19571 | } |
19572 | ||
4378f57c DA |
19573 | DEFUN (no_lcommunity_list_name_standard_all, |
19574 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
19575 | "no bgp large-community-list standard WORD", | |
19576 | NO_STR | |
19577 | BGP_STR | |
19578 | LCOMMUNITY_LIST_STR | |
19579 | "Specify standard large-community-list\n" | |
19580 | "Large Community list name\n") | |
19581 | { | |
19582 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19583 | LARGE_COMMUNITY_LIST_STANDARD); | |
19584 | } | |
19585 | ||
7336e101 SP |
19586 | DEFUN (no_lcommunity_list_name_expanded_all, |
19587 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
19588 | "no bgp large-community-list expanded WORD", | |
19589 | NO_STR | |
19590 | BGP_STR | |
19591 | LCOMMUNITY_LIST_STR | |
19592 | "Specify expanded large-community-list\n" | |
19593 | "Large Community list name\n") | |
57d187bc | 19594 | { |
d62a17ae | 19595 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19596 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19597 | } |
19598 | ||
7336e101 SP |
19599 | DEFUN (no_lcommunity_list_standard, |
19600 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19601 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19602 | NO_STR |
19603 | BGP_STR | |
19604 | LCOMMUNITY_LIST_STR | |
19605 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19606 | "Sequence number of an entry\n" |
19607 | "Sequence number\n" | |
7336e101 SP |
19608 | "Specify large community to reject\n" |
19609 | "Specify large community to accept\n" | |
19610 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19611 | { |
d62a17ae | 19612 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19613 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19614 | } |
19615 | ||
7336e101 SP |
19616 | DEFUN (no_lcommunity_list_expanded, |
19617 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19618 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19619 | NO_STR |
19620 | BGP_STR | |
19621 | LCOMMUNITY_LIST_STR | |
19622 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19623 | "Sequence number of an entry\n" |
19624 | "Sequence number\n" | |
7336e101 SP |
19625 | "Specify large community to reject\n" |
19626 | "Specify large community to accept\n" | |
19627 | "An ordered list as a regular-expression\n") | |
57d187bc | 19628 | { |
d62a17ae | 19629 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19630 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19631 | } |
19632 | ||
7336e101 SP |
19633 | DEFUN (no_lcommunity_list_name_standard, |
19634 | no_bgp_lcommunity_list_name_standard_cmd, | |
a08032fe | 19635 | "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19636 | NO_STR |
19637 | BGP_STR | |
19638 | LCOMMUNITY_LIST_STR | |
19639 | "Specify standard large-community-list\n" | |
19640 | "Large Community list name\n" | |
2f8cc0e5 DA |
19641 | "Sequence number of an entry\n" |
19642 | "Sequence number\n" | |
7336e101 SP |
19643 | "Specify large community to reject\n" |
19644 | "Specify large community to accept\n" | |
19645 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19646 | { |
d62a17ae | 19647 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19648 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19649 | } |
19650 | ||
7336e101 SP |
19651 | DEFUN (no_lcommunity_list_name_expanded, |
19652 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a08032fe | 19653 | "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19654 | NO_STR |
19655 | BGP_STR | |
19656 | LCOMMUNITY_LIST_STR | |
19657 | "Specify expanded large-community-list\n" | |
19658 | "Large community list name\n" | |
2f8cc0e5 DA |
19659 | "Sequence number of an entry\n" |
19660 | "Sequence number\n" | |
7336e101 SP |
19661 | "Specify large community to reject\n" |
19662 | "Specify large community to accept\n" | |
19663 | "An ordered list as a regular-expression\n") | |
57d187bc | 19664 | { |
d62a17ae | 19665 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19666 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19667 | } |
19668 | ||
d62a17ae | 19669 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19670 | { | |
19671 | struct community_entry *entry; | |
19672 | ||
19673 | for (entry = list->head; entry; entry = entry->next) { | |
19674 | if (entry == list->head) { | |
19675 | if (all_digit(list->name)) | |
19676 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19677 | entry->style == |
19678 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19679 | ? "standard" |
19680 | : "(expanded) access", | |
19681 | list->name); | |
19682 | else | |
19683 | vty_out(vty, | |
19684 | "Named large community %s list %s\n", | |
169b72c8 | 19685 | entry->style == |
19686 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19687 | ? "standard" |
19688 | : "expanded", | |
19689 | list->name); | |
19690 | } | |
19691 | if (entry->any) | |
19692 | vty_out(vty, " %s\n", | |
19693 | community_direct_str(entry->direct)); | |
19694 | else | |
19695 | vty_out(vty, " %s %s\n", | |
19696 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19697 | community_list_config_str(entry)); |
d62a17ae | 19698 | } |
57d187bc JS |
19699 | } |
19700 | ||
7336e101 SP |
19701 | DEFUN (show_lcommunity_list, |
19702 | show_bgp_lcommunity_list_cmd, | |
19703 | "show bgp large-community-list", | |
57d187bc | 19704 | SHOW_STR |
7336e101 | 19705 | BGP_STR |
57d187bc JS |
19706 | "List large-community list\n") |
19707 | { | |
d62a17ae | 19708 | struct community_list *list; |
19709 | struct community_list_master *cm; | |
57d187bc | 19710 | |
d62a17ae | 19711 | cm = community_list_master_lookup(bgp_clist, |
19712 | LARGE_COMMUNITY_LIST_MASTER); | |
19713 | if (!cm) | |
19714 | return CMD_SUCCESS; | |
57d187bc | 19715 | |
d62a17ae | 19716 | for (list = cm->num.head; list; list = list->next) |
19717 | lcommunity_list_show(vty, list); | |
57d187bc | 19718 | |
d62a17ae | 19719 | for (list = cm->str.head; list; list = list->next) |
19720 | lcommunity_list_show(vty, list); | |
57d187bc | 19721 | |
d62a17ae | 19722 | return CMD_SUCCESS; |
57d187bc JS |
19723 | } |
19724 | ||
7336e101 SP |
19725 | DEFUN (show_lcommunity_list_arg, |
19726 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 19727 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
19728 | SHOW_STR |
19729 | BGP_STR | |
57d187bc | 19730 | "List large-community list\n" |
960b69b9 | 19731 | "Large-community-list number\n" |
19732 | "Large-community-list name\n" | |
19733 | "Detailed information on large-community-list\n") | |
57d187bc | 19734 | { |
d62a17ae | 19735 | struct community_list *list; |
57d187bc | 19736 | |
e237b0d2 | 19737 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19738 | LARGE_COMMUNITY_LIST_MASTER); |
19739 | if (!list) { | |
960b69b9 | 19740 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19741 | return CMD_WARNING; |
19742 | } | |
57d187bc | 19743 | |
d62a17ae | 19744 | lcommunity_list_show(vty, list); |
57d187bc | 19745 | |
d62a17ae | 19746 | return CMD_SUCCESS; |
57d187bc JS |
19747 | } |
19748 | ||
718e3744 | 19749 | /* "extcommunity-list" keyword help string. */ |
19750 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19751 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19752 | ||
7336e101 SP |
19753 | DEFUN (extcommunity_list_standard, |
19754 | bgp_extcommunity_list_standard_cmd, | |
a08032fe | 19755 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19756 | BGP_STR |
718e3744 | 19757 | EXTCOMMUNITY_LIST_STR |
19758 | "Extended Community list number (standard)\n" | |
718e3744 | 19759 | "Specify standard extcommunity-list\n" |
5bf15956 | 19760 | "Community list name\n" |
2f8cc0e5 DA |
19761 | "Sequence number of an entry\n" |
19762 | "Sequence number\n" | |
718e3744 | 19763 | "Specify community to reject\n" |
19764 | "Specify community to accept\n" | |
19765 | EXTCOMMUNITY_VAL_STR) | |
19766 | { | |
d62a17ae | 19767 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19768 | int direct = 0; | |
19769 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19770 | char *seq = NULL; |
42f914d4 | 19771 | |
d62a17ae | 19772 | int idx = 0; |
7b9a4750 | 19773 | |
d62a17ae | 19774 | argv_find(argv, argc, "(1-99)", &idx); |
19775 | argv_find(argv, argc, "WORD", &idx); | |
19776 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19777 | |
a08032fe | 19778 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19779 | seq = argv[idx]->arg; |
19780 | ||
d62a17ae | 19781 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19782 | : COMMUNITY_DENY; | |
19783 | argv_find(argv, argc, "AA:NN", &idx); | |
19784 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19785 | |
2f8cc0e5 | 19786 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19787 | direct, style); |
42f914d4 | 19788 | |
d62a17ae | 19789 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19790 | |
d62a17ae | 19791 | if (ret < 0) { |
19792 | community_list_perror(vty, ret); | |
19793 | return CMD_WARNING_CONFIG_FAILED; | |
19794 | } | |
42f914d4 | 19795 | |
d62a17ae | 19796 | return CMD_SUCCESS; |
718e3744 | 19797 | } |
19798 | ||
7336e101 SP |
19799 | DEFUN (extcommunity_list_name_expanded, |
19800 | bgp_extcommunity_list_name_expanded_cmd, | |
a08032fe | 19801 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19802 | BGP_STR |
19803 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19804 | "Extended Community list number (expanded)\n" |
718e3744 | 19805 | "Specify expanded extcommunity-list\n" |
19806 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19807 | "Sequence number of an entry\n" |
19808 | "Sequence number\n" | |
718e3744 | 19809 | "Specify community to reject\n" |
19810 | "Specify community to accept\n" | |
19811 | "An ordered list as a regular-expression\n") | |
19812 | { | |
d62a17ae | 19813 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19814 | int direct = 0; | |
19815 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19816 | char *seq = NULL; |
d62a17ae | 19817 | int idx = 0; |
7336e101 | 19818 | |
d62a17ae | 19819 | argv_find(argv, argc, "(100-500)", &idx); |
19820 | argv_find(argv, argc, "WORD", &idx); | |
19821 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 19822 | |
a08032fe | 19823 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19824 | seq = argv[idx]->arg; |
19825 | ||
d62a17ae | 19826 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19827 | : COMMUNITY_DENY; | |
19828 | argv_find(argv, argc, "LINE", &idx); | |
19829 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19830 | |
2f8cc0e5 | 19831 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19832 | direct, style); |
42f914d4 | 19833 | |
d62a17ae | 19834 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19835 | |
d62a17ae | 19836 | if (ret < 0) { |
19837 | community_list_perror(vty, ret); | |
19838 | return CMD_WARNING_CONFIG_FAILED; | |
19839 | } | |
42f914d4 | 19840 | |
d62a17ae | 19841 | return CMD_SUCCESS; |
718e3744 | 19842 | } |
19843 | ||
7336e101 SP |
19844 | DEFUN (no_extcommunity_list_standard_all, |
19845 | no_bgp_extcommunity_list_standard_all_cmd, | |
a08032fe | 19846 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19847 | NO_STR |
19848 | BGP_STR | |
19849 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19850 | "Extended Community list number (standard)\n" |
718e3744 | 19851 | "Specify standard extcommunity-list\n" |
5bf15956 | 19852 | "Community list name\n" |
2f8cc0e5 DA |
19853 | "Sequence number of an entry\n" |
19854 | "Sequence number\n" | |
718e3744 | 19855 | "Specify community to reject\n" |
19856 | "Specify community to accept\n" | |
19857 | EXTCOMMUNITY_VAL_STR) | |
19858 | { | |
d62a17ae | 19859 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19860 | int direct = 0; | |
19861 | char *cl_number_or_name = NULL; | |
d4455c89 | 19862 | char *str = NULL; |
2f8cc0e5 | 19863 | char *seq = NULL; |
d62a17ae | 19864 | int idx = 0; |
d4455c89 | 19865 | |
a08032fe | 19866 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19867 | seq = argv[idx]->arg; |
19868 | ||
19869 | idx = 0; | |
d4455c89 DA |
19870 | argv_find(argv, argc, "permit", &idx); |
19871 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
19872 | if (idx) { |
19873 | direct = argv_find(argv, argc, "permit", &idx) | |
19874 | ? COMMUNITY_PERMIT | |
19875 | : COMMUNITY_DENY; | |
19876 | ||
19877 | idx = 0; | |
19878 | argv_find(argv, argc, "AA:NN", &idx); | |
19879 | str = argv_concat(argv, argc, idx); | |
19880 | } | |
19881 | ||
19882 | idx = 0; | |
d62a17ae | 19883 | argv_find(argv, argc, "(1-99)", &idx); |
19884 | argv_find(argv, argc, "WORD", &idx); | |
19885 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19886 | |
d62a17ae | 19887 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19888 | seq, direct, style); |
42f914d4 | 19889 | |
d62a17ae | 19890 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19891 | |
d62a17ae | 19892 | if (ret < 0) { |
19893 | community_list_perror(vty, ret); | |
19894 | return CMD_WARNING_CONFIG_FAILED; | |
19895 | } | |
42f914d4 | 19896 | |
d62a17ae | 19897 | return CMD_SUCCESS; |
718e3744 | 19898 | } |
19899 | ||
d4455c89 DA |
19900 | ALIAS(no_extcommunity_list_standard_all, |
19901 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
19902 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 19903 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19904 | "Extended Community list number (standard)\n" |
19905 | "Specify standard extcommunity-list\n" | |
19906 | "Community list name\n") | |
19907 | ||
7336e101 SP |
19908 | DEFUN (no_extcommunity_list_expanded_all, |
19909 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a08032fe | 19910 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19911 | NO_STR |
19912 | BGP_STR | |
19913 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 19914 | "Extended Community list number (expanded)\n" |
718e3744 | 19915 | "Specify expanded extcommunity-list\n" |
5bf15956 | 19916 | "Extended Community list name\n" |
2f8cc0e5 DA |
19917 | "Sequence number of an entry\n" |
19918 | "Sequence number\n" | |
718e3744 | 19919 | "Specify community to reject\n" |
19920 | "Specify community to accept\n" | |
19921 | "An ordered list as a regular-expression\n") | |
19922 | { | |
d62a17ae | 19923 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19924 | int direct = 0; | |
19925 | char *cl_number_or_name = NULL; | |
d4455c89 | 19926 | char *str = NULL; |
2f8cc0e5 | 19927 | char *seq = NULL; |
d62a17ae | 19928 | int idx = 0; |
d4455c89 | 19929 | |
a08032fe | 19930 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19931 | seq = argv[idx]->arg; |
19932 | ||
19933 | idx = 0; | |
d4455c89 DA |
19934 | argv_find(argv, argc, "permit", &idx); |
19935 | argv_find(argv, argc, "deny", &idx); | |
19936 | ||
19937 | if (idx) { | |
19938 | direct = argv_find(argv, argc, "permit", &idx) | |
19939 | ? COMMUNITY_PERMIT | |
19940 | : COMMUNITY_DENY; | |
19941 | ||
19942 | idx = 0; | |
19943 | argv_find(argv, argc, "LINE", &idx); | |
19944 | str = argv_concat(argv, argc, idx); | |
19945 | } | |
19946 | ||
19947 | idx = 0; | |
d62a17ae | 19948 | argv_find(argv, argc, "(100-500)", &idx); |
19949 | argv_find(argv, argc, "WORD", &idx); | |
19950 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 19951 | |
d62a17ae | 19952 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 19953 | seq, direct, style); |
42f914d4 | 19954 | |
d62a17ae | 19955 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19956 | |
d62a17ae | 19957 | if (ret < 0) { |
19958 | community_list_perror(vty, ret); | |
19959 | return CMD_WARNING_CONFIG_FAILED; | |
19960 | } | |
42f914d4 | 19961 | |
d62a17ae | 19962 | return CMD_SUCCESS; |
718e3744 | 19963 | } |
19964 | ||
d4455c89 DA |
19965 | ALIAS(no_extcommunity_list_expanded_all, |
19966 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
19967 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 19968 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
19969 | "Extended Community list number (expanded)\n" |
19970 | "Specify expanded extcommunity-list\n" | |
19971 | "Extended Community list name\n") | |
19972 | ||
d62a17ae | 19973 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19974 | { |
d62a17ae | 19975 | struct community_entry *entry; |
718e3744 | 19976 | |
d62a17ae | 19977 | for (entry = list->head; entry; entry = entry->next) { |
19978 | if (entry == list->head) { | |
19979 | if (all_digit(list->name)) | |
19980 | vty_out(vty, "Extended community %s list %s\n", | |
19981 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19982 | ? "standard" | |
19983 | : "(expanded) access", | |
19984 | list->name); | |
19985 | else | |
19986 | vty_out(vty, | |
19987 | "Named extended community %s list %s\n", | |
19988 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
19989 | ? "standard" | |
19990 | : "expanded", | |
19991 | list->name); | |
19992 | } | |
19993 | if (entry->any) | |
19994 | vty_out(vty, " %s\n", | |
19995 | community_direct_str(entry->direct)); | |
19996 | else | |
19997 | vty_out(vty, " %s %s\n", | |
19998 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19999 | community_list_config_str(entry)); |
d62a17ae | 20000 | } |
718e3744 | 20001 | } |
20002 | ||
7336e101 SP |
20003 | DEFUN (show_extcommunity_list, |
20004 | show_bgp_extcommunity_list_cmd, | |
20005 | "show bgp extcommunity-list", | |
718e3744 | 20006 | SHOW_STR |
7336e101 | 20007 | BGP_STR |
718e3744 | 20008 | "List extended-community list\n") |
20009 | { | |
d62a17ae | 20010 | struct community_list *list; |
20011 | struct community_list_master *cm; | |
718e3744 | 20012 | |
d62a17ae | 20013 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
20014 | if (!cm) | |
20015 | return CMD_SUCCESS; | |
718e3744 | 20016 | |
d62a17ae | 20017 | for (list = cm->num.head; list; list = list->next) |
20018 | extcommunity_list_show(vty, list); | |
718e3744 | 20019 | |
d62a17ae | 20020 | for (list = cm->str.head; list; list = list->next) |
20021 | extcommunity_list_show(vty, list); | |
718e3744 | 20022 | |
d62a17ae | 20023 | return CMD_SUCCESS; |
718e3744 | 20024 | } |
20025 | ||
7336e101 SP |
20026 | DEFUN (show_extcommunity_list_arg, |
20027 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 20028 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
20029 | SHOW_STR |
20030 | BGP_STR | |
718e3744 | 20031 | "List extended-community list\n" |
20032 | "Extcommunity-list number\n" | |
960b69b9 | 20033 | "Extcommunity-list name\n" |
20034 | "Detailed information on extcommunity-list\n") | |
718e3744 | 20035 | { |
d62a17ae | 20036 | int idx_comm_list = 3; |
20037 | struct community_list *list; | |
718e3744 | 20038 | |
e237b0d2 | 20039 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20040 | EXTCOMMUNITY_LIST_MASTER); |
20041 | if (!list) { | |
20042 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
20043 | return CMD_WARNING; | |
20044 | } | |
718e3744 | 20045 | |
d62a17ae | 20046 | extcommunity_list_show(vty, list); |
718e3744 | 20047 | |
d62a17ae | 20048 | return CMD_SUCCESS; |
718e3744 | 20049 | } |
6b0655a2 | 20050 | |
718e3744 | 20051 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 20052 | static int community_list_config_write(struct vty *vty) |
20053 | { | |
20054 | struct community_list *list; | |
20055 | struct community_entry *entry; | |
20056 | struct community_list_master *cm; | |
20057 | int write = 0; | |
20058 | ||
20059 | /* Community-list. */ | |
20060 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
20061 | ||
20062 | for (list = cm->num.head; list; list = list->next) | |
20063 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20064 | vty_out(vty, |
20065 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
20066 | list->name, entry->seq, | |
d62a17ae | 20067 | community_direct_str(entry->direct), |
20068 | community_list_config_str(entry)); | |
20069 | write++; | |
20070 | } | |
20071 | for (list = cm->str.head; list; list = list->next) | |
20072 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20073 | vty_out(vty, |
20074 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 20075 | entry->style == COMMUNITY_LIST_STANDARD |
20076 | ? "standard" | |
20077 | : "expanded", | |
2f8cc0e5 DA |
20078 | list->name, entry->seq, |
20079 | community_direct_str(entry->direct), | |
d62a17ae | 20080 | community_list_config_str(entry)); |
20081 | write++; | |
20082 | } | |
20083 | ||
20084 | /* Extcommunity-list. */ | |
20085 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20086 | ||
20087 | for (list = cm->num.head; list; list = list->next) | |
20088 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20089 | vty_out(vty, |
20090 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
20091 | list->name, entry->seq, | |
20092 | community_direct_str(entry->direct), | |
d62a17ae | 20093 | community_list_config_str(entry)); |
20094 | write++; | |
20095 | } | |
20096 | for (list = cm->str.head; list; list = list->next) | |
20097 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20098 | vty_out(vty, |
6cde4b45 | 20099 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 20100 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
20101 | ? "standard" | |
20102 | : "expanded", | |
2f8cc0e5 DA |
20103 | list->name, entry->seq, |
20104 | community_direct_str(entry->direct), | |
d62a17ae | 20105 | community_list_config_str(entry)); |
20106 | write++; | |
20107 | } | |
20108 | ||
20109 | ||
20110 | /* lcommunity-list. */ | |
20111 | cm = community_list_master_lookup(bgp_clist, | |
20112 | LARGE_COMMUNITY_LIST_MASTER); | |
20113 | ||
20114 | for (list = cm->num.head; list; list = list->next) | |
20115 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20116 | vty_out(vty, |
6cde4b45 | 20117 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
20118 | list->name, entry->seq, |
20119 | community_direct_str(entry->direct), | |
d62a17ae | 20120 | community_list_config_str(entry)); |
20121 | write++; | |
20122 | } | |
20123 | for (list = cm->str.head; list; list = list->next) | |
20124 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20125 | vty_out(vty, |
6cde4b45 | 20126 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 20127 | |
d62a17ae | 20128 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
20129 | ? "standard" | |
20130 | : "expanded", | |
2f8cc0e5 | 20131 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 20132 | community_list_config_str(entry)); |
20133 | write++; | |
20134 | } | |
20135 | ||
20136 | return write; | |
20137 | } | |
20138 | ||
612c2c15 | 20139 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 20140 | static struct cmd_node community_list_node = { |
f4b8291f | 20141 | .name = "community list", |
62b346ee DL |
20142 | .node = COMMUNITY_LIST_NODE, |
20143 | .prompt = "", | |
612c2c15 | 20144 | .config_write = community_list_config_write, |
718e3744 | 20145 | }; |
20146 | ||
d62a17ae | 20147 | static void community_list_vty(void) |
20148 | { | |
612c2c15 | 20149 | install_node(&community_list_node); |
d62a17ae | 20150 | |
20151 | /* Community-list. */ | |
7336e101 SP |
20152 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
20153 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20154 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 20155 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 20156 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 20157 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
20158 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
20159 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 20160 | |
20161 | /* Extcommunity-list. */ | |
7336e101 SP |
20162 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
20163 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20164 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
20165 | install_element(CONFIG_NODE, |
20166 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 20167 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
20168 | install_element(CONFIG_NODE, |
20169 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
20170 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
20171 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 20172 | |
20173 | /* Large Community List */ | |
7336e101 | 20174 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
20175 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
20176 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 20177 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
20178 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
20179 | install_element(CONFIG_NODE, | |
20180 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
20181 | install_element(CONFIG_NODE, |
20182 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20183 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20184 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20185 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20186 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20187 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20188 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
20189 | |
20190 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 20191 | } |
ed0e57e3 DA |
20192 | |
20193 | static struct cmd_node community_alias_node = { | |
20194 | .name = "community alias", | |
20195 | .node = COMMUNITY_ALIAS_NODE, | |
20196 | .prompt = "", | |
20197 | .config_write = bgp_community_alias_write, | |
20198 | }; | |
20199 | ||
20200 | void community_alias_vty(void) | |
20201 | { | |
20202 | install_node(&community_alias_node); | |
20203 | ||
20204 | /* Community-list. */ | |
20205 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
20206 | |
20207 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 20208 | } |