]>
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 | ||
8606be87 DA |
3171 | DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd, |
3172 | "bgp long-lived-graceful-restart stale-time (0-4294967295)", BGP_STR | |
3173 | "Enable Long-lived Graceful Restart\n" | |
3174 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3175 | "Stale time value (seconds)\n") | |
3176 | { | |
3177 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3178 | ||
3179 | uint32_t llgr_stale_time; | |
3180 | ||
3181 | llgr_stale_time = strtoul(argv[3]->arg, NULL, 10); | |
3182 | bgp->llgr_stale_time = llgr_stale_time; | |
3183 | ||
3184 | return CMD_SUCCESS; | |
3185 | } | |
3186 | ||
3187 | DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd, | |
3188 | "no bgp long-lived-graceful-restart stale-time [(0-4294967295)]", | |
3189 | NO_STR BGP_STR | |
3190 | "Enable Long-lived Graceful Restart\n" | |
3191 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3192 | "Stale time value (seconds)\n") | |
3193 | { | |
3194 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3195 | ||
3196 | bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; | |
3197 | ||
3198 | return CMD_SUCCESS; | |
3199 | } | |
3200 | ||
1ca2fd11 IR |
3201 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3202 | struct bgp *bgp) | |
05bd726c | 3203 | { |
3204 | bgp_static_redo_import_check(bgp); | |
3205 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3206 | bgp_clear_star_soft_out(vty, bgp->name); |
3207 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3208 | } |
3209 | ||
3210 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3211 | { | |
3212 | struct listnode *node, *nnode; | |
3213 | struct bgp *bgp; | |
3214 | bool vrf_cfg = false; | |
3215 | ||
3216 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3217 | return CMD_SUCCESS; | |
3218 | ||
3219 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3220 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3221 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3222 | vty_out(vty, | |
3223 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3224 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3225 | VRF_DEFAULT_NAME : bgp->name); | |
3226 | vrf_cfg = true; | |
3227 | } | |
3228 | } | |
3229 | ||
3230 | if (vrf_cfg) { | |
3231 | vty_out(vty, | |
3232 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3233 | return CMD_WARNING; | |
3234 | } | |
3235 | ||
3236 | /* Set flag globally */ | |
3237 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3238 | ||
3239 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3240 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3241 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3242 | |
3243 | return CMD_SUCCESS; | |
3244 | } | |
3245 | ||
3246 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3247 | { | |
3248 | struct listnode *node, *nnode; | |
3249 | struct bgp *bgp; | |
3250 | ||
3251 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3252 | return CMD_SUCCESS; | |
3253 | ||
3254 | /* Unset flag globally */ | |
3255 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3256 | ||
3257 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3258 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3259 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3260 | |
3261 | return CMD_SUCCESS; | |
3262 | } | |
3263 | ||
7f323236 DW |
3264 | /* "bgp graceful-shutdown" configuration */ |
3265 | DEFUN (bgp_graceful_shutdown, | |
3266 | bgp_graceful_shutdown_cmd, | |
3267 | "bgp graceful-shutdown", | |
3268 | BGP_STR | |
3269 | "Graceful shutdown parameters\n") | |
3270 | { | |
05bd726c | 3271 | if (vty->node == CONFIG_NODE) |
3272 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3273 | ||
1ca2fd11 | 3274 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3275 | |
1ca2fd11 IR |
3276 | /* if configured globally, per-instance config is not allowed */ |
3277 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3278 | vty_out(vty, | |
3279 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3280 | return CMD_WARNING_CONFIG_FAILED; | |
3281 | } | |
3282 | ||
3283 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3284 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3285 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3286 | } | |
3287 | ||
3288 | return CMD_SUCCESS; | |
7f323236 DW |
3289 | } |
3290 | ||
1ca2fd11 | 3291 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3292 | no_bgp_graceful_shutdown_cmd, |
3293 | "no bgp graceful-shutdown", | |
3294 | NO_STR | |
3295 | BGP_STR | |
3296 | "Graceful shutdown parameters\n") | |
3297 | { | |
05bd726c | 3298 | if (vty->node == CONFIG_NODE) |
3299 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3300 | ||
1ca2fd11 | 3301 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3302 | |
1ca2fd11 IR |
3303 | /* If configured globally, cannot remove from one bgp instance */ |
3304 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3305 | vty_out(vty, | |
3306 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3307 | return CMD_WARNING_CONFIG_FAILED; | |
3308 | } | |
7f323236 | 3309 | |
1ca2fd11 IR |
3310 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3311 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3312 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3313 | } | |
3314 | ||
3315 | return CMD_SUCCESS; | |
7f323236 DW |
3316 | } |
3317 | ||
718e3744 | 3318 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3319 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3320 | bgp_fast_external_failover_cmd, |
3321 | "bgp fast-external-failover", | |
3322 | BGP_STR | |
3323 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3324 | { | |
1ca2fd11 IR |
3325 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3326 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3327 | return CMD_SUCCESS; | |
718e3744 | 3328 | } |
3329 | ||
1ca2fd11 | 3330 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3331 | no_bgp_fast_external_failover_cmd, |
3332 | "no bgp fast-external-failover", | |
3333 | NO_STR | |
3334 | BGP_STR | |
3335 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3336 | { | |
1ca2fd11 IR |
3337 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3338 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3339 | return CMD_SUCCESS; | |
718e3744 | 3340 | } |
6b0655a2 | 3341 | |
718e3744 | 3342 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3343 | DEFUN (bgp_bestpath_compare_router_id, |
3344 | bgp_bestpath_compare_router_id_cmd, | |
3345 | "bgp bestpath compare-routerid", | |
e9273987 | 3346 | BGP_STR |
1ca2fd11 IR |
3347 | "Change the default bestpath selection\n" |
3348 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3349 | { |
1ca2fd11 IR |
3350 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3351 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3352 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3353 | |
1ca2fd11 | 3354 | return CMD_SUCCESS; |
718e3744 | 3355 | } |
3356 | ||
1ca2fd11 IR |
3357 | DEFUN (no_bgp_bestpath_compare_router_id, |
3358 | no_bgp_bestpath_compare_router_id_cmd, | |
3359 | "no bgp bestpath compare-routerid", | |
3360 | NO_STR | |
e9273987 | 3361 | BGP_STR |
1ca2fd11 IR |
3362 | "Change the default bestpath selection\n" |
3363 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3364 | { |
1ca2fd11 IR |
3365 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3366 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3367 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3368 | |
1ca2fd11 | 3369 | return CMD_SUCCESS; |
718e3744 | 3370 | } |
6b0655a2 | 3371 | |
718e3744 | 3372 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3373 | DEFUN (bgp_bestpath_aspath_ignore, |
3374 | bgp_bestpath_aspath_ignore_cmd, | |
3375 | "bgp bestpath as-path ignore", | |
e9273987 | 3376 | BGP_STR |
1ca2fd11 IR |
3377 | "Change the default bestpath selection\n" |
3378 | "AS-path attribute\n" | |
3379 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3380 | { |
1ca2fd11 IR |
3381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3382 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3383 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3384 | |
1ca2fd11 | 3385 | return CMD_SUCCESS; |
718e3744 | 3386 | } |
3387 | ||
1ca2fd11 IR |
3388 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3389 | no_bgp_bestpath_aspath_ignore_cmd, | |
3390 | "no bgp bestpath as-path ignore", | |
3391 | NO_STR | |
e9273987 | 3392 | BGP_STR |
1ca2fd11 IR |
3393 | "Change the default bestpath selection\n" |
3394 | "AS-path attribute\n" | |
3395 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3396 | { |
1ca2fd11 IR |
3397 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3398 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3399 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3400 | |
1ca2fd11 | 3401 | return CMD_SUCCESS; |
718e3744 | 3402 | } |
6b0655a2 | 3403 | |
6811845b | 3404 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3405 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3406 | bgp_bestpath_aspath_confed_cmd, |
3407 | "bgp bestpath as-path confed", | |
e9273987 | 3408 | BGP_STR |
6811845b | 3409 | "Change the default bestpath selection\n" |
3410 | "AS-path attribute\n" | |
3411 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3412 | { | |
1ca2fd11 IR |
3413 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3414 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3415 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3416 | |
1ca2fd11 | 3417 | return CMD_SUCCESS; |
6811845b | 3418 | } |
3419 | ||
1ca2fd11 | 3420 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3421 | no_bgp_bestpath_aspath_confed_cmd, |
3422 | "no bgp bestpath as-path confed", | |
3423 | NO_STR | |
e9273987 | 3424 | BGP_STR |
6811845b | 3425 | "Change the default bestpath selection\n" |
3426 | "AS-path attribute\n" | |
3427 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3428 | { | |
1ca2fd11 IR |
3429 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3430 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3431 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3432 | |
1ca2fd11 | 3433 | return CMD_SUCCESS; |
6811845b | 3434 | } |
6b0655a2 | 3435 | |
2fdd455c | 3436 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3437 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3438 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3439 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3440 | BGP_STR |
16fc1eec DS |
3441 | "Change the default bestpath selection\n" |
3442 | "AS-path attribute\n" | |
3443 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3444 | "Generate an AS_SET\n" |
16fc1eec DS |
3445 | "Do not generate an AS_SET\n") |
3446 | { | |
1ca2fd11 | 3447 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3448 | int idx = 0; |
1ca2fd11 | 3449 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3450 | |
1ca2fd11 IR |
3451 | /* no-as-set is now the default behavior so we can silently |
3452 | * ignore it */ | |
d62a17ae | 3453 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3454 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3455 | else |
1ca2fd11 | 3456 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3457 | |
1ca2fd11 IR |
3458 | bgp_recalculate_all_bestpaths(bgp); |
3459 | ||
3460 | return CMD_SUCCESS; | |
16fc1eec DS |
3461 | } |
3462 | ||
1ca2fd11 | 3463 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3464 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3465 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3466 | NO_STR |
e9273987 | 3467 | BGP_STR |
16fc1eec DS |
3468 | "Change the default bestpath selection\n" |
3469 | "AS-path attribute\n" | |
3470 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3471 | "Generate an AS_SET\n" |
16fc1eec DS |
3472 | "Do not generate an AS_SET\n") |
3473 | { | |
1ca2fd11 IR |
3474 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3475 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3476 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3477 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3478 | |
1ca2fd11 | 3479 | return CMD_SUCCESS; |
2fdd455c | 3480 | } |
6b0655a2 | 3481 | |
ee88563a JM |
3482 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3483 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3484 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3485 | "bgp bestpath peer-type multipath-relax", | |
3486 | BGP_STR | |
3487 | "Change the default bestpath selection\n" | |
3488 | "Peer type\n" | |
3489 | "Allow load sharing across routes learned from different peer types\n") | |
3490 | { | |
3491 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3492 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3493 | bgp_recalculate_all_bestpaths(bgp); | |
3494 | ||
3495 | return CMD_SUCCESS; | |
3496 | } | |
3497 | ||
3498 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3499 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3500 | "no bgp bestpath peer-type multipath-relax", | |
3501 | NO_STR BGP_STR | |
3502 | "Change the default bestpath selection\n" | |
3503 | "Peer type\n" | |
3504 | "Allow load sharing across routes learned from different peer types\n") | |
3505 | { | |
3506 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3507 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3508 | bgp_recalculate_all_bestpaths(bgp); | |
3509 | ||
3510 | return CMD_SUCCESS; | |
3511 | } | |
3512 | ||
848973c7 | 3513 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3514 | DEFUN (bgp_log_neighbor_changes, |
3515 | bgp_log_neighbor_changes_cmd, | |
3516 | "bgp log-neighbor-changes", | |
e9273987 | 3517 | BGP_STR |
1ca2fd11 | 3518 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3519 | { |
1ca2fd11 IR |
3520 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3521 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3522 | return CMD_SUCCESS; | |
848973c7 | 3523 | } |
3524 | ||
1ca2fd11 IR |
3525 | DEFUN (no_bgp_log_neighbor_changes, |
3526 | no_bgp_log_neighbor_changes_cmd, | |
3527 | "no bgp log-neighbor-changes", | |
3528 | NO_STR | |
e9273987 | 3529 | BGP_STR |
1ca2fd11 | 3530 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3531 | { |
1ca2fd11 IR |
3532 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3533 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3534 | return CMD_SUCCESS; | |
848973c7 | 3535 | } |
6b0655a2 | 3536 | |
718e3744 | 3537 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3538 | DEFUN (bgp_bestpath_med, |
718e3744 | 3539 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3540 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3541 | BGP_STR |
718e3744 | 3542 | "Change the default bestpath selection\n" |
3543 | "MED attribute\n" | |
3544 | "Compare MED among confederation paths\n" | |
838758ac DW |
3545 | "Treat missing MED as the least preferred one\n" |
3546 | "Treat missing MED as the least preferred one\n" | |
3547 | "Compare MED among confederation paths\n") | |
718e3744 | 3548 | { |
1ca2fd11 | 3549 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3550 | |
1ca2fd11 | 3551 | int idx = 0; |
d62a17ae | 3552 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3553 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3554 | idx = 0; |
3555 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3556 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3557 | |
1ca2fd11 | 3558 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3559 | |
1ca2fd11 | 3560 | return CMD_SUCCESS; |
718e3744 | 3561 | } |
3562 | ||
1ca2fd11 | 3563 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3564 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3565 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3566 | NO_STR |
e9273987 | 3567 | BGP_STR |
718e3744 | 3568 | "Change the default bestpath selection\n" |
3569 | "MED attribute\n" | |
3570 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3571 | "Treat missing MED as the least preferred one\n" |
3572 | "Treat missing MED as the least preferred one\n" | |
3573 | "Compare MED among confederation paths\n") | |
718e3744 | 3574 | { |
1ca2fd11 | 3575 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3576 | |
1ca2fd11 | 3577 | int idx = 0; |
d62a17ae | 3578 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3579 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3580 | idx = 0; |
3581 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3582 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3583 | ||
3584 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3585 | |
1ca2fd11 | 3586 | return CMD_SUCCESS; |
718e3744 | 3587 | } |
3588 | ||
f7e1c681 | 3589 | /* "bgp bestpath bandwidth" configuration. */ |
3590 | DEFPY (bgp_bestpath_bw, | |
3591 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3592 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3593 | BGP_STR |
f7e1c681 | 3594 | "Change the default bestpath selection\n" |
3595 | "Link Bandwidth attribute\n" | |
3596 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3597 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3598 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3599 | { | |
3600 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3601 | afi_t afi; | |
3602 | safi_t safi; | |
3603 | ||
ad36d216 DS |
3604 | if (!bw_cfg) { |
3605 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3606 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3607 | } |
ad36d216 DS |
3608 | if (!strcmp(bw_cfg, "ignore")) |
3609 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3610 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3611 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3612 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3613 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3614 | else | |
3615 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3616 | |
3617 | /* This config is used in route install, so redo that. */ | |
3618 | FOREACH_AFI_SAFI (afi, safi) { | |
3619 | if (!bgp_fibupd_safi(safi)) | |
3620 | continue; | |
3621 | bgp_zebra_announce_table(bgp, afi, safi); | |
3622 | } | |
3623 | ||
3624 | return CMD_SUCCESS; | |
3625 | } | |
3626 | ||
ad36d216 DS |
3627 | DEFPY (no_bgp_bestpath_bw, |
3628 | no_bgp_bestpath_bw_cmd, | |
3629 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3630 | NO_STR | |
e9273987 | 3631 | BGP_STR |
ad36d216 DS |
3632 | "Change the default bestpath selection\n" |
3633 | "Link Bandwidth attribute\n" | |
3634 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3635 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3636 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3637 | { | |
3638 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3639 | afi_t afi; | |
3640 | safi_t safi; | |
3641 | ||
3642 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3643 | ||
3644 | /* This config is used in route install, so redo that. */ | |
3645 | FOREACH_AFI_SAFI (afi, safi) { | |
3646 | if (!bgp_fibupd_safi(safi)) | |
3647 | continue; | |
3648 | bgp_zebra_announce_table(bgp, afi, safi); | |
3649 | } | |
3650 | return CMD_SUCCESS; | |
3651 | } | |
3652 | ||
b16bcbba | 3653 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3654 | "[no] bgp default <ipv4-unicast|" |
3655 | "ipv4-multicast|" | |
3656 | "ipv4-vpn|" | |
3657 | "ipv4-labeled-unicast|" | |
3658 | "ipv4-flowspec|" | |
3659 | "ipv6-unicast|" | |
3660 | "ipv6-multicast|" | |
3661 | "ipv6-vpn|" | |
3662 | "ipv6-labeled-unicast|" | |
3663 | "ipv6-flowspec|" | |
3664 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3665 | NO_STR |
e9273987 | 3666 | BGP_STR |
e84c59af | 3667 | "Configure BGP defaults\n" |
b16bcbba | 3668 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3669 | "Activate ipv4-multicast for a peer by default\n" |
3670 | "Activate ipv4-vpn for a peer by default\n" | |
3671 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3672 | "Activate ipv4-flowspec for a peer by default\n" | |
3673 | "Activate ipv6-unicast for a peer by default\n" | |
3674 | "Activate ipv6-multicast for a peer by default\n" | |
3675 | "Activate ipv6-vpn for a peer by default\n" | |
3676 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3677 | "Activate ipv6-flowspec for a peer by default\n" | |
3678 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3679 | { |
3680 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3681 | char afi_safi_str[strlen(afi_safi) + 1]; |
3682 | char *afi_safi_str_tok; | |
e84c59af | 3683 | |
b16bcbba TA |
3684 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
3685 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3686 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3687 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 3688 | safi_t safi; |
e84c59af | 3689 | |
38d11af5 TA |
3690 | if (strmatch(safi_str, "labeled")) |
3691 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3692 | else | |
3693 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba TA |
3694 | |
3695 | if (no) | |
3696 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
3697 | else { |
3698 | if ((safi == SAFI_LABELED_UNICAST | |
3699 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3700 | || (safi == SAFI_UNICAST | |
3701 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3702 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3703 | else | |
3704 | bgp->default_af[afi][safi] = true; | |
3705 | } | |
718e3744 | 3706 | |
d62a17ae | 3707 | return CMD_SUCCESS; |
718e3744 | 3708 | } |
6b0655a2 | 3709 | |
04b6bdc0 | 3710 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 3711 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
3712 | bgp_default_show_hostname_cmd, |
3713 | "bgp default show-hostname", | |
e9273987 | 3714 | BGP_STR |
04b6bdc0 | 3715 | "Configure BGP defaults\n" |
0437e105 | 3716 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3717 | { |
1ca2fd11 IR |
3718 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3719 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3720 | return CMD_SUCCESS; | |
ff8a8a7a CS |
3721 | } |
3722 | ||
1ca2fd11 IR |
3723 | DEFUN (no_bgp_default_show_hostname, |
3724 | no_bgp_default_show_hostname_cmd, | |
3725 | "no bgp default show-hostname", | |
3726 | NO_STR | |
e9273987 | 3727 | BGP_STR |
1ca2fd11 IR |
3728 | "Configure BGP defaults\n" |
3729 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 3730 | { |
1ca2fd11 IR |
3731 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3732 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3733 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3734 | } |
3735 | ||
aef999a2 | 3736 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
3737 | DEFUN (bgp_default_show_nexthop_hostname, |
3738 | bgp_default_show_nexthop_hostname_cmd, | |
3739 | "bgp default show-nexthop-hostname", | |
e9273987 | 3740 | BGP_STR |
1d80f243 IR |
3741 | "Configure BGP defaults\n" |
3742 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3743 | { |
1ca2fd11 IR |
3744 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3745 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3746 | return CMD_SUCCESS; | |
aef999a2 DA |
3747 | } |
3748 | ||
3749 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3750 | no_bgp_default_show_nexthop_hostname_cmd, | |
3751 | "no bgp default show-nexthop-hostname", | |
3752 | NO_STR | |
e9273987 | 3753 | BGP_STR |
aef999a2 DA |
3754 | "Configure BGP defaults\n" |
3755 | "Show hostname for nexthop in certain command outputs\n") | |
3756 | { | |
1ca2fd11 IR |
3757 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3758 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3759 | return CMD_SUCCESS; | |
aef999a2 DA |
3760 | } |
3761 | ||
8233ef81 | 3762 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
3763 | DEFUN (bgp_network_import_check, |
3764 | bgp_network_import_check_cmd, | |
3765 | "bgp network import-check", | |
e9273987 | 3766 | BGP_STR |
1ca2fd11 IR |
3767 | "BGP network command\n" |
3768 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3769 | { |
1ca2fd11 IR |
3770 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3771 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3772 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3773 | bgp_static_redo_import_check(bgp); | |
3774 | } | |
078430f6 | 3775 | |
1ca2fd11 | 3776 | return CMD_SUCCESS; |
718e3744 | 3777 | } |
3778 | ||
d62a17ae | 3779 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3780 | "bgp network import-check exact", | |
e9273987 | 3781 | BGP_STR |
d62a17ae | 3782 | "BGP network command\n" |
3783 | "Check BGP network route exists in IGP\n" | |
3784 | "Match route precisely\n") | |
8233ef81 | 3785 | |
1ca2fd11 IR |
3786 | DEFUN (no_bgp_network_import_check, |
3787 | no_bgp_network_import_check_cmd, | |
3788 | "no bgp network import-check", | |
3789 | NO_STR | |
e9273987 | 3790 | BGP_STR |
1ca2fd11 IR |
3791 | "BGP network command\n" |
3792 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3793 | { |
1ca2fd11 IR |
3794 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3795 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3796 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3797 | bgp_static_redo_import_check(bgp); | |
3798 | } | |
6b0655a2 | 3799 | |
1ca2fd11 | 3800 | return CMD_SUCCESS; |
ff8a8a7a | 3801 | } |
718e3744 | 3802 | |
1ca2fd11 IR |
3803 | DEFUN (bgp_default_local_preference, |
3804 | bgp_default_local_preference_cmd, | |
3805 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 3806 | BGP_STR |
1ca2fd11 IR |
3807 | "Configure BGP defaults\n" |
3808 | "local preference (higher=more preferred)\n" | |
3809 | "Configure default local preference value\n") | |
ff8a8a7a | 3810 | { |
1ca2fd11 | 3811 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3812 | int idx_number = 3; |
1ca2fd11 | 3813 | uint32_t local_pref; |
718e3744 | 3814 | |
1ca2fd11 | 3815 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3816 | |
1ca2fd11 IR |
3817 | bgp_default_local_preference_set(bgp, local_pref); |
3818 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3819 | |
1ca2fd11 | 3820 | return CMD_SUCCESS; |
718e3744 | 3821 | } |
3822 | ||
1ca2fd11 IR |
3823 | DEFUN (no_bgp_default_local_preference, |
3824 | no_bgp_default_local_preference_cmd, | |
3825 | "no bgp default local-preference [(0-4294967295)]", | |
3826 | NO_STR | |
e9273987 | 3827 | BGP_STR |
1ca2fd11 IR |
3828 | "Configure BGP defaults\n" |
3829 | "local preference (higher=more preferred)\n" | |
3830 | "Configure default local preference value\n") | |
ff8a8a7a | 3831 | { |
1ca2fd11 IR |
3832 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3833 | bgp_default_local_preference_unset(bgp); | |
3834 | bgp_clear_star_soft_in(vty, bgp->name); | |
3835 | ||
3836 | return CMD_SUCCESS; | |
ff8a8a7a | 3837 | } |
6b0655a2 | 3838 | |
ff8a8a7a | 3839 | |
1ca2fd11 IR |
3840 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3841 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3842 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 3843 | BGP_STR |
1ca2fd11 IR |
3844 | "Configure BGP defaults\n" |
3845 | "subgroup-pkt-queue-max\n" | |
3846 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3847 | { |
1ca2fd11 | 3848 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3849 | int idx_number = 3; |
1ca2fd11 | 3850 | uint32_t max_size; |
3f9c7369 | 3851 | |
1ca2fd11 | 3852 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3853 | |
1ca2fd11 | 3854 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 3855 | |
1ca2fd11 | 3856 | return CMD_SUCCESS; |
8bd9d948 DS |
3857 | } |
3858 | ||
1ca2fd11 IR |
3859 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
3860 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3861 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3862 | NO_STR | |
e9273987 | 3863 | BGP_STR |
1ca2fd11 IR |
3864 | "Configure BGP defaults\n" |
3865 | "subgroup-pkt-queue-max\n" | |
3866 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 3867 | { |
1ca2fd11 IR |
3868 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3869 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3870 | return CMD_SUCCESS; | |
ff8a8a7a | 3871 | } |
813d4307 | 3872 | |
8bd9d948 | 3873 | |
1ca2fd11 IR |
3874 | DEFUN (bgp_rr_allow_outbound_policy, |
3875 | bgp_rr_allow_outbound_policy_cmd, | |
3876 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 3877 | BGP_STR |
1ca2fd11 IR |
3878 | "Allow modifications made by out route-map\n" |
3879 | "on ibgp neighbors\n") | |
ff8a8a7a | 3880 | { |
1ca2fd11 | 3881 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3882 | |
1ca2fd11 IR |
3883 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3884 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3885 | update_group_announce_rrclients(bgp); | |
3886 | bgp_clear_star_soft_out(vty, bgp->name); | |
3887 | } | |
8bd9d948 | 3888 | |
1ca2fd11 IR |
3889 | return CMD_SUCCESS; |
3890 | } | |
ff8a8a7a | 3891 | |
1ca2fd11 IR |
3892 | DEFUN (no_bgp_rr_allow_outbound_policy, |
3893 | no_bgp_rr_allow_outbound_policy_cmd, | |
3894 | "no bgp route-reflector allow-outbound-policy", | |
3895 | NO_STR | |
e9273987 | 3896 | BGP_STR |
1ca2fd11 IR |
3897 | "Allow modifications made by out route-map\n" |
3898 | "on ibgp neighbors\n") | |
8bd9d948 | 3899 | { |
1ca2fd11 | 3900 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3901 | |
1ca2fd11 IR |
3902 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3903 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3904 | update_group_announce_rrclients(bgp); | |
3905 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 3906 | } |
8bd9d948 | 3907 | |
1ca2fd11 | 3908 | return CMD_SUCCESS; |
8bd9d948 DS |
3909 | } |
3910 | ||
1ca2fd11 IR |
3911 | DEFUN (bgp_listen_limit, |
3912 | bgp_listen_limit_cmd, | |
3913 | "bgp listen limit (1-65535)", | |
e9273987 | 3914 | BGP_STR |
1ca2fd11 IR |
3915 | "BGP Dynamic Neighbors listen commands\n" |
3916 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3917 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3918 | { |
1ca2fd11 | 3919 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3920 | int idx_number = 3; |
1ca2fd11 IR |
3921 | int listen_limit; |
3922 | ||
3923 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 3924 | |
1ca2fd11 | 3925 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3926 | |
1ca2fd11 | 3927 | return CMD_SUCCESS; |
f14e6fdb DS |
3928 | } |
3929 | ||
1ca2fd11 IR |
3930 | DEFUN (no_bgp_listen_limit, |
3931 | no_bgp_listen_limit_cmd, | |
3932 | "no bgp listen limit [(1-65535)]", | |
3933 | NO_STR | |
e9273987 | 3934 | BGP_STR |
1ca2fd11 IR |
3935 | "BGP Dynamic Neighbors listen commands\n" |
3936 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3937 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3938 | { |
1ca2fd11 IR |
3939 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3940 | bgp_listen_limit_unset(bgp); | |
3941 | return CMD_SUCCESS; | |
f14e6fdb DS |
3942 | } |
3943 | ||
3944 | ||
20eb8864 | 3945 | /* |
3946 | * Check if this listen range is already configured. Check for exact | |
3947 | * match or overlap based on input. | |
3948 | */ | |
d62a17ae | 3949 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3950 | struct prefix *range, int exact) | |
3951 | { | |
3952 | struct listnode *node, *nnode; | |
3953 | struct listnode *node1, *nnode1; | |
3954 | struct peer_group *group; | |
3955 | struct prefix *lr; | |
3956 | afi_t afi; | |
3957 | int match; | |
3958 | ||
3959 | afi = family2afi(range->family); | |
3960 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3961 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3962 | lr)) { | |
3963 | if (exact) | |
3964 | match = prefix_same(range, lr); | |
3965 | else | |
3966 | match = (prefix_match(range, lr) | |
3967 | || prefix_match(lr, range)); | |
3968 | if (match) | |
3969 | return group; | |
3970 | } | |
3971 | } | |
3972 | ||
3973 | return NULL; | |
20eb8864 | 3974 | } |
3975 | ||
f14e6fdb DS |
3976 | DEFUN (bgp_listen_range, |
3977 | bgp_listen_range_cmd, | |
d7b9898c | 3978 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 3979 | BGP_STR |
d7fa34c1 QY |
3980 | "Configure BGP dynamic neighbors listen range\n" |
3981 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3982 | NEIGHBOR_ADDR_STR |
3983 | "Member of the peer-group\n" | |
3984 | "Peer-group name\n") | |
f14e6fdb | 3985 | { |
d62a17ae | 3986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3987 | struct prefix range; | |
3988 | struct peer_group *group, *existing_group; | |
3989 | afi_t afi; | |
3990 | int ret; | |
3991 | int idx = 0; | |
3992 | ||
3993 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3994 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3995 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3996 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3997 | char *peergroup = argv[idx]->arg; |
3998 | ||
3999 | /* Convert IP prefix string to struct prefix. */ | |
4000 | ret = str2prefix(prefix, &range); | |
4001 | if (!ret) { | |
4002 | vty_out(vty, "%% Malformed listen range\n"); | |
4003 | return CMD_WARNING_CONFIG_FAILED; | |
4004 | } | |
4005 | ||
4006 | afi = family2afi(range.family); | |
4007 | ||
4008 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4009 | vty_out(vty, | |
4010 | "%% Malformed listen range (link-local address)\n"); | |
4011 | return CMD_WARNING_CONFIG_FAILED; | |
4012 | } | |
4013 | ||
4014 | apply_mask(&range); | |
4015 | ||
4016 | /* Check if same listen range is already configured. */ | |
4017 | existing_group = listen_range_exists(bgp, &range, 1); | |
4018 | if (existing_group) { | |
4019 | if (strcmp(existing_group->name, peergroup) == 0) | |
4020 | return CMD_SUCCESS; | |
4021 | else { | |
4022 | vty_out(vty, | |
4023 | "%% Same listen range is attached to peer-group %s\n", | |
4024 | existing_group->name); | |
4025 | return CMD_WARNING_CONFIG_FAILED; | |
4026 | } | |
4027 | } | |
4028 | ||
4029 | /* Check if an overlapping listen range exists. */ | |
4030 | if (listen_range_exists(bgp, &range, 0)) { | |
4031 | vty_out(vty, | |
4032 | "%% Listen range overlaps with existing listen range\n"); | |
4033 | return CMD_WARNING_CONFIG_FAILED; | |
4034 | } | |
4035 | ||
4036 | group = peer_group_lookup(bgp, peergroup); | |
4037 | if (!group) { | |
4038 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4039 | return CMD_WARNING_CONFIG_FAILED; | |
4040 | } | |
4041 | ||
4042 | ret = peer_group_listen_range_add(group, &range); | |
4043 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4044 | } |
4045 | ||
4046 | DEFUN (no_bgp_listen_range, | |
4047 | no_bgp_listen_range_cmd, | |
d7b9898c | 4048 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4049 | NO_STR |
e9273987 | 4050 | BGP_STR |
d7fa34c1 QY |
4051 | "Unconfigure BGP dynamic neighbors listen range\n" |
4052 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4053 | NEIGHBOR_ADDR_STR | |
4054 | "Member of the peer-group\n" | |
4055 | "Peer-group name\n") | |
f14e6fdb | 4056 | { |
d62a17ae | 4057 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4058 | struct prefix range; | |
4059 | struct peer_group *group; | |
4060 | afi_t afi; | |
4061 | int ret; | |
4062 | int idx = 0; | |
4063 | ||
4064 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4065 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4066 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4067 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4068 | char *peergroup = argv[idx]->arg; |
4069 | ||
4070 | /* Convert IP prefix string to struct prefix. */ | |
4071 | ret = str2prefix(prefix, &range); | |
4072 | if (!ret) { | |
4073 | vty_out(vty, "%% Malformed listen range\n"); | |
4074 | return CMD_WARNING_CONFIG_FAILED; | |
4075 | } | |
4076 | ||
4077 | afi = family2afi(range.family); | |
4078 | ||
4079 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4080 | vty_out(vty, | |
4081 | "%% Malformed listen range (link-local address)\n"); | |
4082 | return CMD_WARNING_CONFIG_FAILED; | |
4083 | } | |
4084 | ||
4085 | apply_mask(&range); | |
4086 | ||
4087 | group = peer_group_lookup(bgp, peergroup); | |
4088 | if (!group) { | |
4089 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4090 | return CMD_WARNING_CONFIG_FAILED; | |
4091 | } | |
4092 | ||
4093 | ret = peer_group_listen_range_del(group, &range); | |
4094 | return bgp_vty_return(vty, ret); | |
4095 | } | |
4096 | ||
2b791107 | 4097 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4098 | { |
4099 | struct peer_group *group; | |
4100 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4101 | struct prefix *range; | |
4102 | afi_t afi; | |
d62a17ae | 4103 | |
4104 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4105 | vty_out(vty, " bgp listen limit %d\n", | |
4106 | bgp->dynamic_neighbors_limit); | |
4107 | ||
4108 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4109 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4110 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4111 | nrnode, range)) { | |
d62a17ae | 4112 | vty_out(vty, |
2dbe669b DA |
4113 | " bgp listen range %pFX peer-group %s\n", |
4114 | range, group->name); | |
d62a17ae | 4115 | } |
4116 | } | |
4117 | } | |
f14e6fdb DS |
4118 | } |
4119 | ||
4120 | ||
1ca2fd11 IR |
4121 | DEFUN (bgp_disable_connected_route_check, |
4122 | bgp_disable_connected_route_check_cmd, | |
4123 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4124 | BGP_STR |
1ca2fd11 | 4125 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4126 | { |
1ca2fd11 IR |
4127 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4128 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4129 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4130 | |
1ca2fd11 | 4131 | return CMD_SUCCESS; |
907f92c8 DS |
4132 | } |
4133 | ||
1ca2fd11 IR |
4134 | DEFUN (no_bgp_disable_connected_route_check, |
4135 | no_bgp_disable_connected_route_check_cmd, | |
4136 | "no bgp disable-ebgp-connected-route-check", | |
4137 | NO_STR | |
e9273987 | 4138 | BGP_STR |
1ca2fd11 | 4139 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4140 | { |
1ca2fd11 IR |
4141 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4142 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4143 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4144 | |
1ca2fd11 | 4145 | return CMD_SUCCESS; |
d62a17ae | 4146 | } |
4147 | ||
4148 | ||
28c6e247 IR |
4149 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4150 | const char *as_str) | |
4151 | { | |
4152 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4153 | int ret; | |
4154 | as_t as; | |
4155 | int as_type = AS_SPECIFIED; | |
4156 | union sockunion su; | |
4157 | ||
4158 | if (as_str[0] == 'i') { | |
4159 | as = 0; | |
4160 | as_type = AS_INTERNAL; | |
4161 | } else if (as_str[0] == 'e') { | |
4162 | as = 0; | |
4163 | as_type = AS_EXTERNAL; | |
4164 | } else { | |
4165 | /* Get AS number. */ | |
4166 | as = strtoul(as_str, NULL, 10); | |
4167 | } | |
4168 | ||
4169 | /* If peer is peer group or interface peer, call proper function. */ | |
4170 | ret = str2sockunion(peer_str, &su); | |
4171 | if (ret < 0) { | |
4172 | struct peer *peer; | |
4173 | ||
4174 | /* Check if existing interface peer */ | |
4175 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4176 | ||
4177 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4178 | ||
4179 | /* if not interface peer, check peer-group settings */ | |
4180 | if (ret < 0 && !peer) { | |
4181 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4182 | if (ret < 0) { | |
4183 | vty_out(vty, | |
4184 | "%% Create the peer-group or interface first\n"); | |
4185 | return CMD_WARNING_CONFIG_FAILED; | |
4186 | } | |
4187 | return CMD_SUCCESS; | |
4188 | } | |
4189 | } else { | |
4190 | if (peer_address_self_check(bgp, &su)) { | |
4191 | vty_out(vty, | |
4192 | "%% Can not configure the local system as neighbor\n"); | |
4193 | return CMD_WARNING_CONFIG_FAILED; | |
4194 | } | |
4195 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4196 | } | |
4197 | ||
4198 | /* This peer belongs to peer group. */ | |
4199 | switch (ret) { | |
4200 | case BGP_ERR_PEER_GROUP_MEMBER: | |
4201 | vty_out(vty, | |
4202 | "%% Peer-group member cannot override remote-as of peer-group\n"); | |
4203 | return CMD_WARNING_CONFIG_FAILED; | |
4204 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
4205 | vty_out(vty, | |
4206 | "%% Peer-group members must be all internal or all external\n"); | |
4207 | return CMD_WARNING_CONFIG_FAILED; | |
4208 | } | |
4209 | return bgp_vty_return(vty, ret); | |
4210 | } | |
4211 | ||
1ca2fd11 IR |
4212 | DEFUN (bgp_default_shutdown, |
4213 | bgp_default_shutdown_cmd, | |
4214 | "[no] bgp default shutdown", | |
4215 | NO_STR | |
4216 | BGP_STR | |
4217 | "Configure BGP defaults\n" | |
4218 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4219 | { |
1ca2fd11 IR |
4220 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4221 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4222 | return CMD_SUCCESS; | |
f26845f9 QY |
4223 | } |
4224 | ||
736b68f3 DS |
4225 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4226 | BGP_STR | |
9ddf4b81 | 4227 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4228 | "Add a shutdown message (RFC 8203)\n" |
4229 | "Shutdown message\n") | |
9cf59432 | 4230 | { |
736b68f3 | 4231 | char *msgstr = NULL; |
8389c83a | 4232 | |
9cf59432 DS |
4233 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4234 | ||
8389c83a | 4235 | if (argc > 3) |
f80e35b6 | 4236 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4237 | |
4238 | bgp_shutdown_enable(bgp, msgstr); | |
4239 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4240 | |
4241 | return CMD_SUCCESS; | |
4242 | } | |
4243 | ||
736b68f3 | 4244 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4245 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4246 | { |
4247 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4248 | ||
4249 | bgp_shutdown_enable(bgp, NULL); | |
4250 | ||
4251 | return CMD_SUCCESS; | |
4252 | } | |
8389c83a | 4253 | |
736b68f3 | 4254 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4255 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4256 | { |
4257 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4258 | ||
4259 | bgp_shutdown_disable(bgp); | |
4260 | ||
4261 | return CMD_SUCCESS; | |
4262 | } | |
4263 | ||
9ddf4b81 | 4264 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4265 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4266 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4267 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4268 | |
28c6e247 IR |
4269 | DEFUN (neighbor_remote_as, |
4270 | neighbor_remote_as_cmd, | |
4271 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4272 | NEIGHBOR_STR | |
4273 | NEIGHBOR_ADDR_STR2 | |
4274 | "Specify a BGP neighbor\n" | |
4275 | AS_STR | |
4276 | "Internal BGP peer\n" | |
4277 | "External BGP peer\n") | |
718e3744 | 4278 | { |
d62a17ae | 4279 | int idx_peer = 1; |
4280 | int idx_remote_as = 3; | |
28c6e247 IR |
4281 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4282 | argv[idx_remote_as]->arg); | |
d62a17ae | 4283 | } |
f852eb98 PG |
4284 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4285 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4286 | * when nexthop becomes unreachable | |
4287 | */ | |
4288 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4289 | BGP_STR "Fast convergence for bgp sessions\n") | |
4290 | { | |
4291 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4292 | bgp->fast_convergence = true; | |
4293 | ||
4294 | return CMD_SUCCESS; | |
4295 | } | |
4296 | ||
4297 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4298 | "no bgp fast-convergence", | |
4299 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4300 | { | |
4301 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4302 | bgp->fast_convergence = false; | |
4303 | ||
4304 | return CMD_SUCCESS; | |
4305 | } | |
d62a17ae | 4306 | |
28c6e247 IR |
4307 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4308 | int v6only, | |
4309 | const char *peer_group_name, | |
4310 | const char *as_str) | |
d62a17ae | 4311 | { |
28c6e247 IR |
4312 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4313 | as_t as = 0; | |
4314 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4315 | struct peer *peer; |
4316 | struct peer_group *group; | |
4317 | int ret = 0; | |
d62a17ae | 4318 | |
4319 | group = peer_group_lookup(bgp, conf_if); | |
4320 | ||
4321 | if (group) { | |
28c6e247 IR |
4322 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4323 | return CMD_WARNING_CONFIG_FAILED; | |
4324 | } | |
4325 | ||
4326 | if (as_str) { | |
4327 | if (as_str[0] == 'i') { | |
4328 | as_type = AS_INTERNAL; | |
4329 | } else if (as_str[0] == 'e') { | |
4330 | as_type = AS_EXTERNAL; | |
4331 | } else { | |
4332 | /* Get AS number. */ | |
4333 | as = strtoul(as_str, NULL, 10); | |
4334 | as_type = AS_SPECIFIED; | |
4335 | } | |
d62a17ae | 4336 | } |
4337 | ||
4338 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4339 | if (peer) { | |
28c6e247 | 4340 | if (as_str) |
e84c59af | 4341 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4342 | } else { |
e84c59af DA |
4343 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
4344 | NULL); | |
d62a17ae | 4345 | |
4346 | if (!peer) { | |
28c6e247 IR |
4347 | vty_out(vty, "%% BGP failed to create peer\n"); |
4348 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4349 | } |
4350 | ||
4351 | if (v6only) | |
527de3dc | 4352 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4353 | |
4354 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4355 | * this | |
4356 | * any unnumbered peer in order to not worry about run-time | |
4357 | * transitions | |
4358 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4359 | * address | |
4360 | * gets deleted later etc.) | |
4361 | */ | |
4362 | if (peer->ifp) | |
4363 | bgp_zebra_initiate_radv(bgp, peer); | |
4364 | } | |
4365 | ||
4366 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4367 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4368 | if (v6only) | |
527de3dc | 4369 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4370 | else |
527de3dc | 4371 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4372 | |
4373 | /* v6only flag changed. Reset bgp seesion */ | |
4374 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4375 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4376 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4377 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4378 | } else | |
4379 | bgp_session_reset(peer); | |
4380 | } | |
4381 | ||
9fb964de PM |
4382 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4383 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4384 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4385 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4386 | } |
d62a17ae | 4387 | |
4388 | if (peer_group_name) { | |
4389 | group = peer_group_lookup(bgp, peer_group_name); | |
4390 | if (!group) { | |
28c6e247 IR |
4391 | vty_out(vty, "%% Configure the peer-group first\n"); |
4392 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4393 | } |
4394 | ||
8395c1f8 | 4395 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4396 | } |
4397 | ||
28c6e247 | 4398 | return bgp_vty_return(vty, ret); |
a80beece DS |
4399 | } |
4400 | ||
28c6e247 IR |
4401 | DEFUN (neighbor_interface_config, |
4402 | neighbor_interface_config_cmd, | |
4403 | "neighbor WORD interface [peer-group PGNAME]", | |
4404 | NEIGHBOR_STR | |
4405 | "Interface name or neighbor tag\n" | |
4406 | "Enable BGP on interface\n" | |
4407 | "Member of the peer-group\n" | |
4408 | "Peer-group name\n") | |
4c48cf63 | 4409 | { |
d62a17ae | 4410 | int idx_word = 1; |
4411 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4412 | |
d62a17ae | 4413 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4414 | return peer_conf_interface_get( |
4415 | vty, argv[idx_word]->arg, 0, | |
4416 | argv[idx_peer_group_word]->arg, NULL); | |
4417 | else | |
4418 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4419 | NULL, NULL); | |
4c48cf63 DW |
4420 | } |
4421 | ||
28c6e247 IR |
4422 | DEFUN (neighbor_interface_config_v6only, |
4423 | neighbor_interface_config_v6only_cmd, | |
4424 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4425 | NEIGHBOR_STR | |
4426 | "Interface name or neighbor tag\n" | |
4427 | "Enable BGP on interface\n" | |
4428 | "Enable BGP with v6 link-local only\n" | |
4429 | "Member of the peer-group\n" | |
4430 | "Peer-group name\n") | |
4c48cf63 | 4431 | { |
d62a17ae | 4432 | int idx_word = 1; |
4433 | int idx_peer_group_word = 5; | |
31500417 | 4434 | |
d62a17ae | 4435 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4436 | return peer_conf_interface_get( |
4437 | vty, argv[idx_word]->arg, 1, | |
4438 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4439 | |
28c6e247 | 4440 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4441 | } |
4442 | ||
a80beece | 4443 | |
28c6e247 IR |
4444 | DEFUN (neighbor_interface_config_remote_as, |
4445 | neighbor_interface_config_remote_as_cmd, | |
4446 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4447 | NEIGHBOR_STR | |
4448 | "Interface name or neighbor tag\n" | |
4449 | "Enable BGP on interface\n" | |
4450 | "Specify a BGP neighbor\n" | |
4451 | AS_STR | |
4452 | "Internal BGP peer\n" | |
4453 | "External BGP peer\n") | |
b3a39dc5 | 4454 | { |
d62a17ae | 4455 | int idx_word = 1; |
4456 | int idx_remote_as = 4; | |
28c6e247 IR |
4457 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4458 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4459 | } |
4460 | ||
28c6e247 IR |
4461 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4462 | neighbor_interface_v6only_config_remote_as_cmd, | |
4463 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4464 | NEIGHBOR_STR | |
4465 | "Interface name or neighbor tag\n" | |
4466 | "Enable BGP with v6 link-local only\n" | |
4467 | "Enable BGP on interface\n" | |
4468 | "Specify a BGP neighbor\n" | |
4469 | AS_STR | |
4470 | "Internal BGP peer\n" | |
4471 | "External BGP peer\n") | |
b3a39dc5 | 4472 | { |
d62a17ae | 4473 | int idx_word = 1; |
4474 | int idx_remote_as = 5; | |
28c6e247 IR |
4475 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4476 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4477 | } |
4478 | ||
28c6e247 IR |
4479 | DEFUN (neighbor_peer_group, |
4480 | neighbor_peer_group_cmd, | |
4481 | "neighbor WORD peer-group", | |
4482 | NEIGHBOR_STR | |
4483 | "Interface name or neighbor tag\n" | |
4484 | "Configure peer-group\n") | |
718e3744 | 4485 | { |
28c6e247 | 4486 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4487 | int idx_word = 1; |
28c6e247 IR |
4488 | struct peer *peer; |
4489 | struct peer_group *group; | |
718e3744 | 4490 | |
28c6e247 IR |
4491 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4492 | if (peer) { | |
4493 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4494 | return CMD_WARNING_CONFIG_FAILED; | |
4495 | } | |
718e3744 | 4496 | |
28c6e247 IR |
4497 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4498 | if (!group) { | |
4499 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4500 | return CMD_WARNING_CONFIG_FAILED; | |
4501 | } | |
718e3744 | 4502 | |
28c6e247 | 4503 | return CMD_SUCCESS; |
718e3744 | 4504 | } |
4505 | ||
1d80f243 IR |
4506 | DEFUN (no_neighbor, |
4507 | no_neighbor_cmd, | |
4508 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4509 | NO_STR | |
4510 | NEIGHBOR_STR | |
4511 | NEIGHBOR_ADDR_STR2 | |
4512 | "Specify a BGP neighbor\n" | |
4513 | AS_STR | |
4514 | "Internal BGP peer\n" | |
4515 | "External BGP peer\n") | |
718e3744 | 4516 | { |
28c6e247 | 4517 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4518 | int idx_peer = 2; |
28c6e247 | 4519 | int ret; |
d62a17ae | 4520 | union sockunion su; |
28c6e247 IR |
4521 | struct peer_group *group; |
4522 | struct peer *peer; | |
4523 | struct peer *other; | |
d62a17ae | 4524 | |
28c6e247 IR |
4525 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4526 | if (ret < 0) { | |
4527 | /* look up for neighbor by interface name config. */ | |
4528 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4529 | if (peer) { | |
4530 | /* Request zebra to terminate IPv6 RAs on this | |
4531 | * interface. */ | |
4532 | if (peer->ifp) | |
4533 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4534 | peer_notify_unconfig(peer); | |
4535 | peer_delete(peer); | |
4536 | return CMD_SUCCESS; | |
d62a17ae | 4537 | } |
28c6e247 IR |
4538 | |
4539 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4540 | if (group) { | |
4541 | peer_group_notify_unconfig(group); | |
4542 | peer_group_delete(group); | |
4e2786df | 4543 | } else { |
28c6e247 | 4544 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4545 | return CMD_WARNING_CONFIG_FAILED; |
4546 | } | |
28c6e247 IR |
4547 | } else { |
4548 | peer = peer_lookup(bgp, &su); | |
4549 | if (peer) { | |
4550 | if (peer_dynamic_neighbor(peer)) { | |
4551 | vty_out(vty, | |
4552 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4553 | return CMD_WARNING_CONFIG_FAILED; | |
4554 | } | |
d62a17ae | 4555 | |
28c6e247 | 4556 | other = peer->doppelganger; |
f4b8ec07 | 4557 | |
28c6e247 IR |
4558 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4559 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4560 | |
28c6e247 IR |
4561 | peer_notify_unconfig(peer); |
4562 | peer_delete(peer); | |
4563 | if (other && other->status != Deleted) { | |
4564 | peer_notify_unconfig(other); | |
4565 | peer_delete(other); | |
4566 | } | |
4567 | } | |
4568 | } | |
4569 | ||
4570 | return CMD_SUCCESS; | |
a80beece DS |
4571 | } |
4572 | ||
28c6e247 IR |
4573 | DEFUN (no_neighbor_interface_config, |
4574 | no_neighbor_interface_config_cmd, | |
4575 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4576 | NO_STR | |
4577 | NEIGHBOR_STR | |
4578 | "Interface name\n" | |
4579 | "Configure BGP on interface\n" | |
4580 | "Enable BGP with v6 link-local only\n" | |
4581 | "Member of the peer-group\n" | |
4582 | "Peer-group name\n" | |
4583 | "Specify a BGP neighbor\n" | |
4584 | AS_STR | |
4585 | "Internal BGP peer\n" | |
4586 | "External BGP peer\n") | |
718e3744 | 4587 | { |
28c6e247 | 4588 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4589 | int idx_word = 2; |
28c6e247 | 4590 | struct peer *peer; |
718e3744 | 4591 | |
28c6e247 IR |
4592 | /* look up for neighbor by interface name config. */ |
4593 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4594 | if (peer) { | |
4595 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4596 | if (peer->ifp) | |
4597 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4598 | peer_notify_unconfig(peer); | |
4599 | peer_delete(peer); | |
4600 | } else { | |
4601 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4602 | return CMD_WARNING_CONFIG_FAILED; | |
4603 | } | |
4604 | return CMD_SUCCESS; | |
718e3744 | 4605 | } |
4606 | ||
28c6e247 IR |
4607 | DEFUN (no_neighbor_peer_group, |
4608 | no_neighbor_peer_group_cmd, | |
4609 | "no neighbor WORD peer-group", | |
4610 | NO_STR | |
4611 | NEIGHBOR_STR | |
4612 | "Neighbor tag\n" | |
4613 | "Configure peer-group\n") | |
718e3744 | 4614 | { |
28c6e247 IR |
4615 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4616 | int idx_word = 2; | |
4617 | struct peer_group *group; | |
f4b8ec07 | 4618 | |
28c6e247 IR |
4619 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4620 | if (group) { | |
4621 | peer_group_notify_unconfig(group); | |
4622 | peer_group_delete(group); | |
f4b8ec07 | 4623 | } else { |
28c6e247 | 4624 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4625 | return CMD_WARNING_CONFIG_FAILED; |
4626 | } | |
28c6e247 IR |
4627 | return CMD_SUCCESS; |
4628 | } | |
f4b8ec07 | 4629 | |
28c6e247 IR |
4630 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4631 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4632 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4633 | NO_STR | |
4634 | NEIGHBOR_STR | |
4635 | "Interface name or neighbor tag\n" | |
4636 | "Specify a BGP neighbor\n" | |
4637 | AS_STR | |
4638 | "Internal BGP peer\n" | |
4639 | "External BGP peer\n") | |
4640 | { | |
4641 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4642 | int idx_word = 2; | |
4643 | struct peer_group *group; | |
4644 | struct peer *peer; | |
f4b8ec07 | 4645 | |
28c6e247 IR |
4646 | /* look up for neighbor by interface name config. */ |
4647 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4648 | if (peer) { | |
4649 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4650 | return CMD_SUCCESS; | |
4651 | } | |
f4b8ec07 | 4652 | |
28c6e247 IR |
4653 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4654 | if (group) | |
4655 | peer_group_remote_as_delete(group); | |
4656 | else { | |
4657 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4658 | return CMD_WARNING_CONFIG_FAILED; | |
4659 | } | |
4660 | return CMD_SUCCESS; | |
718e3744 | 4661 | } |
6b0655a2 | 4662 | |
28c6e247 IR |
4663 | DEFUN (neighbor_local_as, |
4664 | neighbor_local_as_cmd, | |
4665 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4666 | NEIGHBOR_STR | |
4667 | NEIGHBOR_ADDR_STR2 | |
4668 | "Specify a local-as number\n" | |
4669 | "AS number used as local AS\n") | |
718e3744 | 4670 | { |
d62a17ae | 4671 | int idx_peer = 1; |
4672 | int idx_number = 3; | |
28c6e247 IR |
4673 | struct peer *peer; |
4674 | int ret; | |
4675 | as_t as; | |
718e3744 | 4676 | |
28c6e247 IR |
4677 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4678 | if (!peer) | |
d62a17ae | 4679 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4680 | |
28c6e247 IR |
4681 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4682 | ret = peer_local_as_set(peer, as, 0, 0); | |
4683 | return bgp_vty_return(vty, ret); | |
718e3744 | 4684 | } |
4685 | ||
28c6e247 IR |
4686 | DEFUN (neighbor_local_as_no_prepend, |
4687 | neighbor_local_as_no_prepend_cmd, | |
4688 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4689 | NEIGHBOR_STR | |
4690 | NEIGHBOR_ADDR_STR2 | |
4691 | "Specify a local-as number\n" | |
4692 | "AS number used as local AS\n" | |
4693 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4694 | { |
d62a17ae | 4695 | int idx_peer = 1; |
4696 | int idx_number = 3; | |
28c6e247 IR |
4697 | struct peer *peer; |
4698 | int ret; | |
4699 | as_t as; | |
718e3744 | 4700 | |
28c6e247 IR |
4701 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4702 | if (!peer) | |
d62a17ae | 4703 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4704 | |
28c6e247 IR |
4705 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4706 | ret = peer_local_as_set(peer, as, 1, 0); | |
4707 | return bgp_vty_return(vty, ret); | |
718e3744 | 4708 | } |
4709 | ||
28c6e247 IR |
4710 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4711 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4712 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4713 | NEIGHBOR_STR | |
4714 | NEIGHBOR_ADDR_STR2 | |
4715 | "Specify a local-as number\n" | |
4716 | "AS number used as local AS\n" | |
4717 | "Do not prepend local-as to updates from ebgp peers\n" | |
4718 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4719 | { |
d62a17ae | 4720 | int idx_peer = 1; |
4721 | int idx_number = 3; | |
28c6e247 IR |
4722 | struct peer *peer; |
4723 | int ret; | |
4724 | as_t as; | |
9d3f9705 | 4725 | |
28c6e247 IR |
4726 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4727 | if (!peer) | |
d62a17ae | 4728 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4729 | |
28c6e247 IR |
4730 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4731 | ret = peer_local_as_set(peer, as, 1, 1); | |
4732 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4733 | } |
4734 | ||
28c6e247 IR |
4735 | DEFUN (no_neighbor_local_as, |
4736 | no_neighbor_local_as_cmd, | |
4737 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4738 | NO_STR | |
4739 | NEIGHBOR_STR | |
4740 | NEIGHBOR_ADDR_STR2 | |
4741 | "Specify a local-as number\n" | |
4742 | "AS number used as local AS\n" | |
4743 | "Do not prepend local-as to updates from ebgp peers\n" | |
4744 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4745 | { |
d62a17ae | 4746 | int idx_peer = 2; |
28c6e247 IR |
4747 | struct peer *peer; |
4748 | int ret; | |
718e3744 | 4749 | |
28c6e247 IR |
4750 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4751 | if (!peer) | |
d62a17ae | 4752 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4753 | |
28c6e247 IR |
4754 | ret = peer_local_as_unset(peer); |
4755 | return bgp_vty_return(vty, ret); | |
718e3744 | 4756 | } |
4757 | ||
718e3744 | 4758 | |
3f9c7369 DS |
4759 | DEFUN (neighbor_solo, |
4760 | neighbor_solo_cmd, | |
9ccf14f7 | 4761 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4762 | NEIGHBOR_STR |
4763 | NEIGHBOR_ADDR_STR2 | |
4764 | "Solo peer - part of its own update group\n") | |
4765 | { | |
d62a17ae | 4766 | int idx_peer = 1; |
4767 | struct peer *peer; | |
4768 | int ret; | |
3f9c7369 | 4769 | |
d62a17ae | 4770 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4771 | if (!peer) | |
4772 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4773 | |
d62a17ae | 4774 | ret = update_group_adjust_soloness(peer, 1); |
4775 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4776 | } |
4777 | ||
4778 | DEFUN (no_neighbor_solo, | |
4779 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4780 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4781 | NO_STR |
4782 | NEIGHBOR_STR | |
4783 | NEIGHBOR_ADDR_STR2 | |
4784 | "Solo peer - part of its own update group\n") | |
4785 | { | |
d62a17ae | 4786 | int idx_peer = 2; |
4787 | struct peer *peer; | |
4788 | int ret; | |
3f9c7369 | 4789 | |
d62a17ae | 4790 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4791 | if (!peer) | |
4792 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4793 | |
d62a17ae | 4794 | ret = update_group_adjust_soloness(peer, 0); |
4795 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4796 | } |
4797 | ||
28c6e247 IR |
4798 | DEFUN (neighbor_password, |
4799 | neighbor_password_cmd, | |
4800 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4801 | NEIGHBOR_STR | |
4802 | NEIGHBOR_ADDR_STR2 | |
4803 | "Set a password\n" | |
4804 | "The password\n") | |
0df7c91f | 4805 | { |
d62a17ae | 4806 | int idx_peer = 1; |
4807 | int idx_line = 3; | |
28c6e247 IR |
4808 | struct peer *peer; |
4809 | int ret; | |
0df7c91f | 4810 | |
28c6e247 IR |
4811 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4812 | if (!peer) | |
d62a17ae | 4813 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4814 | |
28c6e247 IR |
4815 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4816 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4817 | } |
4818 | ||
28c6e247 IR |
4819 | DEFUN (no_neighbor_password, |
4820 | no_neighbor_password_cmd, | |
4821 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4822 | NO_STR | |
4823 | NEIGHBOR_STR | |
4824 | NEIGHBOR_ADDR_STR2 | |
4825 | "Set a password\n" | |
4826 | "The password\n") | |
0df7c91f | 4827 | { |
d62a17ae | 4828 | int idx_peer = 2; |
28c6e247 IR |
4829 | struct peer *peer; |
4830 | int ret; | |
0df7c91f | 4831 | |
28c6e247 IR |
4832 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4833 | if (!peer) | |
d62a17ae | 4834 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4835 | |
28c6e247 IR |
4836 | ret = peer_password_unset(peer); |
4837 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4838 | } |
6b0655a2 | 4839 | |
28c6e247 IR |
4840 | DEFUN (neighbor_activate, |
4841 | neighbor_activate_cmd, | |
4842 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4843 | NEIGHBOR_STR | |
4844 | NEIGHBOR_ADDR_STR2 | |
4845 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4846 | { |
d62a17ae | 4847 | int idx_peer = 1; |
28c6e247 IR |
4848 | int ret; |
4849 | struct peer *peer; | |
56ceae84 | 4850 | |
28c6e247 IR |
4851 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4852 | if (!peer) | |
d62a17ae | 4853 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4854 | |
28c6e247 IR |
4855 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4856 | return bgp_vty_return(vty, ret); | |
718e3744 | 4857 | } |
4858 | ||
d62a17ae | 4859 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4860 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4861 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4862 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4863 | |
28c6e247 IR |
4864 | DEFUN (no_neighbor_activate, |
4865 | no_neighbor_activate_cmd, | |
4866 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4867 | NO_STR | |
4868 | NEIGHBOR_STR | |
4869 | NEIGHBOR_ADDR_STR2 | |
4870 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4871 | { |
d62a17ae | 4872 | int idx_peer = 2; |
28c6e247 IR |
4873 | int ret; |
4874 | struct peer *peer; | |
f4b8ec07 | 4875 | |
28c6e247 IR |
4876 | /* Lookup peer. */ |
4877 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4878 | if (!peer) | |
d62a17ae | 4879 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4880 | |
28c6e247 IR |
4881 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4882 | return bgp_vty_return(vty, ret); | |
718e3744 | 4883 | } |
6b0655a2 | 4884 | |
d62a17ae | 4885 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4886 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4887 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4888 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4889 | |
28c6e247 IR |
4890 | DEFUN (neighbor_set_peer_group, |
4891 | neighbor_set_peer_group_cmd, | |
4892 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4893 | NEIGHBOR_STR | |
4894 | NEIGHBOR_ADDR_STR2 | |
4895 | "Member of the peer-group\n" | |
4896 | "Peer-group name\n") | |
718e3744 | 4897 | { |
28c6e247 | 4898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4899 | int idx_peer = 1; |
4900 | int idx_word = 3; | |
28c6e247 IR |
4901 | int ret; |
4902 | as_t as; | |
4903 | union sockunion su; | |
4904 | struct peer *peer; | |
4905 | struct peer_group *group; | |
4906 | ||
4907 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4908 | if (ret < 0) { | |
4909 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4910 | if (!peer) { | |
4911 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4912 | argv[idx_peer]->arg); | |
4913 | return CMD_WARNING_CONFIG_FAILED; | |
4914 | } | |
4915 | } else { | |
4916 | if (peer_address_self_check(bgp, &su)) { | |
4917 | vty_out(vty, | |
4918 | "%% Can not configure the local system as neighbor\n"); | |
4919 | return CMD_WARNING_CONFIG_FAILED; | |
4920 | } | |
2a059a54 | 4921 | |
28c6e247 IR |
4922 | /* Disallow for dynamic neighbor. */ |
4923 | peer = peer_lookup(bgp, &su); | |
4924 | if (peer && peer_dynamic_neighbor(peer)) { | |
4925 | vty_out(vty, | |
4926 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4927 | return CMD_WARNING_CONFIG_FAILED; | |
4928 | } | |
4929 | } | |
4930 | ||
4931 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4932 | if (!group) { | |
4933 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 4934 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 4935 | } |
d62a17ae | 4936 | |
28c6e247 | 4937 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 4938 | |
28c6e247 IR |
4939 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { |
4940 | vty_out(vty, | |
4941 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4942 | as); | |
4943 | return CMD_WARNING_CONFIG_FAILED; | |
4944 | } | |
4945 | ||
4946 | return bgp_vty_return(vty, ret); | |
d62a17ae | 4947 | } |
4948 | ||
4949 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4950 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4951 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4952 | "Member of the peer-group\n" | |
4953 | "Peer-group name\n") | |
596c17ba | 4954 | |
28c6e247 IR |
4955 | DEFUN (no_neighbor_set_peer_group, |
4956 | no_neighbor_set_peer_group_cmd, | |
4957 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
4958 | NO_STR | |
4959 | NEIGHBOR_STR | |
4960 | NEIGHBOR_ADDR_STR2 | |
4961 | "Member of the peer-group\n" | |
4962 | "Peer-group name\n") | |
718e3744 | 4963 | { |
28c6e247 | 4964 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4965 | int idx_peer = 2; |
28c6e247 IR |
4966 | int idx_word = 4; |
4967 | int ret; | |
4968 | struct peer *peer; | |
4969 | struct peer_group *group; | |
d62a17ae | 4970 | |
28c6e247 IR |
4971 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
4972 | if (!peer) | |
d62a17ae | 4973 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 4974 | |
28c6e247 IR |
4975 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4976 | if (!group) { | |
4977 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4978 | return CMD_WARNING_CONFIG_FAILED; | |
4979 | } | |
718e3744 | 4980 | |
28c6e247 IR |
4981 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4982 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4983 | ||
4984 | peer_notify_unconfig(peer); | |
4985 | ret = peer_delete(peer); | |
4986 | ||
4987 | return bgp_vty_return(vty, ret); | |
718e3744 | 4988 | } |
6b0655a2 | 4989 | |
d62a17ae | 4990 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 4991 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4992 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4993 | "Member of the peer-group\n" | |
4994 | "Peer-group name\n") | |
596c17ba | 4995 | |
d62a17ae | 4996 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4997 | uint32_t flag, int set) |
718e3744 | 4998 | { |
d62a17ae | 4999 | int ret; |
5000 | struct peer *peer; | |
718e3744 | 5001 | |
d62a17ae | 5002 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5003 | if (!peer) | |
5004 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5005 | |
7ebe625c QY |
5006 | /* |
5007 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5008 | * we should not accept disable-connected-check. | |
5009 | */ | |
5010 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5011 | vty_out(vty, | |
3efd0893 | 5012 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
5013 | ip_str); |
5014 | return CMD_WARNING_CONFIG_FAILED; | |
5015 | } | |
5016 | ||
d62a17ae | 5017 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
5018 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 5019 | |
d62a17ae | 5020 | if (set) |
5021 | ret = peer_flag_set(peer, flag); | |
5022 | else | |
5023 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 5024 | |
d62a17ae | 5025 | return bgp_vty_return(vty, ret); |
718e3744 | 5026 | } |
5027 | ||
47cbc09b | 5028 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 5029 | { |
d62a17ae | 5030 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 5031 | } |
5032 | ||
d62a17ae | 5033 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5034 | uint32_t flag) |
718e3744 | 5035 | { |
d62a17ae | 5036 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 5037 | } |
5038 | ||
5039 | /* neighbor passive. */ | |
28c6e247 IR |
5040 | DEFUN (neighbor_passive, |
5041 | neighbor_passive_cmd, | |
5042 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5043 | NEIGHBOR_STR | |
5044 | NEIGHBOR_ADDR_STR2 | |
5045 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5046 | { |
d62a17ae | 5047 | int idx_peer = 1; |
28c6e247 | 5048 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5049 | } |
5050 | ||
28c6e247 IR |
5051 | DEFUN (no_neighbor_passive, |
5052 | no_neighbor_passive_cmd, | |
5053 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5054 | NO_STR | |
5055 | NEIGHBOR_STR | |
5056 | NEIGHBOR_ADDR_STR2 | |
5057 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5058 | { |
d62a17ae | 5059 | int idx_peer = 2; |
28c6e247 | 5060 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5061 | } |
6b0655a2 | 5062 | |
718e3744 | 5063 | /* neighbor shutdown. */ |
28c6e247 IR |
5064 | DEFUN (neighbor_shutdown_msg, |
5065 | neighbor_shutdown_msg_cmd, | |
5066 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5067 | NEIGHBOR_STR | |
5068 | NEIGHBOR_ADDR_STR2 | |
5069 | "Administratively shut down this neighbor\n" | |
5070 | "Add a shutdown message (RFC 8203)\n" | |
5071 | "Shutdown message\n") | |
718e3744 | 5072 | { |
d62a17ae | 5073 | int idx_peer = 1; |
73d70fa6 | 5074 | |
d62a17ae | 5075 | if (argc >= 5) { |
28c6e247 IR |
5076 | struct peer *peer = |
5077 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 5078 | char *message; |
73d70fa6 | 5079 | |
28c6e247 IR |
5080 | if (!peer) |
5081 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5082 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
5083 | peer_tx_shutdown_message_set(peer, message); |
5084 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 5085 | } |
73d70fa6 | 5086 | |
28c6e247 | 5087 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5088 | } |
5089 | ||
1d80f243 | 5090 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5091 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5092 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5093 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5094 | |
28c6e247 IR |
5095 | DEFUN (no_neighbor_shutdown_msg, |
5096 | no_neighbor_shutdown_msg_cmd, | |
5097 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5098 | NO_STR | |
5099 | NEIGHBOR_STR | |
5100 | NEIGHBOR_ADDR_STR2 | |
5101 | "Administratively shut down this neighbor\n" | |
5102 | "Remove a shutdown message (RFC 8203)\n" | |
5103 | "Shutdown message\n") | |
718e3744 | 5104 | { |
d62a17ae | 5105 | int idx_peer = 2; |
73d70fa6 | 5106 | |
28c6e247 IR |
5107 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5108 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5109 | } |
6b0655a2 | 5110 | |
1d80f243 | 5111 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5112 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5113 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5114 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5115 | |
8336c896 DA |
5116 | DEFUN(neighbor_shutdown_rtt, |
5117 | neighbor_shutdown_rtt_cmd, | |
5118 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5119 | NEIGHBOR_STR | |
5120 | NEIGHBOR_ADDR_STR2 | |
5121 | "Administratively shut down this neighbor\n" | |
5122 | "Shutdown if round-trip-time is higher than expected\n" | |
5123 | "Round-trip-time in milliseconds\n" | |
5124 | "Specify the number of keepalives before shutdown\n" | |
5125 | "The number of keepalives with higher RTT to shutdown\n") | |
5126 | { | |
5127 | int idx_peer = 1; | |
5128 | int idx_rtt = 4; | |
5129 | int idx_count = 0; | |
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 = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5138 | ||
5139 | if (argv_find(argv, argc, "count", &idx_count)) | |
5140 | peer->rtt_keepalive_conf = | |
5141 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5142 | ||
5143 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5144 | PEER_FLAG_RTT_SHUTDOWN); | |
5145 | } | |
5146 | ||
5147 | DEFUN(no_neighbor_shutdown_rtt, | |
5148 | no_neighbor_shutdown_rtt_cmd, | |
5149 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5150 | NO_STR | |
5151 | NEIGHBOR_STR | |
5152 | NEIGHBOR_ADDR_STR2 | |
5153 | "Administratively shut down this neighbor\n" | |
5154 | "Shutdown if round-trip-time is higher than expected\n" | |
5155 | "Round-trip-time in milliseconds\n" | |
5156 | "Specify the number of keepalives before shutdown\n" | |
5157 | "The number of keepalives with higher RTT to shutdown\n") | |
5158 | { | |
5159 | int idx_peer = 2; | |
5160 | struct peer *peer; | |
5161 | ||
5162 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5163 | ||
5164 | if (!peer) | |
5165 | return CMD_WARNING_CONFIG_FAILED; | |
5166 | ||
5167 | peer->rtt_expected = 0; | |
5168 | peer->rtt_keepalive_conf = 1; | |
5169 | ||
5170 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5171 | PEER_FLAG_RTT_SHUTDOWN); | |
5172 | } | |
5173 | ||
718e3744 | 5174 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5175 | DEFUN (neighbor_capability_dynamic, |
5176 | neighbor_capability_dynamic_cmd, | |
5177 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5178 | NEIGHBOR_STR | |
5179 | NEIGHBOR_ADDR_STR2 | |
5180 | "Advertise capability to the peer\n" | |
5181 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5182 | { |
d62a17ae | 5183 | int idx_peer = 1; |
28c6e247 IR |
5184 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5185 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5186 | } |
5187 | ||
28c6e247 IR |
5188 | DEFUN (no_neighbor_capability_dynamic, |
5189 | no_neighbor_capability_dynamic_cmd, | |
5190 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5191 | NO_STR | |
5192 | NEIGHBOR_STR | |
5193 | NEIGHBOR_ADDR_STR2 | |
5194 | "Advertise capability to the peer\n" | |
5195 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5196 | { |
d62a17ae | 5197 | int idx_peer = 2; |
28c6e247 IR |
5198 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5199 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5200 | } |
6b0655a2 | 5201 | |
718e3744 | 5202 | /* neighbor dont-capability-negotiate */ |
5203 | DEFUN (neighbor_dont_capability_negotiate, | |
5204 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5205 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5206 | NEIGHBOR_STR |
5207 | NEIGHBOR_ADDR_STR2 | |
5208 | "Do not perform capability negotiation\n") | |
5209 | { | |
d62a17ae | 5210 | int idx_peer = 1; |
5211 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5212 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5213 | } |
5214 | ||
5215 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5216 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5217 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5218 | NO_STR |
5219 | NEIGHBOR_STR | |
5220 | NEIGHBOR_ADDR_STR2 | |
5221 | "Do not perform capability negotiation\n") | |
5222 | { | |
28c6e247 IR |
5223 | int idx_peer = 2; |
5224 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5225 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5226 | } |
5227 | ||
28c6e247 IR |
5228 | /* neighbor capability extended next hop encoding */ |
5229 | DEFUN (neighbor_capability_enhe, | |
5230 | neighbor_capability_enhe_cmd, | |
5231 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5232 | NEIGHBOR_STR | |
5233 | NEIGHBOR_ADDR_STR2 | |
5234 | "Advertise capability to the peer\n" | |
5235 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5236 | { |
28c6e247 IR |
5237 | int idx_peer = 1; |
5238 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5239 | PEER_FLAG_CAPABILITY_ENHE); | |
5240 | } | |
f4b8ec07 | 5241 | |
28c6e247 IR |
5242 | DEFUN (no_neighbor_capability_enhe, |
5243 | no_neighbor_capability_enhe_cmd, | |
5244 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5245 | NO_STR | |
5246 | NEIGHBOR_STR | |
5247 | NEIGHBOR_ADDR_STR2 | |
5248 | "Advertise capability to the peer\n" | |
5249 | "Advertise extended next-hop capability to the peer\n") | |
5250 | { | |
5251 | int idx_peer = 2; | |
5252 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5253 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5254 | } |
5255 | ||
d62a17ae | 5256 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5257 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5258 | int set) |
718e3744 | 5259 | { |
d62a17ae | 5260 | int ret; |
5261 | struct peer *peer; | |
718e3744 | 5262 | |
d62a17ae | 5263 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5264 | if (!peer) | |
5265 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5266 | |
d62a17ae | 5267 | if (set) |
5268 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5269 | else | |
5270 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5271 | |
d62a17ae | 5272 | return bgp_vty_return(vty, ret); |
718e3744 | 5273 | } |
5274 | ||
d62a17ae | 5275 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5276 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5277 | { |
d62a17ae | 5278 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5279 | } |
5280 | ||
d62a17ae | 5281 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5282 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5283 | { |
d62a17ae | 5284 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5285 | } |
6b0655a2 | 5286 | |
718e3744 | 5287 | /* neighbor capability orf prefix-list. */ |
5288 | DEFUN (neighbor_capability_orf_prefix, | |
5289 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5290 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5291 | NEIGHBOR_STR |
5292 | NEIGHBOR_ADDR_STR2 | |
5293 | "Advertise capability to the peer\n" | |
5294 | "Advertise ORF capability to the peer\n" | |
5295 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5296 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5297 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5298 | "Capability to SEND the ORF to this neighbor\n") | |
5299 | { | |
d62a17ae | 5300 | int idx_send_recv = 5; |
db45f64d DS |
5301 | char *peer_str = argv[1]->arg; |
5302 | struct peer *peer; | |
5303 | afi_t afi = bgp_node_afi(vty); | |
5304 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5305 | |
db45f64d DS |
5306 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5307 | if (!peer) | |
d62a17ae | 5308 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5309 | |
db45f64d DS |
5310 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5311 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5312 | PEER_FLAG_ORF_PREFIX_SM); | |
5313 | ||
5314 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5315 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5316 | PEER_FLAG_ORF_PREFIX_RM); | |
5317 | ||
5318 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5319 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5320 | PEER_FLAG_ORF_PREFIX_SM) | |
5321 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5322 | PEER_FLAG_ORF_PREFIX_RM); | |
5323 | ||
5324 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5325 | } |
5326 | ||
5327 | ALIAS_HIDDEN( | |
5328 | neighbor_capability_orf_prefix, | |
5329 | neighbor_capability_orf_prefix_hidden_cmd, | |
5330 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5331 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5332 | "Advertise capability to the peer\n" | |
5333 | "Advertise ORF capability to the peer\n" | |
5334 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5335 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5336 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5337 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5338 | |
718e3744 | 5339 | DEFUN (no_neighbor_capability_orf_prefix, |
5340 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5341 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5342 | NO_STR |
5343 | NEIGHBOR_STR | |
5344 | NEIGHBOR_ADDR_STR2 | |
5345 | "Advertise capability to the peer\n" | |
5346 | "Advertise ORF capability to the peer\n" | |
5347 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5348 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5349 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5350 | "Capability to SEND the ORF to this neighbor\n") | |
5351 | { | |
d62a17ae | 5352 | int idx_send_recv = 6; |
db45f64d DS |
5353 | char *peer_str = argv[2]->arg; |
5354 | struct peer *peer; | |
5355 | afi_t afi = bgp_node_afi(vty); | |
5356 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5357 | |
db45f64d DS |
5358 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5359 | if (!peer) | |
d62a17ae | 5360 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5361 | |
db45f64d DS |
5362 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5363 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5364 | PEER_FLAG_ORF_PREFIX_SM); | |
5365 | ||
5366 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5367 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5368 | PEER_FLAG_ORF_PREFIX_RM); | |
5369 | ||
5370 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5371 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5372 | PEER_FLAG_ORF_PREFIX_SM) | |
5373 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5374 | PEER_FLAG_ORF_PREFIX_RM); | |
5375 | ||
5376 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5377 | } |
5378 | ||
5379 | ALIAS_HIDDEN( | |
5380 | no_neighbor_capability_orf_prefix, | |
5381 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5382 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5383 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5384 | "Advertise capability to the peer\n" | |
5385 | "Advertise ORF capability to the peer\n" | |
5386 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5387 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5388 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5389 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5390 | |
718e3744 | 5391 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5392 | DEFUN (neighbor_nexthop_self, |
5393 | neighbor_nexthop_self_cmd, | |
5394 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5395 | NEIGHBOR_STR | |
5396 | NEIGHBOR_ADDR_STR2 | |
5397 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5398 | { |
d62a17ae | 5399 | int idx_peer = 1; |
28c6e247 IR |
5400 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5401 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5402 | } |
9e7a53c1 | 5403 | |
d62a17ae | 5404 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5405 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5406 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5407 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5408 | |
f4b8ec07 | 5409 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5410 | DEFUN (neighbor_nexthop_self_force, |
5411 | neighbor_nexthop_self_force_cmd, | |
5412 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5413 | NEIGHBOR_STR | |
5414 | NEIGHBOR_ADDR_STR2 | |
5415 | "Disable the next hop calculation for this neighbor\n" | |
5416 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5417 | { |
5418 | int idx_peer = 1; | |
28c6e247 IR |
5419 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5420 | bgp_node_safi(vty), | |
5421 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5422 | } |
5423 | ||
d62a17ae | 5424 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5425 | neighbor_nexthop_self_force_hidden_cmd, | |
5426 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5427 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5428 | "Disable the next hop calculation for this neighbor\n" | |
5429 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5430 | |
1bc4e531 DA |
5431 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5432 | neighbor_nexthop_self_all_hidden_cmd, | |
5433 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5434 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5435 | "Disable the next hop calculation for this neighbor\n" | |
5436 | "Set the next hop to self for reflected routes\n") | |
5437 | ||
28c6e247 IR |
5438 | DEFUN (no_neighbor_nexthop_self, |
5439 | no_neighbor_nexthop_self_cmd, | |
5440 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5441 | NO_STR | |
5442 | NEIGHBOR_STR | |
5443 | NEIGHBOR_ADDR_STR2 | |
5444 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5445 | { |
d62a17ae | 5446 | int idx_peer = 2; |
28c6e247 IR |
5447 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5448 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5449 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5450 | } |
6b0655a2 | 5451 | |
d62a17ae | 5452 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5453 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5454 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5455 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5456 | |
28c6e247 IR |
5457 | DEFUN (no_neighbor_nexthop_self_force, |
5458 | no_neighbor_nexthop_self_force_cmd, | |
5459 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5460 | NO_STR | |
5461 | NEIGHBOR_STR | |
5462 | NEIGHBOR_ADDR_STR2 | |
5463 | "Disable the next hop calculation for this neighbor\n" | |
5464 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5465 | { |
d62a17ae | 5466 | int idx_peer = 2; |
28c6e247 IR |
5467 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5468 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5469 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5470 | } |
a538debe | 5471 | |
d62a17ae | 5472 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5473 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5474 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5475 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5476 | "Disable the next hop calculation for this neighbor\n" | |
5477 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5478 | |
1bc4e531 DA |
5479 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5480 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5481 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5482 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5483 | "Disable the next hop calculation for this neighbor\n" | |
5484 | "Set the next hop to self for reflected routes\n") | |
5485 | ||
c7122e14 | 5486 | /* neighbor as-override */ |
28c6e247 IR |
5487 | DEFUN (neighbor_as_override, |
5488 | neighbor_as_override_cmd, | |
5489 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5490 | NEIGHBOR_STR | |
5491 | NEIGHBOR_ADDR_STR2 | |
5492 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5493 | { |
d62a17ae | 5494 | int idx_peer = 1; |
28c6e247 IR |
5495 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5496 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5497 | } |
5498 | ||
d62a17ae | 5499 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5500 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5501 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5502 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5503 | |
28c6e247 IR |
5504 | DEFUN (no_neighbor_as_override, |
5505 | no_neighbor_as_override_cmd, | |
5506 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5507 | NO_STR | |
5508 | NEIGHBOR_STR | |
5509 | NEIGHBOR_ADDR_STR2 | |
5510 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5511 | { |
d62a17ae | 5512 | int idx_peer = 2; |
28c6e247 IR |
5513 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5514 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5515 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5516 | } |
5517 | ||
d62a17ae | 5518 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5519 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5520 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5521 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5522 | |
718e3744 | 5523 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5524 | DEFUN (neighbor_remove_private_as, |
5525 | neighbor_remove_private_as_cmd, | |
5526 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5527 | NEIGHBOR_STR | |
5528 | NEIGHBOR_ADDR_STR2 | |
5529 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5530 | { |
d62a17ae | 5531 | int idx_peer = 1; |
28c6e247 IR |
5532 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5533 | bgp_node_safi(vty), | |
5534 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5535 | } |
5536 | ||
d62a17ae | 5537 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5538 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5539 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5540 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5541 | |
28c6e247 IR |
5542 | DEFUN (neighbor_remove_private_as_all, |
5543 | neighbor_remove_private_as_all_cmd, | |
5544 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5545 | NEIGHBOR_STR | |
5546 | NEIGHBOR_ADDR_STR2 | |
5547 | "Remove private ASNs in outbound updates\n" | |
5548 | "Apply to all AS numbers\n") | |
5000f21c | 5549 | { |
d62a17ae | 5550 | int idx_peer = 1; |
28c6e247 IR |
5551 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5552 | bgp_node_safi(vty), | |
5553 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5554 | } |
5555 | ||
d62a17ae | 5556 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5557 | neighbor_remove_private_as_all_hidden_cmd, | |
5558 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5559 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5560 | "Remove private ASNs in outbound updates\n" | |
5561 | "Apply to all AS numbers") | |
596c17ba | 5562 | |
28c6e247 IR |
5563 | DEFUN (neighbor_remove_private_as_replace_as, |
5564 | neighbor_remove_private_as_replace_as_cmd, | |
5565 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5566 | NEIGHBOR_STR | |
5567 | NEIGHBOR_ADDR_STR2 | |
5568 | "Remove private ASNs in outbound updates\n" | |
5569 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5570 | { |
d62a17ae | 5571 | int idx_peer = 1; |
28c6e247 IR |
5572 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5573 | bgp_node_safi(vty), | |
5574 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5575 | } |
5576 | ||
d62a17ae | 5577 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5578 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5579 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5580 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5581 | "Remove private ASNs in outbound updates\n" | |
5582 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5583 | |
28c6e247 IR |
5584 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5585 | neighbor_remove_private_as_all_replace_as_cmd, | |
5586 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5587 | NEIGHBOR_STR | |
5588 | NEIGHBOR_ADDR_STR2 | |
5589 | "Remove private ASNs in outbound updates\n" | |
5590 | "Apply to all AS numbers\n" | |
5591 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5592 | { |
d62a17ae | 5593 | int idx_peer = 1; |
28c6e247 IR |
5594 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5595 | bgp_node_safi(vty), | |
5596 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5597 | } |
5598 | ||
d62a17ae | 5599 | ALIAS_HIDDEN( |
5600 | neighbor_remove_private_as_all_replace_as, | |
5601 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5602 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5603 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5604 | "Remove private ASNs in outbound updates\n" | |
5605 | "Apply to all AS numbers\n" | |
5606 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5607 | |
28c6e247 IR |
5608 | DEFUN (no_neighbor_remove_private_as, |
5609 | no_neighbor_remove_private_as_cmd, | |
5610 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5611 | NO_STR | |
5612 | NEIGHBOR_STR | |
5613 | NEIGHBOR_ADDR_STR2 | |
5614 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5615 | { |
d62a17ae | 5616 | int idx_peer = 2; |
28c6e247 IR |
5617 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5618 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5619 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5620 | } |
6b0655a2 | 5621 | |
d62a17ae | 5622 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5623 | no_neighbor_remove_private_as_hidden_cmd, | |
5624 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5625 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5626 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5627 | |
28c6e247 IR |
5628 | DEFUN (no_neighbor_remove_private_as_all, |
5629 | no_neighbor_remove_private_as_all_cmd, | |
5630 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5631 | NO_STR | |
5632 | NEIGHBOR_STR | |
5633 | NEIGHBOR_ADDR_STR2 | |
5634 | "Remove private ASNs in outbound updates\n" | |
5635 | "Apply to all AS numbers\n") | |
88b8ed8d | 5636 | { |
d62a17ae | 5637 | int idx_peer = 2; |
28c6e247 IR |
5638 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5639 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5640 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5641 | } |
5000f21c | 5642 | |
d62a17ae | 5643 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5644 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5645 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5646 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5647 | "Remove private ASNs in outbound updates\n" | |
5648 | "Apply to all AS numbers\n") | |
596c17ba | 5649 | |
28c6e247 IR |
5650 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5651 | no_neighbor_remove_private_as_replace_as_cmd, | |
5652 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5653 | NO_STR | |
5654 | NEIGHBOR_STR | |
5655 | NEIGHBOR_ADDR_STR2 | |
5656 | "Remove private ASNs in outbound updates\n" | |
5657 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5658 | { |
d62a17ae | 5659 | int idx_peer = 2; |
28c6e247 IR |
5660 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5661 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5662 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5663 | } |
5000f21c | 5664 | |
d62a17ae | 5665 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5666 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5667 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5668 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5669 | "Remove private ASNs in outbound updates\n" | |
5670 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5671 | |
28c6e247 IR |
5672 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5673 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5674 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5675 | NO_STR | |
5676 | NEIGHBOR_STR | |
5677 | NEIGHBOR_ADDR_STR2 | |
5678 | "Remove private ASNs in outbound updates\n" | |
5679 | "Apply to all AS numbers\n" | |
5680 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5681 | { |
d62a17ae | 5682 | int idx_peer = 2; |
28c6e247 IR |
5683 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5684 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5685 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5686 | } |
5000f21c | 5687 | |
d62a17ae | 5688 | ALIAS_HIDDEN( |
5689 | no_neighbor_remove_private_as_all_replace_as, | |
5690 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5692 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5693 | "Remove private ASNs in outbound updates\n" | |
5694 | "Apply to all AS numbers\n" | |
5695 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5696 | |
5000f21c | 5697 | |
718e3744 | 5698 | /* neighbor send-community. */ |
28c6e247 IR |
5699 | DEFUN (neighbor_send_community, |
5700 | neighbor_send_community_cmd, | |
5701 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5702 | NEIGHBOR_STR | |
5703 | NEIGHBOR_ADDR_STR2 | |
5704 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5705 | { |
d62a17ae | 5706 | int idx_peer = 1; |
27c05d4d | 5707 | |
f63d4054 IR |
5708 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5709 | bgp_node_safi(vty), | |
5710 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5711 | } |
5712 | ||
d62a17ae | 5713 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5714 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5715 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5716 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5717 | |
28c6e247 IR |
5718 | DEFUN (no_neighbor_send_community, |
5719 | no_neighbor_send_community_cmd, | |
5720 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5721 | NO_STR | |
5722 | NEIGHBOR_STR | |
5723 | NEIGHBOR_ADDR_STR2 | |
5724 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5725 | { |
d62a17ae | 5726 | int idx_peer = 2; |
27c05d4d | 5727 | |
f63d4054 IR |
5728 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5729 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5730 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5731 | } |
6b0655a2 | 5732 | |
d62a17ae | 5733 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5735 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5736 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5737 | |
718e3744 | 5738 | /* neighbor send-community extended. */ |
28c6e247 IR |
5739 | DEFUN (neighbor_send_community_type, |
5740 | neighbor_send_community_type_cmd, | |
5741 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5742 | NEIGHBOR_STR | |
5743 | NEIGHBOR_ADDR_STR2 | |
5744 | "Send Community attribute to this neighbor\n" | |
5745 | "Send Standard and Extended Community attributes\n" | |
5746 | "Send Standard, Large and Extended Community attributes\n" | |
5747 | "Send Extended Community attributes\n" | |
5748 | "Send Standard Community attributes\n" | |
5749 | "Send Large Community attributes\n") | |
718e3744 | 5750 | { |
27c05d4d | 5751 | const char *type = argv[argc - 1]->text; |
db45f64d | 5752 | char *peer_str = argv[1]->arg; |
28c6e247 | 5753 | struct peer *peer; |
db45f64d | 5754 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 5755 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 5756 | |
28c6e247 IR |
5757 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5758 | if (!peer) | |
5759 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 5760 | |
28c6e247 IR |
5761 | if (strmatch(type, "standard")) |
5762 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5763 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5764 | |
28c6e247 IR |
5765 | if (strmatch(type, "extended")) |
5766 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5767 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5768 | |
28c6e247 IR |
5769 | if (strmatch(type, "large")) |
5770 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5771 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 5772 | |
28c6e247 IR |
5773 | if (strmatch(type, "both")) { |
5774 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5775 | PEER_FLAG_SEND_COMMUNITY) | |
5776 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5777 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5778 | } |
28c6e247 IR |
5779 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
5780 | PEER_FLAG_SEND_COMMUNITY) | |
5781 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5782 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5783 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5784 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5785 | } |
5786 | ||
5787 | ALIAS_HIDDEN( | |
5788 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5789 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5790 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5791 | "Send Community attribute to this neighbor\n" | |
5792 | "Send Standard and Extended Community attributes\n" | |
5793 | "Send Standard, Large and Extended Community attributes\n" | |
5794 | "Send Extended Community attributes\n" | |
5795 | "Send Standard Community attributes\n" | |
5796 | "Send Large Community attributes\n") | |
596c17ba | 5797 | |
28c6e247 IR |
5798 | DEFUN (no_neighbor_send_community_type, |
5799 | no_neighbor_send_community_type_cmd, | |
5800 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5801 | NO_STR | |
5802 | NEIGHBOR_STR | |
5803 | NEIGHBOR_ADDR_STR2 | |
5804 | "Send Community attribute to this neighbor\n" | |
5805 | "Send Standard and Extended Community attributes\n" | |
5806 | "Send Standard, Large and Extended Community attributes\n" | |
5807 | "Send Extended Community attributes\n" | |
5808 | "Send Standard Community attributes\n" | |
5809 | "Send Large Community attributes\n") | |
718e3744 | 5810 | { |
d62a17ae | 5811 | const char *type = argv[argc - 1]->text; |
db45f64d | 5812 | char *peer_str = argv[2]->arg; |
28c6e247 | 5813 | struct peer *peer; |
db45f64d DS |
5814 | afi_t afi = bgp_node_afi(vty); |
5815 | safi_t safi = bgp_node_safi(vty); | |
5816 | ||
28c6e247 IR |
5817 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5818 | if (!peer) | |
f4b8ec07 CS |
5819 | return CMD_WARNING_CONFIG_FAILED; |
5820 | ||
28c6e247 IR |
5821 | if (strmatch(type, "standard")) |
5822 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5823 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5824 | |
28c6e247 IR |
5825 | if (strmatch(type, "extended")) |
5826 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5827 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5828 | |
28c6e247 IR |
5829 | if (strmatch(type, "large")) |
5830 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5831 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
5832 | |
5833 | if (strmatch(type, "both")) { | |
db45f64d | 5834 | |
28c6e247 IR |
5835 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5836 | PEER_FLAG_SEND_COMMUNITY) | |
5837 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5838 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5839 | } |
5840 | ||
28c6e247 IR |
5841 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5842 | PEER_FLAG_SEND_COMMUNITY) | |
5843 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5844 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5845 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5846 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5847 | } |
5848 | ||
5849 | ALIAS_HIDDEN( | |
5850 | no_neighbor_send_community_type, | |
5851 | no_neighbor_send_community_type_hidden_cmd, | |
5852 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5853 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5854 | "Send Community attribute to this neighbor\n" | |
5855 | "Send Standard and Extended Community attributes\n" | |
5856 | "Send Standard, Large and Extended Community attributes\n" | |
5857 | "Send Extended Community attributes\n" | |
5858 | "Send Standard Community attributes\n" | |
5859 | "Send Large Community attributes\n") | |
596c17ba | 5860 | |
718e3744 | 5861 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
5862 | DEFUN (neighbor_soft_reconfiguration, |
5863 | neighbor_soft_reconfiguration_cmd, | |
5864 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5865 | NEIGHBOR_STR | |
5866 | NEIGHBOR_ADDR_STR2 | |
5867 | "Per neighbor soft reconfiguration\n" | |
5868 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5869 | { |
d62a17ae | 5870 | int idx_peer = 1; |
28c6e247 IR |
5871 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5872 | bgp_node_safi(vty), | |
5873 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5874 | } |
5875 | ||
d62a17ae | 5876 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5877 | neighbor_soft_reconfiguration_hidden_cmd, | |
5878 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5879 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5880 | "Per neighbor soft reconfiguration\n" | |
5881 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5882 | |
28c6e247 IR |
5883 | DEFUN (no_neighbor_soft_reconfiguration, |
5884 | no_neighbor_soft_reconfiguration_cmd, | |
5885 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5886 | NO_STR | |
5887 | NEIGHBOR_STR | |
5888 | NEIGHBOR_ADDR_STR2 | |
5889 | "Per neighbor soft reconfiguration\n" | |
5890 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 5891 | { |
d62a17ae | 5892 | int idx_peer = 2; |
28c6e247 IR |
5893 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5894 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5895 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5896 | } |
6b0655a2 | 5897 | |
d62a17ae | 5898 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5899 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5900 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5901 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5902 | "Per neighbor soft reconfiguration\n" | |
5903 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5904 | |
28c6e247 IR |
5905 | DEFUN (neighbor_route_reflector_client, |
5906 | neighbor_route_reflector_client_cmd, | |
5907 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5908 | NEIGHBOR_STR | |
5909 | NEIGHBOR_ADDR_STR2 | |
5910 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5911 | { |
d62a17ae | 5912 | int idx_peer = 1; |
28c6e247 | 5913 | struct peer *peer; |
718e3744 | 5914 | |
5915 | ||
28c6e247 IR |
5916 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5917 | if (!peer) | |
d62a17ae | 5918 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5919 | |
28c6e247 IR |
5920 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5921 | bgp_node_safi(vty), | |
5922 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5923 | } |
5924 | ||
d62a17ae | 5925 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5926 | neighbor_route_reflector_client_hidden_cmd, | |
5927 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5928 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5929 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5930 | |
28c6e247 IR |
5931 | DEFUN (no_neighbor_route_reflector_client, |
5932 | no_neighbor_route_reflector_client_cmd, | |
5933 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5934 | NO_STR | |
5935 | NEIGHBOR_STR | |
5936 | NEIGHBOR_ADDR_STR2 | |
5937 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 5938 | { |
d62a17ae | 5939 | int idx_peer = 2; |
28c6e247 IR |
5940 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5941 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5942 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5943 | } |
6b0655a2 | 5944 | |
d62a17ae | 5945 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5946 | no_neighbor_route_reflector_client_hidden_cmd, | |
5947 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5948 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5949 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5950 | |
718e3744 | 5951 | /* neighbor route-server-client. */ |
28c6e247 IR |
5952 | DEFUN (neighbor_route_server_client, |
5953 | neighbor_route_server_client_cmd, | |
5954 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5955 | NEIGHBOR_STR | |
5956 | NEIGHBOR_ADDR_STR2 | |
5957 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 5958 | { |
d62a17ae | 5959 | int idx_peer = 1; |
28c6e247 | 5960 | struct peer *peer; |
f4b8ec07 | 5961 | |
28c6e247 IR |
5962 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5963 | if (!peer) | |
d62a17ae | 5964 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
5965 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5966 | bgp_node_safi(vty), | |
5967 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5968 | } |
5969 | ||
d62a17ae | 5970 | ALIAS_HIDDEN(neighbor_route_server_client, |
5971 | neighbor_route_server_client_hidden_cmd, | |
5972 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5973 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5974 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5975 | |
28c6e247 IR |
5976 | DEFUN (no_neighbor_route_server_client, |
5977 | no_neighbor_route_server_client_cmd, | |
5978 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5979 | NO_STR | |
5980 | NEIGHBOR_STR | |
5981 | NEIGHBOR_ADDR_STR2 | |
5982 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5983 | { |
d62a17ae | 5984 | int idx_peer = 2; |
28c6e247 IR |
5985 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5986 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5987 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5988 | } |
6b0655a2 | 5989 | |
d62a17ae | 5990 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5991 | no_neighbor_route_server_client_hidden_cmd, | |
5992 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5993 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5994 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5995 | |
fee0f4c6 | 5996 | DEFUN (neighbor_nexthop_local_unchanged, |
5997 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5998 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5999 | NEIGHBOR_STR |
6000 | NEIGHBOR_ADDR_STR2 | |
6001 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6002 | "Leave link-local nexthop unchanged for this peer\n") | |
6003 | { | |
d62a17ae | 6004 | int idx_peer = 1; |
6005 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6006 | bgp_node_safi(vty), | |
6007 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6008 | } |
6b0655a2 | 6009 | |
fee0f4c6 | 6010 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6011 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6012 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6013 | NO_STR |
6014 | NEIGHBOR_STR | |
6015 | NEIGHBOR_ADDR_STR2 | |
6016 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6017 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6018 | { |
d62a17ae | 6019 | int idx_peer = 2; |
6020 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6021 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6022 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6023 | } |
6b0655a2 | 6024 | |
28c6e247 IR |
6025 | DEFUN (neighbor_attr_unchanged, |
6026 | neighbor_attr_unchanged_cmd, | |
6027 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6028 | NEIGHBOR_STR | |
6029 | NEIGHBOR_ADDR_STR2 | |
6030 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6031 | "As-path attribute\n" | |
6032 | "Nexthop attribute\n" | |
6033 | "Med attribute\n") | |
718e3744 | 6034 | { |
d62a17ae | 6035 | int idx = 0; |
8eeb0335 | 6036 | char *peer_str = argv[1]->arg; |
28c6e247 | 6037 | struct peer *peer; |
db45f64d DS |
6038 | bool aspath = false; |
6039 | bool nexthop = false; | |
6040 | bool med = false; | |
8eeb0335 DW |
6041 | afi_t afi = bgp_node_afi(vty); |
6042 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6043 | int ret = 0; |
f4b8ec07 | 6044 | |
28c6e247 IR |
6045 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6046 | if (!peer) | |
8eeb0335 | 6047 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6048 | |
6049 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6050 | aspath = true; |
6051 | ||
d62a17ae | 6052 | idx = 0; |
6053 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6054 | nexthop = true; |
6055 | ||
d62a17ae | 6056 | idx = 0; |
6057 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6058 | med = true; |
d62a17ae | 6059 | |
8eeb0335 | 6060 | /* no flags means all of them! */ |
db45f64d | 6061 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6062 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6063 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6064 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6065 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6066 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6067 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6068 | } else { |
28c6e247 IR |
6069 | if (!aspath) { |
6070 | if (peer_af_flag_check(peer, afi, safi, | |
6071 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6072 | ret |= peer_af_flag_unset_vty( | |
6073 | vty, peer_str, afi, safi, | |
6074 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6075 | } | |
6076 | } else | |
6077 | ret |= peer_af_flag_set_vty( | |
6078 | vty, peer_str, afi, safi, | |
6079 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6080 | ||
6081 | if (!nexthop) { | |
6082 | if (peer_af_flag_check(peer, afi, safi, | |
6083 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6084 | ret |= peer_af_flag_unset_vty( | |
6085 | vty, peer_str, afi, safi, | |
6086 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6087 | } | |
6088 | } else | |
6089 | ret |= peer_af_flag_set_vty( | |
6090 | vty, peer_str, afi, safi, | |
6091 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6092 | ||
6093 | if (!med) { | |
6094 | if (peer_af_flag_check(peer, afi, safi, | |
6095 | PEER_FLAG_MED_UNCHANGED)) { | |
6096 | ret |= peer_af_flag_unset_vty( | |
6097 | vty, peer_str, afi, safi, | |
6098 | PEER_FLAG_MED_UNCHANGED); | |
6099 | } | |
6100 | } else | |
6101 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6102 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6103 | } |
6104 | ||
28c6e247 | 6105 | return ret; |
d62a17ae | 6106 | } |
6107 | ||
6108 | ALIAS_HIDDEN( | |
6109 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6110 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6111 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6112 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6113 | "As-path attribute\n" | |
6114 | "Nexthop attribute\n" | |
6115 | "Med attribute\n") | |
596c17ba | 6116 | |
28c6e247 IR |
6117 | DEFUN (no_neighbor_attr_unchanged, |
6118 | no_neighbor_attr_unchanged_cmd, | |
6119 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6120 | NO_STR | |
6121 | NEIGHBOR_STR | |
6122 | NEIGHBOR_ADDR_STR2 | |
6123 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6124 | "As-path attribute\n" | |
6125 | "Nexthop attribute\n" | |
6126 | "Med attribute\n") | |
718e3744 | 6127 | { |
d62a17ae | 6128 | int idx = 0; |
db45f64d | 6129 | char *peer_str = argv[2]->arg; |
28c6e247 | 6130 | struct peer *peer; |
db45f64d DS |
6131 | bool aspath = false; |
6132 | bool nexthop = false; | |
6133 | bool med = false; | |
6134 | afi_t afi = bgp_node_afi(vty); | |
6135 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6136 | int ret = 0; |
f4b8ec07 | 6137 | |
28c6e247 IR |
6138 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6139 | if (!peer) | |
db45f64d | 6140 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6141 | |
6142 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6143 | aspath = true; |
6144 | ||
d62a17ae | 6145 | idx = 0; |
6146 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6147 | nexthop = true; |
6148 | ||
d62a17ae | 6149 | idx = 0; |
6150 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6151 | med = true; |
d62a17ae | 6152 | |
28c6e247 IR |
6153 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6154 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6155 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6156 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6157 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6158 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6159 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6160 | |
6161 | if (aspath) | |
28c6e247 IR |
6162 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6163 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6164 | |
6165 | if (nexthop) | |
28c6e247 IR |
6166 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6167 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6168 | |
db45f64d | 6169 | if (med) |
28c6e247 IR |
6170 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6171 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6172 | |
28c6e247 | 6173 | return ret; |
d62a17ae | 6174 | } |
6175 | ||
6176 | ALIAS_HIDDEN( | |
6177 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6178 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6179 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6180 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6181 | "As-path attribute\n" | |
6182 | "Nexthop attribute\n" | |
6183 | "Med attribute\n") | |
718e3744 | 6184 | |
28c6e247 IR |
6185 | /* EBGP multihop configuration. */ |
6186 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6187 | const char *ttl_str) | |
718e3744 | 6188 | { |
28c6e247 IR |
6189 | struct peer *peer; |
6190 | unsigned int ttl; | |
718e3744 | 6191 | |
28c6e247 IR |
6192 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6193 | if (!peer) | |
d62a17ae | 6194 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6195 | |
28c6e247 IR |
6196 | if (peer->conf_if) |
6197 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6198 | ||
6199 | if (!ttl_str) | |
6200 | ttl = MAXTTL; | |
6201 | else | |
6202 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6203 | |
28c6e247 | 6204 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6205 | } |
6206 | ||
28c6e247 | 6207 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6208 | { |
28c6e247 | 6209 | struct peer *peer; |
718e3744 | 6210 | |
28c6e247 IR |
6211 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6212 | if (!peer) | |
d62a17ae | 6213 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6214 | |
28c6e247 | 6215 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6216 | } |
6217 | ||
28c6e247 IR |
6218 | /* neighbor ebgp-multihop. */ |
6219 | DEFUN (neighbor_ebgp_multihop, | |
6220 | neighbor_ebgp_multihop_cmd, | |
6221 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6222 | NEIGHBOR_STR | |
6223 | NEIGHBOR_ADDR_STR2 | |
6224 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6225 | { |
28c6e247 IR |
6226 | int idx_peer = 1; |
6227 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6228 | } | |
f4b8ec07 | 6229 | |
28c6e247 IR |
6230 | DEFUN (neighbor_ebgp_multihop_ttl, |
6231 | neighbor_ebgp_multihop_ttl_cmd, | |
6232 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6233 | NEIGHBOR_STR | |
6234 | NEIGHBOR_ADDR_STR2 | |
6235 | "Allow EBGP neighbors not on directly connected networks\n" | |
6236 | "maximum hop count\n") | |
6237 | { | |
6238 | int idx_peer = 1; | |
6239 | int idx_number = 3; | |
6240 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6241 | argv[idx_number]->arg); | |
6242 | } | |
f4b8ec07 | 6243 | |
28c6e247 IR |
6244 | DEFUN (no_neighbor_ebgp_multihop, |
6245 | no_neighbor_ebgp_multihop_cmd, | |
6246 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6247 | NO_STR | |
6248 | NEIGHBOR_STR | |
6249 | NEIGHBOR_ADDR_STR2 | |
6250 | "Allow EBGP neighbors not on directly connected networks\n" | |
6251 | "maximum hop count\n") | |
6252 | { | |
6253 | int idx_peer = 2; | |
6254 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6255 | } |
6256 | ||
6b0655a2 | 6257 | |
6ffd2079 | 6258 | /* disable-connected-check */ |
28c6e247 IR |
6259 | DEFUN (neighbor_disable_connected_check, |
6260 | neighbor_disable_connected_check_cmd, | |
6261 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6262 | NEIGHBOR_STR | |
6263 | NEIGHBOR_ADDR_STR2 | |
6264 | "one-hop away EBGP peer using loopback address\n" | |
6265 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6266 | { |
d62a17ae | 6267 | int idx_peer = 1; |
28c6e247 IR |
6268 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6269 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6270 | } |
6271 | ||
28c6e247 IR |
6272 | DEFUN (no_neighbor_disable_connected_check, |
6273 | no_neighbor_disable_connected_check_cmd, | |
6274 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6275 | NO_STR | |
6276 | NEIGHBOR_STR | |
6277 | NEIGHBOR_ADDR_STR2 | |
6278 | "one-hop away EBGP peer using loopback address\n" | |
6279 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6280 | { |
d62a17ae | 6281 | int idx_peer = 2; |
28c6e247 IR |
6282 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6283 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6284 | } |
6285 | ||
7ab294ea DA |
6286 | /* disable-link-bw-encoding-ieee */ |
6287 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6288 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6289 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6290 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6291 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6292 | { |
6293 | int idx_peer = 1; | |
6294 | ||
6295 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6296 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6297 | } | |
6298 | ||
7ab294ea DA |
6299 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6300 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6301 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6302 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6303 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6304 | { |
6305 | int idx_peer = 2; | |
6306 | ||
6307 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6308 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6309 | } | |
6310 | ||
47cbc09b PM |
6311 | |
6312 | /* enforce-first-as */ | |
28c6e247 IR |
6313 | DEFUN (neighbor_enforce_first_as, |
6314 | neighbor_enforce_first_as_cmd, | |
6315 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6316 | NEIGHBOR_STR | |
6317 | NEIGHBOR_ADDR_STR2 | |
6318 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6319 | { |
6320 | int idx_peer = 1; | |
f4b8ec07 | 6321 | |
28c6e247 IR |
6322 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6323 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6324 | } |
6325 | ||
28c6e247 IR |
6326 | DEFUN (no_neighbor_enforce_first_as, |
6327 | no_neighbor_enforce_first_as_cmd, | |
6328 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6329 | NO_STR | |
6330 | NEIGHBOR_STR | |
6331 | NEIGHBOR_ADDR_STR2 | |
6332 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6333 | { |
6334 | int idx_peer = 2; | |
f4b8ec07 | 6335 | |
28c6e247 IR |
6336 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6337 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6338 | } |
6339 | ||
6340 | ||
28c6e247 IR |
6341 | DEFUN (neighbor_description, |
6342 | neighbor_description_cmd, | |
6343 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6344 | NEIGHBOR_STR | |
6345 | NEIGHBOR_ADDR_STR2 | |
6346 | "Neighbor specific description\n" | |
6347 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6348 | { |
d62a17ae | 6349 | int idx_peer = 1; |
6350 | int idx_line = 3; | |
28c6e247 | 6351 | struct peer *peer; |
d62a17ae | 6352 | char *str; |
718e3744 | 6353 | |
28c6e247 IR |
6354 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6355 | if (!peer) | |
d62a17ae | 6356 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6357 | |
d62a17ae | 6358 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6359 | |
28c6e247 | 6360 | peer_description_set(peer, str); |
718e3744 | 6361 | |
d62a17ae | 6362 | XFREE(MTYPE_TMP, str); |
718e3744 | 6363 | |
28c6e247 | 6364 | return CMD_SUCCESS; |
718e3744 | 6365 | } |
6366 | ||
28c6e247 IR |
6367 | DEFUN (no_neighbor_description, |
6368 | no_neighbor_description_cmd, | |
6369 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6370 | NO_STR | |
6371 | NEIGHBOR_STR | |
6372 | NEIGHBOR_ADDR_STR2 | |
6373 | "Neighbor specific description\n") | |
718e3744 | 6374 | { |
d62a17ae | 6375 | int idx_peer = 2; |
28c6e247 | 6376 | struct peer *peer; |
f4b8ec07 | 6377 | |
28c6e247 IR |
6378 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6379 | if (!peer) | |
d62a17ae | 6380 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6381 | |
28c6e247 | 6382 | peer_description_unset(peer); |
718e3744 | 6383 | |
28c6e247 | 6384 | return CMD_SUCCESS; |
718e3744 | 6385 | } |
6386 | ||
1d80f243 | 6387 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6388 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6389 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6390 | "Neighbor specific description\n" | |
6391 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6392 | |
28c6e247 IR |
6393 | /* Neighbor update-source. */ |
6394 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6395 | const char *source_str) | |
6396 | { | |
6397 | struct peer *peer; | |
6398 | struct prefix p; | |
6399 | union sockunion su; | |
6400 | ||
6401 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6402 | if (!peer) | |
6403 | return CMD_WARNING_CONFIG_FAILED; | |
6404 | ||
6405 | if (peer->conf_if) | |
6406 | return CMD_WARNING; | |
6407 | ||
6408 | if (source_str) { | |
6409 | if (str2sockunion(source_str, &su) == 0) | |
6410 | peer_update_source_addr_set(peer, &su); | |
6411 | else { | |
6412 | if (str2prefix(source_str, &p)) { | |
6413 | vty_out(vty, | |
6414 | "%% Invalid update-source, remove prefix length \n"); | |
6415 | return CMD_WARNING_CONFIG_FAILED; | |
6416 | } else | |
6417 | peer_update_source_if_set(peer, source_str); | |
6418 | } | |
6419 | } else | |
6420 | peer_update_source_unset(peer); | |
6421 | ||
6422 | return CMD_SUCCESS; | |
6423 | } | |
6424 | ||
d62a17ae | 6425 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6426 | "IPv4 address\n" \ | |
6427 | "IPv6 address\n" \ | |
6428 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6429 | |
28c6e247 IR |
6430 | DEFUN (neighbor_update_source, |
6431 | neighbor_update_source_cmd, | |
6432 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6433 | NEIGHBOR_STR | |
6434 | NEIGHBOR_ADDR_STR2 | |
6435 | "Source of routing updates\n" | |
6436 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6437 | { |
d62a17ae | 6438 | int idx_peer = 1; |
6439 | int idx_peer_2 = 3; | |
28c6e247 | 6440 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6441 | argv[idx_peer_2]->arg); |
718e3744 | 6442 | } |
6443 | ||
28c6e247 IR |
6444 | DEFUN (no_neighbor_update_source, |
6445 | no_neighbor_update_source_cmd, | |
6446 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6447 | NO_STR | |
6448 | NEIGHBOR_STR | |
6449 | NEIGHBOR_ADDR_STR2 | |
6450 | "Source of routing updates\n" | |
6451 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6452 | { |
d62a17ae | 6453 | int idx_peer = 2; |
28c6e247 | 6454 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6455 | } |
6b0655a2 | 6456 | |
d62a17ae | 6457 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6458 | afi_t afi, safi_t safi, | |
6459 | const char *rmap, int set) | |
718e3744 | 6460 | { |
d62a17ae | 6461 | int ret; |
6462 | struct peer *peer; | |
80912664 | 6463 | struct route_map *route_map = NULL; |
718e3744 | 6464 | |
d62a17ae | 6465 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6466 | if (!peer) | |
6467 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6468 | |
1de27621 | 6469 | if (set) { |
80912664 DS |
6470 | if (rmap) |
6471 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6472 | ret = peer_default_originate_set(peer, afi, safi, |
6473 | rmap, route_map); | |
6474 | } else | |
d62a17ae | 6475 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6476 | |
d62a17ae | 6477 | return bgp_vty_return(vty, ret); |
718e3744 | 6478 | } |
6479 | ||
6480 | /* neighbor default-originate. */ | |
6481 | DEFUN (neighbor_default_originate, | |
6482 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6483 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6484 | NEIGHBOR_STR |
6485 | NEIGHBOR_ADDR_STR2 | |
6486 | "Originate default route to this neighbor\n") | |
6487 | { | |
d62a17ae | 6488 | int idx_peer = 1; |
6489 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6490 | bgp_node_afi(vty), | |
6491 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6492 | } |
6493 | ||
d62a17ae | 6494 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6495 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6496 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6497 | "Originate default route to this neighbor\n") | |
596c17ba | 6498 | |
718e3744 | 6499 | DEFUN (neighbor_default_originate_rmap, |
6500 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 6501 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 6502 | NEIGHBOR_STR |
6503 | NEIGHBOR_ADDR_STR2 | |
6504 | "Originate default route to this neighbor\n" | |
6505 | "Route-map to specify criteria to originate default\n" | |
6506 | "route-map name\n") | |
6507 | { | |
d62a17ae | 6508 | int idx_peer = 1; |
6509 | int idx_word = 4; | |
6510 | return peer_default_originate_set_vty( | |
6511 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6512 | argv[idx_word]->arg, 1); | |
718e3744 | 6513 | } |
6514 | ||
d62a17ae | 6515 | ALIAS_HIDDEN( |
6516 | neighbor_default_originate_rmap, | |
6517 | neighbor_default_originate_rmap_hidden_cmd, | |
6518 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6519 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6520 | "Originate default route to this neighbor\n" | |
6521 | "Route-map to specify criteria to originate default\n" | |
6522 | "route-map name\n") | |
596c17ba | 6523 | |
718e3744 | 6524 | DEFUN (no_neighbor_default_originate, |
6525 | no_neighbor_default_originate_cmd, | |
a636c635 | 6526 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 6527 | NO_STR |
6528 | NEIGHBOR_STR | |
6529 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6530 | "Originate default route to this neighbor\n" |
6531 | "Route-map to specify criteria to originate default\n" | |
6532 | "route-map name\n") | |
718e3744 | 6533 | { |
d62a17ae | 6534 | int idx_peer = 2; |
6535 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6536 | bgp_node_afi(vty), | |
6537 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6538 | } |
6539 | ||
d62a17ae | 6540 | ALIAS_HIDDEN( |
6541 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
6542 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6543 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6544 | "Originate default route to this neighbor\n" | |
6545 | "Route-map to specify criteria to originate default\n" | |
6546 | "route-map name\n") | |
596c17ba | 6547 | |
6b0655a2 | 6548 | |
28c6e247 IR |
6549 | /* Set neighbor's BGP port. */ |
6550 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6551 | const char *port_str) | |
718e3744 | 6552 | { |
28c6e247 IR |
6553 | struct peer *peer; |
6554 | uint16_t port; | |
6555 | struct servent *sp; | |
6556 | ||
6557 | peer = peer_lookup_vty(vty, ip_str); | |
6558 | if (!peer) | |
6559 | return CMD_WARNING_CONFIG_FAILED; | |
6560 | ||
6561 | if (!port_str) { | |
6562 | sp = getservbyname("bgp", "tcp"); | |
6563 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6564 | } else { | |
6565 | port = strtoul(port_str, NULL, 10); | |
6566 | } | |
718e3744 | 6567 | |
28c6e247 | 6568 | peer_port_set(peer, port); |
718e3744 | 6569 | |
28c6e247 IR |
6570 | return CMD_SUCCESS; |
6571 | } | |
f4b8ec07 | 6572 | |
28c6e247 IR |
6573 | /* Set specified peer's BGP port. */ |
6574 | DEFUN (neighbor_port, | |
6575 | neighbor_port_cmd, | |
6576 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
6577 | NEIGHBOR_STR | |
6578 | NEIGHBOR_ADDR_STR | |
6579 | "Neighbor's BGP port\n" | |
6580 | "TCP port number\n") | |
6581 | { | |
6582 | int idx_ip = 1; | |
6583 | int idx_number = 3; | |
6584 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6585 | argv[idx_number]->arg); | |
f4b8ec07 | 6586 | } |
6b0655a2 | 6587 | |
28c6e247 IR |
6588 | DEFUN (no_neighbor_port, |
6589 | no_neighbor_port_cmd, | |
6590 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
6591 | NO_STR | |
6592 | NEIGHBOR_STR | |
6593 | NEIGHBOR_ADDR_STR | |
6594 | "Neighbor's BGP port\n" | |
6595 | "TCP port number\n") | |
718e3744 | 6596 | { |
f4b8ec07 | 6597 | int idx_ip = 2; |
28c6e247 IR |
6598 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
6599 | } | |
6600 | ||
6601 | ||
6602 | /* neighbor weight. */ | |
6603 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
6604 | safi_t safi, const char *weight_str) | |
6605 | { | |
6606 | int ret; | |
6607 | struct peer *peer; | |
6608 | unsigned long weight; | |
718e3744 | 6609 | |
28c6e247 IR |
6610 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6611 | if (!peer) | |
6612 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6613 | |
28c6e247 | 6614 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 6615 | |
28c6e247 IR |
6616 | ret = peer_weight_set(peer, afi, safi, weight); |
6617 | return bgp_vty_return(vty, ret); | |
718e3744 | 6618 | } |
6619 | ||
28c6e247 IR |
6620 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6621 | safi_t safi) | |
718e3744 | 6622 | { |
28c6e247 IR |
6623 | int ret; |
6624 | struct peer *peer; | |
f4b8ec07 | 6625 | |
28c6e247 IR |
6626 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6627 | if (!peer) | |
d62a17ae | 6628 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6629 | |
28c6e247 IR |
6630 | ret = peer_weight_unset(peer, afi, safi); |
6631 | return bgp_vty_return(vty, ret); | |
6632 | } | |
f4b8ec07 | 6633 | |
28c6e247 IR |
6634 | DEFUN (neighbor_weight, |
6635 | neighbor_weight_cmd, | |
6636 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6637 | NEIGHBOR_STR | |
6638 | NEIGHBOR_ADDR_STR2 | |
6639 | "Set default weight for routes from this neighbor\n" | |
6640 | "default weight\n") | |
6641 | { | |
6642 | int idx_peer = 1; | |
6643 | int idx_number = 3; | |
6644 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6645 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 6646 | } |
6647 | ||
d62a17ae | 6648 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
6649 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6650 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6651 | "Set default weight for routes from this neighbor\n" | |
6652 | "default weight\n") | |
596c17ba | 6653 | |
28c6e247 IR |
6654 | DEFUN (no_neighbor_weight, |
6655 | no_neighbor_weight_cmd, | |
6656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6657 | NO_STR | |
6658 | NEIGHBOR_STR | |
6659 | NEIGHBOR_ADDR_STR2 | |
6660 | "Set default weight for routes from this neighbor\n" | |
6661 | "default weight\n") | |
718e3744 | 6662 | { |
d62a17ae | 6663 | int idx_peer = 2; |
28c6e247 IR |
6664 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
6665 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 6666 | } |
6667 | ||
d62a17ae | 6668 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
6669 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6670 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6671 | "Set default weight for routes from this neighbor\n" | |
6672 | "default weight\n") | |
596c17ba | 6673 | |
6b0655a2 | 6674 | |
718e3744 | 6675 | /* Override capability negotiation. */ |
c36bc05f IR |
6676 | DEFUN (neighbor_override_capability, |
6677 | neighbor_override_capability_cmd, | |
6678 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6679 | NEIGHBOR_STR | |
6680 | NEIGHBOR_ADDR_STR2 | |
6681 | "Override capability negotiation result\n") | |
718e3744 | 6682 | { |
d62a17ae | 6683 | int idx_peer = 1; |
c36bc05f IR |
6684 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6685 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6686 | } |
6687 | ||
c36bc05f IR |
6688 | DEFUN (no_neighbor_override_capability, |
6689 | no_neighbor_override_capability_cmd, | |
6690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6691 | NO_STR | |
6692 | NEIGHBOR_STR | |
6693 | NEIGHBOR_ADDR_STR2 | |
6694 | "Override capability negotiation result\n") | |
718e3744 | 6695 | { |
d62a17ae | 6696 | int idx_peer = 2; |
c36bc05f IR |
6697 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6698 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6699 | } |
6b0655a2 | 6700 | |
c36bc05f IR |
6701 | DEFUN (neighbor_strict_capability, |
6702 | neighbor_strict_capability_cmd, | |
6703 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6704 | NEIGHBOR_STR | |
6705 | NEIGHBOR_ADDR_STR2 | |
6706 | "Strict capability negotiation match\n") | |
718e3744 | 6707 | { |
9fb964de PM |
6708 | int idx_peer = 1; |
6709 | ||
c36bc05f IR |
6710 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6711 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6712 | } |
6713 | ||
c36bc05f IR |
6714 | DEFUN (no_neighbor_strict_capability, |
6715 | no_neighbor_strict_capability_cmd, | |
6716 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6717 | NO_STR | |
6718 | NEIGHBOR_STR | |
6719 | NEIGHBOR_ADDR_STR2 | |
6720 | "Strict capability negotiation match\n") | |
718e3744 | 6721 | { |
9fb964de | 6722 | int idx_peer = 2; |
8611c7f3 | 6723 | |
c36bc05f IR |
6724 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6725 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6726 | } |
6b0655a2 | 6727 | |
28c6e247 IR |
6728 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6729 | const char *keep_str, const char *hold_str) | |
718e3744 | 6730 | { |
28c6e247 IR |
6731 | int ret; |
6732 | struct peer *peer; | |
6733 | uint32_t keepalive; | |
6734 | uint32_t holdtime; | |
718e3744 | 6735 | |
28c6e247 IR |
6736 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6737 | if (!peer) | |
d62a17ae | 6738 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6739 | |
28c6e247 IR |
6740 | keepalive = strtoul(keep_str, NULL, 10); |
6741 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6742 | |
28c6e247 | 6743 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6744 | |
28c6e247 | 6745 | return bgp_vty_return(vty, ret); |
718e3744 | 6746 | } |
6b0655a2 | 6747 | |
28c6e247 | 6748 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6749 | { |
28c6e247 IR |
6750 | int ret; |
6751 | struct peer *peer; | |
718e3744 | 6752 | |
28c6e247 IR |
6753 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6754 | if (!peer) | |
d62a17ae | 6755 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6756 | |
28c6e247 | 6757 | ret = peer_timers_unset(peer); |
718e3744 | 6758 | |
28c6e247 | 6759 | return bgp_vty_return(vty, ret); |
718e3744 | 6760 | } |
6b0655a2 | 6761 | |
28c6e247 IR |
6762 | DEFUN (neighbor_timers, |
6763 | neighbor_timers_cmd, | |
6764 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
6765 | NEIGHBOR_STR | |
6766 | NEIGHBOR_ADDR_STR2 | |
6767 | "BGP per neighbor timers\n" | |
6768 | "Keepalive interval\n" | |
6769 | "Holdtime\n") | |
718e3744 | 6770 | { |
f4b8ec07 | 6771 | int idx_peer = 1; |
28c6e247 IR |
6772 | int idx_number = 3; |
6773 | int idx_number_2 = 4; | |
6774 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6775 | argv[idx_number]->arg, | |
6776 | argv[idx_number_2]->arg); | |
6777 | } | |
6778 | ||
6779 | DEFUN (no_neighbor_timers, | |
6780 | no_neighbor_timers_cmd, | |
6781 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
6782 | NO_STR | |
6783 | NEIGHBOR_STR | |
6784 | NEIGHBOR_ADDR_STR2 | |
6785 | "BGP per neighbor timers\n" | |
6786 | "Keepalive interval\n" | |
6787 | "Holdtime\n") | |
6788 | { | |
6789 | int idx_peer = 2; | |
6790 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
6791 | } | |
6792 | ||
6793 | ||
6794 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
6795 | const char *time_str) | |
6796 | { | |
6797 | int ret; | |
6798 | struct peer *peer; | |
6799 | uint32_t connect; | |
718e3744 | 6800 | |
28c6e247 IR |
6801 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6802 | if (!peer) | |
d62a17ae | 6803 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6804 | |
28c6e247 IR |
6805 | connect = strtoul(time_str, NULL, 10); |
6806 | ||
6807 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 6808 | |
28c6e247 | 6809 | return bgp_vty_return(vty, ret); |
718e3744 | 6810 | } |
6811 | ||
28c6e247 | 6812 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6813 | { |
28c6e247 IR |
6814 | int ret; |
6815 | struct peer *peer; | |
718e3744 | 6816 | |
28c6e247 IR |
6817 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6818 | if (!peer) | |
d62a17ae | 6819 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6820 | |
28c6e247 IR |
6821 | ret = peer_timers_connect_unset(peer); |
6822 | ||
6823 | return bgp_vty_return(vty, ret); | |
6824 | } | |
6825 | ||
6826 | DEFUN (neighbor_timers_connect, | |
6827 | neighbor_timers_connect_cmd, | |
6828 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
6829 | NEIGHBOR_STR | |
6830 | NEIGHBOR_ADDR_STR2 | |
6831 | "BGP per neighbor timers\n" | |
6832 | "BGP connect timer\n" | |
6833 | "Connect timer\n") | |
6834 | { | |
6835 | int idx_peer = 1; | |
6836 | int idx_number = 4; | |
6837 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6838 | argv[idx_number]->arg); | |
6839 | } | |
718e3744 | 6840 | |
28c6e247 IR |
6841 | DEFUN (no_neighbor_timers_connect, |
6842 | no_neighbor_timers_connect_cmd, | |
6843 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
6844 | NO_STR | |
6845 | NEIGHBOR_STR | |
6846 | NEIGHBOR_ADDR_STR2 | |
6847 | "BGP per neighbor timers\n" | |
6848 | "BGP connect timer\n" | |
6849 | "Connect timer\n") | |
6850 | { | |
6851 | int idx_peer = 2; | |
6852 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6853 | } |
6854 | ||
d43114f3 DS |
6855 | DEFPY (neighbor_timers_delayopen, |
6856 | neighbor_timers_delayopen_cmd, | |
6857 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
6858 | NEIGHBOR_STR | |
6859 | NEIGHBOR_ADDR_STR2 | |
6860 | "BGP per neighbor timers\n" | |
6861 | "RFC 4271 DelayOpenTimer\n" | |
6862 | "DelayOpenTime timer interval\n") | |
6863 | { | |
6864 | struct peer *peer; | |
6865 | ||
6866 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6867 | if (!peer) | |
6868 | return CMD_WARNING_CONFIG_FAILED; | |
6869 | ||
6870 | if (!interval) { | |
6871 | if (peer_timers_delayopen_unset(peer)) | |
6872 | return CMD_WARNING_CONFIG_FAILED; | |
6873 | } else { | |
6874 | if (peer_timers_delayopen_set(peer, interval)) | |
6875 | return CMD_WARNING_CONFIG_FAILED; | |
6876 | } | |
6877 | ||
6878 | return CMD_SUCCESS; | |
6879 | } | |
6880 | ||
6881 | DEFPY (no_neighbor_timers_delayopen, | |
6882 | no_neighbor_timers_delayopen_cmd, | |
6883 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
6884 | NO_STR | |
6885 | NEIGHBOR_STR | |
6886 | NEIGHBOR_ADDR_STR2 | |
6887 | "BGP per neighbor timers\n" | |
6888 | "RFC 4271 DelayOpenTimer\n" | |
6889 | "DelayOpenTime timer interval\n") | |
6890 | { | |
6891 | struct peer *peer; | |
6892 | ||
6893 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6894 | if (!peer) | |
6895 | return CMD_WARNING_CONFIG_FAILED; | |
6896 | ||
6897 | if (peer_timers_delayopen_unset(peer)) | |
6898 | return CMD_WARNING_CONFIG_FAILED; | |
6899 | ||
6900 | return CMD_SUCCESS; | |
6901 | } | |
6902 | ||
28c6e247 IR |
6903 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6904 | const char *time_str, int set) | |
718e3744 | 6905 | { |
28c6e247 IR |
6906 | int ret; |
6907 | struct peer *peer; | |
6908 | uint32_t routeadv = 0; | |
718e3744 | 6909 | |
28c6e247 IR |
6910 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6911 | if (!peer) | |
d62a17ae | 6912 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6913 | |
28c6e247 IR |
6914 | if (time_str) |
6915 | routeadv = strtoul(time_str, NULL, 10); | |
6916 | ||
6917 | if (set) | |
6918 | ret = peer_advertise_interval_set(peer, routeadv); | |
6919 | else | |
6920 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6921 | |
28c6e247 | 6922 | return bgp_vty_return(vty, ret); |
718e3744 | 6923 | } |
6924 | ||
28c6e247 IR |
6925 | DEFUN (neighbor_advertise_interval, |
6926 | neighbor_advertise_interval_cmd, | |
6927 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
6928 | NEIGHBOR_STR | |
6929 | NEIGHBOR_ADDR_STR2 | |
6930 | "Minimum interval between sending BGP routing updates\n" | |
6931 | "time in seconds\n") | |
718e3744 | 6932 | { |
28c6e247 IR |
6933 | int idx_peer = 1; |
6934 | int idx_number = 3; | |
6935 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6936 | argv[idx_number]->arg, 1); | |
6937 | } | |
f4b8ec07 | 6938 | |
28c6e247 IR |
6939 | DEFUN (no_neighbor_advertise_interval, |
6940 | no_neighbor_advertise_interval_cmd, | |
6941 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
6942 | NO_STR | |
6943 | NEIGHBOR_STR | |
6944 | NEIGHBOR_ADDR_STR2 | |
6945 | "Minimum interval between sending BGP routing updates\n" | |
6946 | "time in seconds\n") | |
6947 | { | |
6948 | int idx_peer = 2; | |
6949 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6950 | } |
6951 | ||
6b0655a2 | 6952 | |
518f0eb1 DS |
6953 | /* Time to wait before processing route-map updates */ |
6954 | DEFUN (bgp_set_route_map_delay_timer, | |
6955 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6956 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6957 | SET_STR |
6958 | "BGP route-map delay timer\n" | |
6959 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6960 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6961 | { |
d62a17ae | 6962 | int idx_number = 3; |
d7c0a89a | 6963 | uint32_t rmap_delay_timer; |
d62a17ae | 6964 | |
6965 | if (argv[idx_number]->arg) { | |
6966 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6967 | bm->rmap_update_timer = rmap_delay_timer; | |
6968 | ||
6969 | /* if the dynamic update handling is being disabled, and a timer | |
6970 | * is | |
6971 | * running, stop the timer and act as if the timer has already | |
6972 | * fired. | |
6973 | */ | |
6974 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6975 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6976 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6977 | NULL, 0); | |
6978 | } | |
6979 | return CMD_SUCCESS; | |
6980 | } else { | |
6981 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6982 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6983 | } |
518f0eb1 DS |
6984 | } |
6985 | ||
6986 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6987 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6988 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6989 | NO_STR |
3a2d747c | 6990 | BGP_STR |
518f0eb1 | 6991 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6992 | "Reset to default time to wait for processing route-map changes\n" |
6993 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6994 | { |
518f0eb1 | 6995 | |
d62a17ae | 6996 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6997 | |
d62a17ae | 6998 | return CMD_SUCCESS; |
518f0eb1 DS |
6999 | } |
7000 | ||
28c6e247 IR |
7001 | /* neighbor interface */ |
7002 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7003 | const char *str) | |
718e3744 | 7004 | { |
28c6e247 | 7005 | struct peer *peer; |
718e3744 | 7006 | |
28c6e247 IR |
7007 | peer = peer_lookup_vty(vty, ip_str); |
7008 | if (!peer || peer->conf_if) { | |
7009 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7010 | return CMD_WARNING_CONFIG_FAILED; | |
7011 | } | |
718e3744 | 7012 | |
28c6e247 IR |
7013 | if (str) |
7014 | peer_interface_set(peer, str); | |
7015 | else | |
7016 | peer_interface_unset(peer); | |
718e3744 | 7017 | |
28c6e247 | 7018 | return CMD_SUCCESS; |
718e3744 | 7019 | } |
7020 | ||
28c6e247 IR |
7021 | DEFUN (neighbor_interface, |
7022 | neighbor_interface_cmd, | |
7023 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7024 | NEIGHBOR_STR | |
7025 | NEIGHBOR_ADDR_STR | |
7026 | "Interface\n" | |
7027 | "Interface name\n") | |
718e3744 | 7028 | { |
28c6e247 IR |
7029 | int idx_ip = 1; |
7030 | int idx_word = 3; | |
294d8425 | 7031 | |
28c6e247 IR |
7032 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7033 | } | |
f4b8ec07 | 7034 | |
28c6e247 IR |
7035 | DEFUN (no_neighbor_interface, |
7036 | no_neighbor_interface_cmd, | |
294d8425 | 7037 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7038 | NO_STR |
7039 | NEIGHBOR_STR | |
294d8425 | 7040 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7041 | "Interface\n" |
7042 | "Interface name\n") | |
7043 | { | |
7044 | int idx_peer = 2; | |
294d8425 | 7045 | |
28c6e247 | 7046 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7047 | } |
6b0655a2 | 7048 | |
718e3744 | 7049 | DEFUN (neighbor_distribute_list, |
7050 | neighbor_distribute_list_cmd, | |
c60dec36 | 7051 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7052 | NEIGHBOR_STR |
7053 | NEIGHBOR_ADDR_STR2 | |
7054 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7055 | "IP Access-list name\n" |
7056 | "Filter incoming updates\n" | |
7057 | "Filter outgoing updates\n") | |
7058 | { | |
d62a17ae | 7059 | int idx_peer = 1; |
7060 | int idx_acl = 3; | |
7061 | int direct, ret; | |
7062 | struct peer *peer; | |
a8206004 | 7063 | |
d62a17ae | 7064 | const char *pstr = argv[idx_peer]->arg; |
7065 | const char *acl = argv[idx_acl]->arg; | |
7066 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7067 | |
d62a17ae | 7068 | peer = peer_and_group_lookup_vty(vty, pstr); |
7069 | if (!peer) | |
7070 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7071 | |
d62a17ae | 7072 | /* Check filter direction. */ |
7073 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7074 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7075 | direct, acl); | |
a8206004 | 7076 | |
d62a17ae | 7077 | return bgp_vty_return(vty, ret); |
718e3744 | 7078 | } |
7079 | ||
d62a17ae | 7080 | ALIAS_HIDDEN( |
7081 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7082 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7083 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7084 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7085 | "IP Access-list name\n" |
7086 | "Filter incoming updates\n" | |
7087 | "Filter outgoing updates\n") | |
596c17ba | 7088 | |
718e3744 | 7089 | DEFUN (no_neighbor_distribute_list, |
7090 | no_neighbor_distribute_list_cmd, | |
c60dec36 | 7091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7092 | NO_STR |
7093 | NEIGHBOR_STR | |
7094 | NEIGHBOR_ADDR_STR2 | |
7095 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7096 | "IP Access-list name\n" |
7097 | "Filter incoming updates\n" | |
7098 | "Filter outgoing updates\n") | |
7099 | { | |
d62a17ae | 7100 | int idx_peer = 2; |
7101 | int direct, ret; | |
7102 | struct peer *peer; | |
a8206004 | 7103 | |
d62a17ae | 7104 | const char *pstr = argv[idx_peer]->arg; |
7105 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7106 | |
d62a17ae | 7107 | peer = peer_and_group_lookup_vty(vty, pstr); |
7108 | if (!peer) | |
7109 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7110 | |
d62a17ae | 7111 | /* Check filter direction. */ |
7112 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7113 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7114 | direct); | |
a8206004 | 7115 | |
d62a17ae | 7116 | return bgp_vty_return(vty, ret); |
718e3744 | 7117 | } |
6b0655a2 | 7118 | |
d62a17ae | 7119 | ALIAS_HIDDEN( |
7120 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7121 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7122 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7123 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7124 | "IP Access-list name\n" |
7125 | "Filter incoming updates\n" | |
7126 | "Filter outgoing updates\n") | |
596c17ba | 7127 | |
718e3744 | 7128 | /* Set prefix list to the peer. */ |
642ef664 IR |
7129 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7130 | afi_t afi, safi_t safi, | |
7131 | const char *name_str, | |
7132 | const char *direct_str) | |
718e3744 | 7133 | { |
642ef664 IR |
7134 | int ret; |
7135 | int direct = FILTER_IN; | |
7136 | struct peer *peer; | |
718e3744 | 7137 | |
642ef664 IR |
7138 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7139 | if (!peer) | |
d62a17ae | 7140 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7141 | |
642ef664 IR |
7142 | /* Check filter direction. */ |
7143 | if (strncmp(direct_str, "i", 1) == 0) | |
7144 | direct = FILTER_IN; | |
7145 | else if (strncmp(direct_str, "o", 1) == 0) | |
7146 | direct = FILTER_OUT; | |
718e3744 | 7147 | |
642ef664 | 7148 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7149 | |
642ef664 IR |
7150 | return bgp_vty_return(vty, ret); |
7151 | } | |
7152 | ||
7153 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7154 | afi_t afi, safi_t safi, | |
7155 | const char *direct_str) | |
7156 | { | |
7157 | int ret; | |
7158 | struct peer *peer; | |
7159 | int direct = FILTER_IN; | |
7160 | ||
7161 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7162 | if (!peer) | |
7163 | return CMD_WARNING_CONFIG_FAILED; | |
7164 | ||
7165 | /* Check filter direction. */ | |
7166 | if (strncmp(direct_str, "i", 1) == 0) | |
7167 | direct = FILTER_IN; | |
7168 | else if (strncmp(direct_str, "o", 1) == 0) | |
7169 | direct = FILTER_OUT; | |
7170 | ||
7171 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7172 | ||
7173 | return bgp_vty_return(vty, ret); | |
7174 | } | |
7175 | ||
7176 | DEFUN (neighbor_prefix_list, | |
7177 | neighbor_prefix_list_cmd, | |
7178 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7179 | NEIGHBOR_STR | |
7180 | NEIGHBOR_ADDR_STR2 | |
7181 | "Filter updates to/from this neighbor\n" | |
7182 | "Name of a prefix list\n" | |
7183 | "Filter incoming updates\n" | |
7184 | "Filter outgoing updates\n") | |
7185 | { | |
7186 | int idx_peer = 1; | |
7187 | int idx_word = 3; | |
7188 | int idx_in_out = 4; | |
7189 | return peer_prefix_list_set_vty( | |
7190 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7191 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7192 | } |
7193 | ||
d62a17ae | 7194 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7195 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7196 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7197 | "Filter updates to/from this neighbor\n" | |
7198 | "Name of a prefix list\n" | |
7199 | "Filter incoming updates\n" | |
7200 | "Filter outgoing updates\n") | |
596c17ba | 7201 | |
642ef664 IR |
7202 | DEFUN (no_neighbor_prefix_list, |
7203 | no_neighbor_prefix_list_cmd, | |
7204 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7205 | NO_STR | |
7206 | NEIGHBOR_STR | |
7207 | NEIGHBOR_ADDR_STR2 | |
7208 | "Filter updates to/from this neighbor\n" | |
7209 | "Name of a prefix list\n" | |
7210 | "Filter incoming updates\n" | |
7211 | "Filter outgoing updates\n") | |
7212 | { | |
7213 | int idx_peer = 2; | |
7214 | int idx_in_out = 5; | |
7215 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7216 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7217 | argv[idx_in_out]->arg); | |
7218 | } | |
7219 | ||
7220 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7221 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7222 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7223 | "Filter updates to/from this neighbor\n" | |
7224 | "Name of a prefix list\n" | |
7225 | "Filter incoming updates\n" | |
7226 | "Filter outgoing updates\n") | |
7227 | ||
d62a17ae | 7228 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7229 | safi_t safi, const char *name_str, | |
7230 | const char *direct_str) | |
718e3744 | 7231 | { |
d62a17ae | 7232 | int ret; |
7233 | struct peer *peer; | |
7234 | int direct = FILTER_IN; | |
718e3744 | 7235 | |
d62a17ae | 7236 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7237 | if (!peer) | |
7238 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7239 | |
d62a17ae | 7240 | /* Check filter direction. */ |
7241 | if (strncmp(direct_str, "i", 1) == 0) | |
7242 | direct = FILTER_IN; | |
7243 | else if (strncmp(direct_str, "o", 1) == 0) | |
7244 | direct = FILTER_OUT; | |
718e3744 | 7245 | |
d62a17ae | 7246 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7247 | |
d62a17ae | 7248 | return bgp_vty_return(vty, ret); |
718e3744 | 7249 | } |
7250 | ||
d62a17ae | 7251 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7252 | safi_t safi, const char *direct_str) | |
718e3744 | 7253 | { |
d62a17ae | 7254 | int ret; |
7255 | struct peer *peer; | |
7256 | int direct = FILTER_IN; | |
718e3744 | 7257 | |
d62a17ae | 7258 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7259 | if (!peer) | |
7260 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7261 | |
d62a17ae | 7262 | /* Check filter direction. */ |
7263 | if (strncmp(direct_str, "i", 1) == 0) | |
7264 | direct = FILTER_IN; | |
7265 | else if (strncmp(direct_str, "o", 1) == 0) | |
7266 | direct = FILTER_OUT; | |
718e3744 | 7267 | |
d62a17ae | 7268 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7269 | |
d62a17ae | 7270 | return bgp_vty_return(vty, ret); |
718e3744 | 7271 | } |
7272 | ||
7273 | DEFUN (neighbor_filter_list, | |
7274 | neighbor_filter_list_cmd, | |
de71d43e | 7275 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7276 | NEIGHBOR_STR |
7277 | NEIGHBOR_ADDR_STR2 | |
7278 | "Establish BGP filters\n" | |
7279 | "AS path access-list name\n" | |
7280 | "Filter incoming routes\n" | |
7281 | "Filter outgoing routes\n") | |
7282 | { | |
d62a17ae | 7283 | int idx_peer = 1; |
7284 | int idx_word = 3; | |
7285 | int idx_in_out = 4; | |
7286 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7287 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7288 | argv[idx_in_out]->arg); | |
718e3744 | 7289 | } |
7290 | ||
d62a17ae | 7291 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
de71d43e | 7292 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7293 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7294 | "Establish BGP filters\n" | |
7295 | "AS path access-list name\n" | |
7296 | "Filter incoming routes\n" | |
7297 | "Filter outgoing routes\n") | |
596c17ba | 7298 | |
718e3744 | 7299 | DEFUN (no_neighbor_filter_list, |
7300 | no_neighbor_filter_list_cmd, | |
de71d43e | 7301 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7302 | NO_STR |
7303 | NEIGHBOR_STR | |
7304 | NEIGHBOR_ADDR_STR2 | |
7305 | "Establish BGP filters\n" | |
7306 | "AS path access-list name\n" | |
7307 | "Filter incoming routes\n" | |
7308 | "Filter outgoing routes\n") | |
7309 | { | |
d62a17ae | 7310 | int idx_peer = 2; |
7311 | int idx_in_out = 5; | |
7312 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7313 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7314 | argv[idx_in_out]->arg); | |
718e3744 | 7315 | } |
6b0655a2 | 7316 | |
d62a17ae | 7317 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
de71d43e | 7318 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7319 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7320 | "Establish BGP filters\n" | |
7321 | "AS path access-list name\n" | |
7322 | "Filter incoming routes\n" | |
7323 | "Filter outgoing routes\n") | |
596c17ba | 7324 | |
7f7940e6 MK |
7325 | /* Set advertise-map to the peer. */ |
7326 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7327 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7328 | const char *advertise_str, |
7329 | const char *condition_str, bool condition, | |
7330 | bool set) | |
7f7940e6 MK |
7331 | { |
7332 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7333 | struct peer *peer; | |
7334 | struct route_map *advertise_map; | |
7335 | struct route_map *condition_map; | |
7336 | ||
7337 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7338 | if (!peer) | |
7339 | return ret; | |
7340 | ||
7341 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7342 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7343 | ||
cf2ad4d8 MK |
7344 | if (set) |
7345 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7346 | advertise_map, condition_str, | |
7347 | condition_map, condition); | |
7348 | else | |
7349 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7350 | advertise_map, condition_str, | |
7351 | condition_map, condition); | |
7f7940e6 MK |
7352 | |
7353 | return bgp_vty_return(vty, ret); | |
7354 | } | |
7355 | ||
389e4f92 QY |
7356 | DEFPY (bgp_condadv_period, |
7357 | bgp_condadv_period_cmd, | |
7358 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7359 | NO_STR | |
7360 | BGP_STR | |
7361 | "Conditional advertisement settings\n" | |
7362 | "Set period to rescan BGP table to check if condition is met\n" | |
7363 | "Period between BGP table scans, in seconds; default 60\n") | |
7364 | { | |
7365 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7366 | ||
7367 | bgp->condition_check_period = | |
7368 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7369 | ||
7370 | return CMD_SUCCESS; | |
7371 | } | |
7372 | ||
cf2ad4d8 | 7373 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7374 | neighbor_advertise_map_cmd, |
52b84062 | 7375 | "[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 | 7376 | NO_STR |
7f7940e6 MK |
7377 | NEIGHBOR_STR |
7378 | NEIGHBOR_ADDR_STR2 | |
7379 | "Route-map to conditionally advertise routes\n" | |
7380 | "Name of advertise map\n" | |
7381 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7382 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7383 | "Name of the exist or non exist map\n") |
7f7940e6 | 7384 | { |
7f7940e6 MK |
7385 | bool condition = CONDITION_EXIST; |
7386 | ||
52b84062 | 7387 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7388 | condition = CONDITION_NON_EXIST; |
7389 | ||
52b84062 MK |
7390 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7391 | bgp_node_safi(vty), advertise_str, | |
7392 | condition_str, condition, !no); | |
7f7940e6 MK |
7393 | } |
7394 | ||
7395 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
52b84062 | 7396 | "[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 |
7397 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7398 | "Route-map to conditionally advertise routes\n" | |
7399 | "Name of advertise map\n" | |
7400 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7401 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7402 | "Name of the exist or non exist map\n") |
7f7940e6 | 7403 | |
718e3744 | 7404 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7405 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7406 | afi_t afi, safi_t safi, const char *name_str, | |
7407 | const char *direct_str) | |
718e3744 | 7408 | { |
0ea8d871 IR |
7409 | int ret; |
7410 | struct peer *peer; | |
7411 | int direct = RMAP_IN; | |
7412 | struct route_map *route_map; | |
718e3744 | 7413 | |
0ea8d871 IR |
7414 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7415 | if (!peer) | |
d62a17ae | 7416 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7417 | |
0ea8d871 IR |
7418 | /* Check filter direction. */ |
7419 | if (strncmp(direct_str, "in", 2) == 0) | |
7420 | direct = RMAP_IN; | |
7421 | else if (strncmp(direct_str, "o", 1) == 0) | |
7422 | direct = RMAP_OUT; | |
718e3744 | 7423 | |
0ea8d871 IR |
7424 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7425 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7426 | |
0ea8d871 IR |
7427 | return bgp_vty_return(vty, ret); |
7428 | } | |
7429 | ||
7430 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7431 | afi_t afi, safi_t safi, | |
7432 | const char *direct_str) | |
7433 | { | |
7434 | int ret; | |
7435 | struct peer *peer; | |
7436 | int direct = RMAP_IN; | |
7437 | ||
7438 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7439 | if (!peer) | |
7440 | return CMD_WARNING_CONFIG_FAILED; | |
7441 | ||
7442 | /* Check filter direction. */ | |
7443 | if (strncmp(direct_str, "in", 2) == 0) | |
7444 | direct = RMAP_IN; | |
7445 | else if (strncmp(direct_str, "o", 1) == 0) | |
7446 | direct = RMAP_OUT; | |
7447 | ||
7448 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7449 | ||
7450 | return bgp_vty_return(vty, ret); | |
7451 | } | |
7452 | ||
7453 | DEFUN (neighbor_route_map, | |
7454 | neighbor_route_map_cmd, | |
7455 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7456 | NEIGHBOR_STR | |
7457 | NEIGHBOR_ADDR_STR2 | |
7458 | "Apply route map to neighbor\n" | |
7459 | "Name of route map\n" | |
7460 | "Apply map to incoming routes\n" | |
7461 | "Apply map to outbound routes\n") | |
7462 | { | |
7463 | int idx_peer = 1; | |
7464 | int idx_word = 3; | |
7465 | int idx_in_out = 4; | |
7466 | return peer_route_map_set_vty( | |
7467 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7468 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7469 | } |
7470 | ||
d6d7ed37 IR |
7471 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7472 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7473 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7474 | "Apply route map to neighbor\n" | |
7475 | "Name of route map\n" | |
7476 | "Apply map to incoming routes\n" | |
7477 | "Apply map to outbound routes\n") | |
7478 | ||
0ea8d871 IR |
7479 | DEFUN (no_neighbor_route_map, |
7480 | no_neighbor_route_map_cmd, | |
7481 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7482 | NO_STR | |
7483 | NEIGHBOR_STR | |
7484 | NEIGHBOR_ADDR_STR2 | |
7485 | "Apply route map to neighbor\n" | |
7486 | "Name of route map\n" | |
7487 | "Apply map to incoming routes\n" | |
7488 | "Apply map to outbound routes\n") | |
7489 | { | |
7490 | int idx_peer = 2; | |
7491 | int idx_in_out = 5; | |
7492 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7493 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7494 | argv[idx_in_out]->arg); | |
7495 | } | |
7496 | ||
7497 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
d6d7ed37 IR |
7498 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
7499 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7500 | "Apply route map to neighbor\n" | |
7501 | "Name of route map\n" | |
7502 | "Apply map to incoming routes\n" | |
7503 | "Apply map to outbound routes\n") | |
7504 | ||
718e3744 | 7505 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7506 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7507 | afi_t afi, safi_t safi, | |
7508 | const char *name_str) | |
718e3744 | 7509 | { |
d62a17ae | 7510 | int ret; |
7511 | struct peer *peer; | |
1de27621 | 7512 | struct route_map *route_map; |
718e3744 | 7513 | |
d62a17ae | 7514 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7515 | if (!peer) | |
7516 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7517 | |
1de27621 DA |
7518 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7519 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7520 | |
d62a17ae | 7521 | return bgp_vty_return(vty, ret); |
718e3744 | 7522 | } |
7523 | ||
7524 | /* Unset route-map from the peer. */ | |
d62a17ae | 7525 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7526 | afi_t afi, safi_t safi) | |
718e3744 | 7527 | { |
d62a17ae | 7528 | int ret; |
7529 | struct peer *peer; | |
718e3744 | 7530 | |
d62a17ae | 7531 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7532 | if (!peer) | |
7533 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7534 | |
d62a17ae | 7535 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7536 | |
d62a17ae | 7537 | return bgp_vty_return(vty, ret); |
718e3744 | 7538 | } |
7539 | ||
7540 | DEFUN (neighbor_unsuppress_map, | |
7541 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7542 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7543 | NEIGHBOR_STR |
7544 | NEIGHBOR_ADDR_STR2 | |
7545 | "Route-map to selectively unsuppress suppressed routes\n" | |
7546 | "Name of route map\n") | |
7547 | { | |
d62a17ae | 7548 | int idx_peer = 1; |
7549 | int idx_word = 3; | |
7550 | return peer_unsuppress_map_set_vty( | |
7551 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7552 | argv[idx_word]->arg); | |
718e3744 | 7553 | } |
7554 | ||
d62a17ae | 7555 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7556 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7557 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7558 | "Route-map to selectively unsuppress suppressed routes\n" | |
7559 | "Name of route map\n") | |
596c17ba | 7560 | |
718e3744 | 7561 | DEFUN (no_neighbor_unsuppress_map, |
7562 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7563 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7564 | NO_STR |
7565 | NEIGHBOR_STR | |
7566 | NEIGHBOR_ADDR_STR2 | |
7567 | "Route-map to selectively unsuppress suppressed routes\n" | |
7568 | "Name of route map\n") | |
7569 | { | |
d62a17ae | 7570 | int idx_peer = 2; |
7571 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7572 | bgp_node_afi(vty), | |
7573 | bgp_node_safi(vty)); | |
718e3744 | 7574 | } |
6b0655a2 | 7575 | |
d62a17ae | 7576 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
7577 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7578 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7579 | "Route-map to selectively unsuppress suppressed routes\n" | |
7580 | "Name of route map\n") | |
596c17ba | 7581 | |
7e62b792 IR |
7582 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
7583 | afi_t afi, safi_t safi, | |
7584 | const char *num_str, | |
7585 | const char *threshold_str, int warning, | |
7586 | const char *restart_str, | |
7587 | const char *force_str) | |
7588 | { | |
7589 | int ret; | |
7590 | struct peer *peer; | |
7591 | uint32_t max; | |
7592 | uint8_t threshold; | |
7593 | uint16_t restart; | |
7594 | ||
7595 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7596 | if (!peer) | |
7597 | return CMD_WARNING_CONFIG_FAILED; | |
7598 | ||
7599 | max = strtoul(num_str, NULL, 10); | |
7600 | if (threshold_str) | |
7601 | threshold = atoi(threshold_str); | |
7602 | else | |
7603 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
7604 | ||
7605 | if (restart_str) | |
7606 | restart = atoi(restart_str); | |
7607 | else | |
7608 | restart = 0; | |
7609 | ||
7610 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
7611 | restart, force_str ? true : false); | |
7612 | ||
7613 | return bgp_vty_return(vty, ret); | |
7614 | } | |
7615 | ||
7616 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
7617 | afi_t afi, safi_t safi) | |
7618 | { | |
7619 | int ret; | |
7620 | struct peer *peer; | |
7621 | ||
7622 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7623 | if (!peer) | |
7624 | return CMD_WARNING_CONFIG_FAILED; | |
7625 | ||
7626 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
7627 | ||
7628 | return bgp_vty_return(vty, ret); | |
7629 | } | |
7630 | ||
fde246e8 | 7631 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
7632 | DEFUN(neighbor_maximum_prefix_out, |
7633 | neighbor_maximum_prefix_out_cmd, | |
7634 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7635 | NEIGHBOR_STR | |
7636 | NEIGHBOR_ADDR_STR2 | |
7637 | "Maximum number of prefixes to be sent to this peer\n" | |
7638 | "Maximum no. of prefix limit\n") | |
fde246e8 DA |
7639 | { |
7640 | int idx_peer = 1; | |
7641 | int idx_number = 3; | |
7e62b792 IR |
7642 | struct peer *peer; |
7643 | uint32_t max; | |
fde246e8 DA |
7644 | afi_t afi = bgp_node_afi(vty); |
7645 | safi_t safi = bgp_node_safi(vty); | |
7646 | ||
7e62b792 IR |
7647 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7648 | if (!peer) | |
fde246e8 DA |
7649 | return CMD_WARNING_CONFIG_FAILED; |
7650 | ||
7e62b792 | 7651 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 7652 | |
7e62b792 IR |
7653 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7654 | peer->pmax_out[afi][safi] = max; | |
fde246e8 | 7655 | |
7e62b792 | 7656 | return CMD_SUCCESS; |
fde246e8 DA |
7657 | } |
7658 | ||
1d80f243 IR |
7659 | DEFUN(no_neighbor_maximum_prefix_out, |
7660 | no_neighbor_maximum_prefix_out_cmd, | |
7661 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
7662 | NO_STR | |
7663 | NEIGHBOR_STR | |
7664 | NEIGHBOR_ADDR_STR2 | |
7665 | "Maximum number of prefixes to be sent to this peer\n") | |
fde246e8 DA |
7666 | { |
7667 | int idx_peer = 2; | |
7e62b792 | 7668 | struct peer *peer; |
fde246e8 DA |
7669 | afi_t afi = bgp_node_afi(vty); |
7670 | safi_t safi = bgp_node_safi(vty); | |
7671 | ||
7e62b792 IR |
7672 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7673 | if (!peer) | |
fde246e8 DA |
7674 | return CMD_WARNING_CONFIG_FAILED; |
7675 | ||
7e62b792 IR |
7676 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
7677 | peer->pmax_out[afi][safi] = 0; | |
fde246e8 | 7678 | |
7e62b792 | 7679 | return CMD_SUCCESS; |
fde246e8 DA |
7680 | } |
7681 | ||
9cbd06e0 DA |
7682 | /* Maximum number of prefix configuration. Prefix count is different |
7683 | for each peer configuration. So this configuration can be set for | |
718e3744 | 7684 | each peer configuration. */ |
1d80f243 IR |
7685 | DEFUN (neighbor_maximum_prefix, |
7686 | neighbor_maximum_prefix_cmd, | |
7687 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
7688 | NEIGHBOR_STR | |
7689 | NEIGHBOR_ADDR_STR2 | |
7690 | "Maximum number of prefix accept from this peer\n" | |
7691 | "maximum no. of prefix limit\n" | |
7692 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7693 | { |
d62a17ae | 7694 | int idx_peer = 1; |
7695 | int idx_number = 3; | |
9cbd06e0 | 7696 | int idx_force = 0; |
7e62b792 | 7697 | char *force = NULL; |
9cbd06e0 DA |
7698 | |
7699 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7700 | force = argv[idx_force]->arg; |
9cbd06e0 | 7701 | |
7e62b792 IR |
7702 | return peer_maximum_prefix_set_vty( |
7703 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7704 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 7705 | } |
7706 | ||
d62a17ae | 7707 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 7708 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 7709 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7710 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7711 | "maximum no. of prefix limit\n" |
7712 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7713 | |
1d80f243 IR |
7714 | DEFUN (neighbor_maximum_prefix_threshold, |
7715 | neighbor_maximum_prefix_threshold_cmd, | |
7716 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
7717 | NEIGHBOR_STR | |
7718 | NEIGHBOR_ADDR_STR2 | |
7719 | "Maximum number of prefix accept from this peer\n" | |
7720 | "maximum no. of prefix limit\n" | |
7721 | "Threshold value (%) at which to generate a warning msg\n" | |
7722 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7723 | { |
d62a17ae | 7724 | int idx_peer = 1; |
7725 | int idx_number = 3; | |
7726 | int idx_number_2 = 4; | |
9cbd06e0 | 7727 | int idx_force = 0; |
7e62b792 | 7728 | char *force = NULL; |
9cbd06e0 DA |
7729 | |
7730 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7731 | force = argv[idx_force]->arg; |
9cbd06e0 | 7732 | |
7e62b792 IR |
7733 | return peer_maximum_prefix_set_vty( |
7734 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7735 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 7736 | } |
e0701b79 | 7737 | |
d62a17ae | 7738 | ALIAS_HIDDEN( |
7739 | neighbor_maximum_prefix_threshold, | |
7740 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 7741 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 7742 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7743 | "Maximum number of prefix accept from this peer\n" | |
7744 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7745 | "Threshold value (%) at which to generate a warning msg\n" |
7746 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7747 | |
1d80f243 IR |
7748 | DEFUN (neighbor_maximum_prefix_warning, |
7749 | neighbor_maximum_prefix_warning_cmd, | |
7750 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
7751 | NEIGHBOR_STR | |
7752 | NEIGHBOR_ADDR_STR2 | |
7753 | "Maximum number of prefix accept from this peer\n" | |
7754 | "maximum no. of prefix limit\n" | |
7755 | "Only give warning message when limit is exceeded\n" | |
7756 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7757 | { |
d62a17ae | 7758 | int idx_peer = 1; |
7759 | int idx_number = 3; | |
9cbd06e0 | 7760 | int idx_force = 0; |
7e62b792 | 7761 | char *force = NULL; |
9cbd06e0 DA |
7762 | |
7763 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7764 | force = argv[idx_force]->arg; |
9cbd06e0 | 7765 | |
7e62b792 IR |
7766 | return peer_maximum_prefix_set_vty( |
7767 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7768 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 7769 | } |
7770 | ||
d62a17ae | 7771 | ALIAS_HIDDEN( |
7772 | neighbor_maximum_prefix_warning, | |
7773 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 7774 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 7775 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7776 | "Maximum number of prefix accept from this peer\n" | |
7777 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7778 | "Only give warning message when limit is exceeded\n" |
7779 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7780 | |
1d80f243 IR |
7781 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
7782 | neighbor_maximum_prefix_threshold_warning_cmd, | |
7783 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
7784 | NEIGHBOR_STR | |
7785 | NEIGHBOR_ADDR_STR2 | |
7786 | "Maximum number of prefix accept from this peer\n" | |
7787 | "maximum no. of prefix limit\n" | |
7788 | "Threshold value (%) at which to generate a warning msg\n" | |
7789 | "Only give warning message when limit is exceeded\n" | |
7790 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7791 | { |
d62a17ae | 7792 | int idx_peer = 1; |
7793 | int idx_number = 3; | |
7794 | int idx_number_2 = 4; | |
9cbd06e0 | 7795 | int idx_force = 0; |
7e62b792 | 7796 | char *force = NULL; |
9cbd06e0 DA |
7797 | |
7798 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7799 | force = argv[idx_force]->arg; |
9cbd06e0 | 7800 | |
7e62b792 IR |
7801 | return peer_maximum_prefix_set_vty( |
7802 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7803 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 7804 | } |
7805 | ||
d62a17ae | 7806 | ALIAS_HIDDEN( |
7807 | neighbor_maximum_prefix_threshold_warning, | |
7808 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 7809 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 7810 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7811 | "Maximum number of prefix accept from this peer\n" | |
7812 | "maximum no. of prefix limit\n" | |
7813 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7814 | "Only give warning message when limit is exceeded\n" |
7815 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7816 | |
1d80f243 IR |
7817 | DEFUN (neighbor_maximum_prefix_restart, |
7818 | neighbor_maximum_prefix_restart_cmd, | |
7819 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
7820 | NEIGHBOR_STR | |
7821 | NEIGHBOR_ADDR_STR2 | |
7822 | "Maximum number of prefix accept from this peer\n" | |
7823 | "maximum no. of prefix limit\n" | |
7824 | "Restart bgp connection after limit is exceeded\n" | |
7825 | "Restart interval in minutes\n" | |
7826 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7827 | { |
d62a17ae | 7828 | int idx_peer = 1; |
7829 | int idx_number = 3; | |
7830 | int idx_number_2 = 5; | |
9cbd06e0 | 7831 | int idx_force = 0; |
7e62b792 | 7832 | char *force = NULL; |
9cbd06e0 DA |
7833 | |
7834 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7835 | force = argv[idx_force]->arg; |
9cbd06e0 | 7836 | |
7e62b792 IR |
7837 | return peer_maximum_prefix_set_vty( |
7838 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7839 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 7840 | } |
7841 | ||
d62a17ae | 7842 | ALIAS_HIDDEN( |
7843 | neighbor_maximum_prefix_restart, | |
7844 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 7845 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 7846 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7847 | "Maximum number of prefix accept from this peer\n" | |
7848 | "maximum no. of prefix limit\n" | |
7849 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7850 | "Restart interval in minutes\n" |
7851 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7852 | |
1d80f243 IR |
7853 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
7854 | neighbor_maximum_prefix_threshold_restart_cmd, | |
7855 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
7856 | NEIGHBOR_STR | |
7857 | NEIGHBOR_ADDR_STR2 | |
7858 | "Maximum number of prefixes to accept from this peer\n" | |
7859 | "maximum no. of prefix limit\n" | |
7860 | "Threshold value (%) at which to generate a warning msg\n" | |
7861 | "Restart bgp connection after limit is exceeded\n" | |
7862 | "Restart interval in minutes\n" | |
7863 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7864 | { |
d62a17ae | 7865 | int idx_peer = 1; |
7866 | int idx_number = 3; | |
7867 | int idx_number_2 = 4; | |
7868 | int idx_number_3 = 6; | |
9cbd06e0 | 7869 | int idx_force = 0; |
7e62b792 | 7870 | char *force = NULL; |
9cbd06e0 DA |
7871 | |
7872 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7873 | force = argv[idx_force]->arg; |
9cbd06e0 | 7874 | |
7e62b792 IR |
7875 | return peer_maximum_prefix_set_vty( |
7876 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7877 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
7878 | argv[idx_number_3]->arg, force); | |
d62a17ae | 7879 | } |
7880 | ||
7881 | ALIAS_HIDDEN( | |
7882 | neighbor_maximum_prefix_threshold_restart, | |
7883 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7884 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7885 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7886 | "Maximum number of prefixes to accept from this peer\n" | |
7887 | "maximum no. of prefix limit\n" | |
7888 | "Threshold value (%) at which to generate a warning msg\n" | |
7889 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7890 | "Restart interval in minutes\n" |
7891 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7892 | |
1d80f243 IR |
7893 | DEFUN (no_neighbor_maximum_prefix, |
7894 | no_neighbor_maximum_prefix_cmd, | |
7895 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
7896 | NO_STR | |
7897 | NEIGHBOR_STR | |
7898 | NEIGHBOR_ADDR_STR2 | |
7899 | "Maximum number of prefixes to accept from this peer\n" | |
7900 | "maximum no. of prefix limit\n" | |
7901 | "Threshold value (%) at which to generate a warning msg\n" | |
7902 | "Restart bgp connection after limit is exceeded\n" | |
7903 | "Restart interval in minutes\n" | |
7904 | "Only give warning message when limit is exceeded\n" | |
7905 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7906 | { |
d62a17ae | 7907 | int idx_peer = 2; |
7e62b792 IR |
7908 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
7909 | bgp_node_afi(vty), | |
7910 | bgp_node_safi(vty)); | |
718e3744 | 7911 | } |
e52702f2 | 7912 | |
d62a17ae | 7913 | ALIAS_HIDDEN( |
7914 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7915 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7916 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7917 | "Maximum number of prefixes to accept from this peer\n" | |
7918 | "maximum no. of prefix limit\n" | |
7919 | "Threshold value (%) at which to generate a warning msg\n" | |
7920 | "Restart bgp connection after limit is exceeded\n" | |
7921 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
7922 | "Only give warning message when limit is exceeded\n" |
7923 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7924 | |
718e3744 | 7925 | |
718e3744 | 7926 | /* "neighbor allowas-in" */ |
7927 | DEFUN (neighbor_allowas_in, | |
7928 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7929 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7930 | NEIGHBOR_STR |
7931 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7932 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7933 | "Number of occurrences of AS number\n" |
fd8503f5 | 7934 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7935 | { |
d62a17ae | 7936 | int idx_peer = 1; |
7937 | int idx_number_origin = 3; | |
7938 | int ret; | |
7939 | int origin = 0; | |
7940 | struct peer *peer; | |
7941 | int allow_num = 0; | |
7942 | ||
7943 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7944 | if (!peer) | |
7945 | return CMD_WARNING_CONFIG_FAILED; | |
7946 | ||
7947 | if (argc <= idx_number_origin) | |
7948 | allow_num = 3; | |
7949 | else { | |
7950 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7951 | origin = 1; | |
7952 | else | |
7953 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7954 | } | |
7955 | ||
7956 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7957 | allow_num, origin); | |
7958 | ||
7959 | return bgp_vty_return(vty, ret); | |
7960 | } | |
7961 | ||
7962 | ALIAS_HIDDEN( | |
7963 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7964 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7965 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7966 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7967 | "Number of occurrences of AS number\n" |
d62a17ae | 7968 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7969 | |
718e3744 | 7970 | DEFUN (no_neighbor_allowas_in, |
7971 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7973 | NO_STR |
7974 | NEIGHBOR_STR | |
7975 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7976 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7977 | "Number of occurrences of AS number\n" |
fd8503f5 | 7978 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7979 | { |
d62a17ae | 7980 | int idx_peer = 2; |
7981 | int ret; | |
7982 | struct peer *peer; | |
718e3744 | 7983 | |
d62a17ae | 7984 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7985 | if (!peer) | |
7986 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7987 | |
d62a17ae | 7988 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7989 | bgp_node_safi(vty)); | |
718e3744 | 7990 | |
d62a17ae | 7991 | return bgp_vty_return(vty, ret); |
718e3744 | 7992 | } |
6b0655a2 | 7993 | |
d62a17ae | 7994 | ALIAS_HIDDEN( |
7995 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7996 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7997 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7998 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7999 | "Number of occurrences of AS number\n" |
d62a17ae | 8000 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8001 | |
28c6e247 IR |
8002 | DEFUN (neighbor_ttl_security, |
8003 | neighbor_ttl_security_cmd, | |
8004 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8005 | NEIGHBOR_STR | |
8006 | NEIGHBOR_ADDR_STR2 | |
8007 | "BGP ttl-security parameters\n" | |
8008 | "Specify the maximum number of hops to the BGP peer\n" | |
8009 | "Number of hops to BGP peer\n") | |
fa411a21 | 8010 | { |
d62a17ae | 8011 | int idx_peer = 1; |
8012 | int idx_number = 4; | |
28c6e247 IR |
8013 | struct peer *peer; |
8014 | int gtsm_hops; | |
d62a17ae | 8015 | |
28c6e247 IR |
8016 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8017 | if (!peer) | |
d62a17ae | 8018 | return CMD_WARNING_CONFIG_FAILED; |
8019 | ||
28c6e247 IR |
8020 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
8021 | ||
8022 | /* | |
8023 | * If 'neighbor swpX', then this is for directly connected peers, | |
8024 | * we should not accept a ttl-security hops value greater than 1. | |
8025 | */ | |
8026 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8027 | vty_out(vty, | |
8028 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8029 | argv[idx_peer]->arg); | |
8030 | return CMD_WARNING_CONFIG_FAILED; | |
8031 | } | |
7ebe625c | 8032 | |
28c6e247 | 8033 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8034 | } |
8035 | ||
1d80f243 IR |
8036 | DEFUN (no_neighbor_ttl_security, |
8037 | no_neighbor_ttl_security_cmd, | |
8038 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8039 | NO_STR | |
8040 | NEIGHBOR_STR | |
8041 | NEIGHBOR_ADDR_STR2 | |
8042 | "BGP ttl-security parameters\n" | |
8043 | "Specify the maximum number of hops to the BGP peer\n" | |
8044 | "Number of hops to BGP peer\n") | |
fa411a21 | 8045 | { |
d62a17ae | 8046 | int idx_peer = 2; |
28c6e247 | 8047 | struct peer *peer; |
fa411a21 | 8048 | |
28c6e247 IR |
8049 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8050 | if (!peer) | |
d62a17ae | 8051 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8052 | |
28c6e247 | 8053 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8054 | } |
6b0655a2 | 8055 | |
7c0e4312 DA |
8056 | /* disable-addpath-rx */ |
8057 | DEFUN(neighbor_disable_addpath_rx, | |
8058 | neighbor_disable_addpath_rx_cmd, | |
8059 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8060 | NEIGHBOR_STR | |
8061 | NEIGHBOR_ADDR_STR2 | |
8062 | "Do not accept additional paths\n") | |
8063 | { | |
8064 | char *peer_str = argv[1]->arg; | |
8065 | struct peer *peer; | |
8066 | afi_t afi = bgp_node_afi(vty); | |
8067 | safi_t safi = bgp_node_safi(vty); | |
8068 | ||
8069 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8070 | if (!peer) | |
8071 | return CMD_WARNING_CONFIG_FAILED; | |
8072 | ||
8073 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8074 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8075 | } | |
8076 | ||
8077 | DEFUN(no_neighbor_disable_addpath_rx, | |
8078 | no_neighbor_disable_addpath_rx_cmd, | |
8079 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8080 | NO_STR | |
8081 | NEIGHBOR_STR | |
8082 | NEIGHBOR_ADDR_STR2 | |
8083 | "Do not accept additional paths\n") | |
8084 | { | |
8085 | char *peer_str = argv[2]->arg; | |
8086 | struct peer *peer; | |
8087 | afi_t afi = bgp_node_afi(vty); | |
8088 | safi_t safi = bgp_node_safi(vty); | |
8089 | ||
8090 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8091 | if (!peer) | |
8092 | return CMD_WARNING_CONFIG_FAILED; | |
8093 | ||
8094 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8095 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8096 | } | |
8097 | ||
adbac85e DW |
8098 | DEFUN (neighbor_addpath_tx_all_paths, |
8099 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8100 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8101 | NEIGHBOR_STR |
8102 | NEIGHBOR_ADDR_STR2 | |
8103 | "Use addpath to advertise all paths to a neighbor\n") | |
8104 | { | |
d62a17ae | 8105 | int idx_peer = 1; |
8106 | struct peer *peer; | |
adbac85e | 8107 | |
d62a17ae | 8108 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8109 | if (!peer) | |
8110 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8111 | |
dcc68b5e MS |
8112 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8113 | BGP_ADDPATH_ALL); | |
8114 | return CMD_SUCCESS; | |
adbac85e DW |
8115 | } |
8116 | ||
d62a17ae | 8117 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8118 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8119 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8120 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8121 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8122 | |
adbac85e DW |
8123 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8124 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8126 | NO_STR |
8127 | NEIGHBOR_STR | |
8128 | NEIGHBOR_ADDR_STR2 | |
8129 | "Use addpath to advertise all paths to a neighbor\n") | |
8130 | { | |
d62a17ae | 8131 | int idx_peer = 2; |
dcc68b5e MS |
8132 | struct peer *peer; |
8133 | ||
8134 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8135 | if (!peer) | |
8136 | return CMD_WARNING_CONFIG_FAILED; | |
8137 | ||
8138 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8139 | != BGP_ADDPATH_ALL) { | |
8140 | vty_out(vty, | |
8141 | "%% Peer not currently configured to transmit all paths."); | |
8142 | return CMD_WARNING_CONFIG_FAILED; | |
8143 | } | |
8144 | ||
8145 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8146 | BGP_ADDPATH_NONE); | |
8147 | ||
8148 | return CMD_SUCCESS; | |
adbac85e DW |
8149 | } |
8150 | ||
d62a17ae | 8151 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8152 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8153 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8154 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8155 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8156 | |
06370dac DW |
8157 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8158 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8159 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8160 | NEIGHBOR_STR |
8161 | NEIGHBOR_ADDR_STR2 | |
8162 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8163 | { | |
d62a17ae | 8164 | int idx_peer = 1; |
8165 | struct peer *peer; | |
06370dac | 8166 | |
d62a17ae | 8167 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8168 | if (!peer) | |
8169 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8170 | |
dcc68b5e MS |
8171 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8172 | BGP_ADDPATH_BEST_PER_AS); | |
8173 | ||
8174 | return CMD_SUCCESS; | |
06370dac DW |
8175 | } |
8176 | ||
d62a17ae | 8177 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8178 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8179 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8180 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8181 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8182 | |
06370dac DW |
8183 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8184 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8185 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8186 | NO_STR |
8187 | NEIGHBOR_STR | |
8188 | NEIGHBOR_ADDR_STR2 | |
8189 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8190 | { | |
d62a17ae | 8191 | int idx_peer = 2; |
dcc68b5e MS |
8192 | struct peer *peer; |
8193 | ||
8194 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8195 | if (!peer) | |
8196 | return CMD_WARNING_CONFIG_FAILED; | |
8197 | ||
8198 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8199 | != BGP_ADDPATH_BEST_PER_AS) { | |
8200 | vty_out(vty, | |
8201 | "%% Peer not currently configured to transmit all best path per as."); | |
8202 | return CMD_WARNING_CONFIG_FAILED; | |
8203 | } | |
8204 | ||
8205 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8206 | BGP_ADDPATH_NONE); | |
8207 | ||
8208 | return CMD_SUCCESS; | |
06370dac DW |
8209 | } |
8210 | ||
d62a17ae | 8211 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8212 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8213 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8214 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8215 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8216 | |
2b31007c RZ |
8217 | DEFPY( |
8218 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8219 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8220 | NEIGHBOR_STR | |
8221 | NEIGHBOR_ADDR_STR2 | |
8222 | "Detect AS loops before sending to neighbor\n") | |
8223 | { | |
8224 | struct peer *peer; | |
8225 | ||
8226 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8227 | if (!peer) | |
8228 | return CMD_WARNING_CONFIG_FAILED; | |
8229 | ||
8230 | peer->as_path_loop_detection = true; | |
8231 | ||
8232 | return CMD_SUCCESS; | |
8233 | } | |
8234 | ||
8235 | DEFPY( | |
8236 | no_neighbor_aspath_loop_detection, | |
8237 | no_neighbor_aspath_loop_detection_cmd, | |
8238 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8239 | NO_STR | |
8240 | NEIGHBOR_STR | |
8241 | NEIGHBOR_ADDR_STR2 | |
8242 | "Detect AS loops before sending to neighbor\n") | |
8243 | { | |
8244 | struct peer *peer; | |
8245 | ||
8246 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8247 | if (!peer) | |
8248 | return CMD_WARNING_CONFIG_FAILED; | |
8249 | ||
8250 | peer->as_path_loop_detection = false; | |
8251 | ||
8252 | return CMD_SUCCESS; | |
8253 | } | |
8254 | ||
b9c7bc5a | 8255 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8256 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8257 | { |
b9c7bc5a PZ |
8258 | struct ecommunity *ecom = NULL; |
8259 | struct ecommunity *ecomadd; | |
ddb5b488 | 8260 | |
b9c7bc5a | 8261 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8262 | if (is_rt6) |
8263 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8264 | ECOMMUNITY_ROUTE_TARGET, | |
8265 | 0); | |
8266 | else | |
8267 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8268 | ECOMMUNITY_ROUTE_TARGET, | |
8269 | 0); | |
b9c7bc5a PZ |
8270 | if (!ecomadd) { |
8271 | vty_out(vty, "Malformed community-list value\n"); | |
8272 | if (ecom) | |
8273 | ecommunity_free(&ecom); | |
8274 | return CMD_WARNING_CONFIG_FAILED; | |
8275 | } | |
ddb5b488 | 8276 | |
b9c7bc5a PZ |
8277 | if (ecom) { |
8278 | ecommunity_merge(ecom, ecomadd); | |
8279 | ecommunity_free(&ecomadd); | |
8280 | } else { | |
8281 | ecom = ecomadd; | |
8282 | } | |
8283 | } | |
8284 | ||
8285 | if (*list) { | |
8286 | ecommunity_free(&*list); | |
ddb5b488 | 8287 | } |
b9c7bc5a PZ |
8288 | *list = ecom; |
8289 | ||
8290 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8291 | } |
8292 | ||
0ca70ba5 DS |
8293 | /* |
8294 | * v2vimport is true if we are handling a `import vrf ...` command | |
8295 | */ | |
8296 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8297 | { |
0ca70ba5 DS |
8298 | afi_t afi; |
8299 | ||
ddb5b488 | 8300 | switch (vty->node) { |
b9c7bc5a | 8301 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8302 | afi = AFI_IP; |
8303 | break; | |
b9c7bc5a | 8304 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8305 | afi = AFI_IP6; |
8306 | break; | |
ddb5b488 PZ |
8307 | default: |
8308 | vty_out(vty, | |
b9c7bc5a | 8309 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8310 | return AFI_MAX; |
ddb5b488 | 8311 | } |
69b07479 | 8312 | |
0ca70ba5 DS |
8313 | if (!v2vimport) { |
8314 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8315 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8316 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8317 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8318 | vty_out(vty, | |
8319 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8320 | return AFI_MAX; | |
8321 | } | |
8322 | } else { | |
8323 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8324 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8325 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8326 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8327 | vty_out(vty, | |
8328 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8329 | return AFI_MAX; | |
8330 | } | |
8331 | } | |
8332 | return afi; | |
ddb5b488 PZ |
8333 | } |
8334 | ||
585f1adc IR |
8335 | DEFPY (af_rd_vpn_export, |
8336 | af_rd_vpn_export_cmd, | |
8337 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8338 | NO_STR | |
8339 | "Specify route distinguisher\n" | |
8340 | "Between current address-family and vpn\n" | |
8341 | "For routes leaked from current address-family to vpn\n" | |
8342 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8343 | { |
585f1adc IR |
8344 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8345 | struct prefix_rd prd; | |
8346 | int ret; | |
ddb5b488 | 8347 | afi_t afi; |
b9c7bc5a | 8348 | int idx = 0; |
585f1adc | 8349 | bool yes = true; |
b9c7bc5a | 8350 | |
585f1adc IR |
8351 | if (argv_find(argv, argc, "no", &idx)) |
8352 | yes = false; | |
ddb5b488 | 8353 | |
585f1adc IR |
8354 | if (yes) { |
8355 | ret = str2prefix_rd(rd_str, &prd); | |
8356 | if (!ret) { | |
8357 | vty_out(vty, "%% Malformed rd\n"); | |
8358 | return CMD_WARNING_CONFIG_FAILED; | |
8359 | } | |
8360 | } | |
ddb5b488 | 8361 | |
585f1adc IR |
8362 | afi = vpn_policy_getafi(vty, bgp, false); |
8363 | if (afi == AFI_MAX) | |
8364 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8365 | |
585f1adc IR |
8366 | /* |
8367 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8368 | */ | |
8369 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8370 | bgp_get_default(), bgp); | |
ddb5b488 | 8371 | |
585f1adc IR |
8372 | if (yes) { |
8373 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8374 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8375 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8376 | } else { | |
8377 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8378 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8379 | } | |
69b07479 | 8380 | |
585f1adc IR |
8381 | /* post-change: re-export vpn routes */ |
8382 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8383 | bgp_get_default(), bgp); | |
8384 | ||
8385 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8386 | } |
8387 | ||
b9c7bc5a PZ |
8388 | ALIAS (af_rd_vpn_export, |
8389 | af_no_rd_vpn_export_cmd, | |
8390 | "no rd vpn export", | |
ddb5b488 | 8391 | NO_STR |
b9c7bc5a PZ |
8392 | "Specify route distinguisher\n" |
8393 | "Between current address-family and vpn\n" | |
8394 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8395 | |
b9c7bc5a PZ |
8396 | DEFPY (af_label_vpn_export, |
8397 | af_label_vpn_export_cmd, | |
e70e9f8e | 8398 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8399 | NO_STR |
ddb5b488 | 8400 | "label value for VRF\n" |
b9c7bc5a PZ |
8401 | "Between current address-family and vpn\n" |
8402 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8403 | "Label Value <0-1048575>\n" |
8404 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8405 | { |
8406 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8407 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8408 | afi_t afi; |
b9c7bc5a | 8409 | int idx = 0; |
c6423c31 | 8410 | bool yes = true; |
b9c7bc5a PZ |
8411 | |
8412 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8413 | yes = false; |
ddb5b488 | 8414 | |
21a16cc2 PZ |
8415 | /* If "no ...", squash trailing parameter */ |
8416 | if (!yes) | |
8417 | label_auto = NULL; | |
8418 | ||
e70e9f8e PZ |
8419 | if (yes) { |
8420 | if (!label_auto) | |
8421 | label = label_val; /* parser should force unsigned */ | |
8422 | } | |
ddb5b488 | 8423 | |
0ca70ba5 | 8424 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8425 | if (afi == AFI_MAX) |
8426 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8427 | |
e70e9f8e | 8428 | |
69b07479 DS |
8429 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8430 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8431 | /* no change */ | |
8432 | return CMD_SUCCESS; | |
e70e9f8e | 8433 | |
69b07479 DS |
8434 | /* |
8435 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8436 | */ | |
8437 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8438 | bgp_get_default(), bgp); | |
8439 | ||
8440 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8441 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8442 | ||
8443 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8444 | ||
8445 | /* | |
8446 | * label has previously been automatically | |
8447 | * assigned by labelpool: release it | |
8448 | * | |
8449 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8450 | * means the automatic assignment is in flight | |
8451 | * and therefore the labelpool callback must | |
8452 | * detect that the auto label is not needed. | |
8453 | */ | |
8454 | ||
8455 | bgp_lp_release(LP_TYPE_VRF, | |
8456 | &bgp->vpn_policy[afi], | |
8457 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8458 | } |
69b07479 DS |
8459 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8460 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8461 | } | |
ddb5b488 | 8462 | |
69b07479 DS |
8463 | bgp->vpn_policy[afi].tovpn_label = label; |
8464 | if (label_auto) { | |
8465 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8466 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8467 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8468 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8469 | } |
8470 | ||
69b07479 DS |
8471 | /* post-change: re-export vpn routes */ |
8472 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8473 | bgp_get_default(), bgp); | |
8474 | ||
0d020cd6 | 8475 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
8476 | return CMD_SUCCESS; |
8477 | } | |
8478 | ||
b72c9e14 HS |
8479 | DEFPY (af_sid_vpn_export, |
8480 | af_sid_vpn_export_cmd, | |
8481 | "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>", | |
8482 | NO_STR | |
8483 | "sid value for VRF\n" | |
8484 | "Between current address-family and vpn\n" | |
8485 | "For routes leaked from current address-family to vpn\n" | |
8486 | "Sid allocation index\n" | |
8487 | "Automatically assign a label\n") | |
8488 | { | |
8489 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8490 | afi_t afi; | |
8491 | int debug = 0; | |
8492 | int idx = 0; | |
8493 | bool yes = true; | |
8494 | ||
8495 | if (argv_find(argv, argc, "no", &idx)) | |
8496 | yes = false; | |
8497 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
8498 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
8499 | ||
8500 | afi = vpn_policy_getafi(vty, bgp, false); | |
8501 | if (afi == AFI_MAX) | |
8502 | return CMD_WARNING_CONFIG_FAILED; | |
8503 | ||
8504 | if (!yes) { | |
8505 | /* implement me */ | |
8506 | vty_out(vty, "It's not implemented"); | |
8507 | return CMD_WARNING_CONFIG_FAILED; | |
8508 | } | |
8509 | ||
8510 | /* skip when it's already configured */ | |
8511 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
8512 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8513 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
8514 | return CMD_SUCCESS; | |
8515 | ||
7de4c885 HS |
8516 | /* |
8517 | * mode change between sid_idx and sid_auto isn't supported. | |
8518 | * user must negate sid vpn export when they want to change the mode | |
8519 | */ | |
b72c9e14 HS |
8520 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
8521 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8522 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
8523 | vty_out(vty, "it's already configured as %s.\n", | |
8524 | sid_auto ? "auto-mode" : "idx-mode"); | |
8525 | return CMD_WARNING_CONFIG_FAILED; | |
8526 | } | |
8527 | ||
8528 | /* pre-change */ | |
8529 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8530 | bgp_get_default(), bgp); | |
8531 | ||
8532 | if (sid_auto) { | |
8533 | /* SID allocation auto-mode */ | |
8534 | if (debug) | |
8535 | zlog_debug("%s: auto sid alloc.", __func__); | |
8536 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8537 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
8538 | } else { | |
8539 | /* SID allocation index-mode */ | |
8540 | if (debug) | |
8541 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
8542 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
8543 | } | |
8544 | ||
8545 | /* post-change */ | |
8546 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8547 | bgp_get_default(), bgp); | |
8548 | return CMD_SUCCESS; | |
8549 | } | |
8550 | ||
b9c7bc5a PZ |
8551 | ALIAS (af_label_vpn_export, |
8552 | af_no_label_vpn_export_cmd, | |
8553 | "no label vpn export", | |
8554 | NO_STR | |
8555 | "label value for VRF\n" | |
8556 | "Between current address-family and vpn\n" | |
8557 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8558 | |
585f1adc | 8559 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 8560 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 8561 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 8562 | NO_STR |
ddb5b488 | 8563 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
8564 | "Between current address-family and vpn\n" |
8565 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8566 | "IPv4 prefix\n" |
8567 | "IPv6 prefix\n") | |
8568 | { | |
585f1adc | 8569 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 8570 | afi_t afi; |
ddb5b488 PZ |
8571 | struct prefix p; |
8572 | ||
8c85ca28 QY |
8573 | if (!no) { |
8574 | if (!nexthop_su) { | |
8575 | vty_out(vty, "%% Nexthop required\n"); | |
8576 | return CMD_WARNING_CONFIG_FAILED; | |
8577 | } | |
8c85ca28 | 8578 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
8579 | return CMD_WARNING_CONFIG_FAILED; |
8580 | } | |
ddb5b488 | 8581 | |
585f1adc IR |
8582 | afi = vpn_policy_getafi(vty, bgp, false); |
8583 | if (afi == AFI_MAX) | |
8584 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8585 | |
585f1adc IR |
8586 | /* |
8587 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8588 | */ | |
8589 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8590 | bgp_get_default(), bgp); | |
ddb5b488 | 8591 | |
585f1adc IR |
8592 | if (!no) { |
8593 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
8594 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8595 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8596 | } else { | |
8597 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8598 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8599 | } | |
69b07479 | 8600 | |
585f1adc IR |
8601 | /* post-change: re-export vpn routes */ |
8602 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8603 | bgp_get_default(), bgp); | |
37a87b8f | 8604 | |
585f1adc | 8605 | return CMD_SUCCESS; |
ddb5b488 PZ |
8606 | } |
8607 | ||
b9c7bc5a | 8608 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 8609 | { |
b9c7bc5a PZ |
8610 | if (!strcmp(dstr, "import")) { |
8611 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8612 | } else if (!strcmp(dstr, "export")) { | |
8613 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8614 | } else if (!strcmp(dstr, "both")) { | |
8615 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8616 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8617 | } else { | |
8618 | vty_out(vty, "%% direction parse error\n"); | |
8619 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8620 | } |
ddb5b488 PZ |
8621 | return CMD_SUCCESS; |
8622 | } | |
8623 | ||
b9c7bc5a PZ |
8624 | DEFPY (af_rt_vpn_imexport, |
8625 | af_rt_vpn_imexport_cmd, | |
8626 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8627 | NO_STR | |
8628 | "Specify route target list\n" | |
ddb5b488 | 8629 | "Specify route target list\n" |
b9c7bc5a PZ |
8630 | "Between current address-family and vpn\n" |
8631 | "For routes leaked from vpn to current address-family: match any\n" | |
8632 | "For routes leaked from current address-family to vpn: set\n" | |
8633 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
8634 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
8635 | { | |
8636 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8637 | int ret; | |
8638 | struct ecommunity *ecom = NULL; | |
8639 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8640 | vpn_policy_direction_t dir; |
8641 | afi_t afi; | |
8642 | int idx = 0; | |
c6423c31 | 8643 | bool yes = true; |
ddb5b488 | 8644 | |
b9c7bc5a | 8645 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8646 | yes = false; |
b9c7bc5a | 8647 | |
0ca70ba5 | 8648 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8649 | if (afi == AFI_MAX) |
8650 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8651 | |
b9c7bc5a | 8652 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8653 | if (ret != CMD_SUCCESS) |
8654 | return ret; | |
8655 | ||
b9c7bc5a PZ |
8656 | if (yes) { |
8657 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8658 | vty_out(vty, "%% Missing RTLIST\n"); | |
8659 | return CMD_WARNING_CONFIG_FAILED; | |
8660 | } | |
c6423c31 | 8661 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
8662 | if (ret != CMD_SUCCESS) { |
8663 | return ret; | |
8664 | } | |
ddb5b488 PZ |
8665 | } |
8666 | ||
69b07479 DS |
8667 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8668 | if (!dodir[dir]) | |
ddb5b488 | 8669 | continue; |
ddb5b488 | 8670 | |
69b07479 | 8671 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8672 | |
69b07479 DS |
8673 | if (yes) { |
8674 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8675 | ecommunity_free( | |
8676 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8677 | bgp->vpn_policy[afi].rtlist[dir] = | |
8678 | ecommunity_dup(ecom); | |
8679 | } else { | |
8680 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8681 | ecommunity_free( | |
8682 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8683 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 8684 | } |
69b07479 DS |
8685 | |
8686 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 8687 | } |
69b07479 | 8688 | |
d555f3e9 PZ |
8689 | if (ecom) |
8690 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
8691 | |
8692 | return CMD_SUCCESS; | |
8693 | } | |
8694 | ||
b9c7bc5a PZ |
8695 | ALIAS (af_rt_vpn_imexport, |
8696 | af_no_rt_vpn_imexport_cmd, | |
8697 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
8698 | NO_STR |
8699 | "Specify route target list\n" | |
b9c7bc5a PZ |
8700 | "Specify route target list\n" |
8701 | "Between current address-family and vpn\n" | |
8702 | "For routes leaked from vpn to current address-family\n" | |
8703 | "For routes leaked from current address-family to vpn\n" | |
8704 | "both import and export\n") | |
8705 | ||
585f1adc | 8706 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
8707 | af_route_map_vpn_imexport_cmd, |
8708 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8709 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8710 | NO_STR | |
ddb5b488 | 8711 | "Specify route map\n" |
b9c7bc5a PZ |
8712 | "Between current address-family and vpn\n" |
8713 | "For routes leaked from vpn to current address-family\n" | |
8714 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8715 | "name of route-map\n") |
8716 | { | |
585f1adc IR |
8717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8718 | int ret; | |
8719 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
8720 | vpn_policy_direction_t dir; | |
ddb5b488 | 8721 | afi_t afi; |
ddb5b488 | 8722 | int idx = 0; |
585f1adc | 8723 | bool yes = true; |
ddb5b488 | 8724 | |
585f1adc IR |
8725 | if (argv_find(argv, argc, "no", &idx)) |
8726 | yes = false; | |
ddb5b488 | 8727 | |
585f1adc IR |
8728 | afi = vpn_policy_getafi(vty, bgp, false); |
8729 | if (afi == AFI_MAX) | |
8730 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8731 | |
585f1adc IR |
8732 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
8733 | if (ret != CMD_SUCCESS) | |
8734 | return ret; | |
ddb5b488 | 8735 | |
585f1adc IR |
8736 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8737 | if (!dodir[dir]) | |
8738 | continue; | |
69b07479 | 8739 | |
585f1adc IR |
8740 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
8741 | ||
8742 | if (yes) { | |
8743 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8744 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8745 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8746 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8747 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8748 | bgp->vpn_policy[afi].rmap[dir] = | |
8749 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8750 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8751 | return CMD_SUCCESS; | |
8752 | } else { | |
8753 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8754 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8755 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8756 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8757 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8758 | } | |
8759 | ||
8760 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8761 | } | |
ddb5b488 | 8762 | |
585f1adc | 8763 | return CMD_SUCCESS; |
ddb5b488 PZ |
8764 | } |
8765 | ||
b9c7bc5a PZ |
8766 | ALIAS (af_route_map_vpn_imexport, |
8767 | af_no_route_map_vpn_imexport_cmd, | |
8768 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
8769 | NO_STR |
8770 | "Specify route map\n" | |
b9c7bc5a PZ |
8771 | "Between current address-family and vpn\n" |
8772 | "For routes leaked from vpn to current address-family\n" | |
8773 | "For routes leaked from current address-family to vpn\n") | |
8774 | ||
bb4f6190 | 8775 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 8776 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
8777 | "Import routes from another VRF\n" |
8778 | "Vrf routes being filtered\n" | |
8779 | "Specify route map\n" | |
8780 | "name of route-map\n") | |
8781 | { | |
8782 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
8783 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
8784 | afi_t afi; | |
bb4f6190 DS |
8785 | struct bgp *bgp_default; |
8786 | ||
0ca70ba5 | 8787 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
8788 | if (afi == AFI_MAX) |
8789 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
8790 | |
8791 | bgp_default = bgp_get_default(); | |
8792 | if (!bgp_default) { | |
8793 | int32_t ret; | |
8794 | as_t as = bgp->as; | |
8795 | ||
8796 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8797 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8798 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
8799 | |
8800 | if (ret) { | |
8801 | vty_out(vty, | |
8802 | "VRF default is not configured as a bgp instance\n"); | |
8803 | return CMD_WARNING; | |
8804 | } | |
8805 | } | |
8806 | ||
69b07479 | 8807 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 8808 | |
ae6a6fb4 DS |
8809 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
8810 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8811 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8812 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8813 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8814 | bgp->vpn_policy[afi].rmap[dir] = | |
8815 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8816 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8817 | return CMD_SUCCESS; | |
8818 | ||
8819 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8820 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 8821 | |
69b07479 DS |
8822 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8823 | ||
bb4f6190 DS |
8824 | return CMD_SUCCESS; |
8825 | } | |
8826 | ||
ae6a6fb4 DS |
8827 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
8828 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
8829 | NO_STR |
8830 | "Import routes from another VRF\n" | |
8831 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
8832 | "Specify route map\n" |
8833 | "name of route-map\n") | |
8834 | { | |
8835 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8836 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8837 | afi_t afi; | |
8838 | ||
8839 | afi = vpn_policy_getafi(vty, bgp, true); | |
8840 | if (afi == AFI_MAX) | |
8841 | return CMD_WARNING_CONFIG_FAILED; | |
8842 | ||
8843 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8844 | ||
8845 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8846 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8847 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8848 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8849 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8850 | ||
8851 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
8852 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8853 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8854 | ||
8855 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8856 | ||
8857 | return CMD_SUCCESS; | |
8858 | } | |
bb4f6190 | 8859 | |
585f1adc IR |
8860 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
8861 | "[no] import vrf VIEWVRFNAME$import_name", | |
8862 | NO_STR | |
8863 | "Import routes from another VRF\n" | |
8864 | "VRF to import from\n" | |
8865 | "The name of the VRF\n") | |
12a844a5 | 8866 | { |
585f1adc IR |
8867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8868 | struct listnode *node; | |
8869 | struct bgp *vrf_bgp, *bgp_default; | |
8870 | int32_t ret = 0; | |
8871 | as_t as = bgp->as; | |
8872 | bool remove = false; | |
8873 | int32_t idx = 0; | |
8874 | char *vname; | |
8875 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
8876 | safi_t safi; |
8877 | afi_t afi; | |
8878 | ||
867f0cca | 8879 | if (import_name == NULL) { |
8880 | vty_out(vty, "%% Missing import name\n"); | |
8881 | return CMD_WARNING; | |
8882 | } | |
8883 | ||
ae6a6fb4 DS |
8884 | if (strcmp(import_name, "route-map") == 0) { |
8885 | vty_out(vty, "%% Must include route-map name\n"); | |
8886 | return CMD_WARNING; | |
8887 | } | |
8888 | ||
585f1adc IR |
8889 | if (argv_find(argv, argc, "no", &idx)) |
8890 | remove = true; | |
8891 | ||
8892 | afi = vpn_policy_getafi(vty, bgp, true); | |
8893 | if (afi == AFI_MAX) | |
8894 | return CMD_WARNING_CONFIG_FAILED; | |
8895 | ||
12a844a5 DS |
8896 | safi = bgp_node_safi(vty); |
8897 | ||
585f1adc IR |
8898 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
8899 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
8900 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
8901 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
8902 | remove ? "unimport" : "import", import_name); | |
8903 | return CMD_WARNING; | |
8904 | } | |
25679caa | 8905 | |
585f1adc IR |
8906 | bgp_default = bgp_get_default(); |
8907 | if (!bgp_default) { | |
8908 | /* Auto-create assuming the same AS */ | |
8909 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
8910 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 8911 | |
585f1adc IR |
8912 | if (ret) { |
8913 | vty_out(vty, | |
8914 | "VRF default is not configured as a bgp instance\n"); | |
8915 | return CMD_WARNING; | |
8916 | } | |
8917 | } | |
12a844a5 | 8918 | |
585f1adc IR |
8919 | vrf_bgp = bgp_lookup_by_name(import_name); |
8920 | if (!vrf_bgp) { | |
8921 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
8922 | vrf_bgp = bgp_default; | |
8923 | else | |
8924 | /* Auto-create assuming the same AS */ | |
8925 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
8926 | ||
8927 | if (ret) { | |
8928 | vty_out(vty, | |
8929 | "VRF %s is not configured as a bgp instance\n", | |
8930 | import_name); | |
8931 | return CMD_WARNING; | |
8932 | } | |
8933 | } | |
8934 | ||
8935 | if (remove) { | |
8936 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
8937 | } else { | |
8938 | /* Already importing from "import_vrf"? */ | |
8939 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
8940 | vname)) { | |
8941 | if (strcmp(vname, import_name) == 0) | |
8942 | return CMD_WARNING; | |
8943 | } | |
8944 | ||
8945 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
8946 | } | |
8947 | ||
8948 | return CMD_SUCCESS; | |
12a844a5 DS |
8949 | } |
8950 | ||
b9c7bc5a | 8951 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 8952 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
8953 | bgp_imexport_vpn_cmd, |
8954 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
8955 | NO_STR |
8956 | "Import routes to this address-family\n" | |
8957 | "Export routes from this address-family\n" | |
8958 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 8959 | { |
585f1adc IR |
8960 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8961 | int previous_state; | |
37a87b8f | 8962 | afi_t afi; |
585f1adc IR |
8963 | safi_t safi; |
8964 | int idx = 0; | |
8965 | bool yes = true; | |
8966 | int flag; | |
8967 | vpn_policy_direction_t dir; | |
8968 | ||
8969 | if (argv_find(argv, argc, "no", &idx)) | |
8970 | yes = false; | |
8971 | ||
8972 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
8973 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
8974 | ||
8975 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
8976 | return CMD_WARNING_CONFIG_FAILED; | |
8977 | } | |
ddb5b488 | 8978 | |
b9c7bc5a PZ |
8979 | afi = bgp_node_afi(vty); |
8980 | safi = bgp_node_safi(vty); | |
585f1adc IR |
8981 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
8982 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
8983 | return CMD_WARNING_CONFIG_FAILED; | |
8984 | } | |
ddb5b488 | 8985 | |
b9c7bc5a | 8986 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
8987 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
8988 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 8989 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
8990 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
8991 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
8992 | } else { |
8993 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
8994 | return CMD_WARNING_CONFIG_FAILED; | |
8995 | } | |
8996 | ||
585f1adc | 8997 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 8998 | |
585f1adc IR |
8999 | if (yes) { |
9000 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9001 | if (!previous_state) { | |
9002 | /* trigger export current vrf */ | |
9003 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9004 | } | |
9005 | } else { | |
9006 | if (previous_state) { | |
9007 | /* trigger un-export current vrf */ | |
9008 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9009 | } | |
9010 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9011 | } | |
37a87b8f | 9012 | |
1ca2fd11 IR |
9013 | hook_call(bgp_snmp_init_stats, bgp); |
9014 | ||
585f1adc | 9015 | return CMD_SUCCESS; |
ddb5b488 PZ |
9016 | } |
9017 | ||
301ad80a PG |
9018 | DEFPY (af_routetarget_import, |
9019 | af_routetarget_import_cmd, | |
9a659715 | 9020 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9021 | NO_STR |
9022 | "Specify route target list\n" | |
9023 | "Specify route target list\n" | |
9a659715 PG |
9024 | "Specify route target list\n" |
9025 | "Specify route target list\n" | |
301ad80a PG |
9026 | "Flow-spec redirect type route target\n" |
9027 | "Import routes to this address-family\n" | |
9a659715 | 9028 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9029 | { |
9030 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9031 | int ret; | |
9032 | struct ecommunity *ecom = NULL; | |
301ad80a | 9033 | afi_t afi; |
9a659715 | 9034 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9035 | bool yes = true; |
9036 | bool rt6 = false; | |
301ad80a PG |
9037 | |
9038 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9039 | yes = false; |
301ad80a | 9040 | |
9a659715 PG |
9041 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9042 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9043 | rt6 = true; |
301ad80a | 9044 | |
0ca70ba5 | 9045 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9046 | if (afi == AFI_MAX) |
9047 | return CMD_WARNING_CONFIG_FAILED; | |
9048 | ||
9a659715 PG |
9049 | if (rt6 && afi != AFI_IP6) |
9050 | return CMD_WARNING_CONFIG_FAILED; | |
9051 | ||
301ad80a PG |
9052 | if (yes) { |
9053 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9054 | vty_out(vty, "%% Missing RTLIST\n"); | |
9055 | return CMD_WARNING_CONFIG_FAILED; | |
9056 | } | |
9a659715 | 9057 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9058 | if (ret != CMD_SUCCESS) |
9059 | return ret; | |
9060 | } | |
69b07479 DS |
9061 | |
9062 | if (yes) { | |
9063 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9064 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9065 | .import_redirect_rtlist); |
69b07479 DS |
9066 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9067 | ecommunity_dup(ecom); | |
9068 | } else { | |
9069 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9070 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9071 | .import_redirect_rtlist); |
69b07479 | 9072 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9073 | } |
69b07479 | 9074 | |
301ad80a PG |
9075 | if (ecom) |
9076 | ecommunity_free(&ecom); | |
9077 | ||
9078 | return CMD_SUCCESS; | |
9079 | } | |
9080 | ||
505e5056 | 9081 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9082 | address_family_ipv4_safi_cmd, |
9083 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9084 | "Enter Address Family command mode\n" | |
9085 | "Address Family\n" | |
9086 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9087 | { |
f51bae9c | 9088 | |
d62a17ae | 9089 | if (argc == 3) { |
585f1adc IR |
9090 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9091 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9092 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9093 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9094 | && safi != SAFI_EVPN) { |
31947174 MK |
9095 | vty_out(vty, |
9096 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9097 | return CMD_WARNING_CONFIG_FAILED; |
9098 | } | |
585f1adc IR |
9099 | vty->node = bgp_node_type(AFI_IP, safi); |
9100 | } else | |
9101 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9102 | |
d62a17ae | 9103 | return CMD_SUCCESS; |
718e3744 | 9104 | } |
9105 | ||
505e5056 | 9106 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9107 | address_family_ipv6_safi_cmd, |
9108 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9109 | "Enter Address Family command mode\n" | |
9110 | "Address Family\n" | |
9111 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9112 | { |
d62a17ae | 9113 | if (argc == 3) { |
585f1adc IR |
9114 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9115 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9116 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9117 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9118 | && safi != SAFI_EVPN) { |
31947174 MK |
9119 | vty_out(vty, |
9120 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9121 | return CMD_WARNING_CONFIG_FAILED; |
9122 | } | |
585f1adc IR |
9123 | vty->node = bgp_node_type(AFI_IP6, safi); |
9124 | } else | |
9125 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9126 | |
d62a17ae | 9127 | return CMD_SUCCESS; |
25ffbdc1 | 9128 | } |
718e3744 | 9129 | |
d6902373 | 9130 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9131 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9132 | address_family_vpnv4_cmd, |
8334fd5a | 9133 | "address-family vpnv4 [unicast]", |
718e3744 | 9134 | "Enter Address Family command mode\n" |
8c3deaae | 9135 | "Address Family\n" |
3a2d747c | 9136 | "Address Family modifier\n") |
718e3744 | 9137 | { |
d62a17ae | 9138 | vty->node = BGP_VPNV4_NODE; |
9139 | return CMD_SUCCESS; | |
718e3744 | 9140 | } |
9141 | ||
505e5056 | 9142 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9143 | address_family_vpnv6_cmd, |
8334fd5a | 9144 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9145 | "Enter Address Family command mode\n" |
8c3deaae | 9146 | "Address Family\n" |
3a2d747c | 9147 | "Address Family modifier\n") |
8ecd3266 | 9148 | { |
d62a17ae | 9149 | vty->node = BGP_VPNV6_NODE; |
9150 | return CMD_SUCCESS; | |
8ecd3266 | 9151 | } |
64e4a6c5 | 9152 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9153 | |
505e5056 | 9154 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9155 | address_family_evpn_cmd, |
7111c1a0 | 9156 | "address-family l2vpn evpn", |
4e0b7b6d | 9157 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9158 | "Address Family\n" |
9159 | "Address Family modifier\n") | |
4e0b7b6d | 9160 | { |
2131d5cf | 9161 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9162 | vty->node = BGP_EVPN_NODE; |
9163 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9164 | } |
9165 | ||
bfaab44d HS |
9166 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9167 | bgp_segment_routing_srv6_cmd, | |
9168 | "segment-routing srv6", | |
9169 | "Segment-Routing configuration\n" | |
9170 | "Segment-Routing SRv6 configuration\n") | |
9171 | { | |
9172 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9173 | bgp->srv6_enabled = true; |
bfaab44d HS |
9174 | vty->node = BGP_SRV6_NODE; |
9175 | return CMD_SUCCESS; | |
9176 | } | |
9177 | ||
0249b8b6 HS |
9178 | DEFUN (no_bgp_segment_routing_srv6, |
9179 | no_bgp_segment_routing_srv6_cmd, | |
9180 | "no segment-routing srv6", | |
9181 | NO_STR | |
9182 | "Segment-Routing configuration\n" | |
9183 | "Segment-Routing SRv6 configuration\n") | |
9184 | { | |
9185 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9186 | ||
9187 | if (strlen(bgp->srv6_locator_name) > 0) | |
9188 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9189 | return CMD_WARNING_CONFIG_FAILED; | |
9190 | ||
9191 | bgp->srv6_enabled = false; | |
9192 | return CMD_SUCCESS; | |
9193 | } | |
9194 | ||
a0281b2e HS |
9195 | DEFPY (bgp_srv6_locator, |
9196 | bgp_srv6_locator_cmd, | |
9197 | "locator NAME$name", | |
9198 | "Specify SRv6 locator\n" | |
9199 | "Specify SRv6 locator\n") | |
9200 | { | |
9201 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9202 | int ret; |
a0281b2e HS |
9203 | |
9204 | if (strlen(bgp->srv6_locator_name) > 0 | |
9205 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9206 | vty_out(vty, "srv6 locator is already configured\n"); | |
9207 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9208 | } |
9209 | ||
9210 | snprintf(bgp->srv6_locator_name, | |
9211 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9212 | |
7de4c885 | 9213 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9214 | if (ret < 0) |
9215 | return CMD_WARNING_CONFIG_FAILED; | |
9216 | ||
9217 | return CMD_SUCCESS; | |
9218 | } | |
9219 | ||
0249b8b6 HS |
9220 | DEFPY (no_bgp_srv6_locator, |
9221 | no_bgp_srv6_locator_cmd, | |
9222 | "no locator NAME$name", | |
9223 | NO_STR | |
9224 | "Specify SRv6 locator\n" | |
9225 | "Specify SRv6 locator\n") | |
9226 | { | |
9227 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9228 | ||
9229 | /* when locator isn't configured, do nothing */ | |
9230 | if (strlen(bgp->srv6_locator_name) < 1) | |
9231 | return CMD_SUCCESS; | |
9232 | ||
9233 | /* name validation */ | |
9234 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9235 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9236 | return CMD_WARNING_CONFIG_FAILED; | |
9237 | } | |
9238 | ||
9239 | /* unset locator */ | |
9240 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9241 | return CMD_WARNING_CONFIG_FAILED; | |
9242 | ||
9243 | return CMD_SUCCESS; | |
9244 | } | |
9245 | ||
ea372e81 HS |
9246 | DEFPY (show_bgp_srv6, |
9247 | show_bgp_srv6_cmd, | |
9248 | "show bgp segment-routing srv6", | |
9249 | SHOW_STR | |
9250 | BGP_STR | |
9251 | "BGP Segment Routing\n" | |
9252 | "BGP Segment Routing SRv6\n") | |
9253 | { | |
9254 | struct bgp *bgp; | |
9255 | struct listnode *node; | |
9256 | struct prefix_ipv6 *chunk; | |
9257 | struct bgp_srv6_function *func; | |
9258 | struct in6_addr *tovpn4_sid; | |
9259 | struct in6_addr *tovpn6_sid; | |
9260 | char buf[256]; | |
9261 | char buf_tovpn4_sid[256]; | |
9262 | char buf_tovpn6_sid[256]; | |
9263 | ||
9264 | bgp = bgp_get_default(); | |
96db4340 | 9265 | if (!bgp) |
ea372e81 HS |
9266 | return CMD_SUCCESS; |
9267 | ||
9268 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9269 | vty_out(vty, "locator_chunks:\n"); | |
9270 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { | |
9271 | prefix2str(chunk, buf, sizeof(buf)); | |
9272 | vty_out(vty, "- %s\n", buf); | |
9273 | } | |
9274 | ||
9275 | vty_out(vty, "functions:\n"); | |
9276 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
9277 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
9278 | vty_out(vty, "- sid: %s\n", buf); | |
9279 | vty_out(vty, " locator: %s\n", func->locator_name); | |
9280 | } | |
9281 | ||
9282 | vty_out(vty, "bgps:\n"); | |
9283 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9284 | vty_out(vty, "- name: %s\n", | |
9285 | bgp->name ? bgp->name : "default"); | |
9286 | ||
9287 | tovpn4_sid = bgp->vpn_policy[AFI_IP].tovpn_sid; | |
9288 | tovpn6_sid = bgp->vpn_policy[AFI_IP6].tovpn_sid; | |
9289 | if (tovpn4_sid) | |
9290 | inet_ntop(AF_INET6, tovpn4_sid, buf_tovpn4_sid, | |
9291 | sizeof(buf_tovpn4_sid)); | |
9292 | if (tovpn6_sid) | |
9293 | inet_ntop(AF_INET6, tovpn6_sid, buf_tovpn6_sid, | |
9294 | sizeof(buf_tovpn6_sid)); | |
9295 | ||
9296 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %s\n", | |
9297 | tovpn4_sid ? buf_tovpn4_sid : "none"); | |
9298 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %s\n", | |
9299 | tovpn6_sid ? buf_tovpn6_sid : "none"); | |
9300 | } | |
9301 | ||
9302 | return CMD_SUCCESS; | |
9303 | } | |
9304 | ||
505e5056 | 9305 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9306 | exit_address_family_cmd, |
9307 | "exit-address-family", | |
9308 | "Exit from Address Family configuration mode\n") | |
9309 | { | |
d62a17ae | 9310 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9311 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9312 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9313 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9314 | || vty->node == BGP_EVPN_NODE |
9315 | || vty->node == BGP_FLOWSPECV4_NODE | |
9316 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9317 | vty->node = BGP_NODE; |
9318 | return CMD_SUCCESS; | |
718e3744 | 9319 | } |
6b0655a2 | 9320 | |
8ad7271d | 9321 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9322 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9323 | const char *ip_str, afi_t afi, safi_t safi, | |
9324 | struct prefix_rd *prd) | |
9325 | { | |
9326 | int ret; | |
9327 | struct prefix match; | |
9bcb3eef DS |
9328 | struct bgp_dest *dest; |
9329 | struct bgp_dest *rm; | |
d62a17ae | 9330 | struct bgp *bgp; |
9331 | struct bgp_table *table; | |
9332 | struct bgp_table *rib; | |
9333 | ||
9334 | /* BGP structure lookup. */ | |
9335 | if (view_name) { | |
9336 | bgp = bgp_lookup_by_name(view_name); | |
9337 | if (bgp == NULL) { | |
9338 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9339 | view_name); | |
9340 | return CMD_WARNING; | |
9341 | } | |
9342 | } else { | |
9343 | bgp = bgp_get_default(); | |
9344 | if (bgp == NULL) { | |
9345 | vty_out(vty, "%% No BGP process is configured\n"); | |
9346 | return CMD_WARNING; | |
9347 | } | |
9348 | } | |
9349 | ||
9350 | /* Check IP address argument. */ | |
9351 | ret = str2prefix(ip_str, &match); | |
9352 | if (!ret) { | |
9353 | vty_out(vty, "%% address is malformed\n"); | |
9354 | return CMD_WARNING; | |
9355 | } | |
9356 | ||
9357 | match.family = afi2family(afi); | |
9358 | rib = bgp->rib[afi][safi]; | |
9359 | ||
9360 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9361 | for (dest = bgp_table_top(rib); dest; |
9362 | dest = bgp_route_next(dest)) { | |
9363 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9364 | |
9bcb3eef | 9365 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9366 | continue; |
9367 | ||
9bcb3eef | 9368 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9369 | if (table == NULL) |
9370 | continue; | |
9371 | ||
4953391b DA |
9372 | rm = bgp_node_match(table, &match); |
9373 | if (rm != NULL) { | |
b54892e0 | 9374 | const struct prefix *rm_p = |
9bcb3eef | 9375 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9376 | |
9377 | if (rm_p->prefixlen == match.prefixlen) { | |
9378 | SET_FLAG(rm->flags, | |
9379 | BGP_NODE_USER_CLEAR); | |
9380 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9381 | } |
9bcb3eef | 9382 | bgp_dest_unlock_node(rm); |
d62a17ae | 9383 | } |
9384 | } | |
9385 | } else { | |
4953391b DA |
9386 | dest = bgp_node_match(rib, &match); |
9387 | if (dest != NULL) { | |
9bcb3eef | 9388 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 9389 | |
9bcb3eef DS |
9390 | if (dest_p->prefixlen == match.prefixlen) { |
9391 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9392 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9393 | } |
9bcb3eef | 9394 | bgp_dest_unlock_node(dest); |
d62a17ae | 9395 | } |
9396 | } | |
9397 | ||
9398 | return CMD_SUCCESS; | |
8ad7271d DS |
9399 | } |
9400 | ||
b09b5ae0 | 9401 | /* one clear bgp command to rule them all */ |
718e3744 | 9402 | DEFUN (clear_ip_bgp_all, |
9403 | clear_ip_bgp_all_cmd, | |
453c92f6 | 9404 | "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 | 9405 | CLEAR_STR |
9406 | IP_STR | |
9407 | BGP_STR | |
838758ac | 9408 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9409 | BGP_AFI_HELP_STR |
fd5e7b70 | 9410 | "Address Family\n" |
510afcd6 | 9411 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9412 | "Address Family modifier\n" |
b09b5ae0 | 9413 | "Clear all peers\n" |
453c92f6 | 9414 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9415 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9416 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9417 | "Clear peers with the AS number\n" |
9418 | "Clear all external peers\n" | |
718e3744 | 9419 | "Clear all members of peer-group\n" |
b09b5ae0 | 9420 | "BGP peer-group name\n" |
b09b5ae0 DW |
9421 | BGP_SOFT_STR |
9422 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9423 | BGP_SOFT_OUT_STR |
9424 | BGP_SOFT_IN_STR | |
9425 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 9426 | BGP_SOFT_OUT_STR) |
718e3744 | 9427 | { |
d62a17ae | 9428 | char *vrf = NULL; |
9429 | ||
dc912615 DS |
9430 | afi_t afi = AFI_UNSPEC; |
9431 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9432 | enum clear_sort clr_sort = clear_peer; |
9433 | enum bgp_clear_type clr_type; | |
9434 | char *clr_arg = NULL; | |
9435 | ||
9436 | int idx = 0; | |
9437 | ||
9438 | /* clear [ip] bgp */ | |
9439 | if (argv_find(argv, argc, "ip", &idx)) | |
9440 | afi = AFI_IP; | |
9441 | ||
9a8bdf1c PG |
9442 | /* [<vrf> VIEWVRFNAME] */ |
9443 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9444 | vrf = argv[idx + 1]->arg; | |
9445 | idx += 2; | |
9446 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9447 | vrf = NULL; | |
9448 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9449 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9450 | vrf = argv[idx + 1]->arg; |
9451 | idx += 2; | |
9452 | } | |
d62a17ae | 9453 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9454 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9455 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9456 | ||
d7b9898c | 9457 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9458 | if (argv_find(argv, argc, "*", &idx)) { |
9459 | clr_sort = clear_all; | |
9460 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9461 | clr_sort = clear_peer; | |
9462 | clr_arg = argv[idx]->arg; | |
9463 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9464 | clr_sort = clear_peer; | |
9465 | clr_arg = argv[idx]->arg; | |
9466 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9467 | clr_sort = clear_group; | |
9468 | idx++; | |
9469 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9470 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9471 | clr_sort = clear_peer; |
9472 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9473 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9474 | clr_sort = clear_peer; | |
9475 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9476 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9477 | clr_sort = clear_as; | |
9478 | clr_arg = argv[idx]->arg; | |
9479 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9480 | clr_sort = clear_external; | |
9481 | } | |
9482 | ||
9483 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
9484 | if (argv_find(argv, argc, "soft", &idx)) { | |
9485 | if (argv_find(argv, argc, "in", &idx) | |
9486 | || argv_find(argv, argc, "out", &idx)) | |
9487 | clr_type = strmatch(argv[idx]->text, "in") | |
9488 | ? BGP_CLEAR_SOFT_IN | |
9489 | : BGP_CLEAR_SOFT_OUT; | |
9490 | else | |
9491 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9492 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9493 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9494 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9495 | : BGP_CLEAR_SOFT_IN; | |
9496 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9497 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9498 | } else | |
9499 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9500 | ||
1ca2fd11 | 9501 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 9502 | } |
01080f7c | 9503 | |
8ad7271d DS |
9504 | DEFUN (clear_ip_bgp_prefix, |
9505 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9506 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9507 | CLEAR_STR |
9508 | IP_STR | |
9509 | BGP_STR | |
838758ac | 9510 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9511 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9512 | "IPv4 prefix\n") |
8ad7271d | 9513 | { |
d62a17ae | 9514 | char *vrf = NULL; |
9515 | char *prefix = NULL; | |
8ad7271d | 9516 | |
d62a17ae | 9517 | int idx = 0; |
01080f7c | 9518 | |
d62a17ae | 9519 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9520 | if (argv_find(argv, argc, "vrf", &idx)) { |
9521 | vrf = argv[idx + 1]->arg; | |
9522 | idx += 2; | |
9523 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9524 | vrf = NULL; | |
9525 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9526 | /* [<view> VIEWVRFNAME] */ | |
9527 | vrf = argv[idx + 1]->arg; | |
9528 | idx += 2; | |
9529 | } | |
0c7b1b01 | 9530 | |
d62a17ae | 9531 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9532 | |
d62a17ae | 9533 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9534 | } |
8ad7271d | 9535 | |
b09b5ae0 DW |
9536 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9537 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9538 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9539 | CLEAR_STR |
3a2d747c | 9540 | IP_STR |
718e3744 | 9541 | BGP_STR |
8c3deaae | 9542 | "Address Family\n" |
46f296b4 | 9543 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9544 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9545 | "IPv6 prefix\n") |
718e3744 | 9546 | { |
9b475e76 PG |
9547 | int idx_safi = 0; |
9548 | int idx_ipv6_prefix = 0; | |
9549 | safi_t safi = SAFI_UNICAST; | |
9550 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9551 | argv[idx_ipv6_prefix]->arg : NULL; | |
9552 | ||
9553 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9554 | return bgp_clear_prefix( |
9b475e76 PG |
9555 | vty, NULL, prefix, AFI_IP6, |
9556 | safi, NULL); | |
838758ac | 9557 | } |
01080f7c | 9558 | |
b09b5ae0 DW |
9559 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9560 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9561 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9562 | CLEAR_STR |
3a2d747c | 9563 | IP_STR |
718e3744 | 9564 | BGP_STR |
838758ac | 9565 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9566 | "Address Family\n" |
46f296b4 | 9567 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9568 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9569 | "IPv6 prefix\n") |
718e3744 | 9570 | { |
9b475e76 | 9571 | int idx_safi = 0; |
9a8bdf1c | 9572 | int idx_vrfview = 0; |
9b475e76 PG |
9573 | int idx_ipv6_prefix = 0; |
9574 | safi_t safi = SAFI_UNICAST; | |
9575 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9576 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9577 | char *vrfview = NULL; |
9b475e76 | 9578 | |
9a8bdf1c PG |
9579 | /* [<view|vrf> VIEWVRFNAME] */ |
9580 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9581 | vrfview = argv[idx_vrfview + 1]->arg; | |
9582 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9583 | vrfview = NULL; | |
9584 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9585 | /* [<view> VIEWVRFNAME] */ | |
9586 | vrfview = argv[idx_vrfview + 1]->arg; | |
9587 | } | |
9b475e76 PG |
9588 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9589 | ||
d62a17ae | 9590 | return bgp_clear_prefix( |
9b475e76 PG |
9591 | vty, vrfview, prefix, |
9592 | AFI_IP6, safi, NULL); | |
718e3744 | 9593 | } |
9594 | ||
b09b5ae0 DW |
9595 | DEFUN (show_bgp_views, |
9596 | show_bgp_views_cmd, | |
d6e3c605 | 9597 | "show [ip] bgp views", |
b09b5ae0 | 9598 | SHOW_STR |
d6e3c605 | 9599 | IP_STR |
01080f7c | 9600 | BGP_STR |
b09b5ae0 | 9601 | "Show the defined BGP views\n") |
01080f7c | 9602 | { |
d62a17ae | 9603 | struct list *inst = bm->bgp; |
9604 | struct listnode *node; | |
9605 | struct bgp *bgp; | |
01080f7c | 9606 | |
d62a17ae | 9607 | vty_out(vty, "Defined BGP views:\n"); |
9608 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9609 | /* Skip VRFs. */ | |
9610 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9611 | continue; | |
9612 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9613 | bgp->as); | |
9614 | } | |
e52702f2 | 9615 | |
d62a17ae | 9616 | return CMD_SUCCESS; |
e0081f70 ML |
9617 | } |
9618 | ||
8386ac43 | 9619 | DEFUN (show_bgp_vrfs, |
9620 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9621 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9622 | SHOW_STR |
d6e3c605 | 9623 | IP_STR |
8386ac43 | 9624 | BGP_STR |
9625 | "Show BGP VRFs\n" | |
9973d184 | 9626 | JSON_STR) |
8386ac43 | 9627 | { |
fe1dc5a3 | 9628 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9629 | struct list *inst = bm->bgp; |
9630 | struct listnode *node; | |
9631 | struct bgp *bgp; | |
9f049418 | 9632 | bool uj = use_json(argc, argv); |
d62a17ae | 9633 | json_object *json = NULL; |
9634 | json_object *json_vrfs = NULL; | |
9635 | int count = 0; | |
d62a17ae | 9636 | |
d62a17ae | 9637 | if (uj) { |
9638 | json = json_object_new_object(); | |
9639 | json_vrfs = json_object_new_object(); | |
9640 | } | |
9641 | ||
9642 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9643 | const char *name, *type; | |
9644 | struct peer *peer; | |
7fe96307 | 9645 | struct listnode *node2, *nnode2; |
d62a17ae | 9646 | int peers_cfg, peers_estb; |
9647 | json_object *json_vrf = NULL; | |
d62a17ae | 9648 | |
9649 | /* Skip Views. */ | |
9650 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9651 | continue; | |
9652 | ||
9653 | count++; | |
efb4077a | 9654 | if (!uj && count == 1) { |
fe1dc5a3 | 9655 | vty_out(vty, |
efb4077a | 9656 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9657 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9658 | "#PeersEstb", "Name"); |
9659 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9660 | "L3-VNI", "RouterMAC", "Interface"); | |
9661 | } | |
d62a17ae | 9662 | |
9663 | peers_cfg = peers_estb = 0; | |
9664 | if (uj) | |
9665 | json_vrf = json_object_new_object(); | |
9666 | ||
9667 | ||
7fe96307 | 9668 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9669 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9670 | continue; | |
9671 | peers_cfg++; | |
feb17238 | 9672 | if (peer_established(peer)) |
d62a17ae | 9673 | peers_estb++; |
9674 | } | |
9675 | ||
9676 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 9677 | name = VRF_DEFAULT_NAME; |
d62a17ae | 9678 | type = "DFLT"; |
9679 | } else { | |
9680 | name = bgp->name; | |
9681 | type = "VRF"; | |
9682 | } | |
9683 | ||
a8bf7d9c | 9684 | |
d62a17ae | 9685 | if (uj) { |
a4d82a8a PZ |
9686 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9687 | ? -1 | |
9688 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
9689 | char buf[BUFSIZ] = {0}; |
9690 | ||
d62a17ae | 9691 | json_object_string_add(json_vrf, "type", type); |
9692 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
c949c771 DA |
9693 | json_object_string_addf(json_vrf, "routerId", "%pI4", |
9694 | &bgp->router_id); | |
d62a17ae | 9695 | json_object_int_add(json_vrf, "numConfiguredPeers", |
9696 | peers_cfg); | |
9697 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9698 | peers_estb); | |
9699 | ||
fe1dc5a3 | 9700 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
9701 | json_object_string_add( |
9702 | json_vrf, "rmac", | |
9703 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
9704 | json_object_string_add(json_vrf, "interface", |
9705 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9706 | bgp->vrf_id)); | |
d62a17ae | 9707 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 9708 | } else { |
23d0a753 | 9709 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
9710 | type, |
9711 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9712 | : (int)bgp->vrf_id, | |
23d0a753 | 9713 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
9714 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
9715 | bgp->l3vni, | |
9716 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9717 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9718 | bgp->vrf_id)); | |
9719 | } | |
d62a17ae | 9720 | } |
9721 | ||
9722 | if (uj) { | |
9723 | json_object_object_add(json, "vrfs", json_vrfs); | |
9724 | ||
9725 | json_object_int_add(json, "totalVrfs", count); | |
9726 | ||
996c9314 LB |
9727 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9728 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9729 | json_object_free(json); |
9730 | } else { | |
9731 | if (count) | |
9732 | vty_out(vty, | |
9733 | "\nTotal number of VRFs (including default): %d\n", | |
9734 | count); | |
9735 | } | |
9736 | ||
9737 | return CMD_SUCCESS; | |
8386ac43 | 9738 | } |
9739 | ||
48ecf8f5 DS |
9740 | DEFUN (show_bgp_mac_hash, |
9741 | show_bgp_mac_hash_cmd, | |
9742 | "show bgp mac hash", | |
9743 | SHOW_STR | |
9744 | BGP_STR | |
9745 | "Mac Address\n" | |
9746 | "Mac Address database\n") | |
9747 | { | |
9748 | bgp_mac_dump_table(vty); | |
9749 | ||
9750 | return CMD_SUCCESS; | |
9751 | } | |
acf71666 | 9752 | |
e3b78da8 | 9753 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 9754 | { |
0291c246 | 9755 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 9756 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 9757 | |
23d0a753 | 9758 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
9759 | } |
9760 | ||
9761 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9762 | { | |
9763 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 9764 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
9765 | |
9766 | vty_out(vty, "Tunnel-ip database:\n"); | |
9767 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 9768 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
9769 | vty); |
9770 | } | |
9771 | ||
15c81ca4 DS |
9772 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
9773 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9774 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
9775 | "martian next-hops\n" |
9776 | "martian next-hop database\n") | |
acf71666 | 9777 | { |
0291c246 | 9778 | struct bgp *bgp = NULL; |
15c81ca4 | 9779 | int idx = 0; |
9a8bdf1c PG |
9780 | char *name = NULL; |
9781 | ||
9782 | /* [<vrf> VIEWVRFNAME] */ | |
9783 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9784 | name = argv[idx + 1]->arg; | |
9785 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9786 | name = NULL; | |
9787 | } else if (argv_find(argv, argc, "view", &idx)) | |
9788 | /* [<view> VIEWVRFNAME] */ | |
9789 | name = argv[idx + 1]->arg; | |
9790 | if (name) | |
9791 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
9792 | else |
9793 | bgp = bgp_get_default(); | |
acf71666 | 9794 | |
acf71666 MK |
9795 | if (!bgp) { |
9796 | vty_out(vty, "%% No BGP process is configured\n"); | |
9797 | return CMD_WARNING; | |
9798 | } | |
9799 | bgp_show_martian_nexthops(vty, bgp); | |
9800 | ||
9801 | return CMD_SUCCESS; | |
9802 | } | |
9803 | ||
f412b39a | 9804 | DEFUN (show_bgp_memory, |
4bf6a362 | 9805 | show_bgp_memory_cmd, |
7fa12b13 | 9806 | "show [ip] bgp memory", |
4bf6a362 | 9807 | SHOW_STR |
3a2d747c | 9808 | IP_STR |
4bf6a362 PJ |
9809 | BGP_STR |
9810 | "Global BGP memory statistics\n") | |
9811 | { | |
d62a17ae | 9812 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
9813 | unsigned long count; | |
9814 | ||
9815 | /* RIB related usage stats */ | |
9816 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9817 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9818 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 9819 | count * sizeof(struct bgp_dest))); |
d62a17ae | 9820 | |
9821 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9822 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
9823 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 9824 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 9825 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
9826 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
9827 | count, | |
4b7e6066 DS |
9828 | mtype_memstr( |
9829 | memstrbuf, sizeof(memstrbuf), | |
9830 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 9831 | |
9832 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
9833 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
9834 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9835 | count * sizeof(struct bgp_static))); | |
9836 | ||
9837 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
9838 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
9839 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9840 | count * sizeof(struct bpacket))); | |
9841 | ||
9842 | /* Adj-In/Out */ | |
9843 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
9844 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
9845 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9846 | count * sizeof(struct bgp_adj_in))); | |
9847 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
9848 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
9849 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9850 | count * sizeof(struct bgp_adj_out))); | |
9851 | ||
9852 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
9853 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
9854 | count, | |
9855 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9856 | count * sizeof(struct bgp_nexthop_cache))); | |
9857 | ||
9858 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
9859 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
9860 | count, | |
9861 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9862 | count * sizeof(struct bgp_damp_info))); | |
9863 | ||
9864 | /* Attributes */ | |
9865 | count = attr_count(); | |
9866 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
9867 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9868 | count * sizeof(struct attr))); | |
9869 | ||
9870 | if ((count = attr_unknown_count())) | |
9871 | vty_out(vty, "%ld unknown attributes\n", count); | |
9872 | ||
9873 | /* AS_PATH attributes */ | |
9874 | count = aspath_count(); | |
9875 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
9876 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9877 | count * sizeof(struct aspath))); | |
9878 | ||
9879 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
9880 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
9881 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9882 | count * sizeof(struct assegment))); | |
9883 | ||
9884 | /* Other attributes */ | |
9885 | if ((count = community_count())) | |
9886 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9887 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9888 | count * sizeof(struct community))); | |
d62a17ae | 9889 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
9890 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9891 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9892 | count * sizeof(struct ecommunity))); | |
d62a17ae | 9893 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
9894 | vty_out(vty, | |
9895 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
9896 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9897 | count * sizeof(struct lcommunity))); | |
d62a17ae | 9898 | |
9899 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
9900 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
9901 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9902 | count * sizeof(struct cluster_list))); | |
9903 | ||
9904 | /* Peer related usage */ | |
9905 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
9906 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
9907 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9908 | count * sizeof(struct peer))); | |
9909 | ||
9910 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
9911 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
9912 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9913 | count * sizeof(struct peer_group))); | |
9914 | ||
9915 | /* Other */ | |
d62a17ae | 9916 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
9917 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
9918 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9919 | count * sizeof(regex_t))); | |
d62a17ae | 9920 | return CMD_SUCCESS; |
4bf6a362 | 9921 | } |
fee0f4c6 | 9922 | |
57a9c8a8 DS |
9923 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
9924 | { | |
9925 | json_object *bestpath = json_object_new_object(); | |
9926 | ||
892fedb6 | 9927 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
9928 | json_object_string_add(bestpath, "asPath", "ignore"); |
9929 | ||
892fedb6 | 9930 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
9931 | json_object_string_add(bestpath, "asPath", "confed"); |
9932 | ||
892fedb6 DA |
9933 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
9934 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 9935 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9936 | "as-set"); |
9937 | else | |
a4d82a8a | 9938 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9939 | "true"); |
9940 | } else | |
a4d82a8a | 9941 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 9942 | |
ee88563a JM |
9943 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
9944 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
9945 | ||
892fedb6 | 9946 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 9947 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
9948 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
9949 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
9950 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 9951 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 9952 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
9953 | json_object_string_add(bestpath, "med", |
9954 | "missing-as-worst"); | |
9955 | else | |
9956 | json_object_string_add(bestpath, "med", "true"); | |
9957 | } | |
9958 | ||
9959 | json_object_object_add(json, "bestPath", bestpath); | |
9960 | } | |
9961 | ||
3577f1c5 DD |
9962 | /* Print the error code/subcode for why the peer is down */ |
9963 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
9964 | json_object *json_peer, bool use_json) | |
9965 | { | |
9966 | const char *code_str; | |
9967 | const char *subcode_str; | |
9968 | ||
9969 | if (use_json) { | |
9970 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9971 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9972 | char errorcodesubcode_hexstr[5]; | |
9973 | char errorcodesubcode_str[256]; | |
9974 | ||
9975 | code_str = bgp_notify_code_str(peer->notify.code); | |
9976 | subcode_str = bgp_notify_subcode_str( | |
9977 | peer->notify.code, | |
9978 | peer->notify.subcode); | |
9979 | ||
772270f3 QY |
9980 | snprintf(errorcodesubcode_hexstr, |
9981 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
9982 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
9983 | json_object_string_add(json_peer, |
9984 | "lastErrorCodeSubcode", | |
9985 | errorcodesubcode_hexstr); | |
9986 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9987 | code_str, subcode_str); | |
9988 | json_object_string_add(json_peer, | |
9989 | "lastNotificationReason", | |
9990 | errorcodesubcode_str); | |
9991 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9992 | && peer->notify.code == BGP_NOTIFY_CEASE | |
9993 | && (peer->notify.subcode | |
9994 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9995 | || peer->notify.subcode | |
9996 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9997 | && peer->notify.length) { | |
9998 | char msgbuf[1024]; | |
9999 | const char *msg_str; | |
10000 | ||
10001 | msg_str = bgp_notify_admin_message( | |
10002 | msgbuf, sizeof(msgbuf), | |
10003 | (uint8_t *)peer->notify.data, | |
10004 | peer->notify.length); | |
10005 | if (msg_str) | |
10006 | json_object_string_add( | |
10007 | json_peer, | |
10008 | "lastShutdownDescription", | |
10009 | msg_str); | |
10010 | } | |
10011 | ||
c258527b | 10012 | } |
3577f1c5 DD |
10013 | json_object_string_add(json_peer, "lastResetDueTo", |
10014 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10015 | json_object_int_add(json_peer, "lastResetCode", |
10016 | peer->last_reset); | |
3577f1c5 DD |
10017 | } else { |
10018 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10019 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10020 | code_str = bgp_notify_code_str(peer->notify.code); | |
10021 | subcode_str = | |
10022 | bgp_notify_subcode_str(peer->notify.code, | |
10023 | peer->notify.subcode); | |
10024 | vty_out(vty, " Notification %s (%s%s)\n", | |
10025 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10026 | ? "sent" | |
10027 | : "received", | |
10028 | code_str, subcode_str); | |
10029 | } else { | |
e91c24c8 | 10030 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10031 | peer_down_str[(int)peer->last_reset]); |
10032 | } | |
10033 | } | |
10034 | } | |
10035 | ||
10036 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10037 | safi_t safi) | |
10038 | { | |
feb17238 | 10039 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10040 | } |
10041 | ||
10042 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10043 | struct peer *peer, json_object *json_peer, | |
10044 | int max_neighbor_width, bool use_json) | |
10045 | { | |
10046 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10047 | int len; | |
10048 | ||
10049 | if (use_json) { | |
10050 | if (peer_dynamic_neighbor(peer)) | |
10051 | json_object_boolean_true_add(json_peer, | |
10052 | "dynamicPeer"); | |
10053 | if (peer->hostname) | |
10054 | json_object_string_add(json_peer, "hostname", | |
10055 | peer->hostname); | |
10056 | ||
10057 | if (peer->domainname) | |
10058 | json_object_string_add(json_peer, "domainname", | |
10059 | peer->domainname); | |
10060 | json_object_int_add(json_peer, "connectionsEstablished", | |
10061 | peer->established); | |
10062 | json_object_int_add(json_peer, "connectionsDropped", | |
10063 | peer->dropped); | |
10064 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10065 | use_json, json_peer); | |
feb17238 | 10066 | if (peer_established(peer)) |
3577f1c5 DD |
10067 | json_object_string_add(json_peer, "lastResetDueTo", |
10068 | "AFI/SAFI Not Negotiated"); | |
10069 | else | |
10070 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10071 | } else { | |
10072 | dn_flag[1] = '\0'; | |
10073 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10074 | if (peer->hostname | |
892fedb6 | 10075 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10076 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10077 | peer->hostname, peer->host); | |
10078 | else | |
10079 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10080 | ||
10081 | /* pad the neighbor column with spaces */ | |
10082 | if (len < max_neighbor_width) | |
10083 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10084 | " "); | |
e91c24c8 | 10085 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10086 | peer->dropped, |
10087 | peer_uptime(peer->uptime, timebuf, | |
10088 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10089 | if (peer_established(peer)) |
3577f1c5 DD |
10090 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10091 | else | |
10092 | bgp_show_peer_reset(vty, peer, NULL, | |
10093 | false); | |
10094 | } | |
10095 | } | |
c258527b | 10096 | |
565e9ddd | 10097 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10098 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10099 | { | |
10100 | static char stripped[BUFSIZ]; | |
cb75bb31 DA |
10101 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; |
10102 | ||
cb75bb31 DA |
10103 | strlcpy(stripped, desc, len + 1); |
10104 | ||
10105 | return stripped; | |
10106 | } | |
3577f1c5 | 10107 | |
8c1d4cd5 LS |
10108 | /* Determine whether var peer should be filtered out of the summary. */ |
10109 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10110 | struct peer *fpeer, int as_type, | |
10111 | as_t as) | |
10112 | { | |
10113 | ||
10114 | /* filter neighbor XXXX */ | |
10115 | if (fpeer && fpeer != peer) | |
10116 | return true; | |
10117 | ||
10118 | /* filter remote-as (internal|external) */ | |
10119 | if (as_type != AS_UNSPECIFIED) { | |
10120 | if (peer->as_type == AS_SPECIFIED) { | |
10121 | if (as_type == AS_INTERNAL) { | |
10122 | if (peer->as != peer->local_as) | |
10123 | return true; | |
10124 | } else if (peer->as == peer->local_as) | |
10125 | return true; | |
10126 | } else if (as_type != peer->as_type) | |
10127 | return true; | |
10128 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10129 | return true; | |
10130 | ||
10131 | return false; | |
10132 | } | |
10133 | ||
565e9ddd DA |
10134 | /* Show BGP peer's summary information. |
10135 | * | |
10136 | * Peer's description is stripped according to if `wide` option is given | |
10137 | * or not. | |
10138 | * | |
10139 | * When adding new columns to `show bgp summary` output, please make | |
10140 | * sure `Desc` is the lastest column to show because it can contain | |
10141 | * whitespaces and the whole output will be tricky. | |
10142 | */ | |
d62a17ae | 10143 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10144 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10145 | uint16_t show_flags) |
d62a17ae | 10146 | { |
10147 | struct peer *peer; | |
10148 | struct listnode *node, *nnode; | |
10149 | unsigned int count = 0, dn_count = 0; | |
10150 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10151 | char neighbor_buf[VTY_BUFSIZ]; | |
10152 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10153 | int len, failed_count = 0; |
ce1944f0 | 10154 | unsigned int filtered_count = 0; |
d62a17ae | 10155 | int max_neighbor_width = 0; |
10156 | int pfx_rcd_safi; | |
3c13337d | 10157 | json_object *json = NULL; |
d62a17ae | 10158 | json_object *json_peer = NULL; |
10159 | json_object *json_peers = NULL; | |
50e05855 | 10160 | struct peer_af *paf; |
d3ada366 | 10161 | struct bgp_filter *filter; |
85eeb029 DA |
10162 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10163 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10164 | bool show_established = | |
10165 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10166 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10167 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10168 | |
10169 | /* labeled-unicast routes are installed in the unicast table so in order | |
10170 | * to | |
10171 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10172 | */ | |
3577f1c5 | 10173 | |
d62a17ae | 10174 | if (safi == SAFI_LABELED_UNICAST) |
10175 | pfx_rcd_safi = SAFI_UNICAST; | |
10176 | else | |
10177 | pfx_rcd_safi = safi; | |
10178 | ||
10179 | if (use_json) { | |
3c13337d | 10180 | json = json_object_new_object(); |
d62a17ae | 10181 | json_peers = json_object_new_object(); |
3577f1c5 | 10182 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10183 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10184 | as_type, as)) { | |
ce1944f0 | 10185 | filtered_count++; |
8c1d4cd5 LS |
10186 | count++; |
10187 | continue; | |
10188 | } | |
10189 | ||
3577f1c5 DD |
10190 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10191 | continue; | |
10192 | ||
10193 | if (peer->afc[afi][safi]) { | |
10194 | /* See if we have at least a single failed peer */ | |
10195 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10196 | failed_count++; | |
10197 | count++; | |
10198 | } | |
10199 | if (peer_dynamic_neighbor(peer)) | |
10200 | dn_count++; | |
10201 | } | |
c258527b | 10202 | |
d62a17ae | 10203 | } else { |
10204 | /* Loop over all neighbors that will be displayed to determine | |
10205 | * how many | |
10206 | * characters are needed for the Neighbor column | |
10207 | */ | |
10208 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10209 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10210 | as_type, as)) { | |
ce1944f0 | 10211 | filtered_count++; |
8c1d4cd5 LS |
10212 | count++; |
10213 | continue; | |
10214 | } | |
10215 | ||
d62a17ae | 10216 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10217 | continue; | |
10218 | ||
10219 | if (peer->afc[afi][safi]) { | |
10220 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10221 | if (peer_dynamic_neighbor(peer)) | |
10222 | dn_flag[0] = '*'; | |
10223 | ||
10224 | if (peer->hostname | |
892fedb6 DA |
10225 | && CHECK_FLAG(bgp->flags, |
10226 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10227 | snprintf(neighbor_buf, |
10228 | sizeof(neighbor_buf), | |
10229 | "%s%s(%s) ", dn_flag, | |
10230 | peer->hostname, peer->host); | |
d62a17ae | 10231 | else |
772270f3 QY |
10232 | snprintf(neighbor_buf, |
10233 | sizeof(neighbor_buf), "%s%s ", | |
10234 | dn_flag, peer->host); | |
d62a17ae | 10235 | |
10236 | len = strlen(neighbor_buf); | |
10237 | ||
10238 | if (len > max_neighbor_width) | |
10239 | max_neighbor_width = len; | |
c258527b | 10240 | |
3577f1c5 DD |
10241 | /* See if we have at least a single failed peer */ |
10242 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10243 | failed_count++; | |
10244 | count++; | |
d62a17ae | 10245 | } |
10246 | } | |
f933309e | 10247 | |
d62a17ae | 10248 | /* Originally we displayed the Neighbor column as 16 |
10249 | * characters wide so make that the default | |
10250 | */ | |
10251 | if (max_neighbor_width < neighbor_col_default_width) | |
10252 | max_neighbor_width = neighbor_col_default_width; | |
10253 | } | |
f933309e | 10254 | |
3577f1c5 DD |
10255 | if (show_failed && !failed_count) { |
10256 | if (use_json) { | |
10257 | json_object_int_add(json, "failedPeersCount", 0); | |
10258 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10259 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
10260 | |
10261 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
10262 | json, JSON_C_TO_STRING_PRETTY)); | |
10263 | json_object_free(json); | |
10264 | } else { | |
10265 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
10266 | } |
10267 | return CMD_SUCCESS; | |
10268 | } | |
c258527b | 10269 | |
3577f1c5 | 10270 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 10271 | filtered_count = 0; |
800867d8 | 10272 | dn_count = 0; |
d62a17ae | 10273 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10274 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10275 | continue; | |
10276 | ||
ea47320b DL |
10277 | if (!peer->afc[afi][safi]) |
10278 | continue; | |
d62a17ae | 10279 | |
ea47320b DL |
10280 | if (!count) { |
10281 | unsigned long ents; | |
10282 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10283 | int64_t vrf_id_ui; |
d62a17ae | 10284 | |
a4d82a8a PZ |
10285 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10286 | ? -1 | |
10287 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10288 | |
10289 | /* Usage summary and header */ | |
10290 | if (use_json) { | |
c949c771 DA |
10291 | json_object_string_addf(json, "routerId", |
10292 | "%pI4", | |
10293 | &bgp->router_id); | |
60466a63 QY |
10294 | json_object_int_add(json, "as", bgp->as); |
10295 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10296 | json_object_string_add( |
10297 | json, "vrfName", | |
10298 | (bgp->inst_type | |
10299 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10300 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10301 | : bgp->name); |
10302 | } else { | |
10303 | vty_out(vty, | |
23d0a753 DA |
10304 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10305 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10306 | bgp->vrf_id == VRF_UNKNOWN |
10307 | ? -1 | |
10308 | : (int)bgp->vrf_id); | |
ea47320b DL |
10309 | vty_out(vty, "\n"); |
10310 | } | |
d62a17ae | 10311 | |
ea47320b | 10312 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10313 | if (use_json) { |
ea47320b | 10314 | json_object_int_add( |
60466a63 | 10315 | json, "updateDelayLimit", |
ea47320b | 10316 | bgp->v_update_delay); |
d62a17ae | 10317 | |
ea47320b DL |
10318 | if (bgp->v_update_delay |
10319 | != bgp->v_establish_wait) | |
d62a17ae | 10320 | json_object_int_add( |
10321 | json, | |
ea47320b DL |
10322 | "updateDelayEstablishWait", |
10323 | bgp->v_establish_wait); | |
d62a17ae | 10324 | |
60466a63 | 10325 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10326 | json_object_string_add( |
10327 | json, | |
10328 | "updateDelayFirstNeighbor", | |
10329 | bgp->update_delay_begin_time); | |
10330 | json_object_boolean_true_add( | |
10331 | json, | |
10332 | "updateDelayInProgress"); | |
10333 | } else { | |
10334 | if (bgp->update_delay_over) { | |
d62a17ae | 10335 | json_object_string_add( |
10336 | json, | |
10337 | "updateDelayFirstNeighbor", | |
10338 | bgp->update_delay_begin_time); | |
ea47320b | 10339 | json_object_string_add( |
d62a17ae | 10340 | json, |
ea47320b DL |
10341 | "updateDelayBestpathResumed", |
10342 | bgp->update_delay_end_time); | |
10343 | json_object_string_add( | |
d62a17ae | 10344 | json, |
ea47320b DL |
10345 | "updateDelayZebraUpdateResume", |
10346 | bgp->update_delay_zebra_resume_time); | |
10347 | json_object_string_add( | |
10348 | json, | |
10349 | "updateDelayPeerUpdateResume", | |
10350 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10351 | } |
ea47320b DL |
10352 | } |
10353 | } else { | |
10354 | vty_out(vty, | |
10355 | "Read-only mode update-delay limit: %d seconds\n", | |
10356 | bgp->v_update_delay); | |
10357 | if (bgp->v_update_delay | |
10358 | != bgp->v_establish_wait) | |
d62a17ae | 10359 | vty_out(vty, |
ea47320b DL |
10360 | " Establish wait: %d seconds\n", |
10361 | bgp->v_establish_wait); | |
d62a17ae | 10362 | |
60466a63 | 10363 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10364 | vty_out(vty, |
10365 | " First neighbor established: %s\n", | |
10366 | bgp->update_delay_begin_time); | |
10367 | vty_out(vty, | |
10368 | " Delay in progress\n"); | |
10369 | } else { | |
10370 | if (bgp->update_delay_over) { | |
d62a17ae | 10371 | vty_out(vty, |
10372 | " First neighbor established: %s\n", | |
10373 | bgp->update_delay_begin_time); | |
10374 | vty_out(vty, | |
ea47320b DL |
10375 | " Best-paths resumed: %s\n", |
10376 | bgp->update_delay_end_time); | |
10377 | vty_out(vty, | |
10378 | " zebra update resumed: %s\n", | |
10379 | bgp->update_delay_zebra_resume_time); | |
10380 | vty_out(vty, | |
10381 | " peers update resumed: %s\n", | |
10382 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10383 | } |
10384 | } | |
10385 | } | |
ea47320b | 10386 | } |
d62a17ae | 10387 | |
ea47320b DL |
10388 | if (use_json) { |
10389 | if (bgp_maxmed_onstartup_configured(bgp) | |
10390 | && bgp->maxmed_active) | |
10391 | json_object_boolean_true_add( | |
60466a63 | 10392 | json, "maxMedOnStartup"); |
ea47320b DL |
10393 | if (bgp->v_maxmed_admin) |
10394 | json_object_boolean_true_add( | |
60466a63 | 10395 | json, "maxMedAdministrative"); |
d62a17ae | 10396 | |
ea47320b DL |
10397 | json_object_int_add( |
10398 | json, "tableVersion", | |
60466a63 | 10399 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10400 | |
60466a63 QY |
10401 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10402 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10403 | json_object_int_add( |
10404 | json, "ribMemory", | |
9bcb3eef | 10405 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10406 | |
210ec2a0 | 10407 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10408 | json_object_int_add(json, "peerCount", ents); |
10409 | json_object_int_add(json, "peerMemory", | |
10410 | ents * sizeof(struct peer)); | |
d62a17ae | 10411 | |
ea47320b DL |
10412 | if ((ents = listcount(bgp->group))) { |
10413 | json_object_int_add( | |
60466a63 | 10414 | json, "peerGroupCount", ents); |
ea47320b DL |
10415 | json_object_int_add( |
10416 | json, "peerGroupMemory", | |
996c9314 LB |
10417 | ents * sizeof(struct |
10418 | peer_group)); | |
ea47320b | 10419 | } |
d62a17ae | 10420 | |
ea47320b DL |
10421 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10422 | BGP_CONFIG_DAMPENING)) | |
10423 | json_object_boolean_true_add( | |
60466a63 | 10424 | json, "dampeningEnabled"); |
ea47320b | 10425 | } else { |
96c81f66 LS |
10426 | if (!show_terse) { |
10427 | if (bgp_maxmed_onstartup_configured(bgp) | |
10428 | && bgp->maxmed_active) | |
10429 | vty_out(vty, | |
10430 | "Max-med on-startup active\n"); | |
10431 | if (bgp->v_maxmed_admin) | |
10432 | vty_out(vty, | |
10433 | "Max-med administrative active\n"); | |
d62a17ae | 10434 | |
96c81f66 LS |
10435 | vty_out(vty, |
10436 | "BGP table version %" PRIu64 | |
10437 | "\n", | |
10438 | bgp_table_version( | |
10439 | bgp->rib[afi][safi])); | |
ea47320b | 10440 | |
96c81f66 LS |
10441 | ents = bgp_table_count( |
10442 | bgp->rib[afi][safi]); | |
d62a17ae | 10443 | vty_out(vty, |
96c81f66 | 10444 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 10445 | ents, |
10446 | mtype_memstr( | |
10447 | memstrbuf, | |
10448 | sizeof(memstrbuf), | |
96c81f66 LS |
10449 | ents |
10450 | * sizeof( | |
10451 | struct | |
10452 | bgp_dest))); | |
d62a17ae | 10453 | |
96c81f66 LS |
10454 | /* Peer related usage */ |
10455 | ents = bgp->af_peer_count[afi][safi]; | |
10456 | vty_out(vty, | |
10457 | "Peers %ld, using %s of memory\n", | |
10458 | ents, | |
10459 | mtype_memstr( | |
10460 | memstrbuf, | |
10461 | sizeof(memstrbuf), | |
10462 | ents | |
10463 | * sizeof( | |
10464 | struct | |
10465 | peer))); | |
d62a17ae | 10466 | |
96c81f66 LS |
10467 | if ((ents = listcount(bgp->group))) |
10468 | vty_out(vty, | |
10469 | "Peer groups %ld, using %s of memory\n", | |
10470 | ents, | |
10471 | mtype_memstr( | |
10472 | memstrbuf, | |
10473 | sizeof(memstrbuf), | |
10474 | ents | |
10475 | * sizeof( | |
10476 | struct | |
10477 | peer_group))); | |
10478 | ||
10479 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
10480 | BGP_CONFIG_DAMPENING)) | |
10481 | vty_out(vty, | |
10482 | "Dampening enabled.\n"); | |
10483 | } | |
10484 | if (show_failed) { | |
10485 | vty_out(vty, "\n"); | |
10486 | ||
10487 | /* Subtract 8 here because 'Neighbor' is | |
10488 | * 8 characters */ | |
10489 | vty_out(vty, "Neighbor"); | |
10490 | vty_out(vty, "%*s", | |
10491 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
10492 | vty_out(vty, |
10493 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 10494 | } |
d62a17ae | 10495 | } |
ea47320b | 10496 | } |
d62a17ae | 10497 | |
d55811cc | 10498 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10499 | filter = &peer->filter[afi][safi]; |
db92d226 | 10500 | |
ea47320b | 10501 | count++; |
3577f1c5 DD |
10502 | /* Works for both failed & successful cases */ |
10503 | if (peer_dynamic_neighbor(peer)) | |
10504 | dn_count++; | |
d62a17ae | 10505 | |
ea47320b | 10506 | if (use_json) { |
3577f1c5 | 10507 | json_peer = NULL; |
8c1d4cd5 | 10508 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10509 | as_type, as)) { |
10510 | filtered_count++; | |
8c1d4cd5 | 10511 | continue; |
ce1944f0 | 10512 | } |
3577f1c5 DD |
10513 | if (show_failed && |
10514 | bgp_has_peer_failed(peer, afi, safi)) { | |
10515 | json_peer = json_object_new_object(); | |
10516 | bgp_show_failed_summary(vty, bgp, peer, | |
10517 | json_peer, 0, use_json); | |
10518 | } else if (!show_failed) { | |
10b49f14 | 10519 | if (show_established |
ce1944f0 LS |
10520 | && bgp_has_peer_failed(peer, afi, safi)) { |
10521 | filtered_count++; | |
10b49f14 | 10522 | continue; |
ce1944f0 | 10523 | } |
10b49f14 | 10524 | |
3577f1c5 DD |
10525 | json_peer = json_object_new_object(); |
10526 | if (peer_dynamic_neighbor(peer)) { | |
10527 | json_object_boolean_true_add(json_peer, | |
10528 | "dynamicPeer"); | |
10529 | } | |
d62a17ae | 10530 | |
3577f1c5 DD |
10531 | if (peer->hostname) |
10532 | json_object_string_add(json_peer, "hostname", | |
10533 | peer->hostname); | |
10534 | ||
10535 | if (peer->domainname) | |
10536 | json_object_string_add(json_peer, "domainname", | |
10537 | peer->domainname); | |
10538 | ||
10539 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
10540 | json_object_int_add( |
10541 | json_peer, "localAs", | |
10542 | peer->change_local_as | |
10543 | ? peer->change_local_as | |
10544 | : peer->local_as); | |
3577f1c5 DD |
10545 | json_object_int_add(json_peer, "version", 4); |
10546 | json_object_int_add(json_peer, "msgRcvd", | |
10547 | PEER_TOTAL_RX(peer)); | |
10548 | json_object_int_add(json_peer, "msgSent", | |
10549 | PEER_TOTAL_TX(peer)); | |
10550 | ||
43aa5965 QY |
10551 | atomic_size_t outq_count, inq_count; |
10552 | outq_count = atomic_load_explicit( | |
10553 | &peer->obuf->count, | |
10554 | memory_order_relaxed); | |
10555 | inq_count = atomic_load_explicit( | |
10556 | &peer->ibuf->count, | |
10557 | memory_order_relaxed); | |
10558 | ||
3577f1c5 DD |
10559 | json_object_int_add(json_peer, "tableVersion", |
10560 | peer->version[afi][safi]); | |
10561 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
10562 | outq_count); |
10563 | json_object_int_add(json_peer, "inq", | |
10564 | inq_count); | |
3577f1c5 DD |
10565 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
10566 | use_json, json_peer); | |
10567 | ||
3577f1c5 DD |
10568 | json_object_int_add(json_peer, "pfxRcd", |
10569 | peer->pcount[afi][pfx_rcd_safi]); | |
10570 | ||
3577f1c5 | 10571 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
10572 | json_object_int_add( |
10573 | json_peer, "pfxSnt", | |
10574 | (PAF_SUBGRP(paf))->scount); | |
10575 | else | |
10576 | json_object_int_add(json_peer, "pfxSnt", | |
10577 | 0); | |
0e1f8ab5 DA |
10578 | |
10579 | /* BGP FSM state */ | |
cb9196e7 | 10580 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10581 | || CHECK_FLAG(peer->bgp->flags, |
10582 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
10583 | json_object_string_add(json_peer, |
10584 | "state", | |
3577f1c5 DD |
10585 | "Idle (Admin)"); |
10586 | else if (peer->afc_recv[afi][safi]) | |
10587 | json_object_string_add( | |
0e1f8ab5 DA |
10588 | json_peer, "state", |
10589 | lookup_msg(bgp_status_msg, | |
10590 | peer->status, NULL)); | |
10591 | else if (CHECK_FLAG( | |
10592 | peer->sflags, | |
10593 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10594 | json_object_string_add(json_peer, | |
10595 | "state", | |
3577f1c5 DD |
10596 | "Idle (PfxCt)"); |
10597 | else | |
10598 | json_object_string_add( | |
0e1f8ab5 DA |
10599 | json_peer, "state", |
10600 | lookup_msg(bgp_status_msg, | |
10601 | peer->status, NULL)); | |
10602 | ||
10603 | /* BGP peer state */ | |
10604 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10605 | || CHECK_FLAG(peer->bgp->flags, | |
10606 | BGP_FLAG_SHUTDOWN)) | |
10607 | json_object_string_add(json_peer, | |
10608 | "peerState", | |
10609 | "Admin"); | |
10610 | else if (CHECK_FLAG( | |
10611 | peer->sflags, | |
10612 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10613 | json_object_string_add(json_peer, | |
10614 | "peerState", | |
10615 | "PfxCt"); | |
10616 | else if (CHECK_FLAG(peer->flags, | |
10617 | PEER_FLAG_PASSIVE)) | |
10618 | json_object_string_add(json_peer, | |
10619 | "peerState", | |
10620 | "Passive"); | |
10621 | else if (CHECK_FLAG(peer->sflags, | |
10622 | PEER_STATUS_NSF_WAIT)) | |
10623 | json_object_string_add(json_peer, | |
10624 | "peerState", | |
10625 | "NSF passive"); | |
10626 | else if (CHECK_FLAG( | |
10627 | peer->bgp->flags, | |
10628 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10629 | && (!bgp_inbound_policy_exists(peer, | |
10630 | filter) | |
10631 | || !bgp_outbound_policy_exists( | |
10632 | peer, filter))) | |
10633 | json_object_string_add(json_peer, | |
10634 | "peerState", | |
10635 | "Policy"); | |
10636 | else | |
10637 | json_object_string_add( | |
10638 | json_peer, "peerState", "OK"); | |
10639 | ||
200116db DD |
10640 | json_object_int_add(json_peer, "connectionsEstablished", |
10641 | peer->established); | |
10642 | json_object_int_add(json_peer, "connectionsDropped", | |
10643 | peer->dropped); | |
aa72bd7e PG |
10644 | if (peer->desc) |
10645 | json_object_string_add( | |
10646 | json_peer, "desc", peer->desc); | |
b4e9dcba | 10647 | } |
3577f1c5 DD |
10648 | /* Avoid creating empty peer dicts in JSON */ |
10649 | if (json_peer == NULL) | |
10650 | continue; | |
ea47320b DL |
10651 | |
10652 | if (peer->conf_if) | |
60466a63 | 10653 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10654 | "interface"); |
10655 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10656 | json_object_string_add(json_peer, "idType", |
10657 | "ipv4"); | |
ea47320b | 10658 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10659 | json_object_string_add(json_peer, "idType", |
10660 | "ipv6"); | |
ea47320b DL |
10661 | json_object_object_add(json_peers, peer->host, |
10662 | json_peer); | |
10663 | } else { | |
8c1d4cd5 | 10664 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10665 | as_type, as)) { |
10666 | filtered_count++; | |
8c1d4cd5 | 10667 | continue; |
ce1944f0 | 10668 | } |
3577f1c5 DD |
10669 | if (show_failed && |
10670 | bgp_has_peer_failed(peer, afi, safi)) { | |
10671 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10672 | max_neighbor_width, | |
10673 | use_json); | |
10674 | } else if (!show_failed) { | |
10b49f14 | 10675 | if (show_established |
ce1944f0 LS |
10676 | && bgp_has_peer_failed(peer, afi, safi)) { |
10677 | filtered_count++; | |
10b49f14 | 10678 | continue; |
ce1944f0 | 10679 | } |
96c81f66 LS |
10680 | |
10681 | if ((count - filtered_count) == 1) { | |
10682 | /* display headline before the first | |
10683 | * neighbor line */ | |
10684 | vty_out(vty, "\n"); | |
10685 | ||
10686 | /* Subtract 8 here because 'Neighbor' is | |
10687 | * 8 characters */ | |
10688 | vty_out(vty, "Neighbor"); | |
10689 | vty_out(vty, "%*s", | |
10690 | max_neighbor_width - 8, " "); | |
10691 | vty_out(vty, | |
10692 | show_wide | |
10693 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
10694 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
10695 | } | |
10696 | ||
3577f1c5 DD |
10697 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10698 | if (peer_dynamic_neighbor(peer)) { | |
10699 | dn_flag[0] = '*'; | |
10700 | } | |
d62a17ae | 10701 | |
3577f1c5 | 10702 | if (peer->hostname |
892fedb6 DA |
10703 | && CHECK_FLAG(bgp->flags, |
10704 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10705 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10706 | peer->hostname, |
10707 | peer->host); | |
d62a17ae | 10708 | else |
3577f1c5 DD |
10709 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10710 | ||
10711 | /* pad the neighbor column with spaces */ | |
10712 | if (len < max_neighbor_width) | |
10713 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10714 | " "); | |
10715 | ||
43aa5965 QY |
10716 | atomic_size_t outq_count, inq_count; |
10717 | outq_count = atomic_load_explicit( | |
10718 | &peer->obuf->count, | |
10719 | memory_order_relaxed); | |
10720 | inq_count = atomic_load_explicit( | |
10721 | &peer->ibuf->count, | |
10722 | memory_order_relaxed); | |
10723 | ||
85eeb029 DA |
10724 | if (show_wide) |
10725 | vty_out(vty, | |
10726 | "4 %10u %10u %9u %9u %8" PRIu64 | |
10727 | " %4zu %4zu %8s", | |
10728 | peer->as, | |
10729 | peer->change_local_as | |
10730 | ? peer->change_local_as | |
10731 | : peer->local_as, | |
10732 | PEER_TOTAL_RX(peer), | |
10733 | PEER_TOTAL_TX(peer), | |
10734 | peer->version[afi][safi], | |
10735 | inq_count, outq_count, | |
10736 | peer_uptime(peer->uptime, | |
10737 | timebuf, | |
10738 | BGP_UPTIME_LEN, 0, | |
10739 | NULL)); | |
10740 | else | |
10741 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
10742 | " %4zu %4zu %8s", | |
10743 | peer->as, PEER_TOTAL_RX(peer), | |
10744 | PEER_TOTAL_TX(peer), | |
10745 | peer->version[afi][safi], | |
10746 | inq_count, outq_count, | |
10747 | peer_uptime(peer->uptime, | |
10748 | timebuf, | |
10749 | BGP_UPTIME_LEN, 0, | |
10750 | NULL)); | |
3577f1c5 | 10751 | |
feb17238 | 10752 | if (peer_established(peer)) { |
d3ada366 DA |
10753 | if (peer->afc_recv[afi][safi]) { |
10754 | if (CHECK_FLAG( | |
10755 | bgp->flags, | |
10756 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10757 | && !bgp_inbound_policy_exists( | |
10758 | peer, filter)) | |
10759 | vty_out(vty, " %12s", | |
10760 | "(Policy)"); | |
10761 | else | |
10762 | vty_out(vty, | |
6cde4b45 | 10763 | " %12u", |
d3ada366 DA |
10764 | peer->pcount |
10765 | [afi] | |
10766 | [pfx_rcd_safi]); | |
10767 | } else { | |
749d0f27 | 10768 | vty_out(vty, " NoNeg"); |
d3ada366 | 10769 | } |
db92d226 | 10770 | |
d3ada366 DA |
10771 | if (paf && PAF_SUBGRP(paf)) { |
10772 | if (CHECK_FLAG( | |
10773 | bgp->flags, | |
10774 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10775 | && !bgp_outbound_policy_exists( | |
10776 | peer, filter)) | |
10777 | vty_out(vty, " %8s", | |
10778 | "(Policy)"); | |
10779 | else | |
10780 | vty_out(vty, | |
6cde4b45 | 10781 | " %8u", |
d3ada366 DA |
10782 | (PAF_SUBGRP( |
10783 | paf)) | |
10784 | ->scount); | |
749d0f27 DA |
10785 | } else { |
10786 | vty_out(vty, " NoNeg"); | |
d3ada366 | 10787 | } |
db92d226 | 10788 | } else { |
736b68f3 DS |
10789 | if (CHECK_FLAG(peer->flags, |
10790 | PEER_FLAG_SHUTDOWN) | |
10791 | || CHECK_FLAG(peer->bgp->flags, | |
10792 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10793 | vty_out(vty, " Idle (Admin)"); |
10794 | else if (CHECK_FLAG( | |
10795 | peer->sflags, | |
10796 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10797 | vty_out(vty, " Idle (PfxCt)"); | |
10798 | else | |
10799 | vty_out(vty, " %12s", | |
10800 | lookup_msg(bgp_status_msg, | |
10801 | peer->status, NULL)); | |
db92d226 | 10802 | |
6cde4b45 | 10803 | vty_out(vty, " %8u", 0); |
3577f1c5 | 10804 | } |
565e9ddd DA |
10805 | /* Make sure `Desc` column is the lastest in |
10806 | * the output. | |
10807 | */ | |
aa72bd7e | 10808 | if (peer->desc) |
cb75bb31 DA |
10809 | vty_out(vty, " %s", |
10810 | bgp_peer_description_stripped( | |
85eeb029 DA |
10811 | peer->desc, |
10812 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
10813 | else |
10814 | vty_out(vty, " N/A"); | |
3577f1c5 | 10815 | vty_out(vty, "\n"); |
d62a17ae | 10816 | } |
3577f1c5 | 10817 | |
d62a17ae | 10818 | } |
10819 | } | |
f933309e | 10820 | |
d62a17ae | 10821 | if (use_json) { |
10822 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 10823 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
10824 | json_object_int_add(json, "displayedPeers", |
10825 | count - filtered_count); | |
d62a17ae | 10826 | json_object_int_add(json, "totalPeers", count); |
10827 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10828 | ||
3577f1c5 DD |
10829 | if (!show_failed) |
10830 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 10831 | |
996c9314 LB |
10832 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10833 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10834 | json_object_free(json); |
10835 | } else { | |
ce1944f0 | 10836 | if (count) { |
96c81f66 LS |
10837 | if (filtered_count == count) |
10838 | vty_out(vty, "\n%% No matching neighbor\n"); | |
10839 | else { | |
10840 | if (show_failed) | |
10841 | vty_out(vty, "\nDisplayed neighbors %d", | |
10842 | failed_count); | |
10843 | else if (as_type != AS_UNSPECIFIED || as | |
10844 | || fpeer || show_established) | |
ce1944f0 LS |
10845 | vty_out(vty, "\nDisplayed neighbors %d", |
10846 | count - filtered_count); | |
96c81f66 LS |
10847 | |
10848 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
10849 | count); | |
ce1944f0 | 10850 | } |
ce1944f0 | 10851 | } else { |
d6ceaca3 | 10852 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 10853 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10854 | } |
b05a1c8b | 10855 | |
d6ceaca3 | 10856 | if (dn_count) { |
d62a17ae | 10857 | vty_out(vty, "* - dynamic neighbor\n"); |
10858 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10859 | dn_count, bgp->dynamic_neighbors_limit); | |
10860 | } | |
10861 | } | |
1ff9a340 | 10862 | |
d62a17ae | 10863 | return CMD_SUCCESS; |
718e3744 | 10864 | } |
10865 | ||
d62a17ae | 10866 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 10867 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 10868 | as_t as, uint16_t show_flags) |
d62a17ae | 10869 | { |
10870 | int is_first = 1; | |
10871 | int afi_wildcard = (afi == AFI_MAX); | |
10872 | int safi_wildcard = (safi == SAFI_MAX); | |
10873 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 10874 | bool nbr_output = false; |
85eeb029 | 10875 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10876 | |
10877 | if (use_json && is_wildcard) | |
10878 | vty_out(vty, "{\n"); | |
10879 | if (afi_wildcard) | |
10880 | afi = 1; /* AFI_IP */ | |
10881 | while (afi < AFI_MAX) { | |
10882 | if (safi_wildcard) | |
10883 | safi = 1; /* SAFI_UNICAST */ | |
10884 | while (safi < SAFI_MAX) { | |
318cac96 | 10885 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 10886 | nbr_output = true; |
f86897b9 | 10887 | |
d62a17ae | 10888 | if (is_wildcard) { |
10889 | /* | |
10890 | * So limit output to those afi/safi | |
10891 | * pairs that | |
10892 | * actualy have something interesting in | |
10893 | * them | |
10894 | */ | |
10895 | if (use_json) { | |
d62a17ae | 10896 | if (!is_first) |
10897 | vty_out(vty, ",\n"); | |
10898 | else | |
10899 | is_first = 0; | |
10900 | ||
10901 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
10902 | get_afi_safi_str(afi, |
10903 | safi, | |
10904 | true)); | |
d62a17ae | 10905 | } else { |
6cac2fcc LS |
10906 | vty_out(vty, |
10907 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
10908 | get_afi_safi_str(afi, |
10909 | safi, | |
6cac2fcc LS |
10910 | false), |
10911 | bgp->name_pretty); | |
d62a17ae | 10912 | } |
10913 | } | |
8c1d4cd5 LS |
10914 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
10915 | as_type, as, show_flags); | |
d62a17ae | 10916 | } |
10917 | safi++; | |
d62a17ae | 10918 | if (!safi_wildcard) |
10919 | safi = SAFI_MAX; | |
10920 | } | |
10921 | afi++; | |
ee851c8c | 10922 | if (!afi_wildcard) |
d62a17ae | 10923 | afi = AFI_MAX; |
10924 | } | |
10925 | ||
10926 | if (use_json && is_wildcard) | |
10927 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
10928 | else if (!nbr_output) { |
10929 | if (use_json) | |
10930 | vty_out(vty, "{}\n"); | |
10931 | else | |
6cac2fcc LS |
10932 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
10933 | bgp->name_pretty); | |
ca61fd25 | 10934 | } |
d62a17ae | 10935 | } |
10936 | ||
10937 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
10938 | safi_t safi, |
10939 | const char *neighbor, | |
10940 | int as_type, as_t as, | |
96c81f66 | 10941 | uint16_t show_flags) |
d62a17ae | 10942 | { |
10943 | struct listnode *node, *nnode; | |
10944 | struct bgp *bgp; | |
8c1d4cd5 | 10945 | struct peer *fpeer = NULL; |
d62a17ae | 10946 | int is_first = 1; |
9f049418 | 10947 | bool nbr_output = false; |
85eeb029 | 10948 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 10949 | |
10950 | if (use_json) | |
10951 | vty_out(vty, "{\n"); | |
10952 | ||
10953 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10954 | nbr_output = true; |
d62a17ae | 10955 | if (use_json) { |
d62a17ae | 10956 | if (!is_first) |
10957 | vty_out(vty, ",\n"); | |
10958 | else | |
10959 | is_first = 0; | |
10960 | ||
10961 | vty_out(vty, "\"%s\":", | |
10962 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10963 | ? VRF_DEFAULT_NAME |
d62a17ae | 10964 | : bgp->name); |
d62a17ae | 10965 | } |
8c1d4cd5 LS |
10966 | if (neighbor) { |
10967 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
10968 | use_json); | |
10969 | if (!fpeer) | |
10970 | continue; | |
10971 | } | |
10972 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
10973 | as, show_flags); | |
d62a17ae | 10974 | } |
10975 | ||
10976 | if (use_json) | |
10977 | vty_out(vty, "}\n"); | |
9f049418 DS |
10978 | else if (!nbr_output) |
10979 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 10980 | } |
10981 | ||
10982 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 10983 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 10984 | as_t as, uint16_t show_flags) |
d62a17ae | 10985 | { |
10986 | struct bgp *bgp; | |
85eeb029 | 10987 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 10988 | struct peer *fpeer = NULL; |
d62a17ae | 10989 | |
10990 | if (name) { | |
10991 | if (strmatch(name, "all")) { | |
85eeb029 | 10992 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
10993 | neighbor, as_type, |
10994 | as, show_flags); | |
d62a17ae | 10995 | return CMD_SUCCESS; |
10996 | } else { | |
10997 | bgp = bgp_lookup_by_name(name); | |
10998 | ||
10999 | if (!bgp) { | |
11000 | if (use_json) | |
11001 | vty_out(vty, "{}\n"); | |
11002 | else | |
11003 | vty_out(vty, | |
ca61fd25 | 11004 | "%% BGP instance not found\n"); |
d62a17ae | 11005 | return CMD_WARNING; |
11006 | } | |
11007 | ||
8c1d4cd5 LS |
11008 | if (neighbor) { |
11009 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11010 | use_json); | |
11011 | if (!fpeer) | |
11012 | return CMD_WARNING; | |
11013 | } | |
11014 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11015 | as_type, as, show_flags); | |
d62a17ae | 11016 | return CMD_SUCCESS; |
11017 | } | |
11018 | } | |
11019 | ||
11020 | bgp = bgp_get_default(); | |
11021 | ||
8c1d4cd5 LS |
11022 | if (bgp) { |
11023 | if (neighbor) { | |
11024 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11025 | use_json); | |
11026 | if (!fpeer) | |
11027 | return CMD_WARNING; | |
11028 | } | |
11029 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11030 | as, show_flags); | |
11031 | } else { | |
ca61fd25 DS |
11032 | if (use_json) |
11033 | vty_out(vty, "{}\n"); | |
11034 | else | |
11035 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11036 | return CMD_WARNING; |
11037 | } | |
d62a17ae | 11038 | |
11039 | return CMD_SUCCESS; | |
4fb25c53 DW |
11040 | } |
11041 | ||
716b2d8a | 11042 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11043 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11044 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11045 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11046 | "]] [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 |
11047 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11048 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11049 | "Display the entries for all address families\n" | |
11050 | "Summary of BGP neighbor status\n" | |
11051 | "Show only sessions in Established state\n" | |
11052 | "Show only sessions not in Established state\n" | |
11053 | "Show only the specified neighbor session\n" | |
11054 | "Neighbor to display information about\n" | |
11055 | "Neighbor to display information about\n" | |
11056 | "Neighbor on BGP configured interface\n" | |
11057 | "Show only the specified remote AS sessions\n" | |
11058 | "AS number\n" | |
11059 | "Internal (iBGP) AS sessions\n" | |
11060 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11061 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11062 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11063 | { |
d62a17ae | 11064 | char *vrf = NULL; |
11065 | afi_t afi = AFI_MAX; | |
11066 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11067 | as_t as = 0; /* 0 means AS filter not set */ |
11068 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11069 | uint16_t show_flags = 0; |
d62a17ae | 11070 | |
11071 | int idx = 0; | |
11072 | ||
11073 | /* show [ip] bgp */ | |
96f3485c | 11074 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11075 | afi = AFI_IP; |
9a8bdf1c PG |
11076 | /* [<vrf> VIEWVRFNAME] */ |
11077 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11078 | vrf = argv[idx + 1]->arg; | |
11079 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11080 | vrf = NULL; | |
11081 | } else if (argv_find(argv, argc, "view", &idx)) | |
11082 | /* [<view> VIEWVRFNAME] */ | |
11083 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11084 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11085 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11086 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11087 | } | |
11088 | ||
3577f1c5 | 11089 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11090 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11091 | ||
10b49f14 | 11092 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11093 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11094 | ||
8c1d4cd5 LS |
11095 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11096 | if (argv[idx + 1]->arg[0] == 'i') | |
11097 | as_type = AS_INTERNAL; | |
11098 | else if (argv[idx + 1]->arg[0] == 'e') | |
11099 | as_type = AS_EXTERNAL; | |
11100 | else | |
11101 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11102 | } | |
11103 | ||
96c81f66 LS |
11104 | if (argv_find(argv, argc, "terse", &idx)) |
11105 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11106 | ||
85eeb029 DA |
11107 | if (argv_find(argv, argc, "wide", &idx)) |
11108 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11109 | ||
11110 | if (argv_find(argv, argc, "json", &idx)) | |
11111 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11112 | |
8c1d4cd5 LS |
11113 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11114 | show_flags); | |
d62a17ae | 11115 | } |
11116 | ||
5cb5f4d0 | 11117 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11118 | { |
5cb5f4d0 DD |
11119 | if (for_json) |
11120 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11121 | else |
5cb5f4d0 | 11122 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11123 | } |
11124 | ||
d62a17ae | 11125 | |
11126 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11127 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11128 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11129 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11130 | bool use_json, json_object *json_pref) |
d62a17ae | 11131 | { |
11132 | /* Send-Mode */ | |
11133 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11134 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11135 | if (use_json) { | |
11136 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11137 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11138 | json_object_string_add(json_pref, "sendMode", | |
11139 | "advertisedAndReceived"); | |
11140 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11141 | json_object_string_add(json_pref, "sendMode", | |
11142 | "advertised"); | |
11143 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11144 | json_object_string_add(json_pref, "sendMode", | |
11145 | "received"); | |
11146 | } else { | |
11147 | vty_out(vty, " Send-mode: "); | |
11148 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11149 | vty_out(vty, "advertised"); | |
11150 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11151 | vty_out(vty, "%sreceived", | |
11152 | CHECK_FLAG(p->af_cap[afi][safi], | |
11153 | adv_smcap) | |
11154 | ? ", " | |
11155 | : ""); | |
11156 | vty_out(vty, "\n"); | |
11157 | } | |
11158 | } | |
11159 | ||
11160 | /* Receive-Mode */ | |
11161 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11162 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11163 | if (use_json) { | |
11164 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11165 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11166 | json_object_string_add(json_pref, "recvMode", | |
11167 | "advertisedAndReceived"); | |
11168 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11169 | json_object_string_add(json_pref, "recvMode", | |
11170 | "advertised"); | |
11171 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11172 | json_object_string_add(json_pref, "recvMode", | |
11173 | "received"); | |
11174 | } else { | |
11175 | vty_out(vty, " Receive-mode: "); | |
11176 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11177 | vty_out(vty, "advertised"); | |
11178 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11179 | vty_out(vty, "%sreceived", | |
11180 | CHECK_FLAG(p->af_cap[afi][safi], | |
11181 | adv_rmcap) | |
11182 | ? ", " | |
11183 | : ""); | |
11184 | vty_out(vty, "\n"); | |
11185 | } | |
11186 | } | |
11187 | } | |
11188 | ||
13909c4f DS |
11189 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
11190 | struct peer *p, | |
11191 | bool use_json, | |
11192 | json_object *json) | |
2986cac2 | 11193 | { |
08c2d52a | 11194 | bool rbit_status = false; |
2986cac2 | 11195 | |
11196 | if (!use_json) | |
a53ca37b | 11197 | vty_out(vty, "\n R bit: "); |
2986cac2 | 11198 | |
13909c4f DS |
11199 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11200 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11201 | && (peer_established(p))) { |
2986cac2 | 11202 | |
11203 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 11204 | rbit_status = true; |
2986cac2 | 11205 | else |
08c2d52a | 11206 | rbit_status = false; |
2986cac2 | 11207 | } |
11208 | ||
11209 | if (rbit_status) { | |
11210 | if (use_json) | |
13909c4f | 11211 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 11212 | else |
11213 | vty_out(vty, "True\n"); | |
11214 | } else { | |
11215 | if (use_json) | |
13909c4f | 11216 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 11217 | else |
11218 | vty_out(vty, "False\n"); | |
11219 | } | |
11220 | } | |
11221 | ||
13909c4f DS |
11222 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11223 | struct peer *peer, | |
11224 | bool use_json, | |
11225 | json_object *json) | |
2986cac2 | 11226 | { |
2bb5d39b | 11227 | const char *mode = "NotApplicable"; |
2986cac2 | 11228 | |
11229 | if (!use_json) | |
a53ca37b | 11230 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11231 | |
13909c4f | 11232 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11233 | && (peer_established(peer))) { |
2986cac2 | 11234 | |
13909c4f DS |
11235 | if ((peer->nsf_af_count == 0) |
11236 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11237 | |
2986cac2 | 11238 | mode = "Disable"; |
11239 | ||
13909c4f DS |
11240 | } else if (peer->nsf_af_count == 0 |
11241 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11242 | |
2986cac2 | 11243 | mode = "Helper"; |
11244 | ||
13909c4f DS |
11245 | } else if (peer->nsf_af_count != 0 |
11246 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11247 | |
2986cac2 | 11248 | mode = "Restart"; |
2986cac2 | 11249 | } |
11250 | } | |
11251 | ||
11252 | if (use_json) { | |
13909c4f | 11253 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11254 | } else |
11255 | vty_out(vty, mode, "\n"); | |
11256 | } | |
11257 | ||
13909c4f DS |
11258 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11259 | struct peer *p, | |
11260 | bool use_json, | |
11261 | json_object *json) | |
2986cac2 | 11262 | { |
11263 | const char *mode = "Invalid"; | |
11264 | ||
11265 | if (!use_json) | |
a53ca37b | 11266 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11267 | |
11268 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11269 | mode = "Helper"; | |
11270 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11271 | mode = "Restart"; | |
11272 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11273 | mode = "Disable"; | |
2ba1fe69 | 11274 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11275 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11276 | mode = "Helper*"; | |
11277 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11278 | mode = "Restart*"; | |
11279 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11280 | mode = "Disable*"; | |
11281 | else | |
11282 | mode = "Invalid*"; | |
2ba1fe69 | 11283 | } |
2986cac2 | 11284 | |
11285 | if (use_json) { | |
13909c4f | 11286 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11287 | } else { |
11288 | vty_out(vty, mode, "\n"); | |
11289 | } | |
11290 | } | |
11291 | ||
13909c4f DS |
11292 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11293 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11294 | { |
2ba1fe69 | 11295 | afi_t afi; |
11296 | safi_t safi; | |
2986cac2 | 11297 | json_object *json_afi_safi = NULL; |
11298 | json_object *json_timer = NULL; | |
11299 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11300 | bool eor_flag = false; |
2986cac2 | 11301 | |
11302 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11303 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
11304 | if (!peer->afc[afi][safi]) |
11305 | continue; | |
2986cac2 | 11306 | |
13909c4f DS |
11307 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
11308 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11309 | continue; | |
9e3b51a7 | 11310 | |
13909c4f DS |
11311 | if (use_json) { |
11312 | json_afi_safi = json_object_new_object(); | |
11313 | json_endofrib_status = json_object_new_object(); | |
11314 | json_timer = json_object_new_object(); | |
11315 | } | |
2986cac2 | 11316 | |
13909c4f DS |
11317 | if (peer->eor_stime[afi][safi] |
11318 | >= peer->pkt_stime[afi][safi]) | |
11319 | eor_flag = true; | |
11320 | else | |
11321 | eor_flag = false; | |
2986cac2 | 11322 | |
13909c4f | 11323 | if (!use_json) { |
a53ca37b | 11324 | vty_out(vty, " %s:\n", |
13909c4f | 11325 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 11326 | |
a53ca37b | 11327 | vty_out(vty, " F bit: "); |
698ba8d0 | 11328 | } |
2986cac2 | 11329 | |
13909c4f DS |
11330 | if (peer->nsf[afi][safi] |
11331 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
11332 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11333 | |
13909c4f DS |
11334 | if (use_json) { |
11335 | json_object_boolean_true_add( | |
2986cac2 | 11336 | json_afi_safi, "fBit"); |
13909c4f DS |
11337 | } else |
11338 | vty_out(vty, "True\n"); | |
11339 | } else { | |
11340 | if (use_json) | |
11341 | json_object_boolean_false_add( | |
11342 | json_afi_safi, "fBit"); | |
11343 | else | |
11344 | vty_out(vty, "False\n"); | |
11345 | } | |
2986cac2 | 11346 | |
13909c4f | 11347 | if (!use_json) |
a53ca37b | 11348 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 11349 | |
13909c4f DS |
11350 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11351 | PEER_STATUS_EOR_SEND)) { | |
11352 | if (use_json) { | |
11353 | json_object_boolean_true_add( | |
2986cac2 | 11354 | json_endofrib_status, |
13909c4f | 11355 | "endOfRibSend"); |
9e3b51a7 | 11356 | |
13909c4f DS |
11357 | PRINT_EOR_JSON(eor_flag); |
11358 | } else { | |
11359 | vty_out(vty, "Yes\n"); | |
11360 | vty_out(vty, | |
a53ca37b | 11361 | " End-of-RIB sent after update: "); |
2986cac2 | 11362 | |
13909c4f DS |
11363 | PRINT_EOR(eor_flag); |
11364 | } | |
11365 | } else { | |
11366 | if (use_json) { | |
11367 | json_object_boolean_false_add( | |
2986cac2 | 11368 | json_endofrib_status, |
13909c4f DS |
11369 | "endOfRibSend"); |
11370 | json_object_boolean_false_add( | |
9e3b51a7 | 11371 | json_endofrib_status, |
13909c4f DS |
11372 | "endOfRibSentAfterUpdate"); |
11373 | } else { | |
11374 | vty_out(vty, "No\n"); | |
11375 | vty_out(vty, | |
a53ca37b | 11376 | " End-of-RIB sent after update: "); |
13909c4f | 11377 | vty_out(vty, "No\n"); |
2986cac2 | 11378 | } |
13909c4f | 11379 | } |
2986cac2 | 11380 | |
a53ca37b DA |
11381 | if (!use_json) |
11382 | vty_out(vty, " End-of-RIB received: "); | |
11383 | ||
11384 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
11385 | PEER_STATUS_EOR_RECEIVED)) { | |
11386 | if (use_json) | |
11387 | json_object_boolean_true_add( | |
11388 | json_endofrib_status, | |
11389 | "endOfRibRecv"); | |
11390 | else | |
11391 | vty_out(vty, "Yes\n"); | |
11392 | } else { | |
11393 | if (use_json) | |
11394 | json_object_boolean_false_add( | |
11395 | json_endofrib_status, | |
11396 | "endOfRibRecv"); | |
11397 | else | |
11398 | vty_out(vty, "No\n"); | |
11399 | } | |
11400 | ||
13909c4f DS |
11401 | if (use_json) { |
11402 | json_object_int_add(json_timer, | |
11403 | "stalePathTimer", | |
11404 | peer->bgp->stalepath_time); | |
2986cac2 | 11405 | |
13909c4f DS |
11406 | if (peer->t_gr_stale != NULL) { |
11407 | json_object_int_add( | |
2986cac2 | 11408 | json_timer, |
11409 | "stalePathTimerRemaining", | |
11410 | thread_timer_remain_second( | |
13909c4f DS |
11411 | peer->t_gr_stale)); |
11412 | } | |
3a75afa4 | 11413 | |
13909c4f DS |
11414 | /* Display Configured Selection |
11415 | * Deferral only when when | |
11416 | * Gr mode is enabled. | |
11417 | */ | |
11418 | if (CHECK_FLAG(peer->flags, | |
11419 | PEER_FLAG_GRACEFUL_RESTART)) { | |
11420 | json_object_int_add( | |
3a75afa4 | 11421 | json_timer, |
2986cac2 | 11422 | "selectionDeferralTimer", |
11423 | peer->bgp->stalepath_time); | |
13909c4f | 11424 | } |
2986cac2 | 11425 | |
13909c4f DS |
11426 | if (peer->bgp->gr_info[afi][safi] |
11427 | .t_select_deferral | |
11428 | != NULL) { | |
2986cac2 | 11429 | |
13909c4f | 11430 | json_object_int_add( |
2986cac2 | 11431 | json_timer, |
11432 | "selectionDeferralTimerRemaining", | |
11433 | thread_timer_remain_second( | |
13909c4f DS |
11434 | peer->bgp |
11435 | ->gr_info[afi] | |
11436 | [safi] | |
11437 | .t_select_deferral)); | |
11438 | } | |
11439 | } else { | |
a53ca37b | 11440 | vty_out(vty, " Timers:\n"); |
13909c4f | 11441 | vty_out(vty, |
a53ca37b DA |
11442 | " Configured Stale Path Time(sec): %u\n", |
11443 | peer->bgp->stalepath_time); | |
2986cac2 | 11444 | |
a53ca37b | 11445 | if (peer->t_gr_stale != NULL) |
2986cac2 | 11446 | vty_out(vty, |
a53ca37b | 11447 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 11448 | thread_timer_remain_second( |
13909c4f | 11449 | peer->t_gr_stale)); |
13909c4f DS |
11450 | /* Display Configured Selection |
11451 | * Deferral only when when | |
11452 | * Gr mode is enabled. | |
11453 | */ | |
11454 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 11455 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 11456 | vty_out(vty, |
a53ca37b | 11457 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 11458 | peer->bgp->select_defer_time); |
2986cac2 | 11459 | |
13909c4f DS |
11460 | if (peer->bgp->gr_info[afi][safi] |
11461 | .t_select_deferral | |
a53ca37b | 11462 | != NULL) |
13909c4f | 11463 | vty_out(vty, |
a53ca37b | 11464 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 11465 | thread_timer_remain_second( |
13909c4f DS |
11466 | peer->bgp |
11467 | ->gr_info[afi] | |
11468 | [safi] | |
11469 | .t_select_deferral)); | |
2986cac2 | 11470 | } |
13909c4f DS |
11471 | if (use_json) { |
11472 | json_object_object_add(json_afi_safi, | |
11473 | "endOfRibStatus", | |
11474 | json_endofrib_status); | |
11475 | json_object_object_add(json_afi_safi, "timers", | |
11476 | json_timer); | |
11477 | json_object_object_add( | |
11478 | json, get_afi_safi_str(afi, safi, true), | |
11479 | json_afi_safi); | |
11480 | } | |
2986cac2 | 11481 | } |
11482 | } | |
11483 | } | |
11484 | ||
36235319 QY |
11485 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11486 | struct peer *p, | |
11487 | bool use_json, | |
11488 | json_object *json) | |
2986cac2 | 11489 | { |
11490 | if (use_json) { | |
11491 | json_object *json_timer = NULL; | |
11492 | ||
11493 | json_timer = json_object_new_object(); | |
11494 | ||
13909c4f DS |
11495 | json_object_int_add(json_timer, "configuredRestartTimer", |
11496 | p->bgp->restart_time); | |
2986cac2 | 11497 | |
13909c4f DS |
11498 | json_object_int_add(json_timer, "receivedRestartTimer", |
11499 | p->v_gr_restart); | |
2986cac2 | 11500 | |
13909c4f DS |
11501 | if (p->t_gr_restart != NULL) |
11502 | json_object_int_add( | |
11503 | json_timer, "restartTimerRemaining", | |
11504 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11505 | |
11506 | json_object_object_add(json, "timers", json_timer); | |
11507 | } else { | |
11508 | ||
a53ca37b DA |
11509 | vty_out(vty, " Timers:\n"); |
11510 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11511 | p->bgp->restart_time); |
2986cac2 | 11512 | |
a53ca37b | 11513 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11514 | p->v_gr_restart); |
11515 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11516 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11517 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11518 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11519 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11520 | thread_timer_remain_second(p->t_gr_restart)); |
11521 | } | |
2986cac2 | 11522 | } |
11523 | } | |
11524 | ||
11525 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11526 | bool use_json, json_object *json) |
2986cac2 | 11527 | { |
11528 | char buf[SU_ADDRSTRLEN] = {0}; | |
11529 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11530 | /* '*' + v6 address of neighbor */ |
11531 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11532 | |
2986cac2 | 11533 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11534 | dn_flag[0] = '*'; | |
11535 | ||
11536 | if (p->conf_if) { | |
11537 | if (use_json) | |
13909c4f DS |
11538 | json_object_string_add( |
11539 | json, "neighborAddr", | |
2986cac2 | 11540 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11541 | ? "none" |
11542 | : sockunion2str(&p->su, buf, | |
11543 | SU_ADDRSTRLEN)); | |
2986cac2 | 11544 | else |
13909c4f | 11545 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11546 | BGP_PEER_SU_UNSPEC(p) |
11547 | ? "none" | |
11548 | : sockunion2str(&p->su, buf, | |
11549 | SU_ADDRSTRLEN)); | |
11550 | } else { | |
772270f3 QY |
11551 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11552 | p->host); | |
2986cac2 | 11553 | |
11554 | if (use_json) | |
36235319 QY |
11555 | json_object_string_add(json, "neighborAddr", |
11556 | neighborAddr); | |
2986cac2 | 11557 | else |
36235319 | 11558 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11559 | } |
11560 | ||
11561 | /* more gr info in new format */ | |
11562 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11563 | } | |
11564 | ||
d62a17ae | 11565 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11566 | safi_t safi, bool use_json, |
d62a17ae | 11567 | json_object *json_neigh) |
11568 | { | |
0291c246 MK |
11569 | struct bgp_filter *filter; |
11570 | struct peer_af *paf; | |
11571 | char orf_pfx_name[BUFSIZ]; | |
11572 | int orf_pfx_count; | |
11573 | json_object *json_af = NULL; | |
11574 | json_object *json_prefA = NULL; | |
11575 | json_object *json_prefB = NULL; | |
11576 | json_object *json_addr = NULL; | |
fa36596c | 11577 | json_object *json_advmap = NULL; |
d62a17ae | 11578 | |
11579 | if (use_json) { | |
11580 | json_addr = json_object_new_object(); | |
11581 | json_af = json_object_new_object(); | |
11582 | filter = &p->filter[afi][safi]; | |
11583 | ||
11584 | if (peer_group_active(p)) | |
11585 | json_object_string_add(json_addr, "peerGroupMember", | |
11586 | p->group->name); | |
11587 | ||
11588 | paf = peer_af_find(p, afi, safi); | |
11589 | if (paf && PAF_SUBGRP(paf)) { | |
11590 | json_object_int_add(json_addr, "updateGroupId", | |
11591 | PAF_UPDGRP(paf)->id); | |
11592 | json_object_int_add(json_addr, "subGroupId", | |
11593 | PAF_SUBGRP(paf)->id); | |
11594 | json_object_int_add(json_addr, "packetQueueLength", | |
11595 | bpacket_queue_virtual_length(paf)); | |
11596 | } | |
11597 | ||
11598 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11599 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11600 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11601 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11602 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11603 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11604 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11605 | json_object_int_add(json_af, "orfType", | |
11606 | ORF_TYPE_PREFIX); | |
11607 | json_prefA = json_object_new_object(); | |
11608 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11609 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11610 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11611 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11612 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11613 | use_json, json_prefA); | |
11614 | json_object_object_add(json_af, "orfPrefixList", | |
11615 | json_prefA); | |
11616 | } | |
11617 | ||
11618 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11619 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11620 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11621 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11622 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11623 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11624 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11625 | json_object_int_add(json_af, "orfOldType", | |
11626 | ORF_TYPE_PREFIX_OLD); | |
11627 | json_prefB = json_object_new_object(); | |
11628 | bgp_show_peer_afi_orf_cap( | |
11629 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11630 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11631 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11632 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11633 | json_prefB); | |
11634 | json_object_object_add(json_af, "orfOldPrefixList", | |
11635 | json_prefB); | |
11636 | } | |
11637 | ||
11638 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11639 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11640 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11641 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11642 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11643 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11644 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11645 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11646 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11647 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11648 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11649 | json_object_object_add(json_addr, "afDependentCap", | |
11650 | json_af); | |
11651 | else | |
11652 | json_object_free(json_af); | |
11653 | ||
772270f3 QY |
11654 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11655 | p->host, afi, safi); | |
d62a17ae | 11656 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11657 | NULL, afi, orf_pfx_name, use_json); | |
11658 | ||
11659 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11660 | PEER_STATUS_ORF_PREFIX_SEND) | |
11661 | || orf_pfx_count) { | |
11662 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11663 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11664 | json_object_boolean_true_add(json_neigh, | |
11665 | "orfSent"); | |
11666 | if (orf_pfx_count) | |
11667 | json_object_int_add(json_addr, "orfRecvCounter", | |
11668 | orf_pfx_count); | |
11669 | } | |
11670 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11671 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11672 | json_object_string_add( | |
11673 | json_addr, "orfFirstUpdate", | |
11674 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11675 | ||
11676 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11677 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11678 | json_object_boolean_true_add(json_addr, | |
11679 | "routeReflectorClient"); | |
11680 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11681 | PEER_FLAG_RSERVER_CLIENT)) | |
11682 | json_object_boolean_true_add(json_addr, | |
11683 | "routeServerClient"); | |
11684 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11685 | json_object_boolean_true_add(json_addr, | |
11686 | "inboundSoftConfigPermit"); | |
11687 | ||
11688 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11689 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11690 | json_object_boolean_true_add( | |
11691 | json_addr, | |
11692 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11693 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11694 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11695 | json_object_boolean_true_add( | |
11696 | json_addr, | |
11697 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11698 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11699 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11700 | json_object_boolean_true_add( | |
11701 | json_addr, | |
11702 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11703 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11704 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11705 | json_object_boolean_true_add( | |
11706 | json_addr, | |
11707 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11708 | ||
dcc68b5e MS |
11709 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11710 | json_object_boolean_true_add( | |
11711 | json_addr, | |
11712 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11713 | ->type_json_name); | |
d62a17ae | 11714 | |
11715 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11716 | json_object_string_add(json_addr, | |
11717 | "overrideASNsInOutboundUpdates", | |
11718 | "ifAspathEqualRemoteAs"); | |
11719 | ||
11720 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11721 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11722 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11723 | json_object_boolean_true_add(json_addr, | |
11724 | "routerAlwaysNextHop"); | |
11725 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11726 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11727 | json_object_boolean_true_add( | |
11728 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11729 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11730 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11731 | json_object_boolean_true_add( | |
11732 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11733 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11734 | json_object_boolean_true_add( | |
11735 | json_addr, "unchangedMedPropogatedToNbr"); | |
11736 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11737 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11738 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11739 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11740 | PEER_FLAG_SEND_COMMUNITY) | |
11741 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11742 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11743 | json_object_string_add(json_addr, | |
11744 | "commAttriSentToNbr", | |
11745 | "extendedAndStandard"); | |
11746 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11747 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11748 | json_object_string_add(json_addr, | |
11749 | "commAttriSentToNbr", | |
11750 | "extended"); | |
11751 | else | |
11752 | json_object_string_add(json_addr, | |
11753 | "commAttriSentToNbr", | |
11754 | "standard"); | |
11755 | } | |
11756 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11757 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11758 | if (p->default_rmap[afi][safi].name) | |
11759 | json_object_string_add( | |
11760 | json_addr, "defaultRouteMap", | |
11761 | p->default_rmap[afi][safi].name); | |
11762 | ||
11763 | if (paf && PAF_SUBGRP(paf) | |
11764 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11765 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11766 | json_object_boolean_true_add(json_addr, | |
11767 | "defaultSent"); | |
11768 | else | |
11769 | json_object_boolean_true_add(json_addr, | |
11770 | "defaultNotSent"); | |
11771 | } | |
11772 | ||
dff8f48d | 11773 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11774 | if (is_evpn_enabled()) |
60466a63 QY |
11775 | json_object_boolean_true_add( |
11776 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11777 | } |
11778 | ||
d62a17ae | 11779 | if (filter->plist[FILTER_IN].name |
11780 | || filter->dlist[FILTER_IN].name | |
11781 | || filter->aslist[FILTER_IN].name | |
11782 | || filter->map[RMAP_IN].name) | |
11783 | json_object_boolean_true_add(json_addr, | |
11784 | "inboundPathPolicyConfig"); | |
11785 | if (filter->plist[FILTER_OUT].name | |
11786 | || filter->dlist[FILTER_OUT].name | |
11787 | || filter->aslist[FILTER_OUT].name | |
11788 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11789 | json_object_boolean_true_add( | |
11790 | json_addr, "outboundPathPolicyConfig"); | |
11791 | ||
11792 | /* prefix-list */ | |
11793 | if (filter->plist[FILTER_IN].name) | |
11794 | json_object_string_add(json_addr, | |
11795 | "incomingUpdatePrefixFilterList", | |
11796 | filter->plist[FILTER_IN].name); | |
11797 | if (filter->plist[FILTER_OUT].name) | |
11798 | json_object_string_add(json_addr, | |
11799 | "outgoingUpdatePrefixFilterList", | |
11800 | filter->plist[FILTER_OUT].name); | |
11801 | ||
11802 | /* distribute-list */ | |
11803 | if (filter->dlist[FILTER_IN].name) | |
11804 | json_object_string_add( | |
11805 | json_addr, "incomingUpdateNetworkFilterList", | |
11806 | filter->dlist[FILTER_IN].name); | |
11807 | if (filter->dlist[FILTER_OUT].name) | |
11808 | json_object_string_add( | |
11809 | json_addr, "outgoingUpdateNetworkFilterList", | |
11810 | filter->dlist[FILTER_OUT].name); | |
11811 | ||
11812 | /* filter-list. */ | |
11813 | if (filter->aslist[FILTER_IN].name) | |
11814 | json_object_string_add(json_addr, | |
11815 | "incomingUpdateAsPathFilterList", | |
11816 | filter->aslist[FILTER_IN].name); | |
11817 | if (filter->aslist[FILTER_OUT].name) | |
11818 | json_object_string_add(json_addr, | |
11819 | "outgoingUpdateAsPathFilterList", | |
11820 | filter->aslist[FILTER_OUT].name); | |
11821 | ||
11822 | /* route-map. */ | |
11823 | if (filter->map[RMAP_IN].name) | |
11824 | json_object_string_add( | |
11825 | json_addr, "routeMapForIncomingAdvertisements", | |
11826 | filter->map[RMAP_IN].name); | |
11827 | if (filter->map[RMAP_OUT].name) | |
11828 | json_object_string_add( | |
11829 | json_addr, "routeMapForOutgoingAdvertisements", | |
11830 | filter->map[RMAP_OUT].name); | |
11831 | ||
9dac9fc8 | 11832 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11833 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11834 | && !bgp_inbound_policy_exists(p, filter)) |
11835 | json_object_string_add( | |
11836 | json_addr, "inboundEbgpRequiresPolicy", | |
11837 | "Inbound updates discarded due to missing policy"); | |
11838 | ||
11839 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11840 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11841 | && (!bgp_outbound_policy_exists(p, filter))) |
11842 | json_object_string_add( | |
11843 | json_addr, "outboundEbgpRequiresPolicy", | |
11844 | "Outbound updates discarded due to missing policy"); | |
11845 | ||
d62a17ae | 11846 | /* unsuppress-map */ |
11847 | if (filter->usmap.name) | |
11848 | json_object_string_add(json_addr, | |
11849 | "selectiveUnsuppressRouteMap", | |
11850 | filter->usmap.name); | |
11851 | ||
fa36596c MK |
11852 | /* advertise-map */ |
11853 | if (filter->advmap.aname) { | |
11854 | json_advmap = json_object_new_object(); | |
11855 | json_object_string_add(json_advmap, "condition", | |
11856 | filter->advmap.condition | |
11857 | ? "EXIST" | |
11858 | : "NON_EXIST"); | |
11859 | json_object_string_add(json_advmap, "conditionMap", | |
11860 | filter->advmap.cname); | |
11861 | json_object_string_add(json_advmap, "advertiseMap", | |
11862 | filter->advmap.aname); | |
11863 | json_object_string_add(json_advmap, "advertiseStatus", | |
11864 | filter->advmap.update_type | |
11865 | == ADVERTISE | |
11866 | ? "Advertise" | |
11867 | : "Withdraw"); | |
11868 | json_object_object_add(json_addr, "advertiseMap", | |
11869 | json_advmap); | |
11870 | } | |
11871 | ||
d62a17ae | 11872 | /* Receive prefix count */ |
11873 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11874 | p->pcount[afi][safi]); | |
50e05855 AD |
11875 | if (paf && PAF_SUBGRP(paf)) |
11876 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11877 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11878 | |
fde246e8 DA |
11879 | /* Maximum prefix */ |
11880 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11881 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11882 | p->pmax_out[afi][safi]); | |
11883 | ||
d62a17ae | 11884 | /* Maximum prefix */ |
11885 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11886 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11887 | p->pmax[afi][safi]); | |
11888 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11889 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11890 | json_object_boolean_true_add( | |
11891 | json_addr, "prefixAllowedMaxWarning"); | |
11892 | json_object_int_add(json_addr, | |
11893 | "prefixAllowedWarningThresh", | |
11894 | p->pmax_threshold[afi][safi]); | |
11895 | if (p->pmax_restart[afi][safi]) | |
11896 | json_object_int_add( | |
11897 | json_addr, | |
11898 | "prefixAllowedRestartIntervalMsecs", | |
11899 | p->pmax_restart[afi][safi] * 60000); | |
11900 | } | |
2986cac2 | 11901 | json_object_object_add(json_neigh, |
36235319 | 11902 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 11903 | json_addr); |
11904 | ||
11905 | } else { | |
11906 | filter = &p->filter[afi][safi]; | |
11907 | ||
11908 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 11909 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11910 | |
11911 | if (peer_group_active(p)) | |
11912 | vty_out(vty, " %s peer-group member\n", | |
11913 | p->group->name); | |
11914 | ||
11915 | paf = peer_af_find(p, afi, safi); | |
11916 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 11917 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 11918 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
11919 | vty_out(vty, " Packet Queue length %d\n", | |
11920 | bpacket_queue_virtual_length(paf)); | |
11921 | } else { | |
11922 | vty_out(vty, " Not part of any update group\n"); | |
11923 | } | |
11924 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11925 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11926 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11927 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11928 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11929 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11930 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11931 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11932 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11933 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11934 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11935 | vty_out(vty, " AF-dependant capabilities:\n"); | |
11936 | ||
11937 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11938 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11939 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11940 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11941 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11942 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11943 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11944 | vty_out(vty, | |
11945 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11946 | ORF_TYPE_PREFIX); | |
11947 | bgp_show_peer_afi_orf_cap( | |
11948 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11949 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11950 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11951 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
11952 | } | |
11953 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11954 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11955 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11956 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11957 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11958 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11959 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11960 | vty_out(vty, | |
11961 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11962 | ORF_TYPE_PREFIX_OLD); | |
11963 | bgp_show_peer_afi_orf_cap( | |
11964 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11965 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11966 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11967 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
11968 | } | |
11969 | ||
772270f3 QY |
11970 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11971 | p->host, afi, safi); | |
d62a17ae | 11972 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11973 | NULL, afi, orf_pfx_name, use_json); | |
11974 | ||
11975 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11976 | PEER_STATUS_ORF_PREFIX_SEND) | |
11977 | || orf_pfx_count) { | |
11978 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
11979 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11980 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11981 | vty_out(vty, " sent;"); | |
11982 | if (orf_pfx_count) | |
11983 | vty_out(vty, " received (%d entries)", | |
11984 | orf_pfx_count); | |
11985 | vty_out(vty, "\n"); | |
11986 | } | |
11987 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11988 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11989 | vty_out(vty, | |
11990 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
11991 | ||
11992 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11993 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11994 | vty_out(vty, " Route-Reflector Client\n"); | |
11995 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11996 | PEER_FLAG_RSERVER_CLIENT)) | |
11997 | vty_out(vty, " Route-Server Client\n"); | |
11998 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11999 | vty_out(vty, | |
12000 | " Inbound soft reconfiguration allowed\n"); | |
12001 | ||
12002 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12003 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12004 | vty_out(vty, | |
12005 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12006 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12007 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12008 | vty_out(vty, | |
12009 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12010 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12011 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12012 | vty_out(vty, | |
12013 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12014 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12015 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12016 | vty_out(vty, | |
12017 | " Private AS numbers removed in updates to this neighbor\n"); | |
12018 | ||
dcc68b5e MS |
12019 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12020 | vty_out(vty, " %s\n", | |
12021 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12022 | ->human_description); | |
d62a17ae | 12023 | |
12024 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12025 | vty_out(vty, | |
12026 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12027 | ||
12028 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12029 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12030 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12031 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12032 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12033 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12034 | vty_out(vty, | |
12035 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12036 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12037 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12038 | vty_out(vty, | |
12039 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12040 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12041 | vty_out(vty, | |
12042 | " MED is propagated unchanged to this neighbor\n"); | |
12043 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12044 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12045 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12046 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12047 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12048 | vty_out(vty, | |
12049 | " Community attribute sent to this neighbor"); | |
12050 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12051 | PEER_FLAG_SEND_COMMUNITY) | |
12052 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12053 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12054 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12055 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12056 | vty_out(vty, "(all)\n"); | |
12057 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12058 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12059 | vty_out(vty, "(large)\n"); | |
12060 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12061 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12062 | vty_out(vty, "(extended)\n"); | |
12063 | else | |
12064 | vty_out(vty, "(standard)\n"); | |
12065 | } | |
12066 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12067 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12068 | vty_out(vty, " Default information originate,"); | |
12069 | ||
12070 | if (p->default_rmap[afi][safi].name) | |
12071 | vty_out(vty, " default route-map %s%s,", | |
12072 | p->default_rmap[afi][safi].map ? "*" | |
12073 | : "", | |
12074 | p->default_rmap[afi][safi].name); | |
12075 | if (paf && PAF_SUBGRP(paf) | |
12076 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12077 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12078 | vty_out(vty, " default sent\n"); | |
12079 | else | |
12080 | vty_out(vty, " default not sent\n"); | |
12081 | } | |
12082 | ||
dff8f48d MK |
12083 | /* advertise-vni-all */ |
12084 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12085 | if (is_evpn_enabled()) |
dff8f48d MK |
12086 | vty_out(vty, " advertise-all-vni\n"); |
12087 | } | |
12088 | ||
d62a17ae | 12089 | if (filter->plist[FILTER_IN].name |
12090 | || filter->dlist[FILTER_IN].name | |
12091 | || filter->aslist[FILTER_IN].name | |
12092 | || filter->map[RMAP_IN].name) | |
12093 | vty_out(vty, " Inbound path policy configured\n"); | |
12094 | if (filter->plist[FILTER_OUT].name | |
12095 | || filter->dlist[FILTER_OUT].name | |
12096 | || filter->aslist[FILTER_OUT].name | |
12097 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12098 | vty_out(vty, " Outbound path policy configured\n"); | |
12099 | ||
12100 | /* prefix-list */ | |
12101 | if (filter->plist[FILTER_IN].name) | |
12102 | vty_out(vty, | |
12103 | " Incoming update prefix filter list is %s%s\n", | |
12104 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12105 | filter->plist[FILTER_IN].name); | |
12106 | if (filter->plist[FILTER_OUT].name) | |
12107 | vty_out(vty, | |
12108 | " Outgoing update prefix filter list is %s%s\n", | |
12109 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12110 | filter->plist[FILTER_OUT].name); | |
12111 | ||
12112 | /* distribute-list */ | |
12113 | if (filter->dlist[FILTER_IN].name) | |
12114 | vty_out(vty, | |
12115 | " Incoming update network filter list is %s%s\n", | |
12116 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12117 | filter->dlist[FILTER_IN].name); | |
12118 | if (filter->dlist[FILTER_OUT].name) | |
12119 | vty_out(vty, | |
12120 | " Outgoing update network filter list is %s%s\n", | |
12121 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12122 | filter->dlist[FILTER_OUT].name); | |
12123 | ||
12124 | /* filter-list. */ | |
12125 | if (filter->aslist[FILTER_IN].name) | |
12126 | vty_out(vty, | |
12127 | " Incoming update AS path filter list is %s%s\n", | |
12128 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12129 | filter->aslist[FILTER_IN].name); | |
12130 | if (filter->aslist[FILTER_OUT].name) | |
12131 | vty_out(vty, | |
12132 | " Outgoing update AS path filter list is %s%s\n", | |
12133 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12134 | filter->aslist[FILTER_OUT].name); | |
12135 | ||
12136 | /* route-map. */ | |
12137 | if (filter->map[RMAP_IN].name) | |
12138 | vty_out(vty, | |
12139 | " Route map for incoming advertisements is %s%s\n", | |
12140 | filter->map[RMAP_IN].map ? "*" : "", | |
12141 | filter->map[RMAP_IN].name); | |
12142 | if (filter->map[RMAP_OUT].name) | |
12143 | vty_out(vty, | |
12144 | " Route map for outgoing advertisements is %s%s\n", | |
12145 | filter->map[RMAP_OUT].map ? "*" : "", | |
12146 | filter->map[RMAP_OUT].name); | |
12147 | ||
9dac9fc8 | 12148 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12149 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12150 | && !bgp_inbound_policy_exists(p, filter)) |
12151 | vty_out(vty, | |
12152 | " Inbound updates discarded due to missing policy\n"); | |
12153 | ||
12154 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12155 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12156 | && !bgp_outbound_policy_exists(p, filter)) |
12157 | vty_out(vty, | |
12158 | " Outbound updates discarded due to missing policy\n"); | |
12159 | ||
d62a17ae | 12160 | /* unsuppress-map */ |
12161 | if (filter->usmap.name) | |
12162 | vty_out(vty, | |
12163 | " Route map for selective unsuppress is %s%s\n", | |
12164 | filter->usmap.map ? "*" : "", | |
12165 | filter->usmap.name); | |
12166 | ||
7f7940e6 MK |
12167 | /* advertise-map */ |
12168 | if (filter->advmap.aname && filter->advmap.cname) | |
12169 | vty_out(vty, | |
12170 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12171 | filter->advmap.condition ? "EXIST" | |
12172 | : "NON_EXIST", | |
12173 | filter->advmap.cmap ? "*" : "", | |
12174 | filter->advmap.cname, | |
12175 | filter->advmap.amap ? "*" : "", | |
12176 | filter->advmap.aname, | |
fa36596c | 12177 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12178 | ? "Advertise" |
12179 | : "Withdraw"); | |
7f7940e6 | 12180 | |
d62a17ae | 12181 | /* Receive prefix count */ |
6cde4b45 | 12182 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12183 | p->pcount[afi][safi]); |
d62a17ae | 12184 | |
fde246e8 DA |
12185 | /* maximum-prefix-out */ |
12186 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12187 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12188 | vty_out(vty, | |
6cde4b45 | 12189 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12190 | p->pmax_out[afi][safi]); |
12191 | ||
d62a17ae | 12192 | /* Maximum prefix */ |
12193 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12194 | vty_out(vty, |
6cde4b45 | 12195 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12196 | p->pmax[afi][safi], |
12197 | CHECK_FLAG(p->af_flags[afi][safi], | |
12198 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12199 | ? " (warning-only)" | |
12200 | : ""); | |
12201 | vty_out(vty, " Threshold for warning message %d%%", | |
12202 | p->pmax_threshold[afi][safi]); | |
12203 | if (p->pmax_restart[afi][safi]) | |
12204 | vty_out(vty, ", restart interval %d min", | |
12205 | p->pmax_restart[afi][safi]); | |
12206 | vty_out(vty, "\n"); | |
12207 | } | |
12208 | ||
12209 | vty_out(vty, "\n"); | |
12210 | } | |
12211 | } | |
12212 | ||
9f049418 | 12213 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12214 | json_object *json) |
718e3744 | 12215 | { |
d62a17ae | 12216 | struct bgp *bgp; |
12217 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12218 | char timebuf[BGP_UPTIME_LEN]; | |
12219 | char dn_flag[2]; | |
d62a17ae | 12220 | afi_t afi; |
12221 | safi_t safi; | |
d7c0a89a QY |
12222 | uint16_t i; |
12223 | uint8_t *msg; | |
d62a17ae | 12224 | json_object *json_neigh = NULL; |
12225 | time_t epoch_tbuf; | |
4ab46701 | 12226 | uint32_t sync_tcp_mss; |
718e3744 | 12227 | |
d62a17ae | 12228 | bgp = p->bgp; |
12229 | ||
12230 | if (use_json) | |
12231 | json_neigh = json_object_new_object(); | |
12232 | ||
12233 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12234 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12235 | dn_flag[0] = '*'; | |
12236 | ||
12237 | if (!use_json) { | |
12238 | if (p->conf_if) /* Configured interface name. */ | |
12239 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12240 | BGP_PEER_SU_UNSPEC(p) | |
12241 | ? "None" | |
12242 | : sockunion2str(&p->su, buf, | |
12243 | SU_ADDRSTRLEN)); | |
12244 | else /* Configured IP address. */ | |
12245 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12246 | p->host); | |
12247 | } | |
12248 | ||
12249 | if (use_json) { | |
12250 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12251 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12252 | "none"); | |
12253 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12254 | json_object_string_add( | |
12255 | json_neigh, "bgpNeighborAddr", | |
12256 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12257 | ||
12258 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12259 | ||
12260 | if (p->change_local_as) | |
12261 | json_object_int_add(json_neigh, "localAs", | |
12262 | p->change_local_as); | |
12263 | else | |
12264 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12265 | ||
12266 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12267 | json_object_boolean_true_add(json_neigh, | |
12268 | "localAsNoPrepend"); | |
12269 | ||
12270 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12271 | json_object_boolean_true_add(json_neigh, | |
12272 | "localAsReplaceAs"); | |
12273 | } else { | |
12274 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12275 | || (p->as_type == AS_INTERNAL)) | |
12276 | vty_out(vty, "remote AS %u, ", p->as); | |
12277 | else | |
12278 | vty_out(vty, "remote AS Unspecified, "); | |
12279 | vty_out(vty, "local AS %u%s%s, ", | |
12280 | p->change_local_as ? p->change_local_as : p->local_as, | |
12281 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12282 | ? " no-prepend" | |
12283 | : "", | |
12284 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12285 | ? " replace-as" | |
12286 | : ""); | |
12287 | } | |
faa16034 DS |
12288 | /* peer type internal or confed-internal */ |
12289 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12290 | if (use_json) { |
12291 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12292 | json_object_boolean_true_add( | |
12293 | json_neigh, "nbrConfedInternalLink"); | |
12294 | else | |
12295 | json_object_boolean_true_add(json_neigh, | |
12296 | "nbrInternalLink"); | |
12297 | } else { | |
12298 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12299 | vty_out(vty, "confed-internal link\n"); | |
12300 | else | |
12301 | vty_out(vty, "internal link\n"); | |
12302 | } | |
faa16034 DS |
12303 | /* peer type external or confed-external */ |
12304 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12305 | if (use_json) { |
12306 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12307 | json_object_boolean_true_add( | |
12308 | json_neigh, "nbrConfedExternalLink"); | |
12309 | else | |
12310 | json_object_boolean_true_add(json_neigh, | |
12311 | "nbrExternalLink"); | |
12312 | } else { | |
12313 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12314 | vty_out(vty, "confed-external link\n"); | |
12315 | else | |
12316 | vty_out(vty, "external link\n"); | |
12317 | } | |
faa16034 DS |
12318 | } else { |
12319 | if (use_json) | |
12320 | json_object_boolean_true_add(json_neigh, | |
12321 | "nbrUnspecifiedLink"); | |
12322 | else | |
12323 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12324 | } |
12325 | ||
12326 | /* Description. */ | |
12327 | if (p->desc) { | |
12328 | if (use_json) | |
12329 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12330 | else | |
12331 | vty_out(vty, " Description: %s\n", p->desc); | |
12332 | } | |
12333 | ||
12334 | if (p->hostname) { | |
12335 | if (use_json) { | |
12336 | if (p->hostname) | |
12337 | json_object_string_add(json_neigh, "hostname", | |
12338 | p->hostname); | |
12339 | ||
12340 | if (p->domainname) | |
12341 | json_object_string_add(json_neigh, "domainname", | |
12342 | p->domainname); | |
12343 | } else { | |
12344 | if (p->domainname && (p->domainname[0] != '\0')) | |
12345 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12346 | p->domainname); | |
12347 | else | |
12348 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12349 | } | |
12350 | } | |
12351 | ||
12352 | /* Peer-group */ | |
12353 | if (p->group) { | |
12354 | if (use_json) { | |
12355 | json_object_string_add(json_neigh, "peerGroup", | |
12356 | p->group->name); | |
12357 | ||
12358 | if (dn_flag[0]) { | |
12359 | struct prefix prefix, *range = NULL; | |
12360 | ||
0154d8ce DS |
12361 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12362 | range = peer_group_lookup_dynamic_neighbor_range( | |
12363 | p->group, &prefix); | |
d62a17ae | 12364 | |
12365 | if (range) { | |
12366 | prefix2str(range, buf1, sizeof(buf1)); | |
12367 | json_object_string_add( | |
12368 | json_neigh, | |
12369 | "peerSubnetRangeGroup", buf1); | |
12370 | } | |
12371 | } | |
12372 | } else { | |
12373 | vty_out(vty, | |
12374 | " Member of peer-group %s for session parameters\n", | |
12375 | p->group->name); | |
12376 | ||
12377 | if (dn_flag[0]) { | |
12378 | struct prefix prefix, *range = NULL; | |
12379 | ||
0154d8ce DS |
12380 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12381 | range = peer_group_lookup_dynamic_neighbor_range( | |
12382 | p->group, &prefix); | |
d62a17ae | 12383 | |
12384 | if (range) { | |
d62a17ae | 12385 | vty_out(vty, |
1b78780b DL |
12386 | " Belongs to the subnet range group: %pFX\n", |
12387 | range); | |
d62a17ae | 12388 | } |
12389 | } | |
12390 | } | |
12391 | } | |
12392 | ||
12393 | if (use_json) { | |
12394 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12395 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12396 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12397 | json_object_boolean_true_add(json_neigh, |
12398 | "adminShutDown"); | |
12399 | ||
12400 | /* BGP Version. */ | |
12401 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
c949c771 DA |
12402 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", |
12403 | &p->remote_id); | |
12404 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
12405 | &bgp->router_id); | |
d62a17ae | 12406 | |
12407 | /* Confederation */ | |
12408 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12409 | && bgp_confederation_peers_check(bgp, p->as)) | |
12410 | json_object_boolean_true_add(json_neigh, | |
12411 | "nbrCommonAdmin"); | |
12412 | ||
12413 | /* Status. */ | |
12414 | json_object_string_add( | |
12415 | json_neigh, "bgpState", | |
12416 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12417 | ||
feb17238 | 12418 | if (peer_established(p)) { |
d62a17ae | 12419 | time_t uptime; |
d62a17ae | 12420 | |
12421 | uptime = bgp_clock(); | |
12422 | uptime -= p->uptime; | |
d62a17ae | 12423 | epoch_tbuf = time(NULL) - uptime; |
12424 | ||
d3c7efed DS |
12425 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12426 | uptime * 1000); | |
d62a17ae | 12427 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12428 | peer_uptime(p->uptime, timebuf, | |
12429 | BGP_UPTIME_LEN, 0, | |
12430 | NULL)); | |
12431 | json_object_int_add(json_neigh, | |
12432 | "bgpTimerUpEstablishedEpoch", | |
12433 | epoch_tbuf); | |
12434 | } | |
12435 | ||
12436 | else if (p->status == Active) { | |
12437 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12438 | json_object_string_add(json_neigh, "bgpStateIs", | |
12439 | "passive"); | |
12440 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12441 | json_object_string_add(json_neigh, "bgpStateIs", | |
12442 | "passiveNSF"); | |
12443 | } | |
12444 | ||
12445 | /* read timer */ | |
12446 | time_t uptime; | |
a2700b50 | 12447 | struct tm tm; |
d62a17ae | 12448 | |
12449 | uptime = bgp_clock(); | |
12450 | uptime -= p->readtime; | |
a2700b50 MS |
12451 | gmtime_r(&uptime, &tm); |
12452 | ||
d62a17ae | 12453 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12454 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12455 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12456 | |
12457 | uptime = bgp_clock(); | |
12458 | uptime -= p->last_write; | |
a2700b50 MS |
12459 | gmtime_r(&uptime, &tm); |
12460 | ||
d62a17ae | 12461 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12462 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12463 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12464 | |
12465 | uptime = bgp_clock(); | |
12466 | uptime -= p->update_time; | |
a2700b50 MS |
12467 | gmtime_r(&uptime, &tm); |
12468 | ||
d62a17ae | 12469 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12470 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12471 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12472 | |
12473 | /* Configured timer values. */ | |
12474 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12475 | p->v_holdtime * 1000); | |
12476 | json_object_int_add(json_neigh, | |
12477 | "bgpTimerKeepAliveIntervalMsecs", | |
12478 | p->v_keepalive * 1000); | |
d43114f3 DS |
12479 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
12480 | json_object_int_add(json_neigh, | |
12481 | "bgpTimerDelayOpenTimeMsecs", | |
12482 | p->v_delayopen * 1000); | |
12483 | } | |
12484 | ||
4ab46701 AR |
12485 | /* Configured and Synced tcp-mss value for peer */ |
12486 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12487 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12488 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
12489 | p->tcp_mss); | |
12490 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
12491 | sync_tcp_mss); | |
12492 | } | |
12493 | ||
b90a8e13 | 12494 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12495 | json_object_int_add(json_neigh, |
12496 | "bgpTimerConfiguredHoldTimeMsecs", | |
12497 | p->holdtime * 1000); | |
12498 | json_object_int_add( | |
12499 | json_neigh, | |
12500 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12501 | p->keepalive * 1000); | |
5d5393b9 DL |
12502 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12503 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12504 | json_object_int_add(json_neigh, |
12505 | "bgpTimerConfiguredHoldTimeMsecs", | |
12506 | bgp->default_holdtime); | |
12507 | json_object_int_add( | |
12508 | json_neigh, | |
12509 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12510 | bgp->default_keepalive); | |
d62a17ae | 12511 | } |
12512 | } else { | |
12513 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12514 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12515 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12516 | vty_out(vty, " Administratively shut down\n"); |
12517 | ||
12518 | /* BGP Version. */ | |
12519 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12520 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12521 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12522 | vty_out(vty, ", local router ID %s\n", |
12523 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12524 | sizeof(buf1))); | |
d62a17ae | 12525 | |
12526 | /* Confederation */ | |
12527 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12528 | && bgp_confederation_peers_check(bgp, p->as)) | |
12529 | vty_out(vty, | |
12530 | " Neighbor under common administration\n"); | |
12531 | ||
12532 | /* Status. */ | |
12533 | vty_out(vty, " BGP state = %s", | |
12534 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12535 | ||
feb17238 | 12536 | if (peer_established(p)) |
d62a17ae | 12537 | vty_out(vty, ", up for %8s", |
12538 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12539 | 0, NULL)); | |
12540 | ||
12541 | else if (p->status == Active) { | |
12542 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12543 | vty_out(vty, " (passive)"); | |
12544 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12545 | vty_out(vty, " (NSF passive)"); | |
12546 | } | |
12547 | vty_out(vty, "\n"); | |
12548 | ||
12549 | /* read timer */ | |
12550 | vty_out(vty, " Last read %s", | |
12551 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12552 | NULL)); | |
12553 | vty_out(vty, ", Last write %s\n", | |
12554 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12555 | NULL)); | |
12556 | ||
12557 | /* Configured timer values. */ | |
12558 | vty_out(vty, | |
12559 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12560 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12561 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12562 | vty_out(vty, " Configured hold time is %d", |
12563 | p->holdtime); | |
12564 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12565 | p->keepalive); | |
5d5393b9 DL |
12566 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12567 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12568 | vty_out(vty, " Configured hold time is %d", |
12569 | bgp->default_holdtime); | |
12570 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12571 | bgp->default_keepalive); | |
d62a17ae | 12572 | } |
d43114f3 DS |
12573 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
12574 | vty_out(vty, | |
12575 | " Configured DelayOpenTime is %d seconds\n", | |
12576 | p->delayopen); | |
4ab46701 AR |
12577 | |
12578 | /* Configured and synced tcp-mss value for peer */ | |
12579 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12580 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12581 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
12582 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
12583 | } | |
d62a17ae | 12584 | } |
12585 | /* Capability. */ | |
feb17238 | 12586 | if (peer_established(p)) { |
d62a17ae | 12587 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] |
12588 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
12589 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
12590 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
12591 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
12592 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
12593 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
12594 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
12595 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
12596 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
12597 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
12598 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 12599 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
12600 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 12601 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
12602 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 12603 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
12604 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 12605 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
12606 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
12607 | if (use_json) { | |
12608 | json_object *json_cap = NULL; | |
12609 | ||
12610 | json_cap = json_object_new_object(); | |
12611 | ||
12612 | /* AS4 */ | |
12613 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12614 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12615 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
12616 | && CHECK_FLAG(p->cap, | |
12617 | PEER_CAP_AS4_RCV)) | |
12618 | json_object_string_add( | |
12619 | json_cap, "4byteAs", | |
12620 | "advertisedAndReceived"); | |
12621 | else if (CHECK_FLAG(p->cap, | |
12622 | PEER_CAP_AS4_ADV)) | |
12623 | json_object_string_add( | |
12624 | json_cap, "4byteAs", | |
12625 | "advertised"); | |
12626 | else if (CHECK_FLAG(p->cap, | |
12627 | PEER_CAP_AS4_RCV)) | |
12628 | json_object_string_add( | |
12629 | json_cap, "4byteAs", | |
12630 | "received"); | |
12631 | } | |
12632 | ||
ef56aee4 DA |
12633 | /* Extended Message Support */ |
12634 | if (CHECK_FLAG(p->cap, | |
12635 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
12636 | && CHECK_FLAG( | |
12637 | p->cap, | |
12638 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12639 | json_object_string_add( | |
12640 | json_cap, "extendedMessage", | |
12641 | "advertisedAndReceived"); | |
12642 | else if (CHECK_FLAG( | |
12643 | p->cap, | |
12644 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
12645 | json_object_string_add( | |
12646 | json_cap, "extendedMessage", | |
12647 | "advertised"); | |
12648 | else if (CHECK_FLAG( | |
12649 | p->cap, | |
12650 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12651 | json_object_string_add( | |
12652 | json_cap, "extendedMessage", | |
12653 | "received"); | |
12654 | ||
d62a17ae | 12655 | /* AddPath */ |
12656 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12657 | || CHECK_FLAG(p->cap, | |
12658 | PEER_CAP_ADDPATH_ADV)) { | |
12659 | json_object *json_add = NULL; | |
12660 | const char *print_store; | |
12661 | ||
12662 | json_add = json_object_new_object(); | |
12663 | ||
05c7a1cc QY |
12664 | FOREACH_AFI_SAFI (afi, safi) { |
12665 | json_object *json_sub = NULL; | |
12666 | json_sub = | |
12667 | json_object_new_object(); | |
5cb5f4d0 DD |
12668 | print_store = get_afi_safi_str( |
12669 | afi, safi, true); | |
d62a17ae | 12670 | |
05c7a1cc QY |
12671 | if (CHECK_FLAG( |
12672 | p->af_cap[afi] | |
12673 | [safi], | |
12674 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12675 | || CHECK_FLAG( | |
12676 | p->af_cap[afi] | |
12677 | [safi], | |
12678 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 12679 | if (CHECK_FLAG( |
12680 | p->af_cap | |
12681 | [afi] | |
12682 | [safi], | |
12683 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 12684 | && CHECK_FLAG( |
d62a17ae | 12685 | p->af_cap |
12686 | [afi] | |
12687 | [safi], | |
05c7a1cc QY |
12688 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12689 | json_object_boolean_true_add( | |
12690 | json_sub, | |
12691 | "txAdvertisedAndReceived"); | |
12692 | else if ( | |
12693 | CHECK_FLAG( | |
12694 | p->af_cap | |
12695 | [afi] | |
12696 | [safi], | |
12697 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12698 | json_object_boolean_true_add( | |
12699 | json_sub, | |
12700 | "txAdvertised"); | |
12701 | else if ( | |
12702 | CHECK_FLAG( | |
12703 | p->af_cap | |
12704 | [afi] | |
12705 | [safi], | |
12706 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12707 | json_object_boolean_true_add( | |
12708 | json_sub, | |
12709 | "txReceived"); | |
12710 | } | |
d62a17ae | 12711 | |
05c7a1cc QY |
12712 | if (CHECK_FLAG( |
12713 | p->af_cap[afi] | |
12714 | [safi], | |
12715 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12716 | || CHECK_FLAG( | |
12717 | p->af_cap[afi] | |
12718 | [safi], | |
12719 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 12720 | if (CHECK_FLAG( |
12721 | p->af_cap | |
12722 | [afi] | |
12723 | [safi], | |
12724 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 12725 | && CHECK_FLAG( |
d62a17ae | 12726 | p->af_cap |
12727 | [afi] | |
12728 | [safi], | |
12729 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
12730 | json_object_boolean_true_add( |
12731 | json_sub, | |
12732 | "rxAdvertisedAndReceived"); | |
12733 | else if ( | |
12734 | CHECK_FLAG( | |
12735 | p->af_cap | |
12736 | [afi] | |
12737 | [safi], | |
12738 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12739 | json_object_boolean_true_add( | |
12740 | json_sub, | |
12741 | "rxAdvertised"); | |
12742 | else if ( | |
12743 | CHECK_FLAG( | |
12744 | p->af_cap | |
12745 | [afi] | |
12746 | [safi], | |
12747 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12748 | json_object_boolean_true_add( | |
12749 | json_sub, | |
12750 | "rxReceived"); | |
d62a17ae | 12751 | } |
12752 | ||
05c7a1cc QY |
12753 | if (CHECK_FLAG( |
12754 | p->af_cap[afi] | |
12755 | [safi], | |
12756 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12757 | || CHECK_FLAG( | |
12758 | p->af_cap[afi] | |
12759 | [safi], | |
12760 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
12761 | || CHECK_FLAG( | |
12762 | p->af_cap[afi] | |
12763 | [safi], | |
12764 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12765 | || CHECK_FLAG( | |
12766 | p->af_cap[afi] | |
12767 | [safi], | |
12768 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12769 | json_object_object_add( | |
12770 | json_add, | |
12771 | print_store, | |
12772 | json_sub); | |
12773 | else | |
12774 | json_object_free( | |
12775 | json_sub); | |
12776 | } | |
12777 | ||
d62a17ae | 12778 | json_object_object_add( |
12779 | json_cap, "addPath", json_add); | |
12780 | } | |
12781 | ||
12782 | /* Dynamic */ | |
12783 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12784 | || CHECK_FLAG(p->cap, | |
12785 | PEER_CAP_DYNAMIC_ADV)) { | |
12786 | if (CHECK_FLAG(p->cap, | |
12787 | PEER_CAP_DYNAMIC_ADV) | |
12788 | && CHECK_FLAG(p->cap, | |
12789 | PEER_CAP_DYNAMIC_RCV)) | |
12790 | json_object_string_add( | |
12791 | json_cap, "dynamic", | |
12792 | "advertisedAndReceived"); | |
12793 | else if (CHECK_FLAG( | |
12794 | p->cap, | |
12795 | PEER_CAP_DYNAMIC_ADV)) | |
12796 | json_object_string_add( | |
12797 | json_cap, "dynamic", | |
12798 | "advertised"); | |
12799 | else if (CHECK_FLAG( | |
12800 | p->cap, | |
12801 | PEER_CAP_DYNAMIC_RCV)) | |
12802 | json_object_string_add( | |
12803 | json_cap, "dynamic", | |
12804 | "received"); | |
12805 | } | |
12806 | ||
12807 | /* Extended nexthop */ | |
12808 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12809 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12810 | json_object *json_nxt = NULL; | |
12811 | const char *print_store; | |
12812 | ||
12813 | ||
12814 | if (CHECK_FLAG(p->cap, | |
12815 | PEER_CAP_ENHE_ADV) | |
12816 | && CHECK_FLAG(p->cap, | |
12817 | PEER_CAP_ENHE_RCV)) | |
12818 | json_object_string_add( | |
12819 | json_cap, | |
12820 | "extendedNexthop", | |
12821 | "advertisedAndReceived"); | |
12822 | else if (CHECK_FLAG(p->cap, | |
12823 | PEER_CAP_ENHE_ADV)) | |
12824 | json_object_string_add( | |
12825 | json_cap, | |
12826 | "extendedNexthop", | |
12827 | "advertised"); | |
12828 | else if (CHECK_FLAG(p->cap, | |
12829 | PEER_CAP_ENHE_RCV)) | |
12830 | json_object_string_add( | |
12831 | json_cap, | |
12832 | "extendedNexthop", | |
12833 | "received"); | |
12834 | ||
12835 | if (CHECK_FLAG(p->cap, | |
12836 | PEER_CAP_ENHE_RCV)) { | |
12837 | json_nxt = | |
12838 | json_object_new_object(); | |
12839 | ||
12840 | for (safi = SAFI_UNICAST; | |
12841 | safi < SAFI_MAX; safi++) { | |
12842 | if (CHECK_FLAG( | |
12843 | p->af_cap | |
12844 | [AFI_IP] | |
12845 | [safi], | |
12846 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 12847 | print_store = get_afi_safi_str( |
d62a17ae | 12848 | AFI_IP, |
5cb5f4d0 | 12849 | safi, true); |
d62a17ae | 12850 | json_object_string_add( |
12851 | json_nxt, | |
12852 | print_store, | |
54f29523 | 12853 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12854 | } |
12855 | } | |
12856 | json_object_object_add( | |
12857 | json_cap, | |
12858 | "extendedNexthopFamililesByPeer", | |
12859 | json_nxt); | |
12860 | } | |
12861 | } | |
12862 | ||
8606be87 DA |
12863 | /* Long-lived Graceful Restart */ |
12864 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) | |
12865 | || CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
12866 | json_object *json_llgr = NULL; | |
12867 | const char *afi_safi_str; | |
12868 | ||
12869 | if (CHECK_FLAG(p->cap, | |
12870 | PEER_CAP_LLGR_ADV) | |
12871 | && CHECK_FLAG(p->cap, | |
12872 | PEER_CAP_LLGR_RCV)) | |
12873 | json_object_string_add( | |
12874 | json_cap, | |
12875 | "longLivedGracefulRestart", | |
12876 | "advertisedAndReceived"); | |
12877 | else if (CHECK_FLAG(p->cap, | |
12878 | PEER_CAP_LLGR_ADV)) | |
12879 | json_object_string_add( | |
12880 | json_cap, | |
12881 | "longLivedGracefulRestart", | |
12882 | "advertised"); | |
12883 | else if (CHECK_FLAG(p->cap, | |
12884 | PEER_CAP_LLGR_RCV)) | |
12885 | json_object_string_add( | |
12886 | json_cap, | |
12887 | "longLivedGracefulRestart", | |
12888 | "received"); | |
12889 | ||
12890 | if (CHECK_FLAG(p->cap, | |
12891 | PEER_CAP_LLGR_RCV)) { | |
12892 | json_llgr = | |
12893 | json_object_new_object(); | |
12894 | ||
12895 | FOREACH_AFI_SAFI (afi, safi) { | |
12896 | if (CHECK_FLAG( | |
12897 | p->af_cap | |
12898 | [afi] | |
12899 | [safi], | |
12900 | PEER_CAP_ENHE_AF_RCV)) { | |
12901 | afi_safi_str = get_afi_safi_str( | |
12902 | afi, | |
12903 | safi, | |
12904 | true); | |
12905 | json_object_string_add( | |
12906 | json_llgr, | |
12907 | afi_safi_str, | |
12908 | "received"); | |
12909 | } | |
12910 | } | |
12911 | json_object_object_add( | |
12912 | json_cap, | |
12913 | "longLivedGracefulRestartByPeer", | |
12914 | json_llgr); | |
12915 | } | |
12916 | } | |
12917 | ||
d62a17ae | 12918 | /* Route Refresh */ |
12919 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12920 | || CHECK_FLAG(p->cap, | |
12921 | PEER_CAP_REFRESH_NEW_RCV) | |
12922 | || CHECK_FLAG(p->cap, | |
12923 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12924 | if (CHECK_FLAG(p->cap, | |
12925 | PEER_CAP_REFRESH_ADV) | |
12926 | && (CHECK_FLAG( | |
12927 | p->cap, | |
12928 | PEER_CAP_REFRESH_NEW_RCV) | |
12929 | || CHECK_FLAG( | |
12930 | p->cap, | |
12931 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12932 | if (CHECK_FLAG( | |
12933 | p->cap, | |
12934 | PEER_CAP_REFRESH_OLD_RCV) | |
12935 | && CHECK_FLAG( | |
12936 | p->cap, | |
12937 | PEER_CAP_REFRESH_NEW_RCV)) | |
12938 | json_object_string_add( | |
12939 | json_cap, | |
12940 | "routeRefresh", | |
12941 | "advertisedAndReceivedOldNew"); | |
12942 | else { | |
12943 | if (CHECK_FLAG( | |
12944 | p->cap, | |
12945 | PEER_CAP_REFRESH_OLD_RCV)) | |
12946 | json_object_string_add( | |
12947 | json_cap, | |
12948 | "routeRefresh", | |
12949 | "advertisedAndReceivedOld"); | |
12950 | else | |
12951 | json_object_string_add( | |
12952 | json_cap, | |
12953 | "routeRefresh", | |
12954 | "advertisedAndReceivedNew"); | |
12955 | } | |
12956 | } else if ( | |
12957 | CHECK_FLAG( | |
12958 | p->cap, | |
12959 | PEER_CAP_REFRESH_ADV)) | |
12960 | json_object_string_add( | |
12961 | json_cap, | |
12962 | "routeRefresh", | |
12963 | "advertised"); | |
12964 | else if ( | |
12965 | CHECK_FLAG( | |
12966 | p->cap, | |
12967 | PEER_CAP_REFRESH_NEW_RCV) | |
12968 | || CHECK_FLAG( | |
12969 | p->cap, | |
12970 | PEER_CAP_REFRESH_OLD_RCV)) | |
12971 | json_object_string_add( | |
12972 | json_cap, | |
12973 | "routeRefresh", | |
12974 | "received"); | |
12975 | } | |
12976 | ||
9af52ccf DA |
12977 | /* Enhanced Route Refresh */ |
12978 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
12979 | || CHECK_FLAG(p->cap, | |
12980 | PEER_CAP_ENHANCED_RR_RCV)) { | |
12981 | if (CHECK_FLAG(p->cap, | |
12982 | PEER_CAP_ENHANCED_RR_ADV) | |
12983 | && CHECK_FLAG( | |
12984 | p->cap, | |
12985 | PEER_CAP_ENHANCED_RR_RCV)) | |
12986 | json_object_string_add( | |
12987 | json_cap, | |
12988 | "enhancedRouteRefresh", | |
12989 | "advertisedAndReceived"); | |
12990 | else if ( | |
12991 | CHECK_FLAG( | |
12992 | p->cap, | |
12993 | PEER_CAP_ENHANCED_RR_ADV)) | |
12994 | json_object_string_add( | |
12995 | json_cap, | |
12996 | "enhancedRouteRefresh", | |
12997 | "advertised"); | |
12998 | else if ( | |
12999 | CHECK_FLAG( | |
13000 | p->cap, | |
13001 | PEER_CAP_ENHANCED_RR_RCV)) | |
13002 | json_object_string_add( | |
13003 | json_cap, | |
13004 | "enhancedRouteRefresh", | |
13005 | "received"); | |
13006 | } | |
13007 | ||
d62a17ae | 13008 | /* Multiprotocol Extensions */ |
13009 | json_object *json_multi = NULL; | |
13010 | json_multi = json_object_new_object(); | |
13011 | ||
05c7a1cc QY |
13012 | FOREACH_AFI_SAFI (afi, safi) { |
13013 | if (p->afc_adv[afi][safi] | |
13014 | || p->afc_recv[afi][safi]) { | |
13015 | json_object *json_exten = NULL; | |
13016 | json_exten = | |
13017 | json_object_new_object(); | |
13018 | ||
d62a17ae | 13019 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
13020 | && p->afc_recv[afi][safi]) |
13021 | json_object_boolean_true_add( | |
13022 | json_exten, | |
13023 | "advertisedAndReceived"); | |
13024 | else if (p->afc_adv[afi][safi]) | |
13025 | json_object_boolean_true_add( | |
13026 | json_exten, | |
13027 | "advertised"); | |
13028 | else if (p->afc_recv[afi][safi]) | |
13029 | json_object_boolean_true_add( | |
13030 | json_exten, | |
13031 | "received"); | |
d62a17ae | 13032 | |
05c7a1cc QY |
13033 | json_object_object_add( |
13034 | json_multi, | |
5cb5f4d0 DD |
13035 | get_afi_safi_str(afi, |
13036 | safi, | |
13037 | true), | |
05c7a1cc | 13038 | json_exten); |
d62a17ae | 13039 | } |
13040 | } | |
13041 | json_object_object_add( | |
13042 | json_cap, "multiprotocolExtensions", | |
13043 | json_multi); | |
13044 | ||
d77114b7 | 13045 | /* Hostname capabilities */ |
60466a63 | 13046 | json_object *json_hname = NULL; |
d77114b7 MK |
13047 | |
13048 | json_hname = json_object_new_object(); | |
13049 | ||
13050 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
13051 | json_object_string_add( | |
60466a63 QY |
13052 | json_hname, "advHostName", |
13053 | bgp->peer_self->hostname | |
13054 | ? bgp->peer_self | |
13055 | ->hostname | |
d77114b7 MK |
13056 | : "n/a"); |
13057 | json_object_string_add( | |
60466a63 QY |
13058 | json_hname, "advDomainName", |
13059 | bgp->peer_self->domainname | |
13060 | ? bgp->peer_self | |
13061 | ->domainname | |
d77114b7 MK |
13062 | : "n/a"); |
13063 | } | |
13064 | ||
13065 | ||
13066 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
13067 | json_object_string_add( | |
60466a63 QY |
13068 | json_hname, "rcvHostName", |
13069 | p->hostname ? p->hostname | |
13070 | : "n/a"); | |
d77114b7 | 13071 | json_object_string_add( |
60466a63 QY |
13072 | json_hname, "rcvDomainName", |
13073 | p->domainname ? p->domainname | |
13074 | : "n/a"); | |
d77114b7 MK |
13075 | } |
13076 | ||
60466a63 | 13077 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
13078 | json_hname); |
13079 | ||
d62a17ae | 13080 | /* Gracefull Restart */ |
13081 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
13082 | || CHECK_FLAG(p->cap, | |
13083 | PEER_CAP_RESTART_ADV)) { | |
13084 | if (CHECK_FLAG(p->cap, | |
13085 | PEER_CAP_RESTART_ADV) | |
13086 | && CHECK_FLAG(p->cap, | |
13087 | PEER_CAP_RESTART_RCV)) | |
13088 | json_object_string_add( | |
13089 | json_cap, | |
13090 | "gracefulRestart", | |
13091 | "advertisedAndReceived"); | |
13092 | else if (CHECK_FLAG( | |
13093 | p->cap, | |
13094 | PEER_CAP_RESTART_ADV)) | |
13095 | json_object_string_add( | |
13096 | json_cap, | |
13097 | "gracefulRestartCapability", | |
13098 | "advertised"); | |
13099 | else if (CHECK_FLAG( | |
13100 | p->cap, | |
13101 | PEER_CAP_RESTART_RCV)) | |
13102 | json_object_string_add( | |
13103 | json_cap, | |
13104 | "gracefulRestartCapability", | |
13105 | "received"); | |
13106 | ||
13107 | if (CHECK_FLAG(p->cap, | |
13108 | PEER_CAP_RESTART_RCV)) { | |
13109 | int restart_af_count = 0; | |
13110 | json_object *json_restart = | |
13111 | NULL; | |
13112 | json_restart = | |
13113 | json_object_new_object(); | |
13114 | ||
13115 | json_object_int_add( | |
13116 | json_cap, | |
13117 | "gracefulRestartRemoteTimerMsecs", | |
13118 | p->v_gr_restart * 1000); | |
13119 | ||
05c7a1cc QY |
13120 | FOREACH_AFI_SAFI (afi, safi) { |
13121 | if (CHECK_FLAG( | |
13122 | p->af_cap | |
13123 | [afi] | |
13124 | [safi], | |
13125 | PEER_CAP_RESTART_AF_RCV)) { | |
13126 | json_object * | |
13127 | json_sub = | |
13128 | NULL; | |
13129 | json_sub = | |
13130 | json_object_new_object(); | |
13131 | ||
d62a17ae | 13132 | if (CHECK_FLAG( |
13133 | p->af_cap | |
13134 | [afi] | |
13135 | [safi], | |
05c7a1cc QY |
13136 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13137 | json_object_boolean_true_add( | |
13138 | json_sub, | |
13139 | "preserved"); | |
13140 | restart_af_count++; | |
13141 | json_object_object_add( | |
13142 | json_restart, | |
5cb5f4d0 | 13143 | get_afi_safi_str( |
05c7a1cc | 13144 | afi, |
5cb5f4d0 DD |
13145 | safi, |
13146 | true), | |
05c7a1cc | 13147 | json_sub); |
d62a17ae | 13148 | } |
13149 | } | |
13150 | if (!restart_af_count) { | |
13151 | json_object_string_add( | |
13152 | json_cap, | |
13153 | "addressFamiliesByPeer", | |
13154 | "none"); | |
13155 | json_object_free( | |
13156 | json_restart); | |
13157 | } else | |
13158 | json_object_object_add( | |
13159 | json_cap, | |
13160 | "addressFamiliesByPeer", | |
13161 | json_restart); | |
13162 | } | |
13163 | } | |
13164 | json_object_object_add(json_neigh, | |
13165 | "neighborCapabilities", | |
13166 | json_cap); | |
13167 | } else { | |
13168 | vty_out(vty, " Neighbor capabilities:\n"); | |
13169 | ||
13170 | /* AS4 */ | |
13171 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
13172 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13173 | vty_out(vty, " 4 Byte AS:"); | |
13174 | if (CHECK_FLAG(p->cap, | |
13175 | PEER_CAP_AS4_ADV)) | |
13176 | vty_out(vty, " advertised"); | |
13177 | if (CHECK_FLAG(p->cap, | |
13178 | PEER_CAP_AS4_RCV)) | |
13179 | vty_out(vty, " %sreceived", | |
13180 | CHECK_FLAG( | |
13181 | p->cap, | |
13182 | PEER_CAP_AS4_ADV) | |
13183 | ? "and " | |
13184 | : ""); | |
13185 | vty_out(vty, "\n"); | |
13186 | } | |
13187 | ||
ef56aee4 DA |
13188 | /* Extended Message Support */ |
13189 | if (CHECK_FLAG(p->cap, | |
13190 | PEER_CAP_EXTENDED_MESSAGE_RCV) | |
13191 | || CHECK_FLAG( | |
13192 | p->cap, | |
13193 | PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13194 | vty_out(vty, " Extended Message:"); | |
13195 | if (CHECK_FLAG( | |
13196 | p->cap, | |
13197 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13198 | vty_out(vty, " advertised"); | |
13199 | if (CHECK_FLAG( | |
13200 | p->cap, | |
13201 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13202 | vty_out(vty, " %sreceived", | |
13203 | CHECK_FLAG( | |
13204 | p->cap, | |
13205 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13206 | ? "and " | |
13207 | : ""); | |
13208 | vty_out(vty, "\n"); | |
13209 | } | |
13210 | ||
d62a17ae | 13211 | /* AddPath */ |
13212 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
13213 | || CHECK_FLAG(p->cap, | |
13214 | PEER_CAP_ADDPATH_ADV)) { | |
13215 | vty_out(vty, " AddPath:\n"); | |
13216 | ||
05c7a1cc QY |
13217 | FOREACH_AFI_SAFI (afi, safi) { |
13218 | if (CHECK_FLAG( | |
13219 | p->af_cap[afi] | |
13220 | [safi], | |
13221 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13222 | || CHECK_FLAG( | |
13223 | p->af_cap[afi] | |
13224 | [safi], | |
13225 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13226 | vty_out(vty, | |
13227 | " %s: TX ", | |
5cb5f4d0 | 13228 | get_afi_safi_str( |
05c7a1cc | 13229 | afi, |
5cb5f4d0 DD |
13230 | safi, |
13231 | false)); | |
05c7a1cc | 13232 | |
d62a17ae | 13233 | if (CHECK_FLAG( |
13234 | p->af_cap | |
13235 | [afi] | |
13236 | [safi], | |
05c7a1cc | 13237 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 13238 | vty_out(vty, |
34c71a4d | 13239 | "advertised"); |
d62a17ae | 13240 | |
05c7a1cc QY |
13241 | if (CHECK_FLAG( |
13242 | p->af_cap | |
13243 | [afi] | |
13244 | [safi], | |
13245 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13246 | vty_out(vty, | |
13247 | "%sreceived", | |
13248 | CHECK_FLAG( | |
13249 | p->af_cap | |
13250 | [afi] | |
13251 | [safi], | |
13252 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13253 | ? " and " | |
13254 | : ""); | |
d62a17ae | 13255 | |
05c7a1cc QY |
13256 | vty_out(vty, "\n"); |
13257 | } | |
d62a17ae | 13258 | |
05c7a1cc QY |
13259 | if (CHECK_FLAG( |
13260 | p->af_cap[afi] | |
13261 | [safi], | |
13262 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13263 | || CHECK_FLAG( | |
13264 | p->af_cap[afi] | |
13265 | [safi], | |
13266 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13267 | vty_out(vty, | |
13268 | " %s: RX ", | |
5cb5f4d0 | 13269 | get_afi_safi_str( |
05c7a1cc | 13270 | afi, |
5cb5f4d0 DD |
13271 | safi, |
13272 | false)); | |
d62a17ae | 13273 | |
13274 | if (CHECK_FLAG( | |
13275 | p->af_cap | |
13276 | [afi] | |
13277 | [safi], | |
05c7a1cc | 13278 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 13279 | vty_out(vty, |
34c71a4d | 13280 | "advertised"); |
d62a17ae | 13281 | |
05c7a1cc QY |
13282 | if (CHECK_FLAG( |
13283 | p->af_cap | |
13284 | [afi] | |
13285 | [safi], | |
13286 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 13287 | vty_out(vty, |
05c7a1cc QY |
13288 | "%sreceived", |
13289 | CHECK_FLAG( | |
13290 | p->af_cap | |
13291 | [afi] | |
13292 | [safi], | |
13293 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13294 | ? " and " | |
13295 | : ""); | |
13296 | ||
13297 | vty_out(vty, "\n"); | |
d62a17ae | 13298 | } |
05c7a1cc | 13299 | } |
d62a17ae | 13300 | } |
13301 | ||
13302 | /* Dynamic */ | |
13303 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
13304 | || CHECK_FLAG(p->cap, | |
13305 | PEER_CAP_DYNAMIC_ADV)) { | |
13306 | vty_out(vty, " Dynamic:"); | |
13307 | if (CHECK_FLAG(p->cap, | |
13308 | PEER_CAP_DYNAMIC_ADV)) | |
13309 | vty_out(vty, " advertised"); | |
13310 | if (CHECK_FLAG(p->cap, | |
13311 | PEER_CAP_DYNAMIC_RCV)) | |
13312 | vty_out(vty, " %sreceived", | |
13313 | CHECK_FLAG( | |
13314 | p->cap, | |
13315 | PEER_CAP_DYNAMIC_ADV) | |
13316 | ? "and " | |
13317 | : ""); | |
13318 | vty_out(vty, "\n"); | |
13319 | } | |
13320 | ||
13321 | /* Extended nexthop */ | |
13322 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
13323 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13324 | vty_out(vty, " Extended nexthop:"); | |
13325 | if (CHECK_FLAG(p->cap, | |
13326 | PEER_CAP_ENHE_ADV)) | |
13327 | vty_out(vty, " advertised"); | |
13328 | if (CHECK_FLAG(p->cap, | |
13329 | PEER_CAP_ENHE_RCV)) | |
13330 | vty_out(vty, " %sreceived", | |
13331 | CHECK_FLAG( | |
13332 | p->cap, | |
13333 | PEER_CAP_ENHE_ADV) | |
13334 | ? "and " | |
13335 | : ""); | |
13336 | vty_out(vty, "\n"); | |
13337 | ||
13338 | if (CHECK_FLAG(p->cap, | |
13339 | PEER_CAP_ENHE_RCV)) { | |
13340 | vty_out(vty, | |
13341 | " Address families by peer:\n "); | |
13342 | for (safi = SAFI_UNICAST; | |
13343 | safi < SAFI_MAX; safi++) | |
13344 | if (CHECK_FLAG( | |
13345 | p->af_cap | |
13346 | [AFI_IP] | |
13347 | [safi], | |
13348 | PEER_CAP_ENHE_AF_RCV)) | |
13349 | vty_out(vty, | |
13350 | " %s\n", | |
5cb5f4d0 | 13351 | get_afi_safi_str( |
d62a17ae | 13352 | AFI_IP, |
5cb5f4d0 DD |
13353 | safi, |
13354 | false)); | |
d62a17ae | 13355 | } |
13356 | } | |
13357 | ||
8606be87 DA |
13358 | /* Long-lived Graceful Restart */ |
13359 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) | |
13360 | || CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13361 | vty_out(vty, | |
13362 | " Long-lived Graceful Restart:"); | |
13363 | if (CHECK_FLAG(p->cap, | |
13364 | PEER_CAP_LLGR_ADV)) | |
13365 | vty_out(vty, " advertised"); | |
13366 | if (CHECK_FLAG(p->cap, | |
13367 | PEER_CAP_LLGR_RCV)) | |
13368 | vty_out(vty, " %sreceived", | |
13369 | CHECK_FLAG( | |
13370 | p->cap, | |
13371 | PEER_CAP_LLGR_ADV) | |
13372 | ? "and " | |
13373 | : ""); | |
13374 | vty_out(vty, "\n"); | |
13375 | ||
13376 | if (CHECK_FLAG(p->cap, | |
13377 | PEER_CAP_LLGR_RCV)) { | |
13378 | vty_out(vty, | |
13379 | " Address families by peer:\n"); | |
13380 | FOREACH_AFI_SAFI (afi, safi) | |
13381 | if (CHECK_FLAG( | |
13382 | p->af_cap | |
13383 | [afi] | |
13384 | [safi], | |
13385 | PEER_CAP_LLGR_AF_RCV)) | |
13386 | vty_out(vty, | |
13387 | " %s\n", | |
13388 | get_afi_safi_str( | |
13389 | afi, | |
13390 | safi, | |
13391 | false)); | |
13392 | } | |
13393 | } | |
13394 | ||
d62a17ae | 13395 | /* Route Refresh */ |
13396 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
13397 | || CHECK_FLAG(p->cap, | |
13398 | PEER_CAP_REFRESH_NEW_RCV) | |
13399 | || CHECK_FLAG(p->cap, | |
13400 | PEER_CAP_REFRESH_OLD_RCV)) { | |
13401 | vty_out(vty, " Route refresh:"); | |
13402 | if (CHECK_FLAG(p->cap, | |
13403 | PEER_CAP_REFRESH_ADV)) | |
13404 | vty_out(vty, " advertised"); | |
13405 | if (CHECK_FLAG(p->cap, | |
13406 | PEER_CAP_REFRESH_NEW_RCV) | |
13407 | || CHECK_FLAG( | |
13408 | p->cap, | |
13409 | PEER_CAP_REFRESH_OLD_RCV)) | |
13410 | vty_out(vty, " %sreceived(%s)", | |
13411 | CHECK_FLAG( | |
13412 | p->cap, | |
13413 | PEER_CAP_REFRESH_ADV) | |
13414 | ? "and " | |
13415 | : "", | |
13416 | (CHECK_FLAG( | |
13417 | p->cap, | |
13418 | PEER_CAP_REFRESH_OLD_RCV) | |
13419 | && CHECK_FLAG( | |
13420 | p->cap, | |
13421 | PEER_CAP_REFRESH_NEW_RCV)) | |
13422 | ? "old & new" | |
13423 | : CHECK_FLAG( | |
13424 | p->cap, | |
13425 | PEER_CAP_REFRESH_OLD_RCV) | |
13426 | ? "old" | |
13427 | : "new"); | |
13428 | ||
13429 | vty_out(vty, "\n"); | |
13430 | } | |
13431 | ||
9af52ccf DA |
13432 | /* Enhanced Route Refresh */ |
13433 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) | |
13434 | || CHECK_FLAG(p->cap, | |
13435 | PEER_CAP_ENHANCED_RR_RCV)) { | |
13436 | vty_out(vty, | |
13437 | " Enhanced Route Refresh:"); | |
13438 | if (CHECK_FLAG( | |
13439 | p->cap, | |
13440 | PEER_CAP_ENHANCED_RR_ADV)) | |
13441 | vty_out(vty, " advertised"); | |
13442 | if (CHECK_FLAG( | |
13443 | p->cap, | |
13444 | PEER_CAP_ENHANCED_RR_RCV)) | |
13445 | vty_out(vty, " %sreceived", | |
13446 | CHECK_FLAG( | |
13447 | p->cap, | |
13448 | PEER_CAP_REFRESH_ADV) | |
13449 | ? "and " | |
13450 | : ""); | |
13451 | vty_out(vty, "\n"); | |
13452 | } | |
13453 | ||
d62a17ae | 13454 | /* Multiprotocol Extensions */ |
05c7a1cc QY |
13455 | FOREACH_AFI_SAFI (afi, safi) |
13456 | if (p->afc_adv[afi][safi] | |
13457 | || p->afc_recv[afi][safi]) { | |
13458 | vty_out(vty, | |
13459 | " Address Family %s:", | |
5cb5f4d0 DD |
13460 | get_afi_safi_str( |
13461 | afi, | |
13462 | safi, | |
13463 | false)); | |
05c7a1cc | 13464 | if (p->afc_adv[afi][safi]) |
d62a17ae | 13465 | vty_out(vty, |
05c7a1cc QY |
13466 | " advertised"); |
13467 | if (p->afc_recv[afi][safi]) | |
13468 | vty_out(vty, | |
13469 | " %sreceived", | |
13470 | p->afc_adv[afi] | |
13471 | [safi] | |
13472 | ? "and " | |
13473 | : ""); | |
13474 | vty_out(vty, "\n"); | |
13475 | } | |
d62a17ae | 13476 | |
13477 | /* Hostname capability */ | |
60466a63 | 13478 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
13479 | |
13480 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
13481 | vty_out(vty, |
13482 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
13483 | bgp->peer_self->hostname |
13484 | ? bgp->peer_self | |
13485 | ->hostname | |
d77114b7 | 13486 | : "n/a", |
60466a63 QY |
13487 | bgp->peer_self->domainname |
13488 | ? bgp->peer_self | |
13489 | ->domainname | |
d77114b7 MK |
13490 | : "n/a"); |
13491 | } else { | |
13492 | vty_out(vty, " not advertised"); | |
d62a17ae | 13493 | } |
13494 | ||
d77114b7 | 13495 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
13496 | vty_out(vty, |
13497 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
13498 | p->hostname ? p->hostname |
13499 | : "n/a", | |
13500 | p->domainname ? p->domainname | |
13501 | : "n/a"); | |
d77114b7 MK |
13502 | } else { |
13503 | vty_out(vty, " not received"); | |
13504 | } | |
13505 | ||
13506 | vty_out(vty, "\n"); | |
13507 | ||
61bfbd51 | 13508 | /* Graceful Restart */ |
d62a17ae | 13509 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
13510 | || CHECK_FLAG(p->cap, | |
13511 | PEER_CAP_RESTART_ADV)) { | |
13512 | vty_out(vty, | |
61bfbd51 | 13513 | " Graceful Restart Capability:"); |
d62a17ae | 13514 | if (CHECK_FLAG(p->cap, |
13515 | PEER_CAP_RESTART_ADV)) | |
13516 | vty_out(vty, " advertised"); | |
13517 | if (CHECK_FLAG(p->cap, | |
13518 | PEER_CAP_RESTART_RCV)) | |
13519 | vty_out(vty, " %sreceived", | |
13520 | CHECK_FLAG( | |
13521 | p->cap, | |
13522 | PEER_CAP_RESTART_ADV) | |
13523 | ? "and " | |
13524 | : ""); | |
13525 | vty_out(vty, "\n"); | |
13526 | ||
13527 | if (CHECK_FLAG(p->cap, | |
13528 | PEER_CAP_RESTART_RCV)) { | |
13529 | int restart_af_count = 0; | |
13530 | ||
13531 | vty_out(vty, | |
13532 | " Remote Restart timer is %d seconds\n", | |
13533 | p->v_gr_restart); | |
13534 | vty_out(vty, | |
13535 | " Address families by peer:\n "); | |
13536 | ||
05c7a1cc QY |
13537 | FOREACH_AFI_SAFI (afi, safi) |
13538 | if (CHECK_FLAG( | |
13539 | p->af_cap | |
13540 | [afi] | |
13541 | [safi], | |
13542 | PEER_CAP_RESTART_AF_RCV)) { | |
13543 | vty_out(vty, | |
13544 | "%s%s(%s)", | |
13545 | restart_af_count | |
13546 | ? ", " | |
13547 | : "", | |
5cb5f4d0 | 13548 | get_afi_safi_str( |
05c7a1cc | 13549 | afi, |
5cb5f4d0 DD |
13550 | safi, |
13551 | false), | |
05c7a1cc QY |
13552 | CHECK_FLAG( |
13553 | p->af_cap | |
13554 | [afi] | |
13555 | [safi], | |
13556 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13557 | ? "preserved" | |
13558 | : "not preserved"); | |
13559 | restart_af_count++; | |
13560 | } | |
d62a17ae | 13561 | if (!restart_af_count) |
13562 | vty_out(vty, "none"); | |
13563 | vty_out(vty, "\n"); | |
13564 | } | |
2986cac2 | 13565 | } /* Gracefull Restart */ |
d62a17ae | 13566 | } |
13567 | } | |
13568 | } | |
13569 | ||
13570 | /* graceful restart information */ | |
d62a17ae | 13571 | json_object *json_grace = NULL; |
13572 | json_object *json_grace_send = NULL; | |
13573 | json_object *json_grace_recv = NULL; | |
13574 | int eor_send_af_count = 0; | |
13575 | int eor_receive_af_count = 0; | |
13576 | ||
13577 | if (use_json) { | |
13578 | json_grace = json_object_new_object(); | |
13579 | json_grace_send = json_object_new_object(); | |
13580 | json_grace_recv = json_object_new_object(); | |
13581 | ||
feb17238 | 13582 | if ((peer_established(p)) |
36235319 | 13583 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
05c7a1cc QY |
13584 | FOREACH_AFI_SAFI (afi, safi) { |
13585 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 13586 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
13587 | json_object_boolean_true_add( |
13588 | json_grace_send, | |
5cb5f4d0 DD |
13589 | get_afi_safi_str(afi, |
13590 | safi, | |
13591 | true)); | |
05c7a1cc | 13592 | eor_send_af_count++; |
d62a17ae | 13593 | } |
13594 | } | |
05c7a1cc QY |
13595 | FOREACH_AFI_SAFI (afi, safi) { |
13596 | if (CHECK_FLAG( | |
36235319 QY |
13597 | p->af_sflags[afi][safi], |
13598 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
13599 | json_object_boolean_true_add( |
13600 | json_grace_recv, | |
5cb5f4d0 DD |
13601 | get_afi_safi_str(afi, |
13602 | safi, | |
13603 | true)); | |
05c7a1cc | 13604 | eor_receive_af_count++; |
d62a17ae | 13605 | } |
13606 | } | |
13607 | } | |
36235319 QY |
13608 | json_object_object_add(json_grace, "endOfRibSend", |
13609 | json_grace_send); | |
13610 | json_object_object_add(json_grace, "endOfRibRecv", | |
13611 | json_grace_recv); | |
d62a17ae | 13612 | |
d62a17ae | 13613 | |
13614 | if (p->t_gr_restart) | |
13615 | json_object_int_add(json_grace, | |
13616 | "gracefulRestartTimerMsecs", | |
13617 | thread_timer_remain_second( | |
13618 | p->t_gr_restart) | |
13619 | * 1000); | |
13620 | ||
13621 | if (p->t_gr_stale) | |
13622 | json_object_int_add( | |
13623 | json_grace, | |
13624 | "gracefulStalepathTimerMsecs", | |
13625 | thread_timer_remain_second( | |
13626 | p->t_gr_stale) | |
13627 | * 1000); | |
2986cac2 | 13628 | /* more gr info in new format */ |
13629 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 13630 | json_grace); |
d62a17ae | 13631 | json_object_object_add( |
13632 | json_neigh, "gracefulRestartInfo", json_grace); | |
13633 | } else { | |
2089dd80 | 13634 | vty_out(vty, " Graceful restart information:\n"); |
feb17238 | 13635 | if ((peer_established(p)) |
36235319 | 13636 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
2986cac2 | 13637 | |
d62a17ae | 13638 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
13639 | FOREACH_AFI_SAFI (afi, safi) { |
13640 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13641 | PEER_STATUS_EOR_SEND)) { | |
13642 | vty_out(vty, "%s%s", | |
13643 | eor_send_af_count ? ", " | |
13644 | : "", | |
36235319 QY |
13645 | get_afi_safi_str( |
13646 | afi, safi, | |
13647 | false)); | |
05c7a1cc | 13648 | eor_send_af_count++; |
d62a17ae | 13649 | } |
13650 | } | |
13651 | vty_out(vty, "\n"); | |
13652 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
13653 | FOREACH_AFI_SAFI (afi, safi) { |
13654 | if (CHECK_FLAG( | |
13655 | p->af_sflags[afi][safi], | |
13656 | PEER_STATUS_EOR_RECEIVED)) { | |
13657 | vty_out(vty, "%s%s", | |
13658 | eor_receive_af_count | |
13659 | ? ", " | |
13660 | : "", | |
5cb5f4d0 DD |
13661 | get_afi_safi_str(afi, |
13662 | safi, | |
13663 | false)); | |
05c7a1cc | 13664 | eor_receive_af_count++; |
d62a17ae | 13665 | } |
13666 | } | |
13667 | vty_out(vty, "\n"); | |
13668 | } | |
13669 | ||
13670 | if (p->t_gr_restart) | |
13671 | vty_out(vty, | |
13672 | " The remaining time of restart timer is %ld\n", | |
13673 | thread_timer_remain_second( | |
13674 | p->t_gr_restart)); | |
13675 | ||
13676 | if (p->t_gr_stale) | |
13677 | vty_out(vty, | |
13678 | " The remaining time of stalepath timer is %ld\n", | |
13679 | thread_timer_remain_second( | |
13680 | p->t_gr_stale)); | |
2986cac2 | 13681 | |
13682 | /* more gr info in new format */ | |
13683 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 13684 | } |
2986cac2 | 13685 | |
d62a17ae | 13686 | if (use_json) { |
13687 | json_object *json_stat = NULL; | |
13688 | json_stat = json_object_new_object(); | |
13689 | /* Packet counts. */ | |
43aa5965 QY |
13690 | |
13691 | atomic_size_t outq_count, inq_count; | |
13692 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13693 | memory_order_relaxed); | |
13694 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13695 | memory_order_relaxed); | |
13696 | ||
13697 | json_object_int_add(json_stat, "depthInq", | |
13698 | (unsigned long)inq_count); | |
d62a17ae | 13699 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13700 | (unsigned long)outq_count); |
0112e9e0 QY |
13701 | json_object_int_add(json_stat, "opensSent", |
13702 | atomic_load_explicit(&p->open_out, | |
13703 | memory_order_relaxed)); | |
13704 | json_object_int_add(json_stat, "opensRecv", | |
13705 | atomic_load_explicit(&p->open_in, | |
13706 | memory_order_relaxed)); | |
d62a17ae | 13707 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13708 | atomic_load_explicit(&p->notify_out, |
13709 | memory_order_relaxed)); | |
d62a17ae | 13710 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13711 | atomic_load_explicit(&p->notify_in, |
13712 | memory_order_relaxed)); | |
13713 | json_object_int_add(json_stat, "updatesSent", | |
13714 | atomic_load_explicit(&p->update_out, | |
13715 | memory_order_relaxed)); | |
13716 | json_object_int_add(json_stat, "updatesRecv", | |
13717 | atomic_load_explicit(&p->update_in, | |
13718 | memory_order_relaxed)); | |
d62a17ae | 13719 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13720 | atomic_load_explicit(&p->keepalive_out, |
13721 | memory_order_relaxed)); | |
d62a17ae | 13722 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13723 | atomic_load_explicit(&p->keepalive_in, |
13724 | memory_order_relaxed)); | |
d62a17ae | 13725 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13726 | atomic_load_explicit(&p->refresh_out, |
13727 | memory_order_relaxed)); | |
d62a17ae | 13728 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13729 | atomic_load_explicit(&p->refresh_in, |
13730 | memory_order_relaxed)); | |
d62a17ae | 13731 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13732 | atomic_load_explicit(&p->dynamic_cap_out, |
13733 | memory_order_relaxed)); | |
d62a17ae | 13734 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13735 | atomic_load_explicit(&p->dynamic_cap_in, |
13736 | memory_order_relaxed)); | |
13737 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13738 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13739 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13740 | } else { | |
43aa5965 QY |
13741 | atomic_size_t outq_count, inq_count; |
13742 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13743 | memory_order_relaxed); | |
13744 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13745 | memory_order_relaxed); | |
13746 | ||
d62a17ae | 13747 | /* Packet counts. */ |
13748 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13749 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13750 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13751 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
13752 | vty_out(vty, " Opens: %10d %10d\n", |
13753 | atomic_load_explicit(&p->open_out, | |
13754 | memory_order_relaxed), | |
13755 | atomic_load_explicit(&p->open_in, | |
13756 | memory_order_relaxed)); | |
13757 | vty_out(vty, " Notifications: %10d %10d\n", | |
13758 | atomic_load_explicit(&p->notify_out, | |
13759 | memory_order_relaxed), | |
13760 | atomic_load_explicit(&p->notify_in, | |
13761 | memory_order_relaxed)); | |
13762 | vty_out(vty, " Updates: %10d %10d\n", | |
13763 | atomic_load_explicit(&p->update_out, | |
13764 | memory_order_relaxed), | |
13765 | atomic_load_explicit(&p->update_in, | |
13766 | memory_order_relaxed)); | |
13767 | vty_out(vty, " Keepalives: %10d %10d\n", | |
13768 | atomic_load_explicit(&p->keepalive_out, | |
13769 | memory_order_relaxed), | |
13770 | atomic_load_explicit(&p->keepalive_in, | |
13771 | memory_order_relaxed)); | |
13772 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
13773 | atomic_load_explicit(&p->refresh_out, | |
13774 | memory_order_relaxed), | |
13775 | atomic_load_explicit(&p->refresh_in, | |
13776 | memory_order_relaxed)); | |
d62a17ae | 13777 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
13778 | atomic_load_explicit(&p->dynamic_cap_out, |
13779 | memory_order_relaxed), | |
13780 | atomic_load_explicit(&p->dynamic_cap_in, | |
13781 | memory_order_relaxed)); | |
13782 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
13783 | PEER_TOTAL_RX(p)); | |
d62a17ae | 13784 | } |
13785 | ||
13786 | if (use_json) { | |
13787 | /* advertisement-interval */ | |
13788 | json_object_int_add(json_neigh, | |
13789 | "minBtwnAdvertisementRunsTimerMsecs", | |
13790 | p->v_routeadv * 1000); | |
13791 | ||
13792 | /* Update-source. */ | |
13793 | if (p->update_if || p->update_source) { | |
13794 | if (p->update_if) | |
13795 | json_object_string_add(json_neigh, | |
13796 | "updateSource", | |
13797 | p->update_if); | |
13798 | else if (p->update_source) | |
13799 | json_object_string_add( | |
13800 | json_neigh, "updateSource", | |
13801 | sockunion2str(p->update_source, buf1, | |
13802 | SU_ADDRSTRLEN)); | |
13803 | } | |
13804 | } else { | |
13805 | /* advertisement-interval */ | |
13806 | vty_out(vty, | |
13807 | " Minimum time between advertisement runs is %d seconds\n", | |
13808 | p->v_routeadv); | |
13809 | ||
13810 | /* Update-source. */ | |
13811 | if (p->update_if || p->update_source) { | |
13812 | vty_out(vty, " Update source is "); | |
13813 | if (p->update_if) | |
13814 | vty_out(vty, "%s", p->update_if); | |
13815 | else if (p->update_source) | |
13816 | vty_out(vty, "%s", | |
13817 | sockunion2str(p->update_source, buf1, | |
13818 | SU_ADDRSTRLEN)); | |
13819 | vty_out(vty, "\n"); | |
13820 | } | |
13821 | ||
13822 | vty_out(vty, "\n"); | |
13823 | } | |
13824 | ||
13825 | /* Address Family Information */ | |
13826 | json_object *json_hold = NULL; | |
13827 | ||
13828 | if (use_json) | |
13829 | json_hold = json_object_new_object(); | |
13830 | ||
05c7a1cc QY |
13831 | FOREACH_AFI_SAFI (afi, safi) |
13832 | if (p->afc[afi][safi]) | |
13833 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13834 | json_hold); | |
d62a17ae | 13835 | |
13836 | if (use_json) { | |
13837 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13838 | json_hold); | |
13839 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13840 | p->established); | |
13841 | json_object_int_add(json_neigh, "connectionsDropped", | |
13842 | p->dropped); | |
13843 | } else | |
13844 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13845 | p->established, p->dropped); | |
13846 | ||
13847 | if (!p->last_reset) { | |
13848 | if (use_json) | |
13849 | json_object_string_add(json_neigh, "lastReset", | |
13850 | "never"); | |
13851 | else | |
13852 | vty_out(vty, " Last reset never\n"); | |
13853 | } else { | |
13854 | if (use_json) { | |
13855 | time_t uptime; | |
a2700b50 | 13856 | struct tm tm; |
d62a17ae | 13857 | |
13858 | uptime = bgp_clock(); | |
13859 | uptime -= p->resettime; | |
a2700b50 MS |
13860 | gmtime_r(&uptime, &tm); |
13861 | ||
d62a17ae | 13862 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13863 | (tm.tm_sec * 1000) |
13864 | + (tm.tm_min * 60000) | |
13865 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13866 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13867 | } else { |
13868 | vty_out(vty, " Last reset %s, ", | |
13869 | peer_uptime(p->resettime, timebuf, | |
13870 | BGP_UPTIME_LEN, 0, NULL)); | |
13871 | ||
3577f1c5 | 13872 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13873 | if (p->last_reset_cause_size) { |
13874 | msg = p->last_reset_cause; | |
13875 | vty_out(vty, | |
13876 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13877 | for (i = 1; i <= p->last_reset_cause_size; | |
13878 | i++) { | |
13879 | vty_out(vty, "%02X", *msg++); | |
13880 | ||
13881 | if (i != p->last_reset_cause_size) { | |
13882 | if (i % 16 == 0) { | |
13883 | vty_out(vty, "\n "); | |
13884 | } else if (i % 4 == 0) { | |
13885 | vty_out(vty, " "); | |
13886 | } | |
13887 | } | |
13888 | } | |
13889 | vty_out(vty, "\n"); | |
13890 | } | |
13891 | } | |
13892 | } | |
13893 | ||
13894 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13895 | if (use_json) | |
13896 | json_object_boolean_true_add(json_neigh, | |
13897 | "prefixesConfigExceedMax"); | |
13898 | else | |
13899 | vty_out(vty, | |
13900 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13901 | ||
13902 | if (p->t_pmax_restart) { | |
13903 | if (use_json) { | |
13904 | json_object_boolean_true_add( | |
13905 | json_neigh, "reducePrefixNumFrom"); | |
13906 | json_object_int_add(json_neigh, | |
13907 | "restartInTimerMsec", | |
13908 | thread_timer_remain_second( | |
13909 | p->t_pmax_restart) | |
13910 | * 1000); | |
13911 | } else | |
13912 | vty_out(vty, | |
13913 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13914 | p->host, thread_timer_remain_second( |
13915 | p->t_pmax_restart)); | |
d62a17ae | 13916 | } else { |
13917 | if (use_json) | |
13918 | json_object_boolean_true_add( | |
13919 | json_neigh, | |
13920 | "reducePrefixNumAndClearIpBgp"); | |
13921 | else | |
13922 | vty_out(vty, | |
13923 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13924 | p->host); | |
13925 | } | |
13926 | } | |
13927 | ||
13928 | /* EBGP Multihop and GTSM */ | |
13929 | if (p->sort != BGP_PEER_IBGP) { | |
13930 | if (use_json) { | |
e2521429 | 13931 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13932 | json_object_int_add(json_neigh, |
13933 | "externalBgpNbrMaxHopsAway", | |
13934 | p->gtsm_hops); | |
c8d6f0d6 | 13935 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13936 | json_object_int_add(json_neigh, |
13937 | "externalBgpNbrMaxHopsAway", | |
13938 | p->ttl); | |
13939 | } else { | |
e2521429 | 13940 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13941 | vty_out(vty, |
13942 | " External BGP neighbor may be up to %d hops away.\n", | |
13943 | p->gtsm_hops); | |
c8d6f0d6 | 13944 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 13945 | vty_out(vty, |
13946 | " External BGP neighbor may be up to %d hops away.\n", | |
13947 | p->ttl); | |
13948 | } | |
13949 | } else { | |
e2521429 | 13950 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 13951 | if (use_json) |
13952 | json_object_int_add(json_neigh, | |
13953 | "internalBgpNbrMaxHopsAway", | |
13954 | p->gtsm_hops); | |
13955 | else | |
13956 | vty_out(vty, | |
13957 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13958 | p->gtsm_hops); | |
13959 | } | |
13960 | } | |
13961 | ||
13962 | /* Local address. */ | |
13963 | if (p->su_local) { | |
13964 | if (use_json) { | |
13965 | json_object_string_add(json_neigh, "hostLocal", | |
13966 | sockunion2str(p->su_local, buf1, | |
13967 | SU_ADDRSTRLEN)); | |
13968 | json_object_int_add(json_neigh, "portLocal", | |
13969 | ntohs(p->su_local->sin.sin_port)); | |
13970 | } else | |
13971 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13972 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13973 | ntohs(p->su_local->sin.sin_port)); | |
13974 | } | |
13975 | ||
13976 | /* Remote address. */ | |
13977 | if (p->su_remote) { | |
13978 | if (use_json) { | |
13979 | json_object_string_add(json_neigh, "hostForeign", | |
13980 | sockunion2str(p->su_remote, buf1, | |
13981 | SU_ADDRSTRLEN)); | |
13982 | json_object_int_add(json_neigh, "portForeign", | |
13983 | ntohs(p->su_remote->sin.sin_port)); | |
13984 | } else | |
13985 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13986 | sockunion2str(p->su_remote, buf1, | |
13987 | SU_ADDRSTRLEN), | |
13988 | ntohs(p->su_remote->sin.sin_port)); | |
13989 | } | |
13990 | ||
13991 | /* Nexthop display. */ | |
13992 | if (p->su_local) { | |
13993 | if (use_json) { | |
c949c771 DA |
13994 | json_object_string_addf(json_neigh, "nexthop", "%pI4", |
13995 | &p->nexthop.v4); | |
13996 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
13997 | "%pI6", &p->nexthop.v6_global); | |
13998 | json_object_string_addf(json_neigh, "nexthopLocal", | |
13999 | "%pI6", &p->nexthop.v6_local); | |
d62a17ae | 14000 | if (p->shared_network) |
14001 | json_object_string_add(json_neigh, | |
14002 | "bgpConnection", | |
14003 | "sharedNetwork"); | |
14004 | else | |
14005 | json_object_string_add(json_neigh, | |
14006 | "bgpConnection", | |
14007 | "nonSharedNetwork"); | |
14008 | } else { | |
14009 | vty_out(vty, "Nexthop: %s\n", | |
14010 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
14011 | sizeof(buf1))); | |
14012 | vty_out(vty, "Nexthop global: %s\n", | |
14013 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
14014 | sizeof(buf1))); | |
14015 | vty_out(vty, "Nexthop local: %s\n", | |
14016 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
14017 | sizeof(buf1))); | |
14018 | vty_out(vty, "BGP connection: %s\n", | |
14019 | p->shared_network ? "shared network" | |
14020 | : "non shared network"); | |
14021 | } | |
14022 | } | |
14023 | ||
14024 | /* Timer information. */ | |
14025 | if (use_json) { | |
14026 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14027 | p->v_connect); | |
feb17238 | 14028 | if (peer_established(p) && p->rtt) |
d62a17ae | 14029 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
14030 | p->rtt); | |
14031 | if (p->t_start) | |
14032 | json_object_int_add( | |
14033 | json_neigh, "nextStartTimerDueInMsecs", | |
14034 | thread_timer_remain_second(p->t_start) * 1000); | |
14035 | if (p->t_connect) | |
14036 | json_object_int_add( | |
14037 | json_neigh, "nextConnectTimerDueInMsecs", | |
14038 | thread_timer_remain_second(p->t_connect) | |
14039 | * 1000); | |
14040 | if (p->t_routeadv) { | |
14041 | json_object_int_add(json_neigh, "mraiInterval", | |
14042 | p->v_routeadv); | |
14043 | json_object_int_add( | |
14044 | json_neigh, "mraiTimerExpireInMsecs", | |
14045 | thread_timer_remain_second(p->t_routeadv) | |
14046 | * 1000); | |
14047 | } | |
14048 | if (p->password) | |
14049 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14050 | 1); | |
14051 | ||
14052 | if (p->t_read) | |
14053 | json_object_string_add(json_neigh, "readThread", "on"); | |
14054 | else | |
14055 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14056 | |
14057 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14058 | json_object_string_add(json_neigh, "writeThread", "on"); |
14059 | else | |
14060 | json_object_string_add(json_neigh, "writeThread", | |
14061 | "off"); | |
14062 | } else { | |
14063 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14064 | p->v_connect); | |
feb17238 | 14065 | if (peer_established(p) && p->rtt) |
d62a17ae | 14066 | vty_out(vty, "Estimated round trip time: %d ms\n", |
14067 | p->rtt); | |
14068 | if (p->t_start) | |
14069 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14070 | thread_timer_remain_second(p->t_start)); | |
14071 | if (p->t_connect) | |
14072 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14073 | thread_timer_remain_second(p->t_connect)); | |
14074 | if (p->t_routeadv) | |
14075 | vty_out(vty, | |
14076 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14077 | p->v_routeadv, | |
14078 | thread_timer_remain_second(p->t_routeadv)); | |
14079 | if (p->password) | |
14080 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14081 | ||
cac9e917 | 14082 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14083 | p->t_read ? "on" : "off", |
14084 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14085 | ? "on" | |
cac9e917 | 14086 | : "off", p->fd); |
d62a17ae | 14087 | } |
14088 | ||
14089 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14090 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14091 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14092 | ||
14093 | if (!use_json) | |
14094 | vty_out(vty, "\n"); | |
14095 | ||
14096 | /* BFD information. */ | |
21bfce98 RZ |
14097 | if (p->bfd_config) |
14098 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 14099 | |
14100 | if (use_json) { | |
14101 | if (p->conf_if) /* Configured interface name. */ | |
14102 | json_object_object_add(json, p->conf_if, json_neigh); | |
14103 | else /* Configured IP address. */ | |
14104 | json_object_object_add(json, p->host, json_neigh); | |
14105 | } | |
14106 | } | |
14107 | ||
36235319 QY |
14108 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14109 | enum show_type type, | |
14110 | union sockunion *su, | |
14111 | const char *conf_if, afi_t afi, | |
74a630b6 | 14112 | bool use_json) |
2986cac2 | 14113 | { |
14114 | struct listnode *node, *nnode; | |
14115 | struct peer *peer; | |
14116 | int find = 0; | |
14117 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14118 | json_object *json = NULL; |
2986cac2 | 14119 | json_object *json_neighbor = NULL; |
14120 | ||
74a630b6 NT |
14121 | if (use_json) { |
14122 | json = json_object_new_object(); | |
14123 | json_neighbor = json_object_new_object(); | |
14124 | } | |
14125 | ||
2986cac2 | 14126 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14127 | ||
14128 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14129 | continue; | |
14130 | ||
14131 | if ((peer->afc[afi][safi]) == 0) | |
14132 | continue; | |
14133 | ||
2ba1fe69 | 14134 | if (type == show_all) { |
2986cac2 | 14135 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14136 | json_neighbor); |
2986cac2 | 14137 | |
74a630b6 | 14138 | if (use_json) { |
13909c4f DS |
14139 | json_object_object_add(json, peer->host, |
14140 | json_neighbor); | |
74a630b6 NT |
14141 | json_neighbor = NULL; |
14142 | } | |
2986cac2 | 14143 | |
2ba1fe69 | 14144 | } else if (type == show_peer) { |
2986cac2 | 14145 | if (conf_if) { |
14146 | if ((peer->conf_if | |
13909c4f DS |
14147 | && !strcmp(peer->conf_if, conf_if)) |
14148 | || (peer->hostname | |
2986cac2 | 14149 | && !strcmp(peer->hostname, conf_if))) { |
14150 | find = 1; | |
13909c4f DS |
14151 | bgp_show_peer_gr_status(vty, peer, |
14152 | use_json, | |
14153 | json_neighbor); | |
2986cac2 | 14154 | } |
14155 | } else { | |
14156 | if (sockunion_same(&peer->su, su)) { | |
14157 | find = 1; | |
13909c4f DS |
14158 | bgp_show_peer_gr_status(vty, peer, |
14159 | use_json, | |
14160 | json_neighbor); | |
2986cac2 | 14161 | } |
14162 | } | |
13909c4f DS |
14163 | if (use_json && find) |
14164 | json_object_object_add(json, peer->host, | |
14165 | json_neighbor); | |
2986cac2 | 14166 | } |
14167 | ||
74a630b6 NT |
14168 | if (find) { |
14169 | json_neighbor = NULL; | |
2986cac2 | 14170 | break; |
74a630b6 | 14171 | } |
2986cac2 | 14172 | } |
14173 | ||
14174 | if (type == show_peer && !find) { | |
14175 | if (use_json) | |
13909c4f | 14176 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14177 | else |
14178 | vty_out(vty, "%% No such neighbor\n"); | |
14179 | } | |
14180 | if (use_json) { | |
13909c4f DS |
14181 | vty_out(vty, "%s\n", |
14182 | json_object_to_json_string_ext( | |
14183 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
14184 | |
14185 | if (json_neighbor) | |
14186 | json_object_free(json_neighbor); | |
14187 | json_object_free(json); | |
2986cac2 | 14188 | } else { |
14189 | vty_out(vty, "\n"); | |
14190 | } | |
14191 | ||
14192 | return CMD_SUCCESS; | |
14193 | } | |
14194 | ||
d62a17ae | 14195 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14196 | enum show_type type, union sockunion *su, | |
9f049418 | 14197 | const char *conf_if, bool use_json, |
d62a17ae | 14198 | json_object *json) |
14199 | { | |
14200 | struct listnode *node, *nnode; | |
14201 | struct peer *peer; | |
14202 | int find = 0; | |
9f049418 | 14203 | bool nbr_output = false; |
d1927ebe AS |
14204 | afi_t afi = AFI_MAX; |
14205 | safi_t safi = SAFI_MAX; | |
14206 | ||
14207 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14208 | afi = AFI_IP; | |
14209 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14210 | afi = AFI_IP6; | |
14211 | } | |
d62a17ae | 14212 | |
14213 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14214 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14215 | continue; | |
14216 | ||
14217 | switch (type) { | |
14218 | case show_all: | |
14219 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14220 | nbr_output = true; |
d62a17ae | 14221 | break; |
14222 | case show_peer: | |
14223 | if (conf_if) { | |
14224 | if ((peer->conf_if | |
14225 | && !strcmp(peer->conf_if, conf_if)) | |
14226 | || (peer->hostname | |
14227 | && !strcmp(peer->hostname, conf_if))) { | |
14228 | find = 1; | |
14229 | bgp_show_peer(vty, peer, use_json, | |
14230 | json); | |
14231 | } | |
14232 | } else { | |
14233 | if (sockunion_same(&peer->su, su)) { | |
14234 | find = 1; | |
14235 | bgp_show_peer(vty, peer, use_json, | |
14236 | json); | |
14237 | } | |
14238 | } | |
14239 | break; | |
d1927ebe AS |
14240 | case show_ipv4_peer: |
14241 | case show_ipv6_peer: | |
14242 | FOREACH_SAFI (safi) { | |
14243 | if (peer->afc[afi][safi]) { | |
14244 | if (conf_if) { | |
14245 | if ((peer->conf_if | |
14246 | && !strcmp(peer->conf_if, conf_if)) | |
14247 | || (peer->hostname | |
14248 | && !strcmp(peer->hostname, conf_if))) { | |
14249 | find = 1; | |
14250 | bgp_show_peer(vty, peer, use_json, | |
14251 | json); | |
14252 | break; | |
14253 | } | |
14254 | } else { | |
14255 | if (sockunion_same(&peer->su, su)) { | |
14256 | find = 1; | |
14257 | bgp_show_peer(vty, peer, use_json, | |
14258 | json); | |
14259 | break; | |
14260 | } | |
14261 | } | |
14262 | } | |
14263 | } | |
14264 | break; | |
14265 | case show_ipv4_all: | |
14266 | case show_ipv6_all: | |
14267 | FOREACH_SAFI (safi) { | |
14268 | if (peer->afc[afi][safi]) { | |
14269 | bgp_show_peer(vty, peer, use_json, json); | |
14270 | nbr_output = true; | |
14271 | break; | |
14272 | } | |
14273 | } | |
14274 | break; | |
d62a17ae | 14275 | } |
14276 | } | |
14277 | ||
d1927ebe AS |
14278 | if ((type == show_peer || type == show_ipv4_peer || |
14279 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14280 | if (use_json) |
14281 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14282 | else | |
88b7d255 | 14283 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14284 | } |
14285 | ||
d1927ebe AS |
14286 | if (type != show_peer && type != show_ipv4_peer && |
14287 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14288 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14289 | |
d62a17ae | 14290 | if (use_json) { |
996c9314 LB |
14291 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14292 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14293 | } else { |
14294 | vty_out(vty, "\n"); | |
14295 | } | |
14296 | ||
14297 | return CMD_SUCCESS; | |
14298 | } | |
14299 | ||
36235319 QY |
14300 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14301 | enum show_type type, | |
14302 | const char *ip_str, | |
14303 | afi_t afi, bool use_json) | |
2986cac2 | 14304 | { |
14305 | ||
14306 | int ret; | |
14307 | struct bgp *bgp; | |
14308 | union sockunion su; | |
2986cac2 | 14309 | |
14310 | bgp = bgp_get_default(); | |
14311 | ||
13909c4f DS |
14312 | if (!bgp) |
14313 | return; | |
2986cac2 | 14314 | |
13909c4f DS |
14315 | if (!use_json) |
14316 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14317 | NULL); | |
2986cac2 | 14318 | |
13909c4f DS |
14319 | if (ip_str) { |
14320 | ret = str2sockunion(ip_str, &su); | |
14321 | if (ret < 0) | |
13909c4f | 14322 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14323 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14324 | else | |
14325 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14326 | NULL, afi, use_json); | |
13909c4f DS |
14327 | } else |
14328 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14329 | afi, use_json); |
2986cac2 | 14330 | } |
14331 | ||
d62a17ae | 14332 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14333 | enum show_type type, |
14334 | const char *ip_str, | |
9f049418 | 14335 | bool use_json) |
d62a17ae | 14336 | { |
0291c246 MK |
14337 | struct listnode *node, *nnode; |
14338 | struct bgp *bgp; | |
71aedaa3 | 14339 | union sockunion su; |
0291c246 | 14340 | json_object *json = NULL; |
71aedaa3 | 14341 | int ret, is_first = 1; |
9f049418 | 14342 | bool nbr_output = false; |
d62a17ae | 14343 | |
14344 | if (use_json) | |
14345 | vty_out(vty, "{\n"); | |
14346 | ||
14347 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14348 | nbr_output = true; |
d62a17ae | 14349 | if (use_json) { |
14350 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14351 | flog_err( |
e50f7cfd | 14352 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14353 | "Unable to allocate memory for JSON object"); |
14354 | vty_out(vty, | |
14355 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14356 | return; | |
14357 | } | |
14358 | ||
14359 | json_object_int_add(json, "vrfId", | |
14360 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14361 | ? -1 |
14362 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14363 | json_object_string_add( |
14364 | json, "vrfName", | |
14365 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14366 | ? VRF_DEFAULT_NAME |
d62a17ae | 14367 | : bgp->name); |
14368 | ||
14369 | if (!is_first) | |
14370 | vty_out(vty, ",\n"); | |
14371 | else | |
14372 | is_first = 0; | |
14373 | ||
14374 | vty_out(vty, "\"%s\":", | |
14375 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14376 | ? VRF_DEFAULT_NAME |
d62a17ae | 14377 | : bgp->name); |
14378 | } else { | |
14379 | vty_out(vty, "\nInstance %s:\n", | |
14380 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14381 | ? VRF_DEFAULT_NAME |
d62a17ae | 14382 | : bgp->name); |
14383 | } | |
71aedaa3 | 14384 | |
d1927ebe AS |
14385 | if (type == show_peer || type == show_ipv4_peer || |
14386 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14387 | ret = str2sockunion(ip_str, &su); |
14388 | if (ret < 0) | |
14389 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14390 | use_json, json); | |
14391 | else | |
14392 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14393 | use_json, json); | |
14394 | } else { | |
d1927ebe | 14395 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14396 | use_json, json); |
14397 | } | |
b77004d6 | 14398 | json_object_free(json); |
121067e9 | 14399 | json = NULL; |
d62a17ae | 14400 | } |
14401 | ||
3e78a6ce | 14402 | if (use_json) |
d62a17ae | 14403 | vty_out(vty, "}\n"); |
9f049418 DS |
14404 | else if (!nbr_output) |
14405 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14406 | } |
14407 | ||
14408 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14409 | enum show_type type, const char *ip_str, | |
9f049418 | 14410 | bool use_json) |
d62a17ae | 14411 | { |
14412 | int ret; | |
14413 | struct bgp *bgp; | |
14414 | union sockunion su; | |
14415 | json_object *json = NULL; | |
14416 | ||
14417 | if (name) { | |
14418 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14419 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14420 | use_json); | |
d62a17ae | 14421 | return CMD_SUCCESS; |
14422 | } else { | |
14423 | bgp = bgp_lookup_by_name(name); | |
14424 | if (!bgp) { | |
14425 | if (use_json) { | |
14426 | json = json_object_new_object(); | |
d62a17ae | 14427 | vty_out(vty, "%s\n", |
14428 | json_object_to_json_string_ext( | |
14429 | json, | |
14430 | JSON_C_TO_STRING_PRETTY)); | |
14431 | json_object_free(json); | |
14432 | } else | |
14433 | vty_out(vty, | |
9f049418 | 14434 | "%% BGP instance not found\n"); |
d62a17ae | 14435 | |
14436 | return CMD_WARNING; | |
14437 | } | |
14438 | } | |
14439 | } else { | |
14440 | bgp = bgp_get_default(); | |
14441 | } | |
14442 | ||
14443 | if (bgp) { | |
14444 | json = json_object_new_object(); | |
14445 | if (ip_str) { | |
14446 | ret = str2sockunion(ip_str, &su); | |
14447 | if (ret < 0) | |
14448 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14449 | use_json, json); | |
14450 | else | |
14451 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14452 | use_json, json); | |
14453 | } else { | |
14454 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14455 | json); | |
14456 | } | |
14457 | json_object_free(json); | |
ca61fd25 DS |
14458 | } else { |
14459 | if (use_json) | |
14460 | vty_out(vty, "{}\n"); | |
14461 | else | |
14462 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14463 | } |
14464 | ||
14465 | return CMD_SUCCESS; | |
4fb25c53 DW |
14466 | } |
14467 | ||
2986cac2 | 14468 | |
14469 | ||
14470 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14471 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14472 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14473 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14474 | SHOW_STR | |
14475 | BGP_STR | |
14476 | IP_STR | |
14477 | IPV6_STR | |
14478 | NEIGHBOR_STR | |
14479 | "Neighbor to display information about\n" | |
14480 | "Neighbor to display information about\n" | |
14481 | "Neighbor on BGP configured interface\n" | |
14482 | GR_SHOW | |
14483 | JSON_STR) | |
14484 | { | |
14485 | char *sh_arg = NULL; | |
14486 | enum show_type sh_type; | |
14487 | int idx = 0; | |
14488 | afi_t afi = AFI_MAX; | |
2986cac2 | 14489 | bool uj = use_json(argc, argv); |
14490 | ||
36235319 | 14491 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14492 | afi = AFI_MAX; |
14493 | ||
14494 | idx++; | |
14495 | ||
14496 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14497 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14498 | || argv_find(argv, argc, "WORD", &idx)) { | |
14499 | sh_type = show_peer; | |
14500 | sh_arg = argv[idx]->arg; | |
14501 | } else | |
14502 | sh_type = show_all; | |
14503 | ||
14504 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14505 | return CMD_SUCCESS; | |
14506 | ||
14507 | ||
36235319 QY |
14508 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14509 | afi, uj); | |
2986cac2 | 14510 | } |
14511 | ||
716b2d8a | 14512 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14513 | DEFUN (show_ip_bgp_neighbors, |
14514 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14515 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14516 | SHOW_STR |
14517 | IP_STR | |
14518 | BGP_STR | |
f2a8972b | 14519 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14520 | "Address Family\n" |
14521 | "Address Family\n" | |
718e3744 | 14522 | "Detailed information on TCP and BGP neighbor connections\n" |
14523 | "Neighbor to display information about\n" | |
a80beece | 14524 | "Neighbor to display information about\n" |
91d37724 | 14525 | "Neighbor on BGP configured interface\n" |
9973d184 | 14526 | JSON_STR) |
718e3744 | 14527 | { |
d62a17ae | 14528 | char *vrf = NULL; |
14529 | char *sh_arg = NULL; | |
14530 | enum show_type sh_type; | |
d1927ebe | 14531 | afi_t afi = AFI_MAX; |
718e3744 | 14532 | |
9f049418 | 14533 | bool uj = use_json(argc, argv); |
718e3744 | 14534 | |
d62a17ae | 14535 | int idx = 0; |
718e3744 | 14536 | |
9a8bdf1c PG |
14537 | /* [<vrf> VIEWVRFNAME] */ |
14538 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14539 | vrf = argv[idx + 1]->arg; | |
14540 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14541 | vrf = NULL; | |
14542 | } else if (argv_find(argv, argc, "view", &idx)) | |
14543 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14544 | vrf = argv[idx + 1]->arg; |
718e3744 | 14545 | |
d62a17ae | 14546 | idx++; |
d1927ebe AS |
14547 | |
14548 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14549 | sh_type = show_ipv4_all; | |
14550 | afi = AFI_IP; | |
14551 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14552 | sh_type = show_ipv6_all; | |
14553 | afi = AFI_IP6; | |
14554 | } else { | |
14555 | sh_type = show_all; | |
14556 | } | |
14557 | ||
d62a17ae | 14558 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14559 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14560 | || argv_find(argv, argc, "WORD", &idx)) { | |
14561 | sh_type = show_peer; | |
14562 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14563 | } |
14564 | ||
14565 | if (sh_type == show_peer && afi == AFI_IP) { | |
14566 | sh_type = show_ipv4_peer; | |
14567 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14568 | sh_type = show_ipv6_peer; | |
14569 | } | |
856ca177 | 14570 | |
d62a17ae | 14571 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14572 | } |
14573 | ||
716b2d8a | 14574 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14575 | paths' and `show ip mbgp paths'. Those functions results are the |
14576 | same.*/ | |
f412b39a | 14577 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14578 | show_ip_bgp_paths_cmd, |
46f296b4 | 14579 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14580 | SHOW_STR |
14581 | IP_STR | |
14582 | BGP_STR | |
46f296b4 | 14583 | BGP_SAFI_HELP_STR |
718e3744 | 14584 | "Path information\n") |
14585 | { | |
d62a17ae | 14586 | vty_out(vty, "Address Refcnt Path\n"); |
14587 | aspath_print_all_vty(vty); | |
14588 | return CMD_SUCCESS; | |
718e3744 | 14589 | } |
14590 | ||
718e3744 | 14591 | #include "hash.h" |
14592 | ||
e3b78da8 | 14593 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14594 | struct vty *vty) |
718e3744 | 14595 | { |
d62a17ae | 14596 | struct community *com; |
718e3744 | 14597 | |
e3b78da8 | 14598 | com = (struct community *)bucket->data; |
3f65c5b1 | 14599 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 14600 | community_str(com, false)); |
718e3744 | 14601 | } |
14602 | ||
14603 | /* Show BGP's community internal data. */ | |
f412b39a | 14604 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14605 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14606 | "show [ip] bgp community-info", |
718e3744 | 14607 | SHOW_STR |
14608 | IP_STR | |
14609 | BGP_STR | |
14610 | "List all bgp community information\n") | |
14611 | { | |
d62a17ae | 14612 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14613 | |
d62a17ae | 14614 | hash_iterate(community_hash(), |
e3b78da8 | 14615 | (void (*)(struct hash_bucket *, |
d62a17ae | 14616 | void *))community_show_all_iterator, |
14617 | vty); | |
718e3744 | 14618 | |
d62a17ae | 14619 | return CMD_SUCCESS; |
718e3744 | 14620 | } |
14621 | ||
e3b78da8 | 14622 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14623 | struct vty *vty) |
57d187bc | 14624 | { |
d62a17ae | 14625 | struct lcommunity *lcom; |
57d187bc | 14626 | |
e3b78da8 | 14627 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14628 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 14629 | lcommunity_str(lcom, false)); |
57d187bc JS |
14630 | } |
14631 | ||
14632 | /* Show BGP's community internal data. */ | |
14633 | DEFUN (show_ip_bgp_lcommunity_info, | |
14634 | show_ip_bgp_lcommunity_info_cmd, | |
14635 | "show ip bgp large-community-info", | |
14636 | SHOW_STR | |
14637 | IP_STR | |
14638 | BGP_STR | |
14639 | "List all bgp large-community information\n") | |
14640 | { | |
d62a17ae | 14641 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14642 | |
d62a17ae | 14643 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14644 | (void (*)(struct hash_bucket *, |
d62a17ae | 14645 | void *))lcommunity_show_all_iterator, |
14646 | vty); | |
57d187bc | 14647 | |
d62a17ae | 14648 | return CMD_SUCCESS; |
57d187bc | 14649 | } |
2986cac2 | 14650 | /* Graceful Restart */ |
14651 | ||
14652 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14653 | struct bgp *bgp, |
14654 | bool use_json, | |
14655 | json_object *json) | |
2986cac2 | 14656 | { |
57d187bc JS |
14657 | |
14658 | ||
2986cac2 | 14659 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14660 | ||
7318ae88 | 14661 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14662 | |
14663 | switch (bgp_global_gr_mode) { | |
14664 | ||
14665 | case GLOBAL_HELPER: | |
13909c4f | 14666 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14667 | break; |
14668 | ||
14669 | case GLOBAL_GR: | |
13909c4f | 14670 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14671 | break; |
14672 | ||
14673 | case GLOBAL_DISABLE: | |
13909c4f | 14674 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14675 | break; |
14676 | ||
14677 | case GLOBAL_INVALID: | |
2986cac2 | 14678 | vty_out(vty, |
2ba1fe69 | 14679 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14680 | break; |
14681 | } | |
14682 | vty_out(vty, "\n"); | |
14683 | } | |
14684 | ||
36235319 QY |
14685 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14686 | enum show_type type, | |
14687 | const char *ip_str, | |
14688 | afi_t afi, bool use_json) | |
2986cac2 | 14689 | { |
14690 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14691 | afi = AFI_IP; | |
14692 | ||
14693 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14694 | ||
36235319 QY |
14695 | bgp_show_neighbor_graceful_restart_vty( |
14696 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14697 | afi++; |
14698 | } | |
14699 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14700 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14701 | use_json); | |
2986cac2 | 14702 | } else { |
14703 | return CMD_ERR_INCOMPLETE; | |
14704 | } | |
14705 | ||
14706 | return CMD_SUCCESS; | |
14707 | } | |
14708 | /* Graceful Restart */ | |
14709 | ||
f412b39a | 14710 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14711 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14712 | "show [ip] bgp attribute-info", |
718e3744 | 14713 | SHOW_STR |
14714 | IP_STR | |
14715 | BGP_STR | |
14716 | "List all bgp attribute information\n") | |
14717 | { | |
d62a17ae | 14718 | attr_show_all(vty); |
14719 | return CMD_SUCCESS; | |
718e3744 | 14720 | } |
6b0655a2 | 14721 | |
03915806 CS |
14722 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14723 | afi_t afi, safi_t safi, | |
14724 | bool use_json, json_object *json) | |
53089bec | 14725 | { |
14726 | struct bgp *bgp; | |
14727 | struct listnode *node; | |
14728 | char *vname; | |
14729 | char buf1[INET6_ADDRSTRLEN]; | |
14730 | char *ecom_str; | |
14731 | vpn_policy_direction_t dir; | |
14732 | ||
03915806 | 14733 | if (json) { |
b46dfd20 DS |
14734 | json_object *json_import_vrfs = NULL; |
14735 | json_object *json_export_vrfs = NULL; | |
14736 | ||
b46dfd20 DS |
14737 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14738 | ||
53089bec | 14739 | if (!bgp) { |
b46dfd20 DS |
14740 | vty_out(vty, "%s\n", |
14741 | json_object_to_json_string_ext( | |
14742 | json, | |
14743 | JSON_C_TO_STRING_PRETTY)); | |
14744 | json_object_free(json); | |
14745 | ||
53089bec | 14746 | return CMD_WARNING; |
14747 | } | |
b46dfd20 | 14748 | |
94d4c685 DS |
14749 | /* Provide context for the block */ |
14750 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14751 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14752 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14753 | |
b46dfd20 DS |
14754 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14755 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14756 | json_object_string_add(json, "importFromVrfs", "none"); | |
14757 | json_object_string_add(json, "importRts", "none"); | |
14758 | } else { | |
6ce24e52 DS |
14759 | json_import_vrfs = json_object_new_array(); |
14760 | ||
b46dfd20 DS |
14761 | for (ALL_LIST_ELEMENTS_RO( |
14762 | bgp->vpn_policy[afi].import_vrf, | |
14763 | node, vname)) | |
14764 | json_object_array_add(json_import_vrfs, | |
14765 | json_object_new_string(vname)); | |
14766 | ||
b20875ea CS |
14767 | json_object_object_add(json, "importFromVrfs", |
14768 | json_import_vrfs); | |
b46dfd20 | 14769 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14770 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14771 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14772 | bgp->vpn_policy[afi].rtlist[dir], |
14773 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14774 | json_object_string_add(json, "importRts", |
14775 | ecom_str); | |
14776 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14777 | } else | |
14778 | json_object_string_add(json, "importRts", | |
14779 | "none"); | |
b46dfd20 DS |
14780 | } |
14781 | ||
14782 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14783 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14784 | json_object_string_add(json, "exportToVrfs", "none"); | |
14785 | json_object_string_add(json, "routeDistinguisher", | |
14786 | "none"); | |
14787 | json_object_string_add(json, "exportRts", "none"); | |
14788 | } else { | |
6ce24e52 DS |
14789 | json_export_vrfs = json_object_new_array(); |
14790 | ||
b46dfd20 DS |
14791 | for (ALL_LIST_ELEMENTS_RO( |
14792 | bgp->vpn_policy[afi].export_vrf, | |
14793 | node, vname)) | |
14794 | json_object_array_add(json_export_vrfs, | |
14795 | json_object_new_string(vname)); | |
14796 | json_object_object_add(json, "exportToVrfs", | |
14797 | json_export_vrfs); | |
14798 | json_object_string_add(json, "routeDistinguisher", | |
14799 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14800 | buf1, RD_ADDRSTRLEN)); | |
14801 | ||
14802 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14803 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14804 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14805 | bgp->vpn_policy[afi].rtlist[dir], |
14806 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14807 | json_object_string_add(json, "exportRts", |
14808 | ecom_str); | |
14809 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14810 | } else | |
14811 | json_object_string_add(json, "exportRts", | |
14812 | "none"); | |
b46dfd20 DS |
14813 | } |
14814 | ||
03915806 CS |
14815 | if (use_json) { |
14816 | vty_out(vty, "%s\n", | |
14817 | json_object_to_json_string_ext(json, | |
b46dfd20 | 14818 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
14819 | json_object_free(json); |
14820 | } | |
53089bec | 14821 | } else { |
b46dfd20 DS |
14822 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14823 | ||
53089bec | 14824 | if (!bgp) { |
b46dfd20 | 14825 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14826 | return CMD_WARNING; |
14827 | } | |
53089bec | 14828 | |
b46dfd20 DS |
14829 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14830 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14831 | vty_out(vty, | |
14832 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14833 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14834 | else { |
14835 | vty_out(vty, | |
14836 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14837 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14838 | |
14839 | for (ALL_LIST_ELEMENTS_RO( | |
14840 | bgp->vpn_policy[afi].import_vrf, | |
14841 | node, vname)) | |
14842 | vty_out(vty, " %s\n", vname); | |
14843 | ||
14844 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14845 | ecom_str = NULL; |
14846 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14847 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14848 | bgp->vpn_policy[afi].rtlist[dir], |
14849 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14850 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14851 | |
b20875ea CS |
14852 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14853 | } else | |
14854 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14855 | } |
53089bec | 14856 | |
b46dfd20 DS |
14857 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14858 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14859 | vty_out(vty, | |
14860 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14861 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14862 | else { |
14863 | vty_out(vty, | |
04c9077f | 14864 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14865 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14866 | |
14867 | for (ALL_LIST_ELEMENTS_RO( | |
14868 | bgp->vpn_policy[afi].export_vrf, | |
14869 | node, vname)) | |
14870 | vty_out(vty, " %s\n", vname); | |
14871 | ||
14872 | vty_out(vty, "RD: %s\n", | |
14873 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14874 | buf1, RD_ADDRSTRLEN)); | |
14875 | ||
14876 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14877 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14878 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14879 | bgp->vpn_policy[afi].rtlist[dir], |
14880 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14881 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14882 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14883 | } else | |
14884 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14885 | } |
53089bec | 14886 | } |
14887 | ||
14888 | return CMD_SUCCESS; | |
14889 | } | |
14890 | ||
03915806 CS |
14891 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14892 | safi_t safi, bool use_json) | |
14893 | { | |
14894 | struct listnode *node, *nnode; | |
14895 | struct bgp *bgp; | |
14896 | char *vrf_name = NULL; | |
14897 | json_object *json = NULL; | |
14898 | json_object *json_vrf = NULL; | |
14899 | json_object *json_vrfs = NULL; | |
14900 | ||
14901 | if (use_json) { | |
14902 | json = json_object_new_object(); | |
14903 | json_vrfs = json_object_new_object(); | |
14904 | } | |
14905 | ||
14906 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14907 | ||
14908 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14909 | vrf_name = bgp->name; | |
14910 | ||
14911 | if (use_json) { | |
14912 | json_vrf = json_object_new_object(); | |
14913 | } else { | |
14914 | vty_out(vty, "\nInstance %s:\n", | |
14915 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14916 | ? VRF_DEFAULT_NAME : bgp->name); | |
14917 | } | |
14918 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14919 | if (use_json) { | |
14920 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14921 | json_object_object_add(json_vrfs, | |
14922 | VRF_DEFAULT_NAME, json_vrf); | |
14923 | else | |
14924 | json_object_object_add(json_vrfs, vrf_name, | |
14925 | json_vrf); | |
14926 | } | |
14927 | } | |
14928 | ||
14929 | if (use_json) { | |
14930 | json_object_object_add(json, "vrfs", json_vrfs); | |
14931 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
14932 | JSON_C_TO_STRING_PRETTY)); | |
14933 | json_object_free(json); | |
14934 | } | |
14935 | ||
14936 | return CMD_SUCCESS; | |
14937 | } | |
14938 | ||
53089bec | 14939 | /* "show [ip] bgp route-leak" command. */ |
14940 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14941 | show_ip_bgp_route_leak_cmd, |
14942 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14943 | SHOW_STR |
14944 | IP_STR | |
14945 | BGP_STR | |
14946 | BGP_INSTANCE_HELP_STR | |
14947 | BGP_AFI_HELP_STR | |
14948 | BGP_SAFI_HELP_STR | |
14949 | "Route leaking information\n" | |
14950 | JSON_STR) | |
53089bec | 14951 | { |
14952 | char *vrf = NULL; | |
14953 | afi_t afi = AFI_MAX; | |
14954 | safi_t safi = SAFI_MAX; | |
14955 | ||
9f049418 | 14956 | bool uj = use_json(argc, argv); |
53089bec | 14957 | int idx = 0; |
03915806 | 14958 | json_object *json = NULL; |
53089bec | 14959 | |
14960 | /* show [ip] bgp */ | |
14961 | if (argv_find(argv, argc, "ip", &idx)) { | |
14962 | afi = AFI_IP; | |
14963 | safi = SAFI_UNICAST; | |
14964 | } | |
14965 | /* [vrf VIEWVRFNAME] */ | |
14966 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14967 | vty_out(vty, |
14968 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14969 | return CMD_WARNING; |
14970 | } | |
14971 | ||
9a8bdf1c PG |
14972 | if (argv_find(argv, argc, "vrf", &idx)) { |
14973 | vrf = argv[idx + 1]->arg; | |
14974 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14975 | vrf = NULL; | |
14976 | } | |
53089bec | 14977 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14978 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14979 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14980 | } | |
14981 | ||
14982 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14983 | vty_out(vty, |
14984 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14985 | return CMD_WARNING; |
14986 | } | |
14987 | ||
03915806 CS |
14988 | if (vrf && strmatch(vrf, "all")) |
14989 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14990 | ||
14991 | if (uj) | |
14992 | json = json_object_new_object(); | |
14993 | ||
14994 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14995 | } |
14996 | ||
d62a17ae | 14997 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14998 | safi_t safi) | |
f186de26 | 14999 | { |
d62a17ae | 15000 | struct listnode *node, *nnode; |
15001 | struct bgp *bgp; | |
f186de26 | 15002 | |
d62a17ae | 15003 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
15004 | vty_out(vty, "\nInstance %s:\n", | |
15005 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15006 | ? VRF_DEFAULT_NAME |
d62a17ae | 15007 | : bgp->name); |
15008 | update_group_show(bgp, afi, safi, vty, 0); | |
15009 | } | |
f186de26 | 15010 | } |
15011 | ||
d62a17ae | 15012 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
15013 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 15014 | { |
d62a17ae | 15015 | struct bgp *bgp; |
4fb25c53 | 15016 | |
d62a17ae | 15017 | if (name) { |
15018 | if (strmatch(name, "all")) { | |
15019 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
15020 | return CMD_SUCCESS; | |
15021 | } else { | |
15022 | bgp = bgp_lookup_by_name(name); | |
15023 | } | |
15024 | } else { | |
15025 | bgp = bgp_get_default(); | |
15026 | } | |
4fb25c53 | 15027 | |
d62a17ae | 15028 | if (bgp) |
15029 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
15030 | return CMD_SUCCESS; | |
4fb25c53 DW |
15031 | } |
15032 | ||
8fe8a7f6 DS |
15033 | DEFUN (show_ip_bgp_updgrps, |
15034 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 15035 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 15036 | SHOW_STR |
15037 | IP_STR | |
15038 | BGP_STR | |
15039 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15040 | BGP_AFI_HELP_STR |
9bedbb1e | 15041 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
15042 | "Detailed info about dynamic update groups\n" |
15043 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 15044 | { |
d62a17ae | 15045 | char *vrf = NULL; |
15046 | afi_t afi = AFI_IP6; | |
15047 | safi_t safi = SAFI_UNICAST; | |
15048 | uint64_t subgrp_id = 0; | |
15049 | ||
15050 | int idx = 0; | |
15051 | ||
15052 | /* show [ip] bgp */ | |
15053 | if (argv_find(argv, argc, "ip", &idx)) | |
15054 | afi = AFI_IP; | |
9a8bdf1c PG |
15055 | /* [<vrf> VIEWVRFNAME] */ |
15056 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15057 | vrf = argv[idx + 1]->arg; | |
15058 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15059 | vrf = NULL; | |
15060 | } else if (argv_find(argv, argc, "view", &idx)) | |
15061 | /* [<view> VIEWVRFNAME] */ | |
15062 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15063 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15064 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15065 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15066 | } | |
5bf15956 | 15067 | |
d62a17ae | 15068 | /* get subgroup id, if provided */ |
15069 | idx = argc - 1; | |
15070 | if (argv[idx]->type == VARIABLE_TKN) | |
15071 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15072 | |
d62a17ae | 15073 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
15074 | } |
15075 | ||
f186de26 | 15076 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15077 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 15078 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 15079 | SHOW_STR |
716b2d8a | 15080 | IP_STR |
f186de26 | 15081 | BGP_STR |
15082 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 15083 | "Detailed info about dynamic update groups\n") |
f186de26 | 15084 | { |
d62a17ae | 15085 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
15086 | return CMD_SUCCESS; | |
f186de26 | 15087 | } |
15088 | ||
43d3f4fc DS |
15089 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15090 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15091 | "show [ip] bgp l2vpn evpn update-groups", | |
15092 | SHOW_STR | |
15093 | IP_STR | |
15094 | BGP_STR | |
15095 | "l2vpn address family\n" | |
15096 | "evpn sub-address family\n" | |
15097 | "Detailed info about dynamic update groups\n") | |
15098 | { | |
15099 | char *vrf = NULL; | |
15100 | uint64_t subgrp_id = 0; | |
15101 | ||
15102 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
15103 | return CMD_SUCCESS; | |
15104 | } | |
15105 | ||
5bf15956 DW |
15106 | DEFUN (show_bgp_updgrps_stats, |
15107 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15108 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15109 | SHOW_STR |
716b2d8a | 15110 | IP_STR |
3f9c7369 | 15111 | BGP_STR |
0c7b1b01 | 15112 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15113 | "Statistics\n") |
15114 | { | |
d62a17ae | 15115 | struct bgp *bgp; |
3f9c7369 | 15116 | |
d62a17ae | 15117 | bgp = bgp_get_default(); |
15118 | if (bgp) | |
15119 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15120 | |
d62a17ae | 15121 | return CMD_SUCCESS; |
3f9c7369 DS |
15122 | } |
15123 | ||
8386ac43 | 15124 | DEFUN (show_bgp_instance_updgrps_stats, |
15125 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15126 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15127 | SHOW_STR |
716b2d8a | 15128 | IP_STR |
8386ac43 | 15129 | BGP_STR |
15130 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15131 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15132 | "Statistics\n") |
15133 | { | |
d62a17ae | 15134 | int idx_word = 3; |
15135 | struct bgp *bgp; | |
8386ac43 | 15136 | |
d62a17ae | 15137 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15138 | if (bgp) | |
15139 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15140 | |
d62a17ae | 15141 | return CMD_SUCCESS; |
8386ac43 | 15142 | } |
15143 | ||
d62a17ae | 15144 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15145 | afi_t afi, safi_t safi, | |
15146 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15147 | { |
d62a17ae | 15148 | struct bgp *bgp; |
8386ac43 | 15149 | |
d62a17ae | 15150 | if (name) |
15151 | bgp = bgp_lookup_by_name(name); | |
15152 | else | |
15153 | bgp = bgp_get_default(); | |
8386ac43 | 15154 | |
d62a17ae | 15155 | if (bgp) { |
15156 | if (!strcmp(what, "advertise-queue")) | |
15157 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15158 | subgrp_id); | |
15159 | else if (!strcmp(what, "advertised-routes")) | |
15160 | update_group_show_advertised(bgp, afi, safi, vty, | |
15161 | subgrp_id); | |
15162 | else if (!strcmp(what, "packet-queue")) | |
15163 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15164 | subgrp_id); | |
15165 | } | |
3f9c7369 DS |
15166 | } |
15167 | ||
dc64bdec QY |
15168 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15169 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15170 | "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", | |
15171 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15172 | BGP_SAFI_HELP_STR | |
15173 | "Detailed info about dynamic update groups\n" | |
15174 | "Specific subgroup to display info for\n" | |
15175 | "Advertisement queue\n" | |
15176 | "Announced routes\n" | |
15177 | "Packet queue\n") | |
3f9c7369 | 15178 | { |
dc64bdec QY |
15179 | uint64_t subgrp_id = 0; |
15180 | afi_t afiz; | |
15181 | safi_t safiz; | |
15182 | if (sgid) | |
15183 | subgrp_id = strtoull(sgid, NULL, 10); | |
15184 | ||
15185 | if (!ip && !afi) | |
15186 | afiz = AFI_IP6; | |
15187 | if (!ip && afi) | |
15188 | afiz = bgp_vty_afi_from_str(afi); | |
15189 | if (ip && !afi) | |
15190 | afiz = AFI_IP; | |
15191 | if (ip && afi) { | |
15192 | afiz = bgp_vty_afi_from_str(afi); | |
15193 | if (afiz != AFI_IP) | |
15194 | vty_out(vty, | |
15195 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15196 | return CMD_WARNING; | |
15197 | } | |
d62a17ae | 15198 | |
dc64bdec | 15199 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15200 | |
dc64bdec | 15201 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15202 | return CMD_SUCCESS; |
15203 | } | |
15204 | ||
6f4eacf3 DA |
15205 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15206 | json_object *json) | |
d62a17ae | 15207 | { |
15208 | struct listnode *node, *nnode; | |
15209 | struct prefix *range; | |
15210 | struct peer *conf; | |
15211 | struct peer *peer; | |
d62a17ae | 15212 | afi_t afi; |
15213 | safi_t safi; | |
15214 | const char *peer_status; | |
d62a17ae | 15215 | int lr_count; |
15216 | int dynamic; | |
6f4eacf3 DA |
15217 | bool af_cfgd; |
15218 | json_object *json_peer_group = NULL; | |
15219 | json_object *json_peer_group_afc = NULL; | |
15220 | json_object *json_peer_group_members = NULL; | |
15221 | json_object *json_peer_group_dynamic = NULL; | |
15222 | json_object *json_peer_group_dynamic_af = NULL; | |
15223 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15224 | |
15225 | conf = group->conf; | |
15226 | ||
6f4eacf3 DA |
15227 | if (json) { |
15228 | json_peer_group = json_object_new_object(); | |
15229 | json_peer_group_afc = json_object_new_array(); | |
15230 | } | |
15231 | ||
d62a17ae | 15232 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15233 | if (json) |
15234 | json_object_int_add(json_peer_group, "remoteAs", | |
15235 | conf->as); | |
15236 | else | |
15237 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15238 | group->name, conf->as); | |
d62a17ae | 15239 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15240 | if (json) |
15241 | json_object_int_add(json_peer_group, "remoteAs", | |
15242 | group->bgp->as); | |
15243 | else | |
15244 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15245 | group->name, group->bgp->as); | |
d62a17ae | 15246 | } else { |
6f4eacf3 DA |
15247 | if (!json) |
15248 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15249 | } |
f14e6fdb | 15250 | |
6f4eacf3 DA |
15251 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15252 | if (json) | |
15253 | json_object_string_add(json_peer_group, "type", | |
15254 | "internal"); | |
15255 | else | |
15256 | vty_out(vty, " Peer-group type is internal\n"); | |
15257 | } else { | |
15258 | if (json) | |
15259 | json_object_string_add(json_peer_group, "type", | |
15260 | "external"); | |
15261 | else | |
15262 | vty_out(vty, " Peer-group type is external\n"); | |
15263 | } | |
d62a17ae | 15264 | |
15265 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15266 | if (!json) |
15267 | vty_out(vty, " Configured address-families:"); | |
15268 | ||
05c7a1cc QY |
15269 | FOREACH_AFI_SAFI (afi, safi) { |
15270 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15271 | af_cfgd = true; |
15272 | if (json) | |
15273 | json_object_array_add( | |
15274 | json_peer_group_afc, | |
15275 | json_object_new_string(get_afi_safi_str( | |
15276 | afi, safi, false))); | |
15277 | else | |
15278 | vty_out(vty, " %s;", | |
15279 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15280 | } |
05c7a1cc | 15281 | } |
6f4eacf3 DA |
15282 | |
15283 | if (json) { | |
15284 | json_object_object_add(json_peer_group, | |
15285 | "addressFamiliesConfigured", | |
15286 | json_peer_group_afc); | |
15287 | } else { | |
15288 | if (!af_cfgd) | |
15289 | vty_out(vty, " none\n"); | |
15290 | else | |
15291 | vty_out(vty, "\n"); | |
15292 | } | |
d62a17ae | 15293 | |
15294 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15295 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15296 | lr_count = listcount(group->listen_range[afi]); |
15297 | if (lr_count) { | |
6f4eacf3 DA |
15298 | if (json) { |
15299 | if (!json_peer_group_dynamic) | |
15300 | json_peer_group_dynamic = | |
15301 | json_object_new_object(); | |
15302 | ||
15303 | json_peer_group_dynamic_af = | |
15304 | json_object_new_object(); | |
15305 | json_peer_group_ranges = | |
15306 | json_object_new_array(); | |
15307 | json_object_int_add(json_peer_group_dynamic_af, | |
15308 | "count", lr_count); | |
15309 | } else { | |
15310 | vty_out(vty, " %d %s listen range(s)\n", | |
15311 | lr_count, afi2str(afi)); | |
15312 | } | |
d62a17ae | 15313 | |
15314 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15315 | nnode, range)) { |
15316 | if (json) { | |
15317 | char buf[BUFSIZ]; | |
15318 | ||
15319 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15320 | range); | |
15321 | ||
15322 | json_object_array_add( | |
15323 | json_peer_group_ranges, | |
15324 | json_object_new_string(buf)); | |
15325 | } else { | |
15326 | vty_out(vty, " %pFX\n", range); | |
15327 | } | |
15328 | } | |
15329 | ||
15330 | if (json) { | |
15331 | json_object_object_add( | |
15332 | json_peer_group_dynamic_af, "ranges", | |
15333 | json_peer_group_ranges); | |
15334 | ||
15335 | json_object_object_add( | |
15336 | json_peer_group_dynamic, afi2str(afi), | |
15337 | json_peer_group_dynamic_af); | |
15338 | } | |
d62a17ae | 15339 | } |
15340 | } | |
f14e6fdb | 15341 | |
6f4eacf3 DA |
15342 | if (json_peer_group_dynamic) |
15343 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15344 | json_peer_group_dynamic); | |
15345 | ||
d62a17ae | 15346 | /* Display group members and their status */ |
15347 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
15348 | if (json) |
15349 | json_peer_group_members = json_object_new_object(); | |
15350 | else | |
15351 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 15352 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
15353 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15354 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15355 | peer_status = "Idle (Admin)"; |
15356 | else if (CHECK_FLAG(peer->sflags, | |
15357 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15358 | peer_status = "Idle (PfxCt)"; | |
15359 | else | |
15360 | peer_status = lookup_msg(bgp_status_msg, | |
15361 | peer->status, NULL); | |
15362 | ||
15363 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
15364 | |
15365 | if (json) { | |
15366 | json_object *json_peer_group_member = | |
15367 | json_object_new_object(); | |
15368 | ||
15369 | json_object_string_add(json_peer_group_member, | |
15370 | "status", peer_status); | |
15371 | ||
15372 | if (dynamic) | |
15373 | json_object_boolean_true_add( | |
15374 | json_peer_group_member, | |
15375 | "dynamic"); | |
15376 | ||
15377 | json_object_object_add(json_peer_group_members, | |
15378 | peer->host, | |
15379 | json_peer_group_member); | |
15380 | } else { | |
15381 | vty_out(vty, " %s %s %s \n", peer->host, | |
15382 | dynamic ? "(dynamic)" : "", | |
15383 | peer_status); | |
15384 | } | |
d62a17ae | 15385 | } |
6f4eacf3 DA |
15386 | if (json) |
15387 | json_object_object_add(json_peer_group, "members", | |
15388 | json_peer_group_members); | |
d62a17ae | 15389 | } |
f14e6fdb | 15390 | |
6f4eacf3 DA |
15391 | if (json) |
15392 | json_object_object_add(json, group->name, json_peer_group); | |
15393 | ||
d62a17ae | 15394 | return CMD_SUCCESS; |
15395 | } | |
15396 | ||
ff9959b0 | 15397 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 15398 | const char *group_name, bool uj) |
d62a17ae | 15399 | { |
ff9959b0 | 15400 | struct bgp *bgp; |
d62a17ae | 15401 | struct listnode *node, *nnode; |
15402 | struct peer_group *group; | |
ff9959b0 | 15403 | bool found = false; |
6f4eacf3 DA |
15404 | json_object *json = NULL; |
15405 | ||
15406 | if (uj) | |
15407 | json = json_object_new_object(); | |
ff9959b0 QY |
15408 | |
15409 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15410 | ||
15411 | if (!bgp) { | |
6f4eacf3 DA |
15412 | if (uj) { |
15413 | vty_out(vty, "%s\n", | |
15414 | json_object_to_json_string_ext( | |
15415 | json, JSON_C_TO_STRING_PRETTY)); | |
15416 | json_object_free(json); | |
15417 | } else { | |
15418 | vty_out(vty, "%% BGP instance not found\n"); | |
15419 | } | |
15420 | ||
ff9959b0 QY |
15421 | return CMD_WARNING; |
15422 | } | |
d62a17ae | 15423 | |
15424 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15425 | if (group_name) { |
15426 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 15427 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
15428 | found = true; |
15429 | break; | |
d62a17ae | 15430 | } |
ff9959b0 | 15431 | } else { |
6f4eacf3 | 15432 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 15433 | } |
f14e6fdb | 15434 | } |
f14e6fdb | 15435 | |
6f4eacf3 | 15436 | if (group_name && !found && !uj) |
d62a17ae | 15437 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15438 | |
6f4eacf3 DA |
15439 | if (uj) { |
15440 | vty_out(vty, "%s\n", | |
15441 | json_object_to_json_string_ext( | |
15442 | json, JSON_C_TO_STRING_PRETTY)); | |
15443 | json_object_free(json); | |
15444 | } | |
15445 | ||
d62a17ae | 15446 | return CMD_SUCCESS; |
f14e6fdb DS |
15447 | } |
15448 | ||
6f4eacf3 DA |
15449 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
15450 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
15451 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
15452 | "Detailed information on BGP peer groups\n" | |
15453 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 15454 | { |
d62a17ae | 15455 | char *vrf, *pg; |
d62a17ae | 15456 | int idx = 0; |
6f4eacf3 | 15457 | bool uj = use_json(argc, argv); |
f14e6fdb | 15458 | |
a4d82a8a PZ |
15459 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15460 | : NULL; | |
d62a17ae | 15461 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15462 | |
6f4eacf3 | 15463 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 15464 | } |
3f9c7369 | 15465 | |
d6e3c605 | 15466 | |
718e3744 | 15467 | /* Redistribute VTY commands. */ |
15468 | ||
585f1adc IR |
15469 | DEFUN (bgp_redistribute_ipv4, |
15470 | bgp_redistribute_ipv4_cmd, | |
15471 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15472 | "Redistribute information from another routing protocol\n" | |
15473 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15474 | { |
585f1adc | 15475 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15476 | int idx_protocol = 1; |
585f1adc | 15477 | int type; |
37a87b8f | 15478 | |
585f1adc IR |
15479 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15480 | if (type < 0) { | |
15481 | vty_out(vty, "%% Invalid route type\n"); | |
15482 | return CMD_WARNING_CONFIG_FAILED; | |
15483 | } | |
7f323236 | 15484 | |
585f1adc IR |
15485 | bgp_redist_add(bgp, AFI_IP, type, 0); |
15486 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 15487 | } |
15488 | ||
d62a17ae | 15489 | ALIAS_HIDDEN( |
15490 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15491 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15492 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15493 | |
585f1adc IR |
15494 | DEFUN (bgp_redistribute_ipv4_rmap, |
15495 | bgp_redistribute_ipv4_rmap_cmd, | |
15496 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15497 | "Redistribute information from another routing protocol\n" | |
15498 | FRR_IP_REDIST_HELP_STR_BGPD | |
15499 | "Route map reference\n" | |
15500 | "Pointer to route-map entries\n") | |
718e3744 | 15501 | { |
585f1adc | 15502 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15503 | int idx_protocol = 1; |
15504 | int idx_word = 3; | |
585f1adc IR |
15505 | int type; |
15506 | struct bgp_redist *red; | |
15507 | bool changed; | |
15508 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
15509 | vty, argv[idx_word]->arg); | |
15510 | ||
15511 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15512 | if (type < 0) { | |
15513 | vty_out(vty, "%% Invalid route type\n"); | |
15514 | return CMD_WARNING_CONFIG_FAILED; | |
15515 | } | |
37a87b8f | 15516 | |
585f1adc IR |
15517 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15518 | changed = | |
15519 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15520 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 15521 | } |
15522 | ||
d62a17ae | 15523 | ALIAS_HIDDEN( |
15524 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
15525 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
15526 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15527 | "Route map reference\n" | |
15528 | "Pointer to route-map entries\n") | |
596c17ba | 15529 | |
585f1adc IR |
15530 | DEFUN (bgp_redistribute_ipv4_metric, |
15531 | bgp_redistribute_ipv4_metric_cmd, | |
15532 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15533 | "Redistribute information from another routing protocol\n" | |
15534 | FRR_IP_REDIST_HELP_STR_BGPD | |
15535 | "Metric for redistributed routes\n" | |
15536 | "Default metric\n") | |
718e3744 | 15537 | { |
585f1adc | 15538 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15539 | int idx_protocol = 1; |
15540 | int idx_number = 3; | |
585f1adc IR |
15541 | int type; |
15542 | uint32_t metric; | |
15543 | struct bgp_redist *red; | |
15544 | bool changed; | |
15545 | ||
15546 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15547 | if (type < 0) { | |
15548 | vty_out(vty, "%% Invalid route type\n"); | |
15549 | return CMD_WARNING_CONFIG_FAILED; | |
15550 | } | |
15551 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15552 | |
585f1adc IR |
15553 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15554 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15555 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15556 | } |
15557 | ||
15558 | ALIAS_HIDDEN( | |
15559 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15560 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15561 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15562 | "Metric for redistributed routes\n" | |
15563 | "Default metric\n") | |
596c17ba | 15564 | |
585f1adc IR |
15565 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
15566 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
15567 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
15568 | "Redistribute information from another routing protocol\n" | |
15569 | FRR_IP_REDIST_HELP_STR_BGPD | |
15570 | "Route map reference\n" | |
15571 | "Pointer to route-map entries\n" | |
15572 | "Metric for redistributed routes\n" | |
15573 | "Default metric\n") | |
718e3744 | 15574 | { |
585f1adc | 15575 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15576 | int idx_protocol = 1; |
15577 | int idx_word = 3; | |
15578 | int idx_number = 5; | |
585f1adc IR |
15579 | int type; |
15580 | uint32_t metric; | |
15581 | struct bgp_redist *red; | |
15582 | bool changed; | |
15583 | struct route_map *route_map = | |
15584 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15585 | ||
15586 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15587 | if (type < 0) { | |
15588 | vty_out(vty, "%% Invalid route type\n"); | |
15589 | return CMD_WARNING_CONFIG_FAILED; | |
15590 | } | |
15591 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15592 | |
585f1adc IR |
15593 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15594 | changed = | |
15595 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15596 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15597 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15598 | } |
15599 | ||
15600 | ALIAS_HIDDEN( | |
15601 | bgp_redistribute_ipv4_rmap_metric, | |
15602 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15603 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15604 | " route-map WORD metric (0-4294967295)", | |
15605 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15606 | "Route map reference\n" | |
15607 | "Pointer to route-map entries\n" | |
15608 | "Metric for redistributed routes\n" | |
15609 | "Default metric\n") | |
596c17ba | 15610 | |
585f1adc IR |
15611 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
15612 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
15613 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
15614 | "Redistribute information from another routing protocol\n" | |
15615 | FRR_IP_REDIST_HELP_STR_BGPD | |
15616 | "Metric for redistributed routes\n" | |
15617 | "Default metric\n" | |
15618 | "Route map reference\n" | |
15619 | "Pointer to route-map entries\n") | |
718e3744 | 15620 | { |
585f1adc | 15621 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15622 | int idx_protocol = 1; |
37a87b8f | 15623 | int idx_number = 3; |
585f1adc IR |
15624 | int idx_word = 5; |
15625 | int type; | |
15626 | uint32_t metric; | |
15627 | struct bgp_redist *red; | |
15628 | bool changed; | |
15629 | struct route_map *route_map = | |
15630 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15631 | ||
15632 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15633 | if (type < 0) { | |
15634 | vty_out(vty, "%% Invalid route type\n"); | |
15635 | return CMD_WARNING_CONFIG_FAILED; | |
15636 | } | |
15637 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15638 | |
585f1adc IR |
15639 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15640 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15641 | changed |= | |
15642 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15643 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15644 | } |
15645 | ||
15646 | ALIAS_HIDDEN( | |
15647 | bgp_redistribute_ipv4_metric_rmap, | |
15648 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15649 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
15650 | " metric (0-4294967295) route-map WORD", | |
15651 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15652 | "Metric for redistributed routes\n" | |
15653 | "Default metric\n" | |
15654 | "Route map reference\n" | |
15655 | "Pointer to route-map entries\n") | |
596c17ba | 15656 | |
585f1adc IR |
15657 | DEFUN (bgp_redistribute_ipv4_ospf, |
15658 | bgp_redistribute_ipv4_ospf_cmd, | |
15659 | "redistribute <ospf|table> (1-65535)", | |
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") | |
7c8ff89e | 15664 | { |
585f1adc IR |
15665 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15666 | int idx_ospf_table = 1; | |
d62a17ae | 15667 | int idx_number = 2; |
585f1adc IR |
15668 | unsigned short instance; |
15669 | unsigned short protocol; | |
7c8ff89e | 15670 | |
585f1adc | 15671 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 15672 | |
585f1adc IR |
15673 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15674 | protocol = ZEBRA_ROUTE_OSPF; | |
15675 | else | |
15676 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 15677 | |
585f1adc IR |
15678 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15679 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
15680 | } |
15681 | ||
d62a17ae | 15682 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15683 | "redistribute <ospf|table> (1-65535)", | |
15684 | "Redistribute information from another routing protocol\n" | |
15685 | "Open Shortest Path First (OSPFv2)\n" | |
15686 | "Non-main Kernel Routing Table\n" | |
15687 | "Instance ID/Table ID\n") | |
596c17ba | 15688 | |
585f1adc IR |
15689 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
15690 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
15691 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15692 | "Redistribute information from another routing protocol\n" | |
15693 | "Open Shortest Path First (OSPFv2)\n" | |
15694 | "Non-main Kernel Routing Table\n" | |
15695 | "Instance ID/Table ID\n" | |
15696 | "Route map reference\n" | |
15697 | "Pointer to route-map entries\n") | |
7c8ff89e | 15698 | { |
585f1adc IR |
15699 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15700 | int idx_ospf_table = 1; | |
d62a17ae | 15701 | int idx_number = 2; |
15702 | int idx_word = 4; | |
585f1adc IR |
15703 | struct bgp_redist *red; |
15704 | unsigned short instance; | |
15705 | int protocol; | |
15706 | bool changed; | |
15707 | struct route_map *route_map = | |
15708 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15709 | ||
15710 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15711 | protocol = ZEBRA_ROUTE_OSPF; | |
15712 | else | |
15713 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15714 | |
585f1adc IR |
15715 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15716 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15717 | changed = | |
15718 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15719 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15720 | } |
15721 | ||
15722 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15723 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
15724 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
15725 | "Redistribute information from another routing protocol\n" | |
15726 | "Open Shortest Path First (OSPFv2)\n" | |
15727 | "Non-main Kernel Routing Table\n" | |
15728 | "Instance ID/Table ID\n" | |
15729 | "Route map reference\n" | |
15730 | "Pointer to route-map entries\n") | |
596c17ba | 15731 | |
585f1adc IR |
15732 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
15733 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15734 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15735 | "Redistribute information from another routing protocol\n" | |
15736 | "Open Shortest Path First (OSPFv2)\n" | |
15737 | "Non-main Kernel Routing Table\n" | |
15738 | "Instance ID/Table ID\n" | |
15739 | "Metric for redistributed routes\n" | |
15740 | "Default metric\n") | |
7c8ff89e | 15741 | { |
585f1adc IR |
15742 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15743 | int idx_ospf_table = 1; | |
d62a17ae | 15744 | int idx_number = 2; |
15745 | int idx_number_2 = 4; | |
585f1adc IR |
15746 | uint32_t metric; |
15747 | struct bgp_redist *red; | |
15748 | unsigned short instance; | |
15749 | int protocol; | |
15750 | bool changed; | |
15751 | ||
15752 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15753 | protocol = ZEBRA_ROUTE_OSPF; | |
15754 | else | |
15755 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15756 | |
585f1adc IR |
15757 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15758 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15759 | |
585f1adc IR |
15760 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15761 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15762 | metric); | |
15763 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15764 | } |
15765 | ||
15766 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15767 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15768 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15769 | "Redistribute information from another routing protocol\n" | |
15770 | "Open Shortest Path First (OSPFv2)\n" | |
15771 | "Non-main Kernel Routing Table\n" | |
15772 | "Instance ID/Table ID\n" | |
15773 | "Metric for redistributed routes\n" | |
15774 | "Default metric\n") | |
596c17ba | 15775 | |
585f1adc IR |
15776 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
15777 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
15778 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
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 | "Route map reference\n" | |
15784 | "Pointer to route-map entries\n" | |
15785 | "Metric for redistributed routes\n" | |
15786 | "Default metric\n") | |
7c8ff89e | 15787 | { |
585f1adc IR |
15788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15789 | int idx_ospf_table = 1; | |
d62a17ae | 15790 | int idx_number = 2; |
15791 | int idx_word = 4; | |
15792 | int idx_number_2 = 6; | |
585f1adc IR |
15793 | uint32_t metric; |
15794 | struct bgp_redist *red; | |
15795 | unsigned short instance; | |
15796 | int protocol; | |
15797 | bool changed; | |
15798 | struct route_map *route_map = | |
15799 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15800 | ||
15801 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15802 | protocol = ZEBRA_ROUTE_OSPF; | |
15803 | else | |
15804 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15805 | |
585f1adc IR |
15806 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15807 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15808 | |
585f1adc IR |
15809 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15810 | changed = | |
15811 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15812 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15813 | metric); | |
15814 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15815 | } |
15816 | ||
15817 | ALIAS_HIDDEN( | |
15818 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15819 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
15820 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
15821 | "Redistribute information from another routing protocol\n" | |
15822 | "Open Shortest Path First (OSPFv2)\n" | |
15823 | "Non-main Kernel Routing Table\n" | |
15824 | "Instance ID/Table ID\n" | |
15825 | "Route map reference\n" | |
15826 | "Pointer to route-map entries\n" | |
15827 | "Metric for redistributed routes\n" | |
15828 | "Default metric\n") | |
596c17ba | 15829 | |
585f1adc IR |
15830 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
15831 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
15832 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15833 | "Redistribute information from another routing protocol\n" | |
15834 | "Open Shortest Path First (OSPFv2)\n" | |
15835 | "Non-main Kernel Routing Table\n" | |
15836 | "Instance ID/Table ID\n" | |
15837 | "Metric for redistributed routes\n" | |
15838 | "Default metric\n" | |
15839 | "Route map reference\n" | |
15840 | "Pointer to route-map entries\n") | |
7c8ff89e | 15841 | { |
585f1adc IR |
15842 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15843 | int idx_ospf_table = 1; | |
d62a17ae | 15844 | int idx_number = 2; |
15845 | int idx_number_2 = 4; | |
15846 | int idx_word = 6; | |
585f1adc IR |
15847 | uint32_t metric; |
15848 | struct bgp_redist *red; | |
15849 | unsigned short instance; | |
15850 | int protocol; | |
15851 | bool changed; | |
15852 | struct route_map *route_map = | |
15853 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15854 | ||
15855 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15856 | protocol = ZEBRA_ROUTE_OSPF; | |
15857 | else | |
15858 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15859 | |
585f1adc IR |
15860 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15861 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15862 | |
585f1adc IR |
15863 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15864 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15865 | metric); | |
15866 | changed |= | |
15867 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15868 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15869 | } |
15870 | ||
15871 | ALIAS_HIDDEN( | |
15872 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15873 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
15874 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
15875 | "Redistribute information from another routing protocol\n" | |
15876 | "Open Shortest Path First (OSPFv2)\n" | |
15877 | "Non-main Kernel Routing Table\n" | |
15878 | "Instance ID/Table ID\n" | |
15879 | "Metric for redistributed routes\n" | |
15880 | "Default metric\n" | |
15881 | "Route map reference\n" | |
15882 | "Pointer to route-map entries\n") | |
596c17ba | 15883 | |
585f1adc IR |
15884 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
15885 | no_bgp_redistribute_ipv4_ospf_cmd, | |
15886 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", | |
15887 | NO_STR | |
15888 | "Redistribute information from another routing protocol\n" | |
15889 | "Open Shortest Path First (OSPFv2)\n" | |
15890 | "Non-main Kernel Routing Table\n" | |
15891 | "Instance ID/Table ID\n" | |
15892 | "Metric for redistributed routes\n" | |
15893 | "Default metric\n" | |
15894 | "Route map reference\n" | |
15895 | "Pointer to route-map entries\n") | |
7c8ff89e | 15896 | { |
585f1adc IR |
15897 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15898 | int idx_ospf_table = 2; | |
d62a17ae | 15899 | int idx_number = 3; |
585f1adc IR |
15900 | unsigned short instance; |
15901 | int protocol; | |
37a87b8f | 15902 | |
585f1adc IR |
15903 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15904 | protocol = ZEBRA_ROUTE_OSPF; | |
15905 | else | |
15906 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15907 | |
585f1adc IR |
15908 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15909 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 15910 | } |
15911 | ||
15912 | ALIAS_HIDDEN( | |
15913 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 15914 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15915 | NO_STR |
15916 | "Redistribute information from another routing protocol\n" | |
15917 | "Open Shortest Path First (OSPFv2)\n" | |
15918 | "Non-main Kernel Routing Table\n" | |
15919 | "Instance ID/Table ID\n" | |
15920 | "Metric for redistributed routes\n" | |
15921 | "Default metric\n" | |
15922 | "Route map reference\n" | |
15923 | "Pointer to route-map entries\n") | |
596c17ba | 15924 | |
585f1adc IR |
15925 | DEFUN (no_bgp_redistribute_ipv4, |
15926 | no_bgp_redistribute_ipv4_cmd, | |
15927 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
15928 | NO_STR | |
15929 | "Redistribute information from another routing protocol\n" | |
15930 | FRR_IP_REDIST_HELP_STR_BGPD | |
15931 | "Metric for redistributed routes\n" | |
15932 | "Default metric\n" | |
15933 | "Route map reference\n" | |
15934 | "Pointer to route-map entries\n") | |
718e3744 | 15935 | { |
585f1adc | 15936 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15937 | int idx_protocol = 2; |
585f1adc | 15938 | int type; |
d62a17ae | 15939 | |
585f1adc IR |
15940 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15941 | if (type < 0) { | |
15942 | vty_out(vty, "%% Invalid route type\n"); | |
15943 | return CMD_WARNING_CONFIG_FAILED; | |
15944 | } | |
15945 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 15946 | } |
15947 | ||
15948 | ALIAS_HIDDEN( | |
15949 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15950 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 15951 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 15952 | NO_STR |
15953 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15954 | "Metric for redistributed routes\n" | |
15955 | "Default metric\n" | |
15956 | "Route map reference\n" | |
15957 | "Pointer to route-map entries\n") | |
596c17ba | 15958 | |
585f1adc IR |
15959 | DEFUN (bgp_redistribute_ipv6, |
15960 | bgp_redistribute_ipv6_cmd, | |
15961 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15962 | "Redistribute information from another routing protocol\n" | |
15963 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15964 | { |
585f1adc | 15965 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15966 | int idx_protocol = 1; |
585f1adc | 15967 | int type; |
718e3744 | 15968 | |
585f1adc IR |
15969 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15970 | if (type < 0) { | |
15971 | vty_out(vty, "%% Invalid route type\n"); | |
15972 | return CMD_WARNING_CONFIG_FAILED; | |
15973 | } | |
718e3744 | 15974 | |
585f1adc IR |
15975 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
15976 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 15977 | } |
15978 | ||
585f1adc IR |
15979 | DEFUN (bgp_redistribute_ipv6_rmap, |
15980 | bgp_redistribute_ipv6_rmap_cmd, | |
15981 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", | |
15982 | "Redistribute information from another routing protocol\n" | |
15983 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15984 | "Route map reference\n" | |
15985 | "Pointer to route-map entries\n") | |
718e3744 | 15986 | { |
585f1adc | 15987 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15988 | int idx_protocol = 1; |
15989 | int idx_word = 3; | |
585f1adc IR |
15990 | int type; |
15991 | struct bgp_redist *red; | |
15992 | bool changed; | |
15993 | struct route_map *route_map = | |
15994 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15995 | ||
15996 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15997 | if (type < 0) { | |
15998 | vty_out(vty, "%% Invalid route type\n"); | |
15999 | return CMD_WARNING_CONFIG_FAILED; | |
16000 | } | |
37a87b8f | 16001 | |
585f1adc IR |
16002 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16003 | changed = | |
16004 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16005 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16006 | } |
16007 | ||
585f1adc | 16008 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 16009 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16010 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16011 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16012 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16013 | "Metric for redistributed routes\n" |
16014 | "Default metric\n") | |
16015 | { | |
585f1adc | 16016 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16017 | int idx_protocol = 1; |
16018 | int idx_number = 3; | |
585f1adc IR |
16019 | int type; |
16020 | uint32_t metric; | |
16021 | struct bgp_redist *red; | |
16022 | bool changed; | |
16023 | ||
16024 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16025 | if (type < 0) { | |
16026 | vty_out(vty, "%% Invalid route type\n"); | |
16027 | return CMD_WARNING_CONFIG_FAILED; | |
16028 | } | |
16029 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16030 | |
585f1adc IR |
16031 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16032 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
16033 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16034 | } |
16035 | ||
585f1adc IR |
16036 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
16037 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
16038 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", | |
16039 | "Redistribute information from another routing protocol\n" | |
16040 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16041 | "Route map reference\n" | |
16042 | "Pointer to route-map entries\n" | |
16043 | "Metric for redistributed routes\n" | |
16044 | "Default metric\n") | |
718e3744 | 16045 | { |
585f1adc | 16046 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16047 | int idx_protocol = 1; |
16048 | int idx_word = 3; | |
16049 | int idx_number = 5; | |
585f1adc IR |
16050 | int type; |
16051 | uint32_t metric; | |
16052 | struct bgp_redist *red; | |
16053 | bool changed; | |
16054 | struct route_map *route_map = | |
16055 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16056 | ||
16057 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16058 | if (type < 0) { | |
16059 | vty_out(vty, "%% Invalid route type\n"); | |
16060 | return CMD_WARNING_CONFIG_FAILED; | |
16061 | } | |
16062 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16063 | |
585f1adc IR |
16064 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16065 | changed = | |
16066 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16067 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
16068 | metric); | |
16069 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16070 | } |
16071 | ||
585f1adc IR |
16072 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
16073 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
16074 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", | |
16075 | "Redistribute information from another routing protocol\n" | |
16076 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16077 | "Metric for redistributed routes\n" | |
16078 | "Default metric\n" | |
16079 | "Route map reference\n" | |
16080 | "Pointer to route-map entries\n") | |
718e3744 | 16081 | { |
585f1adc | 16082 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16083 | int idx_protocol = 1; |
37a87b8f | 16084 | int idx_number = 3; |
585f1adc IR |
16085 | int idx_word = 5; |
16086 | int type; | |
16087 | uint32_t metric; | |
16088 | struct bgp_redist *red; | |
16089 | bool changed; | |
16090 | struct route_map *route_map = | |
16091 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16092 | ||
16093 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16094 | if (type < 0) { | |
16095 | vty_out(vty, "%% Invalid route type\n"); | |
16096 | return CMD_WARNING_CONFIG_FAILED; | |
16097 | } | |
16098 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16099 | |
585f1adc IR |
16100 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16101 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
16102 | metric); | |
16103 | changed |= | |
16104 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16105 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16106 | } |
16107 | ||
585f1adc IR |
16108 | DEFUN (no_bgp_redistribute_ipv6, |
16109 | no_bgp_redistribute_ipv6_cmd, | |
16110 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", | |
16111 | NO_STR | |
16112 | "Redistribute information from another routing protocol\n" | |
16113 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16114 | "Metric for redistributed routes\n" | |
16115 | "Default metric\n" | |
16116 | "Route map reference\n" | |
16117 | "Pointer to route-map entries\n") | |
718e3744 | 16118 | { |
585f1adc | 16119 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16120 | int idx_protocol = 2; |
585f1adc | 16121 | int type; |
37a87b8f | 16122 | |
585f1adc IR |
16123 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16124 | if (type < 0) { | |
16125 | vty_out(vty, "%% Invalid route type\n"); | |
16126 | return CMD_WARNING_CONFIG_FAILED; | |
16127 | } | |
718e3744 | 16128 | |
585f1adc | 16129 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 16130 | } |
16131 | ||
4ab46701 AR |
16132 | /* Neighbor update tcp-mss. */ |
16133 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16134 | const char *tcp_mss_str) | |
16135 | { | |
16136 | struct peer *peer; | |
16137 | uint32_t tcp_mss_val = 0; | |
16138 | ||
16139 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16140 | if (!peer) | |
16141 | return CMD_WARNING_CONFIG_FAILED; | |
16142 | ||
16143 | if (tcp_mss_str) { | |
16144 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16145 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16146 | } else { | |
16147 | peer_tcp_mss_unset(peer); | |
16148 | } | |
16149 | ||
16150 | return CMD_SUCCESS; | |
16151 | } | |
16152 | ||
16153 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16154 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16155 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16156 | "TCP max segment size\n" | |
16157 | "TCP MSS value\n") | |
16158 | { | |
16159 | int peer_index = 1; | |
16160 | int mss_index = 3; | |
16161 | ||
16162 | vty_out(vty, | |
16163 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16164 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16165 | argv[mss_index]->arg); | |
16166 | } | |
16167 | ||
16168 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16169 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16170 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16171 | "TCP max segment size\n" | |
16172 | "TCP MSS value\n") | |
16173 | { | |
16174 | int peer_index = 2; | |
16175 | ||
16176 | vty_out(vty, | |
16177 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16178 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16179 | } | |
16180 | ||
dd65f45e DL |
16181 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16182 | afi_t afi, safi_t safi) | |
d62a17ae | 16183 | { |
16184 | int i; | |
16185 | ||
16186 | /* Unicast redistribution only. */ | |
16187 | if (safi != SAFI_UNICAST) | |
2b791107 | 16188 | return; |
d62a17ae | 16189 | |
16190 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16191 | /* Redistribute BGP does not make sense. */ | |
16192 | if (i != ZEBRA_ROUTE_BGP) { | |
16193 | struct list *red_list; | |
16194 | struct listnode *node; | |
16195 | struct bgp_redist *red; | |
16196 | ||
16197 | red_list = bgp->redist[afi][i]; | |
16198 | if (!red_list) | |
16199 | continue; | |
16200 | ||
16201 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16202 | /* "redistribute" configuration. */ |
16203 | vty_out(vty, " redistribute %s", | |
16204 | zebra_route_string(i)); | |
16205 | if (red->instance) | |
16206 | vty_out(vty, " %d", red->instance); | |
16207 | if (red->redist_metric_flag) | |
16208 | vty_out(vty, " metric %u", | |
16209 | red->redist_metric); | |
16210 | if (red->rmap.name) | |
16211 | vty_out(vty, " route-map %s", | |
16212 | red->rmap.name); | |
16213 | vty_out(vty, "\n"); | |
16214 | } | |
16215 | } | |
16216 | } | |
718e3744 | 16217 | } |
6b0655a2 | 16218 | |
dd65f45e DL |
16219 | /* peer-group helpers for config-write */ |
16220 | ||
16221 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16222 | { | |
16223 | if (!peer_group_active(peer)) { | |
16224 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16225 | return !CHECK_FLAG(peer->flags, flag); | |
16226 | else | |
16227 | return !!CHECK_FLAG(peer->flags, flag); | |
16228 | } | |
16229 | ||
16230 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16231 | } | |
16232 | ||
16233 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16234 | uint32_t flag) | |
16235 | { | |
16236 | if (!peer_group_active(peer)) { | |
16237 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16238 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16239 | else | |
16240 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16241 | } | |
16242 | ||
16243 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16244 | } | |
16245 | ||
16246 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16247 | uint8_t type, int direct) | |
16248 | { | |
16249 | struct bgp_filter *filter; | |
16250 | ||
16251 | if (peer_group_active(peer)) | |
16252 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16253 | type); | |
16254 | ||
16255 | filter = &peer->filter[afi][safi]; | |
16256 | switch (type) { | |
16257 | case PEER_FT_DISTRIBUTE_LIST: | |
16258 | return !!(filter->dlist[direct].name); | |
16259 | case PEER_FT_FILTER_LIST: | |
16260 | return !!(filter->aslist[direct].name); | |
16261 | case PEER_FT_PREFIX_LIST: | |
16262 | return !!(filter->plist[direct].name); | |
16263 | case PEER_FT_ROUTE_MAP: | |
16264 | return !!(filter->map[direct].name); | |
16265 | case PEER_FT_UNSUPPRESS_MAP: | |
16266 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16267 | case PEER_FT_ADVERTISE_MAP: |
16268 | return !!(filter->advmap.aname | |
16269 | && ((filter->advmap.condition == direct) | |
16270 | && filter->advmap.cname)); | |
dd65f45e DL |
16271 | default: |
16272 | return false; | |
16273 | } | |
16274 | } | |
16275 | ||
16276 | /* Return true if the addpath type is set for peer and different from | |
16277 | * peer-group. | |
16278 | */ | |
3dc339cd DA |
16279 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16280 | safi_t safi) | |
dd65f45e DL |
16281 | { |
16282 | enum bgp_addpath_strat type, g_type; | |
16283 | ||
16284 | type = peer->addpath_type[afi][safi]; | |
16285 | ||
16286 | if (type != BGP_ADDPATH_NONE) { | |
16287 | if (peer_group_active(peer)) { | |
16288 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16289 | ||
16290 | if (type != g_type) | |
3dc339cd | 16291 | return true; |
dd65f45e | 16292 | else |
3dc339cd | 16293 | return false; |
dd65f45e DL |
16294 | } |
16295 | ||
3dc339cd | 16296 | return true; |
dd65f45e DL |
16297 | } |
16298 | ||
3dc339cd | 16299 | return false; |
dd65f45e DL |
16300 | } |
16301 | ||
b9c7bc5a | 16302 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16303 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16304 | afi_t afi) |
16305 | { | |
b9c7bc5a | 16306 | int indent = 2; |
53970de3 | 16307 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16308 | |
8a066a70 | 16309 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16310 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16311 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16312 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16313 | bgp->vpn_policy[afi] | |
bb4f6190 | 16314 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16315 | else |
16316 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16317 | bgp->vpn_policy[afi] | |
16318 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16319 | } | |
12a844a5 DS |
16320 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16321 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16322 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16323 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16324 | return; | |
16325 | ||
e70e9f8e PZ |
16326 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16327 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16328 | ||
16329 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16330 | ||
16331 | } else { | |
16332 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16333 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16334 | bgp->vpn_policy[afi].tovpn_label); | |
16335 | } | |
ddb5b488 | 16336 | } |
53970de3 RS |
16337 | |
16338 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16339 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16340 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16341 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16342 | } else if (tovpn_sid_index != 0) { | |
16343 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16344 | tovpn_sid_index); | |
16345 | } | |
16346 | ||
ddb5b488 PZ |
16347 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16348 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16349 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16350 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16351 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16352 | sizeof(buf))); | |
16353 | } | |
16354 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16355 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16356 | ||
16357 | char buf[PREFIX_STRLEN]; | |
16358 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16359 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16360 | sizeof(buf))) { | |
16361 | ||
b9c7bc5a PZ |
16362 | vty_out(vty, "%*snexthop vpn export %s\n", |
16363 | indent, "", buf); | |
ddb5b488 PZ |
16364 | } |
16365 | } | |
16366 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16367 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16368 | && ecommunity_cmp( | |
16369 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16370 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16371 | ||
16372 | char *b = ecommunity_ecom2str( | |
16373 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16374 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16375 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16376 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16377 | } else { | |
16378 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16379 | char *b = ecommunity_ecom2str( | |
16380 | bgp->vpn_policy[afi] | |
16381 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16382 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16383 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16384 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16385 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16386 | } | |
16387 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16388 | char *b = ecommunity_ecom2str( | |
16389 | bgp->vpn_policy[afi] | |
16390 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16391 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16392 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16393 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16394 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16395 | } | |
16396 | } | |
bb4f6190 DS |
16397 | |
16398 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16399 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16400 | bgp->vpn_policy[afi] |
16401 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16402 | |
301ad80a PG |
16403 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16404 | char *b = ecommunity_ecom2str( | |
16405 | bgp->vpn_policy[afi] | |
16406 | .import_redirect_rtlist, | |
16407 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16408 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16409 | |
9a659715 PG |
16410 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16411 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16412 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16413 | indent, "", b); |
16414 | else | |
16415 | vty_out(vty, "%*srt redirect import %s\n", | |
16416 | indent, "", b); | |
301ad80a PG |
16417 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16418 | } | |
ddb5b488 PZ |
16419 | } |
16420 | ||
dd65f45e DL |
16421 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16422 | afi_t afi, safi_t safi) | |
16423 | { | |
16424 | struct bgp_filter *filter; | |
16425 | char *addr; | |
16426 | ||
16427 | addr = peer->host; | |
16428 | filter = &peer->filter[afi][safi]; | |
16429 | ||
16430 | /* distribute-list. */ | |
16431 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16432 | FILTER_IN)) | |
16433 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16434 | filter->dlist[FILTER_IN].name); | |
16435 | ||
16436 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16437 | FILTER_OUT)) | |
16438 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16439 | filter->dlist[FILTER_OUT].name); | |
16440 | ||
16441 | /* prefix-list. */ | |
16442 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16443 | FILTER_IN)) | |
16444 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16445 | filter->plist[FILTER_IN].name); | |
16446 | ||
16447 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16448 | FILTER_OUT)) | |
16449 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16450 | filter->plist[FILTER_OUT].name); | |
16451 | ||
16452 | /* route-map. */ | |
16453 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16454 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16455 | filter->map[RMAP_IN].name); | |
16456 | ||
16457 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16458 | RMAP_OUT)) | |
16459 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16460 | filter->map[RMAP_OUT].name); | |
16461 | ||
16462 | /* unsuppress-map */ | |
16463 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16464 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16465 | filter->usmap.name); | |
16466 | ||
7f7940e6 MK |
16467 | /* advertise-map : always applied in OUT direction*/ |
16468 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16469 | CONDITION_NON_EXIST)) | |
16470 | vty_out(vty, | |
16471 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16472 | addr, filter->advmap.aname, filter->advmap.cname); | |
16473 | ||
16474 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16475 | CONDITION_EXIST)) | |
16476 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16477 | addr, filter->advmap.aname, filter->advmap.cname); | |
16478 | ||
dd65f45e DL |
16479 | /* filter-list. */ |
16480 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16481 | FILTER_IN)) | |
16482 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16483 | filter->aslist[FILTER_IN].name); | |
16484 | ||
16485 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16486 | FILTER_OUT)) | |
16487 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16488 | filter->aslist[FILTER_OUT].name); | |
16489 | } | |
16490 | ||
16491 | /* BGP peer configuration display function. */ | |
16492 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16493 | struct peer *peer) | |
16494 | { | |
16495 | struct peer *g_peer = NULL; | |
16496 | char buf[SU_ADDRSTRLEN]; | |
16497 | char *addr; | |
16498 | int if_pg_printed = false; | |
16499 | int if_ras_printed = false; | |
16500 | ||
16501 | /* Skip dynamic neighbors. */ | |
16502 | if (peer_dynamic_neighbor(peer)) | |
16503 | return; | |
16504 | ||
16505 | if (peer->conf_if) | |
16506 | addr = peer->conf_if; | |
16507 | else | |
16508 | addr = peer->host; | |
16509 | ||
16510 | /************************************ | |
16511 | ****** Global to the neighbor ****** | |
16512 | ************************************/ | |
16513 | if (peer->conf_if) { | |
16514 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16515 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16516 | else | |
16517 | vty_out(vty, " neighbor %s interface", addr); | |
16518 | ||
16519 | if (peer_group_active(peer)) { | |
16520 | vty_out(vty, " peer-group %s", peer->group->name); | |
16521 | if_pg_printed = true; | |
16522 | } else if (peer->as_type == AS_SPECIFIED) { | |
16523 | vty_out(vty, " remote-as %u", peer->as); | |
16524 | if_ras_printed = true; | |
16525 | } else if (peer->as_type == AS_INTERNAL) { | |
16526 | vty_out(vty, " remote-as internal"); | |
16527 | if_ras_printed = true; | |
16528 | } else if (peer->as_type == AS_EXTERNAL) { | |
16529 | vty_out(vty, " remote-as external"); | |
16530 | if_ras_printed = true; | |
16531 | } | |
16532 | ||
16533 | vty_out(vty, "\n"); | |
16534 | } | |
16535 | ||
16536 | /* remote-as and peer-group */ | |
16537 | /* peer is a member of a peer-group */ | |
16538 | if (peer_group_active(peer)) { | |
16539 | g_peer = peer->group->conf; | |
16540 | ||
16541 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16542 | if (peer->as_type == AS_SPECIFIED) { | |
16543 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16544 | addr, peer->as); | |
16545 | } else if (peer->as_type == AS_INTERNAL) { | |
16546 | vty_out(vty, | |
16547 | " neighbor %s remote-as internal\n", | |
16548 | addr); | |
16549 | } else if (peer->as_type == AS_EXTERNAL) { | |
16550 | vty_out(vty, | |
16551 | " neighbor %s remote-as external\n", | |
16552 | addr); | |
16553 | } | |
16554 | } | |
16555 | ||
16556 | /* For swpX peers we displayed the peer-group | |
16557 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16558 | if (!if_pg_printed) | |
16559 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16560 | peer->group->name); | |
16561 | } | |
16562 | ||
16563 | /* peer is NOT a member of a peer-group */ | |
16564 | else { | |
16565 | /* peer is a peer-group, declare the peer-group */ | |
16566 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16567 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16568 | } | |
16569 | ||
16570 | if (!if_ras_printed) { | |
16571 | if (peer->as_type == AS_SPECIFIED) { | |
16572 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16573 | addr, peer->as); | |
16574 | } else if (peer->as_type == AS_INTERNAL) { | |
16575 | vty_out(vty, | |
16576 | " neighbor %s remote-as internal\n", | |
16577 | addr); | |
16578 | } else if (peer->as_type == AS_EXTERNAL) { | |
16579 | vty_out(vty, | |
16580 | " neighbor %s remote-as external\n", | |
16581 | addr); | |
16582 | } | |
16583 | } | |
16584 | } | |
16585 | ||
16586 | /* local-as */ | |
16587 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16588 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16589 | peer->change_local_as); | |
16590 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16591 | vty_out(vty, " no-prepend"); | |
16592 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16593 | vty_out(vty, " replace-as"); | |
16594 | vty_out(vty, "\n"); | |
16595 | } | |
16596 | ||
16597 | /* description */ | |
16598 | if (peer->desc) { | |
16599 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16600 | } | |
16601 | ||
16602 | /* shutdown */ | |
16603 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16604 | if (peer->tx_shutdown_message) | |
16605 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16606 | peer->tx_shutdown_message); | |
16607 | else | |
16608 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16609 | } | |
16610 | ||
8336c896 DA |
16611 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16612 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16613 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16614 | ||
dd65f45e | 16615 | /* bfd */ |
21bfce98 RZ |
16616 | if (peer->bfd_config) |
16617 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
16618 | |
16619 | /* password */ | |
16620 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16621 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16622 | peer->password); | |
16623 | ||
16624 | /* neighbor solo */ | |
16625 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16626 | if (!peer_group_active(peer)) { | |
16627 | vty_out(vty, " neighbor %s solo\n", addr); | |
16628 | } | |
16629 | } | |
16630 | ||
16631 | /* BGP port */ | |
16632 | if (peer->port != BGP_PORT_DEFAULT) { | |
16633 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16634 | } | |
16635 | ||
16636 | /* Local interface name */ | |
16637 | if (peer->ifname) { | |
16638 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16639 | } | |
16640 | ||
4ab46701 AR |
16641 | /* TCP max segment size */ |
16642 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
16643 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
16644 | ||
dd65f45e DL |
16645 | /* passive */ |
16646 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16647 | vty_out(vty, " neighbor %s passive\n", addr); | |
16648 | ||
16649 | /* ebgp-multihop */ | |
16650 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16651 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16652 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16653 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16654 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16655 | peer->ttl); | |
16656 | } | |
16657 | } | |
16658 | ||
16659 | /* ttl-security hops */ | |
e2521429 | 16660 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16661 | if (!peer_group_active(peer) |
16662 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16663 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16664 | addr, peer->gtsm_hops); | |
16665 | } | |
16666 | } | |
16667 | ||
16668 | /* disable-connected-check */ | |
16669 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16670 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16671 | ||
27aa23a4 DA |
16672 | /* link-bw-encoding-ieee */ |
16673 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
16674 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
16675 | addr); | |
16676 | ||
dd65f45e DL |
16677 | /* enforce-first-as */ |
16678 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16679 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16680 | ||
16681 | /* update-source */ | |
16682 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16683 | if (peer->update_source) | |
16684 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16685 | sockunion2str(peer->update_source, buf, | |
16686 | SU_ADDRSTRLEN)); | |
16687 | else if (peer->update_if) | |
16688 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16689 | peer->update_if); | |
16690 | } | |
16691 | ||
16692 | /* advertisement-interval */ | |
16693 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16694 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16695 | peer->routeadv); | |
16696 | ||
16697 | /* timers */ | |
16698 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16699 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16700 | peer->keepalive, peer->holdtime); | |
16701 | ||
16702 | /* timers connect */ | |
16703 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16704 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16705 | peer->connect); | |
5d5393b9 DL |
16706 | /* need special-case handling for changed default values due to |
16707 | * config profile / version (because there is no "timers bgp connect" | |
16708 | * command, we need to save this per-peer :/) | |
16709 | */ | |
16710 | else if (!peer_group_active(peer) && !peer->connect && | |
16711 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16712 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16713 | peer->bgp->default_connect_retry); | |
dd65f45e | 16714 | |
d43114f3 DS |
16715 | /* timers delayopen */ |
16716 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
16717 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16718 | peer->delayopen); | |
16719 | /* Save config even though flag is not set if default values have been | |
16720 | * changed | |
16721 | */ | |
16722 | else if (!peer_group_active(peer) && !peer->delayopen | |
16723 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
16724 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16725 | peer->bgp->default_delayopen); | |
16726 | ||
dd65f45e DL |
16727 | /* capability dynamic */ |
16728 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16729 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16730 | ||
16731 | /* capability extended-nexthop */ | |
16732 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
16733 | if (!peer->conf_if) { | |
16734 | if (CHECK_FLAG(peer->flags_invert, | |
16735 | PEER_FLAG_CAPABILITY_ENHE)) | |
16736 | vty_out(vty, | |
16737 | " no neighbor %s capability extended-nexthop\n", | |
16738 | addr); | |
16739 | else | |
16740 | vty_out(vty, | |
16741 | " neighbor %s capability extended-nexthop\n", | |
16742 | addr); | |
16743 | } | |
16744 | } | |
16745 | ||
16746 | /* dont-capability-negotiation */ | |
16747 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16748 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16749 | ||
16750 | /* override-capability */ | |
16751 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16752 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16753 | ||
16754 | /* strict-capability-match */ | |
16755 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16756 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16757 | ||
16758 | /* Sender side AS path loop detection. */ | |
16759 | if (peer->as_path_loop_detection) | |
16760 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16761 | addr); | |
cfd47646 | 16762 | |
16763 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16764 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16765 | |
16766 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16767 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16768 | vty_out(vty, |
16769 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16770 | } else if (CHECK_FLAG( |
16771 | peer->peer_gr_new_status_flag, | |
16772 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16773 | vty_out(vty, |
16774 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16775 | } else if ( |
16776 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16777 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16778 | && !(CHECK_FLAG( | |
16779 | peer->peer_gr_new_status_flag, | |
16780 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16781 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16782 | addr); | |
cfd47646 | 16783 | } |
16784 | } | |
dd65f45e DL |
16785 | } |
16786 | ||
16787 | /* BGP peer configuration display function. */ | |
16788 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16789 | struct peer *peer, afi_t afi, safi_t safi) | |
16790 | { | |
16791 | struct peer *g_peer = NULL; | |
16792 | char *addr; | |
16793 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16794 | ||
16795 | /* Skip dynamic neighbors. */ | |
16796 | if (peer_dynamic_neighbor(peer)) | |
16797 | return; | |
16798 | ||
16799 | if (peer->conf_if) | |
16800 | addr = peer->conf_if; | |
16801 | else | |
16802 | addr = peer->host; | |
16803 | ||
16804 | /************************************ | |
16805 | ****** Per AF to the neighbor ****** | |
16806 | ************************************/ | |
16807 | if (peer_group_active(peer)) { | |
16808 | g_peer = peer->group->conf; | |
16809 | ||
16810 | /* If the peer-group is active but peer is not, print a 'no | |
16811 | * activate' */ | |
16812 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16813 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16814 | } | |
16815 | ||
16816 | /* If the peer-group is not active but peer is, print an | |
16817 | 'activate' */ | |
16818 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16819 | vty_out(vty, " neighbor %s activate\n", addr); | |
16820 | } | |
16821 | } else { | |
16822 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
16823 | if (safi == SAFI_ENCAP) |
16824 | vty_out(vty, " neighbor %s activate\n", addr); | |
16825 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
16826 | vty_out(vty, " neighbor %s activate\n", addr); |
16827 | } else { | |
38d11af5 TA |
16828 | if (bgp->default_af[afi][safi]) |
16829 | vty_out(vty, " no neighbor %s activate\n", | |
16830 | addr); | |
dd65f45e DL |
16831 | } |
16832 | } | |
16833 | ||
16834 | /* addpath TX knobs */ | |
16835 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16836 | switch (peer->addpath_type[afi][safi]) { | |
16837 | case BGP_ADDPATH_ALL: | |
16838 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16839 | addr); | |
16840 | break; | |
16841 | case BGP_ADDPATH_BEST_PER_AS: | |
16842 | vty_out(vty, | |
16843 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16844 | addr); | |
16845 | break; | |
16846 | case BGP_ADDPATH_MAX: | |
16847 | case BGP_ADDPATH_NONE: | |
16848 | break; | |
16849 | } | |
16850 | } | |
16851 | ||
7c0e4312 DA |
16852 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
16853 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
16854 | ||
dd65f45e DL |
16855 | /* ORF capability. */ |
16856 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16857 | || peergroup_af_flag_check(peer, afi, safi, | |
16858 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16859 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16860 | ||
16861 | if (peergroup_af_flag_check(peer, afi, safi, | |
16862 | PEER_FLAG_ORF_PREFIX_SM) | |
16863 | && peergroup_af_flag_check(peer, afi, safi, | |
16864 | PEER_FLAG_ORF_PREFIX_RM)) | |
16865 | vty_out(vty, " both"); | |
16866 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16867 | PEER_FLAG_ORF_PREFIX_SM)) | |
16868 | vty_out(vty, " send"); | |
16869 | else | |
16870 | vty_out(vty, " receive"); | |
16871 | vty_out(vty, "\n"); | |
16872 | } | |
16873 | ||
dd65f45e DL |
16874 | /* Route reflector client. */ |
16875 | if (peergroup_af_flag_check(peer, afi, safi, | |
16876 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16877 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16878 | } | |
16879 | ||
16880 | /* next-hop-self force */ | |
16881 | if (peergroup_af_flag_check(peer, afi, safi, | |
16882 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16883 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16884 | } | |
16885 | ||
16886 | /* next-hop-self */ | |
16887 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16888 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16889 | } | |
16890 | ||
16891 | /* remove-private-AS */ | |
16892 | if (peergroup_af_flag_check(peer, afi, safi, | |
16893 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16894 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16895 | addr); | |
16896 | } | |
16897 | ||
16898 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16899 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16900 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16901 | addr); | |
16902 | } | |
16903 | ||
16904 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16905 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16906 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16907 | } | |
16908 | ||
16909 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16910 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16911 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16912 | } | |
16913 | ||
16914 | /* as-override */ | |
16915 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16916 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16917 | } | |
16918 | ||
16919 | /* send-community print. */ | |
16920 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16921 | PEER_FLAG_SEND_COMMUNITY); | |
16922 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16923 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16924 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16925 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16926 | ||
16927 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16928 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16929 | } else { | |
16930 | if (flag_scomm) | |
16931 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16932 | if (flag_secomm) | |
16933 | vty_out(vty, | |
16934 | " no neighbor %s send-community extended\n", | |
16935 | addr); | |
16936 | ||
16937 | if (flag_slcomm) | |
16938 | vty_out(vty, " no neighbor %s send-community large\n", | |
16939 | addr); | |
16940 | } | |
16941 | ||
16942 | /* Default information */ | |
16943 | if (peergroup_af_flag_check(peer, afi, safi, | |
16944 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16945 | vty_out(vty, " neighbor %s default-originate", addr); | |
16946 | ||
16947 | if (peer->default_rmap[afi][safi].name) | |
16948 | vty_out(vty, " route-map %s", | |
16949 | peer->default_rmap[afi][safi].name); | |
16950 | ||
16951 | vty_out(vty, "\n"); | |
16952 | } | |
16953 | ||
16954 | /* Soft reconfiguration inbound. */ | |
16955 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16956 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16957 | addr); | |
16958 | } | |
16959 | ||
16960 | /* maximum-prefix. */ | |
16961 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16962 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16963 | peer->pmax[afi][safi]); |
16964 | ||
16965 | if (peer->pmax_threshold[afi][safi] | |
16966 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16967 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16968 | if (peer_af_flag_check(peer, afi, safi, | |
16969 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16970 | vty_out(vty, " warning-only"); | |
16971 | if (peer->pmax_restart[afi][safi]) | |
16972 | vty_out(vty, " restart %u", | |
16973 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16974 | if (peer_af_flag_check(peer, afi, safi, |
16975 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16976 | vty_out(vty, " force"); | |
dd65f45e DL |
16977 | |
16978 | vty_out(vty, "\n"); | |
16979 | } | |
16980 | ||
fde246e8 DA |
16981 | /* maximum-prefix-out */ |
16982 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16983 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16984 | addr, peer->pmax_out[afi][safi]); |
16985 | ||
dd65f45e DL |
16986 | /* Route server client. */ |
16987 | if (peergroup_af_flag_check(peer, afi, safi, | |
16988 | PEER_FLAG_RSERVER_CLIENT)) { | |
16989 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16990 | } | |
16991 | ||
16992 | /* Nexthop-local unchanged. */ | |
16993 | if (peergroup_af_flag_check(peer, afi, safi, | |
16994 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16995 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
16996 | } | |
16997 | ||
16998 | /* allowas-in <1-10> */ | |
16999 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17000 | if (peer_af_flag_check(peer, afi, safi, | |
17001 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17002 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17003 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17004 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17005 | } else { | |
17006 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17007 | peer->allowas_in[afi][safi]); | |
17008 | } | |
17009 | } | |
17010 | ||
17011 | /* weight */ | |
17012 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17013 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17014 | peer->weight[afi][safi]); | |
17015 | ||
17016 | /* Filter. */ | |
17017 | bgp_config_write_filter(vty, peer, afi, safi); | |
17018 | ||
17019 | /* atribute-unchanged. */ | |
17020 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17021 | || (safi != SAFI_EVPN | |
17022 | && peer_af_flag_check(peer, afi, safi, | |
17023 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17024 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17025 | ||
17026 | if (!peer_group_active(peer) | |
17027 | || peergroup_af_flag_check(peer, afi, safi, | |
17028 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17029 | || peergroup_af_flag_check(peer, afi, safi, | |
17030 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17031 | || peergroup_af_flag_check(peer, afi, safi, | |
17032 | PEER_FLAG_MED_UNCHANGED)) { | |
17033 | ||
17034 | vty_out(vty, | |
17035 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17036 | addr, | |
17037 | peer_af_flag_check(peer, afi, safi, | |
17038 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17039 | ? " as-path" | |
17040 | : "", | |
17041 | peer_af_flag_check(peer, afi, safi, | |
17042 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17043 | ? " next-hop" | |
17044 | : "", | |
17045 | peer_af_flag_check(peer, afi, safi, | |
17046 | PEER_FLAG_MED_UNCHANGED) | |
17047 | ? " med" | |
17048 | : ""); | |
17049 | } | |
17050 | } | |
17051 | } | |
17052 | ||
17053 | /* Address family based peer configuration display. */ | |
17054 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17055 | safi_t safi) | |
17056 | { | |
17057 | struct peer *peer; | |
17058 | struct peer_group *group; | |
17059 | struct listnode *node, *nnode; | |
17060 | ||
17061 | ||
17062 | vty_frame(vty, " !\n address-family "); | |
17063 | if (afi == AFI_IP) { | |
17064 | if (safi == SAFI_UNICAST) | |
17065 | vty_frame(vty, "ipv4 unicast"); | |
17066 | else if (safi == SAFI_LABELED_UNICAST) | |
17067 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17068 | else if (safi == SAFI_MULTICAST) | |
17069 | vty_frame(vty, "ipv4 multicast"); | |
17070 | else if (safi == SAFI_MPLS_VPN) | |
17071 | vty_frame(vty, "ipv4 vpn"); | |
17072 | else if (safi == SAFI_ENCAP) | |
17073 | vty_frame(vty, "ipv4 encap"); | |
17074 | else if (safi == SAFI_FLOWSPEC) | |
17075 | vty_frame(vty, "ipv4 flowspec"); | |
17076 | } else if (afi == AFI_IP6) { | |
17077 | if (safi == SAFI_UNICAST) | |
17078 | vty_frame(vty, "ipv6 unicast"); | |
17079 | else if (safi == SAFI_LABELED_UNICAST) | |
17080 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17081 | else if (safi == SAFI_MULTICAST) | |
17082 | vty_frame(vty, "ipv6 multicast"); | |
17083 | else if (safi == SAFI_MPLS_VPN) | |
17084 | vty_frame(vty, "ipv6 vpn"); | |
17085 | else if (safi == SAFI_ENCAP) | |
17086 | vty_frame(vty, "ipv6 encap"); | |
17087 | else if (safi == SAFI_FLOWSPEC) | |
17088 | vty_frame(vty, "ipv6 flowspec"); | |
17089 | } else if (afi == AFI_L2VPN) { | |
17090 | if (safi == SAFI_EVPN) | |
17091 | vty_frame(vty, "l2vpn evpn"); | |
17092 | } | |
17093 | vty_frame(vty, "\n"); | |
17094 | ||
17095 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17096 | ||
17097 | bgp_config_write_network(vty, bgp, afi, safi); | |
17098 | ||
17099 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17100 | ||
8a4e7fe6 DA |
17101 | /* BGP flag dampening. */ |
17102 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 17103 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 17104 | |
dd65f45e DL |
17105 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17106 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17107 | ||
17108 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17109 | /* Do not display doppelganger peers */ |
17110 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17111 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17112 | } | |
17113 | ||
17114 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17115 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17116 | ||
17117 | if (safi == SAFI_EVPN) | |
17118 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17119 | ||
17120 | if (safi == SAFI_FLOWSPEC) | |
17121 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17122 | ||
17123 | if (safi == SAFI_UNICAST) { | |
17124 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17125 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17126 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17127 | ||
17128 | vty_out(vty, " export vpn\n"); | |
17129 | } | |
17130 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17131 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17132 | ||
17133 | vty_out(vty, " import vpn\n"); | |
17134 | } | |
17135 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17136 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17137 | char *name; | |
17138 | ||
17139 | for (ALL_LIST_ELEMENTS_RO( | |
17140 | bgp->vpn_policy[afi].import_vrf, node, | |
17141 | name)) | |
17142 | vty_out(vty, " import vrf %s\n", name); | |
17143 | } | |
17144 | } | |
17145 | ||
17146 | vty_endframe(vty, " exit-address-family\n"); | |
17147 | } | |
17148 | ||
17149 | int bgp_config_write(struct vty *vty) | |
17150 | { | |
17151 | struct bgp *bgp; | |
17152 | struct peer_group *group; | |
17153 | struct peer *peer; | |
17154 | struct listnode *node, *nnode; | |
17155 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17156 | afi_t afi; |
17157 | safi_t safi; | |
dd65f45e DL |
17158 | |
17159 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17160 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17161 | bm->rmap_update_timer); | |
17162 | ||
d70583f7 D |
17163 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17164 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17165 | if (bm->v_update_delay != bm->v_establish_wait) | |
17166 | vty_out(vty, " %d", bm->v_establish_wait); | |
17167 | vty_out(vty, "\n"); | |
17168 | } | |
17169 | ||
9acb67cb DS |
17170 | if (bm->wait_for_fib) |
17171 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17172 | ||
05bd726c | 17173 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17174 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17175 | ||
c163f297 DS |
17176 | /* No-RIB (Zebra) option flag configuration */ |
17177 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17178 | vty_out(vty, "bgp no-rib\n"); | |
17179 | ||
ec0acb80 | 17180 | if (!CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
e46723a5 DS |
17181 | vty_out(vty, "no bgp send-extra-data zebra\n"); |
17182 | ||
dd65f45e DL |
17183 | /* BGP configuration. */ |
17184 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17185 | ||
17186 | /* skip all auto created vrf as they dont have user config */ | |
17187 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17188 | continue; | |
17189 | ||
17190 | /* Router bgp ASN */ | |
17191 | vty_out(vty, "router bgp %u", bgp->as); | |
17192 | ||
17193 | if (bgp->name) | |
17194 | vty_out(vty, " %s %s", | |
17195 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17196 | ? "view" : "vrf", bgp->name); | |
17197 | vty_out(vty, "\n"); | |
17198 | ||
17199 | /* BGP fast-external-failover. */ | |
17200 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17201 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17202 | ||
17203 | /* BGP router ID. */ | |
3a6290bd | 17204 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17205 | vty_out(vty, " bgp router-id %pI4\n", |
17206 | &bgp->router_id_static); | |
dd65f45e | 17207 | |
c208c586 S |
17208 | /* Suppress fib pending */ |
17209 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17210 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17211 | ||
dd65f45e | 17212 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17213 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17214 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17215 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17216 | CHECK_FLAG(bgp->flags, |
17217 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17218 | ? "" |
17219 | : "no "); | |
17220 | ||
17221 | /* BGP configuration. */ | |
892fedb6 | 17222 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17223 | vty_out(vty, " bgp always-compare-med\n"); |
17224 | ||
17225 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17226 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17227 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17228 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17229 | CHECK_FLAG(bgp->flags, | |
17230 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17231 | ? "" | |
17232 | : "no "); | |
dd65f45e DL |
17233 | |
17234 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17235 | if (bgp->reject_as_sets) |
dd65f45e DL |
17236 | vty_out(vty, " bgp reject-as-sets\n"); |
17237 | ||
2adac256 DA |
17238 | /* Suppress duplicate updates if the route actually not changed |
17239 | */ | |
17240 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17241 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17242 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17243 | CHECK_FLAG(bgp->flags, | |
17244 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17245 | ? "" | |
17246 | : "no "); | |
17247 | ||
b16bcbba TA |
17248 | /* BGP default <afi>-<safi> */ |
17249 | FOREACH_AFI_SAFI (afi, safi) { | |
17250 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17251 | if (!bgp->default_af[afi][safi]) | |
17252 | vty_out(vty, " no bgp default %s\n", | |
17253 | get_bgp_default_af_flag(afi, | |
17254 | safi)); | |
17255 | } else if (bgp->default_af[afi][safi]) | |
17256 | vty_out(vty, " bgp default %s\n", | |
17257 | get_bgp_default_af_flag(afi, safi)); | |
17258 | } | |
e84c59af | 17259 | |
dd65f45e DL |
17260 | /* BGP default local-preference. */ |
17261 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17262 | vty_out(vty, " bgp default local-preference %u\n", | |
17263 | bgp->default_local_pref); | |
17264 | ||
17265 | /* BGP default show-hostname */ | |
892fedb6 | 17266 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17267 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17268 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17269 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17270 | ? "" |
17271 | : "no "); | |
17272 | ||
aef999a2 DA |
17273 | /* BGP default show-nexthop-hostname */ |
17274 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17275 | != SAVE_BGP_SHOW_HOSTNAME) | |
17276 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17277 | CHECK_FLAG(bgp->flags, | |
17278 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17279 | ? "" | |
17280 | : "no "); | |
17281 | ||
dd65f45e DL |
17282 | /* BGP default subgroup-pkt-queue-max. */ |
17283 | if (bgp->default_subgroup_pkt_queue_max | |
17284 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17285 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17286 | bgp->default_subgroup_pkt_queue_max); | |
17287 | ||
17288 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17289 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17290 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17291 | ||
17292 | /* BGP cluster ID. */ | |
17293 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17294 | vty_out(vty, " bgp cluster-id %pI4\n", |
17295 | &bgp->cluster_id); | |
dd65f45e DL |
17296 | |
17297 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17298 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17299 | vty_out(vty, |
17300 | " bgp disable-ebgp-connected-route-check\n"); | |
17301 | ||
17302 | /* Confederation identifier*/ | |
17303 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17304 | vty_out(vty, " bgp confederation identifier %u\n", | |
17305 | bgp->confed_id); | |
17306 | ||
17307 | /* Confederation peer */ | |
17308 | if (bgp->confed_peers_cnt > 0) { | |
17309 | int i; | |
17310 | ||
17311 | vty_out(vty, " bgp confederation peers"); | |
17312 | ||
17313 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17314 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17315 | ||
17316 | vty_out(vty, "\n"); | |
17317 | } | |
17318 | ||
17319 | /* BGP deterministic-med. */ | |
892fedb6 | 17320 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17321 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17322 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17323 | CHECK_FLAG(bgp->flags, |
17324 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17325 | ? "" |
17326 | : "no "); | |
17327 | ||
17328 | /* BGP update-delay. */ | |
17329 | bgp_config_write_update_delay(vty, bgp); | |
17330 | ||
17331 | if (bgp->v_maxmed_onstartup | |
17332 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17333 | vty_out(vty, " bgp max-med on-startup %u", | |
17334 | bgp->v_maxmed_onstartup); | |
17335 | if (bgp->maxmed_onstartup_value | |
17336 | != BGP_MAXMED_VALUE_DEFAULT) | |
17337 | vty_out(vty, " %u", | |
17338 | bgp->maxmed_onstartup_value); | |
17339 | vty_out(vty, "\n"); | |
17340 | } | |
17341 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17342 | vty_out(vty, " bgp max-med administrative"); | |
17343 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17344 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17345 | vty_out(vty, "\n"); | |
17346 | } | |
17347 | ||
17348 | /* write quanta */ | |
17349 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17350 | /* read quanta */ | |
17351 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17352 | ||
17353 | /* coalesce time */ | |
17354 | bgp_config_write_coalesce_time(vty, bgp); | |
17355 | ||
05bd726c | 17356 | /* BGP per-instance graceful-shutdown */ |
17357 | /* BGP-wide settings and per-instance settings are mutually | |
17358 | * exclusive. | |
17359 | */ | |
17360 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17361 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17362 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17363 | ||
8606be87 DA |
17364 | /* Long-lived Graceful Restart */ |
17365 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
17366 | vty_out(vty, | |
17367 | " bgp long-lived-graceful-restart stale-time %u\n", | |
17368 | bgp->llgr_stale_time); | |
17369 | ||
dd65f45e DL |
17370 | /* BGP graceful-restart. */ |
17371 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17372 | vty_out(vty, | |
17373 | " bgp graceful-restart stalepath-time %u\n", | |
17374 | bgp->stalepath_time); | |
cfd47646 | 17375 | |
dd65f45e DL |
17376 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17377 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17378 | bgp->restart_time); | |
cfd47646 | 17379 | |
17380 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
17381 | vty_out(vty, | |
17382 | " bgp graceful-restart select-defer-time %u\n", | |
17383 | bgp->select_defer_time); | |
17384 | ||
17385 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17386 | vty_out(vty, " bgp graceful-restart\n"); |
17387 | ||
cfd47646 | 17388 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17389 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17390 | ||
dd65f45e | 17391 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17392 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17393 | vty_out(vty, |
17394 | " bgp graceful-restart preserve-fw-state\n"); | |
17395 | ||
dc95985f | 17396 | /* Stale timer for RIB */ |
17397 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17398 | vty_out(vty, | |
17399 | " bgp graceful-restart rib-stale-time %u\n", | |
17400 | bgp->rib_stale_time); | |
17401 | ||
dd65f45e | 17402 | /* BGP bestpath method. */ |
892fedb6 | 17403 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17404 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17405 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17406 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17407 | ||
892fedb6 DA |
17408 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17409 | if (CHECK_FLAG(bgp->flags, | |
17410 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17411 | vty_out(vty, |
17412 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17413 | } else { | |
17414 | vty_out(vty, | |
17415 | " bgp bestpath as-path multipath-relax\n"); | |
17416 | } | |
17417 | } | |
17418 | ||
892fedb6 | 17419 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17420 | vty_out(vty, |
17421 | " bgp route-reflector allow-outbound-policy\n"); | |
17422 | } | |
892fedb6 | 17423 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17424 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17425 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17426 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17427 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17428 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17429 | vty_out(vty, " confed"); |
892fedb6 DA |
17430 | if (CHECK_FLAG(bgp->flags, |
17431 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17432 | vty_out(vty, " missing-as-worst"); |
17433 | vty_out(vty, "\n"); | |
17434 | } | |
17435 | ||
ee88563a JM |
17436 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
17437 | vty_out(vty, | |
17438 | " bgp bestpath peer-type multipath-relax\n"); | |
17439 | ||
f7e1c681 | 17440 | /* Link bandwidth handling. */ |
17441 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17442 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17443 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17444 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17445 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17446 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17447 | ||
dd65f45e | 17448 | /* BGP network import check. */ |
892fedb6 | 17449 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17450 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17451 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17452 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17453 | ? "" |
17454 | : "no "); | |
17455 | ||
17456 | /* BGP timers configuration. */ | |
5d5393b9 | 17457 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 17458 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
17459 | vty_out(vty, " timers bgp %u %u\n", |
17460 | bgp->default_keepalive, bgp->default_holdtime); | |
17461 | ||
b042667a TI |
17462 | /* BGP minimum holdtime configuration. */ |
17463 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
17464 | && bgp->default_min_holdtime != 0) | |
17465 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
17466 | bgp->default_min_holdtime); | |
17467 | ||
389e4f92 QY |
17468 | /* Conditional advertisement timer configuration */ |
17469 | if (bgp->condition_check_period | |
17470 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
17471 | vty_out(vty, | |
17472 | " bgp conditional-advertisement timer %u\n", | |
17473 | bgp->condition_check_period); | |
17474 | ||
dd65f45e DL |
17475 | /* peer-group */ |
17476 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17477 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17478 | } | |
17479 | ||
17480 | /* Normal neighbor configuration. */ | |
17481 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17482 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17483 | bgp_config_write_peer_global(vty, bgp, peer); | |
17484 | } | |
17485 | ||
17486 | /* listen range and limit for dynamic BGP neighbors */ | |
17487 | bgp_config_write_listen(vty, bgp); | |
17488 | ||
17489 | /* | |
17490 | * BGP default autoshutdown neighbors | |
17491 | * | |
17492 | * This must be placed after any peer and peer-group | |
17493 | * configuration, to avoid setting all peers to shutdown after | |
17494 | * a daemon restart, which is undesired behavior. (see #2286) | |
17495 | */ | |
17496 | if (bgp->autoshutdown) | |
17497 | vty_out(vty, " bgp default shutdown\n"); | |
17498 | ||
9cf59432 DS |
17499 | /* BGP instance administrative shutdown */ |
17500 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17501 | vty_out(vty, " bgp shutdown\n"); | |
17502 | ||
f852eb98 PG |
17503 | if (bgp->fast_convergence) |
17504 | vty_out(vty, " bgp fast-convergence\n"); | |
17505 | ||
a0281b2e HS |
17506 | if (bgp->srv6_enabled) { |
17507 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 17508 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
17509 | vty_out(vty, " locator %s\n", |
17510 | bgp->srv6_locator_name); | |
ff7c3ee1 | 17511 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
17512 | } |
17513 | ||
17514 | ||
dd65f45e DL |
17515 | /* IPv4 unicast configuration. */ |
17516 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17517 | ||
17518 | /* IPv4 multicast configuration. */ | |
17519 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17520 | ||
17521 | /* IPv4 labeled-unicast configuration. */ | |
17522 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17523 | ||
17524 | /* IPv4 VPN configuration. */ | |
17525 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17526 | ||
17527 | /* ENCAPv4 configuration. */ | |
17528 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17529 | ||
17530 | /* FLOWSPEC v4 configuration. */ | |
17531 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17532 | ||
17533 | /* IPv6 unicast configuration. */ | |
17534 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17535 | ||
17536 | /* IPv6 multicast configuration. */ | |
17537 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17538 | ||
17539 | /* IPv6 labeled-unicast configuration. */ | |
17540 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17541 | SAFI_LABELED_UNICAST); | |
17542 | ||
17543 | /* IPv6 VPN configuration. */ | |
17544 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17545 | ||
17546 | /* ENCAPv6 configuration. */ | |
17547 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17548 | ||
17549 | /* FLOWSPEC v6 configuration. */ | |
17550 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17551 | ||
17552 | /* EVPN configuration. */ | |
17553 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17554 | ||
17555 | hook_call(bgp_inst_config_write, bgp, vty); | |
17556 | ||
49e5a4a0 | 17557 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17558 | bgp_rfapi_cfg_write(vty, bgp); |
17559 | #endif | |
17560 | ||
07679ad9 | 17561 | vty_out(vty, "exit\n"); |
dd65f45e DL |
17562 | vty_out(vty, "!\n"); |
17563 | } | |
17564 | return 0; | |
17565 | } | |
17566 | ||
ddb5b488 | 17567 | |
718e3744 | 17568 | /* BGP node structure. */ |
d62a17ae | 17569 | static struct cmd_node bgp_node = { |
f4b8291f | 17570 | .name = "bgp", |
62b346ee | 17571 | .node = BGP_NODE, |
24389580 | 17572 | .parent_node = CONFIG_NODE, |
62b346ee | 17573 | .prompt = "%s(config-router)# ", |
612c2c15 | 17574 | .config_write = bgp_config_write, |
718e3744 | 17575 | }; |
17576 | ||
d62a17ae | 17577 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17578 | .name = "bgp ipv4 unicast", |
62b346ee | 17579 | .node = BGP_IPV4_NODE, |
24389580 | 17580 | .parent_node = BGP_NODE, |
62b346ee | 17581 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17582 | .no_xpath = true, |
718e3744 | 17583 | }; |
17584 | ||
d62a17ae | 17585 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17586 | .name = "bgp ipv4 multicast", |
62b346ee | 17587 | .node = BGP_IPV4M_NODE, |
24389580 | 17588 | .parent_node = BGP_NODE, |
62b346ee | 17589 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17590 | .no_xpath = true, |
718e3744 | 17591 | }; |
17592 | ||
d62a17ae | 17593 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17594 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17595 | .node = BGP_IPV4L_NODE, |
24389580 | 17596 | .parent_node = BGP_NODE, |
62b346ee | 17597 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17598 | .no_xpath = true, |
f51bae9c DS |
17599 | }; |
17600 | ||
d62a17ae | 17601 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 17602 | .name = "bgp ipv6 unicast", |
62b346ee | 17603 | .node = BGP_IPV6_NODE, |
24389580 | 17604 | .parent_node = BGP_NODE, |
62b346ee | 17605 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17606 | .no_xpath = true, |
718e3744 | 17607 | }; |
17608 | ||
d62a17ae | 17609 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17610 | .name = "bgp ipv6 multicast", |
62b346ee | 17611 | .node = BGP_IPV6M_NODE, |
24389580 | 17612 | .parent_node = BGP_NODE, |
62b346ee | 17613 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17614 | .no_xpath = true, |
25ffbdc1 | 17615 | }; |
17616 | ||
d62a17ae | 17617 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17618 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17619 | .node = BGP_IPV6L_NODE, |
24389580 | 17620 | .parent_node = BGP_NODE, |
62b346ee | 17621 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17622 | .no_xpath = true, |
f51bae9c DS |
17623 | }; |
17624 | ||
62b346ee | 17625 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17626 | .name = "bgp vpnv4", |
62b346ee | 17627 | .node = BGP_VPNV4_NODE, |
24389580 | 17628 | .parent_node = BGP_NODE, |
62b346ee | 17629 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17630 | .no_xpath = true, |
62b346ee | 17631 | }; |
6b0655a2 | 17632 | |
62b346ee | 17633 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17634 | .name = "bgp vpnv6", |
62b346ee | 17635 | .node = BGP_VPNV6_NODE, |
24389580 | 17636 | .parent_node = BGP_NODE, |
62b346ee | 17637 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 17638 | .no_xpath = true, |
62b346ee | 17639 | }; |
8ecd3266 | 17640 | |
62b346ee | 17641 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17642 | .name = "bgp evpn", |
62b346ee | 17643 | .node = BGP_EVPN_NODE, |
24389580 | 17644 | .parent_node = BGP_NODE, |
62b346ee | 17645 | .prompt = "%s(config-router-evpn)# ", |
dd2c81b8 | 17646 | .no_xpath = true, |
62b346ee | 17647 | }; |
4e0b7b6d | 17648 | |
62b346ee | 17649 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17650 | .name = "bgp evpn vni", |
62b346ee | 17651 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17652 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17653 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17654 | }; |
90e60aa7 | 17655 | |
62b346ee | 17656 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17657 | .name = "bgp ipv4 flowspec", |
62b346ee | 17658 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17659 | .parent_node = BGP_NODE, |
62b346ee | 17660 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17661 | .no_xpath = true, |
62b346ee | 17662 | }; |
7c40bf39 | 17663 | |
62b346ee | 17664 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17665 | .name = "bgp ipv6 flowspec", |
62b346ee | 17666 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17667 | .parent_node = BGP_NODE, |
62b346ee | 17668 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 17669 | .no_xpath = true, |
62b346ee | 17670 | }; |
7c40bf39 | 17671 | |
bfaab44d HS |
17672 | static struct cmd_node bgp_srv6_node = { |
17673 | .name = "bgp srv6", | |
17674 | .node = BGP_SRV6_NODE, | |
17675 | .parent_node = BGP_NODE, | |
17676 | .prompt = "%s(config-router-srv6)# ", | |
17677 | }; | |
17678 | ||
d62a17ae | 17679 | static void community_list_vty(void); |
1f8ae70b | 17680 | |
d62a17ae | 17681 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 17682 | { |
d62a17ae | 17683 | struct bgp *bgp; |
17684 | struct peer *peer; | |
d62a17ae | 17685 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17686 | |
d62a17ae | 17687 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17688 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17689 | /* only provide suggestions on the appropriate input | |
17690 | * token type, | |
17691 | * they'll otherwise show up multiple times */ | |
17692 | enum cmd_token_type match_type; | |
17693 | char *name = peer->host; | |
d48ed3e0 | 17694 | |
d62a17ae | 17695 | if (peer->conf_if) { |
17696 | match_type = VARIABLE_TKN; | |
17697 | name = peer->conf_if; | |
17698 | } else if (strchr(peer->host, ':')) | |
17699 | match_type = IPV6_TKN; | |
17700 | else | |
17701 | match_type = IPV4_TKN; | |
d48ed3e0 | 17702 | |
d62a17ae | 17703 | if (token->type != match_type) |
17704 | continue; | |
d48ed3e0 | 17705 | |
d62a17ae | 17706 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17707 | } | |
d62a17ae | 17708 | } |
b8a815e5 DL |
17709 | } |
17710 | ||
17711 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 17712 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17713 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17714 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17715 | {.completions = NULL}}; |
17716 | ||
47a306a0 DS |
17717 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17718 | { | |
17719 | struct bgp *bgp; | |
17720 | struct peer_group *group; | |
17721 | struct listnode *lnbgp, *lnpeer; | |
17722 | ||
17723 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17724 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17725 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
17726 | group->name)); | |
17727 | } | |
17728 | } | |
17729 | ||
17730 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
17731 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17732 | {.completions = NULL} }; | |
17733 | ||
d62a17ae | 17734 | void bgp_vty_init(void) |
17735 | { | |
17736 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17737 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17738 | |
17739 | /* Install bgp top node. */ | |
612c2c15 DL |
17740 | install_node(&bgp_node); |
17741 | install_node(&bgp_ipv4_unicast_node); | |
17742 | install_node(&bgp_ipv4_multicast_node); | |
17743 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17744 | install_node(&bgp_ipv6_unicast_node); | |
17745 | install_node(&bgp_ipv6_multicast_node); | |
17746 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17747 | install_node(&bgp_vpnv4_node); | |
17748 | install_node(&bgp_vpnv6_node); | |
17749 | install_node(&bgp_evpn_node); | |
17750 | install_node(&bgp_evpn_vni_node); | |
17751 | install_node(&bgp_flowspecv4_node); | |
17752 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 17753 | install_node(&bgp_srv6_node); |
d62a17ae | 17754 | |
17755 | /* Install default VTY commands to new nodes. */ | |
17756 | install_default(BGP_NODE); | |
17757 | install_default(BGP_IPV4_NODE); | |
17758 | install_default(BGP_IPV4M_NODE); | |
17759 | install_default(BGP_IPV4L_NODE); | |
17760 | install_default(BGP_IPV6_NODE); | |
17761 | install_default(BGP_IPV6M_NODE); | |
17762 | install_default(BGP_IPV6L_NODE); | |
17763 | install_default(BGP_VPNV4_NODE); | |
17764 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17765 | install_default(BGP_FLOWSPECV4_NODE); |
17766 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17767 | install_default(BGP_EVPN_NODE); |
17768 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 17769 | install_default(BGP_SRV6_NODE); |
d62a17ae | 17770 | |
8029b216 AK |
17771 | /* "bgp local-mac" hidden commands. */ |
17772 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17773 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17774 | ||
9acb67cb DS |
17775 | /* "bgp suppress-fib-pending" global */ |
17776 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
17777 | ||
d62a17ae | 17778 | /* bgp route-map delay-timer commands. */ |
17779 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17780 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17781 | ||
f852eb98 PG |
17782 | /* bgp fast-convergence command */ |
17783 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
17784 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
17785 | ||
d70583f7 D |
17786 | /* global bgp update-delay command */ |
17787 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17788 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17789 | ||
05bd726c | 17790 | /* global bgp graceful-shutdown command */ |
17791 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17792 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17793 | ||
d62a17ae | 17794 | /* Dummy commands (Currently not supported) */ |
17795 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17796 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17797 | ||
17798 | /* "router bgp" commands. */ | |
17799 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17800 | ||
17801 | /* "no router bgp" commands. */ | |
17802 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17803 | ||
17804 | /* "bgp router-id" commands. */ | |
17805 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17806 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17807 | ||
c208c586 S |
17808 | /* "bgp suppress-fib-pending" command */ |
17809 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17810 | ||
d62a17ae | 17811 | /* "bgp cluster-id" commands. */ |
17812 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17813 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17814 | ||
c163f297 DS |
17815 | /* "bgp no-rib" commands. */ |
17816 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17817 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17818 | ||
e46723a5 DS |
17819 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
17820 | ||
d62a17ae | 17821 | /* "bgp confederation" commands. */ |
17822 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17823 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17824 | ||
17825 | /* "bgp confederation peers" commands. */ | |
17826 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17827 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17828 | ||
17829 | /* bgp max-med command */ | |
17830 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17831 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17832 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17833 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17834 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17835 | ||
17836 | /* bgp disable-ebgp-connected-nh-check */ | |
17837 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17838 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17839 | ||
17840 | /* bgp update-delay command */ | |
17841 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17842 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17843 | |
17844 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17845 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17846 | |
17847 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17848 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17849 | ||
17850 | /* "maximum-paths" commands. */ | |
17851 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17852 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17853 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17854 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17855 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17856 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17857 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17858 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17859 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17860 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17861 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17862 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17863 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17864 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17865 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17866 | ||
39edabac PG |
17867 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17868 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17869 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17870 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17871 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17872 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17873 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17874 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17875 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17876 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17877 | ||
17878 | /* "timers bgp" commands. */ | |
17879 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17880 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17881 | ||
b042667a TI |
17882 | /* "minimum-holdtime" commands. */ |
17883 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
17884 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
17885 | ||
d62a17ae | 17886 | /* route-map delay-timer commands - per instance for backwards compat. |
17887 | */ | |
17888 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17889 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17890 | ||
17891 | /* "bgp client-to-client reflection" commands */ | |
17892 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17893 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17894 | ||
17895 | /* "bgp always-compare-med" commands */ | |
17896 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17897 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17898 | ||
9dac9fc8 DA |
17899 | /* bgp ebgp-requires-policy */ |
17900 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17901 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17902 | ||
2adac256 DA |
17903 | /* bgp suppress-duplicates */ |
17904 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
17905 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
17906 | ||
fb29348a DA |
17907 | /* bgp reject-as-sets */ |
17908 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
17909 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
17910 | ||
d62a17ae | 17911 | /* "bgp deterministic-med" commands */ |
17912 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
17913 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
17914 | ||
055679e9 | 17915 | /* "bgp graceful-restart" command */ |
36235319 QY |
17916 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
17917 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 17918 | |
17919 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
17920 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
17921 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 17922 | |
17923 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
17924 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
17925 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 17926 | |
17927 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
17928 | install_element(BGP_NODE, | |
17929 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
17930 | install_element(BGP_NODE, | |
17931 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
17932 | ||
17933 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
17934 | install_element(BGP_NODE, | |
17935 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
17936 | install_element(BGP_NODE, | |
17937 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
17938 | ||
d62a17ae | 17939 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
17940 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
17941 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
17942 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 17943 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 17944 | install_element(BGP_NODE, |
17945 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 17946 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
17947 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
17948 | ||
d6e3c15b | 17949 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
17950 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 17951 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
17952 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 17953 | |
7f323236 DW |
17954 | /* "bgp graceful-shutdown" commands */ |
17955 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
17956 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
17957 | ||
8606be87 DA |
17958 | /* "bgp long-lived-graceful-restart" commands */ |
17959 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
17960 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
17961 | ||
d62a17ae | 17962 | /* "bgp fast-external-failover" commands */ |
17963 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
17964 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
17965 | ||
d62a17ae | 17966 | /* "bgp bestpath compare-routerid" commands */ |
17967 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
17968 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
17969 | ||
17970 | /* "bgp bestpath as-path ignore" commands */ | |
17971 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
17972 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
17973 | ||
17974 | /* "bgp bestpath as-path confed" commands */ | |
17975 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
17976 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
17977 | ||
17978 | /* "bgp bestpath as-path multipath-relax" commands */ | |
17979 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
17980 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
17981 | ||
ee88563a JM |
17982 | /* "bgp bestpath peer-type multipath-relax" commands */ |
17983 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
17984 | install_element(BGP_NODE, | |
17985 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
17986 | ||
d62a17ae | 17987 | /* "bgp log-neighbor-changes" commands */ |
17988 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
17989 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
17990 | ||
17991 | /* "bgp bestpath med" commands */ | |
17992 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
17993 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
17994 | ||
f7e1c681 | 17995 | /* "bgp bestpath bandwidth" commands */ |
17996 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 17997 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 17998 | |
b16bcbba TA |
17999 | /* "no bgp default <afi>-<safi>" commands. */ |
18000 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 18001 | |
d62a17ae | 18002 | /* "bgp network import-check" commands. */ |
18003 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
18004 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
18005 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
18006 | ||
18007 | /* "bgp default local-preference" commands. */ | |
18008 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
18009 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
18010 | ||
18011 | /* bgp default show-hostname */ | |
18012 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
18013 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
18014 | ||
aef999a2 DA |
18015 | /* bgp default show-nexthop-hostname */ |
18016 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
18017 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
18018 | ||
d62a17ae | 18019 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
18020 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
18021 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
18022 | ||
18023 | /* bgp ibgp-allow-policy-mods command */ | |
18024 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
18025 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
18026 | ||
18027 | /* "bgp listen limit" commands. */ | |
18028 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
18029 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
18030 | ||
18031 | /* "bgp listen range" commands. */ | |
18032 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
18033 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
18034 | ||
8175f54a | 18035 | /* "bgp default shutdown" command */ |
f26845f9 | 18036 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
18037 | |
18038 | /* "bgp shutdown" commands */ | |
18039 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 18040 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 18041 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 18042 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 18043 | |
d62a17ae | 18044 | /* "neighbor remote-as" commands. */ |
18045 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
18046 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
18047 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
18048 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
18049 | install_element(BGP_NODE, | |
18050 | &neighbor_interface_v6only_config_remote_as_cmd); | |
18051 | install_element(BGP_NODE, &no_neighbor_cmd); | |
18052 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
18053 | ||
18054 | /* "neighbor peer-group" commands. */ | |
18055 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
18056 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
18057 | install_element(BGP_NODE, | |
18058 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
18059 | ||
18060 | /* "neighbor local-as" commands. */ | |
18061 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
18062 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
18063 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
18064 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
18065 | ||
18066 | /* "neighbor solo" commands. */ | |
18067 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
18068 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
18069 | ||
18070 | /* "neighbor password" commands. */ | |
18071 | install_element(BGP_NODE, &neighbor_password_cmd); | |
18072 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
18073 | ||
18074 | /* "neighbor activate" commands. */ | |
18075 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
18076 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
18077 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
18078 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
18079 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
18080 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
18081 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
18082 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
18083 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 18084 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
18085 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 18086 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
18087 | ||
18088 | /* "no neighbor activate" commands. */ | |
18089 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
18090 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
18091 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
18092 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
18093 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
18094 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
18095 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
18096 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
18097 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 18098 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
18099 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 18100 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
18101 | ||
18102 | /* "neighbor peer-group" set commands. */ | |
18103 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
18104 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18105 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18106 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18107 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18108 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18109 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18110 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18111 | install_element(BGP_FLOWSPECV4_NODE, |
18112 | &neighbor_set_peer_group_hidden_cmd); | |
18113 | install_element(BGP_FLOWSPECV6_NODE, | |
18114 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18115 | |
18116 | /* "no neighbor peer-group unset" commands. */ | |
18117 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
18118 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18119 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18120 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18121 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18122 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18123 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18124 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18125 | install_element(BGP_FLOWSPECV4_NODE, |
18126 | &no_neighbor_set_peer_group_hidden_cmd); | |
18127 | install_element(BGP_FLOWSPECV6_NODE, | |
18128 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18129 | |
18130 | /* "neighbor softreconfiguration inbound" commands.*/ | |
18131 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
18132 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
18133 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18134 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18135 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18136 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18137 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18138 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18139 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18140 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18141 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18142 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18143 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18144 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18145 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18146 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18147 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18148 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 18149 | install_element(BGP_FLOWSPECV4_NODE, |
18150 | &neighbor_soft_reconfiguration_cmd); | |
18151 | install_element(BGP_FLOWSPECV4_NODE, | |
18152 | &no_neighbor_soft_reconfiguration_cmd); | |
18153 | install_element(BGP_FLOWSPECV6_NODE, | |
18154 | &neighbor_soft_reconfiguration_cmd); | |
18155 | install_element(BGP_FLOWSPECV6_NODE, | |
18156 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
18157 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
18158 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 18159 | |
18160 | /* "neighbor attribute-unchanged" commands. */ | |
18161 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
18162 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
18163 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
18164 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18165 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
18166 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18167 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
18168 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18169 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
18170 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18171 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
18172 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18173 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
18174 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18175 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18176 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18177 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18178 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18179 | ||
18180 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
18181 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
18182 | ||
b8ad84d2 PG |
18183 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
18184 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18185 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
18186 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18187 | ||
d62a17ae | 18188 | /* "nexthop-local unchanged" commands */ |
18189 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
18190 | install_element(BGP_IPV6_NODE, | |
18191 | &no_neighbor_nexthop_local_unchanged_cmd); | |
18192 | ||
18193 | /* "neighbor next-hop-self" commands. */ | |
18194 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
18195 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
18196 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
18197 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18198 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
18199 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
18200 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
18201 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
18202 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
18203 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18204 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
18205 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
18206 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
18207 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
18208 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
18209 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18210 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
18211 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
18212 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
18213 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 18214 | |
18215 | /* "neighbor next-hop-self force" commands. */ | |
18216 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
18217 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
18218 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18219 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18220 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
18221 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18222 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18223 | install_element(BGP_IPV4_NODE, | |
18224 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18225 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
18226 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18227 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18228 | install_element(BGP_IPV4M_NODE, | |
18229 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18230 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
18231 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18232 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18233 | install_element(BGP_IPV4L_NODE, | |
18234 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18235 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
18236 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18237 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18238 | install_element(BGP_IPV6_NODE, | |
18239 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18240 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
18241 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18242 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18243 | install_element(BGP_IPV6M_NODE, | |
18244 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18245 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
18246 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18247 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18248 | install_element(BGP_IPV6L_NODE, | |
18249 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18250 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
18251 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18252 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18253 | install_element(BGP_VPNV4_NODE, | |
18254 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18255 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
18256 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18257 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18258 | install_element(BGP_VPNV6_NODE, | |
18259 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
18260 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
18261 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 18262 | |
18263 | /* "neighbor as-override" commands. */ | |
18264 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18265 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18266 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18267 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18268 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18269 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18270 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18271 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18272 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18273 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18274 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18275 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18276 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18277 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18278 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18279 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18280 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18281 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18282 | ||
18283 | /* "neighbor remove-private-AS" commands. */ | |
18284 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18285 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18286 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18287 | install_element(BGP_NODE, | |
18288 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18289 | install_element(BGP_NODE, | |
18290 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18291 | install_element(BGP_NODE, | |
18292 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18293 | install_element(BGP_NODE, | |
18294 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18295 | install_element( | |
18296 | BGP_NODE, | |
18297 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18298 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18299 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18300 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18301 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18302 | install_element(BGP_IPV4_NODE, | |
18303 | &neighbor_remove_private_as_replace_as_cmd); | |
18304 | install_element(BGP_IPV4_NODE, | |
18305 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18306 | install_element(BGP_IPV4_NODE, | |
18307 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18308 | install_element(BGP_IPV4_NODE, | |
18309 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18310 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18311 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18312 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18313 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18314 | install_element(BGP_IPV4M_NODE, | |
18315 | &neighbor_remove_private_as_replace_as_cmd); | |
18316 | install_element(BGP_IPV4M_NODE, | |
18317 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18318 | install_element(BGP_IPV4M_NODE, | |
18319 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18320 | install_element(BGP_IPV4M_NODE, | |
18321 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18322 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18323 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18324 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18325 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18326 | install_element(BGP_IPV4L_NODE, | |
18327 | &neighbor_remove_private_as_replace_as_cmd); | |
18328 | install_element(BGP_IPV4L_NODE, | |
18329 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18330 | install_element(BGP_IPV4L_NODE, | |
18331 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18332 | install_element(BGP_IPV4L_NODE, | |
18333 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18334 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
18335 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18336 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18337 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18338 | install_element(BGP_IPV6_NODE, | |
18339 | &neighbor_remove_private_as_replace_as_cmd); | |
18340 | install_element(BGP_IPV6_NODE, | |
18341 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18342 | install_element(BGP_IPV6_NODE, | |
18343 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18344 | install_element(BGP_IPV6_NODE, | |
18345 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18346 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
18347 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
18348 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
18349 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18350 | install_element(BGP_IPV6M_NODE, | |
18351 | &neighbor_remove_private_as_replace_as_cmd); | |
18352 | install_element(BGP_IPV6M_NODE, | |
18353 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18354 | install_element(BGP_IPV6M_NODE, | |
18355 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18356 | install_element(BGP_IPV6M_NODE, | |
18357 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18358 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
18359 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
18360 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
18361 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18362 | install_element(BGP_IPV6L_NODE, | |
18363 | &neighbor_remove_private_as_replace_as_cmd); | |
18364 | install_element(BGP_IPV6L_NODE, | |
18365 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18366 | install_element(BGP_IPV6L_NODE, | |
18367 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18368 | install_element(BGP_IPV6L_NODE, | |
18369 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18370 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
18371 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18372 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18373 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18374 | install_element(BGP_VPNV4_NODE, | |
18375 | &neighbor_remove_private_as_replace_as_cmd); | |
18376 | install_element(BGP_VPNV4_NODE, | |
18377 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18378 | install_element(BGP_VPNV4_NODE, | |
18379 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18380 | install_element(BGP_VPNV4_NODE, | |
18381 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18382 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
18383 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18384 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18385 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18386 | install_element(BGP_VPNV6_NODE, | |
18387 | &neighbor_remove_private_as_replace_as_cmd); | |
18388 | install_element(BGP_VPNV6_NODE, | |
18389 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18390 | install_element(BGP_VPNV6_NODE, | |
18391 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18392 | install_element(BGP_VPNV6_NODE, | |
18393 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18394 | ||
18395 | /* "neighbor send-community" commands.*/ | |
18396 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
18397 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
18398 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
18399 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
18400 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
18401 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
18402 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
18403 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
18404 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
18405 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
18406 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
18407 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
18408 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
18409 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
18410 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
18411 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
18412 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
18413 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
18414 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
18415 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
18416 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
18417 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
18418 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
18419 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
18420 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
18421 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
18422 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
18423 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
18424 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
18425 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
18426 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
18427 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
18428 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
18429 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18430 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18431 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18432 | ||
18433 | /* "neighbor route-reflector" commands.*/ | |
18434 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18435 | install_element(BGP_NODE, | |
18436 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18437 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18438 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18439 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18440 | install_element(BGP_IPV4M_NODE, | |
18441 | &no_neighbor_route_reflector_client_cmd); | |
18442 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18443 | install_element(BGP_IPV4L_NODE, | |
18444 | &no_neighbor_route_reflector_client_cmd); | |
18445 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18446 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18447 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18448 | install_element(BGP_IPV6M_NODE, | |
18449 | &no_neighbor_route_reflector_client_cmd); | |
18450 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18451 | install_element(BGP_IPV6L_NODE, | |
18452 | &no_neighbor_route_reflector_client_cmd); | |
18453 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18454 | install_element(BGP_VPNV4_NODE, | |
18455 | &no_neighbor_route_reflector_client_cmd); | |
18456 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18457 | install_element(BGP_VPNV6_NODE, | |
18458 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18459 | install_element(BGP_FLOWSPECV4_NODE, |
18460 | &neighbor_route_reflector_client_cmd); | |
18461 | install_element(BGP_FLOWSPECV4_NODE, | |
18462 | &no_neighbor_route_reflector_client_cmd); | |
18463 | install_element(BGP_FLOWSPECV6_NODE, | |
18464 | &neighbor_route_reflector_client_cmd); | |
18465 | install_element(BGP_FLOWSPECV6_NODE, | |
18466 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18467 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18468 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18469 | ||
18470 | /* "neighbor route-server" commands.*/ | |
18471 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18472 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18473 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18474 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18475 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18476 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18477 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18478 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18479 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18480 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18481 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18482 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18483 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18484 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18485 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18486 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18487 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18488 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18489 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18490 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18491 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18492 | install_element(BGP_FLOWSPECV4_NODE, | |
18493 | &no_neighbor_route_server_client_cmd); | |
18494 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18495 | install_element(BGP_FLOWSPECV6_NODE, | |
18496 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18497 | |
7c0e4312 DA |
18498 | /* "neighbor disable-addpath-rx" commands. */ |
18499 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18500 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18501 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18502 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18503 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18504 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18505 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18506 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18507 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18508 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18509 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18510 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18511 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18512 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18513 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18514 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18515 | ||
d62a17ae | 18516 | /* "neighbor addpath-tx-all-paths" commands.*/ |
18517 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18518 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18519 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18520 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18521 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18522 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18523 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18524 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18525 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18526 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18527 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18528 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18529 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18530 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18531 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18532 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18533 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18534 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18535 | ||
18536 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18537 | install_element(BGP_NODE, | |
18538 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18539 | install_element(BGP_NODE, | |
18540 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18541 | install_element(BGP_IPV4_NODE, | |
18542 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18543 | install_element(BGP_IPV4_NODE, | |
18544 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18545 | install_element(BGP_IPV4M_NODE, | |
18546 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18547 | install_element(BGP_IPV4M_NODE, | |
18548 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18549 | install_element(BGP_IPV4L_NODE, | |
18550 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18551 | install_element(BGP_IPV4L_NODE, | |
18552 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18553 | install_element(BGP_IPV6_NODE, | |
18554 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18555 | install_element(BGP_IPV6_NODE, | |
18556 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18557 | install_element(BGP_IPV6M_NODE, | |
18558 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18559 | install_element(BGP_IPV6M_NODE, | |
18560 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18561 | install_element(BGP_IPV6L_NODE, | |
18562 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18563 | install_element(BGP_IPV6L_NODE, | |
18564 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18565 | install_element(BGP_VPNV4_NODE, | |
18566 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18567 | install_element(BGP_VPNV4_NODE, | |
18568 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18569 | install_element(BGP_VPNV6_NODE, | |
18570 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18571 | install_element(BGP_VPNV6_NODE, | |
18572 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18573 | ||
2b31007c RZ |
18574 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18575 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18576 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18577 | ||
d62a17ae | 18578 | /* "neighbor passive" commands. */ |
18579 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18580 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18581 | ||
18582 | ||
18583 | /* "neighbor shutdown" commands. */ | |
18584 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18585 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18586 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18587 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18588 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18589 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18590 | |
18591 | /* "neighbor capability extended-nexthop" commands.*/ | |
18592 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18593 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18594 | ||
18595 | /* "neighbor capability orf prefix-list" commands.*/ | |
18596 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18597 | install_element(BGP_NODE, | |
18598 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18599 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18600 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18601 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18602 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18603 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18604 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18605 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18606 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18607 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18608 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18609 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18610 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18611 | ||
18612 | /* "neighbor capability dynamic" commands.*/ | |
18613 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18614 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18615 | ||
18616 | /* "neighbor dont-capability-negotiate" commands. */ | |
18617 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18618 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18619 | ||
18620 | /* "neighbor ebgp-multihop" commands. */ | |
18621 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18622 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18623 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18624 | ||
18625 | /* "neighbor disable-connected-check" commands. */ | |
18626 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18627 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18628 | ||
7ab294ea DA |
18629 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
18630 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
18631 | install_element(BGP_NODE, | |
18632 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 18633 | |
47cbc09b PM |
18634 | /* "neighbor enforce-first-as" commands. */ |
18635 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18636 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18637 | ||
d62a17ae | 18638 | /* "neighbor description" commands. */ |
18639 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18640 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18641 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18642 | |
18643 | /* "neighbor update-source" commands. "*/ | |
18644 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18645 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18646 | ||
18647 | /* "neighbor default-originate" commands. */ | |
18648 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18649 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18650 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18651 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18652 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18653 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18654 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18655 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18656 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18657 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18658 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18659 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18660 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18661 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18662 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18663 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18664 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18665 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18666 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18667 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18668 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18669 | ||
18670 | /* "neighbor port" commands. */ | |
18671 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18672 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18673 | ||
18674 | /* "neighbor weight" commands. */ | |
18675 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18676 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18677 | ||
18678 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18679 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18680 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18681 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18682 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18683 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18684 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18685 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18686 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18687 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18688 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18689 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18690 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18691 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18692 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18693 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18694 | ||
18695 | /* "neighbor override-capability" commands. */ | |
18696 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18697 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18698 | ||
18699 | /* "neighbor strict-capability-match" commands. */ | |
18700 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18701 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18702 | ||
18703 | /* "neighbor timers" commands. */ | |
18704 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18705 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18706 | ||
18707 | /* "neighbor timers connect" commands. */ | |
18708 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18709 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18710 | ||
d43114f3 DS |
18711 | /* "neighbor timers delayopen" commands. */ |
18712 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
18713 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
18714 | ||
d62a17ae | 18715 | /* "neighbor advertisement-interval" commands. */ |
18716 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18717 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18718 | ||
18719 | /* "neighbor interface" commands. */ | |
18720 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18721 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18722 | ||
18723 | /* "neighbor distribute" commands. */ | |
18724 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18725 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18726 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18727 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18728 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18729 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18730 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18731 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18732 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18733 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18734 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18735 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18736 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18737 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18738 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18739 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18740 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18741 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18742 | ||
18743 | /* "neighbor prefix-list" commands. */ | |
18744 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 18745 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 18746 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18747 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18748 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18749 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18750 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18751 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18752 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18753 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18754 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18755 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18756 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18757 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18758 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18759 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18760 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18761 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18762 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18763 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18764 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18765 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18766 | |
18767 | /* "neighbor filter-list" commands. */ | |
18768 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18769 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18770 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18771 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18772 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18773 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18774 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18775 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18776 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18777 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18778 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18779 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18780 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18781 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18782 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18783 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18784 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18785 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18786 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18787 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18788 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18789 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18790 | |
18791 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
18792 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
18793 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 18794 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18795 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18796 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18797 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18798 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18799 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18800 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18801 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18802 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18803 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18804 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18805 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18806 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18807 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18808 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18809 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18810 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18811 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18812 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18813 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 18814 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18815 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18816 | |
18817 | /* "neighbor unsuppress-map" commands. */ | |
18818 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18819 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18820 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18821 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18822 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18823 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18824 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18825 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18826 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18827 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18828 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18829 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18830 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18831 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18832 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18833 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18834 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18835 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18836 | ||
7f7940e6 | 18837 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 18838 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 18839 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 18840 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18841 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18842 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18843 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18844 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18845 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18846 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18847 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18848 | |
fde246e8 DA |
18849 | /* neighbor maximum-prefix-out commands. */ |
18850 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18851 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18852 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18853 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18854 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18855 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18856 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18857 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18858 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18859 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18860 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18861 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18862 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18863 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18864 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18865 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18866 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18867 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18868 | ||
d62a17ae | 18869 | /* "neighbor maximum-prefix" commands. */ |
18870 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18871 | install_element(BGP_NODE, | |
18872 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18873 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18874 | install_element(BGP_NODE, | |
18875 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18876 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18877 | install_element(BGP_NODE, | |
18878 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18879 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18880 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18881 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18882 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18883 | install_element(BGP_IPV4_NODE, | |
18884 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18885 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18886 | install_element(BGP_IPV4_NODE, | |
18887 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18888 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18889 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18890 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18891 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18892 | install_element(BGP_IPV4M_NODE, | |
18893 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18894 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18895 | install_element(BGP_IPV4M_NODE, | |
18896 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18897 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18898 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
18899 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18900 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18901 | install_element(BGP_IPV4L_NODE, | |
18902 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18903 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18904 | install_element(BGP_IPV4L_NODE, | |
18905 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18906 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18907 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
18908 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18909 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18910 | install_element(BGP_IPV6_NODE, | |
18911 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18912 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18913 | install_element(BGP_IPV6_NODE, | |
18914 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18915 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18916 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
18917 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18918 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18919 | install_element(BGP_IPV6M_NODE, | |
18920 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18921 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18922 | install_element(BGP_IPV6M_NODE, | |
18923 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18924 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
18925 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
18926 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18927 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18928 | install_element(BGP_IPV6L_NODE, | |
18929 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18930 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18931 | install_element(BGP_IPV6L_NODE, | |
18932 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18933 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
18934 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
18935 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18936 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18937 | install_element(BGP_VPNV4_NODE, | |
18938 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18939 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18940 | install_element(BGP_VPNV4_NODE, | |
18941 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18942 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18943 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
18944 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18945 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18946 | install_element(BGP_VPNV6_NODE, | |
18947 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18948 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18949 | install_element(BGP_VPNV6_NODE, | |
18950 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18951 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
18952 | ||
18953 | /* "neighbor allowas-in" */ | |
18954 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
18955 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
18956 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
18957 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
18958 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
18959 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
18960 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
18961 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
18962 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
18963 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
18964 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
18965 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
18966 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
18967 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
18968 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
18969 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
18970 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
18971 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
18972 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
18973 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
18974 | ||
18975 | /* address-family commands. */ | |
18976 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
18977 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 18978 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 18979 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
18980 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 18981 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 18982 | |
d62a17ae | 18983 | install_element(BGP_NODE, &address_family_evpn_cmd); |
18984 | ||
18985 | /* "exit-address-family" command. */ | |
18986 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
18987 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
18988 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
18989 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
18990 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
18991 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
18992 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
18993 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 18994 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
18995 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 18996 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
18997 | ||
18998 | /* "clear ip bgp commands" */ | |
18999 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
19000 | ||
19001 | /* clear ip bgp prefix */ | |
19002 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
19003 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
19004 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
19005 | ||
19006 | /* "show [ip] bgp summary" commands. */ | |
19007 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 19008 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 19009 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 19010 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 19011 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
19012 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 19013 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
19014 | ||
19015 | /* "show [ip] bgp neighbors" commands. */ | |
19016 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
19017 | ||
36235319 | 19018 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 19019 | |
d62a17ae | 19020 | /* "show [ip] bgp peer-group" commands. */ |
19021 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
19022 | ||
19023 | /* "show [ip] bgp paths" commands. */ | |
19024 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
19025 | ||
19026 | /* "show [ip] bgp community" commands. */ | |
19027 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
19028 | ||
19029 | /* "show ip bgp large-community" commands. */ | |
19030 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
19031 | /* "show [ip] bgp attribute-info" commands. */ | |
19032 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 19033 | /* "show [ip] bgp route-leak" command */ |
19034 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 19035 | |
19036 | /* "redistribute" commands. */ | |
19037 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
19038 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
19039 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
19040 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
19041 | install_element(BGP_NODE, | |
19042 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
19043 | install_element(BGP_NODE, | |
19044 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
19045 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19046 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19047 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
19048 | install_element(BGP_NODE, | |
19049 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
19050 | install_element(BGP_NODE, | |
19051 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
19052 | install_element(BGP_NODE, | |
19053 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
19054 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
19055 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
19056 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
19057 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
19058 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
19059 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
19060 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
19061 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
19062 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
19063 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
19064 | install_element(BGP_IPV4_NODE, | |
19065 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
19066 | install_element(BGP_IPV4_NODE, | |
19067 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
19068 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
19069 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
19070 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
19071 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
19072 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
19073 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
19074 | ||
b9c7bc5a PZ |
19075 | /* import|export vpn [route-map WORD] */ |
19076 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
19077 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 19078 | |
12a844a5 DS |
19079 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
19080 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
19081 | ||
d62a17ae | 19082 | /* ttl_security commands */ |
19083 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
19084 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
19085 | ||
19086 | /* "show [ip] bgp memory" commands. */ | |
19087 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
19088 | ||
acf71666 MK |
19089 | /* "show bgp martian next-hop" */ |
19090 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
19091 | ||
48ecf8f5 DS |
19092 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
19093 | ||
d62a17ae | 19094 | /* "show [ip] bgp views" commands. */ |
19095 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
19096 | ||
19097 | /* "show [ip] bgp vrfs" commands. */ | |
19098 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
19099 | ||
19100 | /* Community-list. */ | |
19101 | community_list_vty(); | |
ddb5b488 | 19102 | |
ed0e57e3 DA |
19103 | community_alias_vty(); |
19104 | ||
ddb5b488 | 19105 | /* vpn-policy commands */ |
b9c7bc5a PZ |
19106 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
19107 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
19108 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
19109 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
19110 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
19111 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
19112 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
19113 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
19114 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
19115 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19116 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
19117 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 19118 | |
301ad80a PG |
19119 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
19120 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
19121 | ||
b9c7bc5a PZ |
19122 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
19123 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
19124 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
19125 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
19126 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
19127 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
19128 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
19129 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19130 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
19131 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
19132 | |
19133 | /* tcp-mss command */ | |
19134 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
19135 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
19136 | |
19137 | /* srv6 commands */ | |
ea372e81 | 19138 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 19139 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 19140 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 19141 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 19142 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
19143 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
19144 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
718e3744 | 19145 | } |
6b0655a2 | 19146 | |
718e3744 | 19147 | #include "memory.h" |
19148 | #include "bgp_regex.h" | |
19149 | #include "bgp_clist.h" | |
19150 | #include "bgp_ecommunity.h" | |
19151 | ||
19152 | /* VTY functions. */ | |
19153 | ||
19154 | /* Direction value to string conversion. */ | |
d62a17ae | 19155 | static const char *community_direct_str(int direct) |
19156 | { | |
19157 | switch (direct) { | |
19158 | case COMMUNITY_DENY: | |
19159 | return "deny"; | |
19160 | case COMMUNITY_PERMIT: | |
19161 | return "permit"; | |
19162 | default: | |
19163 | return "unknown"; | |
19164 | } | |
718e3744 | 19165 | } |
19166 | ||
19167 | /* Display error string. */ | |
d62a17ae | 19168 | static void community_list_perror(struct vty *vty, int ret) |
19169 | { | |
19170 | switch (ret) { | |
19171 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
19172 | vty_out(vty, "%% Can't find community-list\n"); | |
19173 | break; | |
19174 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
19175 | vty_out(vty, "%% Malformed community-list value\n"); | |
19176 | break; | |
19177 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
19178 | vty_out(vty, | |
19179 | "%% Community name conflict, previously defined as standard community\n"); | |
19180 | break; | |
19181 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
19182 | vty_out(vty, | |
19183 | "%% Community name conflict, previously defined as expanded community\n"); | |
19184 | break; | |
19185 | } | |
718e3744 | 19186 | } |
19187 | ||
5bf15956 DW |
19188 | /* "community-list" keyword help string. */ |
19189 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
19190 | ||
7336e101 SP |
19191 | /*community-list standard */ |
19192 | DEFUN (community_list_standard, | |
19193 | bgp_community_list_standard_cmd, | |
a2099c1d | 19194 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19195 | BGP_STR |
718e3744 | 19196 | COMMUNITY_LIST_STR |
19197 | "Community list number (standard)\n" | |
5bf15956 | 19198 | "Add an standard community-list entry\n" |
718e3744 | 19199 | "Community list name\n" |
2f8cc0e5 DA |
19200 | "Sequence number of an entry\n" |
19201 | "Sequence number\n" | |
718e3744 | 19202 | "Specify community to reject\n" |
19203 | "Specify community to accept\n" | |
19204 | COMMUNITY_VAL_STR) | |
19205 | { | |
d62a17ae | 19206 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19207 | char *seq = NULL; |
d62a17ae | 19208 | int direct = 0; |
19209 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 19210 | int idx = 0; |
7336e101 | 19211 | |
a08032fe | 19212 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19213 | if (idx) |
19214 | seq = argv[idx]->arg; | |
19215 | ||
19216 | idx = 0; | |
d62a17ae | 19217 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19218 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19219 | cl_name_or_number = argv[idx]->arg; |
19220 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19221 | : COMMUNITY_DENY; | |
19222 | argv_find(argv, argc, "AA:NN", &idx); | |
19223 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19224 | |
2f8cc0e5 DA |
19225 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19226 | direct, style); | |
42f914d4 | 19227 | |
d62a17ae | 19228 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19229 | |
d62a17ae | 19230 | if (ret < 0) { |
19231 | /* Display error string. */ | |
19232 | community_list_perror(vty, ret); | |
19233 | return CMD_WARNING_CONFIG_FAILED; | |
19234 | } | |
42f914d4 | 19235 | |
d62a17ae | 19236 | return CMD_SUCCESS; |
718e3744 | 19237 | } |
19238 | ||
7336e101 SP |
19239 | DEFUN (no_community_list_standard_all, |
19240 | no_bgp_community_list_standard_all_cmd, | |
a2099c1d | 19241 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19242 | NO_STR |
19243 | BGP_STR | |
19244 | COMMUNITY_LIST_STR | |
19245 | "Community list number (standard)\n" | |
19246 | "Add an standard community-list entry\n" | |
19247 | "Community list name\n" | |
2f8cc0e5 DA |
19248 | "Sequence number of an entry\n" |
19249 | "Sequence number\n" | |
7336e101 SP |
19250 | "Specify community to reject\n" |
19251 | "Specify community to accept\n" | |
19252 | COMMUNITY_VAL_STR) | |
718e3744 | 19253 | { |
d62a17ae | 19254 | char *cl_name_or_number = NULL; |
174b5cb9 | 19255 | char *str = NULL; |
d62a17ae | 19256 | int direct = 0; |
19257 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 19258 | char *seq = NULL; |
d62a17ae | 19259 | int idx = 0; |
7336e101 | 19260 | |
a08032fe | 19261 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19262 | if (idx) |
19263 | seq = argv[idx]->arg; | |
19264 | ||
19265 | idx = 0; | |
174b5cb9 DA |
19266 | argv_find(argv, argc, "permit", &idx); |
19267 | argv_find(argv, argc, "deny", &idx); | |
19268 | ||
19269 | if (idx) { | |
19270 | direct = argv_find(argv, argc, "permit", &idx) | |
19271 | ? COMMUNITY_PERMIT | |
19272 | : COMMUNITY_DENY; | |
19273 | ||
19274 | idx = 0; | |
19275 | argv_find(argv, argc, "AA:NN", &idx); | |
19276 | str = argv_concat(argv, argc, idx); | |
19277 | } | |
19278 | ||
19279 | idx = 0; | |
d62a17ae | 19280 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19281 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19282 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 19283 | |
2f8cc0e5 | 19284 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19285 | direct, style); |
42f914d4 | 19286 | |
d62a17ae | 19287 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19288 | |
d62a17ae | 19289 | if (ret < 0) { |
19290 | community_list_perror(vty, ret); | |
19291 | return CMD_WARNING_CONFIG_FAILED; | |
19292 | } | |
42f914d4 | 19293 | |
d62a17ae | 19294 | return CMD_SUCCESS; |
718e3744 | 19295 | } |
7336e101 | 19296 | |
174b5cb9 | 19297 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
a2099c1d | 19298 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", |
174b5cb9 DA |
19299 | NO_STR BGP_STR COMMUNITY_LIST_STR |
19300 | "Community list number (standard)\n" | |
19301 | "Add an standard community-list entry\n" | |
19302 | "Community list name\n") | |
19303 | ||
7336e101 SP |
19304 | /*community-list expanded */ |
19305 | DEFUN (community_list_expanded_all, | |
19306 | bgp_community_list_expanded_all_cmd, | |
a2099c1d | 19307 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19308 | BGP_STR |
19309 | COMMUNITY_LIST_STR | |
718e3744 | 19310 | "Community list number (expanded)\n" |
5bf15956 | 19311 | "Add an expanded community-list entry\n" |
718e3744 | 19312 | "Community list name\n" |
2f8cc0e5 DA |
19313 | "Sequence number of an entry\n" |
19314 | "Sequence number\n" | |
718e3744 | 19315 | "Specify community to reject\n" |
19316 | "Specify community to accept\n" | |
19317 | COMMUNITY_VAL_STR) | |
19318 | { | |
d62a17ae | 19319 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19320 | char *seq = NULL; |
d62a17ae | 19321 | int direct = 0; |
19322 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19323 | int idx = 0; |
7b9a4750 | 19324 | |
a08032fe | 19325 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19326 | if (idx) |
19327 | seq = argv[idx]->arg; | |
19328 | ||
19329 | idx = 0; | |
19330 | ||
d62a17ae | 19331 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19332 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19333 | cl_name_or_number = argv[idx]->arg; |
19334 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19335 | : COMMUNITY_DENY; | |
19336 | argv_find(argv, argc, "AA:NN", &idx); | |
19337 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19338 | |
2f8cc0e5 DA |
19339 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19340 | direct, style); | |
42f914d4 | 19341 | |
d62a17ae | 19342 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19343 | |
d62a17ae | 19344 | if (ret < 0) { |
19345 | /* Display error string. */ | |
19346 | community_list_perror(vty, ret); | |
19347 | return CMD_WARNING_CONFIG_FAILED; | |
19348 | } | |
42f914d4 | 19349 | |
d62a17ae | 19350 | return CMD_SUCCESS; |
718e3744 | 19351 | } |
19352 | ||
7336e101 SP |
19353 | DEFUN (no_community_list_expanded_all, |
19354 | no_bgp_community_list_expanded_all_cmd, | |
a2099c1d | 19355 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19356 | NO_STR |
19357 | BGP_STR | |
19358 | COMMUNITY_LIST_STR | |
19359 | "Community list number (expanded)\n" | |
19360 | "Add an expanded community-list entry\n" | |
19361 | "Community list name\n" | |
2f8cc0e5 DA |
19362 | "Sequence number of an entry\n" |
19363 | "Sequence number\n" | |
7336e101 SP |
19364 | "Specify community to reject\n" |
19365 | "Specify community to accept\n" | |
19366 | COMMUNITY_VAL_STR) | |
718e3744 | 19367 | { |
d62a17ae | 19368 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19369 | char *seq = NULL; |
174b5cb9 | 19370 | char *str = NULL; |
d62a17ae | 19371 | int direct = 0; |
19372 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19373 | int idx = 0; |
174b5cb9 | 19374 | |
a08032fe | 19375 | argv_find(argv, argc, "(0-4294967295)", &idx); |
2f8cc0e5 DA |
19376 | if (idx) |
19377 | seq = argv[idx]->arg; | |
19378 | ||
19379 | idx = 0; | |
174b5cb9 DA |
19380 | argv_find(argv, argc, "permit", &idx); |
19381 | argv_find(argv, argc, "deny", &idx); | |
19382 | ||
19383 | if (idx) { | |
19384 | direct = argv_find(argv, argc, "permit", &idx) | |
19385 | ? COMMUNITY_PERMIT | |
19386 | : COMMUNITY_DENY; | |
19387 | ||
19388 | idx = 0; | |
19389 | argv_find(argv, argc, "AA:NN", &idx); | |
19390 | str = argv_concat(argv, argc, idx); | |
7336e101 | 19391 | } |
174b5cb9 DA |
19392 | |
19393 | idx = 0; | |
d62a17ae | 19394 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19395 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19396 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 19397 | |
2f8cc0e5 | 19398 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19399 | direct, style); |
42f914d4 | 19400 | |
d62a17ae | 19401 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19402 | |
d62a17ae | 19403 | if (ret < 0) { |
19404 | community_list_perror(vty, ret); | |
19405 | return CMD_WARNING_CONFIG_FAILED; | |
19406 | } | |
42f914d4 | 19407 | |
d62a17ae | 19408 | return CMD_SUCCESS; |
718e3744 | 19409 | } |
19410 | ||
36d4bb44 EB |
19411 | ALIAS(no_community_list_expanded_all, |
19412 | no_bgp_community_list_expanded_all_list_cmd, | |
a2099c1d | 19413 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", |
36d4bb44 | 19414 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
19415 | "Community list number (expanded)\n" |
19416 | "Add an expanded community-list entry\n" | |
19417 | "Community list name\n") | |
19418 | ||
8d9b8ed9 PM |
19419 | /* Return configuration string of community-list entry. */ |
19420 | static const char *community_list_config_str(struct community_entry *entry) | |
19421 | { | |
19422 | const char *str; | |
19423 | ||
19424 | if (entry->any) | |
19425 | str = ""; | |
19426 | else { | |
19427 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
19428 | str = community_str(entry->u.com, false); | |
19429 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
19430 | str = lcommunity_str(entry->u.lcom, false); | |
19431 | else | |
19432 | str = entry->config; | |
19433 | } | |
19434 | return str; | |
19435 | } | |
19436 | ||
d62a17ae | 19437 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19438 | { |
d62a17ae | 19439 | struct community_entry *entry; |
718e3744 | 19440 | |
d62a17ae | 19441 | for (entry = list->head; entry; entry = entry->next) { |
19442 | if (entry == list->head) { | |
19443 | if (all_digit(list->name)) | |
19444 | vty_out(vty, "Community %s list %s\n", | |
19445 | entry->style == COMMUNITY_LIST_STANDARD | |
19446 | ? "standard" | |
19447 | : "(expanded) access", | |
19448 | list->name); | |
19449 | else | |
19450 | vty_out(vty, "Named Community %s list %s\n", | |
19451 | entry->style == COMMUNITY_LIST_STANDARD | |
19452 | ? "standard" | |
19453 | : "expanded", | |
19454 | list->name); | |
19455 | } | |
19456 | if (entry->any) | |
19457 | vty_out(vty, " %s\n", | |
19458 | community_direct_str(entry->direct)); | |
19459 | else | |
19460 | vty_out(vty, " %s %s\n", | |
19461 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19462 | community_list_config_str(entry)); |
d62a17ae | 19463 | } |
718e3744 | 19464 | } |
19465 | ||
7336e101 SP |
19466 | DEFUN (show_community_list, |
19467 | show_bgp_community_list_cmd, | |
19468 | "show bgp community-list", | |
718e3744 | 19469 | SHOW_STR |
7336e101 | 19470 | BGP_STR |
718e3744 | 19471 | "List community-list\n") |
19472 | { | |
d62a17ae | 19473 | struct community_list *list; |
19474 | struct community_list_master *cm; | |
718e3744 | 19475 | |
d62a17ae | 19476 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19477 | if (!cm) | |
19478 | return CMD_SUCCESS; | |
718e3744 | 19479 | |
d62a17ae | 19480 | for (list = cm->num.head; list; list = list->next) |
19481 | community_list_show(vty, list); | |
718e3744 | 19482 | |
d62a17ae | 19483 | for (list = cm->str.head; list; list = list->next) |
19484 | community_list_show(vty, list); | |
718e3744 | 19485 | |
d62a17ae | 19486 | return CMD_SUCCESS; |
718e3744 | 19487 | } |
19488 | ||
7336e101 SP |
19489 | DEFUN (show_community_list_arg, |
19490 | show_bgp_community_list_arg_cmd, | |
a2099c1d | 19491 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", |
7336e101 SP |
19492 | SHOW_STR |
19493 | BGP_STR | |
718e3744 | 19494 | "List community-list\n" |
19495 | "Community-list number\n" | |
960b69b9 | 19496 | "Community-list name\n" |
19497 | "Detailed information on community-list\n") | |
718e3744 | 19498 | { |
d62a17ae | 19499 | int idx_comm_list = 3; |
19500 | struct community_list *list; | |
718e3744 | 19501 | |
e237b0d2 | 19502 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19503 | COMMUNITY_LIST_MASTER); |
19504 | if (!list) { | |
19505 | vty_out(vty, "%% Can't find community-list\n"); | |
19506 | return CMD_WARNING; | |
19507 | } | |
718e3744 | 19508 | |
d62a17ae | 19509 | community_list_show(vty, list); |
718e3744 | 19510 | |
d62a17ae | 19511 | return CMD_SUCCESS; |
718e3744 | 19512 | } |
6b0655a2 | 19513 | |
57d187bc JS |
19514 | /* |
19515 | * Large Community code. | |
19516 | */ | |
d62a17ae | 19517 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19518 | struct cmd_token **argv, int style, | |
19519 | int reject_all_digit_name) | |
19520 | { | |
19521 | int ret; | |
19522 | int direct; | |
19523 | char *str; | |
19524 | int idx = 0; | |
19525 | char *cl_name; | |
2f8cc0e5 DA |
19526 | char *seq = NULL; |
19527 | ||
a08032fe | 19528 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19529 | seq = argv[idx]->arg; |
d62a17ae | 19530 | |
2f8cc0e5 | 19531 | idx = 0; |
d62a17ae | 19532 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19533 | : COMMUNITY_DENY; | |
19534 | ||
19535 | /* All digit name check. */ | |
19536 | idx = 0; | |
a2099c1d | 19537 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19538 | argv_find(argv, argc, "(1-99)", &idx); |
19539 | argv_find(argv, argc, "(100-500)", &idx); | |
19540 | cl_name = argv[idx]->arg; | |
19541 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19542 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19543 | return CMD_WARNING_CONFIG_FAILED; | |
19544 | } | |
19545 | ||
19546 | idx = 0; | |
19547 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19548 | argv_find(argv, argc, "LINE", &idx); | |
19549 | /* Concat community string argument. */ | |
19550 | if (idx) | |
19551 | str = argv_concat(argv, argc, idx); | |
19552 | else | |
19553 | str = NULL; | |
19554 | ||
2f8cc0e5 | 19555 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19556 | |
19557 | /* Free temporary community list string allocated by | |
19558 | argv_concat(). */ | |
0a22ddfb | 19559 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19560 | |
19561 | if (ret < 0) { | |
19562 | community_list_perror(vty, ret); | |
19563 | return CMD_WARNING_CONFIG_FAILED; | |
19564 | } | |
19565 | return CMD_SUCCESS; | |
19566 | } | |
19567 | ||
19568 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19569 | struct cmd_token **argv, int style) | |
19570 | { | |
19571 | int ret; | |
19572 | int direct = 0; | |
19573 | char *str = NULL; | |
19574 | int idx = 0; | |
2f8cc0e5 | 19575 | char *seq = NULL; |
d62a17ae | 19576 | |
a08032fe | 19577 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19578 | seq = argv[idx]->arg; |
d62a17ae | 19579 | |
2f8cc0e5 | 19580 | idx = 0; |
d62a17ae | 19581 | argv_find(argv, argc, "permit", &idx); |
19582 | argv_find(argv, argc, "deny", &idx); | |
19583 | ||
19584 | if (idx) { | |
19585 | /* Check the list direct. */ | |
19586 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19587 | direct = COMMUNITY_PERMIT; | |
19588 | else | |
19589 | direct = COMMUNITY_DENY; | |
19590 | ||
19591 | idx = 0; | |
19592 | argv_find(argv, argc, "LINE", &idx); | |
19593 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19594 | /* Concat community string argument. */ | |
19595 | str = argv_concat(argv, argc, idx); | |
19596 | } | |
19597 | ||
19598 | idx = 0; | |
19599 | argv_find(argv, argc, "(1-99)", &idx); | |
19600 | argv_find(argv, argc, "(100-500)", &idx); | |
a2099c1d | 19601 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19602 | |
19603 | /* Unset community list. */ | |
2f8cc0e5 | 19604 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19605 | style); |
19606 | ||
19607 | /* Free temporary community list string allocated by | |
19608 | argv_concat(). */ | |
0a22ddfb | 19609 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19610 | |
19611 | if (ret < 0) { | |
19612 | community_list_perror(vty, ret); | |
19613 | return CMD_WARNING_CONFIG_FAILED; | |
19614 | } | |
19615 | ||
19616 | return CMD_SUCCESS; | |
57d187bc JS |
19617 | } |
19618 | ||
19619 | /* "large-community-list" keyword help string. */ | |
19620 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19621 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19622 | ||
7336e101 SP |
19623 | DEFUN (lcommunity_list_standard, |
19624 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19625 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19626 | BGP_STR |
19627 | LCOMMUNITY_LIST_STR | |
19628 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19629 | "Sequence number of an entry\n" |
19630 | "Sequence number\n" | |
7336e101 SP |
19631 | "Specify large community to reject\n" |
19632 | "Specify large community to accept\n" | |
19633 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19634 | { |
d62a17ae | 19635 | return lcommunity_list_set_vty(vty, argc, argv, |
19636 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19637 | } |
19638 | ||
7336e101 SP |
19639 | DEFUN (lcommunity_list_expanded, |
19640 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19641 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19642 | BGP_STR |
19643 | LCOMMUNITY_LIST_STR | |
19644 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19645 | "Sequence number of an entry\n" |
19646 | "Sequence number\n" | |
7336e101 SP |
19647 | "Specify large community to reject\n" |
19648 | "Specify large community to accept\n" | |
19649 | "An ordered list as a regular-expression\n") | |
57d187bc | 19650 | { |
d62a17ae | 19651 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19652 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19653 | } |
19654 | ||
7336e101 SP |
19655 | DEFUN (lcommunity_list_name_standard, |
19656 | bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 19657 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19658 | BGP_STR |
19659 | LCOMMUNITY_LIST_STR | |
19660 | "Specify standard large-community-list\n" | |
19661 | "Large Community list name\n" | |
2f8cc0e5 DA |
19662 | "Sequence number of an entry\n" |
19663 | "Sequence number\n" | |
7336e101 SP |
19664 | "Specify large community to reject\n" |
19665 | "Specify large community to accept\n" | |
19666 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19667 | { |
d62a17ae | 19668 | return lcommunity_list_set_vty(vty, argc, argv, |
19669 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19670 | } |
19671 | ||
7336e101 SP |
19672 | DEFUN (lcommunity_list_name_expanded, |
19673 | bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 19674 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19675 | BGP_STR |
19676 | LCOMMUNITY_LIST_STR | |
19677 | "Specify expanded large-community-list\n" | |
19678 | "Large Community list name\n" | |
2f8cc0e5 DA |
19679 | "Sequence number of an entry\n" |
19680 | "Sequence number\n" | |
7336e101 SP |
19681 | "Specify large community to reject\n" |
19682 | "Specify large community to accept\n" | |
19683 | "An ordered list as a regular-expression\n") | |
57d187bc | 19684 | { |
d62a17ae | 19685 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19686 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19687 | } |
19688 | ||
4378f57c DA |
19689 | DEFUN (no_lcommunity_list_all, |
19690 | no_bgp_lcommunity_list_all_cmd, | |
a2099c1d | 19691 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", |
7336e101 SP |
19692 | NO_STR |
19693 | BGP_STR | |
19694 | LCOMMUNITY_LIST_STR | |
19695 | "Large Community list number (standard)\n" | |
19696 | "Large Community list number (expanded)\n" | |
19697 | "Large Community list name\n") | |
57d187bc | 19698 | { |
7336e101 SP |
19699 | return lcommunity_list_unset_vty(vty, argc, argv, |
19700 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19701 | } |
19702 | ||
4378f57c DA |
19703 | DEFUN (no_lcommunity_list_name_standard_all, |
19704 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
a2099c1d | 19705 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", |
4378f57c DA |
19706 | NO_STR |
19707 | BGP_STR | |
19708 | LCOMMUNITY_LIST_STR | |
19709 | "Specify standard large-community-list\n" | |
19710 | "Large Community list name\n") | |
19711 | { | |
19712 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19713 | LARGE_COMMUNITY_LIST_STANDARD); | |
19714 | } | |
19715 | ||
7336e101 SP |
19716 | DEFUN (no_lcommunity_list_name_expanded_all, |
19717 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
a2099c1d | 19718 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", |
7336e101 SP |
19719 | NO_STR |
19720 | BGP_STR | |
19721 | LCOMMUNITY_LIST_STR | |
19722 | "Specify expanded large-community-list\n" | |
19723 | "Large Community list name\n") | |
57d187bc | 19724 | { |
d62a17ae | 19725 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19726 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19727 | } |
19728 | ||
7336e101 SP |
19729 | DEFUN (no_lcommunity_list_standard, |
19730 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19731 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19732 | NO_STR |
19733 | BGP_STR | |
19734 | LCOMMUNITY_LIST_STR | |
19735 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19736 | "Sequence number of an entry\n" |
19737 | "Sequence number\n" | |
7336e101 SP |
19738 | "Specify large community to reject\n" |
19739 | "Specify large community to accept\n" | |
19740 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19741 | { |
d62a17ae | 19742 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19743 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19744 | } |
19745 | ||
7336e101 SP |
19746 | DEFUN (no_lcommunity_list_expanded, |
19747 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19748 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19749 | NO_STR |
19750 | BGP_STR | |
19751 | LCOMMUNITY_LIST_STR | |
19752 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19753 | "Sequence number of an entry\n" |
19754 | "Sequence number\n" | |
7336e101 SP |
19755 | "Specify large community to reject\n" |
19756 | "Specify large community to accept\n" | |
19757 | "An ordered list as a regular-expression\n") | |
57d187bc | 19758 | { |
d62a17ae | 19759 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19760 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19761 | } |
19762 | ||
7336e101 SP |
19763 | DEFUN (no_lcommunity_list_name_standard, |
19764 | no_bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 19765 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19766 | NO_STR |
19767 | BGP_STR | |
19768 | LCOMMUNITY_LIST_STR | |
19769 | "Specify standard large-community-list\n" | |
19770 | "Large Community list name\n" | |
2f8cc0e5 DA |
19771 | "Sequence number of an entry\n" |
19772 | "Sequence number\n" | |
7336e101 SP |
19773 | "Specify large community to reject\n" |
19774 | "Specify large community to accept\n" | |
19775 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19776 | { |
d62a17ae | 19777 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19778 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19779 | } |
19780 | ||
7336e101 SP |
19781 | DEFUN (no_lcommunity_list_name_expanded, |
19782 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 19783 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19784 | NO_STR |
19785 | BGP_STR | |
19786 | LCOMMUNITY_LIST_STR | |
19787 | "Specify expanded large-community-list\n" | |
19788 | "Large community list name\n" | |
2f8cc0e5 DA |
19789 | "Sequence number of an entry\n" |
19790 | "Sequence number\n" | |
7336e101 SP |
19791 | "Specify large community to reject\n" |
19792 | "Specify large community to accept\n" | |
19793 | "An ordered list as a regular-expression\n") | |
57d187bc | 19794 | { |
d62a17ae | 19795 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19796 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19797 | } |
19798 | ||
d62a17ae | 19799 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19800 | { | |
19801 | struct community_entry *entry; | |
19802 | ||
19803 | for (entry = list->head; entry; entry = entry->next) { | |
19804 | if (entry == list->head) { | |
19805 | if (all_digit(list->name)) | |
19806 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19807 | entry->style == |
19808 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19809 | ? "standard" |
19810 | : "(expanded) access", | |
19811 | list->name); | |
19812 | else | |
19813 | vty_out(vty, | |
19814 | "Named large community %s list %s\n", | |
169b72c8 | 19815 | entry->style == |
19816 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19817 | ? "standard" |
19818 | : "expanded", | |
19819 | list->name); | |
19820 | } | |
19821 | if (entry->any) | |
19822 | vty_out(vty, " %s\n", | |
19823 | community_direct_str(entry->direct)); | |
19824 | else | |
19825 | vty_out(vty, " %s %s\n", | |
19826 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19827 | community_list_config_str(entry)); |
d62a17ae | 19828 | } |
57d187bc JS |
19829 | } |
19830 | ||
7336e101 SP |
19831 | DEFUN (show_lcommunity_list, |
19832 | show_bgp_lcommunity_list_cmd, | |
19833 | "show bgp large-community-list", | |
57d187bc | 19834 | SHOW_STR |
7336e101 | 19835 | BGP_STR |
57d187bc JS |
19836 | "List large-community list\n") |
19837 | { | |
d62a17ae | 19838 | struct community_list *list; |
19839 | struct community_list_master *cm; | |
57d187bc | 19840 | |
d62a17ae | 19841 | cm = community_list_master_lookup(bgp_clist, |
19842 | LARGE_COMMUNITY_LIST_MASTER); | |
19843 | if (!cm) | |
19844 | return CMD_SUCCESS; | |
57d187bc | 19845 | |
d62a17ae | 19846 | for (list = cm->num.head; list; list = list->next) |
19847 | lcommunity_list_show(vty, list); | |
57d187bc | 19848 | |
d62a17ae | 19849 | for (list = cm->str.head; list; list = list->next) |
19850 | lcommunity_list_show(vty, list); | |
57d187bc | 19851 | |
d62a17ae | 19852 | return CMD_SUCCESS; |
57d187bc JS |
19853 | } |
19854 | ||
7336e101 SP |
19855 | DEFUN (show_lcommunity_list_arg, |
19856 | show_bgp_lcommunity_list_arg_cmd, | |
a2099c1d | 19857 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
19858 | SHOW_STR |
19859 | BGP_STR | |
57d187bc | 19860 | "List large-community list\n" |
960b69b9 | 19861 | "Large-community-list number\n" |
19862 | "Large-community-list name\n" | |
19863 | "Detailed information on large-community-list\n") | |
57d187bc | 19864 | { |
d62a17ae | 19865 | struct community_list *list; |
57d187bc | 19866 | |
e237b0d2 | 19867 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19868 | LARGE_COMMUNITY_LIST_MASTER); |
19869 | if (!list) { | |
960b69b9 | 19870 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19871 | return CMD_WARNING; |
19872 | } | |
57d187bc | 19873 | |
d62a17ae | 19874 | lcommunity_list_show(vty, list); |
57d187bc | 19875 | |
d62a17ae | 19876 | return CMD_SUCCESS; |
57d187bc JS |
19877 | } |
19878 | ||
718e3744 | 19879 | /* "extcommunity-list" keyword help string. */ |
19880 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19881 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19882 | ||
7336e101 SP |
19883 | DEFUN (extcommunity_list_standard, |
19884 | bgp_extcommunity_list_standard_cmd, | |
a2099c1d | 19885 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19886 | BGP_STR |
718e3744 | 19887 | EXTCOMMUNITY_LIST_STR |
19888 | "Extended Community list number (standard)\n" | |
718e3744 | 19889 | "Specify standard extcommunity-list\n" |
5bf15956 | 19890 | "Community list name\n" |
2f8cc0e5 DA |
19891 | "Sequence number of an entry\n" |
19892 | "Sequence number\n" | |
718e3744 | 19893 | "Specify community to reject\n" |
19894 | "Specify community to accept\n" | |
19895 | EXTCOMMUNITY_VAL_STR) | |
19896 | { | |
d62a17ae | 19897 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19898 | int direct = 0; | |
19899 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19900 | char *seq = NULL; |
42f914d4 | 19901 | |
d62a17ae | 19902 | int idx = 0; |
7b9a4750 | 19903 | |
d62a17ae | 19904 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19905 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19906 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 19907 | |
a08032fe | 19908 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19909 | seq = argv[idx]->arg; |
19910 | ||
d62a17ae | 19911 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19912 | : COMMUNITY_DENY; | |
19913 | argv_find(argv, argc, "AA:NN", &idx); | |
19914 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19915 | |
2f8cc0e5 | 19916 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19917 | direct, style); |
42f914d4 | 19918 | |
d62a17ae | 19919 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19920 | |
d62a17ae | 19921 | if (ret < 0) { |
19922 | community_list_perror(vty, ret); | |
19923 | return CMD_WARNING_CONFIG_FAILED; | |
19924 | } | |
42f914d4 | 19925 | |
d62a17ae | 19926 | return CMD_SUCCESS; |
718e3744 | 19927 | } |
19928 | ||
7336e101 SP |
19929 | DEFUN (extcommunity_list_name_expanded, |
19930 | bgp_extcommunity_list_name_expanded_cmd, | |
a2099c1d | 19931 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19932 | BGP_STR |
19933 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 19934 | "Extended Community list number (expanded)\n" |
718e3744 | 19935 | "Specify expanded extcommunity-list\n" |
19936 | "Extended Community list name\n" | |
2f8cc0e5 DA |
19937 | "Sequence number of an entry\n" |
19938 | "Sequence number\n" | |
718e3744 | 19939 | "Specify community to reject\n" |
19940 | "Specify community to accept\n" | |
19941 | "An ordered list as a regular-expression\n") | |
19942 | { | |
d62a17ae | 19943 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
19944 | int direct = 0; | |
19945 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19946 | char *seq = NULL; |
d62a17ae | 19947 | int idx = 0; |
7336e101 | 19948 | |
d62a17ae | 19949 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19950 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19951 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 19952 | |
a08032fe | 19953 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19954 | seq = argv[idx]->arg; |
19955 | ||
d62a17ae | 19956 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19957 | : COMMUNITY_DENY; | |
19958 | argv_find(argv, argc, "LINE", &idx); | |
19959 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19960 | |
2f8cc0e5 | 19961 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 19962 | direct, style); |
42f914d4 | 19963 | |
d62a17ae | 19964 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19965 | |
d62a17ae | 19966 | if (ret < 0) { |
19967 | community_list_perror(vty, ret); | |
19968 | return CMD_WARNING_CONFIG_FAILED; | |
19969 | } | |
42f914d4 | 19970 | |
d62a17ae | 19971 | return CMD_SUCCESS; |
718e3744 | 19972 | } |
19973 | ||
7336e101 SP |
19974 | DEFUN (no_extcommunity_list_standard_all, |
19975 | no_bgp_extcommunity_list_standard_all_cmd, | |
a2099c1d | 19976 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19977 | NO_STR |
19978 | BGP_STR | |
19979 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 19980 | "Extended Community list number (standard)\n" |
718e3744 | 19981 | "Specify standard extcommunity-list\n" |
5bf15956 | 19982 | "Community list name\n" |
2f8cc0e5 DA |
19983 | "Sequence number of an entry\n" |
19984 | "Sequence number\n" | |
718e3744 | 19985 | "Specify community to reject\n" |
19986 | "Specify community to accept\n" | |
19987 | EXTCOMMUNITY_VAL_STR) | |
19988 | { | |
d62a17ae | 19989 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19990 | int direct = 0; | |
19991 | char *cl_number_or_name = NULL; | |
d4455c89 | 19992 | char *str = NULL; |
2f8cc0e5 | 19993 | char *seq = NULL; |
d62a17ae | 19994 | int idx = 0; |
d4455c89 | 19995 | |
a08032fe | 19996 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19997 | seq = argv[idx]->arg; |
19998 | ||
19999 | idx = 0; | |
d4455c89 DA |
20000 | argv_find(argv, argc, "permit", &idx); |
20001 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
20002 | if (idx) { |
20003 | direct = argv_find(argv, argc, "permit", &idx) | |
20004 | ? COMMUNITY_PERMIT | |
20005 | : COMMUNITY_DENY; | |
20006 | ||
20007 | idx = 0; | |
20008 | argv_find(argv, argc, "AA:NN", &idx); | |
20009 | str = argv_concat(argv, argc, idx); | |
20010 | } | |
20011 | ||
20012 | idx = 0; | |
d62a17ae | 20013 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20014 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20015 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 20016 | |
d62a17ae | 20017 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20018 | seq, direct, style); |
42f914d4 | 20019 | |
d62a17ae | 20020 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20021 | |
d62a17ae | 20022 | if (ret < 0) { |
20023 | community_list_perror(vty, ret); | |
20024 | return CMD_WARNING_CONFIG_FAILED; | |
20025 | } | |
42f914d4 | 20026 | |
d62a17ae | 20027 | return CMD_SUCCESS; |
718e3744 | 20028 | } |
20029 | ||
d4455c89 DA |
20030 | ALIAS(no_extcommunity_list_standard_all, |
20031 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
a2099c1d | 20032 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 20033 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20034 | "Extended Community list number (standard)\n" |
20035 | "Specify standard extcommunity-list\n" | |
20036 | "Community list name\n") | |
20037 | ||
7336e101 SP |
20038 | DEFUN (no_extcommunity_list_expanded_all, |
20039 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a2099c1d | 20040 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20041 | NO_STR |
20042 | BGP_STR | |
20043 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 20044 | "Extended Community list number (expanded)\n" |
718e3744 | 20045 | "Specify expanded extcommunity-list\n" |
5bf15956 | 20046 | "Extended Community list name\n" |
2f8cc0e5 DA |
20047 | "Sequence number of an entry\n" |
20048 | "Sequence number\n" | |
718e3744 | 20049 | "Specify community to reject\n" |
20050 | "Specify community to accept\n" | |
20051 | "An ordered list as a regular-expression\n") | |
20052 | { | |
d62a17ae | 20053 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20054 | int direct = 0; | |
20055 | char *cl_number_or_name = NULL; | |
d4455c89 | 20056 | char *str = NULL; |
2f8cc0e5 | 20057 | char *seq = NULL; |
d62a17ae | 20058 | int idx = 0; |
d4455c89 | 20059 | |
a08032fe | 20060 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20061 | seq = argv[idx]->arg; |
20062 | ||
20063 | idx = 0; | |
d4455c89 DA |
20064 | argv_find(argv, argc, "permit", &idx); |
20065 | argv_find(argv, argc, "deny", &idx); | |
20066 | ||
20067 | if (idx) { | |
20068 | direct = argv_find(argv, argc, "permit", &idx) | |
20069 | ? COMMUNITY_PERMIT | |
20070 | : COMMUNITY_DENY; | |
20071 | ||
20072 | idx = 0; | |
20073 | argv_find(argv, argc, "LINE", &idx); | |
20074 | str = argv_concat(argv, argc, idx); | |
20075 | } | |
20076 | ||
20077 | idx = 0; | |
d62a17ae | 20078 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20079 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20080 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 20081 | |
d62a17ae | 20082 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20083 | seq, direct, style); |
42f914d4 | 20084 | |
d62a17ae | 20085 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20086 | |
d62a17ae | 20087 | if (ret < 0) { |
20088 | community_list_perror(vty, ret); | |
20089 | return CMD_WARNING_CONFIG_FAILED; | |
20090 | } | |
42f914d4 | 20091 | |
d62a17ae | 20092 | return CMD_SUCCESS; |
718e3744 | 20093 | } |
20094 | ||
d4455c89 DA |
20095 | ALIAS(no_extcommunity_list_expanded_all, |
20096 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
a2099c1d | 20097 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 20098 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20099 | "Extended Community list number (expanded)\n" |
20100 | "Specify expanded extcommunity-list\n" | |
20101 | "Extended Community list name\n") | |
20102 | ||
d62a17ae | 20103 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20104 | { |
d62a17ae | 20105 | struct community_entry *entry; |
718e3744 | 20106 | |
d62a17ae | 20107 | for (entry = list->head; entry; entry = entry->next) { |
20108 | if (entry == list->head) { | |
20109 | if (all_digit(list->name)) | |
20110 | vty_out(vty, "Extended community %s list %s\n", | |
20111 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20112 | ? "standard" | |
20113 | : "(expanded) access", | |
20114 | list->name); | |
20115 | else | |
20116 | vty_out(vty, | |
20117 | "Named extended community %s list %s\n", | |
20118 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20119 | ? "standard" | |
20120 | : "expanded", | |
20121 | list->name); | |
20122 | } | |
20123 | if (entry->any) | |
20124 | vty_out(vty, " %s\n", | |
20125 | community_direct_str(entry->direct)); | |
20126 | else | |
20127 | vty_out(vty, " %s %s\n", | |
20128 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20129 | community_list_config_str(entry)); |
d62a17ae | 20130 | } |
718e3744 | 20131 | } |
20132 | ||
7336e101 SP |
20133 | DEFUN (show_extcommunity_list, |
20134 | show_bgp_extcommunity_list_cmd, | |
20135 | "show bgp extcommunity-list", | |
718e3744 | 20136 | SHOW_STR |
7336e101 | 20137 | BGP_STR |
718e3744 | 20138 | "List extended-community list\n") |
20139 | { | |
d62a17ae | 20140 | struct community_list *list; |
20141 | struct community_list_master *cm; | |
718e3744 | 20142 | |
d62a17ae | 20143 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
20144 | if (!cm) | |
20145 | return CMD_SUCCESS; | |
718e3744 | 20146 | |
d62a17ae | 20147 | for (list = cm->num.head; list; list = list->next) |
20148 | extcommunity_list_show(vty, list); | |
718e3744 | 20149 | |
d62a17ae | 20150 | for (list = cm->str.head; list; list = list->next) |
20151 | extcommunity_list_show(vty, list); | |
718e3744 | 20152 | |
d62a17ae | 20153 | return CMD_SUCCESS; |
718e3744 | 20154 | } |
20155 | ||
7336e101 SP |
20156 | DEFUN (show_extcommunity_list_arg, |
20157 | show_bgp_extcommunity_list_arg_cmd, | |
a2099c1d | 20158 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20159 | SHOW_STR |
20160 | BGP_STR | |
718e3744 | 20161 | "List extended-community list\n" |
20162 | "Extcommunity-list number\n" | |
960b69b9 | 20163 | "Extcommunity-list name\n" |
20164 | "Detailed information on extcommunity-list\n") | |
718e3744 | 20165 | { |
d62a17ae | 20166 | int idx_comm_list = 3; |
20167 | struct community_list *list; | |
718e3744 | 20168 | |
e237b0d2 | 20169 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20170 | EXTCOMMUNITY_LIST_MASTER); |
20171 | if (!list) { | |
20172 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
20173 | return CMD_WARNING; | |
20174 | } | |
718e3744 | 20175 | |
d62a17ae | 20176 | extcommunity_list_show(vty, list); |
718e3744 | 20177 | |
d62a17ae | 20178 | return CMD_SUCCESS; |
718e3744 | 20179 | } |
6b0655a2 | 20180 | |
718e3744 | 20181 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 20182 | static int community_list_config_write(struct vty *vty) |
20183 | { | |
20184 | struct community_list *list; | |
20185 | struct community_entry *entry; | |
20186 | struct community_list_master *cm; | |
20187 | int write = 0; | |
20188 | ||
20189 | /* Community-list. */ | |
20190 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
20191 | ||
20192 | for (list = cm->num.head; list; list = list->next) | |
20193 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20194 | vty_out(vty, |
20195 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
20196 | list->name, entry->seq, | |
d62a17ae | 20197 | community_direct_str(entry->direct), |
20198 | community_list_config_str(entry)); | |
20199 | write++; | |
20200 | } | |
20201 | for (list = cm->str.head; list; list = list->next) | |
20202 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20203 | vty_out(vty, |
20204 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 20205 | entry->style == COMMUNITY_LIST_STANDARD |
20206 | ? "standard" | |
20207 | : "expanded", | |
2f8cc0e5 DA |
20208 | list->name, entry->seq, |
20209 | community_direct_str(entry->direct), | |
d62a17ae | 20210 | community_list_config_str(entry)); |
20211 | write++; | |
20212 | } | |
20213 | ||
20214 | /* Extcommunity-list. */ | |
20215 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20216 | ||
20217 | for (list = cm->num.head; list; list = list->next) | |
20218 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20219 | vty_out(vty, |
20220 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
20221 | list->name, entry->seq, | |
20222 | community_direct_str(entry->direct), | |
d62a17ae | 20223 | community_list_config_str(entry)); |
20224 | write++; | |
20225 | } | |
20226 | for (list = cm->str.head; list; list = list->next) | |
20227 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20228 | vty_out(vty, |
6cde4b45 | 20229 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 20230 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
20231 | ? "standard" | |
20232 | : "expanded", | |
2f8cc0e5 DA |
20233 | list->name, entry->seq, |
20234 | community_direct_str(entry->direct), | |
d62a17ae | 20235 | community_list_config_str(entry)); |
20236 | write++; | |
20237 | } | |
20238 | ||
20239 | ||
20240 | /* lcommunity-list. */ | |
20241 | cm = community_list_master_lookup(bgp_clist, | |
20242 | LARGE_COMMUNITY_LIST_MASTER); | |
20243 | ||
20244 | for (list = cm->num.head; list; list = list->next) | |
20245 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20246 | vty_out(vty, |
6cde4b45 | 20247 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
20248 | list->name, entry->seq, |
20249 | community_direct_str(entry->direct), | |
d62a17ae | 20250 | community_list_config_str(entry)); |
20251 | write++; | |
20252 | } | |
20253 | for (list = cm->str.head; list; list = list->next) | |
20254 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20255 | vty_out(vty, |
6cde4b45 | 20256 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 20257 | |
d62a17ae | 20258 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
20259 | ? "standard" | |
20260 | : "expanded", | |
2f8cc0e5 | 20261 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 20262 | community_list_config_str(entry)); |
20263 | write++; | |
20264 | } | |
20265 | ||
20266 | return write; | |
20267 | } | |
20268 | ||
612c2c15 | 20269 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 20270 | static struct cmd_node community_list_node = { |
f4b8291f | 20271 | .name = "community list", |
62b346ee DL |
20272 | .node = COMMUNITY_LIST_NODE, |
20273 | .prompt = "", | |
612c2c15 | 20274 | .config_write = community_list_config_write, |
718e3744 | 20275 | }; |
20276 | ||
d62a17ae | 20277 | static void community_list_vty(void) |
20278 | { | |
612c2c15 | 20279 | install_node(&community_list_node); |
d62a17ae | 20280 | |
20281 | /* Community-list. */ | |
7336e101 SP |
20282 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
20283 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20284 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 20285 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 20286 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 20287 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
20288 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
20289 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 20290 | |
20291 | /* Extcommunity-list. */ | |
7336e101 SP |
20292 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
20293 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20294 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
20295 | install_element(CONFIG_NODE, |
20296 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 20297 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
20298 | install_element(CONFIG_NODE, |
20299 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
20300 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
20301 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 20302 | |
20303 | /* Large Community List */ | |
7336e101 | 20304 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
20305 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
20306 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 20307 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
20308 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
20309 | install_element(CONFIG_NODE, | |
20310 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
20311 | install_element(CONFIG_NODE, |
20312 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20313 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20314 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20315 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20316 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20317 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20318 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
20319 | |
20320 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 20321 | } |
ed0e57e3 DA |
20322 | |
20323 | static struct cmd_node community_alias_node = { | |
20324 | .name = "community alias", | |
20325 | .node = COMMUNITY_ALIAS_NODE, | |
20326 | .prompt = "", | |
20327 | .config_write = bgp_community_alias_write, | |
20328 | }; | |
20329 | ||
20330 | void community_alias_vty(void) | |
20331 | { | |
20332 | install_node(&community_alias_node); | |
20333 | ||
20334 | /* Community-list. */ | |
20335 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
20336 | |
20337 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 20338 | } |