]>
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" |
4cd690ae | 56 | #include "bgpd/bgp_nht.h" |
4bf6a362 | 57 | #include "bgpd/bgp_nexthop.h" |
4122b697 | 58 | #include "bgpd/bgp_network.h" |
718e3744 | 59 | #include "bgpd/bgp_open.h" |
4bf6a362 | 60 | #include "bgpd/bgp_regex.h" |
718e3744 | 61 | #include "bgpd/bgp_route.h" |
c016b6c7 | 62 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 63 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 64 | #include "bgpd/bgp_table.h" |
94f2b392 | 65 | #include "bgpd/bgp_vty.h" |
165b5fff | 66 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 67 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 68 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 69 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 70 | #include "bgpd/bgp_io.h" |
94c2f693 | 71 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 72 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 73 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 74 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 75 | #include "bgpd/bgp_mac.h" |
dd65f45e | 76 | #include "bgpd/bgp_flowspec.h" |
389e4f92 | 77 | #include "bgpd/bgp_conditional_adv.h" |
49e5a4a0 | 78 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
79 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
80 | #endif | |
81 | ||
5d5393b9 | 82 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
83 | { |
84 | .val_bool = false, | |
85 | .match_profile = "traditional", | |
86 | .match_version = "< 7.4", | |
87 | }, | |
88 | { .val_bool = true }, | |
67b0f40c | 89 | ); |
5d5393b9 | 90 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
91 | { .val_bool = true, .match_profile = "datacenter", }, |
92 | { .val_bool = false }, | |
67b0f40c | 93 | ); |
aef999a2 DA |
94 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
95 | { .val_bool = true, .match_profile = "datacenter", }, | |
96 | { .val_bool = false }, | |
67b0f40c | 97 | ); |
5d5393b9 | 98 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
99 | { .val_bool = true, .match_profile = "datacenter", }, |
100 | { .val_bool = false }, | |
67b0f40c | 101 | ); |
5d5393b9 | 102 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
103 | { .val_bool = true, .match_profile = "datacenter", }, |
104 | { .val_bool = false }, | |
67b0f40c | 105 | ); |
5d5393b9 DL |
106 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
107 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
108 | { .val_ulong = 120 }, | |
67b0f40c | 109 | ); |
5d5393b9 DL |
110 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
111 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
112 | { .val_ulong = 180 }, | |
67b0f40c | 113 | ); |
5d5393b9 DL |
114 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
115 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
116 | { .val_ulong = 60 }, | |
67b0f40c | 117 | ); |
1d3fdccf DA |
118 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
119 | { .val_bool = false, .match_profile = "datacenter", }, | |
120 | { .val_bool = false, .match_version = "< 7.4", }, | |
121 | { .val_bool = true }, | |
67b0f40c | 122 | ); |
2adac256 DA |
123 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
124 | { .val_bool = false, .match_version = "< 7.6", }, | |
125 | { .val_bool = true }, | |
67b0f40c | 126 | ); |
f2ca5c5b DA |
127 | FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION, |
128 | { .val_bool = false, .match_version = "< 8.3", }, | |
129 | { .val_bool = true }, | |
130 | ); | |
1ae314be DA |
131 | FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET, |
132 | { .val_bool = false, .match_version = "< 8.3", }, | |
133 | { .val_bool = true }, | |
134 | ); | |
5d5393b9 | 135 | |
dd65f45e DL |
136 | DEFINE_HOOK(bgp_inst_config_write, |
137 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
138 | (bgp, vty)); |
139 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
1ca2fd11 | 140 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); |
718e3744 | 141 | |
d62a17ae | 142 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
143 | struct prefix *range, int exact); | |
144 | ||
055679e9 | 145 | /* Show BGP peer's information. */ |
146 | enum show_type { | |
147 | show_all, | |
148 | show_peer, | |
149 | show_ipv4_all, | |
150 | show_ipv6_all, | |
151 | show_ipv4_peer, | |
152 | show_ipv6_peer | |
153 | }; | |
154 | ||
36235319 QY |
155 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
156 | struct prefix *range, int exact); | |
2986cac2 | 157 | |
36235319 | 158 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
403e64f8 | 159 | struct bgp *bgp); |
2986cac2 | 160 | |
36235319 QY |
161 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
162 | enum show_type type, | |
163 | const char *ip_str, | |
164 | afi_t afi, bool use_json); | |
2986cac2 | 165 | |
d62a17ae | 166 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
167 | { | |
168 | switch (afi) { | |
169 | case AFI_IP: | |
170 | switch (safi) { | |
171 | case SAFI_UNICAST: | |
172 | return BGP_IPV4_NODE; | |
d62a17ae | 173 | case SAFI_MULTICAST: |
174 | return BGP_IPV4M_NODE; | |
d62a17ae | 175 | case SAFI_LABELED_UNICAST: |
176 | return BGP_IPV4L_NODE; | |
d62a17ae | 177 | case SAFI_MPLS_VPN: |
178 | return BGP_VPNV4_NODE; | |
7c40bf39 | 179 | case SAFI_FLOWSPEC: |
180 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
181 | default: |
182 | /* not expected */ | |
183 | return BGP_IPV4_NODE; | |
d62a17ae | 184 | } |
d62a17ae | 185 | case AFI_IP6: |
186 | switch (safi) { | |
187 | case SAFI_UNICAST: | |
188 | return BGP_IPV6_NODE; | |
d62a17ae | 189 | case SAFI_MULTICAST: |
190 | return BGP_IPV6M_NODE; | |
d62a17ae | 191 | case SAFI_LABELED_UNICAST: |
192 | return BGP_IPV6L_NODE; | |
d62a17ae | 193 | case SAFI_MPLS_VPN: |
194 | return BGP_VPNV6_NODE; | |
7c40bf39 | 195 | case SAFI_FLOWSPEC: |
196 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
197 | default: |
198 | /* not expected */ | |
199 | return BGP_IPV4_NODE; | |
d62a17ae | 200 | } |
d62a17ae | 201 | case AFI_L2VPN: |
202 | return BGP_EVPN_NODE; | |
b26f891d | 203 | case AFI_UNSPEC: |
d62a17ae | 204 | case AFI_MAX: |
205 | // We should never be here but to clarify the switch statement.. | |
206 | return BGP_IPV4_NODE; | |
d62a17ae | 207 | } |
208 | ||
209 | // Impossible to happen | |
210 | return BGP_IPV4_NODE; | |
f51bae9c | 211 | } |
20eb8864 | 212 | |
5cb5f4d0 DD |
213 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
214 | { | |
7d0d37de DS |
215 | if (afi == AFI_IP) { |
216 | if (safi == SAFI_UNICAST) | |
217 | return "IPv4 Unicast"; | |
218 | if (safi == SAFI_MULTICAST) | |
219 | return "IPv4 Multicast"; | |
220 | if (safi == SAFI_LABELED_UNICAST) | |
221 | return "IPv4 Labeled Unicast"; | |
222 | if (safi == SAFI_MPLS_VPN) | |
223 | return "IPv4 VPN"; | |
224 | if (safi == SAFI_ENCAP) | |
225 | return "IPv4 Encap"; | |
226 | if (safi == SAFI_FLOWSPEC) | |
227 | return "IPv4 Flowspec"; | |
228 | } else if (afi == AFI_IP6) { | |
229 | if (safi == SAFI_UNICAST) | |
230 | return "IPv6 Unicast"; | |
231 | if (safi == SAFI_MULTICAST) | |
232 | return "IPv6 Multicast"; | |
233 | if (safi == SAFI_LABELED_UNICAST) | |
234 | return "IPv6 Labeled Unicast"; | |
235 | if (safi == SAFI_MPLS_VPN) | |
236 | return "IPv6 VPN"; | |
237 | if (safi == SAFI_ENCAP) | |
238 | return "IPv6 Encap"; | |
239 | if (safi == SAFI_FLOWSPEC) | |
240 | return "IPv6 Flowspec"; | |
241 | } else if (afi == AFI_L2VPN) { | |
242 | if (safi == SAFI_EVPN) | |
243 | return "L2VPN EVPN"; | |
244 | } | |
245 | ||
246 | return "Unknown"; | |
5cb5f4d0 DD |
247 | } |
248 | ||
249 | /* | |
250 | * Please note that we have intentionally camelCased | |
251 | * the return strings here. So if you want | |
252 | * to use this function, please ensure you | |
253 | * are doing this within json output | |
254 | */ | |
255 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
256 | { | |
7d0d37de DS |
257 | if (afi == AFI_IP) { |
258 | if (safi == SAFI_UNICAST) | |
259 | return "ipv4Unicast"; | |
260 | if (safi == SAFI_MULTICAST) | |
261 | return "ipv4Multicast"; | |
262 | if (safi == SAFI_LABELED_UNICAST) | |
263 | return "ipv4LabeledUnicast"; | |
264 | if (safi == SAFI_MPLS_VPN) | |
265 | return "ipv4Vpn"; | |
266 | if (safi == SAFI_ENCAP) | |
267 | return "ipv4Encap"; | |
268 | if (safi == SAFI_FLOWSPEC) | |
269 | return "ipv4Flowspec"; | |
270 | } else if (afi == AFI_IP6) { | |
271 | if (safi == SAFI_UNICAST) | |
272 | return "ipv6Unicast"; | |
273 | if (safi == SAFI_MULTICAST) | |
274 | return "ipv6Multicast"; | |
275 | if (safi == SAFI_LABELED_UNICAST) | |
276 | return "ipv6LabeledUnicast"; | |
277 | if (safi == SAFI_MPLS_VPN) | |
278 | return "ipv6Vpn"; | |
279 | if (safi == SAFI_ENCAP) | |
280 | return "ipv6Encap"; | |
281 | if (safi == SAFI_FLOWSPEC) | |
282 | return "ipv6Flowspec"; | |
283 | } else if (afi == AFI_L2VPN) { | |
284 | if (safi == SAFI_EVPN) | |
285 | return "l2VpnEvpn"; | |
286 | } | |
287 | ||
288 | return "Unknown"; | |
5cb5f4d0 DD |
289 | } |
290 | ||
0249b8b6 HS |
291 | /* unset srv6 locator */ |
292 | static int bgp_srv6_locator_unset(struct bgp *bgp) | |
293 | { | |
294 | int ret; | |
295 | struct listnode *node, *nnode; | |
efae8c26 | 296 | struct srv6_locator_chunk *chunk; |
0249b8b6 HS |
297 | struct bgp_srv6_function *func; |
298 | struct bgp *bgp_vrf; | |
0249b8b6 HS |
299 | |
300 | /* release chunk notification via ZAPI */ | |
301 | ret = bgp_zebra_srv6_manager_release_locator_chunk( | |
302 | bgp->srv6_locator_name); | |
303 | if (ret < 0) | |
304 | return -1; | |
305 | ||
306 | /* refresh chunks */ | |
03852f67 | 307 | for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) { |
0249b8b6 | 308 | listnode_delete(bgp->srv6_locator_chunks, chunk); |
69467313 | 309 | srv6_locator_chunk_free(&chunk); |
03852f67 | 310 | } |
0249b8b6 HS |
311 | |
312 | /* refresh functions */ | |
bda15542 | 313 | for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) { |
0249b8b6 | 314 | listnode_delete(bgp->srv6_functions, func); |
bda15542 CS |
315 | XFREE(MTYPE_BGP_SRV6_FUNCTION, func); |
316 | } | |
0249b8b6 HS |
317 | |
318 | /* refresh tovpn_sid */ | |
319 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
320 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
321 | continue; | |
322 | ||
323 | /* refresh vpnv4 tovpn_sid */ | |
944909f4 CS |
324 | XFREE(MTYPE_BGP_SRV6_SID, |
325 | bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); | |
0249b8b6 HS |
326 | |
327 | /* refresh vpnv6 tovpn_sid */ | |
944909f4 CS |
328 | XFREE(MTYPE_BGP_SRV6_SID, |
329 | bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid); | |
527588aa CS |
330 | |
331 | /* refresh per-vrf tovpn_sid */ | |
332 | XFREE(MTYPE_BGP_SRV6_SID, bgp_vrf->tovpn_sid); | |
0249b8b6 HS |
333 | } |
334 | ||
335 | /* update vpn bgp processes */ | |
336 | vpn_leak_postchange_all(); | |
337 | ||
f8e9c702 CS |
338 | /* refresh tovpn_sid_locator */ |
339 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
340 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
341 | continue; | |
342 | ||
343 | /* refresh vpnv4 tovpn_sid_locator */ | |
efae8c26 CS |
344 | srv6_locator_chunk_free( |
345 | &bgp_vrf->vpn_policy[AFI_IP].tovpn_sid_locator); | |
f8e9c702 CS |
346 | |
347 | /* refresh vpnv6 tovpn_sid_locator */ | |
efae8c26 CS |
348 | srv6_locator_chunk_free( |
349 | &bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid_locator); | |
527588aa CS |
350 | |
351 | /* refresh per-vrf tovpn_sid_locator */ | |
69467313 | 352 | srv6_locator_chunk_free(&bgp_vrf->tovpn_sid_locator); |
f8e9c702 CS |
353 | } |
354 | ||
0249b8b6 HS |
355 | /* clear locator name */ |
356 | memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name)); | |
357 | ||
358 | return 0; | |
359 | } | |
360 | ||
718e3744 | 361 | /* Utility function to get address family from current node. */ |
d62a17ae | 362 | afi_t bgp_node_afi(struct vty *vty) |
363 | { | |
364 | afi_t afi; | |
365 | switch (vty->node) { | |
366 | case BGP_IPV6_NODE: | |
367 | case BGP_IPV6M_NODE: | |
368 | case BGP_IPV6L_NODE: | |
369 | case BGP_VPNV6_NODE: | |
7c40bf39 | 370 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 371 | afi = AFI_IP6; |
372 | break; | |
373 | case BGP_EVPN_NODE: | |
374 | afi = AFI_L2VPN; | |
375 | break; | |
376 | default: | |
377 | afi = AFI_IP; | |
378 | break; | |
379 | } | |
380 | return afi; | |
718e3744 | 381 | } |
382 | ||
383 | /* Utility function to get subsequent address family from current | |
384 | node. */ | |
d62a17ae | 385 | safi_t bgp_node_safi(struct vty *vty) |
386 | { | |
387 | safi_t safi; | |
388 | switch (vty->node) { | |
389 | case BGP_VPNV4_NODE: | |
390 | case BGP_VPNV6_NODE: | |
391 | safi = SAFI_MPLS_VPN; | |
392 | break; | |
393 | case BGP_IPV4M_NODE: | |
394 | case BGP_IPV6M_NODE: | |
395 | safi = SAFI_MULTICAST; | |
396 | break; | |
397 | case BGP_EVPN_NODE: | |
398 | safi = SAFI_EVPN; | |
399 | break; | |
400 | case BGP_IPV4L_NODE: | |
401 | case BGP_IPV6L_NODE: | |
402 | safi = SAFI_LABELED_UNICAST; | |
403 | break; | |
7c40bf39 | 404 | case BGP_FLOWSPECV4_NODE: |
405 | case BGP_FLOWSPECV6_NODE: | |
406 | safi = SAFI_FLOWSPEC; | |
407 | break; | |
d62a17ae | 408 | default: |
409 | safi = SAFI_UNICAST; | |
410 | break; | |
411 | } | |
412 | return safi; | |
718e3744 | 413 | } |
414 | ||
55f91488 QY |
415 | /** |
416 | * Converts an AFI in string form to afi_t | |
417 | * | |
418 | * @param afi string, one of | |
419 | * - "ipv4" | |
420 | * - "ipv6" | |
81cf0de5 | 421 | * - "l2vpn" |
55f91488 QY |
422 | * @return the corresponding afi_t |
423 | */ | |
d62a17ae | 424 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
425 | { | |
426 | afi_t afi = AFI_MAX; /* unknown */ | |
427 | if (strmatch(afi_str, "ipv4")) | |
428 | afi = AFI_IP; | |
429 | else if (strmatch(afi_str, "ipv6")) | |
430 | afi = AFI_IP6; | |
81cf0de5 CS |
431 | else if (strmatch(afi_str, "l2vpn")) |
432 | afi = AFI_L2VPN; | |
d62a17ae | 433 | return afi; |
434 | } | |
435 | ||
436 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
437 | afi_t *afi) | |
438 | { | |
439 | int ret = 0; | |
440 | if (argv_find(argv, argc, "ipv4", index)) { | |
441 | ret = 1; | |
442 | if (afi) | |
443 | *afi = AFI_IP; | |
444 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
445 | ret = 1; | |
446 | if (afi) | |
447 | *afi = AFI_IP6; | |
8688b3e7 DS |
448 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
449 | ret = 1; | |
450 | if (afi) | |
451 | *afi = AFI_L2VPN; | |
d62a17ae | 452 | } |
453 | return ret; | |
46f296b4 LB |
454 | } |
455 | ||
375a2e67 | 456 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 457 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
458 | { | |
459 | safi_t safi = SAFI_MAX; /* unknown */ | |
460 | if (strmatch(safi_str, "multicast")) | |
461 | safi = SAFI_MULTICAST; | |
462 | else if (strmatch(safi_str, "unicast")) | |
463 | safi = SAFI_UNICAST; | |
464 | else if (strmatch(safi_str, "vpn")) | |
465 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
466 | else if (strmatch(safi_str, "evpn")) |
467 | safi = SAFI_EVPN; | |
d62a17ae | 468 | else if (strmatch(safi_str, "labeled-unicast")) |
469 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 470 | else if (strmatch(safi_str, "flowspec")) |
471 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 472 | return safi; |
473 | } | |
474 | ||
475 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
476 | safi_t *safi) | |
477 | { | |
478 | int ret = 0; | |
479 | if (argv_find(argv, argc, "unicast", index)) { | |
480 | ret = 1; | |
481 | if (safi) | |
482 | *safi = SAFI_UNICAST; | |
483 | } else if (argv_find(argv, argc, "multicast", index)) { | |
484 | ret = 1; | |
485 | if (safi) | |
486 | *safi = SAFI_MULTICAST; | |
487 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
488 | ret = 1; | |
489 | if (safi) | |
490 | *safi = SAFI_LABELED_UNICAST; | |
491 | } else if (argv_find(argv, argc, "vpn", index)) { | |
492 | ret = 1; | |
493 | if (safi) | |
494 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
495 | } else if (argv_find(argv, argc, "evpn", index)) { |
496 | ret = 1; | |
497 | if (safi) | |
498 | *safi = SAFI_EVPN; | |
7c40bf39 | 499 | } else if (argv_find(argv, argc, "flowspec", index)) { |
500 | ret = 1; | |
501 | if (safi) | |
502 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 503 | } |
504 | return ret; | |
46f296b4 LB |
505 | } |
506 | ||
b16bcbba TA |
507 | /* |
508 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
509 | * | |
510 | * afi | |
511 | * address-family identifier | |
512 | * | |
513 | * safi | |
514 | * subsequent address-family identifier | |
515 | * | |
516 | * Returns: | |
517 | * default_af string corresponding to the supplied afi/safi pair. | |
518 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
519 | * return -1. | |
520 | */ | |
521 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
522 | { | |
523 | switch (afi) { | |
524 | case AFI_IP: | |
525 | switch (safi) { | |
526 | case SAFI_UNICAST: | |
527 | return "ipv4-unicast"; | |
528 | case SAFI_MULTICAST: | |
529 | return "ipv4-multicast"; | |
530 | case SAFI_MPLS_VPN: | |
531 | return "ipv4-vpn"; | |
532 | case SAFI_ENCAP: | |
533 | return "ipv4-encap"; | |
534 | case SAFI_LABELED_UNICAST: | |
535 | return "ipv4-labeled-unicast"; | |
536 | case SAFI_FLOWSPEC: | |
537 | return "ipv4-flowspec"; | |
538 | default: | |
539 | return "unknown-afi/safi"; | |
540 | } | |
541 | break; | |
542 | case AFI_IP6: | |
543 | switch (safi) { | |
544 | case SAFI_UNICAST: | |
545 | return "ipv6-unicast"; | |
546 | case SAFI_MULTICAST: | |
547 | return "ipv6-multicast"; | |
548 | case SAFI_MPLS_VPN: | |
549 | return "ipv6-vpn"; | |
550 | case SAFI_ENCAP: | |
551 | return "ipv6-encap"; | |
552 | case SAFI_LABELED_UNICAST: | |
553 | return "ipv6-labeled-unicast"; | |
554 | case SAFI_FLOWSPEC: | |
555 | return "ipv6-flowspec"; | |
556 | default: | |
557 | return "unknown-afi/safi"; | |
558 | } | |
559 | break; | |
560 | case AFI_L2VPN: | |
561 | switch (safi) { | |
562 | case SAFI_EVPN: | |
563 | return "l2vpn-evpn"; | |
564 | default: | |
565 | return "unknown-afi/safi"; | |
566 | } | |
567 | case AFI_UNSPEC: | |
568 | case AFI_MAX: | |
569 | return "unknown-afi/safi"; | |
570 | } | |
571 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
572 | return "unknown-afi/safi"; | |
573 | } | |
574 | ||
5d5393b9 DL |
575 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
576 | enum bgp_instance_type inst_type) | |
577 | { | |
578 | int ret = bgp_get(bgp, as, name, inst_type); | |
579 | ||
580 | if (ret == BGP_CREATED) { | |
581 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 582 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
583 | |
584 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 585 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 586 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 587 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
588 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
589 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 590 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 591 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 592 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 593 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
594 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
595 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
596 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
597 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
f2ca5c5b DA |
598 | if (DFLT_BGP_GRACEFUL_NOTIFICATION) |
599 | SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
1ae314be DA |
600 | if (DFLT_BGP_HARD_ADMIN_RESET) |
601 | SET_FLAG((*bgp)->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
5d5393b9 DL |
602 | |
603 | ret = BGP_SUCCESS; | |
604 | } | |
605 | return ret; | |
606 | } | |
607 | ||
7eeee51e | 608 | /* |
f212a857 | 609 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 610 | * |
f212a857 DS |
611 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
612 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
613 | * to appropriate values for the calling function. This is to allow the |
614 | * calling function to make decisions appropriate for the show command | |
615 | * that is being parsed. | |
616 | * | |
617 | * The show commands are generally of the form: | |
d62a17ae | 618 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
619 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
620 | * |
621 | * Since we use argv_find if the show command in particular doesn't have: | |
622 | * [ip] | |
18c57037 | 623 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 624 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
625 | * The command parsing should still be ok. |
626 | * | |
627 | * vty -> The vty for the command so we can output some useful data in | |
628 | * the event of a parse error in the vrf. | |
629 | * argv -> The command tokens | |
630 | * argc -> How many command tokens we have | |
d62a17ae | 631 | * idx -> The current place in the command, generally should be 0 for this |
632 | * function | |
7eeee51e DS |
633 | * afi -> The parsed afi if it was included in the show command, returned here |
634 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 635 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 636 | * use_json -> json is configured or not |
7eeee51e DS |
637 | * |
638 | * The function returns the correct location in the parse tree for the | |
639 | * last token found. | |
0e37c258 DS |
640 | * |
641 | * Returns 0 for failure to parse correctly, else the idx position of where | |
642 | * it found the last token. | |
7eeee51e | 643 | */ |
d62a17ae | 644 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
645 | struct cmd_token **argv, int argc, | |
646 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 647 | struct bgp **bgp, bool use_json) |
d62a17ae | 648 | { |
649 | char *vrf_name = NULL; | |
650 | ||
651 | assert(afi); | |
652 | assert(safi); | |
653 | assert(bgp); | |
654 | ||
655 | if (argv_find(argv, argc, "ip", idx)) | |
656 | *afi = AFI_IP; | |
657 | ||
9a8bdf1c | 658 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 659 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
660 | else if (argv_find(argv, argc, "vrf", idx)) { |
661 | vrf_name = argv[*idx + 1]->arg; | |
662 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
663 | vrf_name = NULL; | |
664 | } | |
665 | if (vrf_name) { | |
d62a17ae | 666 | if (strmatch(vrf_name, "all")) |
667 | *bgp = NULL; | |
668 | else { | |
669 | *bgp = bgp_lookup_by_name(vrf_name); | |
670 | if (!*bgp) { | |
52e5b8c4 SP |
671 | if (use_json) { |
672 | json_object *json = NULL; | |
673 | json = json_object_new_object(); | |
674 | json_object_string_add( | |
675 | json, "warning", | |
676 | "View/Vrf is unknown"); | |
75eeda93 | 677 | vty_json(vty, json); |
52e5b8c4 | 678 | } |
ca61fd25 DS |
679 | else |
680 | vty_out(vty, "View/Vrf %s is unknown\n", | |
681 | vrf_name); | |
d62a17ae | 682 | *idx = 0; |
683 | return 0; | |
684 | } | |
685 | } | |
686 | } else { | |
687 | *bgp = bgp_get_default(); | |
688 | if (!*bgp) { | |
52e5b8c4 SP |
689 | if (use_json) { |
690 | json_object *json = NULL; | |
691 | json = json_object_new_object(); | |
692 | json_object_string_add( | |
693 | json, "warning", | |
694 | "Default BGP instance not found"); | |
75eeda93 | 695 | vty_json(vty, json); |
52e5b8c4 | 696 | } |
ca61fd25 DS |
697 | else |
698 | vty_out(vty, | |
699 | "Default BGP instance not found\n"); | |
d62a17ae | 700 | *idx = 0; |
701 | return 0; | |
702 | } | |
703 | } | |
704 | ||
705 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
706 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
707 | ||
708 | *idx += 1; | |
709 | return *idx; | |
710 | } | |
711 | ||
28c6e247 | 712 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 713 | { |
714 | struct interface *ifp = NULL; | |
4122b697 DA |
715 | struct listnode *node; |
716 | struct bgp_listener *listener; | |
717 | union sockunion all_su; | |
d62a17ae | 718 | |
4122b697 | 719 | if (su->sa.sa_family == AF_INET) { |
3d2a2725 | 720 | (void)str2sockunion("0.0.0.0", &all_su); |
d62a17ae | 721 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); |
4122b697 | 722 | } else if (su->sa.sa_family == AF_INET6) { |
3d2a2725 | 723 | (void)str2sockunion("::", &all_su); |
d62a17ae | 724 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, |
725 | su->sin6.sin6_scope_id, | |
726 | bgp->vrf_id); | |
4122b697 | 727 | } |
d62a17ae | 728 | |
4122b697 DA |
729 | if (ifp) { |
730 | for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) { | |
731 | if (sockunion_family(su) != | |
732 | sockunion_family(&listener->su)) | |
733 | continue; | |
734 | ||
735 | /* If 0.0.0.0/:: is a listener, then treat as self and | |
736 | * reject. | |
737 | */ | |
738 | if (!sockunion_cmp(&listener->su, su) || | |
739 | !sockunion_cmp(&listener->su, &all_su)) | |
740 | return true; | |
741 | } | |
742 | } | |
d62a17ae | 743 | |
3dc339cd | 744 | return false; |
718e3744 | 745 | } |
746 | ||
28c6e247 IR |
747 | /* Utility function for looking up peer from VTY. */ |
748 | /* This is used only for configuration, so disallow if attempted on | |
749 | * a dynamic neighbor. | |
750 | */ | |
751 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
752 | { | |
753 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
754 | int ret; | |
755 | union sockunion su; | |
756 | struct peer *peer; | |
757 | ||
758 | if (!bgp) { | |
759 | return NULL; | |
760 | } | |
761 | ||
762 | ret = str2sockunion(ip_str, &su); | |
763 | if (ret < 0) { | |
764 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
765 | if (!peer) { | |
766 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
767 | == NULL) { | |
768 | vty_out(vty, | |
769 | "%% Malformed address or name: %s\n", | |
770 | ip_str); | |
771 | return NULL; | |
772 | } | |
773 | } | |
774 | } else { | |
775 | peer = peer_lookup(bgp, &su); | |
776 | if (!peer) { | |
777 | vty_out(vty, | |
778 | "%% Specify remote-as or peer-group commands first\n"); | |
779 | return NULL; | |
780 | } | |
781 | if (peer_dynamic_neighbor(peer)) { | |
782 | vty_out(vty, | |
783 | "%% Operation not allowed on a dynamic neighbor\n"); | |
784 | return NULL; | |
785 | } | |
786 | } | |
787 | return peer; | |
788 | } | |
789 | ||
718e3744 | 790 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
791 | /* This is used only for configuration, so disallow if attempted on |
792 | * a dynamic neighbor. | |
793 | */ | |
d62a17ae | 794 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
795 | { | |
796 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
797 | int ret; | |
798 | union sockunion su; | |
799 | struct peer *peer = NULL; | |
800 | struct peer_group *group = NULL; | |
801 | ||
802 | if (!bgp) { | |
803 | return NULL; | |
804 | } | |
805 | ||
806 | ret = str2sockunion(peer_str, &su); | |
807 | if (ret == 0) { | |
808 | /* IP address, locate peer. */ | |
809 | peer = peer_lookup(bgp, &su); | |
810 | } else { | |
811 | /* Not IP, could match either peer configured on interface or a | |
812 | * group. */ | |
813 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
814 | if (!peer) | |
815 | group = peer_group_lookup(bgp, peer_str); | |
816 | } | |
817 | ||
818 | if (peer) { | |
819 | if (peer_dynamic_neighbor(peer)) { | |
3b56a646 DA |
820 | zlog_warn( |
821 | "%pBP: Operation not allowed on a dynamic neighbor", | |
822 | peer); | |
d62a17ae | 823 | vty_out(vty, |
824 | "%% Operation not allowed on a dynamic neighbor\n"); | |
825 | return NULL; | |
826 | } | |
827 | ||
828 | return peer; | |
829 | } | |
830 | ||
831 | if (group) | |
832 | return group->conf; | |
833 | ||
3b56a646 DA |
834 | zlog_warn("Specify remote-as or peer-group commands first before: %s", |
835 | vty->buf); | |
d62a17ae | 836 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); |
837 | ||
838 | return NULL; | |
839 | } | |
840 | ||
4b7e23e9 | 841 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret) |
d62a17ae | 842 | { |
843 | const char *str = NULL; | |
844 | ||
845 | switch (ret) { | |
4b7e23e9 DS |
846 | case BGP_SUCCESS: |
847 | case BGP_CREATED: | |
848 | case BGP_GR_NO_OPERATION: | |
849 | break; | |
d62a17ae | 850 | case BGP_ERR_INVALID_VALUE: |
851 | str = "Invalid value"; | |
852 | break; | |
853 | case BGP_ERR_INVALID_FLAG: | |
854 | str = "Invalid flag"; | |
855 | break; | |
856 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
857 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
858 | break; | |
859 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
860 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
861 | break; | |
862 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
863 | str = "Specify remote-as or peer-group remote AS first"; | |
864 | break; | |
865 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
866 | str = "Cannot change the peer-group. Deconfigure first"; | |
867 | break; | |
868 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
869 | str = "Peer is not a member of this peer-group"; | |
870 | break; | |
871 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
872 | str = "Prefix/distribute list can not co-exist"; | |
873 | break; | |
874 | case BGP_ERR_NOT_INTERNAL_PEER: | |
875 | str = "Invalid command. Not an internal neighbor"; | |
876 | break; | |
877 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
878 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
879 | break; | |
d62a17ae | 880 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: |
881 | str = "Cannot have local-as same as BGP AS number"; | |
882 | break; | |
883 | case BGP_ERR_TCPSIG_FAILED: | |
884 | str = "Error while applying TCP-Sig to session(s)"; | |
885 | break; | |
886 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
887 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
888 | break; | |
889 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
890 | str = "ttl-security only allowed for EBGP peers"; | |
891 | break; | |
892 | case BGP_ERR_AS_OVERRIDE: | |
893 | str = "as-override cannot be configured for IBGP peers"; | |
894 | break; | |
895 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
896 | str = "Invalid limit for number of dynamic neighbors"; | |
897 | break; | |
898 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
899 | str = "Dynamic neighbor listen range already exists"; | |
900 | break; | |
901 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
902 | str = "Operation not allowed on a dynamic neighbor"; | |
903 | break; | |
904 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
905 | str = "Operation not allowed on a directly connected neighbor"; | |
906 | break; | |
907 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 908 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 909 | break; |
910 | case BGP_ERR_GR_INVALID_CMD: | |
911 | str = "The Graceful Restart command used is not valid at this moment."; | |
912 | break; | |
913 | case BGP_ERR_GR_OPERATION_FAILED: | |
914 | str = "The Graceful Restart Operation failed due to an err."; | |
915 | break; | |
6dcea6fe DS |
916 | case BGP_ERR_PEER_GROUP_MEMBER: |
917 | str = "Peer-group member cannot override remote-as of peer-group."; | |
918 | break; | |
919 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
920 | str = "Peer-group members must be all internal or all external."; | |
921 | break; | |
4b7e23e9 DS |
922 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND: |
923 | str = "Range specified cannot be deleted because it is not part of current config."; | |
924 | break; | |
925 | case BGP_ERR_INSTANCE_MISMATCH: | |
926 | str = "Instance specified does not match the current instance."; | |
927 | break; | |
928 | case BGP_ERR_NO_INTERFACE_CONFIG: | |
929 | str = "Interface specified is not being used for interface based peer."; | |
930 | break; | |
931 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
932 | str = "No configuration already specified for soft reconfiguration."; | |
933 | break; | |
934 | case BGP_ERR_AS_MISMATCH: | |
935 | str = "BGP is already running."; | |
936 | break; | |
937 | case BGP_ERR_AF_UNCONFIGURED: | |
938 | str = "AFI/SAFI specified is not currently configured."; | |
939 | break; | |
4b7e23e9 DS |
940 | case BGP_ERR_INVALID_AS: |
941 | str = "Confederation AS specified is the same AS as our AS."; | |
942 | break; | |
d864dd9e EB |
943 | case BGP_ERR_INVALID_ROLE_NAME: |
944 | str = "Invalid role name"; | |
945 | break; | |
946 | case BGP_ERR_INVALID_INTERNAL_ROLE: | |
8f2d6021 | 947 | str = "External roles can be set only on eBGP session"; |
d864dd9e | 948 | break; |
d62a17ae | 949 | } |
950 | if (str) { | |
951 | vty_out(vty, "%% %s\n", str); | |
952 | return CMD_WARNING_CONFIG_FAILED; | |
953 | } | |
954 | return CMD_SUCCESS; | |
718e3744 | 955 | } |
956 | ||
7aafcaca | 957 | /* BGP clear sort. */ |
d62a17ae | 958 | enum clear_sort { |
959 | clear_all, | |
960 | clear_peer, | |
961 | clear_group, | |
962 | clear_external, | |
963 | clear_as | |
7aafcaca DS |
964 | }; |
965 | ||
1ca2fd11 IR |
966 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
967 | safi_t safi, int error) | |
d62a17ae | 968 | { |
969 | switch (error) { | |
970 | case BGP_ERR_AF_UNCONFIGURED: | |
a486300b PG |
971 | if (vty) |
972 | vty_out(vty, | |
973 | "%% BGP: Enable %s address family for the neighbor %s\n", | |
974 | get_afi_safi_str(afi, safi, false), peer->host); | |
975 | else | |
976 | zlog_warn( | |
1af6e82b | 977 | "%% BGP: Enable %s address family for the neighbor %s", |
a486300b | 978 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 979 | break; |
980 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
a486300b PG |
981 | if (vty) |
982 | vty_out(vty, | |
983 | "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
984 | peer->host); | |
985 | else | |
986 | zlog_warn( | |
1af6e82b | 987 | "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig", |
a486300b | 988 | peer->host); |
d62a17ae | 989 | break; |
990 | default: | |
991 | break; | |
992 | } | |
7aafcaca DS |
993 | } |
994 | ||
dc912615 | 995 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 996 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
997 | { |
998 | int ret = 0; | |
2adac256 | 999 | struct peer_af *paf; |
dc912615 DS |
1000 | |
1001 | /* if afi/.safi not specified, spin thru all of them */ | |
1002 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
1003 | afi_t tmp_afi; | |
1004 | safi_t tmp_safi; | |
0e5cdd59 DS |
1005 | enum bgp_af_index index; |
1006 | ||
1007 | for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { | |
1008 | paf = peer->peer_af_array[index]; | |
1009 | if (!paf) | |
1010 | continue; | |
dc912615 | 1011 | |
2adac256 DA |
1012 | if (paf && paf->subgroup) |
1013 | SET_FLAG(paf->subgroup->sflags, | |
1014 | SUBGRP_STATUS_FORCE_UPDATES); | |
1015 | ||
0e5cdd59 DS |
1016 | tmp_afi = paf->afi; |
1017 | tmp_safi = paf->safi; | |
dc912615 DS |
1018 | if (!peer->afc[tmp_afi][tmp_safi]) |
1019 | continue; | |
1020 | ||
1021 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 1022 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1023 | else |
1024 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
1025 | stype); | |
1026 | } | |
1027 | /* if afi specified and safi not, spin thru safis on this afi */ | |
1028 | } else if (safi == SAFI_UNSPEC) { | |
1029 | safi_t tmp_safi; | |
1030 | ||
1031 | for (tmp_safi = SAFI_UNICAST; | |
1032 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
1033 | if (!peer->afc[afi][tmp_safi]) | |
1034 | continue; | |
1035 | ||
2adac256 DA |
1036 | paf = peer_af_find(peer, afi, tmp_safi); |
1037 | if (paf && paf->subgroup) | |
1038 | SET_FLAG(paf->subgroup->sflags, | |
1039 | SUBGRP_STATUS_FORCE_UPDATES); | |
1040 | ||
dc912615 | 1041 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1042 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1043 | else |
1044 | ret = peer_clear_soft(peer, afi, | |
1045 | tmp_safi, stype); | |
1046 | } | |
1047 | /* both afi/safi specified, let the caller know if not defined */ | |
1048 | } else { | |
1049 | if (!peer->afc[afi][safi]) | |
1050 | return 1; | |
1051 | ||
2adac256 DA |
1052 | paf = peer_af_find(peer, afi, safi); |
1053 | if (paf && paf->subgroup) | |
1054 | SET_FLAG(paf->subgroup->sflags, | |
1055 | SUBGRP_STATUS_FORCE_UPDATES); | |
1056 | ||
dc912615 | 1057 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1058 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1059 | else |
1060 | ret = peer_clear_soft(peer, afi, safi, stype); | |
1061 | } | |
1062 | ||
1063 | return ret; | |
1064 | } | |
1065 | ||
7aafcaca | 1066 | /* `clear ip bgp' functions. */ |
1ca2fd11 | 1067 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 1068 | enum clear_sort sort, enum bgp_clear_type stype, |
1ca2fd11 | 1069 | const char *arg) |
d62a17ae | 1070 | { |
dc912615 | 1071 | int ret = 0; |
3ae8bfa5 | 1072 | bool found = false; |
d62a17ae | 1073 | struct peer *peer; |
dc95985f | 1074 | |
1075 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 1076 | |
1077 | /* Clear all neighbors. */ | |
1078 | /* | |
1079 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
1080 | * nodes on the BGP instance as that may get freed if it is a |
1081 | * doppelganger | |
d62a17ae | 1082 | */ |
1083 | if (sort == clear_all) { | |
1084 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 1085 | |
1086 | bgp_peer_gr_flags_update(peer); | |
1087 | ||
36235319 | 1088 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 1089 | gr_router_detected = true; |
1090 | ||
c368171c | 1091 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 1092 | stype); |
d62a17ae | 1093 | |
1094 | if (ret < 0) | |
1ca2fd11 | 1095 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
dc95985f | 1096 | } |
1097 | ||
36235319 QY |
1098 | if (gr_router_detected |
1099 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1100 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1101 | } else if (!gr_router_detected |
1102 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1103 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 1104 | } |
d62a17ae | 1105 | |
1106 | /* This is to apply read-only mode on this clear. */ | |
1107 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1108 | bgp->update_delay_over = 0; | |
1109 | ||
1110 | return CMD_SUCCESS; | |
7aafcaca DS |
1111 | } |
1112 | ||
3ae8bfa5 | 1113 | /* Clear specified neighbor. */ |
d62a17ae | 1114 | if (sort == clear_peer) { |
1115 | union sockunion su; | |
d62a17ae | 1116 | |
1117 | /* Make sockunion for lookup. */ | |
1118 | ret = str2sockunion(arg, &su); | |
1119 | if (ret < 0) { | |
1120 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1121 | if (!peer) { | |
1122 | peer = peer_lookup_by_hostname(bgp, arg); | |
1123 | if (!peer) { | |
1ca2fd11 IR |
1124 | vty_out(vty, |
1125 | "Malformed address or name: %s\n", | |
d62a17ae | 1126 | arg); |
1127 | return CMD_WARNING; | |
1128 | } | |
1129 | } | |
1130 | } else { | |
1131 | peer = peer_lookup(bgp, &su); | |
1132 | if (!peer) { | |
1ca2fd11 | 1133 | vty_out(vty, |
664b6f18 | 1134 | "%% BGP: Unknown neighbor - \"%s\"\n", |
1ca2fd11 | 1135 | arg); |
d62a17ae | 1136 | return CMD_WARNING; |
1137 | } | |
1138 | } | |
7aafcaca | 1139 | |
dc95985f | 1140 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1141 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1142 | ||
dc912615 DS |
1143 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1144 | ||
1145 | /* if afi/safi not defined for this peer, let caller know */ | |
1146 | if (ret == 1) | |
3ae8bfa5 | 1147 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1148 | |
d62a17ae | 1149 | if (ret < 0) |
1ca2fd11 | 1150 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
7aafcaca | 1151 | |
d62a17ae | 1152 | return CMD_SUCCESS; |
7aafcaca | 1153 | } |
7aafcaca | 1154 | |
3ae8bfa5 | 1155 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1156 | if (sort == clear_group) { |
1157 | struct peer_group *group; | |
7aafcaca | 1158 | |
d62a17ae | 1159 | group = peer_group_lookup(bgp, arg); |
1160 | if (!group) { | |
664b6f18 | 1161 | vty_out(vty, "%% BGP: No such peer-group %s\n", arg); |
d62a17ae | 1162 | return CMD_WARNING; |
1163 | } | |
1164 | ||
1165 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1166 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1167 | |
d62a17ae | 1168 | if (ret < 0) |
1ca2fd11 | 1169 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1170 | else |
1171 | found = true; | |
d62a17ae | 1172 | } |
3ae8bfa5 PM |
1173 | |
1174 | if (!found) | |
1ca2fd11 | 1175 | vty_out(vty, |
664b6f18 | 1176 | "%% BGP: No %s peer belonging to peer-group %s is configured\n", |
5cb5f4d0 | 1177 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1178 | |
d62a17ae | 1179 | return CMD_SUCCESS; |
7aafcaca | 1180 | } |
7aafcaca | 1181 | |
3ae8bfa5 | 1182 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1183 | if (sort == clear_external) { |
1184 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1185 | if (peer->sort == BGP_PEER_IBGP) | |
1186 | continue; | |
7aafcaca | 1187 | |
dc95985f | 1188 | bgp_peer_gr_flags_update(peer); |
1189 | ||
36235319 | 1190 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1191 | gr_router_detected = true; |
dc95985f | 1192 | |
c368171c | 1193 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1194 | |
d62a17ae | 1195 | if (ret < 0) |
1ca2fd11 | 1196 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1197 | else |
1198 | found = true; | |
d62a17ae | 1199 | } |
3ae8bfa5 | 1200 | |
36235319 QY |
1201 | if (gr_router_detected |
1202 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1203 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1204 | } else if (!gr_router_detected |
1205 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1206 | bgp_zebra_send_capabilities(bgp, true); |
1207 | } | |
1208 | ||
3ae8bfa5 | 1209 | if (!found) |
1ca2fd11 | 1210 | vty_out(vty, |
664b6f18 | 1211 | "%% BGP: No external %s peer is configured\n", |
1ca2fd11 | 1212 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 1213 | |
d62a17ae | 1214 | return CMD_SUCCESS; |
1215 | } | |
1216 | ||
3ae8bfa5 | 1217 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1218 | if (sort == clear_as) { |
3ae8bfa5 | 1219 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1220 | |
1221 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1222 | if (peer->as != as) | |
1223 | continue; | |
1224 | ||
dc95985f | 1225 | bgp_peer_gr_flags_update(peer); |
1226 | ||
36235319 | 1227 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1228 | gr_router_detected = true; |
dc95985f | 1229 | |
c368171c | 1230 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1231 | |
1232 | if (ret < 0) | |
1ca2fd11 | 1233 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1234 | else |
1235 | found = true; | |
d62a17ae | 1236 | } |
3ae8bfa5 | 1237 | |
36235319 QY |
1238 | if (gr_router_detected |
1239 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1240 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1241 | } else if (!gr_router_detected |
1242 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1243 | bgp_zebra_send_capabilities(bgp, true); |
1244 | } | |
1245 | ||
3ae8bfa5 | 1246 | if (!found) |
1ca2fd11 | 1247 | vty_out(vty, |
664b6f18 | 1248 | "%% BGP: No %s peer is configured with AS %s\n", |
1ca2fd11 | 1249 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1250 | |
d62a17ae | 1251 | return CMD_SUCCESS; |
1252 | } | |
1253 | ||
1254 | return CMD_SUCCESS; | |
1255 | } | |
1256 | ||
1ca2fd11 IR |
1257 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, |
1258 | safi_t safi, enum clear_sort sort, | |
1259 | enum bgp_clear_type stype, const char *arg) | |
d62a17ae | 1260 | { |
1261 | struct bgp *bgp; | |
1262 | ||
1263 | /* BGP structure lookup. */ | |
1264 | if (name) { | |
1265 | bgp = bgp_lookup_by_name(name); | |
1266 | if (bgp == NULL) { | |
1ca2fd11 | 1267 | vty_out(vty, "Can't find BGP instance %s\n", name); |
d62a17ae | 1268 | return CMD_WARNING; |
1269 | } | |
1270 | } else { | |
1271 | bgp = bgp_get_default(); | |
1272 | if (bgp == NULL) { | |
1ca2fd11 | 1273 | vty_out(vty, "No BGP process is configured\n"); |
d62a17ae | 1274 | return CMD_WARNING; |
1275 | } | |
1276 | } | |
1277 | ||
1ca2fd11 | 1278 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); |
7aafcaca DS |
1279 | } |
1280 | ||
1281 | /* clear soft inbound */ | |
1ca2fd11 | 1282 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1283 | { |
99b3ebd3 NS |
1284 | afi_t afi; |
1285 | safi_t safi; | |
1286 | ||
1ca2fd11 IR |
1287 | FOREACH_AFI_SAFI (afi, safi) |
1288 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1289 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1290 | } |
1291 | ||
1292 | /* clear soft outbound */ | |
1ca2fd11 | 1293 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1294 | { |
99b3ebd3 NS |
1295 | afi_t afi; |
1296 | safi_t safi; | |
1297 | ||
1ca2fd11 IR |
1298 | FOREACH_AFI_SAFI (afi, safi) |
1299 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1300 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1301 | } |
1302 | ||
1303 | ||
a486300b PG |
1304 | void bgp_clear_soft_in(struct bgp *bgp, afi_t afi, safi_t safi) |
1305 | { | |
1306 | bgp_clear(NULL, bgp, afi, safi, clear_all, BGP_CLEAR_SOFT_IN, NULL); | |
1307 | } | |
1308 | ||
4f770cf1 DA |
1309 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
1310 | uint64_t flag, int set) | |
1311 | { | |
1312 | int ret; | |
1313 | struct peer *peer; | |
1314 | ||
1315 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
1316 | if (!peer) | |
1317 | return CMD_WARNING_CONFIG_FAILED; | |
1318 | ||
1319 | /* | |
1320 | * If 'neighbor <interface>', then this is for directly connected peers, | |
1321 | * we should not accept disable-connected-check. | |
1322 | */ | |
1323 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
1324 | vty_out(vty, | |
1325 | "%s is directly connected peer, cannot accept disable-connected-check\n", | |
1326 | ip_str); | |
1327 | return CMD_WARNING_CONFIG_FAILED; | |
1328 | } | |
1329 | ||
1330 | if (!set && flag == PEER_FLAG_SHUTDOWN) | |
1331 | peer_tx_shutdown_message_unset(peer); | |
1332 | ||
1333 | if (set) | |
1334 | ret = peer_flag_set(peer, flag); | |
1335 | else | |
1336 | ret = peer_flag_unset(peer, flag); | |
1337 | ||
1338 | return bgp_vty_return(vty, ret); | |
1339 | } | |
1340 | ||
1341 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint64_t flag) | |
1342 | { | |
1343 | return peer_flag_modify_vty(vty, ip_str, flag, 1); | |
1344 | } | |
1345 | ||
1346 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, | |
1347 | uint64_t flag) | |
1348 | { | |
1349 | return peer_flag_modify_vty(vty, ip_str, flag, 0); | |
1350 | } | |
1351 | ||
2e4c2296 | 1352 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 | 1353 | |
8029b216 AK |
1354 | DEFUN_HIDDEN (bgp_local_mac, |
1355 | bgp_local_mac_cmd, | |
093e3f23 | 1356 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1357 | BGP_STR |
1358 | "Local MAC config\n" | |
1359 | "VxLAN Network Identifier\n" | |
1360 | "VNI number\n" | |
1361 | "local mac\n" | |
1362 | "mac address\n" | |
1363 | "mac-mobility sequence\n" | |
1364 | "seq number\n") | |
1365 | { | |
1366 | int rv; | |
1367 | vni_t vni; | |
1368 | struct ethaddr mac; | |
1369 | struct ipaddr ip; | |
1370 | uint32_t seq; | |
1371 | struct bgp *bgp; | |
1372 | ||
1373 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1374 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1375 | vty_out(vty, "%% Malformed MAC address\n"); | |
1376 | return CMD_WARNING; | |
1377 | } | |
1378 | memset(&ip, 0, sizeof(ip)); | |
1379 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1380 | ||
1381 | bgp = bgp_get_default(); | |
1382 | if (!bgp) { | |
1383 | vty_out(vty, "Default BGP instance is not there\n"); | |
1384 | return CMD_WARNING; | |
1385 | } | |
1386 | ||
b5e140c8 AK |
1387 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1388 | zero_esi); | |
8029b216 AK |
1389 | if (rv < 0) { |
1390 | vty_out(vty, "Internal error\n"); | |
1391 | return CMD_WARNING; | |
1392 | } | |
1393 | ||
1394 | return CMD_SUCCESS; | |
1395 | } | |
1396 | ||
1397 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1398 | no_bgp_local_mac_cmd, | |
093e3f23 | 1399 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1400 | NO_STR |
1401 | BGP_STR | |
1402 | "Local MAC config\n" | |
1403 | "VxLAN Network Identifier\n" | |
1404 | "VNI number\n" | |
1405 | "local mac\n" | |
1406 | "mac address\n") | |
1407 | { | |
1408 | int rv; | |
1409 | vni_t vni; | |
1410 | struct ethaddr mac; | |
1411 | struct ipaddr ip; | |
1412 | struct bgp *bgp; | |
1413 | ||
1414 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1415 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1416 | vty_out(vty, "%% Malformed MAC address\n"); | |
1417 | return CMD_WARNING; | |
1418 | } | |
1419 | memset(&ip, 0, sizeof(ip)); | |
1420 | ||
1421 | bgp = bgp_get_default(); | |
1422 | if (!bgp) { | |
1423 | vty_out(vty, "Default BGP instance is not there\n"); | |
1424 | return CMD_WARNING; | |
1425 | } | |
1426 | ||
ec0ab544 | 1427 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1428 | if (rv < 0) { |
1429 | vty_out(vty, "Internal error\n"); | |
1430 | return CMD_WARNING; | |
1431 | } | |
1432 | ||
1433 | return CMD_SUCCESS; | |
1434 | } | |
1435 | ||
718e3744 | 1436 | DEFUN (no_synchronization, |
1437 | no_synchronization_cmd, | |
1438 | "no synchronization", | |
1439 | NO_STR | |
1440 | "Perform IGP synchronization\n") | |
1441 | { | |
d62a17ae | 1442 | return CMD_SUCCESS; |
718e3744 | 1443 | } |
1444 | ||
1445 | DEFUN (no_auto_summary, | |
1446 | no_auto_summary_cmd, | |
1447 | "no auto-summary", | |
1448 | NO_STR | |
1449 | "Enable automatic network number summarization\n") | |
1450 | { | |
d62a17ae | 1451 | return CMD_SUCCESS; |
718e3744 | 1452 | } |
3d515fd9 | 1453 | |
718e3744 | 1454 | /* "router bgp" commands. */ |
1ca2fd11 IR |
1455 | DEFUN_NOSH (router_bgp, |
1456 | router_bgp_cmd, | |
1457 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1458 | ROUTER_STR | |
1459 | BGP_STR | |
1460 | AS_STR | |
1461 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1462 | { |
d62a17ae | 1463 | int idx_asn = 2; |
1464 | int idx_view_vrf = 3; | |
1465 | int idx_vrf = 4; | |
1ca2fd11 IR |
1466 | int is_new_bgp = 0; |
1467 | int ret; | |
d62a17ae | 1468 | as_t as; |
1469 | struct bgp *bgp; | |
1470 | const char *name = NULL; | |
1471 | enum bgp_instance_type inst_type; | |
1472 | ||
1473 | // "router bgp" without an ASN | |
1474 | if (argc == 2) { | |
1475 | // Pending: Make VRF option available for ASN less config | |
1abef40f | 1476 | bgp = bgp_get_default(); |
d62a17ae | 1477 | |
1abef40f | 1478 | if (bgp == NULL) { |
d62a17ae | 1479 | vty_out(vty, "%% No BGP process is configured\n"); |
1480 | return CMD_WARNING_CONFIG_FAILED; | |
1481 | } | |
1482 | ||
1483 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1484 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1485 | return CMD_WARNING_CONFIG_FAILED; |
1486 | } | |
1487 | } | |
1488 | ||
1489 | // "router bgp X" | |
1490 | else { | |
ff8a8a7a | 1491 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1ca2fd11 | 1492 | |
cc413e2a DA |
1493 | if (as == BGP_PRIVATE_AS_MAX || as == BGP_AS4_MAX) |
1494 | vty_out(vty, "Reserved AS used (%u|%u); AS is %u\n", | |
1495 | BGP_PRIVATE_AS_MAX, BGP_AS4_MAX, as); | |
1496 | ||
d62a17ae | 1497 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1498 | if (argc > 3) { | |
1499 | name = argv[idx_vrf]->arg; | |
1500 | ||
9a8bdf1c PG |
1501 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1502 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1503 | name = NULL; | |
1504 | else | |
1505 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1ca2fd11 | 1506 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
d62a17ae | 1507 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
d62a17ae | 1508 | } |
1509 | ||
1ca2fd11 IR |
1510 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1511 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
3bd70bf8 | 1512 | |
1ca2fd11 IR |
1513 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
1514 | switch (ret) { | |
1515 | case BGP_ERR_AS_MISMATCH: | |
1516 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1517 | return CMD_WARNING_CONFIG_FAILED; | |
1518 | case BGP_ERR_INSTANCE_MISMATCH: | |
1519 | vty_out(vty, | |
1520 | "BGP instance name and AS number mismatch\n"); | |
1521 | vty_out(vty, | |
1522 | "BGP instance is already running; AS is %u\n", | |
1523 | as); | |
1524 | return CMD_WARNING_CONFIG_FAILED; | |
ff8a8a7a | 1525 | } |
1ca2fd11 IR |
1526 | |
1527 | /* | |
1528 | * If we just instantiated the default instance, complete | |
1529 | * any pending VRF-VPN leaking that was configured via | |
1530 | * earlier "router bgp X vrf FOO" blocks. | |
1531 | */ | |
1532 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1533 | vpn_leak_postchange_all(); | |
1534 | ||
1535 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1536 | bgp_vpn_leak_export(bgp); | |
1537 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1538 | */ | |
d62a17ae | 1539 | } |
1540 | ||
1ca2fd11 IR |
1541 | /* unset the auto created flag as the user config is now present */ |
1542 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1543 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1544 | ||
1545 | return CMD_SUCCESS; | |
718e3744 | 1546 | } |
1547 | ||
718e3744 | 1548 | /* "no router bgp" commands. */ |
1ca2fd11 IR |
1549 | DEFUN (no_router_bgp, |
1550 | no_router_bgp_cmd, | |
1551 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1552 | NO_STR | |
1553 | ROUTER_STR | |
1554 | BGP_STR | |
1555 | AS_STR | |
1556 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1557 | { |
4fd9919e | 1558 | int idx_asn = 3; |
d62a17ae | 1559 | int idx_vrf = 5; |
1ca2fd11 | 1560 | as_t as; |
4fd9919e | 1561 | struct bgp *bgp; |
d62a17ae | 1562 | const char *name = NULL; |
718e3744 | 1563 | |
d62a17ae | 1564 | // "no router bgp" without an ASN |
1565 | if (argc == 3) { | |
1566 | // Pending: Make VRF option available for ASN less config | |
8382083a | 1567 | bgp = bgp_get_default(); |
718e3744 | 1568 | |
8382083a | 1569 | if (bgp == NULL) { |
d62a17ae | 1570 | vty_out(vty, "%% No BGP process is configured\n"); |
1571 | return CMD_WARNING_CONFIG_FAILED; | |
1572 | } | |
7fb21a9f | 1573 | |
d62a17ae | 1574 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1575 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1576 | return CMD_WARNING_CONFIG_FAILED; |
1577 | } | |
4fd9919e | 1578 | |
4fd9919e | 1579 | if (bgp->l3vni) { |
be125e6f | 1580 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
4fd9919e IR |
1581 | bgp->l3vni); |
1582 | return CMD_WARNING_CONFIG_FAILED; | |
1583 | } | |
d62a17ae | 1584 | } else { |
4fd9919e IR |
1585 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1586 | ||
1ca42c8d | 1587 | if (argc > 4) { |
d62a17ae | 1588 | name = argv[idx_vrf]->arg; |
1ca42c8d IR |
1589 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") |
1590 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1591 | name = NULL; | |
1592 | } | |
7fb21a9f | 1593 | |
4fd9919e IR |
1594 | /* Lookup bgp structure. */ |
1595 | bgp = bgp_lookup(as, name); | |
1596 | if (!bgp) { | |
1597 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1598 | return CMD_WARNING_CONFIG_FAILED; | |
1599 | } | |
1600 | ||
1601 | if (bgp->l3vni) { | |
1602 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1603 | bgp->l3vni); | |
1604 | return CMD_WARNING_CONFIG_FAILED; | |
1605 | } | |
1606 | ||
1607 | /* Cannot delete default instance if vrf instances exist */ | |
1608 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1609 | struct listnode *node; | |
1610 | struct bgp *tmp_bgp; | |
1611 | ||
1612 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1613 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1614 | continue; | |
1615 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1616 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1617 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1618 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1619 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1620 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1621 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1622 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1623 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1624 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1625 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1626 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1627 | (bgp == bgp_get_evpn() && | |
1628 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1629 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1630 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1631 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1632 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1633 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1634 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1635 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
f33bf7c0 | 1636 | (hashcount(tmp_bgp->vnihash))) { |
4fd9919e IR |
1637 | vty_out(vty, |
1638 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1639 | return CMD_WARNING_CONFIG_FAILED; | |
1640 | } | |
1641 | } | |
1642 | } | |
d62a17ae | 1643 | } |
718e3744 | 1644 | |
1ca2fd11 | 1645 | bgp_delete(bgp); |
718e3744 | 1646 | |
1ca2fd11 | 1647 | return CMD_SUCCESS; |
718e3744 | 1648 | } |
1649 | ||
425bd64b PS |
1650 | /* bgp session-dscp */ |
1651 | ||
1652 | DEFPY (bgp_session_dscp, | |
1653 | bgp_session_dscp_cmd, | |
1654 | "bgp session-dscp (0-63)$dscp", | |
1655 | BGP_STR | |
1656 | "Override default (C6) bgp TCP session DSCP value\n" | |
1657 | "Manually configured dscp parameter\n") | |
1658 | { | |
1659 | bm->tcp_dscp = dscp << 2; | |
1660 | ||
1661 | return CMD_SUCCESS; | |
1662 | } | |
1663 | ||
1664 | DEFPY (no_bgp_session_dscp, | |
1665 | no_bgp_session_dscp_cmd, | |
1666 | "no bgp session-dscp [(0-63)]", | |
1667 | NO_STR | |
1668 | BGP_STR | |
1669 | "Override default (C6) bgp TCP session DSCP value\n" | |
1670 | "Manually configured dscp parameter\n") | |
1671 | { | |
1672 | bm->tcp_dscp = IPTOS_PREC_INTERNETCONTROL; | |
1673 | ||
1674 | return CMD_SUCCESS; | |
1675 | } | |
718e3744 | 1676 | |
ff8a8a7a CS |
1677 | /* BGP router-id. */ |
1678 | ||
1ca2fd11 IR |
1679 | DEFPY (bgp_router_id, |
1680 | bgp_router_id_cmd, | |
1681 | "bgp router-id A.B.C.D", | |
1682 | BGP_STR | |
1683 | "Override configured router identifier\n" | |
1684 | "Manually configured router identifier\n") | |
718e3744 | 1685 | { |
1ca2fd11 IR |
1686 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1687 | bgp_router_id_static_set(bgp, router_id); | |
1688 | return CMD_SUCCESS; | |
ff8a8a7a | 1689 | } |
718e3744 | 1690 | |
1ca2fd11 IR |
1691 | DEFPY (no_bgp_router_id, |
1692 | no_bgp_router_id_cmd, | |
1693 | "no bgp router-id [A.B.C.D]", | |
1694 | NO_STR | |
1695 | BGP_STR | |
1696 | "Override configured router identifier\n" | |
1697 | "Manually configured router identifier\n") | |
ff8a8a7a | 1698 | { |
1ca2fd11 | 1699 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1700 | |
1ca2fd11 IR |
1701 | if (router_id_str) { |
1702 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1703 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1704 | return CMD_WARNING_CONFIG_FAILED; | |
1705 | } | |
1706 | } | |
718e3744 | 1707 | |
1ca2fd11 IR |
1708 | router_id.s_addr = 0; |
1709 | bgp_router_id_static_set(bgp, router_id); | |
1710 | ||
1711 | return CMD_SUCCESS; | |
ff8a8a7a | 1712 | } |
6b0655a2 | 1713 | |
ed0e57e3 | 1714 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
b4ad2fae | 1715 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", |
ed0e57e3 DA |
1716 | NO_STR BGP_STR |
1717 | "Add community specific parameters\n" | |
1718 | "Create an alias for a community\n" | |
1719 | "Community (AA:BB or AA:BB:CC)\n" | |
1720 | "Alias name\n") | |
1721 | { | |
8cfa1e78 | 1722 | struct community_alias ca = {}; |
ed0e57e3 DA |
1723 | struct community_alias *lookup_community; |
1724 | struct community_alias *lookup_alias; | |
d13d137a DA |
1725 | struct community *comm; |
1726 | struct lcommunity *lcomm; | |
1727 | uint8_t invalid = 0; | |
ed0e57e3 | 1728 | |
d13d137a DA |
1729 | comm = community_str2com(community); |
1730 | if (!comm) | |
1731 | invalid++; | |
1732 | community_free(&comm); | |
1733 | ||
1734 | lcomm = lcommunity_str2com(community); | |
1735 | if (!lcomm) | |
1736 | invalid++; | |
1737 | lcommunity_free(&lcomm); | |
1738 | ||
1739 | if (invalid > 1) { | |
ed0e57e3 DA |
1740 | vty_out(vty, "Invalid community format\n"); |
1741 | return CMD_WARNING; | |
1742 | } | |
1743 | ||
8cfa1e78 DA |
1744 | strlcpy(ca.community, community, sizeof(ca.community)); |
1745 | strlcpy(ca.alias, alias_name, sizeof(ca.alias)); | |
ed0e57e3 | 1746 | |
8cfa1e78 DA |
1747 | lookup_community = bgp_ca_community_lookup(&ca); |
1748 | lookup_alias = bgp_ca_alias_lookup(&ca); | |
ed0e57e3 DA |
1749 | |
1750 | if (no) { | |
8cfa1e78 DA |
1751 | bgp_ca_alias_delete(&ca); |
1752 | bgp_ca_community_delete(&ca); | |
ed0e57e3 DA |
1753 | } else { |
1754 | if (lookup_alias) { | |
1755 | /* Lookup if community hash table has an item | |
1756 | * with the same alias name. | |
1757 | */ | |
8cfa1e78 DA |
1758 | strlcpy(ca.community, lookup_alias->community, |
1759 | sizeof(ca.community)); | |
1760 | if (bgp_ca_community_lookup(&ca)) { | |
ed0e57e3 DA |
1761 | vty_out(vty, |
1762 | "community (%s) already has this alias (%s)\n", | |
1763 | lookup_alias->community, | |
1764 | lookup_alias->alias); | |
1765 | return CMD_WARNING; | |
1766 | } | |
8cfa1e78 | 1767 | bgp_ca_alias_delete(&ca); |
ed0e57e3 DA |
1768 | } |
1769 | ||
8cfa1e78 DA |
1770 | if (lookup_community) { |
1771 | /* Lookup if alias hash table has an item | |
1772 | * with the same community. | |
1773 | */ | |
1774 | strlcpy(ca.alias, lookup_community->alias, | |
1775 | sizeof(ca.alias)); | |
1776 | if (bgp_ca_alias_lookup(&ca)) { | |
1777 | vty_out(vty, | |
1778 | "alias (%s) already has this community (%s)\n", | |
1779 | lookup_community->alias, | |
1780 | lookup_community->community); | |
1781 | return CMD_WARNING; | |
1782 | } | |
1783 | bgp_ca_community_delete(&ca); | |
1784 | } | |
ed0e57e3 | 1785 | |
8cfa1e78 DA |
1786 | bgp_ca_alias_insert(&ca); |
1787 | bgp_ca_community_insert(&ca); | |
ed0e57e3 DA |
1788 | } |
1789 | ||
1790 | return CMD_SUCCESS; | |
1791 | } | |
1792 | ||
9acb67cb DS |
1793 | DEFPY (bgp_global_suppress_fib_pending, |
1794 | bgp_global_suppress_fib_pending_cmd, | |
1795 | "[no] bgp suppress-fib-pending", | |
1796 | NO_STR | |
1797 | BGP_STR | |
1798 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1799 | { | |
1800 | bm_wait_for_fib_set(!no); | |
1801 | ||
1802 | return CMD_SUCCESS; | |
1803 | } | |
1804 | ||
c208c586 S |
1805 | DEFPY (bgp_suppress_fib_pending, |
1806 | bgp_suppress_fib_pending_cmd, | |
1807 | "[no] bgp suppress-fib-pending", | |
1808 | NO_STR | |
1809 | BGP_STR | |
1810 | "Advertise only routes that are programmed in kernel to peers\n") | |
1811 | { | |
1812 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1813 | ||
1814 | bgp_suppress_fib_pending_set(bgp, !no); | |
1815 | return CMD_SUCCESS; | |
1816 | } | |
1817 | ||
1818 | ||
718e3744 | 1819 | /* BGP Cluster ID. */ |
1ca2fd11 IR |
1820 | DEFUN (bgp_cluster_id, |
1821 | bgp_cluster_id_cmd, | |
1822 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1823 | BGP_STR | |
1824 | "Configure Route-Reflector Cluster-id\n" | |
1825 | "Route-Reflector Cluster-id in IP address format\n" | |
1826 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1827 | { |
1ca2fd11 | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1829 | int idx_ipv4 = 2; |
1ca2fd11 IR |
1830 | int ret; |
1831 | struct in_addr cluster; | |
1832 | ||
1833 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1834 | if (!ret) { | |
1835 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1836 | return CMD_WARNING_CONFIG_FAILED; | |
1837 | } | |
718e3744 | 1838 | |
1ca2fd11 IR |
1839 | bgp_cluster_id_set(bgp, &cluster); |
1840 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1841 | |
1ca2fd11 | 1842 | return CMD_SUCCESS; |
718e3744 | 1843 | } |
1844 | ||
1ca2fd11 IR |
1845 | DEFUN (no_bgp_cluster_id, |
1846 | no_bgp_cluster_id_cmd, | |
1847 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1848 | NO_STR | |
1849 | BGP_STR | |
1850 | "Configure Route-Reflector Cluster-id\n" | |
1851 | "Route-Reflector Cluster-id in IP address format\n" | |
1852 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1853 | { |
1ca2fd11 IR |
1854 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1855 | bgp_cluster_id_unset(bgp); | |
1856 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1857 | |
1ca2fd11 | 1858 | return CMD_SUCCESS; |
718e3744 | 1859 | } |
1860 | ||
c163f297 DS |
1861 | DEFPY (bgp_norib, |
1862 | bgp_norib_cmd, | |
1863 | "bgp no-rib", | |
1864 | BGP_STR | |
1865 | "Disable BGP route installation to RIB (Zebra)\n") | |
1866 | { | |
1867 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1868 | vty_out(vty, | |
1869 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1870 | return CMD_SUCCESS; | |
1871 | } | |
1872 | ||
1873 | bgp_option_norib_set_runtime(); | |
1874 | ||
1875 | return CMD_SUCCESS; | |
1876 | } | |
1877 | ||
1878 | DEFPY (no_bgp_norib, | |
1879 | no_bgp_norib_cmd, | |
1880 | "no bgp no-rib", | |
1881 | NO_STR | |
1882 | BGP_STR | |
1883 | "Disable BGP route installation to RIB (Zebra)\n") | |
1884 | { | |
1885 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1886 | vty_out(vty, | |
1887 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1888 | return CMD_SUCCESS; | |
1889 | } | |
1890 | ||
1891 | bgp_option_norib_unset_runtime(); | |
1892 | ||
1893 | return CMD_SUCCESS; | |
1894 | } | |
1895 | ||
e46723a5 DS |
1896 | DEFPY (no_bgp_send_extra_data, |
1897 | no_bgp_send_extra_data_cmd, | |
1898 | "[no] bgp send-extra-data zebra", | |
1899 | NO_STR | |
1900 | BGP_STR | |
1901 | "Extra data to Zebra for display/use\n" | |
1902 | "To zebra\n") | |
1903 | { | |
ec0acb80 DA |
1904 | if (no) |
1905 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1906 | else | |
1907 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1908 | |
1909 | return CMD_SUCCESS; | |
1910 | } | |
1911 | ||
1ca2fd11 IR |
1912 | DEFUN (bgp_confederation_identifier, |
1913 | bgp_confederation_identifier_cmd, | |
1914 | "bgp confederation identifier (1-4294967295)", | |
e9273987 | 1915 | BGP_STR |
1ca2fd11 IR |
1916 | "AS confederation parameters\n" |
1917 | "AS number\n" | |
1918 | "Set routing domain confederation AS\n") | |
718e3744 | 1919 | { |
1ca2fd11 | 1920 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1921 | int idx_number = 3; |
1ca2fd11 | 1922 | as_t as; |
718e3744 | 1923 | |
1ca2fd11 | 1924 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1925 | |
1ca2fd11 | 1926 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1927 | |
1ca2fd11 | 1928 | return CMD_SUCCESS; |
718e3744 | 1929 | } |
1930 | ||
1ca2fd11 IR |
1931 | DEFUN (no_bgp_confederation_identifier, |
1932 | no_bgp_confederation_identifier_cmd, | |
1933 | "no bgp confederation identifier [(1-4294967295)]", | |
1934 | NO_STR | |
e9273987 | 1935 | BGP_STR |
1ca2fd11 IR |
1936 | "AS confederation parameters\n" |
1937 | "AS number\n" | |
1938 | "Set routing domain confederation AS\n") | |
ff8a8a7a | 1939 | { |
1ca2fd11 IR |
1940 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1941 | bgp_confederation_id_unset(bgp); | |
1942 | ||
1943 | return CMD_SUCCESS; | |
ff8a8a7a CS |
1944 | } |
1945 | ||
1ca2fd11 IR |
1946 | DEFUN (bgp_confederation_peers, |
1947 | bgp_confederation_peers_cmd, | |
1948 | "bgp confederation peers (1-4294967295)...", | |
e9273987 | 1949 | BGP_STR |
1ca2fd11 IR |
1950 | "AS confederation parameters\n" |
1951 | "Peer ASs in BGP confederation\n" | |
1952 | AS_STR) | |
718e3744 | 1953 | { |
1ca2fd11 | 1954 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1955 | int idx_asn = 3; |
1ca2fd11 | 1956 | as_t as; |
d62a17ae | 1957 | int i; |
718e3744 | 1958 | |
1ca2fd11 IR |
1959 | for (i = idx_asn; i < argc; i++) { |
1960 | as = strtoul(argv[i]->arg, NULL, 10); | |
1ca2fd11 IR |
1961 | bgp_confederation_peers_add(bgp, as); |
1962 | } | |
1963 | return CMD_SUCCESS; | |
718e3744 | 1964 | } |
1965 | ||
1ca2fd11 IR |
1966 | DEFUN (no_bgp_confederation_peers, |
1967 | no_bgp_confederation_peers_cmd, | |
1968 | "no bgp confederation peers (1-4294967295)...", | |
1969 | NO_STR | |
e9273987 | 1970 | BGP_STR |
1ca2fd11 IR |
1971 | "AS confederation parameters\n" |
1972 | "Peer ASs in BGP confederation\n" | |
1973 | AS_STR) | |
718e3744 | 1974 | { |
1ca2fd11 | 1975 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1976 | int idx_asn = 4; |
1ca2fd11 | 1977 | as_t as; |
d62a17ae | 1978 | int i; |
718e3744 | 1979 | |
1ca2fd11 IR |
1980 | for (i = idx_asn; i < argc; i++) { |
1981 | as = strtoul(argv[i]->arg, NULL, 10); | |
ff8a8a7a | 1982 | |
1ca2fd11 IR |
1983 | bgp_confederation_peers_remove(bgp, as); |
1984 | } | |
1985 | return CMD_SUCCESS; | |
718e3744 | 1986 | } |
6b0655a2 | 1987 | |
5e242b0d DS |
1988 | /** |
1989 | * Central routine for maximum-paths configuration. | |
1990 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1991 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1992 | */ | |
585f1adc IR |
1993 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1994 | const char *mpaths, uint16_t options, | |
1995 | int set) | |
d62a17ae | 1996 | { |
585f1adc IR |
1997 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1998 | uint16_t maxpaths = 0; | |
d62a17ae | 1999 | int ret; |
585f1adc IR |
2000 | afi_t afi; |
2001 | safi_t safi; | |
2002 | ||
2003 | afi = bgp_node_afi(vty); | |
2004 | safi = bgp_node_safi(vty); | |
d62a17ae | 2005 | |
2006 | if (set) { | |
585f1adc | 2007 | maxpaths = strtol(mpaths, NULL, 10); |
d62a17ae | 2008 | if (maxpaths > multipath_num) { |
585f1adc | 2009 | vty_out(vty, |
d62a17ae | 2010 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
2011 | maxpaths, multipath_num); | |
2012 | return CMD_WARNING_CONFIG_FAILED; | |
2013 | } | |
2014 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
2015 | options); | |
2016 | } else | |
2017 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
2018 | ||
2019 | if (ret < 0) { | |
585f1adc | 2020 | vty_out(vty, |
d62a17ae | 2021 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
2022 | (set == 1) ? "" : "un", | |
2023 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
2024 | maxpaths, afi, safi); | |
2025 | return CMD_WARNING_CONFIG_FAILED; | |
2026 | } | |
2027 | ||
2028 | bgp_recalculate_all_bestpaths(bgp); | |
2029 | ||
2030 | return CMD_SUCCESS; | |
165b5fff JB |
2031 | } |
2032 | ||
1ca2fd11 IR |
2033 | DEFUN (bgp_maxmed_admin, |
2034 | bgp_maxmed_admin_cmd, | |
2035 | "bgp max-med administrative ", | |
2036 | BGP_STR | |
2037 | "Advertise routes with max-med\n" | |
2038 | "Administratively applied, for an indefinite period\n") | |
abc920f8 | 2039 | { |
1ca2fd11 | 2040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 2041 | |
1ca2fd11 IR |
2042 | bgp->v_maxmed_admin = 1; |
2043 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
ff8a8a7a | 2044 | |
1ca2fd11 | 2045 | bgp_maxmed_update(bgp); |
abc920f8 | 2046 | |
1ca2fd11 | 2047 | return CMD_SUCCESS; |
ff8a8a7a CS |
2048 | } |
2049 | ||
1ca2fd11 IR |
2050 | DEFUN (bgp_maxmed_admin_medv, |
2051 | bgp_maxmed_admin_medv_cmd, | |
2052 | "bgp max-med administrative (0-4294967295)", | |
2053 | BGP_STR | |
2054 | "Advertise routes with max-med\n" | |
2055 | "Administratively applied, for an indefinite period\n" | |
2056 | "Max MED value to be used\n") | |
abc920f8 | 2057 | { |
1ca2fd11 | 2058 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2059 | int idx_number = 3; |
abc920f8 | 2060 | |
1ca2fd11 IR |
2061 | bgp->v_maxmed_admin = 1; |
2062 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 2063 | |
1ca2fd11 | 2064 | bgp_maxmed_update(bgp); |
abc920f8 | 2065 | |
1ca2fd11 | 2066 | return CMD_SUCCESS; |
abc920f8 DS |
2067 | } |
2068 | ||
1ca2fd11 IR |
2069 | DEFUN (no_bgp_maxmed_admin, |
2070 | no_bgp_maxmed_admin_cmd, | |
2071 | "no bgp max-med administrative [(0-4294967295)]", | |
2072 | NO_STR | |
2073 | BGP_STR | |
2074 | "Advertise routes with max-med\n" | |
2075 | "Administratively applied, for an indefinite period\n" | |
2076 | "Max MED value to be used\n") | |
abc920f8 | 2077 | { |
1ca2fd11 IR |
2078 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2079 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
2080 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
2081 | bgp_maxmed_update(bgp); | |
ff8a8a7a | 2082 | |
1ca2fd11 | 2083 | return CMD_SUCCESS; |
abc920f8 DS |
2084 | } |
2085 | ||
1ca2fd11 IR |
2086 | DEFUN (bgp_maxmed_onstartup, |
2087 | bgp_maxmed_onstartup_cmd, | |
2088 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
2089 | BGP_STR | |
2090 | "Advertise routes with max-med\n" | |
2091 | "Effective on a startup\n" | |
2092 | "Time (seconds) period for max-med\n" | |
2093 | "Max MED value to be used\n") | |
abc920f8 | 2094 | { |
1ca2fd11 | 2095 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2096 | int idx = 0; |
4668a151 | 2097 | |
9b01d289 DA |
2098 | if (argv_find(argv, argc, "(5-86400)", &idx)) |
2099 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
d62a17ae | 2100 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
1ca2fd11 | 2101 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 2102 | else |
1ca2fd11 | 2103 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 | 2104 | |
1ca2fd11 IR |
2105 | bgp_maxmed_update(bgp); |
2106 | ||
2107 | return CMD_SUCCESS; | |
abc920f8 DS |
2108 | } |
2109 | ||
1ca2fd11 IR |
2110 | DEFUN (no_bgp_maxmed_onstartup, |
2111 | no_bgp_maxmed_onstartup_cmd, | |
2112 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
2113 | NO_STR | |
2114 | BGP_STR | |
2115 | "Advertise routes with max-med\n" | |
2116 | "Effective on a startup\n" | |
2117 | "Time (seconds) period for max-med\n" | |
2118 | "Max MED value to be used\n") | |
abc920f8 | 2119 | { |
1ca2fd11 IR |
2120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2121 | ||
2122 | /* Cancel max-med onstartup if its on */ | |
2123 | if (bgp->t_maxmed_onstartup) { | |
c3aaa89a | 2124 | THREAD_OFF(bgp->t_maxmed_onstartup); |
1ca2fd11 IR |
2125 | bgp->maxmed_onstartup_over = 1; |
2126 | } | |
abc920f8 | 2127 | |
1ca2fd11 IR |
2128 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
2129 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 2130 | |
1ca2fd11 IR |
2131 | bgp_maxmed_update(bgp); |
2132 | ||
2133 | return CMD_SUCCESS; | |
abc920f8 DS |
2134 | } |
2135 | ||
d70583f7 D |
2136 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
2137 | uint16_t update_delay, | |
2138 | uint16_t establish_wait) | |
2139 | { | |
2140 | struct listnode *node, *nnode; | |
2141 | struct bgp *bgp; | |
2142 | bool vrf_cfg = false; | |
2143 | ||
2144 | /* | |
2145 | * See if update-delay is set per-vrf and warn user to delete it | |
2146 | * Note that we only need to check this if this is the first time | |
2147 | * setting the global config. | |
2148 | */ | |
2149 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
2150 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2151 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
2152 | vty_out(vty, | |
2153 | "%% update-delay configuration found in vrf %s\n", | |
2154 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
2155 | ? VRF_DEFAULT_NAME | |
2156 | : bgp->name); | |
2157 | vrf_cfg = true; | |
2158 | } | |
2159 | } | |
2160 | } | |
2161 | ||
2162 | if (vrf_cfg) { | |
2163 | vty_out(vty, | |
2164 | "%%Failed: global update-delay config not permitted\n"); | |
2165 | return CMD_WARNING; | |
2166 | } | |
2167 | ||
2168 | if (!establish_wait) { /* update-delay <delay> */ | |
2169 | bm->v_update_delay = update_delay; | |
2170 | bm->v_establish_wait = bm->v_update_delay; | |
2171 | } else { | |
2172 | /* update-delay <delay> <establish-wait> */ | |
2173 | if (update_delay < establish_wait) { | |
2174 | vty_out(vty, | |
2175 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2176 | return CMD_WARNING_CONFIG_FAILED; | |
2177 | } | |
2178 | ||
2179 | bm->v_update_delay = update_delay; | |
2180 | bm->v_establish_wait = establish_wait; | |
2181 | } | |
2182 | ||
2183 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2184 | bgp->v_update_delay = bm->v_update_delay; | |
2185 | bgp->v_establish_wait = bm->v_establish_wait; | |
2186 | } | |
2187 | ||
2188 | return CMD_SUCCESS; | |
2189 | } | |
2190 | ||
2191 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2192 | { | |
2193 | struct listnode *node, *nnode; | |
2194 | struct bgp *bgp; | |
2195 | ||
2196 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2197 | bm->v_establish_wait = bm->v_update_delay; | |
2198 | ||
2199 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2200 | bgp->v_update_delay = bm->v_update_delay; | |
2201 | bgp->v_establish_wait = bm->v_establish_wait; | |
2202 | } | |
2203 | ||
2204 | return CMD_SUCCESS; | |
2205 | } | |
2206 | ||
2207 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2208 | uint16_t establish_wait) | |
f188f2c4 | 2209 | { |
d62a17ae | 2210 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2211 | |
d70583f7 D |
2212 | /* if configured globally, per-instance config is not allowed */ |
2213 | if (bm->v_update_delay) { | |
2214 | vty_out(vty, | |
2215 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2216 | return CMD_WARNING_CONFIG_FAILED; | |
2217 | } | |
2218 | ||
f188f2c4 | 2219 | |
d70583f7 | 2220 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2221 | { |
2222 | bgp->v_update_delay = update_delay; | |
2223 | bgp->v_establish_wait = bgp->v_update_delay; | |
2224 | return CMD_SUCCESS; | |
2225 | } | |
f188f2c4 | 2226 | |
d62a17ae | 2227 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2228 | if (update_delay < establish_wait) { |
2229 | vty_out(vty, | |
2230 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2231 | return CMD_WARNING_CONFIG_FAILED; | |
2232 | } | |
f188f2c4 | 2233 | |
d62a17ae | 2234 | bgp->v_update_delay = update_delay; |
2235 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2236 | |
d62a17ae | 2237 | return CMD_SUCCESS; |
f188f2c4 DS |
2238 | } |
2239 | ||
d62a17ae | 2240 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2241 | { |
d62a17ae | 2242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2243 | |
d70583f7 D |
2244 | /* If configured globally, cannot remove from one bgp instance */ |
2245 | if (bm->v_update_delay) { | |
2246 | vty_out(vty, | |
2247 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2248 | return CMD_WARNING_CONFIG_FAILED; | |
2249 | } | |
d62a17ae | 2250 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2251 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2252 | |
d62a17ae | 2253 | return CMD_SUCCESS; |
f188f2c4 DS |
2254 | } |
2255 | ||
2b791107 | 2256 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2257 | { |
d70583f7 D |
2258 | /* If configured globally, no need to display per-instance value */ |
2259 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2260 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2261 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2262 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2263 | vty_out(vty, "\n"); | |
2264 | } | |
f188f2c4 DS |
2265 | } |
2266 | ||
d70583f7 D |
2267 | /* Global update-delay configuration */ |
2268 | DEFPY (bgp_global_update_delay, | |
2269 | bgp_global_update_delay_cmd, | |
2270 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2271 | BGP_STR | |
2272 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2273 | "Max delay in seconds\n" | |
2274 | "Establish wait in seconds\n") | |
2275 | { | |
2276 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2277 | } | |
f188f2c4 | 2278 | |
d70583f7 D |
2279 | /* Global update-delay deconfiguration */ |
2280 | DEFPY (no_bgp_global_update_delay, | |
2281 | no_bgp_global_update_delay_cmd, | |
2282 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2283 | NO_STR | |
2284 | BGP_STR | |
f188f2c4 | 2285 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2286 | "Max delay in seconds\n" |
2287 | "Establish wait in seconds\n") | |
f188f2c4 | 2288 | { |
d70583f7 | 2289 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2290 | } |
2291 | ||
d70583f7 D |
2292 | /* Update-delay configuration */ |
2293 | ||
2294 | DEFPY (bgp_update_delay, | |
2295 | bgp_update_delay_cmd, | |
2296 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2297 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2298 | "Max delay in seconds\n" |
2299 | "Establish wait in seconds\n") | |
f188f2c4 | 2300 | { |
d70583f7 | 2301 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2302 | } |
2303 | ||
2304 | /* Update-delay deconfiguration */ | |
d70583f7 | 2305 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2306 | no_bgp_update_delay_cmd, |
838758ac DW |
2307 | "no update-delay [(0-3600) [(1-3600)]]", |
2308 | NO_STR | |
f188f2c4 | 2309 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2310 | "Max delay in seconds\n" |
2311 | "Establish wait in seconds\n") | |
f188f2c4 | 2312 | { |
d62a17ae | 2313 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2314 | } |
2315 | ||
5e242b0d | 2316 | |
1ca2fd11 IR |
2317 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2318 | bool set) | |
cb1faec9 | 2319 | { |
1ca2fd11 IR |
2320 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2321 | ||
8fa7732f QY |
2322 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2323 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2324 | |
2325 | return CMD_SUCCESS; | |
2326 | } | |
2327 | ||
1ca2fd11 IR |
2328 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2329 | bool set) | |
555e09d4 | 2330 | { |
1ca2fd11 IR |
2331 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2332 | ||
8fa7732f QY |
2333 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2334 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2335 | |
d62a17ae | 2336 | return CMD_SUCCESS; |
cb1faec9 DS |
2337 | } |
2338 | ||
2b791107 | 2339 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2340 | { |
555e09d4 QY |
2341 | uint32_t quanta = |
2342 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2343 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2344 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2345 | } |
2346 | ||
555e09d4 QY |
2347 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2348 | { | |
2349 | uint32_t quanta = | |
2350 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2351 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2352 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2353 | } |
cb1faec9 | 2354 | |
8fa7732f QY |
2355 | /* Packet quanta configuration |
2356 | * | |
2357 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2358 | * thread. When changing these limits be careful to prevent stack overflow. | |
2359 | * | |
2360 | * Furthermore, the maximums used here should correspond to | |
2361 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2362 | */ | |
1ca2fd11 IR |
2363 | DEFPY (bgp_wpkt_quanta, |
2364 | bgp_wpkt_quanta_cmd, | |
2365 | "[no] write-quanta (1-64)$quanta", | |
2366 | NO_STR | |
2367 | "How many packets to write to peer socket per run\n" | |
2368 | "Number of packets\n") | |
2369 | { | |
2370 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2371 | } | |
cb1faec9 | 2372 | |
1ca2fd11 IR |
2373 | DEFPY (bgp_rpkt_quanta, |
2374 | bgp_rpkt_quanta_cmd, | |
2375 | "[no] read-quanta (1-10)$quanta", | |
2376 | NO_STR | |
2377 | "How many packets to read from peer socket per I/O cycle\n" | |
2378 | "Number of packets\n") | |
2379 | { | |
2380 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
555e09d4 QY |
2381 | } |
2382 | ||
2b791107 | 2383 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2384 | { |
37a333fe | 2385 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2386 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2387 | } |
2388 | ||
d1adb448 PG |
2389 | /* BGP TCP keepalive */ |
2390 | static void bgp_config_tcp_keepalive(struct vty *vty, struct bgp *bgp) | |
2391 | { | |
2392 | if (bgp->tcp_keepalive_idle) { | |
2393 | vty_out(vty, " bgp tcp-keepalive %u %u %u\n", | |
2394 | bgp->tcp_keepalive_idle, bgp->tcp_keepalive_intvl, | |
2395 | bgp->tcp_keepalive_probes); | |
2396 | } | |
2397 | } | |
4668a151 | 2398 | |
1ca2fd11 IR |
2399 | DEFUN (bgp_coalesce_time, |
2400 | bgp_coalesce_time_cmd, | |
2401 | "coalesce-time (0-4294967295)", | |
2402 | "Subgroup coalesce timer\n" | |
2403 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2404 | { |
1ca2fd11 | 2405 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 2406 | |
1ca2fd11 | 2407 | int idx = 0; |
9b01d289 | 2408 | |
1ca2fd11 | 2409 | bgp->heuristic_coalesce = false; |
9b01d289 DA |
2410 | |
2411 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
2412 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2413 | ||
1ca2fd11 | 2414 | return CMD_SUCCESS; |
3f9c7369 DS |
2415 | } |
2416 | ||
1ca2fd11 IR |
2417 | DEFUN (no_bgp_coalesce_time, |
2418 | no_bgp_coalesce_time_cmd, | |
2419 | "no coalesce-time (0-4294967295)", | |
2420 | NO_STR | |
2421 | "Subgroup coalesce timer\n" | |
2422 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2423 | { |
1ca2fd11 | 2424 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 2425 | |
1ca2fd11 IR |
2426 | bgp->heuristic_coalesce = true; |
2427 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2428 | return CMD_SUCCESS; | |
3f9c7369 DS |
2429 | } |
2430 | ||
5e242b0d | 2431 | /* Maximum-paths configuration */ |
585f1adc IR |
2432 | DEFUN (bgp_maxpaths, |
2433 | bgp_maxpaths_cmd, | |
2434 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2435 | "Forward packets over multiple paths\n" | |
2436 | "Number of paths\n") | |
5e242b0d | 2437 | { |
d62a17ae | 2438 | int idx_number = 1; |
585f1adc IR |
2439 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, |
2440 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2441 | } |
2442 | ||
d62a17ae | 2443 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2444 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2445 | "Forward packets over multiple paths\n" | |
2446 | "Number of paths\n") | |
596c17ba | 2447 | |
585f1adc IR |
2448 | DEFUN (bgp_maxpaths_ibgp, |
2449 | bgp_maxpaths_ibgp_cmd, | |
2450 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2451 | "Forward packets over multiple paths\n" | |
2452 | "iBGP-multipath\n" | |
2453 | "Number of paths\n") | |
165b5fff | 2454 | { |
d62a17ae | 2455 | int idx_number = 2; |
585f1adc IR |
2456 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2457 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2458 | } |
165b5fff | 2459 | |
d62a17ae | 2460 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2461 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2462 | "Forward packets over multiple paths\n" | |
2463 | "iBGP-multipath\n" | |
2464 | "Number of paths\n") | |
596c17ba | 2465 | |
585f1adc IR |
2466 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2467 | bgp_maxpaths_ibgp_cluster_cmd, | |
2468 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2469 | "Forward packets over multiple paths\n" | |
2470 | "iBGP-multipath\n" | |
2471 | "Number of paths\n" | |
2472 | "Match the cluster length\n") | |
5e242b0d | 2473 | { |
d62a17ae | 2474 | int idx_number = 2; |
aa53c036 DS |
2475 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2476 | argv[idx_number]->arg, true, 1); | |
165b5fff JB |
2477 | } |
2478 | ||
d62a17ae | 2479 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2480 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2481 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2482 | "Forward packets over multiple paths\n" | |
2483 | "iBGP-multipath\n" | |
2484 | "Number of paths\n" | |
2485 | "Match the cluster length\n") | |
596c17ba | 2486 | |
585f1adc IR |
2487 | DEFUN (no_bgp_maxpaths, |
2488 | no_bgp_maxpaths_cmd, | |
2489 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2490 | NO_STR | |
2491 | "Forward packets over multiple paths\n" | |
2492 | "Number of paths\n") | |
165b5fff | 2493 | { |
585f1adc | 2494 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2495 | } |
2496 | ||
d62a17ae | 2497 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2498 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2499 | "Forward packets over multiple paths\n" |
2500 | "Number of paths\n") | |
596c17ba | 2501 | |
585f1adc IR |
2502 | DEFUN (no_bgp_maxpaths_ibgp, |
2503 | no_bgp_maxpaths_ibgp_cmd, | |
2504 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2505 | NO_STR | |
2506 | "Forward packets over multiple paths\n" | |
2507 | "iBGP-multipath\n" | |
2508 | "Number of paths\n" | |
2509 | "Match the cluster length\n") | |
165b5fff | 2510 | { |
585f1adc | 2511 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2512 | } |
2513 | ||
d62a17ae | 2514 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2515 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2516 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2517 | NO_STR | |
2518 | "Forward packets over multiple paths\n" | |
2519 | "iBGP-multipath\n" | |
2520 | "Number of paths\n" | |
2521 | "Match the cluster length\n") | |
596c17ba | 2522 | |
dd65f45e DL |
2523 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2524 | afi_t afi, safi_t safi) | |
165b5fff | 2525 | { |
00908b7a | 2526 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2527 | vty_out(vty, " maximum-paths %d\n", |
2528 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2529 | } | |
165b5fff | 2530 | |
00908b7a | 2531 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2532 | vty_out(vty, " maximum-paths ibgp %d", |
2533 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
aa53c036 | 2534 | if (bgp->maxpaths[afi][safi].same_clusterlen) |
d62a17ae | 2535 | vty_out(vty, " equal-cluster-length"); |
2536 | vty_out(vty, "\n"); | |
2537 | } | |
165b5fff | 2538 | } |
6b0655a2 | 2539 | |
718e3744 | 2540 | /* BGP timers. */ |
2541 | ||
1ca2fd11 IR |
2542 | DEFUN (bgp_timers, |
2543 | bgp_timers_cmd, | |
2544 | "timers bgp (0-65535) (0-65535)", | |
2545 | "Adjust routing timers\n" | |
2546 | "BGP timers\n" | |
2547 | "Keepalive interval\n" | |
2548 | "Holdtime\n") | |
718e3744 | 2549 | { |
1ca2fd11 | 2550 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2551 | int idx_number = 2; |
2552 | int idx_number_2 = 3; | |
1ca2fd11 IR |
2553 | unsigned long keepalive = 0; |
2554 | unsigned long holdtime = 0; | |
718e3744 | 2555 | |
1ca2fd11 IR |
2556 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
2557 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 2558 | |
1ca2fd11 IR |
2559 | /* Holdtime value check. */ |
2560 | if (holdtime < 3 && holdtime != 0) { | |
2561 | vty_out(vty, | |
2562 | "%% hold time value must be either 0 or greater than 3\n"); | |
2563 | return CMD_WARNING_CONFIG_FAILED; | |
2564 | } | |
718e3744 | 2565 | |
1ca2fd11 IR |
2566 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, |
2567 | BGP_DEFAULT_DELAYOPEN); | |
718e3744 | 2568 | |
1ca2fd11 | 2569 | return CMD_SUCCESS; |
718e3744 | 2570 | } |
2571 | ||
1ca2fd11 IR |
2572 | DEFUN (no_bgp_timers, |
2573 | no_bgp_timers_cmd, | |
2574 | "no timers bgp [(0-65535) (0-65535)]", | |
2575 | NO_STR | |
2576 | "Adjust routing timers\n" | |
2577 | "BGP timers\n" | |
2578 | "Keepalive interval\n" | |
2579 | "Holdtime\n") | |
718e3744 | 2580 | { |
1ca2fd11 IR |
2581 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2582 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2583 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
ff8a8a7a | 2584 | |
1ca2fd11 | 2585 | return CMD_SUCCESS; |
718e3744 | 2586 | } |
2587 | ||
b042667a TI |
2588 | /* BGP minimum holdtime. */ |
2589 | ||
2590 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2591 | "bgp minimum-holdtime (1-65535)", | |
2592 | "BGP specific commands\n" | |
2593 | "BGP minimum holdtime\n" | |
2594 | "Seconds\n") | |
2595 | { | |
2596 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2597 | int idx_number = 2; | |
2598 | unsigned long min_holdtime; | |
2599 | ||
2600 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2601 | ||
2602 | bgp->default_min_holdtime = min_holdtime; | |
2603 | ||
2604 | return CMD_SUCCESS; | |
2605 | } | |
2606 | ||
2607 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2608 | "no bgp minimum-holdtime [(1-65535)]", | |
2609 | NO_STR | |
2610 | "BGP specific commands\n" | |
2611 | "BGP minimum holdtime\n" | |
2612 | "Seconds\n") | |
2613 | { | |
2614 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2615 | ||
2616 | bgp->default_min_holdtime = 0; | |
2617 | ||
2618 | return CMD_SUCCESS; | |
2619 | } | |
ff8a8a7a | 2620 | |
d1adb448 PG |
2621 | DEFPY(bgp_tcp_keepalive, bgp_tcp_keepalive_cmd, |
2622 | "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes", | |
2623 | BGP_STR | |
2624 | "TCP keepalive parameters\n" | |
2625 | "TCP keepalive idle time (seconds)\n" | |
2626 | "TCP keepalive interval (seconds)\n" | |
2627 | "TCP keepalive maximum probes\n") | |
2628 | { | |
2629 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2630 | ||
2631 | bgp_tcp_keepalive_set(bgp, (uint16_t)idle, (uint16_t)intvl, | |
2632 | (uint16_t)probes); | |
2633 | ||
2634 | return CMD_SUCCESS; | |
2635 | } | |
2636 | ||
2637 | DEFPY(no_bgp_tcp_keepalive, no_bgp_tcp_keepalive_cmd, | |
2638 | "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]", | |
2639 | NO_STR | |
2640 | BGP_STR | |
2641 | "TCP keepalive parameters\n" | |
2642 | "TCP keepalive idle time (seconds)\n" | |
2643 | "TCP keepalive interval (seconds)\n" | |
2644 | "TCP keepalive maximum probes\n") | |
2645 | { | |
2646 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2647 | ||
2648 | bgp_tcp_keepalive_unset(bgp); | |
2649 | ||
2650 | return CMD_SUCCESS; | |
2651 | } | |
2652 | ||
1ca2fd11 IR |
2653 | DEFUN (bgp_client_to_client_reflection, |
2654 | bgp_client_to_client_reflection_cmd, | |
2655 | "bgp client-to-client reflection", | |
e9273987 | 2656 | BGP_STR |
1ca2fd11 IR |
2657 | "Configure client to client route reflection\n" |
2658 | "reflection of routes allowed\n") | |
718e3744 | 2659 | { |
1ca2fd11 IR |
2660 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2661 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2662 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2663 | |
1ca2fd11 | 2664 | return CMD_SUCCESS; |
718e3744 | 2665 | } |
2666 | ||
1ca2fd11 IR |
2667 | DEFUN (no_bgp_client_to_client_reflection, |
2668 | no_bgp_client_to_client_reflection_cmd, | |
2669 | "no bgp client-to-client reflection", | |
2670 | NO_STR | |
e9273987 | 2671 | BGP_STR |
1ca2fd11 IR |
2672 | "Configure client to client route reflection\n" |
2673 | "reflection of routes allowed\n") | |
718e3744 | 2674 | { |
1ca2fd11 IR |
2675 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2676 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2677 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2678 | |
1ca2fd11 | 2679 | return CMD_SUCCESS; |
718e3744 | 2680 | } |
2681 | ||
2682 | /* "bgp always-compare-med" configuration. */ | |
1ca2fd11 IR |
2683 | DEFUN (bgp_always_compare_med, |
2684 | bgp_always_compare_med_cmd, | |
2685 | "bgp always-compare-med", | |
e9273987 | 2686 | BGP_STR |
1ca2fd11 | 2687 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2688 | { |
1ca2fd11 IR |
2689 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2690 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2691 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2692 | |
1ca2fd11 | 2693 | return CMD_SUCCESS; |
718e3744 | 2694 | } |
2695 | ||
1ca2fd11 IR |
2696 | DEFUN (no_bgp_always_compare_med, |
2697 | no_bgp_always_compare_med_cmd, | |
2698 | "no bgp always-compare-med", | |
2699 | NO_STR | |
e9273987 | 2700 | BGP_STR |
1ca2fd11 | 2701 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2702 | { |
1ca2fd11 IR |
2703 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2704 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2705 | bgp_recalculate_all_bestpaths(bgp); | |
6b0655a2 | 2706 | |
1ca2fd11 | 2707 | return CMD_SUCCESS; |
2adac256 DA |
2708 | } |
2709 | ||
2adac256 | 2710 | |
1ca2fd11 IR |
2711 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, |
2712 | "bgp ebgp-requires-policy", | |
e9273987 | 2713 | BGP_STR |
1ca2fd11 | 2714 | "Require in and out policy for eBGP peers (RFC8212)\n") |
2adac256 | 2715 | { |
1ca2fd11 IR |
2716 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2717 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2718 | return CMD_SUCCESS; | |
2adac256 DA |
2719 | } |
2720 | ||
1ca2fd11 IR |
2721 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, |
2722 | "no bgp ebgp-requires-policy", | |
2723 | NO_STR | |
e9273987 | 2724 | BGP_STR |
1ca2fd11 | 2725 | "Require in and out policy for eBGP peers (RFC8212)\n") |
ff8a8a7a | 2726 | { |
1ca2fd11 IR |
2727 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2728 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2729 | return CMD_SUCCESS; | |
ff8a8a7a | 2730 | } |
9dac9fc8 | 2731 | |
1ca2fd11 IR |
2732 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, |
2733 | "bgp suppress-duplicates", | |
e9273987 | 2734 | BGP_STR |
1ca2fd11 | 2735 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2736 | { |
1ca2fd11 IR |
2737 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2738 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2739 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2740 | } |
2741 | ||
1ca2fd11 IR |
2742 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, |
2743 | "no bgp suppress-duplicates", | |
2744 | NO_STR | |
e9273987 | 2745 | BGP_STR |
1ca2fd11 | 2746 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2747 | { |
1ca2fd11 IR |
2748 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2749 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2750 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2751 | } |
2752 | ||
fb29348a DA |
2753 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2754 | "bgp reject-as-sets", | |
e9273987 | 2755 | BGP_STR |
fb29348a DA |
2756 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2757 | { | |
2758 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2759 | struct listnode *node, *nnode; | |
2760 | struct peer *peer; | |
2761 | ||
7f972cd8 | 2762 | bgp->reject_as_sets = true; |
fb29348a DA |
2763 | |
2764 | /* Reset existing BGP sessions to reject routes | |
2765 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2766 | */ | |
2767 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2768 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2769 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2770 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2771 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2772 | } | |
2773 | } | |
2774 | ||
2775 | return CMD_SUCCESS; | |
2776 | } | |
2777 | ||
2778 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2779 | "no bgp reject-as-sets", | |
2780 | NO_STR | |
e9273987 | 2781 | BGP_STR |
fb29348a DA |
2782 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2783 | { | |
2784 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2785 | struct listnode *node, *nnode; | |
2786 | struct peer *peer; | |
2787 | ||
7f972cd8 | 2788 | bgp->reject_as_sets = false; |
fb29348a DA |
2789 | |
2790 | /* Reset existing BGP sessions to reject routes | |
2791 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2792 | */ | |
2793 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2794 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2795 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2796 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2797 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2798 | } | |
2799 | } | |
2800 | ||
2801 | return CMD_SUCCESS; | |
2802 | } | |
9dac9fc8 | 2803 | |
718e3744 | 2804 | /* "bgp deterministic-med" configuration. */ |
1ca2fd11 | 2805 | DEFUN (bgp_deterministic_med, |
718e3744 | 2806 | bgp_deterministic_med_cmd, |
2807 | "bgp deterministic-med", | |
e9273987 | 2808 | BGP_STR |
718e3744 | 2809 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2810 | { | |
1ca2fd11 IR |
2811 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2812 | ||
2813 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2814 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2815 | bgp_recalculate_all_bestpaths(bgp); | |
2816 | } | |
7aafcaca | 2817 | |
1ca2fd11 | 2818 | return CMD_SUCCESS; |
718e3744 | 2819 | } |
2820 | ||
1ca2fd11 | 2821 | DEFUN (no_bgp_deterministic_med, |
718e3744 | 2822 | no_bgp_deterministic_med_cmd, |
2823 | "no bgp deterministic-med", | |
2824 | NO_STR | |
e9273987 | 2825 | BGP_STR |
718e3744 | 2826 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2827 | { | |
1ca2fd11 IR |
2828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2829 | int bestpath_per_as_used; | |
2830 | afi_t afi; | |
2831 | safi_t safi; | |
2832 | struct peer *peer; | |
2833 | struct listnode *node, *nnode; | |
2834 | ||
2835 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2836 | bestpath_per_as_used = 0; | |
2837 | ||
2838 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2839 | FOREACH_AFI_SAFI (afi, safi) | |
2840 | if (bgp_addpath_dmed_required( | |
2841 | peer->addpath_type[afi][safi])) { | |
2842 | bestpath_per_as_used = 1; | |
2843 | break; | |
2844 | } | |
2845 | ||
2846 | if (bestpath_per_as_used) | |
2847 | break; | |
2848 | } | |
2849 | ||
2850 | if (bestpath_per_as_used) { | |
2851 | vty_out(vty, | |
2852 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2853 | return CMD_WARNING_CONFIG_FAILED; | |
2854 | } else { | |
2855 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2856 | bgp_recalculate_all_bestpaths(bgp); | |
2857 | } | |
2858 | } | |
d62a17ae | 2859 | |
1ca2fd11 | 2860 | return CMD_SUCCESS; |
718e3744 | 2861 | } |
538621f2 | 2862 | |
055679e9 | 2863 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2864 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2865 | bgp_graceful_restart_cmd, |
2866 | "bgp graceful-restart", | |
e9273987 | 2867 | BGP_STR |
2ba1fe69 | 2868 | GR_CMD |
055679e9 | 2869 | ) |
538621f2 | 2870 | { |
055679e9 | 2871 | int ret = BGP_GR_FAILURE; |
2872 | ||
2873 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2874 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2875 | |
d62a17ae | 2876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2877 | |
2878 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2879 | ||
36235319 QY |
2880 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2881 | ret); | |
5cce3f05 | 2882 | |
055679e9 | 2883 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2884 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2885 | vty_out(vty, |
2886 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2887 | return bgp_vty_return(vty, ret); |
538621f2 | 2888 | } |
2889 | ||
2890 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2891 | no_bgp_graceful_restart_cmd, |
2892 | "no bgp graceful-restart", | |
2893 | NO_STR | |
e9273987 | 2894 | BGP_STR |
2ba1fe69 | 2895 | NO_GR_CMD |
055679e9 | 2896 | ) |
538621f2 | 2897 | { |
d62a17ae | 2898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2899 | |
2900 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2901 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2902 | |
2903 | int ret = BGP_GR_FAILURE; | |
2904 | ||
2905 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2906 | ||
36235319 QY |
2907 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2908 | ret); | |
5cce3f05 | 2909 | |
055679e9 | 2910 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2911 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2912 | vty_out(vty, |
2913 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2914 | |
2915 | return bgp_vty_return(vty, ret); | |
538621f2 | 2916 | } |
2917 | ||
93406d87 | 2918 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2919 | bgp_graceful_restart_stalepath_time_cmd, |
2920 | "bgp graceful-restart stalepath-time (1-4095)", | |
e9273987 | 2921 | BGP_STR |
2ba1fe69 | 2922 | "Graceful restart capability parameters\n" |
2923 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2924 | "Delay value (seconds)\n") | |
93406d87 | 2925 | { |
d62a17ae | 2926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2927 | int idx_number = 3; | |
d7c0a89a | 2928 | uint32_t stalepath; |
93406d87 | 2929 | |
d62a17ae | 2930 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2931 | bgp->stalepath_time = stalepath; | |
2932 | return CMD_SUCCESS; | |
93406d87 | 2933 | } |
2934 | ||
eb6f1b41 | 2935 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2936 | bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2937 | "bgp graceful-restart restart-time (0-4095)", |
e9273987 | 2938 | BGP_STR |
2ba1fe69 | 2939 | "Graceful restart capability parameters\n" |
2940 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2941 | "Delay value (seconds)\n") | |
eb6f1b41 | 2942 | { |
d62a17ae | 2943 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2944 | int idx_number = 3; | |
d7c0a89a | 2945 | uint32_t restart; |
eb6f1b41 | 2946 | |
d62a17ae | 2947 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2948 | bgp->restart_time = restart; | |
2949 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2950 | } |
2951 | ||
cfd47646 | 2952 | DEFUN (bgp_graceful_restart_select_defer_time, |
2953 | bgp_graceful_restart_select_defer_time_cmd, | |
2954 | "bgp graceful-restart select-defer-time (0-3600)", | |
e9273987 | 2955 | BGP_STR |
cfd47646 | 2956 | "Graceful restart capability parameters\n" |
2957 | "Set the time to defer the BGP route selection after restart\n" | |
2958 | "Delay value (seconds, 0 - disable)\n") | |
2959 | { | |
2960 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2961 | int idx_number = 3; | |
2962 | uint32_t defer_time; | |
2963 | ||
2964 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2965 | bgp->select_defer_time = defer_time; | |
2966 | if (defer_time == 0) | |
892fedb6 | 2967 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2968 | else |
892fedb6 | 2969 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2970 | |
2971 | return CMD_SUCCESS; | |
2972 | } | |
2973 | ||
93406d87 | 2974 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2975 | no_bgp_graceful_restart_stalepath_time_cmd, |
2976 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2977 | NO_STR | |
e9273987 | 2978 | BGP_STR |
2ba1fe69 | 2979 | "Graceful restart capability parameters\n" |
2980 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2981 | "Delay value (seconds)\n") | |
93406d87 | 2982 | { |
d62a17ae | 2983 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2984 | |
d62a17ae | 2985 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2986 | return CMD_SUCCESS; | |
93406d87 | 2987 | } |
2988 | ||
eb6f1b41 | 2989 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2990 | no_bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2991 | "no bgp graceful-restart restart-time [(0-4095)]", |
2ba1fe69 | 2992 | NO_STR |
e9273987 | 2993 | BGP_STR |
2ba1fe69 | 2994 | "Graceful restart capability parameters\n" |
2995 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2996 | "Delay value (seconds)\n") | |
eb6f1b41 | 2997 | { |
d62a17ae | 2998 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2999 | |
d62a17ae | 3000 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
3001 | return CMD_SUCCESS; | |
eb6f1b41 PG |
3002 | } |
3003 | ||
cfd47646 | 3004 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
3005 | no_bgp_graceful_restart_select_defer_time_cmd, | |
3006 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
3007 | NO_STR | |
e9273987 | 3008 | BGP_STR |
cfd47646 | 3009 | "Graceful restart capability parameters\n" |
3010 | "Set the time to defer the BGP route selection after restart\n" | |
3011 | "Delay value (seconds)\n") | |
3012 | { | |
3013 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3014 | ||
3015 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 3016 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 3017 | |
3018 | return CMD_SUCCESS; | |
3019 | } | |
3020 | ||
43fc21b3 | 3021 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 3022 | bgp_graceful_restart_preserve_fw_cmd, |
3023 | "bgp graceful-restart preserve-fw-state", | |
e9273987 | 3024 | BGP_STR |
2ba1fe69 | 3025 | "Graceful restart capability parameters\n" |
3026 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 3027 | { |
d62a17ae | 3028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3029 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 3030 | return CMD_SUCCESS; |
43fc21b3 JC |
3031 | } |
3032 | ||
3033 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 3034 | no_bgp_graceful_restart_preserve_fw_cmd, |
3035 | "no bgp graceful-restart preserve-fw-state", | |
3036 | NO_STR | |
e9273987 | 3037 | BGP_STR |
2ba1fe69 | 3038 | "Graceful restart capability parameters\n" |
3039 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 3040 | { |
d62a17ae | 3041 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3042 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 3043 | return CMD_SUCCESS; |
43fc21b3 JC |
3044 | } |
3045 | ||
f2ca5c5b DA |
3046 | DEFPY (bgp_graceful_restart_notification, |
3047 | bgp_graceful_restart_notification_cmd, | |
3048 | "[no$no] bgp graceful-restart notification", | |
3049 | NO_STR | |
3050 | BGP_STR | |
3051 | "Graceful restart capability parameters\n" | |
3052 | "Indicate Graceful Restart support for BGP NOTIFICATION messages\n") | |
3053 | { | |
3054 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3055 | ||
3056 | if (no) | |
3057 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
3058 | else | |
3059 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
3060 | ||
3061 | return CMD_SUCCESS; | |
3062 | } | |
3063 | ||
1ae314be DA |
3064 | DEFPY (bgp_administrative_reset, |
3065 | bgp_administrative_reset_cmd, | |
3066 | "[no$no] bgp hard-administrative-reset", | |
3067 | NO_STR | |
3068 | BGP_STR | |
3069 | "Send Hard Reset CEASE Notification for 'Administrative Reset'\n") | |
3070 | { | |
3071 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3072 | ||
3073 | if (no) | |
3074 | UNSET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
3075 | else | |
3076 | SET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
3077 | ||
3078 | return CMD_SUCCESS; | |
3079 | } | |
3080 | ||
055679e9 | 3081 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 3082 | bgp_graceful_restart_disable_cmd, |
3083 | "bgp graceful-restart-disable", | |
e9273987 | 3084 | BGP_STR |
2ba1fe69 | 3085 | GR_DISABLE) |
055679e9 | 3086 | { |
3087 | int ret = BGP_GR_FAILURE; | |
3088 | ||
3089 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3090 | zlog_debug( | |
2ba1fe69 | 3091 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 3092 | |
055679e9 | 3093 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3094 | ||
3095 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
3096 | ||
dc95985f | 3097 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
3098 | bgp->peer, ret); | |
5cce3f05 | 3099 | |
055679e9 | 3100 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3101 | zlog_debug( | |
2ba1fe69 | 3102 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3103 | vty_out(vty, |
3104 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
3105 | ||
055679e9 | 3106 | return bgp_vty_return(vty, ret); |
3107 | } | |
3108 | ||
3109 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 3110 | no_bgp_graceful_restart_disable_cmd, |
3111 | "no bgp graceful-restart-disable", | |
3112 | NO_STR | |
e9273987 | 3113 | BGP_STR |
2ba1fe69 | 3114 | NO_GR_DISABLE |
055679e9 | 3115 | ) |
3116 | { | |
3117 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3118 | ||
3119 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3120 | zlog_debug( | |
2ba1fe69 | 3121 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 3122 | |
3123 | int ret = BGP_GR_FAILURE; | |
3124 | ||
3125 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
3126 | ||
36235319 QY |
3127 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
3128 | ret); | |
5cce3f05 | 3129 | |
055679e9 | 3130 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3131 | zlog_debug( | |
2ba1fe69 | 3132 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3133 | vty_out(vty, |
3134 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 3135 | |
3136 | return bgp_vty_return(vty, ret); | |
3137 | } | |
3138 | ||
3139 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 3140 | bgp_neighbor_graceful_restart_set_cmd, |
3141 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3142 | NEIGHBOR_STR | |
3143 | NEIGHBOR_ADDR_STR2 | |
3144 | GR_NEIGHBOR_CMD | |
055679e9 | 3145 | ) |
3146 | { | |
3147 | int idx_peer = 1; | |
3148 | struct peer *peer; | |
3149 | int ret = BGP_GR_FAILURE; | |
3150 | ||
dc95985f | 3151 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3152 | ||
055679e9 | 3153 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3154 | zlog_debug( | |
2ba1fe69 | 3155 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 3156 | |
055679e9 | 3157 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3158 | if (!peer) | |
3159 | return CMD_WARNING_CONFIG_FAILED; | |
3160 | ||
3161 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
3162 | ||
dc95985f | 3163 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3164 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3165 | |
3166 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3167 | zlog_debug( | |
2ba1fe69 | 3168 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3169 | vty_out(vty, |
3170 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3171 | |
3172 | return bgp_vty_return(vty, ret); | |
3173 | } | |
3174 | ||
3175 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 3176 | no_bgp_neighbor_graceful_restart_set_cmd, |
3177 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3178 | NO_STR | |
3179 | NEIGHBOR_STR | |
3180 | NEIGHBOR_ADDR_STR2 | |
3181 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 3182 | ) |
3183 | { | |
3184 | int idx_peer = 2; | |
3185 | int ret = BGP_GR_FAILURE; | |
3186 | struct peer *peer; | |
3187 | ||
dc95985f | 3188 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3189 | ||
055679e9 | 3190 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3191 | if (!peer) | |
3192 | return CMD_WARNING_CONFIG_FAILED; | |
3193 | ||
3194 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3195 | zlog_debug( | |
2ba1fe69 | 3196 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 3197 | |
3198 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
3199 | ||
dc95985f | 3200 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3201 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3202 | |
3203 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3204 | zlog_debug( | |
2ba1fe69 | 3205 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3206 | vty_out(vty, |
3207 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3208 | |
3209 | return bgp_vty_return(vty, ret); | |
3210 | } | |
3211 | ||
3212 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 3213 | bgp_neighbor_graceful_restart_helper_set_cmd, |
3214 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3215 | NEIGHBOR_STR | |
3216 | NEIGHBOR_ADDR_STR2 | |
3217 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3218 | ) |
3219 | { | |
3220 | int idx_peer = 1; | |
3221 | struct peer *peer; | |
3222 | int ret = BGP_GR_FAILURE; | |
3223 | ||
dc95985f | 3224 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3225 | ||
055679e9 | 3226 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3227 | zlog_debug( | |
2ba1fe69 | 3228 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 3229 | |
055679e9 | 3230 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3231 | ||
055679e9 | 3232 | if (!peer) |
3233 | return CMD_WARNING_CONFIG_FAILED; | |
3234 | ||
3235 | ||
3236 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 3237 | |
dc95985f | 3238 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3239 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 3240 | |
055679e9 | 3241 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3242 | zlog_debug( | |
2ba1fe69 | 3243 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3244 | vty_out(vty, |
3245 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3246 | |
3247 | return bgp_vty_return(vty, ret); | |
3248 | } | |
3249 | ||
3250 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 3251 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
3252 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3253 | NO_STR | |
3254 | NEIGHBOR_STR | |
3255 | NEIGHBOR_ADDR_STR2 | |
3256 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3257 | ) |
3258 | { | |
3259 | int idx_peer = 2; | |
3260 | int ret = BGP_GR_FAILURE; | |
3261 | struct peer *peer; | |
3262 | ||
dc95985f | 3263 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3264 | ||
055679e9 | 3265 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3266 | if (!peer) | |
3267 | return CMD_WARNING_CONFIG_FAILED; | |
3268 | ||
3269 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3270 | zlog_debug( | |
2ba1fe69 | 3271 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3272 | |
36235319 | 3273 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3274 | |
dc95985f | 3275 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3276 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3277 | |
3278 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3279 | zlog_debug( | |
2ba1fe69 | 3280 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3281 | vty_out(vty, |
3282 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3283 | |
3284 | return bgp_vty_return(vty, ret); | |
3285 | } | |
3286 | ||
3287 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3288 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3289 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3290 | NEIGHBOR_STR | |
3291 | NEIGHBOR_ADDR_STR2 | |
3292 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3293 | ) |
3294 | { | |
3295 | int idx_peer = 1; | |
3296 | struct peer *peer; | |
3297 | int ret = BGP_GR_FAILURE; | |
3298 | ||
dc95985f | 3299 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3300 | ||
055679e9 | 3301 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3302 | zlog_debug( | |
2ba1fe69 | 3303 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3304 | |
3305 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3306 | if (!peer) | |
3307 | return CMD_WARNING_CONFIG_FAILED; | |
3308 | ||
36235319 | 3309 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3310 | |
3311 | if (peer->bgp->t_startup) | |
3312 | bgp_peer_gr_flags_update(peer); | |
3313 | ||
dc95985f | 3314 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3315 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3316 | ||
055679e9 | 3317 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3318 | zlog_debug( | |
2ba1fe69 | 3319 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3320 | vty_out(vty, |
3321 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3322 | |
3323 | return bgp_vty_return(vty, ret); | |
3324 | } | |
3325 | ||
3326 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3327 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3328 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3329 | NO_STR | |
3330 | NEIGHBOR_STR | |
3331 | NEIGHBOR_ADDR_STR2 | |
3332 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3333 | ) |
3334 | { | |
3335 | int idx_peer = 2; | |
3336 | int ret = BGP_GR_FAILURE; | |
3337 | struct peer *peer; | |
3338 | ||
dc95985f | 3339 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3340 | ||
055679e9 | 3341 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3342 | if (!peer) | |
3343 | return CMD_WARNING_CONFIG_FAILED; | |
3344 | ||
3345 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3346 | zlog_debug( | |
2ba1fe69 | 3347 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3348 | |
3349 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3350 | ||
dc95985f | 3351 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3352 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3353 | |
3354 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3355 | zlog_debug( | |
2ba1fe69 | 3356 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3357 | vty_out(vty, |
3358 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3359 | |
3360 | return bgp_vty_return(vty, ret); | |
3361 | } | |
3362 | ||
4f770cf1 DA |
3363 | DEFPY (neighbor_graceful_shutdown, |
3364 | neighbor_graceful_shutdown_cmd, | |
3365 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown", | |
3366 | NO_STR | |
3367 | NEIGHBOR_STR | |
3368 | NEIGHBOR_ADDR_STR2 | |
3369 | "Graceful shutdown\n") | |
3370 | { | |
3371 | afi_t afi; | |
3372 | safi_t safi; | |
3373 | struct peer *peer; | |
3374 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3375 | int ret; | |
3376 | ||
3377 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
3378 | if (!peer) | |
3379 | return CMD_WARNING_CONFIG_FAILED; | |
3380 | ||
3381 | if (no) | |
3382 | ret = peer_flag_unset_vty(vty, neighbor, | |
3383 | PEER_FLAG_GRACEFUL_SHUTDOWN); | |
3384 | else | |
3385 | ret = peer_flag_set_vty(vty, neighbor, | |
3386 | PEER_FLAG_GRACEFUL_SHUTDOWN); | |
3387 | ||
3388 | FOREACH_AFI_SAFI (afi, safi) { | |
3389 | if (!peer->afc[afi][safi]) | |
3390 | continue; | |
3391 | ||
3392 | bgp_clear(vty, bgp, afi, safi, clear_peer, BGP_CLEAR_SOFT_IN, | |
3393 | neighbor); | |
3394 | } | |
3395 | ||
3396 | return ret; | |
3397 | } | |
3398 | ||
d6e3c15b | 3399 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3400 | bgp_graceful_restart_disable_eor_cmd, | |
3401 | "bgp graceful-restart disable-eor", | |
e9273987 | 3402 | BGP_STR |
d6e3c15b | 3403 | "Graceful restart configuration parameters\n" |
3404 | "Disable EOR Check\n") | |
3405 | { | |
3406 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3407 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3408 | |
d6e3c15b | 3409 | return CMD_SUCCESS; |
3410 | } | |
3411 | ||
3412 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3413 | no_bgp_graceful_restart_disable_eor_cmd, | |
3414 | "no bgp graceful-restart disable-eor", | |
3415 | NO_STR | |
e9273987 | 3416 | BGP_STR |
d6e3c15b | 3417 | "Graceful restart configuration parameters\n" |
3418 | "Disable EOR Check\n") | |
3419 | { | |
3420 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3421 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3422 | |
3423 | return CMD_SUCCESS; | |
3424 | } | |
3425 | ||
3426 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3427 | bgp_graceful_restart_rib_stale_time_cmd, | |
3428 | "bgp graceful-restart rib-stale-time (1-3600)", | |
e9273987 | 3429 | BGP_STR |
dc95985f | 3430 | "Graceful restart configuration parameters\n" |
3431 | "Specify the stale route removal timer in rib\n" | |
3432 | "Delay value (seconds)\n") | |
3433 | { | |
3434 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3435 | int idx_number = 3; | |
3436 | uint32_t stale_time; | |
3437 | ||
3438 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3439 | bgp->rib_stale_time = stale_time; | |
3440 | /* Send the stale timer update message to RIB */ | |
3441 | if (bgp_zebra_stale_timer_update(bgp)) | |
3442 | return CMD_WARNING; | |
3443 | ||
3444 | return CMD_SUCCESS; | |
3445 | } | |
3446 | ||
3447 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3448 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3449 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3450 | NO_STR | |
e9273987 | 3451 | BGP_STR |
dc95985f | 3452 | "Graceful restart configuration parameters\n" |
3453 | "Specify the stale route removal timer in rib\n" | |
3454 | "Delay value (seconds)\n") | |
3455 | { | |
3456 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3457 | ||
3458 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3459 | /* Send the stale timer update message to RIB */ | |
3460 | if (bgp_zebra_stale_timer_update(bgp)) | |
3461 | return CMD_WARNING; | |
3462 | ||
d6e3c15b | 3463 | return CMD_SUCCESS; |
3464 | } | |
3465 | ||
8606be87 | 3466 | DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd, |
5970204c | 3467 | "bgp long-lived-graceful-restart stale-time (1-16777215)", |
7f8a9a24 | 3468 | BGP_STR |
8606be87 DA |
3469 | "Enable Long-lived Graceful Restart\n" |
3470 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3471 | "Stale time value (seconds)\n") | |
3472 | { | |
3473 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3474 | ||
3475 | uint32_t llgr_stale_time; | |
3476 | ||
3477 | llgr_stale_time = strtoul(argv[3]->arg, NULL, 10); | |
3478 | bgp->llgr_stale_time = llgr_stale_time; | |
3479 | ||
3480 | return CMD_SUCCESS; | |
3481 | } | |
3482 | ||
3483 | DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd, | |
5970204c | 3484 | "no bgp long-lived-graceful-restart stale-time [(1-16777215)]", |
8606be87 DA |
3485 | NO_STR BGP_STR |
3486 | "Enable Long-lived Graceful Restart\n" | |
3487 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3488 | "Stale time value (seconds)\n") | |
3489 | { | |
3490 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3491 | ||
3492 | bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; | |
3493 | ||
3494 | return CMD_SUCCESS; | |
3495 | } | |
3496 | ||
1ca2fd11 IR |
3497 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3498 | struct bgp *bgp) | |
05bd726c | 3499 | { |
3500 | bgp_static_redo_import_check(bgp); | |
3501 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3502 | bgp_clear_star_soft_out(vty, bgp->name); |
3503 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3504 | } |
3505 | ||
3506 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3507 | { | |
3508 | struct listnode *node, *nnode; | |
3509 | struct bgp *bgp; | |
3510 | bool vrf_cfg = false; | |
3511 | ||
3512 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3513 | return CMD_SUCCESS; | |
3514 | ||
3515 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3516 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3517 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3518 | vty_out(vty, | |
3519 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3520 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3521 | VRF_DEFAULT_NAME : bgp->name); | |
3522 | vrf_cfg = true; | |
3523 | } | |
3524 | } | |
3525 | ||
3526 | if (vrf_cfg) { | |
3527 | vty_out(vty, | |
3528 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3529 | return CMD_WARNING; | |
3530 | } | |
3531 | ||
3532 | /* Set flag globally */ | |
3533 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3534 | ||
3535 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3536 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3537 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3538 | |
3539 | return CMD_SUCCESS; | |
3540 | } | |
3541 | ||
3542 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3543 | { | |
3544 | struct listnode *node, *nnode; | |
3545 | struct bgp *bgp; | |
3546 | ||
3547 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3548 | return CMD_SUCCESS; | |
3549 | ||
3550 | /* Unset flag globally */ | |
3551 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3552 | ||
3553 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3554 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3555 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3556 | |
3557 | return CMD_SUCCESS; | |
3558 | } | |
3559 | ||
7f323236 DW |
3560 | /* "bgp graceful-shutdown" configuration */ |
3561 | DEFUN (bgp_graceful_shutdown, | |
3562 | bgp_graceful_shutdown_cmd, | |
3563 | "bgp graceful-shutdown", | |
3564 | BGP_STR | |
3565 | "Graceful shutdown parameters\n") | |
3566 | { | |
05bd726c | 3567 | if (vty->node == CONFIG_NODE) |
3568 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3569 | ||
1ca2fd11 | 3570 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3571 | |
1ca2fd11 IR |
3572 | /* if configured globally, per-instance config is not allowed */ |
3573 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3574 | vty_out(vty, | |
3575 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3576 | return CMD_WARNING_CONFIG_FAILED; | |
3577 | } | |
3578 | ||
3579 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3580 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3581 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3582 | } | |
3583 | ||
3584 | return CMD_SUCCESS; | |
7f323236 DW |
3585 | } |
3586 | ||
1ca2fd11 | 3587 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3588 | no_bgp_graceful_shutdown_cmd, |
3589 | "no bgp graceful-shutdown", | |
3590 | NO_STR | |
3591 | BGP_STR | |
3592 | "Graceful shutdown parameters\n") | |
3593 | { | |
05bd726c | 3594 | if (vty->node == CONFIG_NODE) |
3595 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3596 | ||
1ca2fd11 | 3597 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3598 | |
1ca2fd11 IR |
3599 | /* If configured globally, cannot remove from one bgp instance */ |
3600 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3601 | vty_out(vty, | |
3602 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3603 | return CMD_WARNING_CONFIG_FAILED; | |
3604 | } | |
7f323236 | 3605 | |
1ca2fd11 IR |
3606 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3607 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3608 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3609 | } | |
3610 | ||
3611 | return CMD_SUCCESS; | |
7f323236 DW |
3612 | } |
3613 | ||
718e3744 | 3614 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3615 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3616 | bgp_fast_external_failover_cmd, |
3617 | "bgp fast-external-failover", | |
3618 | BGP_STR | |
3619 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3620 | { | |
1ca2fd11 IR |
3621 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3622 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3623 | return CMD_SUCCESS; | |
718e3744 | 3624 | } |
3625 | ||
1ca2fd11 | 3626 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3627 | no_bgp_fast_external_failover_cmd, |
3628 | "no bgp fast-external-failover", | |
3629 | NO_STR | |
3630 | BGP_STR | |
3631 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3632 | { | |
1ca2fd11 IR |
3633 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3634 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3635 | return CMD_SUCCESS; | |
718e3744 | 3636 | } |
6b0655a2 | 3637 | |
97a52c82 DA |
3638 | DEFPY (bgp_bestpath_aigp, |
3639 | bgp_bestpath_aigp_cmd, | |
3640 | "[no$no] bgp bestpath aigp", | |
3641 | NO_STR | |
3642 | BGP_STR | |
3643 | "Change the default bestpath selection\n" | |
3644 | "Evaluate the AIGP attribute during the best path selection process\n") | |
3645 | { | |
3646 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3647 | ||
3648 | if (no) | |
3649 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP); | |
3650 | else | |
3651 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP); | |
3652 | ||
3653 | bgp_recalculate_all_bestpaths(bgp); | |
3654 | ||
3655 | return CMD_SUCCESS; | |
3656 | } | |
3657 | ||
718e3744 | 3658 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3659 | DEFUN (bgp_bestpath_compare_router_id, |
3660 | bgp_bestpath_compare_router_id_cmd, | |
3661 | "bgp bestpath compare-routerid", | |
e9273987 | 3662 | BGP_STR |
1ca2fd11 IR |
3663 | "Change the default bestpath selection\n" |
3664 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3665 | { |
1ca2fd11 IR |
3666 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3667 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3668 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3669 | |
1ca2fd11 | 3670 | return CMD_SUCCESS; |
718e3744 | 3671 | } |
3672 | ||
1ca2fd11 IR |
3673 | DEFUN (no_bgp_bestpath_compare_router_id, |
3674 | no_bgp_bestpath_compare_router_id_cmd, | |
3675 | "no bgp bestpath compare-routerid", | |
3676 | NO_STR | |
e9273987 | 3677 | BGP_STR |
1ca2fd11 IR |
3678 | "Change the default bestpath selection\n" |
3679 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3680 | { |
1ca2fd11 IR |
3681 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3682 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3683 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3684 | |
1ca2fd11 | 3685 | return CMD_SUCCESS; |
718e3744 | 3686 | } |
6b0655a2 | 3687 | |
718e3744 | 3688 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3689 | DEFUN (bgp_bestpath_aspath_ignore, |
3690 | bgp_bestpath_aspath_ignore_cmd, | |
3691 | "bgp bestpath as-path ignore", | |
e9273987 | 3692 | BGP_STR |
1ca2fd11 IR |
3693 | "Change the default bestpath selection\n" |
3694 | "AS-path attribute\n" | |
3695 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3696 | { |
1ca2fd11 IR |
3697 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3698 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3699 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3700 | |
1ca2fd11 | 3701 | return CMD_SUCCESS; |
718e3744 | 3702 | } |
3703 | ||
1ca2fd11 IR |
3704 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3705 | no_bgp_bestpath_aspath_ignore_cmd, | |
3706 | "no bgp bestpath as-path ignore", | |
3707 | NO_STR | |
e9273987 | 3708 | BGP_STR |
1ca2fd11 IR |
3709 | "Change the default bestpath selection\n" |
3710 | "AS-path attribute\n" | |
3711 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3712 | { |
1ca2fd11 IR |
3713 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3714 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3715 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3716 | |
1ca2fd11 | 3717 | return CMD_SUCCESS; |
718e3744 | 3718 | } |
6b0655a2 | 3719 | |
6811845b | 3720 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3721 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3722 | bgp_bestpath_aspath_confed_cmd, |
3723 | "bgp bestpath as-path confed", | |
e9273987 | 3724 | BGP_STR |
6811845b | 3725 | "Change the default bestpath selection\n" |
3726 | "AS-path attribute\n" | |
3727 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3728 | { | |
1ca2fd11 IR |
3729 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3730 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3731 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3732 | |
1ca2fd11 | 3733 | return CMD_SUCCESS; |
6811845b | 3734 | } |
3735 | ||
1ca2fd11 | 3736 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3737 | no_bgp_bestpath_aspath_confed_cmd, |
3738 | "no bgp bestpath as-path confed", | |
3739 | NO_STR | |
e9273987 | 3740 | BGP_STR |
6811845b | 3741 | "Change the default bestpath selection\n" |
3742 | "AS-path attribute\n" | |
3743 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3744 | { | |
1ca2fd11 IR |
3745 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3746 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3747 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3748 | |
1ca2fd11 | 3749 | return CMD_SUCCESS; |
6811845b | 3750 | } |
6b0655a2 | 3751 | |
2fdd455c | 3752 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3753 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3754 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3755 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3756 | BGP_STR |
16fc1eec DS |
3757 | "Change the default bestpath selection\n" |
3758 | "AS-path attribute\n" | |
3759 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3760 | "Generate an AS_SET\n" |
16fc1eec DS |
3761 | "Do not generate an AS_SET\n") |
3762 | { | |
1ca2fd11 | 3763 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3764 | int idx = 0; |
1ca2fd11 | 3765 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3766 | |
1ca2fd11 IR |
3767 | /* no-as-set is now the default behavior so we can silently |
3768 | * ignore it */ | |
d62a17ae | 3769 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3770 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3771 | else |
1ca2fd11 | 3772 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3773 | |
1ca2fd11 IR |
3774 | bgp_recalculate_all_bestpaths(bgp); |
3775 | ||
3776 | return CMD_SUCCESS; | |
16fc1eec DS |
3777 | } |
3778 | ||
1ca2fd11 | 3779 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3780 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3781 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3782 | NO_STR |
e9273987 | 3783 | BGP_STR |
16fc1eec DS |
3784 | "Change the default bestpath selection\n" |
3785 | "AS-path attribute\n" | |
3786 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3787 | "Generate an AS_SET\n" |
16fc1eec DS |
3788 | "Do not generate an AS_SET\n") |
3789 | { | |
1ca2fd11 IR |
3790 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3791 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3792 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3793 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3794 | |
1ca2fd11 | 3795 | return CMD_SUCCESS; |
2fdd455c | 3796 | } |
6b0655a2 | 3797 | |
ee88563a JM |
3798 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3799 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3800 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3801 | "bgp bestpath peer-type multipath-relax", | |
3802 | BGP_STR | |
3803 | "Change the default bestpath selection\n" | |
3804 | "Peer type\n" | |
3805 | "Allow load sharing across routes learned from different peer types\n") | |
3806 | { | |
3807 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3808 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3809 | bgp_recalculate_all_bestpaths(bgp); | |
3810 | ||
3811 | return CMD_SUCCESS; | |
3812 | } | |
3813 | ||
3814 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3815 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3816 | "no bgp bestpath peer-type multipath-relax", | |
3817 | NO_STR BGP_STR | |
3818 | "Change the default bestpath selection\n" | |
3819 | "Peer type\n" | |
3820 | "Allow load sharing across routes learned from different peer types\n") | |
3821 | { | |
3822 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3823 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3824 | bgp_recalculate_all_bestpaths(bgp); | |
3825 | ||
3826 | return CMD_SUCCESS; | |
3827 | } | |
3828 | ||
848973c7 | 3829 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3830 | DEFUN (bgp_log_neighbor_changes, |
3831 | bgp_log_neighbor_changes_cmd, | |
3832 | "bgp log-neighbor-changes", | |
e9273987 | 3833 | BGP_STR |
1ca2fd11 | 3834 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3835 | { |
1ca2fd11 IR |
3836 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3837 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3838 | return CMD_SUCCESS; | |
848973c7 | 3839 | } |
3840 | ||
1ca2fd11 IR |
3841 | DEFUN (no_bgp_log_neighbor_changes, |
3842 | no_bgp_log_neighbor_changes_cmd, | |
3843 | "no bgp log-neighbor-changes", | |
3844 | NO_STR | |
e9273987 | 3845 | BGP_STR |
1ca2fd11 | 3846 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3847 | { |
1ca2fd11 IR |
3848 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3849 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3850 | return CMD_SUCCESS; | |
848973c7 | 3851 | } |
6b0655a2 | 3852 | |
718e3744 | 3853 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3854 | DEFUN (bgp_bestpath_med, |
718e3744 | 3855 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3856 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3857 | BGP_STR |
718e3744 | 3858 | "Change the default bestpath selection\n" |
3859 | "MED attribute\n" | |
3860 | "Compare MED among confederation paths\n" | |
838758ac DW |
3861 | "Treat missing MED as the least preferred one\n" |
3862 | "Treat missing MED as the least preferred one\n" | |
3863 | "Compare MED among confederation paths\n") | |
718e3744 | 3864 | { |
1ca2fd11 | 3865 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3866 | |
1ca2fd11 | 3867 | int idx = 0; |
d62a17ae | 3868 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3869 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3870 | idx = 0; |
3871 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3872 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3873 | |
1ca2fd11 | 3874 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3875 | |
1ca2fd11 | 3876 | return CMD_SUCCESS; |
718e3744 | 3877 | } |
3878 | ||
1ca2fd11 | 3879 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3880 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3881 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3882 | NO_STR |
e9273987 | 3883 | BGP_STR |
718e3744 | 3884 | "Change the default bestpath selection\n" |
3885 | "MED attribute\n" | |
3886 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3887 | "Treat missing MED as the least preferred one\n" |
3888 | "Treat missing MED as the least preferred one\n" | |
3889 | "Compare MED among confederation paths\n") | |
718e3744 | 3890 | { |
1ca2fd11 | 3891 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3892 | |
1ca2fd11 | 3893 | int idx = 0; |
d62a17ae | 3894 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3895 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3896 | idx = 0; |
3897 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3898 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3899 | ||
3900 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3901 | |
1ca2fd11 | 3902 | return CMD_SUCCESS; |
718e3744 | 3903 | } |
3904 | ||
f7e1c681 | 3905 | /* "bgp bestpath bandwidth" configuration. */ |
3906 | DEFPY (bgp_bestpath_bw, | |
3907 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3908 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3909 | BGP_STR |
f7e1c681 | 3910 | "Change the default bestpath selection\n" |
3911 | "Link Bandwidth attribute\n" | |
3912 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3913 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3914 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3915 | { | |
3916 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3917 | afi_t afi; | |
3918 | safi_t safi; | |
3919 | ||
ad36d216 DS |
3920 | if (!bw_cfg) { |
3921 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3922 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3923 | } |
ad36d216 DS |
3924 | if (!strcmp(bw_cfg, "ignore")) |
3925 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3926 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3927 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3928 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3929 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3930 | else | |
3931 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3932 | |
3933 | /* This config is used in route install, so redo that. */ | |
3934 | FOREACH_AFI_SAFI (afi, safi) { | |
3935 | if (!bgp_fibupd_safi(safi)) | |
3936 | continue; | |
3937 | bgp_zebra_announce_table(bgp, afi, safi); | |
3938 | } | |
3939 | ||
3940 | return CMD_SUCCESS; | |
3941 | } | |
3942 | ||
ad36d216 DS |
3943 | DEFPY (no_bgp_bestpath_bw, |
3944 | no_bgp_bestpath_bw_cmd, | |
3945 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3946 | NO_STR | |
e9273987 | 3947 | BGP_STR |
ad36d216 DS |
3948 | "Change the default bestpath selection\n" |
3949 | "Link Bandwidth attribute\n" | |
3950 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3951 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3952 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3953 | { | |
3954 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3955 | afi_t afi; | |
3956 | safi_t safi; | |
3957 | ||
3958 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3959 | ||
3960 | /* This config is used in route install, so redo that. */ | |
3961 | FOREACH_AFI_SAFI (afi, safi) { | |
3962 | if (!bgp_fibupd_safi(safi)) | |
3963 | continue; | |
3964 | bgp_zebra_announce_table(bgp, afi, safi); | |
3965 | } | |
3966 | return CMD_SUCCESS; | |
3967 | } | |
3968 | ||
b16bcbba | 3969 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3970 | "[no] bgp default <ipv4-unicast|" |
3971 | "ipv4-multicast|" | |
3972 | "ipv4-vpn|" | |
3973 | "ipv4-labeled-unicast|" | |
3974 | "ipv4-flowspec|" | |
3975 | "ipv6-unicast|" | |
3976 | "ipv6-multicast|" | |
3977 | "ipv6-vpn|" | |
3978 | "ipv6-labeled-unicast|" | |
3979 | "ipv6-flowspec|" | |
3980 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3981 | NO_STR |
e9273987 | 3982 | BGP_STR |
e84c59af | 3983 | "Configure BGP defaults\n" |
b16bcbba | 3984 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3985 | "Activate ipv4-multicast for a peer by default\n" |
3986 | "Activate ipv4-vpn for a peer by default\n" | |
3987 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3988 | "Activate ipv4-flowspec for a peer by default\n" | |
3989 | "Activate ipv6-unicast for a peer by default\n" | |
3990 | "Activate ipv6-multicast for a peer by default\n" | |
3991 | "Activate ipv6-vpn for a peer by default\n" | |
3992 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3993 | "Activate ipv6-flowspec for a peer by default\n" | |
3994 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3995 | { |
3996 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3997 | char afi_safi_str[strlen(afi_safi) + 1]; |
3998 | char *afi_safi_str_tok; | |
e84c59af | 3999 | |
b16bcbba TA |
4000 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
4001 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
4002 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
4003 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 4004 | safi_t safi; |
e84c59af | 4005 | |
d880a643 DS |
4006 | /* |
4007 | * Impossible situation but making coverity happy | |
4008 | */ | |
4009 | assert(afi != AFI_MAX); | |
4010 | ||
38d11af5 TA |
4011 | if (strmatch(safi_str, "labeled")) |
4012 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
4013 | else | |
4014 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba | 4015 | |
f609bcd6 | 4016 | assert(safi != SAFI_MAX); |
b16bcbba TA |
4017 | if (no) |
4018 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
4019 | else { |
4020 | if ((safi == SAFI_LABELED_UNICAST | |
4021 | && bgp->default_af[afi][SAFI_UNICAST]) | |
4022 | || (safi == SAFI_UNICAST | |
4023 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
4024 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
4025 | else | |
4026 | bgp->default_af[afi][safi] = true; | |
4027 | } | |
718e3744 | 4028 | |
d62a17ae | 4029 | return CMD_SUCCESS; |
718e3744 | 4030 | } |
6b0655a2 | 4031 | |
04b6bdc0 | 4032 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 4033 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
4034 | bgp_default_show_hostname_cmd, |
4035 | "bgp default show-hostname", | |
e9273987 | 4036 | BGP_STR |
04b6bdc0 | 4037 | "Configure BGP defaults\n" |
0437e105 | 4038 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 4039 | { |
1ca2fd11 IR |
4040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4041 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
4042 | return CMD_SUCCESS; | |
ff8a8a7a CS |
4043 | } |
4044 | ||
1ca2fd11 IR |
4045 | DEFUN (no_bgp_default_show_hostname, |
4046 | no_bgp_default_show_hostname_cmd, | |
4047 | "no bgp default show-hostname", | |
4048 | NO_STR | |
e9273987 | 4049 | BGP_STR |
1ca2fd11 IR |
4050 | "Configure BGP defaults\n" |
4051 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 4052 | { |
1ca2fd11 IR |
4053 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4054 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
4055 | return CMD_SUCCESS; | |
04b6bdc0 DW |
4056 | } |
4057 | ||
aef999a2 | 4058 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
4059 | DEFUN (bgp_default_show_nexthop_hostname, |
4060 | bgp_default_show_nexthop_hostname_cmd, | |
4061 | "bgp default show-nexthop-hostname", | |
e9273987 | 4062 | BGP_STR |
1d80f243 IR |
4063 | "Configure BGP defaults\n" |
4064 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 4065 | { |
1ca2fd11 IR |
4066 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4067 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
4068 | return CMD_SUCCESS; | |
aef999a2 DA |
4069 | } |
4070 | ||
4071 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
4072 | no_bgp_default_show_nexthop_hostname_cmd, | |
4073 | "no bgp default show-nexthop-hostname", | |
4074 | NO_STR | |
e9273987 | 4075 | BGP_STR |
aef999a2 DA |
4076 | "Configure BGP defaults\n" |
4077 | "Show hostname for nexthop in certain command outputs\n") | |
4078 | { | |
1ca2fd11 IR |
4079 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4080 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
4081 | return CMD_SUCCESS; | |
aef999a2 DA |
4082 | } |
4083 | ||
8233ef81 | 4084 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
4085 | DEFUN (bgp_network_import_check, |
4086 | bgp_network_import_check_cmd, | |
4087 | "bgp network import-check", | |
e9273987 | 4088 | BGP_STR |
1ca2fd11 IR |
4089 | "BGP network command\n" |
4090 | "Check BGP network route exists in IGP\n") | |
718e3744 | 4091 | { |
1ca2fd11 IR |
4092 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4093 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
4094 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
4095 | bgp_static_redo_import_check(bgp); | |
4096 | } | |
078430f6 | 4097 | |
1ca2fd11 | 4098 | return CMD_SUCCESS; |
718e3744 | 4099 | } |
4100 | ||
d62a17ae | 4101 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
4102 | "bgp network import-check exact", | |
e9273987 | 4103 | BGP_STR |
d62a17ae | 4104 | "BGP network command\n" |
4105 | "Check BGP network route exists in IGP\n" | |
4106 | "Match route precisely\n") | |
8233ef81 | 4107 | |
1ca2fd11 IR |
4108 | DEFUN (no_bgp_network_import_check, |
4109 | no_bgp_network_import_check_cmd, | |
4110 | "no bgp network import-check", | |
4111 | NO_STR | |
e9273987 | 4112 | BGP_STR |
1ca2fd11 IR |
4113 | "BGP network command\n" |
4114 | "Check BGP network route exists in IGP\n") | |
718e3744 | 4115 | { |
1ca2fd11 IR |
4116 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4117 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
4118 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
4119 | bgp_static_redo_import_check(bgp); | |
4120 | } | |
6b0655a2 | 4121 | |
1ca2fd11 | 4122 | return CMD_SUCCESS; |
ff8a8a7a | 4123 | } |
718e3744 | 4124 | |
1ca2fd11 IR |
4125 | DEFUN (bgp_default_local_preference, |
4126 | bgp_default_local_preference_cmd, | |
4127 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 4128 | BGP_STR |
1ca2fd11 IR |
4129 | "Configure BGP defaults\n" |
4130 | "local preference (higher=more preferred)\n" | |
4131 | "Configure default local preference value\n") | |
ff8a8a7a | 4132 | { |
1ca2fd11 | 4133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 4134 | int idx_number = 3; |
1ca2fd11 | 4135 | uint32_t local_pref; |
718e3744 | 4136 | |
1ca2fd11 | 4137 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 4138 | |
1ca2fd11 IR |
4139 | bgp_default_local_preference_set(bgp, local_pref); |
4140 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 4141 | |
1ca2fd11 | 4142 | return CMD_SUCCESS; |
718e3744 | 4143 | } |
4144 | ||
1ca2fd11 IR |
4145 | DEFUN (no_bgp_default_local_preference, |
4146 | no_bgp_default_local_preference_cmd, | |
4147 | "no bgp default local-preference [(0-4294967295)]", | |
4148 | NO_STR | |
e9273987 | 4149 | BGP_STR |
1ca2fd11 IR |
4150 | "Configure BGP defaults\n" |
4151 | "local preference (higher=more preferred)\n" | |
4152 | "Configure default local preference value\n") | |
ff8a8a7a | 4153 | { |
1ca2fd11 IR |
4154 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4155 | bgp_default_local_preference_unset(bgp); | |
4156 | bgp_clear_star_soft_in(vty, bgp->name); | |
4157 | ||
4158 | return CMD_SUCCESS; | |
ff8a8a7a | 4159 | } |
6b0655a2 | 4160 | |
ff8a8a7a | 4161 | |
1ca2fd11 IR |
4162 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
4163 | bgp_default_subgroup_pkt_queue_max_cmd, | |
4164 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 4165 | BGP_STR |
1ca2fd11 IR |
4166 | "Configure BGP defaults\n" |
4167 | "subgroup-pkt-queue-max\n" | |
4168 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 4169 | { |
1ca2fd11 | 4170 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4171 | int idx_number = 3; |
1ca2fd11 | 4172 | uint32_t max_size; |
3f9c7369 | 4173 | |
1ca2fd11 | 4174 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 4175 | |
1ca2fd11 | 4176 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 4177 | |
1ca2fd11 | 4178 | return CMD_SUCCESS; |
8bd9d948 DS |
4179 | } |
4180 | ||
1ca2fd11 IR |
4181 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
4182 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
4183 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
4184 | NO_STR | |
e9273987 | 4185 | BGP_STR |
1ca2fd11 IR |
4186 | "Configure BGP defaults\n" |
4187 | "subgroup-pkt-queue-max\n" | |
4188 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 4189 | { |
1ca2fd11 IR |
4190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4191 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
4192 | return CMD_SUCCESS; | |
ff8a8a7a | 4193 | } |
813d4307 | 4194 | |
8bd9d948 | 4195 | |
1ca2fd11 IR |
4196 | DEFUN (bgp_rr_allow_outbound_policy, |
4197 | bgp_rr_allow_outbound_policy_cmd, | |
4198 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 4199 | BGP_STR |
1ca2fd11 IR |
4200 | "Allow modifications made by out route-map\n" |
4201 | "on ibgp neighbors\n") | |
ff8a8a7a | 4202 | { |
1ca2fd11 | 4203 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 4204 | |
1ca2fd11 IR |
4205 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4206 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4207 | update_group_announce_rrclients(bgp); | |
4208 | bgp_clear_star_soft_out(vty, bgp->name); | |
4209 | } | |
8bd9d948 | 4210 | |
1ca2fd11 IR |
4211 | return CMD_SUCCESS; |
4212 | } | |
ff8a8a7a | 4213 | |
1ca2fd11 IR |
4214 | DEFUN (no_bgp_rr_allow_outbound_policy, |
4215 | no_bgp_rr_allow_outbound_policy_cmd, | |
4216 | "no bgp route-reflector allow-outbound-policy", | |
4217 | NO_STR | |
e9273987 | 4218 | BGP_STR |
1ca2fd11 IR |
4219 | "Allow modifications made by out route-map\n" |
4220 | "on ibgp neighbors\n") | |
8bd9d948 | 4221 | { |
1ca2fd11 | 4222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 4223 | |
1ca2fd11 IR |
4224 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4225 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4226 | update_group_announce_rrclients(bgp); | |
4227 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 4228 | } |
8bd9d948 | 4229 | |
1ca2fd11 | 4230 | return CMD_SUCCESS; |
8bd9d948 DS |
4231 | } |
4232 | ||
1ca2fd11 IR |
4233 | DEFUN (bgp_listen_limit, |
4234 | bgp_listen_limit_cmd, | |
4235 | "bgp listen limit (1-65535)", | |
e9273987 | 4236 | BGP_STR |
1ca2fd11 IR |
4237 | "BGP Dynamic Neighbors listen commands\n" |
4238 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4239 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4240 | { |
1ca2fd11 | 4241 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4242 | int idx_number = 3; |
1ca2fd11 IR |
4243 | int listen_limit; |
4244 | ||
4245 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 4246 | |
1ca2fd11 | 4247 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 4248 | |
1ca2fd11 | 4249 | return CMD_SUCCESS; |
f14e6fdb DS |
4250 | } |
4251 | ||
1ca2fd11 IR |
4252 | DEFUN (no_bgp_listen_limit, |
4253 | no_bgp_listen_limit_cmd, | |
4254 | "no bgp listen limit [(1-65535)]", | |
4255 | NO_STR | |
e9273987 | 4256 | BGP_STR |
1ca2fd11 IR |
4257 | "BGP Dynamic Neighbors listen commands\n" |
4258 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4259 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4260 | { |
1ca2fd11 IR |
4261 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4262 | bgp_listen_limit_unset(bgp); | |
4263 | return CMD_SUCCESS; | |
f14e6fdb DS |
4264 | } |
4265 | ||
4266 | ||
20eb8864 | 4267 | /* |
4268 | * Check if this listen range is already configured. Check for exact | |
4269 | * match or overlap based on input. | |
4270 | */ | |
d62a17ae | 4271 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
4272 | struct prefix *range, int exact) | |
4273 | { | |
4274 | struct listnode *node, *nnode; | |
4275 | struct listnode *node1, *nnode1; | |
4276 | struct peer_group *group; | |
4277 | struct prefix *lr; | |
4278 | afi_t afi; | |
4279 | int match; | |
4280 | ||
4281 | afi = family2afi(range->family); | |
4282 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4283 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
4284 | lr)) { | |
4285 | if (exact) | |
4286 | match = prefix_same(range, lr); | |
4287 | else | |
4288 | match = (prefix_match(range, lr) | |
4289 | || prefix_match(lr, range)); | |
4290 | if (match) | |
4291 | return group; | |
4292 | } | |
4293 | } | |
4294 | ||
4295 | return NULL; | |
20eb8864 | 4296 | } |
4297 | ||
f14e6fdb DS |
4298 | DEFUN (bgp_listen_range, |
4299 | bgp_listen_range_cmd, | |
d7b9898c | 4300 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 4301 | BGP_STR |
d7fa34c1 QY |
4302 | "Configure BGP dynamic neighbors listen range\n" |
4303 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
4304 | NEIGHBOR_ADDR_STR |
4305 | "Member of the peer-group\n" | |
4306 | "Peer-group name\n") | |
f14e6fdb | 4307 | { |
d62a17ae | 4308 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4309 | struct prefix range; | |
4310 | struct peer_group *group, *existing_group; | |
4311 | afi_t afi; | |
4312 | int ret; | |
4313 | int idx = 0; | |
4314 | ||
4315 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4316 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4317 | char *prefix = argv[idx]->arg; | |
d7b9898c | 4318 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4319 | char *peergroup = argv[idx]->arg; |
4320 | ||
4321 | /* Convert IP prefix string to struct prefix. */ | |
4322 | ret = str2prefix(prefix, &range); | |
4323 | if (!ret) { | |
4324 | vty_out(vty, "%% Malformed listen range\n"); | |
4325 | return CMD_WARNING_CONFIG_FAILED; | |
4326 | } | |
4327 | ||
4328 | afi = family2afi(range.family); | |
4329 | ||
4330 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4331 | vty_out(vty, | |
4332 | "%% Malformed listen range (link-local address)\n"); | |
4333 | return CMD_WARNING_CONFIG_FAILED; | |
4334 | } | |
4335 | ||
4336 | apply_mask(&range); | |
4337 | ||
4338 | /* Check if same listen range is already configured. */ | |
4339 | existing_group = listen_range_exists(bgp, &range, 1); | |
4340 | if (existing_group) { | |
4341 | if (strcmp(existing_group->name, peergroup) == 0) | |
4342 | return CMD_SUCCESS; | |
4343 | else { | |
4344 | vty_out(vty, | |
4345 | "%% Same listen range is attached to peer-group %s\n", | |
4346 | existing_group->name); | |
4347 | return CMD_WARNING_CONFIG_FAILED; | |
4348 | } | |
4349 | } | |
4350 | ||
4351 | /* Check if an overlapping listen range exists. */ | |
4352 | if (listen_range_exists(bgp, &range, 0)) { | |
4353 | vty_out(vty, | |
4354 | "%% Listen range overlaps with existing listen range\n"); | |
4355 | return CMD_WARNING_CONFIG_FAILED; | |
4356 | } | |
4357 | ||
4358 | group = peer_group_lookup(bgp, peergroup); | |
4359 | if (!group) { | |
4360 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4361 | return CMD_WARNING_CONFIG_FAILED; | |
4362 | } | |
4363 | ||
4364 | ret = peer_group_listen_range_add(group, &range); | |
4365 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4366 | } |
4367 | ||
4368 | DEFUN (no_bgp_listen_range, | |
4369 | no_bgp_listen_range_cmd, | |
d7b9898c | 4370 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4371 | NO_STR |
e9273987 | 4372 | BGP_STR |
d7fa34c1 QY |
4373 | "Unconfigure BGP dynamic neighbors listen range\n" |
4374 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4375 | NEIGHBOR_ADDR_STR | |
4376 | "Member of the peer-group\n" | |
4377 | "Peer-group name\n") | |
f14e6fdb | 4378 | { |
d62a17ae | 4379 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4380 | struct prefix range; | |
4381 | struct peer_group *group; | |
4382 | afi_t afi; | |
4383 | int ret; | |
4384 | int idx = 0; | |
4385 | ||
4386 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4387 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4388 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4389 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4390 | char *peergroup = argv[idx]->arg; |
4391 | ||
4392 | /* Convert IP prefix string to struct prefix. */ | |
4393 | ret = str2prefix(prefix, &range); | |
4394 | if (!ret) { | |
4395 | vty_out(vty, "%% Malformed listen range\n"); | |
4396 | return CMD_WARNING_CONFIG_FAILED; | |
4397 | } | |
4398 | ||
4399 | afi = family2afi(range.family); | |
4400 | ||
4401 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4402 | vty_out(vty, | |
4403 | "%% Malformed listen range (link-local address)\n"); | |
4404 | return CMD_WARNING_CONFIG_FAILED; | |
4405 | } | |
4406 | ||
4407 | apply_mask(&range); | |
4408 | ||
4409 | group = peer_group_lookup(bgp, peergroup); | |
4410 | if (!group) { | |
4411 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4412 | return CMD_WARNING_CONFIG_FAILED; | |
4413 | } | |
4414 | ||
4415 | ret = peer_group_listen_range_del(group, &range); | |
4416 | return bgp_vty_return(vty, ret); | |
4417 | } | |
4418 | ||
2b791107 | 4419 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4420 | { |
4421 | struct peer_group *group; | |
4422 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4423 | struct prefix *range; | |
4424 | afi_t afi; | |
d62a17ae | 4425 | |
4426 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4427 | vty_out(vty, " bgp listen limit %d\n", | |
4428 | bgp->dynamic_neighbors_limit); | |
4429 | ||
4430 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4431 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4432 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4433 | nrnode, range)) { | |
d62a17ae | 4434 | vty_out(vty, |
2dbe669b DA |
4435 | " bgp listen range %pFX peer-group %s\n", |
4436 | range, group->name); | |
d62a17ae | 4437 | } |
4438 | } | |
4439 | } | |
f14e6fdb DS |
4440 | } |
4441 | ||
4442 | ||
1ca2fd11 IR |
4443 | DEFUN (bgp_disable_connected_route_check, |
4444 | bgp_disable_connected_route_check_cmd, | |
4445 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4446 | BGP_STR |
1ca2fd11 | 4447 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4448 | { |
1ca2fd11 IR |
4449 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4450 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4451 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4452 | |
1ca2fd11 | 4453 | return CMD_SUCCESS; |
907f92c8 DS |
4454 | } |
4455 | ||
1ca2fd11 IR |
4456 | DEFUN (no_bgp_disable_connected_route_check, |
4457 | no_bgp_disable_connected_route_check_cmd, | |
4458 | "no bgp disable-ebgp-connected-route-check", | |
4459 | NO_STR | |
e9273987 | 4460 | BGP_STR |
1ca2fd11 | 4461 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4462 | { |
1ca2fd11 IR |
4463 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4464 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4465 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4466 | |
1ca2fd11 | 4467 | return CMD_SUCCESS; |
d62a17ae | 4468 | } |
4469 | ||
4470 | ||
28c6e247 IR |
4471 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4472 | const char *as_str) | |
4473 | { | |
4474 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4475 | int ret; | |
4476 | as_t as; | |
4477 | int as_type = AS_SPECIFIED; | |
4478 | union sockunion su; | |
4479 | ||
4480 | if (as_str[0] == 'i') { | |
4481 | as = 0; | |
4482 | as_type = AS_INTERNAL; | |
4483 | } else if (as_str[0] == 'e') { | |
4484 | as = 0; | |
4485 | as_type = AS_EXTERNAL; | |
4486 | } else { | |
4487 | /* Get AS number. */ | |
4488 | as = strtoul(as_str, NULL, 10); | |
4489 | } | |
4490 | ||
4491 | /* If peer is peer group or interface peer, call proper function. */ | |
4492 | ret = str2sockunion(peer_str, &su); | |
4493 | if (ret < 0) { | |
4494 | struct peer *peer; | |
4495 | ||
4496 | /* Check if existing interface peer */ | |
4497 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4498 | ||
4499 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4500 | ||
4501 | /* if not interface peer, check peer-group settings */ | |
4502 | if (ret < 0 && !peer) { | |
4503 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4504 | if (ret < 0) { | |
4505 | vty_out(vty, | |
4506 | "%% Create the peer-group or interface first\n"); | |
4507 | return CMD_WARNING_CONFIG_FAILED; | |
4508 | } | |
4509 | return CMD_SUCCESS; | |
4510 | } | |
4511 | } else { | |
4512 | if (peer_address_self_check(bgp, &su)) { | |
4513 | vty_out(vty, | |
4514 | "%% Can not configure the local system as neighbor\n"); | |
4515 | return CMD_WARNING_CONFIG_FAILED; | |
4516 | } | |
4517 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4518 | } | |
4519 | ||
28c6e247 IR |
4520 | return bgp_vty_return(vty, ret); |
4521 | } | |
4522 | ||
1ca2fd11 IR |
4523 | DEFUN (bgp_default_shutdown, |
4524 | bgp_default_shutdown_cmd, | |
4525 | "[no] bgp default shutdown", | |
4526 | NO_STR | |
4527 | BGP_STR | |
4528 | "Configure BGP defaults\n" | |
4529 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4530 | { |
1ca2fd11 IR |
4531 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4532 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4533 | return CMD_SUCCESS; | |
f26845f9 QY |
4534 | } |
4535 | ||
736b68f3 DS |
4536 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4537 | BGP_STR | |
9ddf4b81 | 4538 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4539 | "Add a shutdown message (RFC 8203)\n" |
4540 | "Shutdown message\n") | |
9cf59432 | 4541 | { |
736b68f3 | 4542 | char *msgstr = NULL; |
8389c83a | 4543 | |
9cf59432 DS |
4544 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4545 | ||
8389c83a | 4546 | if (argc > 3) |
f80e35b6 | 4547 | msgstr = argv_concat(argv, argc, 3); |
8389c83a | 4548 | |
b776f48c DA |
4549 | if (msgstr && strlen(msgstr) > BGP_ADMIN_SHUTDOWN_MSG_LEN) { |
4550 | vty_out(vty, "%% Shutdown message size exceeded %d\n", | |
4551 | BGP_ADMIN_SHUTDOWN_MSG_LEN); | |
4552 | return CMD_WARNING_CONFIG_FAILED; | |
4553 | } | |
4554 | ||
8389c83a DS |
4555 | bgp_shutdown_enable(bgp, msgstr); |
4556 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4557 | |
4558 | return CMD_SUCCESS; | |
4559 | } | |
4560 | ||
736b68f3 | 4561 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4562 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4563 | { |
4564 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4565 | ||
4566 | bgp_shutdown_enable(bgp, NULL); | |
4567 | ||
4568 | return CMD_SUCCESS; | |
4569 | } | |
8389c83a | 4570 | |
736b68f3 | 4571 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4572 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4573 | { |
4574 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4575 | ||
4576 | bgp_shutdown_disable(bgp); | |
4577 | ||
4578 | return CMD_SUCCESS; | |
4579 | } | |
4580 | ||
9ddf4b81 | 4581 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4582 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4583 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4584 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4585 | |
28c6e247 IR |
4586 | DEFUN (neighbor_remote_as, |
4587 | neighbor_remote_as_cmd, | |
4588 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4589 | NEIGHBOR_STR | |
4590 | NEIGHBOR_ADDR_STR2 | |
4591 | "Specify a BGP neighbor\n" | |
4592 | AS_STR | |
4593 | "Internal BGP peer\n" | |
4594 | "External BGP peer\n") | |
718e3744 | 4595 | { |
d62a17ae | 4596 | int idx_peer = 1; |
4597 | int idx_remote_as = 3; | |
28c6e247 IR |
4598 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4599 | argv[idx_remote_as]->arg); | |
d62a17ae | 4600 | } |
8666265e DS |
4601 | |
4602 | DEFPY (bgp_allow_martian, | |
4603 | bgp_allow_martian_cmd, | |
4604 | "[no]$no bgp allow-martian-nexthop", | |
4605 | NO_STR | |
4606 | BGP_STR | |
4607 | "Allow Martian nexthops to be received in the NLRI from a peer\n") | |
4608 | { | |
4609 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4610 | ||
4611 | if (no) | |
4612 | bgp->allow_martian = false; | |
4613 | else | |
4614 | bgp->allow_martian = true; | |
4615 | ||
4616 | return CMD_SUCCESS; | |
4617 | } | |
4618 | ||
f852eb98 PG |
4619 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4620 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4621 | * when nexthop becomes unreachable | |
4622 | */ | |
4623 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4624 | BGP_STR "Fast convergence for bgp sessions\n") | |
4625 | { | |
4626 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4627 | bgp->fast_convergence = true; | |
4628 | ||
4629 | return CMD_SUCCESS; | |
4630 | } | |
4631 | ||
4632 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4633 | "no bgp fast-convergence", | |
4634 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4635 | { | |
4636 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4637 | bgp->fast_convergence = false; | |
4638 | ||
4639 | return CMD_SUCCESS; | |
4640 | } | |
d62a17ae | 4641 | |
28c6e247 IR |
4642 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4643 | int v6only, | |
4644 | const char *peer_group_name, | |
4645 | const char *as_str) | |
d62a17ae | 4646 | { |
28c6e247 IR |
4647 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4648 | as_t as = 0; | |
4649 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4650 | struct peer *peer; |
4651 | struct peer_group *group; | |
4652 | int ret = 0; | |
d62a17ae | 4653 | |
4654 | group = peer_group_lookup(bgp, conf_if); | |
4655 | ||
4656 | if (group) { | |
28c6e247 IR |
4657 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4658 | return CMD_WARNING_CONFIG_FAILED; | |
4659 | } | |
4660 | ||
4661 | if (as_str) { | |
4662 | if (as_str[0] == 'i') { | |
4663 | as_type = AS_INTERNAL; | |
4664 | } else if (as_str[0] == 'e') { | |
4665 | as_type = AS_EXTERNAL; | |
4666 | } else { | |
4667 | /* Get AS number. */ | |
4668 | as = strtoul(as_str, NULL, 10); | |
4669 | as_type = AS_SPECIFIED; | |
4670 | } | |
d62a17ae | 4671 | } |
4672 | ||
4673 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4674 | if (peer) { | |
28c6e247 | 4675 | if (as_str) |
e84c59af | 4676 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4677 | } else { |
e84c59af | 4678 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
534db980 | 4679 | NULL, true); |
d62a17ae | 4680 | |
4681 | if (!peer) { | |
28c6e247 IR |
4682 | vty_out(vty, "%% BGP failed to create peer\n"); |
4683 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4684 | } |
4685 | ||
4686 | if (v6only) | |
527de3dc | 4687 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4688 | |
4689 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4690 | * this | |
4691 | * any unnumbered peer in order to not worry about run-time | |
4692 | * transitions | |
4693 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4694 | * address | |
4695 | * gets deleted later etc.) | |
4696 | */ | |
4697 | if (peer->ifp) | |
4698 | bgp_zebra_initiate_radv(bgp, peer); | |
4699 | } | |
4700 | ||
4701 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4702 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4703 | if (v6only) | |
527de3dc | 4704 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4705 | else |
527de3dc | 4706 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4707 | |
4708 | /* v6only flag changed. Reset bgp seesion */ | |
4709 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4710 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4711 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4712 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4713 | } else | |
4714 | bgp_session_reset(peer); | |
4715 | } | |
4716 | ||
9fb964de PM |
4717 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4718 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4719 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4720 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4721 | } |
d62a17ae | 4722 | |
4723 | if (peer_group_name) { | |
4724 | group = peer_group_lookup(bgp, peer_group_name); | |
4725 | if (!group) { | |
28c6e247 IR |
4726 | vty_out(vty, "%% Configure the peer-group first\n"); |
4727 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4728 | } |
4729 | ||
8395c1f8 | 4730 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4731 | } |
4732 | ||
28c6e247 | 4733 | return bgp_vty_return(vty, ret); |
a80beece DS |
4734 | } |
4735 | ||
28c6e247 IR |
4736 | DEFUN (neighbor_interface_config, |
4737 | neighbor_interface_config_cmd, | |
4738 | "neighbor WORD interface [peer-group PGNAME]", | |
4739 | NEIGHBOR_STR | |
4740 | "Interface name or neighbor tag\n" | |
4741 | "Enable BGP on interface\n" | |
4742 | "Member of the peer-group\n" | |
4743 | "Peer-group name\n") | |
4c48cf63 | 4744 | { |
d62a17ae | 4745 | int idx_word = 1; |
4746 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4747 | |
d62a17ae | 4748 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4749 | return peer_conf_interface_get( |
4750 | vty, argv[idx_word]->arg, 0, | |
4751 | argv[idx_peer_group_word]->arg, NULL); | |
4752 | else | |
4753 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4754 | NULL, NULL); | |
4c48cf63 DW |
4755 | } |
4756 | ||
28c6e247 IR |
4757 | DEFUN (neighbor_interface_config_v6only, |
4758 | neighbor_interface_config_v6only_cmd, | |
4759 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4760 | NEIGHBOR_STR | |
4761 | "Interface name or neighbor tag\n" | |
4762 | "Enable BGP on interface\n" | |
4763 | "Enable BGP with v6 link-local only\n" | |
4764 | "Member of the peer-group\n" | |
4765 | "Peer-group name\n") | |
4c48cf63 | 4766 | { |
d62a17ae | 4767 | int idx_word = 1; |
4768 | int idx_peer_group_word = 5; | |
31500417 | 4769 | |
d62a17ae | 4770 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4771 | return peer_conf_interface_get( |
4772 | vty, argv[idx_word]->arg, 1, | |
4773 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4774 | |
28c6e247 | 4775 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4776 | } |
4777 | ||
a80beece | 4778 | |
28c6e247 IR |
4779 | DEFUN (neighbor_interface_config_remote_as, |
4780 | neighbor_interface_config_remote_as_cmd, | |
4781 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4782 | NEIGHBOR_STR | |
4783 | "Interface name or neighbor tag\n" | |
4784 | "Enable BGP on interface\n" | |
4785 | "Specify a BGP neighbor\n" | |
4786 | AS_STR | |
4787 | "Internal BGP peer\n" | |
4788 | "External BGP peer\n") | |
b3a39dc5 | 4789 | { |
d62a17ae | 4790 | int idx_word = 1; |
4791 | int idx_remote_as = 4; | |
28c6e247 IR |
4792 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4793 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4794 | } |
4795 | ||
28c6e247 IR |
4796 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4797 | neighbor_interface_v6only_config_remote_as_cmd, | |
4798 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4799 | NEIGHBOR_STR | |
4800 | "Interface name or neighbor tag\n" | |
4801 | "Enable BGP with v6 link-local only\n" | |
4802 | "Enable BGP on interface\n" | |
4803 | "Specify a BGP neighbor\n" | |
4804 | AS_STR | |
4805 | "Internal BGP peer\n" | |
4806 | "External BGP peer\n") | |
b3a39dc5 | 4807 | { |
d62a17ae | 4808 | int idx_word = 1; |
4809 | int idx_remote_as = 5; | |
28c6e247 IR |
4810 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4811 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4812 | } |
4813 | ||
28c6e247 IR |
4814 | DEFUN (neighbor_peer_group, |
4815 | neighbor_peer_group_cmd, | |
4816 | "neighbor WORD peer-group", | |
4817 | NEIGHBOR_STR | |
4818 | "Interface name or neighbor tag\n" | |
4819 | "Configure peer-group\n") | |
718e3744 | 4820 | { |
28c6e247 | 4821 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4822 | int idx_word = 1; |
28c6e247 IR |
4823 | struct peer *peer; |
4824 | struct peer_group *group; | |
718e3744 | 4825 | |
28c6e247 IR |
4826 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4827 | if (peer) { | |
4828 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4829 | return CMD_WARNING_CONFIG_FAILED; | |
4830 | } | |
718e3744 | 4831 | |
28c6e247 IR |
4832 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4833 | if (!group) { | |
4834 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4835 | return CMD_WARNING_CONFIG_FAILED; | |
4836 | } | |
718e3744 | 4837 | |
28c6e247 | 4838 | return CMD_SUCCESS; |
718e3744 | 4839 | } |
4840 | ||
1d80f243 IR |
4841 | DEFUN (no_neighbor, |
4842 | no_neighbor_cmd, | |
4843 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4844 | NO_STR | |
4845 | NEIGHBOR_STR | |
4846 | NEIGHBOR_ADDR_STR2 | |
4847 | "Specify a BGP neighbor\n" | |
4848 | AS_STR | |
4849 | "Internal BGP peer\n" | |
4850 | "External BGP peer\n") | |
718e3744 | 4851 | { |
28c6e247 | 4852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4853 | int idx_peer = 2; |
28c6e247 | 4854 | int ret; |
d62a17ae | 4855 | union sockunion su; |
28c6e247 IR |
4856 | struct peer_group *group; |
4857 | struct peer *peer; | |
4858 | struct peer *other; | |
d62a17ae | 4859 | |
28c6e247 IR |
4860 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4861 | if (ret < 0) { | |
4862 | /* look up for neighbor by interface name config. */ | |
4863 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4864 | if (peer) { | |
4865 | /* Request zebra to terminate IPv6 RAs on this | |
4866 | * interface. */ | |
4867 | if (peer->ifp) | |
4868 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4869 | peer_notify_unconfig(peer); | |
4870 | peer_delete(peer); | |
4871 | return CMD_SUCCESS; | |
d62a17ae | 4872 | } |
28c6e247 IR |
4873 | |
4874 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4875 | if (group) { | |
4876 | peer_group_notify_unconfig(group); | |
4877 | peer_group_delete(group); | |
4e2786df | 4878 | } else { |
28c6e247 | 4879 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4880 | return CMD_WARNING_CONFIG_FAILED; |
4881 | } | |
28c6e247 IR |
4882 | } else { |
4883 | peer = peer_lookup(bgp, &su); | |
4884 | if (peer) { | |
4885 | if (peer_dynamic_neighbor(peer)) { | |
4886 | vty_out(vty, | |
4887 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4888 | return CMD_WARNING_CONFIG_FAILED; | |
4889 | } | |
d62a17ae | 4890 | |
28c6e247 | 4891 | other = peer->doppelganger; |
f4b8ec07 | 4892 | |
28c6e247 IR |
4893 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4894 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4895 | |
28c6e247 IR |
4896 | peer_notify_unconfig(peer); |
4897 | peer_delete(peer); | |
4898 | if (other && other->status != Deleted) { | |
4899 | peer_notify_unconfig(other); | |
4900 | peer_delete(other); | |
4901 | } | |
4902 | } | |
4903 | } | |
4904 | ||
4905 | return CMD_SUCCESS; | |
a80beece DS |
4906 | } |
4907 | ||
28c6e247 IR |
4908 | DEFUN (no_neighbor_interface_config, |
4909 | no_neighbor_interface_config_cmd, | |
4910 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4911 | NO_STR | |
4912 | NEIGHBOR_STR | |
4913 | "Interface name\n" | |
4914 | "Configure BGP on interface\n" | |
4915 | "Enable BGP with v6 link-local only\n" | |
4916 | "Member of the peer-group\n" | |
4917 | "Peer-group name\n" | |
4918 | "Specify a BGP neighbor\n" | |
4919 | AS_STR | |
4920 | "Internal BGP peer\n" | |
4921 | "External BGP peer\n") | |
718e3744 | 4922 | { |
28c6e247 | 4923 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4924 | int idx_word = 2; |
28c6e247 | 4925 | struct peer *peer; |
718e3744 | 4926 | |
28c6e247 IR |
4927 | /* look up for neighbor by interface name config. */ |
4928 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4929 | if (peer) { | |
4930 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4931 | if (peer->ifp) | |
4932 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4933 | peer_notify_unconfig(peer); | |
4934 | peer_delete(peer); | |
4935 | } else { | |
4936 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4937 | return CMD_WARNING_CONFIG_FAILED; | |
4938 | } | |
4939 | return CMD_SUCCESS; | |
718e3744 | 4940 | } |
4941 | ||
28c6e247 IR |
4942 | DEFUN (no_neighbor_peer_group, |
4943 | no_neighbor_peer_group_cmd, | |
4944 | "no neighbor WORD peer-group", | |
4945 | NO_STR | |
4946 | NEIGHBOR_STR | |
4947 | "Neighbor tag\n" | |
4948 | "Configure peer-group\n") | |
718e3744 | 4949 | { |
28c6e247 IR |
4950 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4951 | int idx_word = 2; | |
4952 | struct peer_group *group; | |
f4b8ec07 | 4953 | |
28c6e247 IR |
4954 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4955 | if (group) { | |
4956 | peer_group_notify_unconfig(group); | |
4957 | peer_group_delete(group); | |
f4b8ec07 | 4958 | } else { |
28c6e247 | 4959 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4960 | return CMD_WARNING_CONFIG_FAILED; |
4961 | } | |
28c6e247 IR |
4962 | return CMD_SUCCESS; |
4963 | } | |
f4b8ec07 | 4964 | |
28c6e247 IR |
4965 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4966 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4967 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4968 | NO_STR | |
4969 | NEIGHBOR_STR | |
4970 | "Interface name or neighbor tag\n" | |
4971 | "Specify a BGP neighbor\n" | |
4972 | AS_STR | |
4973 | "Internal BGP peer\n" | |
4974 | "External BGP peer\n") | |
4975 | { | |
4976 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4977 | int idx_word = 2; | |
4978 | struct peer_group *group; | |
4979 | struct peer *peer; | |
f4b8ec07 | 4980 | |
28c6e247 IR |
4981 | /* look up for neighbor by interface name config. */ |
4982 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4983 | if (peer) { | |
4984 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4985 | return CMD_SUCCESS; | |
4986 | } | |
f4b8ec07 | 4987 | |
28c6e247 IR |
4988 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4989 | if (group) | |
4990 | peer_group_remote_as_delete(group); | |
4991 | else { | |
4992 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4993 | return CMD_WARNING_CONFIG_FAILED; | |
4994 | } | |
4995 | return CMD_SUCCESS; | |
718e3744 | 4996 | } |
6b0655a2 | 4997 | |
28c6e247 IR |
4998 | DEFUN (neighbor_local_as, |
4999 | neighbor_local_as_cmd, | |
5000 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
5001 | NEIGHBOR_STR | |
5002 | NEIGHBOR_ADDR_STR2 | |
5003 | "Specify a local-as number\n" | |
5004 | "AS number used as local AS\n") | |
718e3744 | 5005 | { |
d62a17ae | 5006 | int idx_peer = 1; |
5007 | int idx_number = 3; | |
28c6e247 IR |
5008 | struct peer *peer; |
5009 | int ret; | |
5010 | as_t as; | |
718e3744 | 5011 | |
28c6e247 IR |
5012 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5013 | if (!peer) | |
d62a17ae | 5014 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5015 | |
28c6e247 IR |
5016 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
5017 | ret = peer_local_as_set(peer, as, 0, 0); | |
5018 | return bgp_vty_return(vty, ret); | |
718e3744 | 5019 | } |
5020 | ||
28c6e247 IR |
5021 | DEFUN (neighbor_local_as_no_prepend, |
5022 | neighbor_local_as_no_prepend_cmd, | |
5023 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
5024 | NEIGHBOR_STR | |
5025 | NEIGHBOR_ADDR_STR2 | |
5026 | "Specify a local-as number\n" | |
5027 | "AS number used as local AS\n" | |
5028 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 5029 | { |
d62a17ae | 5030 | int idx_peer = 1; |
5031 | int idx_number = 3; | |
28c6e247 IR |
5032 | struct peer *peer; |
5033 | int ret; | |
5034 | as_t as; | |
718e3744 | 5035 | |
28c6e247 IR |
5036 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5037 | if (!peer) | |
d62a17ae | 5038 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5039 | |
28c6e247 IR |
5040 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
5041 | ret = peer_local_as_set(peer, as, 1, 0); | |
5042 | return bgp_vty_return(vty, ret); | |
718e3744 | 5043 | } |
5044 | ||
28c6e247 IR |
5045 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
5046 | neighbor_local_as_no_prepend_replace_as_cmd, | |
5047 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
5048 | NEIGHBOR_STR | |
5049 | NEIGHBOR_ADDR_STR2 | |
5050 | "Specify a local-as number\n" | |
5051 | "AS number used as local AS\n" | |
5052 | "Do not prepend local-as to updates from ebgp peers\n" | |
5053 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 5054 | { |
d62a17ae | 5055 | int idx_peer = 1; |
5056 | int idx_number = 3; | |
28c6e247 IR |
5057 | struct peer *peer; |
5058 | int ret; | |
5059 | as_t as; | |
9d3f9705 | 5060 | |
28c6e247 IR |
5061 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5062 | if (!peer) | |
d62a17ae | 5063 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 5064 | |
28c6e247 IR |
5065 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
5066 | ret = peer_local_as_set(peer, as, 1, 1); | |
5067 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
5068 | } |
5069 | ||
28c6e247 IR |
5070 | DEFUN (no_neighbor_local_as, |
5071 | no_neighbor_local_as_cmd, | |
5072 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
5073 | NO_STR | |
5074 | NEIGHBOR_STR | |
5075 | NEIGHBOR_ADDR_STR2 | |
5076 | "Specify a local-as number\n" | |
5077 | "AS number used as local AS\n" | |
5078 | "Do not prepend local-as to updates from ebgp peers\n" | |
5079 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 5080 | { |
d62a17ae | 5081 | int idx_peer = 2; |
28c6e247 IR |
5082 | struct peer *peer; |
5083 | int ret; | |
718e3744 | 5084 | |
28c6e247 IR |
5085 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5086 | if (!peer) | |
d62a17ae | 5087 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5088 | |
28c6e247 IR |
5089 | ret = peer_local_as_unset(peer); |
5090 | return bgp_vty_return(vty, ret); | |
718e3744 | 5091 | } |
5092 | ||
718e3744 | 5093 | |
3f9c7369 DS |
5094 | DEFUN (neighbor_solo, |
5095 | neighbor_solo_cmd, | |
9ccf14f7 | 5096 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
5097 | NEIGHBOR_STR |
5098 | NEIGHBOR_ADDR_STR2 | |
5099 | "Solo peer - part of its own update group\n") | |
5100 | { | |
d62a17ae | 5101 | int idx_peer = 1; |
5102 | struct peer *peer; | |
5103 | int ret; | |
3f9c7369 | 5104 | |
d62a17ae | 5105 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5106 | if (!peer) | |
5107 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 5108 | |
d62a17ae | 5109 | ret = update_group_adjust_soloness(peer, 1); |
5110 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
5111 | } |
5112 | ||
5113 | DEFUN (no_neighbor_solo, | |
5114 | no_neighbor_solo_cmd, | |
9ccf14f7 | 5115 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
5116 | NO_STR |
5117 | NEIGHBOR_STR | |
5118 | NEIGHBOR_ADDR_STR2 | |
5119 | "Solo peer - part of its own update group\n") | |
5120 | { | |
d62a17ae | 5121 | int idx_peer = 2; |
5122 | struct peer *peer; | |
5123 | int ret; | |
3f9c7369 | 5124 | |
d62a17ae | 5125 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5126 | if (!peer) | |
5127 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 5128 | |
d62a17ae | 5129 | ret = update_group_adjust_soloness(peer, 0); |
5130 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
5131 | } |
5132 | ||
28c6e247 IR |
5133 | DEFUN (neighbor_password, |
5134 | neighbor_password_cmd, | |
5135 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
5136 | NEIGHBOR_STR | |
5137 | NEIGHBOR_ADDR_STR2 | |
5138 | "Set a password\n" | |
5139 | "The password\n") | |
0df7c91f | 5140 | { |
d62a17ae | 5141 | int idx_peer = 1; |
5142 | int idx_line = 3; | |
28c6e247 IR |
5143 | struct peer *peer; |
5144 | int ret; | |
0df7c91f | 5145 | |
28c6e247 IR |
5146 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5147 | if (!peer) | |
d62a17ae | 5148 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5149 | |
28c6e247 IR |
5150 | ret = peer_password_set(peer, argv[idx_line]->arg); |
5151 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
5152 | } |
5153 | ||
28c6e247 IR |
5154 | DEFUN (no_neighbor_password, |
5155 | no_neighbor_password_cmd, | |
5156 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
5157 | NO_STR | |
5158 | NEIGHBOR_STR | |
5159 | NEIGHBOR_ADDR_STR2 | |
5160 | "Set a password\n" | |
5161 | "The password\n") | |
0df7c91f | 5162 | { |
d62a17ae | 5163 | int idx_peer = 2; |
28c6e247 IR |
5164 | struct peer *peer; |
5165 | int ret; | |
0df7c91f | 5166 | |
28c6e247 IR |
5167 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5168 | if (!peer) | |
d62a17ae | 5169 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5170 | |
28c6e247 IR |
5171 | ret = peer_password_unset(peer); |
5172 | return bgp_vty_return(vty, ret); | |
0df7c91f | 5173 | } |
6b0655a2 | 5174 | |
28c6e247 IR |
5175 | DEFUN (neighbor_activate, |
5176 | neighbor_activate_cmd, | |
5177 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5178 | NEIGHBOR_STR | |
5179 | NEIGHBOR_ADDR_STR2 | |
5180 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5181 | { |
d62a17ae | 5182 | int idx_peer = 1; |
28c6e247 IR |
5183 | int ret; |
5184 | struct peer *peer; | |
56ceae84 | 5185 | |
28c6e247 IR |
5186 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5187 | if (!peer) | |
d62a17ae | 5188 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5189 | |
28c6e247 IR |
5190 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
5191 | return bgp_vty_return(vty, ret); | |
718e3744 | 5192 | } |
5193 | ||
d62a17ae | 5194 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
5195 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5196 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5197 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5198 | |
28c6e247 IR |
5199 | DEFUN (no_neighbor_activate, |
5200 | no_neighbor_activate_cmd, | |
5201 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5202 | NO_STR | |
5203 | NEIGHBOR_STR | |
5204 | NEIGHBOR_ADDR_STR2 | |
5205 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5206 | { |
d62a17ae | 5207 | int idx_peer = 2; |
28c6e247 IR |
5208 | int ret; |
5209 | struct peer *peer; | |
f4b8ec07 | 5210 | |
28c6e247 IR |
5211 | /* Lookup peer. */ |
5212 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5213 | if (!peer) | |
d62a17ae | 5214 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5215 | |
28c6e247 IR |
5216 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
5217 | return bgp_vty_return(vty, ret); | |
718e3744 | 5218 | } |
6b0655a2 | 5219 | |
d62a17ae | 5220 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
5221 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5222 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5223 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5224 | |
28c6e247 IR |
5225 | DEFUN (neighbor_set_peer_group, |
5226 | neighbor_set_peer_group_cmd, | |
5227 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5228 | NEIGHBOR_STR | |
5229 | NEIGHBOR_ADDR_STR2 | |
5230 | "Member of the peer-group\n" | |
5231 | "Peer-group name\n") | |
718e3744 | 5232 | { |
28c6e247 | 5233 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5234 | int idx_peer = 1; |
5235 | int idx_word = 3; | |
28c6e247 IR |
5236 | int ret; |
5237 | as_t as; | |
5238 | union sockunion su; | |
5239 | struct peer *peer; | |
5240 | struct peer_group *group; | |
5241 | ||
5242 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
5243 | if (ret < 0) { | |
5244 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
5245 | if (!peer) { | |
5246 | vty_out(vty, "%% Malformed address or name: %s\n", | |
5247 | argv[idx_peer]->arg); | |
5248 | return CMD_WARNING_CONFIG_FAILED; | |
5249 | } | |
5250 | } else { | |
5251 | if (peer_address_self_check(bgp, &su)) { | |
5252 | vty_out(vty, | |
5253 | "%% Can not configure the local system as neighbor\n"); | |
5254 | return CMD_WARNING_CONFIG_FAILED; | |
5255 | } | |
2a059a54 | 5256 | |
28c6e247 IR |
5257 | /* Disallow for dynamic neighbor. */ |
5258 | peer = peer_lookup(bgp, &su); | |
5259 | if (peer && peer_dynamic_neighbor(peer)) { | |
5260 | vty_out(vty, | |
5261 | "%% Operation not allowed on a dynamic neighbor\n"); | |
5262 | return CMD_WARNING_CONFIG_FAILED; | |
5263 | } | |
5264 | } | |
5265 | ||
5266 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
5267 | if (!group) { | |
5268 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 5269 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 5270 | } |
d62a17ae | 5271 | |
28c6e247 | 5272 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 5273 | |
28c6e247 | 5274 | return bgp_vty_return(vty, ret); |
d62a17ae | 5275 | } |
5276 | ||
5277 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 5278 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5279 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5280 | "Member of the peer-group\n" | |
5281 | "Peer-group name\n") | |
596c17ba | 5282 | |
28c6e247 IR |
5283 | DEFUN (no_neighbor_set_peer_group, |
5284 | no_neighbor_set_peer_group_cmd, | |
5285 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5286 | NO_STR | |
5287 | NEIGHBOR_STR | |
5288 | NEIGHBOR_ADDR_STR2 | |
5289 | "Member of the peer-group\n" | |
5290 | "Peer-group name\n") | |
718e3744 | 5291 | { |
28c6e247 | 5292 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5293 | int idx_peer = 2; |
28c6e247 IR |
5294 | int idx_word = 4; |
5295 | int ret; | |
5296 | struct peer *peer; | |
5297 | struct peer_group *group; | |
d62a17ae | 5298 | |
28c6e247 IR |
5299 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
5300 | if (!peer) | |
d62a17ae | 5301 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 5302 | |
28c6e247 IR |
5303 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
5304 | if (!group) { | |
5305 | vty_out(vty, "%% Configure the peer-group first\n"); | |
5306 | return CMD_WARNING_CONFIG_FAILED; | |
5307 | } | |
718e3744 | 5308 | |
28c6e247 IR |
5309 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
5310 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
5311 | ||
5312 | peer_notify_unconfig(peer); | |
5313 | ret = peer_delete(peer); | |
5314 | ||
5315 | return bgp_vty_return(vty, ret); | |
718e3744 | 5316 | } |
6b0655a2 | 5317 | |
d62a17ae | 5318 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 5319 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5320 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5321 | "Member of the peer-group\n" | |
5322 | "Peer-group name\n") | |
596c17ba | 5323 | |
718e3744 | 5324 | /* neighbor passive. */ |
28c6e247 IR |
5325 | DEFUN (neighbor_passive, |
5326 | neighbor_passive_cmd, | |
5327 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5328 | NEIGHBOR_STR | |
5329 | NEIGHBOR_ADDR_STR2 | |
5330 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5331 | { |
d62a17ae | 5332 | int idx_peer = 1; |
28c6e247 | 5333 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5334 | } |
5335 | ||
28c6e247 IR |
5336 | DEFUN (no_neighbor_passive, |
5337 | no_neighbor_passive_cmd, | |
5338 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5339 | NO_STR | |
5340 | NEIGHBOR_STR | |
5341 | NEIGHBOR_ADDR_STR2 | |
5342 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5343 | { |
d62a17ae | 5344 | int idx_peer = 2; |
28c6e247 | 5345 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5346 | } |
6b0655a2 | 5347 | |
718e3744 | 5348 | /* neighbor shutdown. */ |
28c6e247 IR |
5349 | DEFUN (neighbor_shutdown_msg, |
5350 | neighbor_shutdown_msg_cmd, | |
5351 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5352 | NEIGHBOR_STR | |
5353 | NEIGHBOR_ADDR_STR2 | |
5354 | "Administratively shut down this neighbor\n" | |
5355 | "Add a shutdown message (RFC 8203)\n" | |
5356 | "Shutdown message\n") | |
718e3744 | 5357 | { |
d62a17ae | 5358 | int idx_peer = 1; |
73d70fa6 | 5359 | |
d62a17ae | 5360 | if (argc >= 5) { |
28c6e247 IR |
5361 | struct peer *peer = |
5362 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 5363 | char *message; |
73d70fa6 | 5364 | |
28c6e247 IR |
5365 | if (!peer) |
5366 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5367 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
5368 | peer_tx_shutdown_message_set(peer, message); |
5369 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 5370 | } |
73d70fa6 | 5371 | |
28c6e247 | 5372 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5373 | } |
5374 | ||
1d80f243 | 5375 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5376 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5377 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5378 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5379 | |
28c6e247 IR |
5380 | DEFUN (no_neighbor_shutdown_msg, |
5381 | no_neighbor_shutdown_msg_cmd, | |
5382 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5383 | NO_STR | |
5384 | NEIGHBOR_STR | |
5385 | NEIGHBOR_ADDR_STR2 | |
5386 | "Administratively shut down this neighbor\n" | |
5387 | "Remove a shutdown message (RFC 8203)\n" | |
5388 | "Shutdown message\n") | |
718e3744 | 5389 | { |
d62a17ae | 5390 | int idx_peer = 2; |
73d70fa6 | 5391 | |
28c6e247 IR |
5392 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5393 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5394 | } |
6b0655a2 | 5395 | |
1d80f243 | 5396 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5397 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5398 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5399 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5400 | |
8336c896 DA |
5401 | DEFUN(neighbor_shutdown_rtt, |
5402 | neighbor_shutdown_rtt_cmd, | |
5403 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5404 | NEIGHBOR_STR | |
5405 | NEIGHBOR_ADDR_STR2 | |
5406 | "Administratively shut down this neighbor\n" | |
5407 | "Shutdown if round-trip-time is higher than expected\n" | |
5408 | "Round-trip-time in milliseconds\n" | |
5409 | "Specify the number of keepalives before shutdown\n" | |
5410 | "The number of keepalives with higher RTT to shutdown\n") | |
5411 | { | |
5412 | int idx_peer = 1; | |
5413 | int idx_rtt = 4; | |
5414 | int idx_count = 0; | |
5415 | struct peer *peer; | |
5416 | ||
5417 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5418 | ||
5419 | if (!peer) | |
5420 | return CMD_WARNING_CONFIG_FAILED; | |
5421 | ||
5422 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5423 | ||
5424 | if (argv_find(argv, argc, "count", &idx_count)) | |
5425 | peer->rtt_keepalive_conf = | |
5426 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5427 | ||
5428 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5429 | PEER_FLAG_RTT_SHUTDOWN); | |
5430 | } | |
5431 | ||
5432 | DEFUN(no_neighbor_shutdown_rtt, | |
5433 | no_neighbor_shutdown_rtt_cmd, | |
5434 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5435 | NO_STR | |
5436 | NEIGHBOR_STR | |
5437 | NEIGHBOR_ADDR_STR2 | |
5438 | "Administratively shut down this neighbor\n" | |
5439 | "Shutdown if round-trip-time is higher than expected\n" | |
5440 | "Round-trip-time in milliseconds\n" | |
5441 | "Specify the number of keepalives before shutdown\n" | |
5442 | "The number of keepalives with higher RTT to shutdown\n") | |
5443 | { | |
5444 | int idx_peer = 2; | |
5445 | struct peer *peer; | |
5446 | ||
5447 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5448 | ||
5449 | if (!peer) | |
5450 | return CMD_WARNING_CONFIG_FAILED; | |
5451 | ||
5452 | peer->rtt_expected = 0; | |
5453 | peer->rtt_keepalive_conf = 1; | |
5454 | ||
5455 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5456 | PEER_FLAG_RTT_SHUTDOWN); | |
5457 | } | |
5458 | ||
718e3744 | 5459 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5460 | DEFUN (neighbor_capability_dynamic, |
5461 | neighbor_capability_dynamic_cmd, | |
5462 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5463 | NEIGHBOR_STR | |
5464 | NEIGHBOR_ADDR_STR2 | |
5465 | "Advertise capability to the peer\n" | |
5466 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5467 | { |
d62a17ae | 5468 | int idx_peer = 1; |
28c6e247 IR |
5469 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5470 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5471 | } |
5472 | ||
28c6e247 IR |
5473 | DEFUN (no_neighbor_capability_dynamic, |
5474 | no_neighbor_capability_dynamic_cmd, | |
5475 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5476 | NO_STR | |
5477 | NEIGHBOR_STR | |
5478 | NEIGHBOR_ADDR_STR2 | |
5479 | "Advertise capability to the peer\n" | |
5480 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5481 | { |
d62a17ae | 5482 | int idx_peer = 2; |
28c6e247 IR |
5483 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5484 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5485 | } |
6b0655a2 | 5486 | |
718e3744 | 5487 | /* neighbor dont-capability-negotiate */ |
5488 | DEFUN (neighbor_dont_capability_negotiate, | |
5489 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5490 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5491 | NEIGHBOR_STR |
5492 | NEIGHBOR_ADDR_STR2 | |
5493 | "Do not perform capability negotiation\n") | |
5494 | { | |
d62a17ae | 5495 | int idx_peer = 1; |
5496 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5497 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5498 | } |
5499 | ||
5500 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5501 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5502 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5503 | NO_STR |
5504 | NEIGHBOR_STR | |
5505 | NEIGHBOR_ADDR_STR2 | |
5506 | "Do not perform capability negotiation\n") | |
5507 | { | |
28c6e247 IR |
5508 | int idx_peer = 2; |
5509 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5510 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5511 | } |
5512 | ||
28c6e247 IR |
5513 | /* neighbor capability extended next hop encoding */ |
5514 | DEFUN (neighbor_capability_enhe, | |
5515 | neighbor_capability_enhe_cmd, | |
5516 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5517 | NEIGHBOR_STR | |
5518 | NEIGHBOR_ADDR_STR2 | |
5519 | "Advertise capability to the peer\n" | |
5520 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5521 | { |
28c6e247 | 5522 | int idx_peer = 1; |
c4786405 DS |
5523 | struct peer *peer; |
5524 | ||
5525 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5526 | if (peer && peer->conf_if) | |
5527 | return CMD_SUCCESS; | |
5528 | ||
28c6e247 IR |
5529 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5530 | PEER_FLAG_CAPABILITY_ENHE); | |
5531 | } | |
f4b8ec07 | 5532 | |
28c6e247 IR |
5533 | DEFUN (no_neighbor_capability_enhe, |
5534 | no_neighbor_capability_enhe_cmd, | |
5535 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5536 | NO_STR | |
5537 | NEIGHBOR_STR | |
5538 | NEIGHBOR_ADDR_STR2 | |
5539 | "Advertise capability to the peer\n" | |
5540 | "Advertise extended next-hop capability to the peer\n") | |
5541 | { | |
5542 | int idx_peer = 2; | |
c4786405 DS |
5543 | struct peer *peer; |
5544 | ||
5545 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5546 | if (peer && peer->conf_if) { | |
5547 | vty_out(vty, | |
5548 | "Peer %s cannot have capability extended-nexthop turned off\n", | |
5549 | argv[idx_peer]->arg); | |
5550 | return CMD_WARNING_CONFIG_FAILED; | |
5551 | } | |
5552 | ||
28c6e247 IR |
5553 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5554 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5555 | } |
5556 | ||
d62a17ae | 5557 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5558 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5559 | int set) |
718e3744 | 5560 | { |
d62a17ae | 5561 | int ret; |
5562 | struct peer *peer; | |
718e3744 | 5563 | |
d62a17ae | 5564 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5565 | if (!peer) | |
5566 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5567 | |
d62a17ae | 5568 | if (set) |
5569 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5570 | else | |
5571 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5572 | |
d62a17ae | 5573 | return bgp_vty_return(vty, ret); |
718e3744 | 5574 | } |
5575 | ||
d62a17ae | 5576 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5577 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5578 | { |
d62a17ae | 5579 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5580 | } |
5581 | ||
d62a17ae | 5582 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5583 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5584 | { |
d62a17ae | 5585 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5586 | } |
6b0655a2 | 5587 | |
718e3744 | 5588 | /* neighbor capability orf prefix-list. */ |
5589 | DEFUN (neighbor_capability_orf_prefix, | |
5590 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5591 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5592 | NEIGHBOR_STR |
5593 | NEIGHBOR_ADDR_STR2 | |
5594 | "Advertise capability to the peer\n" | |
5595 | "Advertise ORF capability to the peer\n" | |
5596 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5597 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5598 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5599 | "Capability to SEND the ORF to this neighbor\n") | |
5600 | { | |
d62a17ae | 5601 | int idx_send_recv = 5; |
db45f64d DS |
5602 | char *peer_str = argv[1]->arg; |
5603 | struct peer *peer; | |
5604 | afi_t afi = bgp_node_afi(vty); | |
5605 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5606 | |
db45f64d DS |
5607 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5608 | if (!peer) | |
d62a17ae | 5609 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5610 | |
db45f64d DS |
5611 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5612 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5613 | PEER_FLAG_ORF_PREFIX_SM); | |
5614 | ||
5615 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5616 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5617 | PEER_FLAG_ORF_PREFIX_RM); | |
5618 | ||
5619 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5620 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5621 | PEER_FLAG_ORF_PREFIX_SM) | |
5622 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5623 | PEER_FLAG_ORF_PREFIX_RM); | |
5624 | ||
5625 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5626 | } |
5627 | ||
5628 | ALIAS_HIDDEN( | |
5629 | neighbor_capability_orf_prefix, | |
5630 | neighbor_capability_orf_prefix_hidden_cmd, | |
5631 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5632 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5633 | "Advertise capability to the peer\n" | |
5634 | "Advertise ORF capability to the peer\n" | |
5635 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5636 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5637 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5638 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5639 | |
718e3744 | 5640 | DEFUN (no_neighbor_capability_orf_prefix, |
5641 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5642 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5643 | NO_STR |
5644 | NEIGHBOR_STR | |
5645 | NEIGHBOR_ADDR_STR2 | |
5646 | "Advertise capability to the peer\n" | |
5647 | "Advertise ORF capability to the peer\n" | |
5648 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5649 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5650 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5651 | "Capability to SEND the ORF to this neighbor\n") | |
5652 | { | |
d62a17ae | 5653 | int idx_send_recv = 6; |
db45f64d DS |
5654 | char *peer_str = argv[2]->arg; |
5655 | struct peer *peer; | |
5656 | afi_t afi = bgp_node_afi(vty); | |
5657 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5658 | |
db45f64d DS |
5659 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5660 | if (!peer) | |
d62a17ae | 5661 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5662 | |
db45f64d DS |
5663 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5664 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5665 | PEER_FLAG_ORF_PREFIX_SM); | |
5666 | ||
5667 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5668 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5669 | PEER_FLAG_ORF_PREFIX_RM); | |
5670 | ||
5671 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5672 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5673 | PEER_FLAG_ORF_PREFIX_SM) | |
5674 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5675 | PEER_FLAG_ORF_PREFIX_RM); | |
5676 | ||
5677 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5678 | } |
5679 | ||
5680 | ALIAS_HIDDEN( | |
5681 | no_neighbor_capability_orf_prefix, | |
5682 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5683 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5684 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5685 | "Advertise capability to the peer\n" | |
5686 | "Advertise ORF capability to the peer\n" | |
5687 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5688 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5689 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5690 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5691 | |
718e3744 | 5692 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5693 | DEFUN (neighbor_nexthop_self, |
5694 | neighbor_nexthop_self_cmd, | |
5695 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5696 | NEIGHBOR_STR | |
5697 | NEIGHBOR_ADDR_STR2 | |
5698 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5699 | { |
d62a17ae | 5700 | int idx_peer = 1; |
28c6e247 IR |
5701 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5702 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5703 | } |
9e7a53c1 | 5704 | |
d62a17ae | 5705 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5706 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5707 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5708 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5709 | |
f4b8ec07 | 5710 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5711 | DEFUN (neighbor_nexthop_self_force, |
5712 | neighbor_nexthop_self_force_cmd, | |
5713 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5714 | NEIGHBOR_STR | |
5715 | NEIGHBOR_ADDR_STR2 | |
5716 | "Disable the next hop calculation for this neighbor\n" | |
5717 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5718 | { |
5719 | int idx_peer = 1; | |
28c6e247 IR |
5720 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5721 | bgp_node_safi(vty), | |
5722 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5723 | } |
5724 | ||
d62a17ae | 5725 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5726 | neighbor_nexthop_self_force_hidden_cmd, | |
5727 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5728 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5729 | "Disable the next hop calculation for this neighbor\n" | |
5730 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5731 | |
1bc4e531 DA |
5732 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5733 | neighbor_nexthop_self_all_hidden_cmd, | |
5734 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5735 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5736 | "Disable the next hop calculation for this neighbor\n" | |
5737 | "Set the next hop to self for reflected routes\n") | |
5738 | ||
28c6e247 IR |
5739 | DEFUN (no_neighbor_nexthop_self, |
5740 | no_neighbor_nexthop_self_cmd, | |
5741 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5742 | NO_STR | |
5743 | NEIGHBOR_STR | |
5744 | NEIGHBOR_ADDR_STR2 | |
5745 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5746 | { |
d62a17ae | 5747 | int idx_peer = 2; |
28c6e247 IR |
5748 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5749 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5750 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5751 | } |
6b0655a2 | 5752 | |
d62a17ae | 5753 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5754 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5755 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5756 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5757 | |
28c6e247 IR |
5758 | DEFUN (no_neighbor_nexthop_self_force, |
5759 | no_neighbor_nexthop_self_force_cmd, | |
5760 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5761 | NO_STR | |
5762 | NEIGHBOR_STR | |
5763 | NEIGHBOR_ADDR_STR2 | |
5764 | "Disable the next hop calculation for this neighbor\n" | |
5765 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5766 | { |
d62a17ae | 5767 | int idx_peer = 2; |
28c6e247 IR |
5768 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5769 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5770 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5771 | } |
a538debe | 5772 | |
d62a17ae | 5773 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5774 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5775 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5776 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5777 | "Disable the next hop calculation for this neighbor\n" | |
5778 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5779 | |
1bc4e531 DA |
5780 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5781 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5782 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5783 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5784 | "Disable the next hop calculation for this neighbor\n" | |
5785 | "Set the next hop to self for reflected routes\n") | |
5786 | ||
c7122e14 | 5787 | /* neighbor as-override */ |
28c6e247 IR |
5788 | DEFUN (neighbor_as_override, |
5789 | neighbor_as_override_cmd, | |
5790 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5791 | NEIGHBOR_STR | |
5792 | NEIGHBOR_ADDR_STR2 | |
5793 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5794 | { |
d62a17ae | 5795 | int idx_peer = 1; |
28c6e247 IR |
5796 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5797 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5798 | } |
5799 | ||
d62a17ae | 5800 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5801 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5802 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5803 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5804 | |
28c6e247 IR |
5805 | DEFUN (no_neighbor_as_override, |
5806 | no_neighbor_as_override_cmd, | |
5807 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5808 | NO_STR | |
5809 | NEIGHBOR_STR | |
5810 | NEIGHBOR_ADDR_STR2 | |
5811 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5812 | { |
d62a17ae | 5813 | int idx_peer = 2; |
28c6e247 IR |
5814 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5815 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5816 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5817 | } |
5818 | ||
d62a17ae | 5819 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5820 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5821 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5822 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5823 | |
718e3744 | 5824 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5825 | DEFUN (neighbor_remove_private_as, |
5826 | neighbor_remove_private_as_cmd, | |
5827 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5828 | NEIGHBOR_STR | |
5829 | NEIGHBOR_ADDR_STR2 | |
5830 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5831 | { |
d62a17ae | 5832 | int idx_peer = 1; |
28c6e247 IR |
5833 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5834 | bgp_node_safi(vty), | |
5835 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5836 | } |
5837 | ||
d62a17ae | 5838 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5839 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5840 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5841 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5842 | |
28c6e247 IR |
5843 | DEFUN (neighbor_remove_private_as_all, |
5844 | neighbor_remove_private_as_all_cmd, | |
5845 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5846 | NEIGHBOR_STR | |
5847 | NEIGHBOR_ADDR_STR2 | |
5848 | "Remove private ASNs in outbound updates\n" | |
5849 | "Apply to all AS numbers\n") | |
5000f21c | 5850 | { |
d62a17ae | 5851 | int idx_peer = 1; |
28c6e247 IR |
5852 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5853 | bgp_node_safi(vty), | |
5854 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5855 | } |
5856 | ||
d62a17ae | 5857 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5858 | neighbor_remove_private_as_all_hidden_cmd, | |
5859 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5860 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5861 | "Remove private ASNs in outbound updates\n" | |
a0dfca37 | 5862 | "Apply to all AS numbers\n") |
596c17ba | 5863 | |
28c6e247 IR |
5864 | DEFUN (neighbor_remove_private_as_replace_as, |
5865 | neighbor_remove_private_as_replace_as_cmd, | |
5866 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5867 | NEIGHBOR_STR | |
5868 | NEIGHBOR_ADDR_STR2 | |
5869 | "Remove private ASNs in outbound updates\n" | |
5870 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5871 | { |
d62a17ae | 5872 | int idx_peer = 1; |
28c6e247 IR |
5873 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5874 | bgp_node_safi(vty), | |
5875 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5876 | } |
5877 | ||
d62a17ae | 5878 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5879 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5880 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5881 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5882 | "Remove private ASNs in outbound updates\n" | |
5883 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5884 | |
28c6e247 IR |
5885 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5886 | neighbor_remove_private_as_all_replace_as_cmd, | |
5887 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5888 | NEIGHBOR_STR | |
5889 | NEIGHBOR_ADDR_STR2 | |
5890 | "Remove private ASNs in outbound updates\n" | |
5891 | "Apply to all AS numbers\n" | |
5892 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5893 | { |
d62a17ae | 5894 | int idx_peer = 1; |
28c6e247 IR |
5895 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5896 | bgp_node_safi(vty), | |
5897 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5898 | } |
5899 | ||
d62a17ae | 5900 | ALIAS_HIDDEN( |
5901 | neighbor_remove_private_as_all_replace_as, | |
5902 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5903 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5904 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5905 | "Remove private ASNs in outbound updates\n" | |
5906 | "Apply to all AS numbers\n" | |
5907 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5908 | |
28c6e247 IR |
5909 | DEFUN (no_neighbor_remove_private_as, |
5910 | no_neighbor_remove_private_as_cmd, | |
5911 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5912 | NO_STR | |
5913 | NEIGHBOR_STR | |
5914 | NEIGHBOR_ADDR_STR2 | |
5915 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5916 | { |
d62a17ae | 5917 | int idx_peer = 2; |
28c6e247 IR |
5918 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5919 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5920 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5921 | } |
6b0655a2 | 5922 | |
d62a17ae | 5923 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5924 | no_neighbor_remove_private_as_hidden_cmd, | |
5925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5926 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5927 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5928 | |
28c6e247 IR |
5929 | DEFUN (no_neighbor_remove_private_as_all, |
5930 | no_neighbor_remove_private_as_all_cmd, | |
5931 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5932 | NO_STR | |
5933 | NEIGHBOR_STR | |
5934 | NEIGHBOR_ADDR_STR2 | |
5935 | "Remove private ASNs in outbound updates\n" | |
5936 | "Apply to all AS numbers\n") | |
88b8ed8d | 5937 | { |
d62a17ae | 5938 | int idx_peer = 2; |
28c6e247 IR |
5939 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5940 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5941 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5942 | } |
5000f21c | 5943 | |
d62a17ae | 5944 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5945 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5946 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5947 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5948 | "Remove private ASNs in outbound updates\n" | |
5949 | "Apply to all AS numbers\n") | |
596c17ba | 5950 | |
28c6e247 IR |
5951 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5952 | no_neighbor_remove_private_as_replace_as_cmd, | |
5953 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5954 | NO_STR | |
5955 | NEIGHBOR_STR | |
5956 | NEIGHBOR_ADDR_STR2 | |
5957 | "Remove private ASNs in outbound updates\n" | |
5958 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5959 | { |
d62a17ae | 5960 | int idx_peer = 2; |
28c6e247 IR |
5961 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5962 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5963 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5964 | } |
5000f21c | 5965 | |
d62a17ae | 5966 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5967 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5968 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5969 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5970 | "Remove private ASNs in outbound updates\n" | |
5971 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5972 | |
28c6e247 IR |
5973 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5974 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5975 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5976 | NO_STR | |
5977 | NEIGHBOR_STR | |
5978 | NEIGHBOR_ADDR_STR2 | |
5979 | "Remove private ASNs in outbound updates\n" | |
5980 | "Apply to all AS numbers\n" | |
5981 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5982 | { |
d62a17ae | 5983 | int idx_peer = 2; |
28c6e247 IR |
5984 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5985 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5986 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5987 | } |
5000f21c | 5988 | |
d62a17ae | 5989 | ALIAS_HIDDEN( |
5990 | no_neighbor_remove_private_as_all_replace_as, | |
5991 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5992 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5993 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5994 | "Remove private ASNs in outbound updates\n" | |
5995 | "Apply to all AS numbers\n" | |
5996 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5997 | |
5000f21c | 5998 | |
718e3744 | 5999 | /* neighbor send-community. */ |
28c6e247 IR |
6000 | DEFUN (neighbor_send_community, |
6001 | neighbor_send_community_cmd, | |
6002 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6003 | NEIGHBOR_STR | |
6004 | NEIGHBOR_ADDR_STR2 | |
6005 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6006 | { |
d62a17ae | 6007 | int idx_peer = 1; |
27c05d4d | 6008 | |
f63d4054 IR |
6009 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6010 | bgp_node_safi(vty), | |
6011 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6012 | } |
6013 | ||
d62a17ae | 6014 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
6015 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6016 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6017 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6018 | |
28c6e247 IR |
6019 | DEFUN (no_neighbor_send_community, |
6020 | no_neighbor_send_community_cmd, | |
6021 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6022 | NO_STR | |
6023 | NEIGHBOR_STR | |
6024 | NEIGHBOR_ADDR_STR2 | |
6025 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6026 | { |
d62a17ae | 6027 | int idx_peer = 2; |
27c05d4d | 6028 | |
f63d4054 IR |
6029 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6030 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6031 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6032 | } |
6b0655a2 | 6033 | |
d62a17ae | 6034 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
6035 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6036 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6037 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6038 | |
718e3744 | 6039 | /* neighbor send-community extended. */ |
28c6e247 IR |
6040 | DEFUN (neighbor_send_community_type, |
6041 | neighbor_send_community_type_cmd, | |
6042 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6043 | NEIGHBOR_STR | |
6044 | NEIGHBOR_ADDR_STR2 | |
6045 | "Send Community attribute to this neighbor\n" | |
6046 | "Send Standard and Extended Community attributes\n" | |
6047 | "Send Standard, Large and Extended Community attributes\n" | |
6048 | "Send Extended Community attributes\n" | |
6049 | "Send Standard Community attributes\n" | |
6050 | "Send Large Community attributes\n") | |
718e3744 | 6051 | { |
27c05d4d | 6052 | const char *type = argv[argc - 1]->text; |
db45f64d | 6053 | char *peer_str = argv[1]->arg; |
28c6e247 | 6054 | struct peer *peer; |
db45f64d | 6055 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 6056 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 6057 | |
28c6e247 IR |
6058 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6059 | if (!peer) | |
6060 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 6061 | |
28c6e247 IR |
6062 | if (strmatch(type, "standard")) |
6063 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6064 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 6065 | |
28c6e247 IR |
6066 | if (strmatch(type, "extended")) |
6067 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6068 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6069 | |
28c6e247 IR |
6070 | if (strmatch(type, "large")) |
6071 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6072 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 6073 | |
28c6e247 IR |
6074 | if (strmatch(type, "both")) { |
6075 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6076 | PEER_FLAG_SEND_COMMUNITY) | |
6077 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6078 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6079 | } |
28c6e247 IR |
6080 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6081 | PEER_FLAG_SEND_COMMUNITY) | |
6082 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6083 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
6084 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6085 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 6086 | } |
6087 | ||
6088 | ALIAS_HIDDEN( | |
6089 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
6090 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6091 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6092 | "Send Community attribute to this neighbor\n" | |
6093 | "Send Standard and Extended Community attributes\n" | |
6094 | "Send Standard, Large and Extended Community attributes\n" | |
6095 | "Send Extended Community attributes\n" | |
6096 | "Send Standard Community attributes\n" | |
6097 | "Send Large Community attributes\n") | |
596c17ba | 6098 | |
28c6e247 IR |
6099 | DEFUN (no_neighbor_send_community_type, |
6100 | no_neighbor_send_community_type_cmd, | |
6101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6102 | NO_STR | |
6103 | NEIGHBOR_STR | |
6104 | NEIGHBOR_ADDR_STR2 | |
6105 | "Send Community attribute to this neighbor\n" | |
6106 | "Send Standard and Extended Community attributes\n" | |
6107 | "Send Standard, Large and Extended Community attributes\n" | |
6108 | "Send Extended Community attributes\n" | |
6109 | "Send Standard Community attributes\n" | |
6110 | "Send Large Community attributes\n") | |
718e3744 | 6111 | { |
d62a17ae | 6112 | const char *type = argv[argc - 1]->text; |
db45f64d | 6113 | char *peer_str = argv[2]->arg; |
28c6e247 | 6114 | struct peer *peer; |
db45f64d DS |
6115 | afi_t afi = bgp_node_afi(vty); |
6116 | safi_t safi = bgp_node_safi(vty); | |
6117 | ||
28c6e247 IR |
6118 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6119 | if (!peer) | |
f4b8ec07 CS |
6120 | return CMD_WARNING_CONFIG_FAILED; |
6121 | ||
28c6e247 IR |
6122 | if (strmatch(type, "standard")) |
6123 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6124 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 6125 | |
28c6e247 IR |
6126 | if (strmatch(type, "extended")) |
6127 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6128 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6129 | |
28c6e247 IR |
6130 | if (strmatch(type, "large")) |
6131 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6132 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
6133 | |
6134 | if (strmatch(type, "both")) { | |
db45f64d | 6135 | |
28c6e247 IR |
6136 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6137 | PEER_FLAG_SEND_COMMUNITY) | |
6138 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6139 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
6140 | } |
6141 | ||
28c6e247 IR |
6142 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6143 | PEER_FLAG_SEND_COMMUNITY) | |
6144 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6145 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
6146 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6147 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 6148 | } |
6149 | ||
6150 | ALIAS_HIDDEN( | |
6151 | no_neighbor_send_community_type, | |
6152 | no_neighbor_send_community_type_hidden_cmd, | |
6153 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6154 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6155 | "Send Community attribute to this neighbor\n" | |
6156 | "Send Standard and Extended Community attributes\n" | |
6157 | "Send Standard, Large and Extended Community attributes\n" | |
6158 | "Send Extended Community attributes\n" | |
6159 | "Send Standard Community attributes\n" | |
6160 | "Send Large Community attributes\n") | |
596c17ba | 6161 | |
718e3744 | 6162 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
6163 | DEFUN (neighbor_soft_reconfiguration, |
6164 | neighbor_soft_reconfiguration_cmd, | |
6165 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6166 | NEIGHBOR_STR | |
6167 | NEIGHBOR_ADDR_STR2 | |
6168 | "Per neighbor soft reconfiguration\n" | |
6169 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6170 | { |
d62a17ae | 6171 | int idx_peer = 1; |
28c6e247 IR |
6172 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6173 | bgp_node_safi(vty), | |
6174 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6175 | } |
6176 | ||
d62a17ae | 6177 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6178 | neighbor_soft_reconfiguration_hidden_cmd, | |
6179 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6180 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6181 | "Per neighbor soft reconfiguration\n" | |
6182 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6183 | |
28c6e247 IR |
6184 | DEFUN (no_neighbor_soft_reconfiguration, |
6185 | no_neighbor_soft_reconfiguration_cmd, | |
6186 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6187 | NO_STR | |
6188 | NEIGHBOR_STR | |
6189 | NEIGHBOR_ADDR_STR2 | |
6190 | "Per neighbor soft reconfiguration\n" | |
6191 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6192 | { |
d62a17ae | 6193 | int idx_peer = 2; |
28c6e247 IR |
6194 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6195 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6196 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6197 | } |
6b0655a2 | 6198 | |
d62a17ae | 6199 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6200 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6201 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6202 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6203 | "Per neighbor soft reconfiguration\n" | |
6204 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6205 | |
28c6e247 IR |
6206 | DEFUN (neighbor_route_reflector_client, |
6207 | neighbor_route_reflector_client_cmd, | |
6208 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6209 | NEIGHBOR_STR | |
6210 | NEIGHBOR_ADDR_STR2 | |
6211 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6212 | { |
d62a17ae | 6213 | int idx_peer = 1; |
28c6e247 | 6214 | struct peer *peer; |
718e3744 | 6215 | |
6216 | ||
28c6e247 IR |
6217 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6218 | if (!peer) | |
d62a17ae | 6219 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6220 | |
28c6e247 IR |
6221 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6222 | bgp_node_safi(vty), | |
6223 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 6224 | } |
6225 | ||
d62a17ae | 6226 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6227 | neighbor_route_reflector_client_hidden_cmd, | |
6228 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6229 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6230 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6231 | |
28c6e247 IR |
6232 | DEFUN (no_neighbor_route_reflector_client, |
6233 | no_neighbor_route_reflector_client_cmd, | |
6234 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6235 | NO_STR | |
6236 | NEIGHBOR_STR | |
6237 | NEIGHBOR_ADDR_STR2 | |
6238 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6239 | { |
d62a17ae | 6240 | int idx_peer = 2; |
28c6e247 IR |
6241 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6242 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6243 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 6244 | } |
6b0655a2 | 6245 | |
d62a17ae | 6246 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6247 | no_neighbor_route_reflector_client_hidden_cmd, | |
6248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6249 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6250 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6251 | |
718e3744 | 6252 | /* neighbor route-server-client. */ |
28c6e247 IR |
6253 | DEFUN (neighbor_route_server_client, |
6254 | neighbor_route_server_client_cmd, | |
6255 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6256 | NEIGHBOR_STR | |
6257 | NEIGHBOR_ADDR_STR2 | |
6258 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6259 | { |
d62a17ae | 6260 | int idx_peer = 1; |
28c6e247 | 6261 | struct peer *peer; |
f4b8ec07 | 6262 | |
28c6e247 IR |
6263 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6264 | if (!peer) | |
d62a17ae | 6265 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
6266 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6267 | bgp_node_safi(vty), | |
6268 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 6269 | } |
6270 | ||
d62a17ae | 6271 | ALIAS_HIDDEN(neighbor_route_server_client, |
6272 | neighbor_route_server_client_hidden_cmd, | |
6273 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6274 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6275 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6276 | |
28c6e247 IR |
6277 | DEFUN (no_neighbor_route_server_client, |
6278 | no_neighbor_route_server_client_cmd, | |
6279 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6280 | NO_STR | |
6281 | NEIGHBOR_STR | |
6282 | NEIGHBOR_ADDR_STR2 | |
6283 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6284 | { |
d62a17ae | 6285 | int idx_peer = 2; |
28c6e247 IR |
6286 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6287 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6288 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 6289 | } |
6b0655a2 | 6290 | |
d62a17ae | 6291 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6292 | no_neighbor_route_server_client_hidden_cmd, | |
6293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6294 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6295 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6296 | |
fee0f4c6 | 6297 | DEFUN (neighbor_nexthop_local_unchanged, |
6298 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6299 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6300 | NEIGHBOR_STR |
6301 | NEIGHBOR_ADDR_STR2 | |
6302 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6303 | "Leave link-local nexthop unchanged for this peer\n") | |
6304 | { | |
d62a17ae | 6305 | int idx_peer = 1; |
6306 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6307 | bgp_node_safi(vty), | |
6308 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6309 | } |
6b0655a2 | 6310 | |
fee0f4c6 | 6311 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6312 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6313 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6314 | NO_STR |
6315 | NEIGHBOR_STR | |
6316 | NEIGHBOR_ADDR_STR2 | |
6317 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6318 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6319 | { |
d62a17ae | 6320 | int idx_peer = 2; |
6321 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6322 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6323 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6324 | } |
6b0655a2 | 6325 | |
28c6e247 IR |
6326 | DEFUN (neighbor_attr_unchanged, |
6327 | neighbor_attr_unchanged_cmd, | |
6328 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6329 | NEIGHBOR_STR | |
6330 | NEIGHBOR_ADDR_STR2 | |
6331 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6332 | "As-path attribute\n" | |
6333 | "Nexthop attribute\n" | |
6334 | "Med attribute\n") | |
718e3744 | 6335 | { |
d62a17ae | 6336 | int idx = 0; |
8eeb0335 | 6337 | char *peer_str = argv[1]->arg; |
28c6e247 | 6338 | struct peer *peer; |
db45f64d DS |
6339 | bool aspath = false; |
6340 | bool nexthop = false; | |
6341 | bool med = false; | |
8eeb0335 DW |
6342 | afi_t afi = bgp_node_afi(vty); |
6343 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6344 | int ret = 0; |
f4b8ec07 | 6345 | |
28c6e247 IR |
6346 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6347 | if (!peer) | |
8eeb0335 | 6348 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6349 | |
6350 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6351 | aspath = true; |
6352 | ||
d62a17ae | 6353 | idx = 0; |
6354 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6355 | nexthop = true; |
6356 | ||
d62a17ae | 6357 | idx = 0; |
6358 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6359 | med = true; |
d62a17ae | 6360 | |
8eeb0335 | 6361 | /* no flags means all of them! */ |
db45f64d | 6362 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6363 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6364 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6365 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6366 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6367 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6368 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6369 | } else { |
28c6e247 IR |
6370 | if (!aspath) { |
6371 | if (peer_af_flag_check(peer, afi, safi, | |
6372 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6373 | ret |= peer_af_flag_unset_vty( | |
6374 | vty, peer_str, afi, safi, | |
6375 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6376 | } | |
6377 | } else | |
6378 | ret |= peer_af_flag_set_vty( | |
6379 | vty, peer_str, afi, safi, | |
6380 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6381 | ||
6382 | if (!nexthop) { | |
6383 | if (peer_af_flag_check(peer, afi, safi, | |
6384 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6385 | ret |= peer_af_flag_unset_vty( | |
6386 | vty, peer_str, afi, safi, | |
6387 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6388 | } | |
6389 | } else | |
6390 | ret |= peer_af_flag_set_vty( | |
6391 | vty, peer_str, afi, safi, | |
6392 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6393 | ||
6394 | if (!med) { | |
6395 | if (peer_af_flag_check(peer, afi, safi, | |
6396 | PEER_FLAG_MED_UNCHANGED)) { | |
6397 | ret |= peer_af_flag_unset_vty( | |
6398 | vty, peer_str, afi, safi, | |
6399 | PEER_FLAG_MED_UNCHANGED); | |
6400 | } | |
6401 | } else | |
6402 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6403 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6404 | } |
6405 | ||
28c6e247 | 6406 | return ret; |
d62a17ae | 6407 | } |
6408 | ||
6409 | ALIAS_HIDDEN( | |
6410 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6411 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6412 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6413 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6414 | "As-path attribute\n" | |
6415 | "Nexthop attribute\n" | |
6416 | "Med attribute\n") | |
596c17ba | 6417 | |
28c6e247 IR |
6418 | DEFUN (no_neighbor_attr_unchanged, |
6419 | no_neighbor_attr_unchanged_cmd, | |
6420 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6421 | NO_STR | |
6422 | NEIGHBOR_STR | |
6423 | NEIGHBOR_ADDR_STR2 | |
6424 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6425 | "As-path attribute\n" | |
6426 | "Nexthop attribute\n" | |
6427 | "Med attribute\n") | |
718e3744 | 6428 | { |
d62a17ae | 6429 | int idx = 0; |
db45f64d | 6430 | char *peer_str = argv[2]->arg; |
28c6e247 | 6431 | struct peer *peer; |
db45f64d DS |
6432 | bool aspath = false; |
6433 | bool nexthop = false; | |
6434 | bool med = false; | |
6435 | afi_t afi = bgp_node_afi(vty); | |
6436 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6437 | int ret = 0; |
f4b8ec07 | 6438 | |
28c6e247 IR |
6439 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6440 | if (!peer) | |
db45f64d | 6441 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6442 | |
6443 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6444 | aspath = true; |
6445 | ||
d62a17ae | 6446 | idx = 0; |
6447 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6448 | nexthop = true; |
6449 | ||
d62a17ae | 6450 | idx = 0; |
6451 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6452 | med = true; |
d62a17ae | 6453 | |
28c6e247 IR |
6454 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6455 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6456 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6457 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6458 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6459 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6460 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6461 | |
6462 | if (aspath) | |
28c6e247 IR |
6463 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6464 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6465 | |
6466 | if (nexthop) | |
28c6e247 IR |
6467 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6468 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6469 | |
db45f64d | 6470 | if (med) |
28c6e247 IR |
6471 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6472 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6473 | |
28c6e247 | 6474 | return ret; |
d62a17ae | 6475 | } |
6476 | ||
6477 | ALIAS_HIDDEN( | |
6478 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6479 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6480 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6481 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6482 | "As-path attribute\n" | |
6483 | "Nexthop attribute\n" | |
6484 | "Med attribute\n") | |
718e3744 | 6485 | |
28c6e247 IR |
6486 | /* EBGP multihop configuration. */ |
6487 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6488 | const char *ttl_str) | |
718e3744 | 6489 | { |
28c6e247 IR |
6490 | struct peer *peer; |
6491 | unsigned int ttl; | |
718e3744 | 6492 | |
28c6e247 IR |
6493 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6494 | if (!peer) | |
d62a17ae | 6495 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6496 | |
28c6e247 IR |
6497 | if (peer->conf_if) |
6498 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6499 | ||
6500 | if (!ttl_str) | |
6501 | ttl = MAXTTL; | |
6502 | else | |
6503 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6504 | |
28c6e247 | 6505 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6506 | } |
6507 | ||
28c6e247 | 6508 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6509 | { |
28c6e247 | 6510 | struct peer *peer; |
718e3744 | 6511 | |
28c6e247 IR |
6512 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6513 | if (!peer) | |
d62a17ae | 6514 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6515 | |
28c6e247 | 6516 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6517 | } |
6518 | ||
28c6e247 IR |
6519 | /* neighbor ebgp-multihop. */ |
6520 | DEFUN (neighbor_ebgp_multihop, | |
6521 | neighbor_ebgp_multihop_cmd, | |
6522 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6523 | NEIGHBOR_STR | |
6524 | NEIGHBOR_ADDR_STR2 | |
6525 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6526 | { |
28c6e247 IR |
6527 | int idx_peer = 1; |
6528 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6529 | } | |
f4b8ec07 | 6530 | |
28c6e247 IR |
6531 | DEFUN (neighbor_ebgp_multihop_ttl, |
6532 | neighbor_ebgp_multihop_ttl_cmd, | |
6533 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6534 | NEIGHBOR_STR | |
6535 | NEIGHBOR_ADDR_STR2 | |
6536 | "Allow EBGP neighbors not on directly connected networks\n" | |
6537 | "maximum hop count\n") | |
6538 | { | |
6539 | int idx_peer = 1; | |
6540 | int idx_number = 3; | |
6541 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6542 | argv[idx_number]->arg); | |
6543 | } | |
f4b8ec07 | 6544 | |
28c6e247 IR |
6545 | DEFUN (no_neighbor_ebgp_multihop, |
6546 | no_neighbor_ebgp_multihop_cmd, | |
6547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6548 | NO_STR | |
6549 | NEIGHBOR_STR | |
6550 | NEIGHBOR_ADDR_STR2 | |
6551 | "Allow EBGP neighbors not on directly connected networks\n" | |
6552 | "maximum hop count\n") | |
6553 | { | |
6554 | int idx_peer = 2; | |
6555 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6556 | } |
6557 | ||
97a52c82 DA |
6558 | DEFPY (neighbor_aigp, |
6559 | neighbor_aigp_cmd, | |
6560 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp", | |
6561 | NO_STR | |
6562 | NEIGHBOR_STR | |
6563 | NEIGHBOR_ADDR_STR2 | |
6564 | "Enable send and receive of the AIGP attribute per neighbor\n") | |
6565 | { | |
6566 | struct peer *peer; | |
6567 | ||
6568 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6569 | if (!peer) | |
6570 | return CMD_WARNING_CONFIG_FAILED; | |
6571 | ||
6572 | if (no) | |
6573 | return peer_flag_unset_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6574 | else | |
6575 | return peer_flag_set_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6576 | } | |
6577 | ||
d864dd9e EB |
6578 | static uint8_t get_role_by_name(const char *role_str) |
6579 | { | |
6580 | if (strncmp(role_str, "peer", 2) == 0) | |
6581 | return ROLE_PEER; | |
6582 | if (strncmp(role_str, "provider", 2) == 0) | |
6583 | return ROLE_PROVIDER; | |
6584 | if (strncmp(role_str, "customer", 2) == 0) | |
6585 | return ROLE_CUSTOMER; | |
6586 | if (strncmp(role_str, "rs-server", 4) == 0) | |
6587 | return ROLE_RS_SERVER; | |
6588 | if (strncmp(role_str, "rs-client", 4) == 0) | |
6589 | return ROLE_RS_CLIENT; | |
8f2d6021 | 6590 | return ROLE_UNDEFINED; |
d864dd9e EB |
6591 | } |
6592 | ||
6593 | static int peer_role_set_vty(struct vty *vty, const char *ip_str, | |
8f2d6021 | 6594 | const char *role_str, bool strict_mode) |
d864dd9e EB |
6595 | { |
6596 | struct peer *peer; | |
6597 | ||
7dddd1f7 | 6598 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6599 | if (!peer) |
6600 | return CMD_WARNING_CONFIG_FAILED; | |
6601 | uint8_t role = get_role_by_name(role_str); | |
6602 | ||
8f2d6021 | 6603 | if (role == ROLE_UNDEFINED) |
d864dd9e EB |
6604 | return bgp_vty_return(vty, BGP_ERR_INVALID_ROLE_NAME); |
6605 | return bgp_vty_return(vty, peer_role_set(peer, role, strict_mode)); | |
6606 | } | |
6607 | ||
6608 | static int peer_role_unset_vty(struct vty *vty, const char *ip_str) | |
6609 | { | |
6610 | struct peer *peer; | |
6611 | ||
7dddd1f7 | 6612 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6613 | if (!peer) |
6614 | return CMD_WARNING_CONFIG_FAILED; | |
6615 | return bgp_vty_return(vty, peer_role_unset(peer)); | |
6616 | } | |
6617 | ||
8f2d6021 | 6618 | DEFPY(neighbor_role, |
d864dd9e EB |
6619 | neighbor_role_cmd, |
6620 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>", | |
6621 | NEIGHBOR_STR | |
6622 | NEIGHBOR_ADDR_STR2 | |
6623 | "Set session role\n" | |
6624 | ROLE_STR) | |
6625 | { | |
6626 | int idx_peer = 1; | |
6627 | int idx_role = 3; | |
6628 | ||
6629 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6630 | false); |
d864dd9e EB |
6631 | } |
6632 | ||
8f2d6021 | 6633 | DEFPY(neighbor_role_strict, |
d864dd9e EB |
6634 | neighbor_role_strict_cmd, |
6635 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode", | |
6636 | NEIGHBOR_STR | |
6637 | NEIGHBOR_ADDR_STR2 | |
6638 | "Set session role\n" | |
6639 | ROLE_STR | |
6640 | "Use additional restriction on peer\n") | |
6641 | { | |
6642 | int idx_peer = 1; | |
6643 | int idx_role = 3; | |
6644 | ||
6645 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6646 | true); |
d864dd9e EB |
6647 | } |
6648 | ||
8f2d6021 | 6649 | DEFPY(no_neighbor_role, |
d864dd9e EB |
6650 | no_neighbor_role_cmd, |
6651 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]", | |
6652 | NO_STR | |
6653 | NEIGHBOR_STR | |
6654 | NEIGHBOR_ADDR_STR2 | |
8f2d6021 | 6655 | "Set session role\n" |
d864dd9e | 6656 | ROLE_STR |
8f2d6021 | 6657 | "Use additional restriction on peer\n") |
d864dd9e EB |
6658 | { |
6659 | int idx_peer = 2; | |
6660 | ||
6661 | return peer_role_unset_vty(vty, argv[idx_peer]->arg); | |
6662 | } | |
6b0655a2 | 6663 | |
6ffd2079 | 6664 | /* disable-connected-check */ |
28c6e247 IR |
6665 | DEFUN (neighbor_disable_connected_check, |
6666 | neighbor_disable_connected_check_cmd, | |
6667 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6668 | NEIGHBOR_STR | |
6669 | NEIGHBOR_ADDR_STR2 | |
6670 | "one-hop away EBGP peer using loopback address\n" | |
6671 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6672 | { |
d62a17ae | 6673 | int idx_peer = 1; |
28c6e247 IR |
6674 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6675 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6676 | } |
6677 | ||
28c6e247 IR |
6678 | DEFUN (no_neighbor_disable_connected_check, |
6679 | no_neighbor_disable_connected_check_cmd, | |
6680 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6681 | NO_STR | |
6682 | NEIGHBOR_STR | |
6683 | NEIGHBOR_ADDR_STR2 | |
6684 | "one-hop away EBGP peer using loopback address\n" | |
6685 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6686 | { |
d62a17ae | 6687 | int idx_peer = 2; |
28c6e247 IR |
6688 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6689 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6690 | } |
6691 | ||
7ab294ea DA |
6692 | /* disable-link-bw-encoding-ieee */ |
6693 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6694 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6695 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6696 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6697 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6698 | { |
6699 | int idx_peer = 1; | |
6700 | ||
6701 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6702 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6703 | } | |
6704 | ||
7ab294ea DA |
6705 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6706 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6707 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6708 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6709 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6710 | { |
6711 | int idx_peer = 2; | |
6712 | ||
6713 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6714 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6715 | } | |
6716 | ||
d08c0c80 DA |
6717 | /* extended-optional-parameters */ |
6718 | DEFUN(neighbor_extended_optional_parameters, | |
6719 | neighbor_extended_optional_parameters_cmd, | |
6720 | "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6721 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6722 | "Force the extended optional parameters format for OPEN messages\n") | |
6723 | { | |
6724 | int idx_peer = 1; | |
6725 | ||
6726 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6727 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6728 | } | |
6729 | ||
6730 | DEFUN(no_neighbor_extended_optional_parameters, | |
6731 | no_neighbor_extended_optional_parameters_cmd, | |
6732 | "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6733 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6734 | "Force the extended optional parameters format for OPEN messages\n") | |
6735 | { | |
6736 | int idx_peer = 2; | |
6737 | ||
6738 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6739 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6740 | } | |
47cbc09b PM |
6741 | |
6742 | /* enforce-first-as */ | |
28c6e247 IR |
6743 | DEFUN (neighbor_enforce_first_as, |
6744 | neighbor_enforce_first_as_cmd, | |
6745 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6746 | NEIGHBOR_STR | |
6747 | NEIGHBOR_ADDR_STR2 | |
6748 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6749 | { |
6750 | int idx_peer = 1; | |
f4b8ec07 | 6751 | |
28c6e247 IR |
6752 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6753 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6754 | } |
6755 | ||
28c6e247 IR |
6756 | DEFUN (no_neighbor_enforce_first_as, |
6757 | no_neighbor_enforce_first_as_cmd, | |
6758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6759 | NO_STR | |
6760 | NEIGHBOR_STR | |
6761 | NEIGHBOR_ADDR_STR2 | |
6762 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6763 | { |
6764 | int idx_peer = 2; | |
f4b8ec07 | 6765 | |
28c6e247 IR |
6766 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6767 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6768 | } |
6769 | ||
6770 | ||
28c6e247 IR |
6771 | DEFUN (neighbor_description, |
6772 | neighbor_description_cmd, | |
6773 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6774 | NEIGHBOR_STR | |
6775 | NEIGHBOR_ADDR_STR2 | |
6776 | "Neighbor specific description\n" | |
6777 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6778 | { |
d62a17ae | 6779 | int idx_peer = 1; |
6780 | int idx_line = 3; | |
28c6e247 | 6781 | struct peer *peer; |
d62a17ae | 6782 | char *str; |
718e3744 | 6783 | |
28c6e247 IR |
6784 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6785 | if (!peer) | |
d62a17ae | 6786 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6787 | |
d62a17ae | 6788 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6789 | |
28c6e247 | 6790 | peer_description_set(peer, str); |
718e3744 | 6791 | |
d62a17ae | 6792 | XFREE(MTYPE_TMP, str); |
718e3744 | 6793 | |
28c6e247 | 6794 | return CMD_SUCCESS; |
718e3744 | 6795 | } |
6796 | ||
28c6e247 IR |
6797 | DEFUN (no_neighbor_description, |
6798 | no_neighbor_description_cmd, | |
6799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6800 | NO_STR | |
6801 | NEIGHBOR_STR | |
6802 | NEIGHBOR_ADDR_STR2 | |
6803 | "Neighbor specific description\n") | |
718e3744 | 6804 | { |
d62a17ae | 6805 | int idx_peer = 2; |
28c6e247 | 6806 | struct peer *peer; |
f4b8ec07 | 6807 | |
28c6e247 IR |
6808 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6809 | if (!peer) | |
d62a17ae | 6810 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6811 | |
28c6e247 | 6812 | peer_description_unset(peer); |
718e3744 | 6813 | |
28c6e247 | 6814 | return CMD_SUCCESS; |
718e3744 | 6815 | } |
6816 | ||
1d80f243 | 6817 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6818 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6819 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6820 | "Neighbor specific description\n" | |
6821 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6822 | |
28c6e247 IR |
6823 | /* Neighbor update-source. */ |
6824 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6825 | const char *source_str) | |
6826 | { | |
6827 | struct peer *peer; | |
6828 | struct prefix p; | |
6829 | union sockunion su; | |
6830 | ||
6831 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6832 | if (!peer) | |
6833 | return CMD_WARNING_CONFIG_FAILED; | |
6834 | ||
6835 | if (peer->conf_if) | |
6836 | return CMD_WARNING; | |
6837 | ||
6838 | if (source_str) { | |
6839 | if (str2sockunion(source_str, &su) == 0) | |
6840 | peer_update_source_addr_set(peer, &su); | |
6841 | else { | |
6842 | if (str2prefix(source_str, &p)) { | |
6843 | vty_out(vty, | |
6844 | "%% Invalid update-source, remove prefix length \n"); | |
6845 | return CMD_WARNING_CONFIG_FAILED; | |
6846 | } else | |
6847 | peer_update_source_if_set(peer, source_str); | |
6848 | } | |
6849 | } else | |
6850 | peer_update_source_unset(peer); | |
6851 | ||
6852 | return CMD_SUCCESS; | |
6853 | } | |
6854 | ||
d62a17ae | 6855 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6856 | "IPv4 address\n" \ | |
6857 | "IPv6 address\n" \ | |
6858 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6859 | |
28c6e247 IR |
6860 | DEFUN (neighbor_update_source, |
6861 | neighbor_update_source_cmd, | |
6862 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6863 | NEIGHBOR_STR | |
6864 | NEIGHBOR_ADDR_STR2 | |
6865 | "Source of routing updates\n" | |
6866 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6867 | { |
d62a17ae | 6868 | int idx_peer = 1; |
6869 | int idx_peer_2 = 3; | |
28c6e247 | 6870 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6871 | argv[idx_peer_2]->arg); |
718e3744 | 6872 | } |
6873 | ||
28c6e247 IR |
6874 | DEFUN (no_neighbor_update_source, |
6875 | no_neighbor_update_source_cmd, | |
6876 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6877 | NO_STR | |
6878 | NEIGHBOR_STR | |
6879 | NEIGHBOR_ADDR_STR2 | |
6880 | "Source of routing updates\n" | |
6881 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6882 | { |
d62a17ae | 6883 | int idx_peer = 2; |
28c6e247 | 6884 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6885 | } |
6b0655a2 | 6886 | |
d62a17ae | 6887 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6888 | afi_t afi, safi_t safi, | |
6889 | const char *rmap, int set) | |
718e3744 | 6890 | { |
d62a17ae | 6891 | int ret; |
6892 | struct peer *peer; | |
80912664 | 6893 | struct route_map *route_map = NULL; |
718e3744 | 6894 | |
d62a17ae | 6895 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6896 | if (!peer) | |
6897 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6898 | |
1de27621 | 6899 | if (set) { |
80912664 DS |
6900 | if (rmap) |
6901 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6902 | ret = peer_default_originate_set(peer, afi, safi, |
6903 | rmap, route_map); | |
6904 | } else | |
d62a17ae | 6905 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6906 | |
d62a17ae | 6907 | return bgp_vty_return(vty, ret); |
718e3744 | 6908 | } |
6909 | ||
6910 | /* neighbor default-originate. */ | |
6911 | DEFUN (neighbor_default_originate, | |
6912 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6913 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6914 | NEIGHBOR_STR |
6915 | NEIGHBOR_ADDR_STR2 | |
6916 | "Originate default route to this neighbor\n") | |
6917 | { | |
d62a17ae | 6918 | int idx_peer = 1; |
6919 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6920 | bgp_node_afi(vty), | |
6921 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6922 | } |
6923 | ||
d62a17ae | 6924 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6925 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6926 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6927 | "Originate default route to this neighbor\n") | |
596c17ba | 6928 | |
718e3744 | 6929 | DEFUN (neighbor_default_originate_rmap, |
6930 | neighbor_default_originate_rmap_cmd, | |
70dd370f | 6931 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
718e3744 | 6932 | NEIGHBOR_STR |
6933 | NEIGHBOR_ADDR_STR2 | |
6934 | "Originate default route to this neighbor\n" | |
6935 | "Route-map to specify criteria to originate default\n" | |
6936 | "route-map name\n") | |
6937 | { | |
d62a17ae | 6938 | int idx_peer = 1; |
6939 | int idx_word = 4; | |
6940 | return peer_default_originate_set_vty( | |
6941 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6942 | argv[idx_word]->arg, 1); | |
718e3744 | 6943 | } |
6944 | ||
d62a17ae | 6945 | ALIAS_HIDDEN( |
6946 | neighbor_default_originate_rmap, | |
6947 | neighbor_default_originate_rmap_hidden_cmd, | |
70dd370f | 6948 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
d62a17ae | 6949 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6950 | "Originate default route to this neighbor\n" | |
6951 | "Route-map to specify criteria to originate default\n" | |
6952 | "route-map name\n") | |
596c17ba | 6953 | |
718e3744 | 6954 | DEFUN (no_neighbor_default_originate, |
6955 | no_neighbor_default_originate_cmd, | |
70dd370f | 6956 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
718e3744 | 6957 | NO_STR |
6958 | NEIGHBOR_STR | |
6959 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6960 | "Originate default route to this neighbor\n" |
6961 | "Route-map to specify criteria to originate default\n" | |
6962 | "route-map name\n") | |
718e3744 | 6963 | { |
d62a17ae | 6964 | int idx_peer = 2; |
6965 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6966 | bgp_node_afi(vty), | |
6967 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6968 | } |
6969 | ||
d62a17ae | 6970 | ALIAS_HIDDEN( |
6971 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
70dd370f | 6972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
d62a17ae | 6973 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6974 | "Originate default route to this neighbor\n" | |
6975 | "Route-map to specify criteria to originate default\n" | |
6976 | "route-map name\n") | |
596c17ba | 6977 | |
6b0655a2 | 6978 | |
28c6e247 IR |
6979 | /* Set neighbor's BGP port. */ |
6980 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6981 | const char *port_str) | |
718e3744 | 6982 | { |
28c6e247 IR |
6983 | struct peer *peer; |
6984 | uint16_t port; | |
6985 | struct servent *sp; | |
6986 | ||
a3aecc99 | 6987 | peer = peer_and_group_lookup_vty(vty, ip_str); |
28c6e247 IR |
6988 | if (!peer) |
6989 | return CMD_WARNING_CONFIG_FAILED; | |
6990 | ||
6991 | if (!port_str) { | |
6992 | sp = getservbyname("bgp", "tcp"); | |
6993 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6994 | } else { | |
6995 | port = strtoul(port_str, NULL, 10); | |
6996 | } | |
718e3744 | 6997 | |
28c6e247 | 6998 | peer_port_set(peer, port); |
718e3744 | 6999 | |
28c6e247 IR |
7000 | return CMD_SUCCESS; |
7001 | } | |
f4b8ec07 | 7002 | |
28c6e247 IR |
7003 | /* Set specified peer's BGP port. */ |
7004 | DEFUN (neighbor_port, | |
7005 | neighbor_port_cmd, | |
a3aecc99 | 7006 | "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)", |
28c6e247 | 7007 | NEIGHBOR_STR |
a3aecc99 | 7008 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7009 | "Neighbor's BGP port\n" |
7010 | "TCP port number\n") | |
7011 | { | |
7012 | int idx_ip = 1; | |
7013 | int idx_number = 3; | |
7014 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
7015 | argv[idx_number]->arg); | |
f4b8ec07 | 7016 | } |
6b0655a2 | 7017 | |
28c6e247 IR |
7018 | DEFUN (no_neighbor_port, |
7019 | no_neighbor_port_cmd, | |
a3aecc99 | 7020 | "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]", |
28c6e247 IR |
7021 | NO_STR |
7022 | NEIGHBOR_STR | |
a3aecc99 | 7023 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7024 | "Neighbor's BGP port\n" |
7025 | "TCP port number\n") | |
718e3744 | 7026 | { |
f4b8ec07 | 7027 | int idx_ip = 2; |
28c6e247 IR |
7028 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
7029 | } | |
7030 | ||
7031 | ||
7032 | /* neighbor weight. */ | |
7033 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
7034 | safi_t safi, const char *weight_str) | |
7035 | { | |
7036 | int ret; | |
7037 | struct peer *peer; | |
7038 | unsigned long weight; | |
718e3744 | 7039 | |
28c6e247 IR |
7040 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7041 | if (!peer) | |
7042 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7043 | |
28c6e247 | 7044 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 7045 | |
28c6e247 IR |
7046 | ret = peer_weight_set(peer, afi, safi, weight); |
7047 | return bgp_vty_return(vty, ret); | |
718e3744 | 7048 | } |
7049 | ||
28c6e247 IR |
7050 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7051 | safi_t safi) | |
718e3744 | 7052 | { |
28c6e247 IR |
7053 | int ret; |
7054 | struct peer *peer; | |
f4b8ec07 | 7055 | |
28c6e247 IR |
7056 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7057 | if (!peer) | |
d62a17ae | 7058 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7059 | |
28c6e247 IR |
7060 | ret = peer_weight_unset(peer, afi, safi); |
7061 | return bgp_vty_return(vty, ret); | |
7062 | } | |
f4b8ec07 | 7063 | |
28c6e247 IR |
7064 | DEFUN (neighbor_weight, |
7065 | neighbor_weight_cmd, | |
7066 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7067 | NEIGHBOR_STR | |
7068 | NEIGHBOR_ADDR_STR2 | |
7069 | "Set default weight for routes from this neighbor\n" | |
7070 | "default weight\n") | |
7071 | { | |
7072 | int idx_peer = 1; | |
7073 | int idx_number = 3; | |
7074 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7075 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 7076 | } |
7077 | ||
d62a17ae | 7078 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7079 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7080 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7081 | "Set default weight for routes from this neighbor\n" | |
7082 | "default weight\n") | |
596c17ba | 7083 | |
28c6e247 IR |
7084 | DEFUN (no_neighbor_weight, |
7085 | no_neighbor_weight_cmd, | |
7086 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7087 | NO_STR | |
7088 | NEIGHBOR_STR | |
7089 | NEIGHBOR_ADDR_STR2 | |
7090 | "Set default weight for routes from this neighbor\n" | |
7091 | "default weight\n") | |
718e3744 | 7092 | { |
d62a17ae | 7093 | int idx_peer = 2; |
28c6e247 IR |
7094 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
7095 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 7096 | } |
7097 | ||
d62a17ae | 7098 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7099 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7100 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7101 | "Set default weight for routes from this neighbor\n" | |
7102 | "default weight\n") | |
596c17ba | 7103 | |
6b0655a2 | 7104 | |
718e3744 | 7105 | /* Override capability negotiation. */ |
c36bc05f IR |
7106 | DEFUN (neighbor_override_capability, |
7107 | neighbor_override_capability_cmd, | |
7108 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7109 | NEIGHBOR_STR | |
7110 | NEIGHBOR_ADDR_STR2 | |
7111 | "Override capability negotiation result\n") | |
718e3744 | 7112 | { |
d62a17ae | 7113 | int idx_peer = 1; |
c36bc05f IR |
7114 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7115 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7116 | } |
7117 | ||
c36bc05f IR |
7118 | DEFUN (no_neighbor_override_capability, |
7119 | no_neighbor_override_capability_cmd, | |
7120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7121 | NO_STR | |
7122 | NEIGHBOR_STR | |
7123 | NEIGHBOR_ADDR_STR2 | |
7124 | "Override capability negotiation result\n") | |
718e3744 | 7125 | { |
d62a17ae | 7126 | int idx_peer = 2; |
c36bc05f IR |
7127 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7128 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7129 | } |
6b0655a2 | 7130 | |
c36bc05f IR |
7131 | DEFUN (neighbor_strict_capability, |
7132 | neighbor_strict_capability_cmd, | |
7133 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7134 | NEIGHBOR_STR | |
7135 | NEIGHBOR_ADDR_STR2 | |
7136 | "Strict capability negotiation match\n") | |
718e3744 | 7137 | { |
9fb964de PM |
7138 | int idx_peer = 1; |
7139 | ||
c36bc05f IR |
7140 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7141 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7142 | } |
7143 | ||
c36bc05f IR |
7144 | DEFUN (no_neighbor_strict_capability, |
7145 | no_neighbor_strict_capability_cmd, | |
7146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7147 | NO_STR | |
7148 | NEIGHBOR_STR | |
7149 | NEIGHBOR_ADDR_STR2 | |
7150 | "Strict capability negotiation match\n") | |
718e3744 | 7151 | { |
9fb964de | 7152 | int idx_peer = 2; |
8611c7f3 | 7153 | |
c36bc05f IR |
7154 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7155 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7156 | } |
6b0655a2 | 7157 | |
28c6e247 IR |
7158 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
7159 | const char *keep_str, const char *hold_str) | |
718e3744 | 7160 | { |
28c6e247 IR |
7161 | int ret; |
7162 | struct peer *peer; | |
7163 | uint32_t keepalive; | |
7164 | uint32_t holdtime; | |
718e3744 | 7165 | |
28c6e247 IR |
7166 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7167 | if (!peer) | |
d62a17ae | 7168 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7169 | |
28c6e247 IR |
7170 | keepalive = strtoul(keep_str, NULL, 10); |
7171 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 7172 | |
28c6e247 | 7173 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 7174 | |
28c6e247 | 7175 | return bgp_vty_return(vty, ret); |
718e3744 | 7176 | } |
6b0655a2 | 7177 | |
28c6e247 | 7178 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7179 | { |
28c6e247 IR |
7180 | int ret; |
7181 | struct peer *peer; | |
718e3744 | 7182 | |
28c6e247 IR |
7183 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7184 | if (!peer) | |
d62a17ae | 7185 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7186 | |
28c6e247 | 7187 | ret = peer_timers_unset(peer); |
718e3744 | 7188 | |
28c6e247 | 7189 | return bgp_vty_return(vty, ret); |
718e3744 | 7190 | } |
6b0655a2 | 7191 | |
28c6e247 IR |
7192 | DEFUN (neighbor_timers, |
7193 | neighbor_timers_cmd, | |
7194 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7195 | NEIGHBOR_STR | |
7196 | NEIGHBOR_ADDR_STR2 | |
7197 | "BGP per neighbor timers\n" | |
7198 | "Keepalive interval\n" | |
7199 | "Holdtime\n") | |
718e3744 | 7200 | { |
f4b8ec07 | 7201 | int idx_peer = 1; |
28c6e247 IR |
7202 | int idx_number = 3; |
7203 | int idx_number_2 = 4; | |
7204 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
7205 | argv[idx_number]->arg, | |
7206 | argv[idx_number_2]->arg); | |
7207 | } | |
7208 | ||
7209 | DEFUN (no_neighbor_timers, | |
7210 | no_neighbor_timers_cmd, | |
7211 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7212 | NO_STR | |
7213 | NEIGHBOR_STR | |
7214 | NEIGHBOR_ADDR_STR2 | |
7215 | "BGP per neighbor timers\n" | |
7216 | "Keepalive interval\n" | |
7217 | "Holdtime\n") | |
7218 | { | |
7219 | int idx_peer = 2; | |
7220 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
7221 | } | |
7222 | ||
7223 | ||
7224 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
7225 | const char *time_str) | |
7226 | { | |
7227 | int ret; | |
7228 | struct peer *peer; | |
7229 | uint32_t connect; | |
718e3744 | 7230 | |
28c6e247 IR |
7231 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7232 | if (!peer) | |
d62a17ae | 7233 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7234 | |
28c6e247 IR |
7235 | connect = strtoul(time_str, NULL, 10); |
7236 | ||
7237 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 7238 | |
28c6e247 | 7239 | return bgp_vty_return(vty, ret); |
718e3744 | 7240 | } |
7241 | ||
28c6e247 | 7242 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7243 | { |
28c6e247 IR |
7244 | int ret; |
7245 | struct peer *peer; | |
718e3744 | 7246 | |
28c6e247 IR |
7247 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7248 | if (!peer) | |
d62a17ae | 7249 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7250 | |
28c6e247 IR |
7251 | ret = peer_timers_connect_unset(peer); |
7252 | ||
7253 | return bgp_vty_return(vty, ret); | |
7254 | } | |
7255 | ||
7256 | DEFUN (neighbor_timers_connect, | |
7257 | neighbor_timers_connect_cmd, | |
7258 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7259 | NEIGHBOR_STR | |
7260 | NEIGHBOR_ADDR_STR2 | |
7261 | "BGP per neighbor timers\n" | |
7262 | "BGP connect timer\n" | |
7263 | "Connect timer\n") | |
7264 | { | |
7265 | int idx_peer = 1; | |
7266 | int idx_number = 4; | |
7267 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
7268 | argv[idx_number]->arg); | |
7269 | } | |
718e3744 | 7270 | |
28c6e247 IR |
7271 | DEFUN (no_neighbor_timers_connect, |
7272 | no_neighbor_timers_connect_cmd, | |
7273 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7274 | NO_STR | |
7275 | NEIGHBOR_STR | |
7276 | NEIGHBOR_ADDR_STR2 | |
7277 | "BGP per neighbor timers\n" | |
7278 | "BGP connect timer\n" | |
7279 | "Connect timer\n") | |
7280 | { | |
7281 | int idx_peer = 2; | |
7282 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 7283 | } |
7284 | ||
d43114f3 DS |
7285 | DEFPY (neighbor_timers_delayopen, |
7286 | neighbor_timers_delayopen_cmd, | |
7287 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
7288 | NEIGHBOR_STR | |
7289 | NEIGHBOR_ADDR_STR2 | |
7290 | "BGP per neighbor timers\n" | |
7291 | "RFC 4271 DelayOpenTimer\n" | |
7292 | "DelayOpenTime timer interval\n") | |
7293 | { | |
7294 | struct peer *peer; | |
7295 | ||
7296 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7297 | if (!peer) | |
7298 | return CMD_WARNING_CONFIG_FAILED; | |
7299 | ||
7300 | if (!interval) { | |
7301 | if (peer_timers_delayopen_unset(peer)) | |
7302 | return CMD_WARNING_CONFIG_FAILED; | |
7303 | } else { | |
7304 | if (peer_timers_delayopen_set(peer, interval)) | |
7305 | return CMD_WARNING_CONFIG_FAILED; | |
7306 | } | |
7307 | ||
7308 | return CMD_SUCCESS; | |
7309 | } | |
7310 | ||
7311 | DEFPY (no_neighbor_timers_delayopen, | |
7312 | no_neighbor_timers_delayopen_cmd, | |
7313 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
7314 | NO_STR | |
7315 | NEIGHBOR_STR | |
7316 | NEIGHBOR_ADDR_STR2 | |
7317 | "BGP per neighbor timers\n" | |
7318 | "RFC 4271 DelayOpenTimer\n" | |
7319 | "DelayOpenTime timer interval\n") | |
7320 | { | |
7321 | struct peer *peer; | |
7322 | ||
7323 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7324 | if (!peer) | |
7325 | return CMD_WARNING_CONFIG_FAILED; | |
7326 | ||
7327 | if (peer_timers_delayopen_unset(peer)) | |
7328 | return CMD_WARNING_CONFIG_FAILED; | |
7329 | ||
7330 | return CMD_SUCCESS; | |
7331 | } | |
7332 | ||
28c6e247 IR |
7333 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
7334 | const char *time_str, int set) | |
718e3744 | 7335 | { |
28c6e247 IR |
7336 | int ret; |
7337 | struct peer *peer; | |
7338 | uint32_t routeadv = 0; | |
718e3744 | 7339 | |
28c6e247 IR |
7340 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7341 | if (!peer) | |
d62a17ae | 7342 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7343 | |
28c6e247 IR |
7344 | if (time_str) |
7345 | routeadv = strtoul(time_str, NULL, 10); | |
7346 | ||
7347 | if (set) | |
7348 | ret = peer_advertise_interval_set(peer, routeadv); | |
7349 | else | |
7350 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 7351 | |
28c6e247 | 7352 | return bgp_vty_return(vty, ret); |
718e3744 | 7353 | } |
7354 | ||
28c6e247 IR |
7355 | DEFUN (neighbor_advertise_interval, |
7356 | neighbor_advertise_interval_cmd, | |
7357 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7358 | NEIGHBOR_STR | |
7359 | NEIGHBOR_ADDR_STR2 | |
7360 | "Minimum interval between sending BGP routing updates\n" | |
7361 | "time in seconds\n") | |
718e3744 | 7362 | { |
28c6e247 IR |
7363 | int idx_peer = 1; |
7364 | int idx_number = 3; | |
7365 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
7366 | argv[idx_number]->arg, 1); | |
7367 | } | |
f4b8ec07 | 7368 | |
28c6e247 IR |
7369 | DEFUN (no_neighbor_advertise_interval, |
7370 | no_neighbor_advertise_interval_cmd, | |
7371 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7372 | NO_STR | |
7373 | NEIGHBOR_STR | |
7374 | NEIGHBOR_ADDR_STR2 | |
7375 | "Minimum interval between sending BGP routing updates\n" | |
7376 | "time in seconds\n") | |
7377 | { | |
7378 | int idx_peer = 2; | |
7379 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 7380 | } |
7381 | ||
6b0655a2 | 7382 | |
518f0eb1 DS |
7383 | /* Time to wait before processing route-map updates */ |
7384 | DEFUN (bgp_set_route_map_delay_timer, | |
7385 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7386 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7387 | SET_STR |
7388 | "BGP route-map delay timer\n" | |
7389 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7390 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7391 | { |
d62a17ae | 7392 | int idx_number = 3; |
d7c0a89a | 7393 | uint32_t rmap_delay_timer; |
d62a17ae | 7394 | |
7395 | if (argv[idx_number]->arg) { | |
7396 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7397 | bm->rmap_update_timer = rmap_delay_timer; | |
7398 | ||
7399 | /* if the dynamic update handling is being disabled, and a timer | |
7400 | * is | |
7401 | * running, stop the timer and act as if the timer has already | |
7402 | * fired. | |
7403 | */ | |
7404 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
fa5806c3 | 7405 | THREAD_OFF(bm->t_rmap_update); |
d62a17ae | 7406 | thread_execute(bm->master, bgp_route_map_update_timer, |
7407 | NULL, 0); | |
7408 | } | |
7409 | return CMD_SUCCESS; | |
7410 | } else { | |
7411 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7412 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7413 | } |
518f0eb1 DS |
7414 | } |
7415 | ||
7416 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7417 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7418 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7419 | NO_STR |
3a2d747c | 7420 | BGP_STR |
518f0eb1 | 7421 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7422 | "Reset to default time to wait for processing route-map changes\n" |
7423 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7424 | { |
518f0eb1 | 7425 | |
d62a17ae | 7426 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7427 | |
d62a17ae | 7428 | return CMD_SUCCESS; |
518f0eb1 DS |
7429 | } |
7430 | ||
28c6e247 IR |
7431 | /* neighbor interface */ |
7432 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7433 | const char *str) | |
718e3744 | 7434 | { |
28c6e247 | 7435 | struct peer *peer; |
718e3744 | 7436 | |
28c6e247 IR |
7437 | peer = peer_lookup_vty(vty, ip_str); |
7438 | if (!peer || peer->conf_if) { | |
7439 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7440 | return CMD_WARNING_CONFIG_FAILED; | |
7441 | } | |
718e3744 | 7442 | |
28c6e247 IR |
7443 | if (str) |
7444 | peer_interface_set(peer, str); | |
7445 | else | |
7446 | peer_interface_unset(peer); | |
718e3744 | 7447 | |
28c6e247 | 7448 | return CMD_SUCCESS; |
718e3744 | 7449 | } |
7450 | ||
28c6e247 IR |
7451 | DEFUN (neighbor_interface, |
7452 | neighbor_interface_cmd, | |
7453 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7454 | NEIGHBOR_STR | |
7455 | NEIGHBOR_ADDR_STR | |
7456 | "Interface\n" | |
7457 | "Interface name\n") | |
718e3744 | 7458 | { |
28c6e247 IR |
7459 | int idx_ip = 1; |
7460 | int idx_word = 3; | |
294d8425 | 7461 | |
28c6e247 IR |
7462 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7463 | } | |
f4b8ec07 | 7464 | |
28c6e247 IR |
7465 | DEFUN (no_neighbor_interface, |
7466 | no_neighbor_interface_cmd, | |
294d8425 | 7467 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7468 | NO_STR |
7469 | NEIGHBOR_STR | |
294d8425 | 7470 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7471 | "Interface\n" |
7472 | "Interface name\n") | |
7473 | { | |
7474 | int idx_peer = 2; | |
294d8425 | 7475 | |
28c6e247 | 7476 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7477 | } |
6b0655a2 | 7478 | |
718e3744 | 7479 | DEFUN (neighbor_distribute_list, |
7480 | neighbor_distribute_list_cmd, | |
c60dec36 | 7481 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7482 | NEIGHBOR_STR |
7483 | NEIGHBOR_ADDR_STR2 | |
7484 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7485 | "IP Access-list name\n" |
7486 | "Filter incoming updates\n" | |
7487 | "Filter outgoing updates\n") | |
7488 | { | |
d62a17ae | 7489 | int idx_peer = 1; |
7490 | int idx_acl = 3; | |
7491 | int direct, ret; | |
7492 | struct peer *peer; | |
a8206004 | 7493 | |
d62a17ae | 7494 | const char *pstr = argv[idx_peer]->arg; |
7495 | const char *acl = argv[idx_acl]->arg; | |
7496 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7497 | |
d62a17ae | 7498 | peer = peer_and_group_lookup_vty(vty, pstr); |
7499 | if (!peer) | |
7500 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7501 | |
d62a17ae | 7502 | /* Check filter direction. */ |
7503 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7504 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7505 | direct, acl); | |
a8206004 | 7506 | |
d62a17ae | 7507 | return bgp_vty_return(vty, ret); |
718e3744 | 7508 | } |
7509 | ||
d62a17ae | 7510 | ALIAS_HIDDEN( |
7511 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7512 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7513 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7514 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7515 | "IP Access-list name\n" |
7516 | "Filter incoming updates\n" | |
7517 | "Filter outgoing updates\n") | |
596c17ba | 7518 | |
718e3744 | 7519 | DEFUN (no_neighbor_distribute_list, |
7520 | no_neighbor_distribute_list_cmd, | |
c60dec36 | 7521 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7522 | NO_STR |
7523 | NEIGHBOR_STR | |
7524 | NEIGHBOR_ADDR_STR2 | |
7525 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7526 | "IP Access-list name\n" |
7527 | "Filter incoming updates\n" | |
7528 | "Filter outgoing updates\n") | |
7529 | { | |
d62a17ae | 7530 | int idx_peer = 2; |
7531 | int direct, ret; | |
7532 | struct peer *peer; | |
a8206004 | 7533 | |
d62a17ae | 7534 | const char *pstr = argv[idx_peer]->arg; |
7535 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7536 | |
d62a17ae | 7537 | peer = peer_and_group_lookup_vty(vty, pstr); |
7538 | if (!peer) | |
7539 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7540 | |
d62a17ae | 7541 | /* Check filter direction. */ |
7542 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7543 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7544 | direct); | |
a8206004 | 7545 | |
d62a17ae | 7546 | return bgp_vty_return(vty, ret); |
718e3744 | 7547 | } |
6b0655a2 | 7548 | |
d62a17ae | 7549 | ALIAS_HIDDEN( |
7550 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7552 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7553 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7554 | "IP Access-list name\n" |
7555 | "Filter incoming updates\n" | |
7556 | "Filter outgoing updates\n") | |
596c17ba | 7557 | |
718e3744 | 7558 | /* Set prefix list to the peer. */ |
642ef664 IR |
7559 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7560 | afi_t afi, safi_t safi, | |
7561 | const char *name_str, | |
7562 | const char *direct_str) | |
718e3744 | 7563 | { |
642ef664 IR |
7564 | int ret; |
7565 | int direct = FILTER_IN; | |
7566 | struct peer *peer; | |
718e3744 | 7567 | |
642ef664 IR |
7568 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7569 | if (!peer) | |
d62a17ae | 7570 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7571 | |
642ef664 IR |
7572 | /* Check filter direction. */ |
7573 | if (strncmp(direct_str, "i", 1) == 0) | |
7574 | direct = FILTER_IN; | |
7575 | else if (strncmp(direct_str, "o", 1) == 0) | |
7576 | direct = FILTER_OUT; | |
718e3744 | 7577 | |
642ef664 | 7578 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7579 | |
642ef664 IR |
7580 | return bgp_vty_return(vty, ret); |
7581 | } | |
7582 | ||
7583 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7584 | afi_t afi, safi_t safi, | |
7585 | const char *direct_str) | |
7586 | { | |
7587 | int ret; | |
7588 | struct peer *peer; | |
7589 | int direct = FILTER_IN; | |
7590 | ||
7591 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7592 | if (!peer) | |
7593 | return CMD_WARNING_CONFIG_FAILED; | |
7594 | ||
7595 | /* Check filter direction. */ | |
7596 | if (strncmp(direct_str, "i", 1) == 0) | |
7597 | direct = FILTER_IN; | |
7598 | else if (strncmp(direct_str, "o", 1) == 0) | |
7599 | direct = FILTER_OUT; | |
7600 | ||
7601 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7602 | ||
7603 | return bgp_vty_return(vty, ret); | |
7604 | } | |
7605 | ||
7606 | DEFUN (neighbor_prefix_list, | |
7607 | neighbor_prefix_list_cmd, | |
7608 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7609 | NEIGHBOR_STR | |
7610 | NEIGHBOR_ADDR_STR2 | |
7611 | "Filter updates to/from this neighbor\n" | |
7612 | "Name of a prefix list\n" | |
7613 | "Filter incoming updates\n" | |
7614 | "Filter outgoing updates\n") | |
7615 | { | |
7616 | int idx_peer = 1; | |
7617 | int idx_word = 3; | |
7618 | int idx_in_out = 4; | |
7619 | return peer_prefix_list_set_vty( | |
7620 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7621 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7622 | } |
7623 | ||
d62a17ae | 7624 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7625 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7626 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7627 | "Filter updates to/from this neighbor\n" | |
7628 | "Name of a prefix list\n" | |
7629 | "Filter incoming updates\n" | |
7630 | "Filter outgoing updates\n") | |
596c17ba | 7631 | |
642ef664 IR |
7632 | DEFUN (no_neighbor_prefix_list, |
7633 | no_neighbor_prefix_list_cmd, | |
7634 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7635 | NO_STR | |
7636 | NEIGHBOR_STR | |
7637 | NEIGHBOR_ADDR_STR2 | |
7638 | "Filter updates to/from this neighbor\n" | |
7639 | "Name of a prefix list\n" | |
7640 | "Filter incoming updates\n" | |
7641 | "Filter outgoing updates\n") | |
7642 | { | |
7643 | int idx_peer = 2; | |
7644 | int idx_in_out = 5; | |
7645 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7646 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7647 | argv[idx_in_out]->arg); | |
7648 | } | |
7649 | ||
7650 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7651 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7652 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7653 | "Filter updates to/from this neighbor\n" | |
7654 | "Name of a prefix list\n" | |
7655 | "Filter incoming updates\n" | |
7656 | "Filter outgoing updates\n") | |
7657 | ||
d62a17ae | 7658 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7659 | safi_t safi, const char *name_str, | |
7660 | const char *direct_str) | |
718e3744 | 7661 | { |
d62a17ae | 7662 | int ret; |
7663 | struct peer *peer; | |
7664 | int direct = FILTER_IN; | |
718e3744 | 7665 | |
d62a17ae | 7666 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7667 | if (!peer) | |
7668 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7669 | |
d62a17ae | 7670 | /* Check filter direction. */ |
7671 | if (strncmp(direct_str, "i", 1) == 0) | |
7672 | direct = FILTER_IN; | |
7673 | else if (strncmp(direct_str, "o", 1) == 0) | |
7674 | direct = FILTER_OUT; | |
718e3744 | 7675 | |
d62a17ae | 7676 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7677 | |
d62a17ae | 7678 | return bgp_vty_return(vty, ret); |
718e3744 | 7679 | } |
7680 | ||
d62a17ae | 7681 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7682 | safi_t safi, const char *direct_str) | |
718e3744 | 7683 | { |
d62a17ae | 7684 | int ret; |
7685 | struct peer *peer; | |
7686 | int direct = FILTER_IN; | |
718e3744 | 7687 | |
d62a17ae | 7688 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7689 | if (!peer) | |
7690 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7691 | |
d62a17ae | 7692 | /* Check filter direction. */ |
7693 | if (strncmp(direct_str, "i", 1) == 0) | |
7694 | direct = FILTER_IN; | |
7695 | else if (strncmp(direct_str, "o", 1) == 0) | |
7696 | direct = FILTER_OUT; | |
718e3744 | 7697 | |
d62a17ae | 7698 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7699 | |
d62a17ae | 7700 | return bgp_vty_return(vty, ret); |
718e3744 | 7701 | } |
7702 | ||
7703 | DEFUN (neighbor_filter_list, | |
7704 | neighbor_filter_list_cmd, | |
de71d43e | 7705 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7706 | NEIGHBOR_STR |
7707 | NEIGHBOR_ADDR_STR2 | |
7708 | "Establish BGP filters\n" | |
7709 | "AS path access-list name\n" | |
7710 | "Filter incoming routes\n" | |
7711 | "Filter outgoing routes\n") | |
7712 | { | |
d62a17ae | 7713 | int idx_peer = 1; |
7714 | int idx_word = 3; | |
7715 | int idx_in_out = 4; | |
7716 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7717 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7718 | argv[idx_in_out]->arg); | |
718e3744 | 7719 | } |
7720 | ||
d62a17ae | 7721 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
de71d43e | 7722 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7723 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7724 | "Establish BGP filters\n" | |
7725 | "AS path access-list name\n" | |
7726 | "Filter incoming routes\n" | |
7727 | "Filter outgoing routes\n") | |
596c17ba | 7728 | |
718e3744 | 7729 | DEFUN (no_neighbor_filter_list, |
7730 | no_neighbor_filter_list_cmd, | |
de71d43e | 7731 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7732 | NO_STR |
7733 | NEIGHBOR_STR | |
7734 | NEIGHBOR_ADDR_STR2 | |
7735 | "Establish BGP filters\n" | |
7736 | "AS path access-list name\n" | |
7737 | "Filter incoming routes\n" | |
7738 | "Filter outgoing routes\n") | |
7739 | { | |
d62a17ae | 7740 | int idx_peer = 2; |
7741 | int idx_in_out = 5; | |
7742 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7743 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7744 | argv[idx_in_out]->arg); | |
718e3744 | 7745 | } |
6b0655a2 | 7746 | |
d62a17ae | 7747 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
de71d43e | 7748 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7749 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7750 | "Establish BGP filters\n" | |
7751 | "AS path access-list name\n" | |
7752 | "Filter incoming routes\n" | |
7753 | "Filter outgoing routes\n") | |
596c17ba | 7754 | |
7f7940e6 MK |
7755 | /* Set advertise-map to the peer. */ |
7756 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7757 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7758 | const char *advertise_str, |
7759 | const char *condition_str, bool condition, | |
7760 | bool set) | |
7f7940e6 MK |
7761 | { |
7762 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7763 | struct peer *peer; | |
7764 | struct route_map *advertise_map; | |
7765 | struct route_map *condition_map; | |
7766 | ||
7767 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7768 | if (!peer) | |
7769 | return ret; | |
7770 | ||
7771 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7772 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7773 | ||
cf2ad4d8 MK |
7774 | if (set) |
7775 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7776 | advertise_map, condition_str, | |
7777 | condition_map, condition); | |
7778 | else | |
7779 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7780 | advertise_map, condition_str, | |
7781 | condition_map, condition); | |
7f7940e6 MK |
7782 | |
7783 | return bgp_vty_return(vty, ret); | |
7784 | } | |
7785 | ||
389e4f92 QY |
7786 | DEFPY (bgp_condadv_period, |
7787 | bgp_condadv_period_cmd, | |
7788 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7789 | NO_STR | |
7790 | BGP_STR | |
7791 | "Conditional advertisement settings\n" | |
7792 | "Set period to rescan BGP table to check if condition is met\n" | |
7793 | "Period between BGP table scans, in seconds; default 60\n") | |
7794 | { | |
7795 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7796 | ||
7797 | bgp->condition_check_period = | |
7798 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7799 | ||
7800 | return CMD_SUCCESS; | |
7801 | } | |
7802 | ||
cf2ad4d8 | 7803 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7804 | neighbor_advertise_map_cmd, |
3ccddc25 | 7805 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str", |
cf2ad4d8 | 7806 | NO_STR |
7f7940e6 MK |
7807 | NEIGHBOR_STR |
7808 | NEIGHBOR_ADDR_STR2 | |
7809 | "Route-map to conditionally advertise routes\n" | |
7810 | "Name of advertise map\n" | |
7811 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7812 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7813 | "Name of the exist or non exist map\n") |
7f7940e6 | 7814 | { |
7f7940e6 MK |
7815 | bool condition = CONDITION_EXIST; |
7816 | ||
52b84062 | 7817 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7818 | condition = CONDITION_NON_EXIST; |
7819 | ||
52b84062 MK |
7820 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7821 | bgp_node_safi(vty), advertise_str, | |
7822 | condition_str, condition, !no); | |
7f7940e6 MK |
7823 | } |
7824 | ||
7825 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
3ccddc25 | 7826 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map RMAP_NAME$advertise_str <exist-map|non-exist-map>$exist RMAP_NAME$condition_str", |
7f7940e6 MK |
7827 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7828 | "Route-map to conditionally advertise routes\n" | |
7829 | "Name of advertise map\n" | |
7830 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7831 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7832 | "Name of the exist or non exist map\n") |
7f7940e6 | 7833 | |
718e3744 | 7834 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7835 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7836 | afi_t afi, safi_t safi, const char *name_str, | |
7837 | const char *direct_str) | |
718e3744 | 7838 | { |
0ea8d871 IR |
7839 | int ret; |
7840 | struct peer *peer; | |
7841 | int direct = RMAP_IN; | |
7842 | struct route_map *route_map; | |
718e3744 | 7843 | |
0ea8d871 IR |
7844 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7845 | if (!peer) | |
d62a17ae | 7846 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7847 | |
0ea8d871 IR |
7848 | /* Check filter direction. */ |
7849 | if (strncmp(direct_str, "in", 2) == 0) | |
7850 | direct = RMAP_IN; | |
7851 | else if (strncmp(direct_str, "o", 1) == 0) | |
7852 | direct = RMAP_OUT; | |
718e3744 | 7853 | |
0ea8d871 IR |
7854 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7855 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7856 | |
0ea8d871 IR |
7857 | return bgp_vty_return(vty, ret); |
7858 | } | |
7859 | ||
7860 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7861 | afi_t afi, safi_t safi, | |
7862 | const char *direct_str) | |
7863 | { | |
7864 | int ret; | |
7865 | struct peer *peer; | |
7866 | int direct = RMAP_IN; | |
7867 | ||
7868 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7869 | if (!peer) | |
7870 | return CMD_WARNING_CONFIG_FAILED; | |
7871 | ||
7872 | /* Check filter direction. */ | |
7873 | if (strncmp(direct_str, "in", 2) == 0) | |
7874 | direct = RMAP_IN; | |
7875 | else if (strncmp(direct_str, "o", 1) == 0) | |
7876 | direct = RMAP_OUT; | |
7877 | ||
7878 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7879 | ||
7880 | return bgp_vty_return(vty, ret); | |
7881 | } | |
7882 | ||
7883 | DEFUN (neighbor_route_map, | |
7884 | neighbor_route_map_cmd, | |
70dd370f | 7885 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7886 | NEIGHBOR_STR |
7887 | NEIGHBOR_ADDR_STR2 | |
7888 | "Apply route map to neighbor\n" | |
7889 | "Name of route map\n" | |
7890 | "Apply map to incoming routes\n" | |
7891 | "Apply map to outbound routes\n") | |
7892 | { | |
7893 | int idx_peer = 1; | |
7894 | int idx_word = 3; | |
7895 | int idx_in_out = 4; | |
7896 | return peer_route_map_set_vty( | |
7897 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7898 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7899 | } |
7900 | ||
d6d7ed37 | 7901 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
70dd370f | 7902 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7903 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7904 | "Apply route map to neighbor\n" | |
7905 | "Name of route map\n" | |
7906 | "Apply map to incoming routes\n" | |
7907 | "Apply map to outbound routes\n") | |
7908 | ||
0ea8d871 IR |
7909 | DEFUN (no_neighbor_route_map, |
7910 | no_neighbor_route_map_cmd, | |
70dd370f | 7911 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7912 | NO_STR |
7913 | NEIGHBOR_STR | |
7914 | NEIGHBOR_ADDR_STR2 | |
7915 | "Apply route map to neighbor\n" | |
7916 | "Name of route map\n" | |
7917 | "Apply map to incoming routes\n" | |
7918 | "Apply map to outbound routes\n") | |
7919 | { | |
7920 | int idx_peer = 2; | |
7921 | int idx_in_out = 5; | |
7922 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7923 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7924 | argv[idx_in_out]->arg); | |
7925 | } | |
7926 | ||
7927 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
70dd370f | 7928 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7929 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7930 | "Apply route map to neighbor\n" | |
7931 | "Name of route map\n" | |
7932 | "Apply map to incoming routes\n" | |
7933 | "Apply map to outbound routes\n") | |
7934 | ||
718e3744 | 7935 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7936 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7937 | afi_t afi, safi_t safi, | |
7938 | const char *name_str) | |
718e3744 | 7939 | { |
d62a17ae | 7940 | int ret; |
7941 | struct peer *peer; | |
1de27621 | 7942 | struct route_map *route_map; |
718e3744 | 7943 | |
d62a17ae | 7944 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7945 | if (!peer) | |
7946 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7947 | |
1de27621 DA |
7948 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7949 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7950 | |
d62a17ae | 7951 | return bgp_vty_return(vty, ret); |
718e3744 | 7952 | } |
7953 | ||
7954 | /* Unset route-map from the peer. */ | |
d62a17ae | 7955 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7956 | afi_t afi, safi_t safi) | |
718e3744 | 7957 | { |
d62a17ae | 7958 | int ret; |
7959 | struct peer *peer; | |
718e3744 | 7960 | |
d62a17ae | 7961 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7962 | if (!peer) | |
7963 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7964 | |
d62a17ae | 7965 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7966 | |
d62a17ae | 7967 | return bgp_vty_return(vty, ret); |
718e3744 | 7968 | } |
7969 | ||
7970 | DEFUN (neighbor_unsuppress_map, | |
7971 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7972 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7973 | NEIGHBOR_STR |
7974 | NEIGHBOR_ADDR_STR2 | |
7975 | "Route-map to selectively unsuppress suppressed routes\n" | |
7976 | "Name of route map\n") | |
7977 | { | |
d62a17ae | 7978 | int idx_peer = 1; |
7979 | int idx_word = 3; | |
7980 | return peer_unsuppress_map_set_vty( | |
7981 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7982 | argv[idx_word]->arg); | |
718e3744 | 7983 | } |
7984 | ||
d62a17ae | 7985 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7986 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7987 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7988 | "Route-map to selectively unsuppress suppressed routes\n" | |
7989 | "Name of route map\n") | |
596c17ba | 7990 | |
718e3744 | 7991 | DEFUN (no_neighbor_unsuppress_map, |
7992 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7993 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7994 | NO_STR |
7995 | NEIGHBOR_STR | |
7996 | NEIGHBOR_ADDR_STR2 | |
7997 | "Route-map to selectively unsuppress suppressed routes\n" | |
7998 | "Name of route map\n") | |
7999 | { | |
d62a17ae | 8000 | int idx_peer = 2; |
8001 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8002 | bgp_node_afi(vty), | |
8003 | bgp_node_safi(vty)); | |
718e3744 | 8004 | } |
6b0655a2 | 8005 | |
d62a17ae | 8006 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8007 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8008 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8009 | "Route-map to selectively unsuppress suppressed routes\n" | |
8010 | "Name of route map\n") | |
596c17ba | 8011 | |
7e62b792 IR |
8012 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
8013 | afi_t afi, safi_t safi, | |
8014 | const char *num_str, | |
8015 | const char *threshold_str, int warning, | |
8016 | const char *restart_str, | |
8017 | const char *force_str) | |
8018 | { | |
8019 | int ret; | |
8020 | struct peer *peer; | |
8021 | uint32_t max; | |
8022 | uint8_t threshold; | |
8023 | uint16_t restart; | |
8024 | ||
8025 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8026 | if (!peer) | |
8027 | return CMD_WARNING_CONFIG_FAILED; | |
8028 | ||
8029 | max = strtoul(num_str, NULL, 10); | |
8030 | if (threshold_str) | |
8031 | threshold = atoi(threshold_str); | |
8032 | else | |
8033 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
8034 | ||
8035 | if (restart_str) | |
8036 | restart = atoi(restart_str); | |
8037 | else | |
8038 | restart = 0; | |
8039 | ||
8040 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
8041 | restart, force_str ? true : false); | |
8042 | ||
8043 | return bgp_vty_return(vty, ret); | |
8044 | } | |
8045 | ||
8046 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
8047 | afi_t afi, safi_t safi) | |
8048 | { | |
8049 | int ret; | |
8050 | struct peer *peer; | |
8051 | ||
8052 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8053 | if (!peer) | |
8054 | return CMD_WARNING_CONFIG_FAILED; | |
8055 | ||
8056 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
8057 | ||
8058 | return bgp_vty_return(vty, ret); | |
8059 | } | |
8060 | ||
fde246e8 | 8061 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
8062 | DEFUN(neighbor_maximum_prefix_out, |
8063 | neighbor_maximum_prefix_out_cmd, | |
8064 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8065 | NEIGHBOR_STR | |
8066 | NEIGHBOR_ADDR_STR2 | |
8067 | "Maximum number of prefixes to be sent to this peer\n" | |
8068 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8069 | { |
80444d30 | 8070 | int ret; |
fde246e8 DA |
8071 | int idx_peer = 1; |
8072 | int idx_number = 3; | |
7e62b792 IR |
8073 | struct peer *peer; |
8074 | uint32_t max; | |
fde246e8 DA |
8075 | afi_t afi = bgp_node_afi(vty); |
8076 | safi_t safi = bgp_node_safi(vty); | |
8077 | ||
7e62b792 IR |
8078 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8079 | if (!peer) | |
fde246e8 DA |
8080 | return CMD_WARNING_CONFIG_FAILED; |
8081 | ||
7e62b792 | 8082 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 8083 | |
80444d30 | 8084 | ret = peer_maximum_prefix_out_set(peer, afi, safi, max); |
fde246e8 | 8085 | |
80444d30 | 8086 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8087 | } |
8088 | ||
1d80f243 IR |
8089 | DEFUN(no_neighbor_maximum_prefix_out, |
8090 | no_neighbor_maximum_prefix_out_cmd, | |
bc03c622 | 8091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]", |
1d80f243 IR |
8092 | NO_STR |
8093 | NEIGHBOR_STR | |
8094 | NEIGHBOR_ADDR_STR2 | |
bc03c622 LS |
8095 | "Maximum number of prefixes to be sent to this peer\n" |
8096 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8097 | { |
80444d30 | 8098 | int ret; |
fde246e8 | 8099 | int idx_peer = 2; |
7e62b792 | 8100 | struct peer *peer; |
fde246e8 DA |
8101 | afi_t afi = bgp_node_afi(vty); |
8102 | safi_t safi = bgp_node_safi(vty); | |
8103 | ||
7e62b792 IR |
8104 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8105 | if (!peer) | |
fde246e8 DA |
8106 | return CMD_WARNING_CONFIG_FAILED; |
8107 | ||
80444d30 | 8108 | ret = peer_maximum_prefix_out_unset(peer, afi, safi); |
fde246e8 | 8109 | |
80444d30 | 8110 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8111 | } |
8112 | ||
9cbd06e0 DA |
8113 | /* Maximum number of prefix configuration. Prefix count is different |
8114 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8115 | each peer configuration. */ |
1d80f243 IR |
8116 | DEFUN (neighbor_maximum_prefix, |
8117 | neighbor_maximum_prefix_cmd, | |
8118 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
8119 | NEIGHBOR_STR | |
8120 | NEIGHBOR_ADDR_STR2 | |
8121 | "Maximum number of prefix accept from this peer\n" | |
8122 | "maximum no. of prefix limit\n" | |
8123 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8124 | { |
d62a17ae | 8125 | int idx_peer = 1; |
8126 | int idx_number = 3; | |
9cbd06e0 | 8127 | int idx_force = 0; |
7e62b792 | 8128 | char *force = NULL; |
9cbd06e0 DA |
8129 | |
8130 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8131 | force = argv[idx_force]->arg; |
9cbd06e0 | 8132 | |
7e62b792 IR |
8133 | return peer_maximum_prefix_set_vty( |
8134 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8135 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 8136 | } |
8137 | ||
d62a17ae | 8138 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8139 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8140 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8141 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8142 | "maximum no. of prefix limit\n" |
8143 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8144 | |
1d80f243 IR |
8145 | DEFUN (neighbor_maximum_prefix_threshold, |
8146 | neighbor_maximum_prefix_threshold_cmd, | |
8147 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
8148 | NEIGHBOR_STR | |
8149 | NEIGHBOR_ADDR_STR2 | |
8150 | "Maximum number of prefix accept from this peer\n" | |
8151 | "maximum no. of prefix limit\n" | |
8152 | "Threshold value (%) at which to generate a warning msg\n" | |
8153 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8154 | { |
d62a17ae | 8155 | int idx_peer = 1; |
8156 | int idx_number = 3; | |
8157 | int idx_number_2 = 4; | |
9cbd06e0 | 8158 | int idx_force = 0; |
7e62b792 | 8159 | char *force = NULL; |
9cbd06e0 DA |
8160 | |
8161 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8162 | force = argv[idx_force]->arg; |
9cbd06e0 | 8163 | |
7e62b792 IR |
8164 | return peer_maximum_prefix_set_vty( |
8165 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8166 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 8167 | } |
e0701b79 | 8168 | |
d62a17ae | 8169 | ALIAS_HIDDEN( |
8170 | neighbor_maximum_prefix_threshold, | |
8171 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8172 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8173 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8174 | "Maximum number of prefix accept from this peer\n" | |
8175 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8176 | "Threshold value (%) at which to generate a warning msg\n" |
8177 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8178 | |
1d80f243 IR |
8179 | DEFUN (neighbor_maximum_prefix_warning, |
8180 | neighbor_maximum_prefix_warning_cmd, | |
8181 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
8182 | NEIGHBOR_STR | |
8183 | NEIGHBOR_ADDR_STR2 | |
8184 | "Maximum number of prefix accept from this peer\n" | |
8185 | "maximum no. of prefix limit\n" | |
8186 | "Only give warning message when limit is exceeded\n" | |
8187 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8188 | { |
d62a17ae | 8189 | int idx_peer = 1; |
8190 | int idx_number = 3; | |
9cbd06e0 | 8191 | int idx_force = 0; |
7e62b792 | 8192 | char *force = NULL; |
9cbd06e0 DA |
8193 | |
8194 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8195 | force = argv[idx_force]->arg; |
9cbd06e0 | 8196 | |
7e62b792 IR |
8197 | return peer_maximum_prefix_set_vty( |
8198 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8199 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 8200 | } |
8201 | ||
d62a17ae | 8202 | ALIAS_HIDDEN( |
8203 | neighbor_maximum_prefix_warning, | |
8204 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8205 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8206 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8207 | "Maximum number of prefix accept from this peer\n" | |
8208 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8209 | "Only give warning message when limit is exceeded\n" |
8210 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8211 | |
1d80f243 IR |
8212 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
8213 | neighbor_maximum_prefix_threshold_warning_cmd, | |
8214 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
8215 | NEIGHBOR_STR | |
8216 | NEIGHBOR_ADDR_STR2 | |
8217 | "Maximum number of prefix accept from this peer\n" | |
8218 | "maximum no. of prefix limit\n" | |
8219 | "Threshold value (%) at which to generate a warning msg\n" | |
8220 | "Only give warning message when limit is exceeded\n" | |
8221 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8222 | { |
d62a17ae | 8223 | int idx_peer = 1; |
8224 | int idx_number = 3; | |
8225 | int idx_number_2 = 4; | |
9cbd06e0 | 8226 | int idx_force = 0; |
7e62b792 | 8227 | char *force = NULL; |
9cbd06e0 DA |
8228 | |
8229 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8230 | force = argv[idx_force]->arg; |
9cbd06e0 | 8231 | |
7e62b792 IR |
8232 | return peer_maximum_prefix_set_vty( |
8233 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8234 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 8235 | } |
8236 | ||
d62a17ae | 8237 | ALIAS_HIDDEN( |
8238 | neighbor_maximum_prefix_threshold_warning, | |
8239 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8240 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8241 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8242 | "Maximum number of prefix accept from this peer\n" | |
8243 | "maximum no. of prefix limit\n" | |
8244 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8245 | "Only give warning message when limit is exceeded\n" |
8246 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8247 | |
1d80f243 IR |
8248 | DEFUN (neighbor_maximum_prefix_restart, |
8249 | neighbor_maximum_prefix_restart_cmd, | |
8250 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
8251 | NEIGHBOR_STR | |
8252 | NEIGHBOR_ADDR_STR2 | |
8253 | "Maximum number of prefix accept from this peer\n" | |
8254 | "maximum no. of prefix limit\n" | |
8255 | "Restart bgp connection after limit is exceeded\n" | |
8256 | "Restart interval in minutes\n" | |
8257 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8258 | { |
d62a17ae | 8259 | int idx_peer = 1; |
8260 | int idx_number = 3; | |
8261 | int idx_number_2 = 5; | |
9cbd06e0 | 8262 | int idx_force = 0; |
7e62b792 | 8263 | char *force = NULL; |
9cbd06e0 DA |
8264 | |
8265 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8266 | force = argv[idx_force]->arg; |
9cbd06e0 | 8267 | |
7e62b792 IR |
8268 | return peer_maximum_prefix_set_vty( |
8269 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8270 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 8271 | } |
8272 | ||
d62a17ae | 8273 | ALIAS_HIDDEN( |
8274 | neighbor_maximum_prefix_restart, | |
8275 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8276 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8277 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8278 | "Maximum number of prefix accept from this peer\n" | |
8279 | "maximum no. of prefix limit\n" | |
8280 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8281 | "Restart interval in minutes\n" |
8282 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8283 | |
1d80f243 IR |
8284 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
8285 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8286 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8287 | NEIGHBOR_STR | |
8288 | NEIGHBOR_ADDR_STR2 | |
8289 | "Maximum number of prefixes to accept from this peer\n" | |
8290 | "maximum no. of prefix limit\n" | |
8291 | "Threshold value (%) at which to generate a warning msg\n" | |
8292 | "Restart bgp connection after limit is exceeded\n" | |
8293 | "Restart interval in minutes\n" | |
8294 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8295 | { |
d62a17ae | 8296 | int idx_peer = 1; |
8297 | int idx_number = 3; | |
8298 | int idx_number_2 = 4; | |
8299 | int idx_number_3 = 6; | |
9cbd06e0 | 8300 | int idx_force = 0; |
7e62b792 | 8301 | char *force = NULL; |
9cbd06e0 DA |
8302 | |
8303 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8304 | force = argv[idx_force]->arg; |
9cbd06e0 | 8305 | |
7e62b792 IR |
8306 | return peer_maximum_prefix_set_vty( |
8307 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8308 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
8309 | argv[idx_number_3]->arg, force); | |
d62a17ae | 8310 | } |
8311 | ||
8312 | ALIAS_HIDDEN( | |
8313 | neighbor_maximum_prefix_threshold_restart, | |
8314 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8315 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8316 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8317 | "Maximum number of prefixes to accept from this peer\n" | |
8318 | "maximum no. of prefix limit\n" | |
8319 | "Threshold value (%) at which to generate a warning msg\n" | |
8320 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8321 | "Restart interval in minutes\n" |
8322 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8323 | |
1d80f243 IR |
8324 | DEFUN (no_neighbor_maximum_prefix, |
8325 | no_neighbor_maximum_prefix_cmd, | |
8326 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8327 | NO_STR | |
8328 | NEIGHBOR_STR | |
8329 | NEIGHBOR_ADDR_STR2 | |
8330 | "Maximum number of prefixes to accept from this peer\n" | |
8331 | "maximum no. of prefix limit\n" | |
8332 | "Threshold value (%) at which to generate a warning msg\n" | |
8333 | "Restart bgp connection after limit is exceeded\n" | |
8334 | "Restart interval in minutes\n" | |
8335 | "Only give warning message when limit is exceeded\n" | |
8336 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8337 | { |
d62a17ae | 8338 | int idx_peer = 2; |
7e62b792 IR |
8339 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
8340 | bgp_node_afi(vty), | |
8341 | bgp_node_safi(vty)); | |
718e3744 | 8342 | } |
e52702f2 | 8343 | |
d62a17ae | 8344 | ALIAS_HIDDEN( |
8345 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8346 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8347 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8348 | "Maximum number of prefixes to accept from this peer\n" | |
8349 | "maximum no. of prefix limit\n" | |
8350 | "Threshold value (%) at which to generate a warning msg\n" | |
8351 | "Restart bgp connection after limit is exceeded\n" | |
8352 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8353 | "Only give warning message when limit is exceeded\n" |
8354 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8355 | |
46dbf9d0 DA |
8356 | /* "neighbor accept-own" */ |
8357 | DEFPY (neighbor_accept_own, | |
8358 | neighbor_accept_own_cmd, | |
8359 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own", | |
8360 | NO_STR | |
8361 | NEIGHBOR_STR | |
8362 | NEIGHBOR_ADDR_STR2 | |
8363 | "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n") | |
8364 | { | |
8365 | struct peer *peer; | |
8366 | afi_t afi = bgp_node_afi(vty); | |
8367 | safi_t safi = bgp_node_safi(vty); | |
8368 | int ret; | |
8369 | ||
8370 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8371 | if (!peer) | |
8372 | return CMD_WARNING_CONFIG_FAILED; | |
8373 | ||
8374 | if (no) | |
8375 | ret = peer_af_flag_unset(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8376 | else | |
8377 | ret = peer_af_flag_set(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8378 | ||
8379 | return bgp_vty_return(vty, ret); | |
8380 | } | |
8381 | ||
01da2d26 DA |
8382 | /* "neighbor soo" */ |
8383 | DEFPY (neighbor_soo, | |
8384 | neighbor_soo_cmd, | |
8385 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo", | |
8386 | NEIGHBOR_STR | |
8387 | NEIGHBOR_ADDR_STR2 | |
8388 | "Set the Site-of-Origin (SoO) extended community\n" | |
8389 | "VPN extended community\n") | |
8390 | { | |
8391 | struct peer *peer; | |
8392 | afi_t afi = bgp_node_afi(vty); | |
8393 | safi_t safi = bgp_node_safi(vty); | |
8394 | struct ecommunity *ecomm_soo; | |
8395 | ||
8396 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8397 | if (!peer) | |
8398 | return CMD_WARNING_CONFIG_FAILED; | |
8399 | ||
8400 | ecomm_soo = ecommunity_str2com(soo, ECOMMUNITY_SITE_ORIGIN, 0); | |
8401 | if (!ecomm_soo) { | |
8402 | vty_out(vty, "%% Malformed SoO extended community\n"); | |
8403 | return CMD_WARNING; | |
8404 | } | |
8405 | ecommunity_str(ecomm_soo); | |
8406 | ||
8407 | if (!ecommunity_match(peer->soo[afi][safi], ecomm_soo)) { | |
8408 | ecommunity_free(&peer->soo[afi][safi]); | |
8409 | peer->soo[afi][safi] = ecomm_soo; | |
8410 | peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO); | |
8411 | } | |
8412 | ||
8413 | return bgp_vty_return(vty, | |
8414 | peer_af_flag_set(peer, afi, safi, PEER_FLAG_SOO)); | |
8415 | } | |
8416 | ||
8417 | DEFPY (no_neighbor_soo, | |
8418 | no_neighbor_soo_cmd, | |
8419 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]", | |
8420 | NO_STR | |
8421 | NEIGHBOR_STR | |
8422 | NEIGHBOR_ADDR_STR2 | |
8423 | "Set the Site-of-Origin (SoO) extended community\n" | |
8424 | "VPN extended community\n") | |
8425 | { | |
8426 | struct peer *peer; | |
8427 | afi_t afi = bgp_node_afi(vty); | |
8428 | safi_t safi = bgp_node_safi(vty); | |
8429 | ||
8430 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8431 | if (!peer) | |
8432 | return CMD_WARNING_CONFIG_FAILED; | |
8433 | ||
8434 | ecommunity_free(&peer->soo[afi][safi]); | |
8435 | ||
8436 | return bgp_vty_return( | |
8437 | vty, peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO)); | |
8438 | } | |
718e3744 | 8439 | |
718e3744 | 8440 | /* "neighbor allowas-in" */ |
8441 | DEFUN (neighbor_allowas_in, | |
8442 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8443 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8444 | NEIGHBOR_STR |
8445 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8446 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8447 | "Number of occurrences of AS number\n" |
fd8503f5 | 8448 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8449 | { |
d62a17ae | 8450 | int idx_peer = 1; |
8451 | int idx_number_origin = 3; | |
8452 | int ret; | |
8453 | int origin = 0; | |
8454 | struct peer *peer; | |
8455 | int allow_num = 0; | |
8456 | ||
8457 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8458 | if (!peer) | |
8459 | return CMD_WARNING_CONFIG_FAILED; | |
8460 | ||
8461 | if (argc <= idx_number_origin) | |
8462 | allow_num = 3; | |
8463 | else { | |
8464 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8465 | origin = 1; | |
8466 | else | |
8467 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8468 | } | |
8469 | ||
8470 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8471 | allow_num, origin); | |
8472 | ||
8473 | return bgp_vty_return(vty, ret); | |
8474 | } | |
8475 | ||
8476 | ALIAS_HIDDEN( | |
8477 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8478 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8479 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8480 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8481 | "Number of occurrences of AS number\n" |
d62a17ae | 8482 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8483 | |
718e3744 | 8484 | DEFUN (no_neighbor_allowas_in, |
8485 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8486 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8487 | NO_STR |
8488 | NEIGHBOR_STR | |
8489 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8490 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8491 | "Number of occurrences of AS number\n" |
fd8503f5 | 8492 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8493 | { |
d62a17ae | 8494 | int idx_peer = 2; |
8495 | int ret; | |
8496 | struct peer *peer; | |
718e3744 | 8497 | |
d62a17ae | 8498 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8499 | if (!peer) | |
8500 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8501 | |
d62a17ae | 8502 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8503 | bgp_node_safi(vty)); | |
718e3744 | 8504 | |
d62a17ae | 8505 | return bgp_vty_return(vty, ret); |
718e3744 | 8506 | } |
6b0655a2 | 8507 | |
d62a17ae | 8508 | ALIAS_HIDDEN( |
8509 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8510 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8511 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8512 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8513 | "Number of occurrences of AS number\n" |
d62a17ae | 8514 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8515 | |
28c6e247 IR |
8516 | DEFUN (neighbor_ttl_security, |
8517 | neighbor_ttl_security_cmd, | |
8518 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8519 | NEIGHBOR_STR | |
8520 | NEIGHBOR_ADDR_STR2 | |
8521 | "BGP ttl-security parameters\n" | |
8522 | "Specify the maximum number of hops to the BGP peer\n" | |
8523 | "Number of hops to BGP peer\n") | |
fa411a21 | 8524 | { |
d62a17ae | 8525 | int idx_peer = 1; |
8526 | int idx_number = 4; | |
28c6e247 IR |
8527 | struct peer *peer; |
8528 | int gtsm_hops; | |
d62a17ae | 8529 | |
28c6e247 IR |
8530 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8531 | if (!peer) | |
d62a17ae | 8532 | return CMD_WARNING_CONFIG_FAILED; |
8533 | ||
28c6e247 IR |
8534 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
8535 | ||
8536 | /* | |
8537 | * If 'neighbor swpX', then this is for directly connected peers, | |
8538 | * we should not accept a ttl-security hops value greater than 1. | |
8539 | */ | |
8540 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8541 | vty_out(vty, | |
8542 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8543 | argv[idx_peer]->arg); | |
8544 | return CMD_WARNING_CONFIG_FAILED; | |
8545 | } | |
7ebe625c | 8546 | |
28c6e247 | 8547 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8548 | } |
8549 | ||
1d80f243 IR |
8550 | DEFUN (no_neighbor_ttl_security, |
8551 | no_neighbor_ttl_security_cmd, | |
8552 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8553 | NO_STR | |
8554 | NEIGHBOR_STR | |
8555 | NEIGHBOR_ADDR_STR2 | |
8556 | "BGP ttl-security parameters\n" | |
8557 | "Specify the maximum number of hops to the BGP peer\n" | |
8558 | "Number of hops to BGP peer\n") | |
fa411a21 | 8559 | { |
d62a17ae | 8560 | int idx_peer = 2; |
28c6e247 | 8561 | struct peer *peer; |
fa411a21 | 8562 | |
28c6e247 IR |
8563 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8564 | if (!peer) | |
d62a17ae | 8565 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8566 | |
28c6e247 | 8567 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8568 | } |
6b0655a2 | 8569 | |
7c0e4312 DA |
8570 | /* disable-addpath-rx */ |
8571 | DEFUN(neighbor_disable_addpath_rx, | |
8572 | neighbor_disable_addpath_rx_cmd, | |
8573 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8574 | NEIGHBOR_STR | |
8575 | NEIGHBOR_ADDR_STR2 | |
8576 | "Do not accept additional paths\n") | |
8577 | { | |
8578 | char *peer_str = argv[1]->arg; | |
8579 | struct peer *peer; | |
8580 | afi_t afi = bgp_node_afi(vty); | |
8581 | safi_t safi = bgp_node_safi(vty); | |
8582 | ||
8583 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8584 | if (!peer) | |
8585 | return CMD_WARNING_CONFIG_FAILED; | |
8586 | ||
8587 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8588 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8589 | } | |
8590 | ||
8591 | DEFUN(no_neighbor_disable_addpath_rx, | |
8592 | no_neighbor_disable_addpath_rx_cmd, | |
8593 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8594 | NO_STR | |
8595 | NEIGHBOR_STR | |
8596 | NEIGHBOR_ADDR_STR2 | |
8597 | "Do not accept additional paths\n") | |
8598 | { | |
8599 | char *peer_str = argv[2]->arg; | |
8600 | struct peer *peer; | |
8601 | afi_t afi = bgp_node_afi(vty); | |
8602 | safi_t safi = bgp_node_safi(vty); | |
8603 | ||
8604 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8605 | if (!peer) | |
8606 | return CMD_WARNING_CONFIG_FAILED; | |
8607 | ||
8608 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8609 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8610 | } | |
8611 | ||
adbac85e DW |
8612 | DEFUN (neighbor_addpath_tx_all_paths, |
8613 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8614 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8615 | NEIGHBOR_STR |
8616 | NEIGHBOR_ADDR_STR2 | |
8617 | "Use addpath to advertise all paths to a neighbor\n") | |
8618 | { | |
d62a17ae | 8619 | int idx_peer = 1; |
8620 | struct peer *peer; | |
adbac85e | 8621 | |
d62a17ae | 8622 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8623 | if (!peer) | |
8624 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8625 | |
dcc68b5e MS |
8626 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8627 | BGP_ADDPATH_ALL); | |
8628 | return CMD_SUCCESS; | |
adbac85e DW |
8629 | } |
8630 | ||
d62a17ae | 8631 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8632 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8633 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8634 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8635 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8636 | |
adbac85e DW |
8637 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8638 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8639 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8640 | NO_STR |
8641 | NEIGHBOR_STR | |
8642 | NEIGHBOR_ADDR_STR2 | |
8643 | "Use addpath to advertise all paths to a neighbor\n") | |
8644 | { | |
d62a17ae | 8645 | int idx_peer = 2; |
dcc68b5e MS |
8646 | struct peer *peer; |
8647 | ||
8648 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8649 | if (!peer) | |
8650 | return CMD_WARNING_CONFIG_FAILED; | |
8651 | ||
8652 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8653 | != BGP_ADDPATH_ALL) { | |
8654 | vty_out(vty, | |
8655 | "%% Peer not currently configured to transmit all paths."); | |
8656 | return CMD_WARNING_CONFIG_FAILED; | |
8657 | } | |
8658 | ||
8659 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8660 | BGP_ADDPATH_NONE); | |
8661 | ||
8662 | return CMD_SUCCESS; | |
adbac85e DW |
8663 | } |
8664 | ||
d62a17ae | 8665 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8666 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8667 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8668 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8669 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8670 | |
06370dac DW |
8671 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8672 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8673 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8674 | NEIGHBOR_STR |
8675 | NEIGHBOR_ADDR_STR2 | |
8676 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8677 | { | |
d62a17ae | 8678 | int idx_peer = 1; |
8679 | struct peer *peer; | |
06370dac | 8680 | |
d62a17ae | 8681 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8682 | if (!peer) | |
8683 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8684 | |
dcc68b5e MS |
8685 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8686 | BGP_ADDPATH_BEST_PER_AS); | |
8687 | ||
8688 | return CMD_SUCCESS; | |
06370dac DW |
8689 | } |
8690 | ||
d62a17ae | 8691 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8692 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8693 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8694 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8695 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8696 | |
06370dac DW |
8697 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8698 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8699 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8700 | NO_STR |
8701 | NEIGHBOR_STR | |
8702 | NEIGHBOR_ADDR_STR2 | |
8703 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8704 | { | |
d62a17ae | 8705 | int idx_peer = 2; |
dcc68b5e MS |
8706 | struct peer *peer; |
8707 | ||
8708 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8709 | if (!peer) | |
8710 | return CMD_WARNING_CONFIG_FAILED; | |
8711 | ||
8712 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8713 | != BGP_ADDPATH_BEST_PER_AS) { | |
8714 | vty_out(vty, | |
8715 | "%% Peer not currently configured to transmit all best path per as."); | |
8716 | return CMD_WARNING_CONFIG_FAILED; | |
8717 | } | |
8718 | ||
8719 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8720 | BGP_ADDPATH_NONE); | |
8721 | ||
8722 | return CMD_SUCCESS; | |
06370dac DW |
8723 | } |
8724 | ||
d62a17ae | 8725 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8726 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8727 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8728 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8729 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8730 | |
2b31007c RZ |
8731 | DEFPY( |
8732 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8733 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8734 | NEIGHBOR_STR | |
8735 | NEIGHBOR_ADDR_STR2 | |
8736 | "Detect AS loops before sending to neighbor\n") | |
8737 | { | |
8738 | struct peer *peer; | |
8739 | ||
8740 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8741 | if (!peer) | |
8742 | return CMD_WARNING_CONFIG_FAILED; | |
8743 | ||
8744 | peer->as_path_loop_detection = true; | |
8745 | ||
8746 | return CMD_SUCCESS; | |
8747 | } | |
8748 | ||
8749 | DEFPY( | |
8750 | no_neighbor_aspath_loop_detection, | |
8751 | no_neighbor_aspath_loop_detection_cmd, | |
8752 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8753 | NO_STR | |
8754 | NEIGHBOR_STR | |
8755 | NEIGHBOR_ADDR_STR2 | |
8756 | "Detect AS loops before sending to neighbor\n") | |
8757 | { | |
8758 | struct peer *peer; | |
8759 | ||
8760 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8761 | if (!peer) | |
8762 | return CMD_WARNING_CONFIG_FAILED; | |
8763 | ||
8764 | peer->as_path_loop_detection = false; | |
8765 | ||
8766 | return CMD_SUCCESS; | |
8767 | } | |
8768 | ||
a5c6a9b1 DA |
8769 | DEFPY(neighbor_path_attribute_discard, |
8770 | neighbor_path_attribute_discard_cmd, | |
8771 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard (1-255)...", | |
8772 | NEIGHBOR_STR | |
8773 | NEIGHBOR_ADDR_STR2 | |
8774 | "Manipulate path attributes from incoming UPDATE messages\n" | |
8775 | "Drop specified attributes from incoming UPDATE messages\n" | |
8776 | "Attribute number\n") | |
8777 | { | |
8778 | struct peer *peer; | |
8779 | int idx = 0; | |
8780 | const char *discard_attrs = NULL; | |
8781 | ||
8782 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8783 | if (!peer) | |
8784 | return CMD_WARNING_CONFIG_FAILED; | |
8785 | ||
8786 | argv_find(argv, argc, "(1-255)", &idx); | |
8787 | if (idx) | |
8788 | discard_attrs = argv_concat(argv, argc, idx); | |
8789 | ||
b986d7f4 DA |
8790 | bgp_path_attribute_discard_vty(vty, peer, discard_attrs, true); |
8791 | ||
8792 | return CMD_SUCCESS; | |
8793 | } | |
8794 | ||
8795 | DEFPY(no_neighbor_path_attribute_discard, | |
8796 | no_neighbor_path_attribute_discard_cmd, | |
8797 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard [(1-255)]", | |
8798 | NO_STR | |
8799 | NEIGHBOR_STR | |
8800 | NEIGHBOR_ADDR_STR2 | |
8801 | "Manipulate path attributes from incoming UPDATE messages\n" | |
8802 | "Drop specified attributes from incoming UPDATE messages\n" | |
8803 | "Attribute number\n") | |
8804 | { | |
8805 | struct peer *peer; | |
8806 | int idx = 0; | |
8807 | const char *discard_attrs = NULL; | |
8808 | ||
8809 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8810 | if (!peer) | |
8811 | return CMD_WARNING_CONFIG_FAILED; | |
8812 | ||
8813 | argv_find(argv, argc, "(1-255)", &idx); | |
8814 | if (idx) | |
8815 | discard_attrs = argv[idx]->arg; | |
8816 | ||
8817 | bgp_path_attribute_discard_vty(vty, peer, discard_attrs, false); | |
a5c6a9b1 DA |
8818 | |
8819 | return CMD_SUCCESS; | |
8820 | } | |
8821 | ||
b9c7bc5a | 8822 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8823 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8824 | { |
b9c7bc5a PZ |
8825 | struct ecommunity *ecom = NULL; |
8826 | struct ecommunity *ecomadd; | |
ddb5b488 | 8827 | |
b9c7bc5a | 8828 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8829 | if (is_rt6) |
8830 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8831 | ECOMMUNITY_ROUTE_TARGET, | |
8832 | 0); | |
8833 | else | |
8834 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8835 | ECOMMUNITY_ROUTE_TARGET, | |
8836 | 0); | |
b9c7bc5a PZ |
8837 | if (!ecomadd) { |
8838 | vty_out(vty, "Malformed community-list value\n"); | |
8839 | if (ecom) | |
8840 | ecommunity_free(&ecom); | |
8841 | return CMD_WARNING_CONFIG_FAILED; | |
8842 | } | |
ddb5b488 | 8843 | |
b9c7bc5a PZ |
8844 | if (ecom) { |
8845 | ecommunity_merge(ecom, ecomadd); | |
8846 | ecommunity_free(&ecomadd); | |
8847 | } else { | |
8848 | ecom = ecomadd; | |
8849 | } | |
8850 | } | |
8851 | ||
8852 | if (*list) { | |
8853 | ecommunity_free(&*list); | |
ddb5b488 | 8854 | } |
b9c7bc5a PZ |
8855 | *list = ecom; |
8856 | ||
8857 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8858 | } |
8859 | ||
0ca70ba5 DS |
8860 | /* |
8861 | * v2vimport is true if we are handling a `import vrf ...` command | |
8862 | */ | |
8863 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8864 | { |
0ca70ba5 DS |
8865 | afi_t afi; |
8866 | ||
ddb5b488 | 8867 | switch (vty->node) { |
b9c7bc5a | 8868 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8869 | afi = AFI_IP; |
8870 | break; | |
b9c7bc5a | 8871 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8872 | afi = AFI_IP6; |
8873 | break; | |
ddb5b488 PZ |
8874 | default: |
8875 | vty_out(vty, | |
b9c7bc5a | 8876 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8877 | return AFI_MAX; |
ddb5b488 | 8878 | } |
69b07479 | 8879 | |
0ca70ba5 DS |
8880 | if (!v2vimport) { |
8881 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8882 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8883 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8884 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8885 | vty_out(vty, | |
8886 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8887 | return AFI_MAX; | |
8888 | } | |
8889 | } else { | |
8890 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8891 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8892 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8893 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8894 | vty_out(vty, | |
8895 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8896 | return AFI_MAX; | |
8897 | } | |
8898 | } | |
8899 | return afi; | |
ddb5b488 PZ |
8900 | } |
8901 | ||
585f1adc IR |
8902 | DEFPY (af_rd_vpn_export, |
8903 | af_rd_vpn_export_cmd, | |
8904 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8905 | NO_STR | |
8906 | "Specify route distinguisher\n" | |
8907 | "Between current address-family and vpn\n" | |
8908 | "For routes leaked from current address-family to vpn\n" | |
8909 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8910 | { |
585f1adc IR |
8911 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8912 | struct prefix_rd prd; | |
8913 | int ret; | |
ddb5b488 | 8914 | afi_t afi; |
b9c7bc5a | 8915 | int idx = 0; |
585f1adc | 8916 | bool yes = true; |
b9c7bc5a | 8917 | |
585f1adc IR |
8918 | if (argv_find(argv, argc, "no", &idx)) |
8919 | yes = false; | |
ddb5b488 | 8920 | |
585f1adc IR |
8921 | if (yes) { |
8922 | ret = str2prefix_rd(rd_str, &prd); | |
8923 | if (!ret) { | |
8924 | vty_out(vty, "%% Malformed rd\n"); | |
8925 | return CMD_WARNING_CONFIG_FAILED; | |
8926 | } | |
8927 | } | |
ddb5b488 | 8928 | |
585f1adc IR |
8929 | afi = vpn_policy_getafi(vty, bgp, false); |
8930 | if (afi == AFI_MAX) | |
8931 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8932 | |
585f1adc IR |
8933 | /* |
8934 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8935 | */ | |
8936 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8937 | bgp_get_default(), bgp); | |
ddb5b488 | 8938 | |
585f1adc IR |
8939 | if (yes) { |
8940 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8941 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8942 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8943 | } else { | |
8944 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8945 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8946 | } | |
69b07479 | 8947 | |
585f1adc IR |
8948 | /* post-change: re-export vpn routes */ |
8949 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8950 | bgp_get_default(), bgp); | |
8951 | ||
8952 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8953 | } |
8954 | ||
b9c7bc5a PZ |
8955 | ALIAS (af_rd_vpn_export, |
8956 | af_no_rd_vpn_export_cmd, | |
8957 | "no rd vpn export", | |
ddb5b488 | 8958 | NO_STR |
b9c7bc5a PZ |
8959 | "Specify route distinguisher\n" |
8960 | "Between current address-family and vpn\n" | |
8961 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8962 | |
b9c7bc5a PZ |
8963 | DEFPY (af_label_vpn_export, |
8964 | af_label_vpn_export_cmd, | |
e70e9f8e | 8965 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8966 | NO_STR |
ddb5b488 | 8967 | "label value for VRF\n" |
b9c7bc5a PZ |
8968 | "Between current address-family and vpn\n" |
8969 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8970 | "Label Value <0-1048575>\n" |
8971 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8972 | { |
8973 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8974 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8975 | afi_t afi; |
b9c7bc5a | 8976 | int idx = 0; |
c6423c31 | 8977 | bool yes = true; |
b9c7bc5a PZ |
8978 | |
8979 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8980 | yes = false; |
ddb5b488 | 8981 | |
21a16cc2 PZ |
8982 | /* If "no ...", squash trailing parameter */ |
8983 | if (!yes) | |
8984 | label_auto = NULL; | |
8985 | ||
e70e9f8e PZ |
8986 | if (yes) { |
8987 | if (!label_auto) | |
8988 | label = label_val; /* parser should force unsigned */ | |
8989 | } | |
ddb5b488 | 8990 | |
0ca70ba5 | 8991 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8992 | if (afi == AFI_MAX) |
8993 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8994 | |
e70e9f8e | 8995 | |
69b07479 DS |
8996 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8997 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8998 | /* no change */ | |
8999 | return CMD_SUCCESS; | |
e70e9f8e | 9000 | |
69b07479 DS |
9001 | /* |
9002 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9003 | */ | |
9004 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9005 | bgp_get_default(), bgp); | |
9006 | ||
9007 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9008 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
9009 | ||
9010 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
9011 | ||
9012 | /* | |
9013 | * label has previously been automatically | |
9014 | * assigned by labelpool: release it | |
9015 | * | |
9016 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
9017 | * means the automatic assignment is in flight | |
9018 | * and therefore the labelpool callback must | |
9019 | * detect that the auto label is not needed. | |
9020 | */ | |
9021 | ||
9022 | bgp_lp_release(LP_TYPE_VRF, | |
9023 | &bgp->vpn_policy[afi], | |
9024 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 9025 | } |
69b07479 DS |
9026 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
9027 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9028 | } | |
ddb5b488 | 9029 | |
69b07479 DS |
9030 | bgp->vpn_policy[afi].tovpn_label = label; |
9031 | if (label_auto) { | |
9032 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9033 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9034 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
9035 | vpn_leak_label_callback); | |
ddb5b488 PZ |
9036 | } |
9037 | ||
69b07479 DS |
9038 | /* post-change: re-export vpn routes */ |
9039 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9040 | bgp_get_default(), bgp); | |
9041 | ||
0d020cd6 | 9042 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
9043 | return CMD_SUCCESS; |
9044 | } | |
9045 | ||
b72c9e14 HS |
9046 | DEFPY (af_sid_vpn_export, |
9047 | af_sid_vpn_export_cmd, | |
46279a11 | 9048 | "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>", |
b72c9e14 HS |
9049 | NO_STR |
9050 | "sid value for VRF\n" | |
9051 | "Between current address-family and vpn\n" | |
9052 | "For routes leaked from current address-family to vpn\n" | |
9053 | "Sid allocation index\n" | |
9054 | "Automatically assign a label\n") | |
9055 | { | |
9056 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9057 | afi_t afi; | |
9058 | int debug = 0; | |
9059 | int idx = 0; | |
9060 | bool yes = true; | |
9061 | ||
9062 | if (argv_find(argv, argc, "no", &idx)) | |
9063 | yes = false; | |
9064 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9065 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9066 | ||
9067 | afi = vpn_policy_getafi(vty, bgp, false); | |
9068 | if (afi == AFI_MAX) | |
9069 | return CMD_WARNING_CONFIG_FAILED; | |
9070 | ||
9071 | if (!yes) { | |
9072 | /* implement me */ | |
4d4c404b | 9073 | vty_out(vty, "It's not implemented\n"); |
b72c9e14 HS |
9074 | return CMD_WARNING_CONFIG_FAILED; |
9075 | } | |
9076 | ||
527588aa CS |
9077 | if (bgp->tovpn_sid_index != 0 || |
9078 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
9079 | vty_out(vty, | |
9080 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9081 | "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n"); | |
9082 | return CMD_WARNING_CONFIG_FAILED; | |
9083 | } | |
9084 | ||
b72c9e14 HS |
9085 | /* skip when it's already configured */ |
9086 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
9087 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9088 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
9089 | return CMD_SUCCESS; | |
9090 | ||
7de4c885 HS |
9091 | /* |
9092 | * mode change between sid_idx and sid_auto isn't supported. | |
9093 | * user must negate sid vpn export when they want to change the mode | |
9094 | */ | |
b72c9e14 HS |
9095 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
9096 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9097 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
9098 | vty_out(vty, "it's already configured as %s.\n", | |
9099 | sid_auto ? "auto-mode" : "idx-mode"); | |
9100 | return CMD_WARNING_CONFIG_FAILED; | |
9101 | } | |
9102 | ||
9103 | /* pre-change */ | |
9104 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9105 | bgp_get_default(), bgp); | |
9106 | ||
9107 | if (sid_auto) { | |
9108 | /* SID allocation auto-mode */ | |
9109 | if (debug) | |
9110 | zlog_debug("%s: auto sid alloc.", __func__); | |
9111 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9112 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
9113 | } else { | |
9114 | /* SID allocation index-mode */ | |
9115 | if (debug) | |
9116 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
9117 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
9118 | } | |
9119 | ||
9120 | /* post-change */ | |
9121 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9122 | bgp_get_default(), bgp); | |
9123 | return CMD_SUCCESS; | |
9124 | } | |
9125 | ||
527588aa CS |
9126 | DEFPY (bgp_sid_vpn_export, |
9127 | bgp_sid_vpn_export_cmd, | |
346bbb39 | 9128 | "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>", |
527588aa CS |
9129 | NO_STR |
9130 | "sid value for VRF\n" | |
9131 | "Between current vrf and vpn\n" | |
9132 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9133 | "For routes leaked from current vrf to vpn\n" | |
9134 | "Sid allocation index\n" | |
9135 | "Automatically assign a label\n") | |
9136 | { | |
9137 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9138 | int debug; | |
9139 | ||
9140 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9141 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9142 | ||
9143 | if (no) { | |
e606d8ec CS |
9144 | /* when per-VRF SID is not set, do nothing */ |
9145 | if (bgp->tovpn_sid_index == 0 && | |
9146 | !CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) | |
9147 | return CMD_SUCCESS; | |
9148 | ||
9149 | sid_idx = 0; | |
9150 | sid_auto = false; | |
9151 | bgp->tovpn_sid_index = 0; | |
9152 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
527588aa CS |
9153 | } |
9154 | ||
9155 | if (bgp->vpn_policy[AFI_IP].tovpn_sid_index != 0 || | |
9156 | CHECK_FLAG(bgp->vpn_policy[AFI_IP].flags, | |
9157 | BGP_VPN_POLICY_TOVPN_SID_AUTO) || | |
9158 | bgp->vpn_policy[AFI_IP6].tovpn_sid_index != 0 || | |
9159 | CHECK_FLAG(bgp->vpn_policy[AFI_IP6].flags, | |
9160 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
9161 | vty_out(vty, | |
9162 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9163 | "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n"); | |
9164 | return CMD_WARNING_CONFIG_FAILED; | |
9165 | } | |
9166 | ||
9167 | /* skip when it's already configured */ | |
9168 | if ((sid_idx != 0 && bgp->tovpn_sid_index != 0) || | |
9169 | (sid_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) | |
9170 | return CMD_SUCCESS; | |
9171 | ||
9172 | /* | |
9173 | * mode change between sid_idx and sid_auto isn't supported. | |
9174 | * user must negate sid vpn export when they want to change the mode | |
9175 | */ | |
9176 | if ((sid_auto && bgp->tovpn_sid_index != 0) || | |
9177 | (sid_idx != 0 && | |
9178 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) { | |
9179 | vty_out(vty, "it's already configured as %s.\n", | |
9180 | sid_auto ? "auto-mode" : "idx-mode"); | |
9181 | return CMD_WARNING_CONFIG_FAILED; | |
9182 | } | |
9183 | ||
9184 | /* pre-change */ | |
9185 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9186 | bgp); | |
9187 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp_get_default(), | |
9188 | bgp); | |
9189 | ||
9190 | if (sid_auto) { | |
9191 | /* SID allocation auto-mode */ | |
9192 | if (debug) | |
9193 | zlog_debug("%s: auto per-vrf sid alloc.", __func__); | |
9194 | SET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
e606d8ec | 9195 | } else if (sid_idx != 0) { |
527588aa CS |
9196 | /* SID allocation index-mode */ |
9197 | if (debug) | |
9198 | zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__, | |
9199 | sid_idx); | |
9200 | bgp->tovpn_sid_index = sid_idx; | |
9201 | } | |
9202 | ||
9203 | /* post-change */ | |
9204 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9205 | bgp); | |
9206 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, | |
9207 | bgp_get_default(), bgp); | |
9208 | ||
9209 | return CMD_SUCCESS; | |
9210 | } | |
9211 | ||
b9c7bc5a PZ |
9212 | ALIAS (af_label_vpn_export, |
9213 | af_no_label_vpn_export_cmd, | |
9214 | "no label vpn export", | |
9215 | NO_STR | |
9216 | "label value for VRF\n" | |
9217 | "Between current address-family and vpn\n" | |
9218 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9219 | |
e606d8ec CS |
9220 | ALIAS (bgp_sid_vpn_export, |
9221 | no_bgp_sid_vpn_export_cmd, | |
9222 | "no$no sid vpn per-vrf export", | |
9223 | NO_STR | |
9224 | "sid value for VRF\n" | |
9225 | "Between current vrf and vpn\n" | |
9226 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9227 | "For routes leaked from current vrf to vpn\n") | |
9228 | ||
585f1adc | 9229 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 9230 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9231 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9232 | NO_STR |
ddb5b488 | 9233 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9234 | "Between current address-family and vpn\n" |
9235 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9236 | "IPv4 prefix\n" |
9237 | "IPv6 prefix\n") | |
9238 | { | |
585f1adc | 9239 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 9240 | afi_t afi; |
ddb5b488 PZ |
9241 | struct prefix p; |
9242 | ||
8c85ca28 QY |
9243 | if (!no) { |
9244 | if (!nexthop_su) { | |
9245 | vty_out(vty, "%% Nexthop required\n"); | |
9246 | return CMD_WARNING_CONFIG_FAILED; | |
9247 | } | |
8c85ca28 | 9248 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9249 | return CMD_WARNING_CONFIG_FAILED; |
9250 | } | |
ddb5b488 | 9251 | |
585f1adc IR |
9252 | afi = vpn_policy_getafi(vty, bgp, false); |
9253 | if (afi == AFI_MAX) | |
9254 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9255 | |
585f1adc IR |
9256 | /* |
9257 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9258 | */ | |
9259 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9260 | bgp_get_default(), bgp); | |
ddb5b488 | 9261 | |
585f1adc IR |
9262 | if (!no) { |
9263 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
9264 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9265 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9266 | } else { | |
9267 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
9268 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9269 | } | |
69b07479 | 9270 | |
585f1adc IR |
9271 | /* post-change: re-export vpn routes */ |
9272 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9273 | bgp_get_default(), bgp); | |
37a87b8f | 9274 | |
585f1adc | 9275 | return CMD_SUCCESS; |
ddb5b488 PZ |
9276 | } |
9277 | ||
b9c7bc5a | 9278 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9279 | { |
b9c7bc5a PZ |
9280 | if (!strcmp(dstr, "import")) { |
9281 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9282 | } else if (!strcmp(dstr, "export")) { | |
9283 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9284 | } else if (!strcmp(dstr, "both")) { | |
9285 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9286 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9287 | } else { | |
9288 | vty_out(vty, "%% direction parse error\n"); | |
9289 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9290 | } |
ddb5b488 PZ |
9291 | return CMD_SUCCESS; |
9292 | } | |
9293 | ||
b9c7bc5a PZ |
9294 | DEFPY (af_rt_vpn_imexport, |
9295 | af_rt_vpn_imexport_cmd, | |
9296 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9297 | NO_STR | |
9298 | "Specify route target list\n" | |
ddb5b488 | 9299 | "Specify route target list\n" |
b9c7bc5a PZ |
9300 | "Between current address-family and vpn\n" |
9301 | "For routes leaked from vpn to current address-family: match any\n" | |
9302 | "For routes leaked from current address-family to vpn: set\n" | |
9303 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9304 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9305 | { | |
9306 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9307 | int ret; | |
9308 | struct ecommunity *ecom = NULL; | |
9309 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9310 | enum vpn_policy_direction dir; |
ddb5b488 PZ |
9311 | afi_t afi; |
9312 | int idx = 0; | |
c6423c31 | 9313 | bool yes = true; |
ddb5b488 | 9314 | |
b9c7bc5a | 9315 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9316 | yes = false; |
b9c7bc5a | 9317 | |
0ca70ba5 | 9318 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9319 | if (afi == AFI_MAX) |
9320 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9321 | |
b9c7bc5a | 9322 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9323 | if (ret != CMD_SUCCESS) |
9324 | return ret; | |
9325 | ||
b9c7bc5a PZ |
9326 | if (yes) { |
9327 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9328 | vty_out(vty, "%% Missing RTLIST\n"); | |
9329 | return CMD_WARNING_CONFIG_FAILED; | |
9330 | } | |
c6423c31 | 9331 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9332 | if (ret != CMD_SUCCESS) { |
9333 | return ret; | |
9334 | } | |
ddb5b488 PZ |
9335 | } |
9336 | ||
69b07479 DS |
9337 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9338 | if (!dodir[dir]) | |
ddb5b488 | 9339 | continue; |
ddb5b488 | 9340 | |
69b07479 | 9341 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9342 | |
69b07479 DS |
9343 | if (yes) { |
9344 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9345 | ecommunity_free( | |
9346 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9347 | bgp->vpn_policy[afi].rtlist[dir] = | |
9348 | ecommunity_dup(ecom); | |
9349 | } else { | |
9350 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9351 | ecommunity_free( | |
9352 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9353 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9354 | } |
69b07479 DS |
9355 | |
9356 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9357 | } |
69b07479 | 9358 | |
d555f3e9 PZ |
9359 | if (ecom) |
9360 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9361 | |
9362 | return CMD_SUCCESS; | |
9363 | } | |
9364 | ||
b9c7bc5a PZ |
9365 | ALIAS (af_rt_vpn_imexport, |
9366 | af_no_rt_vpn_imexport_cmd, | |
9367 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9368 | NO_STR |
9369 | "Specify route target list\n" | |
b9c7bc5a PZ |
9370 | "Specify route target list\n" |
9371 | "Between current address-family and vpn\n" | |
9372 | "For routes leaked from vpn to current address-family\n" | |
9373 | "For routes leaked from current address-family to vpn\n" | |
9374 | "both import and export\n") | |
9375 | ||
585f1adc | 9376 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9377 | af_route_map_vpn_imexport_cmd, |
9378 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9379 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9380 | NO_STR | |
ddb5b488 | 9381 | "Specify route map\n" |
b9c7bc5a PZ |
9382 | "Between current address-family and vpn\n" |
9383 | "For routes leaked from vpn to current address-family\n" | |
9384 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9385 | "name of route-map\n") |
9386 | { | |
585f1adc IR |
9387 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9388 | int ret; | |
9389 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9390 | enum vpn_policy_direction dir; |
ddb5b488 | 9391 | afi_t afi; |
ddb5b488 | 9392 | int idx = 0; |
585f1adc | 9393 | bool yes = true; |
ddb5b488 | 9394 | |
585f1adc IR |
9395 | if (argv_find(argv, argc, "no", &idx)) |
9396 | yes = false; | |
ddb5b488 | 9397 | |
585f1adc IR |
9398 | afi = vpn_policy_getafi(vty, bgp, false); |
9399 | if (afi == AFI_MAX) | |
9400 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9401 | |
585f1adc IR |
9402 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
9403 | if (ret != CMD_SUCCESS) | |
9404 | return ret; | |
ddb5b488 | 9405 | |
585f1adc IR |
9406 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9407 | if (!dodir[dir]) | |
9408 | continue; | |
69b07479 | 9409 | |
585f1adc IR |
9410 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
9411 | ||
9412 | if (yes) { | |
9413 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9414 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9415 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9416 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
9417 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9418 | bgp->vpn_policy[afi].rmap[dir] = | |
9419 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9420 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9421 | return CMD_SUCCESS; | |
9422 | } else { | |
9423 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9424 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9425 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9426 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9427 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9428 | } | |
9429 | ||
9430 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9431 | } | |
ddb5b488 | 9432 | |
585f1adc | 9433 | return CMD_SUCCESS; |
ddb5b488 PZ |
9434 | } |
9435 | ||
b9c7bc5a PZ |
9436 | ALIAS (af_route_map_vpn_imexport, |
9437 | af_no_route_map_vpn_imexport_cmd, | |
9438 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9439 | NO_STR |
9440 | "Specify route map\n" | |
b9c7bc5a PZ |
9441 | "Between current address-family and vpn\n" |
9442 | "For routes leaked from vpn to current address-family\n" | |
9443 | "For routes leaked from current address-family to vpn\n") | |
9444 | ||
bb4f6190 | 9445 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9446 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9447 | "Import routes from another VRF\n" |
9448 | "Vrf routes being filtered\n" | |
9449 | "Specify route map\n" | |
9450 | "name of route-map\n") | |
9451 | { | |
9452 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9453 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
bb4f6190 | 9454 | afi_t afi; |
bb4f6190 DS |
9455 | struct bgp *bgp_default; |
9456 | ||
0ca70ba5 | 9457 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9458 | if (afi == AFI_MAX) |
9459 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9460 | |
9461 | bgp_default = bgp_get_default(); | |
9462 | if (!bgp_default) { | |
9463 | int32_t ret; | |
9464 | as_t as = bgp->as; | |
9465 | ||
9466 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
9467 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
9468 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
9469 | |
9470 | if (ret) { | |
9471 | vty_out(vty, | |
9472 | "VRF default is not configured as a bgp instance\n"); | |
9473 | return CMD_WARNING; | |
9474 | } | |
9475 | } | |
9476 | ||
69b07479 | 9477 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9478 | |
ae6a6fb4 DS |
9479 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9480 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9481 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9482 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9483 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9484 | bgp->vpn_policy[afi].rmap[dir] = | |
9485 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9486 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9487 | return CMD_SUCCESS; | |
9488 | ||
9489 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9490 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9491 | |
69b07479 DS |
9492 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9493 | ||
bb4f6190 DS |
9494 | return CMD_SUCCESS; |
9495 | } | |
9496 | ||
ae6a6fb4 DS |
9497 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9498 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9499 | NO_STR |
9500 | "Import routes from another VRF\n" | |
9501 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9502 | "Specify route map\n" |
9503 | "name of route-map\n") | |
9504 | { | |
9505 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9506 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
ae6a6fb4 DS |
9507 | afi_t afi; |
9508 | ||
9509 | afi = vpn_policy_getafi(vty, bgp, true); | |
9510 | if (afi == AFI_MAX) | |
9511 | return CMD_WARNING_CONFIG_FAILED; | |
9512 | ||
9513 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9514 | ||
9515 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9516 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9517 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9518 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9519 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9520 | ||
9521 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9522 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9523 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9524 | ||
9525 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9526 | ||
9527 | return CMD_SUCCESS; | |
9528 | } | |
bb4f6190 | 9529 | |
585f1adc IR |
9530 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
9531 | "[no] import vrf VIEWVRFNAME$import_name", | |
9532 | NO_STR | |
9533 | "Import routes from another VRF\n" | |
9534 | "VRF to import from\n" | |
9535 | "The name of the VRF\n") | |
12a844a5 | 9536 | { |
585f1adc IR |
9537 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9538 | struct listnode *node; | |
9539 | struct bgp *vrf_bgp, *bgp_default; | |
9540 | int32_t ret = 0; | |
9541 | as_t as = bgp->as; | |
9542 | bool remove = false; | |
9543 | int32_t idx = 0; | |
9544 | char *vname; | |
9545 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
9546 | safi_t safi; |
9547 | afi_t afi; | |
9548 | ||
867f0cca | 9549 | if (import_name == NULL) { |
9550 | vty_out(vty, "%% Missing import name\n"); | |
9551 | return CMD_WARNING; | |
9552 | } | |
9553 | ||
ae6a6fb4 DS |
9554 | if (strcmp(import_name, "route-map") == 0) { |
9555 | vty_out(vty, "%% Must include route-map name\n"); | |
9556 | return CMD_WARNING; | |
9557 | } | |
9558 | ||
585f1adc IR |
9559 | if (argv_find(argv, argc, "no", &idx)) |
9560 | remove = true; | |
9561 | ||
9562 | afi = vpn_policy_getafi(vty, bgp, true); | |
9563 | if (afi == AFI_MAX) | |
9564 | return CMD_WARNING_CONFIG_FAILED; | |
9565 | ||
12a844a5 DS |
9566 | safi = bgp_node_safi(vty); |
9567 | ||
585f1adc IR |
9568 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
9569 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
9570 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
9571 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
9572 | remove ? "unimport" : "import", import_name); | |
9573 | return CMD_WARNING; | |
9574 | } | |
25679caa | 9575 | |
585f1adc IR |
9576 | bgp_default = bgp_get_default(); |
9577 | if (!bgp_default) { | |
9578 | /* Auto-create assuming the same AS */ | |
9579 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
9580 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 9581 | |
585f1adc IR |
9582 | if (ret) { |
9583 | vty_out(vty, | |
9584 | "VRF default is not configured as a bgp instance\n"); | |
9585 | return CMD_WARNING; | |
9586 | } | |
9587 | } | |
12a844a5 | 9588 | |
585f1adc IR |
9589 | vrf_bgp = bgp_lookup_by_name(import_name); |
9590 | if (!vrf_bgp) { | |
9591 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
9592 | vrf_bgp = bgp_default; | |
9593 | else | |
9594 | /* Auto-create assuming the same AS */ | |
9595 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
9596 | ||
9597 | if (ret) { | |
9598 | vty_out(vty, | |
9599 | "VRF %s is not configured as a bgp instance\n", | |
9600 | import_name); | |
9601 | return CMD_WARNING; | |
9602 | } | |
9603 | } | |
9604 | ||
9605 | if (remove) { | |
9606 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
9607 | } else { | |
9608 | /* Already importing from "import_vrf"? */ | |
9609 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
9610 | vname)) { | |
9611 | if (strcmp(vname, import_name) == 0) | |
9612 | return CMD_WARNING; | |
9613 | } | |
9614 | ||
9615 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
9616 | } | |
9617 | ||
9618 | return CMD_SUCCESS; | |
12a844a5 DS |
9619 | } |
9620 | ||
b9c7bc5a | 9621 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 9622 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
9623 | bgp_imexport_vpn_cmd, |
9624 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9625 | NO_STR |
9626 | "Import routes to this address-family\n" | |
9627 | "Export routes from this address-family\n" | |
9628 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9629 | { |
585f1adc IR |
9630 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9631 | int previous_state; | |
37a87b8f | 9632 | afi_t afi; |
585f1adc IR |
9633 | safi_t safi; |
9634 | int idx = 0; | |
9635 | bool yes = true; | |
9636 | int flag; | |
9c2fd3fe | 9637 | enum vpn_policy_direction dir; |
585f1adc IR |
9638 | |
9639 | if (argv_find(argv, argc, "no", &idx)) | |
9640 | yes = false; | |
9641 | ||
9642 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
9643 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
9644 | ||
9645 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
9646 | return CMD_WARNING_CONFIG_FAILED; | |
9647 | } | |
ddb5b488 | 9648 | |
b9c7bc5a PZ |
9649 | afi = bgp_node_afi(vty); |
9650 | safi = bgp_node_safi(vty); | |
585f1adc IR |
9651 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
9652 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
9653 | return CMD_WARNING_CONFIG_FAILED; | |
9654 | } | |
ddb5b488 | 9655 | |
b9c7bc5a | 9656 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
9657 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
9658 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 9659 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
9660 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
9661 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
9662 | } else { |
9663 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9664 | return CMD_WARNING_CONFIG_FAILED; | |
9665 | } | |
9666 | ||
585f1adc | 9667 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 9668 | |
585f1adc IR |
9669 | if (yes) { |
9670 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9671 | if (!previous_state) { | |
9672 | /* trigger export current vrf */ | |
9673 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9674 | } | |
9675 | } else { | |
9676 | if (previous_state) { | |
9677 | /* trigger un-export current vrf */ | |
9678 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9679 | } | |
9680 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9681 | } | |
37a87b8f | 9682 | |
1ca2fd11 IR |
9683 | hook_call(bgp_snmp_init_stats, bgp); |
9684 | ||
585f1adc | 9685 | return CMD_SUCCESS; |
ddb5b488 PZ |
9686 | } |
9687 | ||
301ad80a PG |
9688 | DEFPY (af_routetarget_import, |
9689 | af_routetarget_import_cmd, | |
9a659715 | 9690 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9691 | NO_STR |
9692 | "Specify route target list\n" | |
9693 | "Specify route target list\n" | |
9a659715 PG |
9694 | "Specify route target list\n" |
9695 | "Specify route target list\n" | |
301ad80a PG |
9696 | "Flow-spec redirect type route target\n" |
9697 | "Import routes to this address-family\n" | |
9a659715 | 9698 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9699 | { |
9700 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9701 | int ret; | |
9702 | struct ecommunity *ecom = NULL; | |
301ad80a | 9703 | afi_t afi; |
9a659715 | 9704 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9705 | bool yes = true; |
9706 | bool rt6 = false; | |
301ad80a PG |
9707 | |
9708 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9709 | yes = false; |
301ad80a | 9710 | |
9a659715 PG |
9711 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9712 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9713 | rt6 = true; |
301ad80a | 9714 | |
0ca70ba5 | 9715 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9716 | if (afi == AFI_MAX) |
9717 | return CMD_WARNING_CONFIG_FAILED; | |
9718 | ||
9a659715 PG |
9719 | if (rt6 && afi != AFI_IP6) |
9720 | return CMD_WARNING_CONFIG_FAILED; | |
9721 | ||
301ad80a PG |
9722 | if (yes) { |
9723 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9724 | vty_out(vty, "%% Missing RTLIST\n"); | |
9725 | return CMD_WARNING_CONFIG_FAILED; | |
9726 | } | |
9a659715 | 9727 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9728 | if (ret != CMD_SUCCESS) |
9729 | return ret; | |
9730 | } | |
69b07479 DS |
9731 | |
9732 | if (yes) { | |
9733 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9734 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9735 | .import_redirect_rtlist); |
69b07479 DS |
9736 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9737 | ecommunity_dup(ecom); | |
9738 | } else { | |
9739 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9740 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9741 | .import_redirect_rtlist); |
69b07479 | 9742 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9743 | } |
69b07479 | 9744 | |
301ad80a PG |
9745 | if (ecom) |
9746 | ecommunity_free(&ecom); | |
9747 | ||
9748 | return CMD_SUCCESS; | |
9749 | } | |
9750 | ||
505e5056 | 9751 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9752 | address_family_ipv4_safi_cmd, |
9753 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9754 | "Enter Address Family command mode\n" | |
00e6edb9 | 9755 | BGP_AF_STR |
7c40bf39 | 9756 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 9757 | { |
f51bae9c | 9758 | |
d62a17ae | 9759 | if (argc == 3) { |
585f1adc IR |
9760 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9761 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9762 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9763 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9764 | && safi != SAFI_EVPN) { |
31947174 MK |
9765 | vty_out(vty, |
9766 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9767 | return CMD_WARNING_CONFIG_FAILED; |
9768 | } | |
585f1adc IR |
9769 | vty->node = bgp_node_type(AFI_IP, safi); |
9770 | } else | |
9771 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9772 | |
d62a17ae | 9773 | return CMD_SUCCESS; |
718e3744 | 9774 | } |
9775 | ||
505e5056 | 9776 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9777 | address_family_ipv6_safi_cmd, |
9778 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9779 | "Enter Address Family command mode\n" | |
00e6edb9 | 9780 | BGP_AF_STR |
7c40bf39 | 9781 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 9782 | { |
d62a17ae | 9783 | if (argc == 3) { |
585f1adc IR |
9784 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9785 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9786 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9787 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9788 | && safi != SAFI_EVPN) { |
31947174 MK |
9789 | vty_out(vty, |
9790 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9791 | return CMD_WARNING_CONFIG_FAILED; |
9792 | } | |
585f1adc IR |
9793 | vty->node = bgp_node_type(AFI_IP6, safi); |
9794 | } else | |
9795 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9796 | |
d62a17ae | 9797 | return CMD_SUCCESS; |
25ffbdc1 | 9798 | } |
718e3744 | 9799 | |
d6902373 | 9800 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9801 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9802 | address_family_vpnv4_cmd, |
8334fd5a | 9803 | "address-family vpnv4 [unicast]", |
718e3744 | 9804 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9805 | BGP_AF_STR |
9806 | BGP_AF_MODIFIER_STR) | |
718e3744 | 9807 | { |
d62a17ae | 9808 | vty->node = BGP_VPNV4_NODE; |
9809 | return CMD_SUCCESS; | |
718e3744 | 9810 | } |
9811 | ||
505e5056 | 9812 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9813 | address_family_vpnv6_cmd, |
8334fd5a | 9814 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9815 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9816 | BGP_AF_STR |
9817 | BGP_AF_MODIFIER_STR) | |
8ecd3266 | 9818 | { |
d62a17ae | 9819 | vty->node = BGP_VPNV6_NODE; |
9820 | return CMD_SUCCESS; | |
8ecd3266 | 9821 | } |
64e4a6c5 | 9822 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9823 | |
505e5056 | 9824 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9825 | address_family_evpn_cmd, |
7111c1a0 | 9826 | "address-family l2vpn evpn", |
4e0b7b6d | 9827 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9828 | BGP_AF_STR |
9829 | BGP_AF_MODIFIER_STR) | |
4e0b7b6d | 9830 | { |
2131d5cf | 9831 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9832 | vty->node = BGP_EVPN_NODE; |
9833 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9834 | } |
9835 | ||
bfaab44d HS |
9836 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9837 | bgp_segment_routing_srv6_cmd, | |
9838 | "segment-routing srv6", | |
9839 | "Segment-Routing configuration\n" | |
9840 | "Segment-Routing SRv6 configuration\n") | |
9841 | { | |
9842 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9843 | bgp->srv6_enabled = true; |
bfaab44d HS |
9844 | vty->node = BGP_SRV6_NODE; |
9845 | return CMD_SUCCESS; | |
9846 | } | |
9847 | ||
0249b8b6 HS |
9848 | DEFUN (no_bgp_segment_routing_srv6, |
9849 | no_bgp_segment_routing_srv6_cmd, | |
9850 | "no segment-routing srv6", | |
9851 | NO_STR | |
9852 | "Segment-Routing configuration\n" | |
9853 | "Segment-Routing SRv6 configuration\n") | |
9854 | { | |
9855 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9856 | ||
9857 | if (strlen(bgp->srv6_locator_name) > 0) | |
9858 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9859 | return CMD_WARNING_CONFIG_FAILED; | |
9860 | ||
9861 | bgp->srv6_enabled = false; | |
9862 | return CMD_SUCCESS; | |
9863 | } | |
9864 | ||
a0281b2e HS |
9865 | DEFPY (bgp_srv6_locator, |
9866 | bgp_srv6_locator_cmd, | |
9867 | "locator NAME$name", | |
9868 | "Specify SRv6 locator\n" | |
9869 | "Specify SRv6 locator\n") | |
9870 | { | |
9871 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9872 | int ret; |
a0281b2e HS |
9873 | |
9874 | if (strlen(bgp->srv6_locator_name) > 0 | |
9875 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9876 | vty_out(vty, "srv6 locator is already configured\n"); | |
9877 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9878 | } |
9879 | ||
9880 | snprintf(bgp->srv6_locator_name, | |
9881 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9882 | |
7de4c885 | 9883 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9884 | if (ret < 0) |
9885 | return CMD_WARNING_CONFIG_FAILED; | |
9886 | ||
9887 | return CMD_SUCCESS; | |
9888 | } | |
9889 | ||
0249b8b6 HS |
9890 | DEFPY (no_bgp_srv6_locator, |
9891 | no_bgp_srv6_locator_cmd, | |
9892 | "no locator NAME$name", | |
9893 | NO_STR | |
9894 | "Specify SRv6 locator\n" | |
9895 | "Specify SRv6 locator\n") | |
9896 | { | |
9897 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9898 | ||
9899 | /* when locator isn't configured, do nothing */ | |
9900 | if (strlen(bgp->srv6_locator_name) < 1) | |
9901 | return CMD_SUCCESS; | |
9902 | ||
9903 | /* name validation */ | |
9904 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9905 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9906 | return CMD_WARNING_CONFIG_FAILED; | |
9907 | } | |
9908 | ||
9909 | /* unset locator */ | |
9910 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9911 | return CMD_WARNING_CONFIG_FAILED; | |
9912 | ||
9913 | return CMD_SUCCESS; | |
9914 | } | |
9915 | ||
ea372e81 HS |
9916 | DEFPY (show_bgp_srv6, |
9917 | show_bgp_srv6_cmd, | |
9918 | "show bgp segment-routing srv6", | |
9919 | SHOW_STR | |
9920 | BGP_STR | |
9921 | "BGP Segment Routing\n" | |
9922 | "BGP Segment Routing SRv6\n") | |
9923 | { | |
9924 | struct bgp *bgp; | |
9925 | struct listnode *node; | |
1c21a234 | 9926 | struct srv6_locator_chunk *chunk; |
ea372e81 | 9927 | struct bgp_srv6_function *func; |
ea372e81 HS |
9928 | |
9929 | bgp = bgp_get_default(); | |
96db4340 | 9930 | if (!bgp) |
ea372e81 HS |
9931 | return CMD_SUCCESS; |
9932 | ||
9933 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9934 | vty_out(vty, "locator_chunks:\n"); | |
dccef127 | 9935 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { |
511211bf | 9936 | vty_out(vty, "- %pFX\n", &chunk->prefix); |
dccef127 CS |
9937 | vty_out(vty, " block-length: %d\n", chunk->block_bits_length); |
9938 | vty_out(vty, " node-length: %d\n", chunk->node_bits_length); | |
9939 | vty_out(vty, " func-length: %d\n", | |
9940 | chunk->function_bits_length); | |
9941 | vty_out(vty, " arg-length: %d\n", chunk->argument_bits_length); | |
9942 | } | |
ea372e81 HS |
9943 | |
9944 | vty_out(vty, "functions:\n"); | |
9945 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
07380148 | 9946 | vty_out(vty, "- sid: %pI6\n", &func->sid); |
ea372e81 HS |
9947 | vty_out(vty, " locator: %s\n", func->locator_name); |
9948 | } | |
9949 | ||
9950 | vty_out(vty, "bgps:\n"); | |
9951 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9952 | vty_out(vty, "- name: %s\n", | |
9953 | bgp->name ? bgp->name : "default"); | |
9954 | ||
1830895a CS |
9955 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n", |
9956 | bgp->vpn_policy[AFI_IP].tovpn_sid); | |
9957 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n", | |
9958 | bgp->vpn_policy[AFI_IP6].tovpn_sid); | |
9f5d4430 | 9959 | vty_out(vty, " per-vrf tovpn_sid: %pI6\n", bgp->tovpn_sid); |
ea372e81 HS |
9960 | } |
9961 | ||
9962 | return CMD_SUCCESS; | |
9963 | } | |
9964 | ||
505e5056 | 9965 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9966 | exit_address_family_cmd, |
9967 | "exit-address-family", | |
9968 | "Exit from Address Family configuration mode\n") | |
9969 | { | |
d62a17ae | 9970 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9971 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9972 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9973 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9974 | || vty->node == BGP_EVPN_NODE |
9975 | || vty->node == BGP_FLOWSPECV4_NODE | |
9976 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9977 | vty->node = BGP_NODE; |
9978 | return CMD_SUCCESS; | |
718e3744 | 9979 | } |
6b0655a2 | 9980 | |
8ad7271d | 9981 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9982 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9983 | const char *ip_str, afi_t afi, safi_t safi, | |
9984 | struct prefix_rd *prd) | |
9985 | { | |
9986 | int ret; | |
9987 | struct prefix match; | |
9bcb3eef DS |
9988 | struct bgp_dest *dest; |
9989 | struct bgp_dest *rm; | |
d62a17ae | 9990 | struct bgp *bgp; |
9991 | struct bgp_table *table; | |
9992 | struct bgp_table *rib; | |
9993 | ||
9994 | /* BGP structure lookup. */ | |
9995 | if (view_name) { | |
9996 | bgp = bgp_lookup_by_name(view_name); | |
9997 | if (bgp == NULL) { | |
9998 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9999 | view_name); | |
10000 | return CMD_WARNING; | |
10001 | } | |
10002 | } else { | |
10003 | bgp = bgp_get_default(); | |
10004 | if (bgp == NULL) { | |
10005 | vty_out(vty, "%% No BGP process is configured\n"); | |
10006 | return CMD_WARNING; | |
10007 | } | |
10008 | } | |
10009 | ||
10010 | /* Check IP address argument. */ | |
10011 | ret = str2prefix(ip_str, &match); | |
10012 | if (!ret) { | |
10013 | vty_out(vty, "%% address is malformed\n"); | |
10014 | return CMD_WARNING; | |
10015 | } | |
10016 | ||
10017 | match.family = afi2family(afi); | |
10018 | rib = bgp->rib[afi][safi]; | |
10019 | ||
10020 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
10021 | for (dest = bgp_table_top(rib); dest; |
10022 | dest = bgp_route_next(dest)) { | |
10023 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 10024 | |
9bcb3eef | 10025 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 10026 | continue; |
10027 | ||
9bcb3eef | 10028 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
10029 | if (table == NULL) |
10030 | continue; | |
10031 | ||
4953391b DA |
10032 | rm = bgp_node_match(table, &match); |
10033 | if (rm != NULL) { | |
b54892e0 | 10034 | const struct prefix *rm_p = |
9bcb3eef | 10035 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
10036 | |
10037 | if (rm_p->prefixlen == match.prefixlen) { | |
10038 | SET_FLAG(rm->flags, | |
10039 | BGP_NODE_USER_CLEAR); | |
10040 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 10041 | } |
9bcb3eef | 10042 | bgp_dest_unlock_node(rm); |
d62a17ae | 10043 | } |
10044 | } | |
10045 | } else { | |
4953391b DA |
10046 | dest = bgp_node_match(rib, &match); |
10047 | if (dest != NULL) { | |
9bcb3eef | 10048 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 10049 | |
9bcb3eef DS |
10050 | if (dest_p->prefixlen == match.prefixlen) { |
10051 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
10052 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 10053 | } |
9bcb3eef | 10054 | bgp_dest_unlock_node(dest); |
d62a17ae | 10055 | } |
10056 | } | |
10057 | ||
10058 | return CMD_SUCCESS; | |
8ad7271d DS |
10059 | } |
10060 | ||
b09b5ae0 | 10061 | /* one clear bgp command to rule them all */ |
718e3744 | 10062 | DEFUN (clear_ip_bgp_all, |
10063 | clear_ip_bgp_all_cmd, | |
3cb14f26 | 10064 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]", |
718e3744 | 10065 | CLEAR_STR |
10066 | IP_STR | |
10067 | BGP_STR | |
838758ac | 10068 | BGP_INSTANCE_HELP_STR |
510afcd6 | 10069 | BGP_AFI_HELP_STR |
00e6edb9 | 10070 | BGP_AF_STR |
510afcd6 | 10071 | BGP_SAFI_WITH_LABEL_HELP_STR |
00e6edb9 | 10072 | BGP_AF_MODIFIER_STR |
b09b5ae0 | 10073 | "Clear all peers\n" |
453c92f6 | 10074 | "BGP IPv4 neighbor to clear\n" |
a80beece | 10075 | "BGP IPv6 neighbor to clear\n" |
838758ac | 10076 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
10077 | "Clear peers with the AS number\n" |
10078 | "Clear all external peers\n" | |
718e3744 | 10079 | "Clear all members of peer-group\n" |
b09b5ae0 | 10080 | "BGP peer-group name\n" |
b09b5ae0 DW |
10081 | BGP_SOFT_STR |
10082 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
10083 | BGP_SOFT_OUT_STR |
10084 | BGP_SOFT_IN_STR | |
10085 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
3cb14f26 DS |
10086 | BGP_SOFT_OUT_STR |
10087 | "Reset message statistics\n") | |
718e3744 | 10088 | { |
d62a17ae | 10089 | char *vrf = NULL; |
10090 | ||
dc912615 DS |
10091 | afi_t afi = AFI_UNSPEC; |
10092 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 10093 | enum clear_sort clr_sort = clear_peer; |
10094 | enum bgp_clear_type clr_type; | |
10095 | char *clr_arg = NULL; | |
10096 | ||
10097 | int idx = 0; | |
10098 | ||
10099 | /* clear [ip] bgp */ | |
10100 | if (argv_find(argv, argc, "ip", &idx)) | |
10101 | afi = AFI_IP; | |
10102 | ||
9a8bdf1c PG |
10103 | /* [<vrf> VIEWVRFNAME] */ |
10104 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10105 | vrf = argv[idx + 1]->arg; | |
10106 | idx += 2; | |
10107 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10108 | vrf = NULL; | |
10109 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10110 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 10111 | vrf = argv[idx + 1]->arg; |
10112 | idx += 2; | |
10113 | } | |
d62a17ae | 10114 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10115 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
10116 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10117 | ||
d7b9898c | 10118 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 10119 | if (argv_find(argv, argc, "*", &idx)) { |
10120 | clr_sort = clear_all; | |
10121 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
10122 | clr_sort = clear_peer; | |
10123 | clr_arg = argv[idx]->arg; | |
10124 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
10125 | clr_sort = clear_peer; | |
10126 | clr_arg = argv[idx]->arg; | |
10127 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
10128 | clr_sort = clear_group; | |
10129 | idx++; | |
10130 | clr_arg = argv[idx]->arg; | |
d7b9898c | 10131 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 10132 | clr_sort = clear_peer; |
10133 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
10134 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
10135 | clr_sort = clear_peer; | |
10136 | clr_arg = argv[idx]->arg; | |
d62a17ae | 10137 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
10138 | clr_sort = clear_as; | |
10139 | clr_arg = argv[idx]->arg; | |
10140 | } else if (argv_find(argv, argc, "external", &idx)) { | |
10141 | clr_sort = clear_external; | |
10142 | } | |
10143 | ||
3cb14f26 | 10144 | /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */ |
d62a17ae | 10145 | if (argv_find(argv, argc, "soft", &idx)) { |
10146 | if (argv_find(argv, argc, "in", &idx) | |
10147 | || argv_find(argv, argc, "out", &idx)) | |
10148 | clr_type = strmatch(argv[idx]->text, "in") | |
10149 | ? BGP_CLEAR_SOFT_IN | |
10150 | : BGP_CLEAR_SOFT_OUT; | |
10151 | else | |
10152 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
10153 | } else if (argv_find(argv, argc, "in", &idx)) { | |
10154 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
10155 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
10156 | : BGP_CLEAR_SOFT_IN; | |
10157 | } else if (argv_find(argv, argc, "out", &idx)) { | |
10158 | clr_type = BGP_CLEAR_SOFT_OUT; | |
3cb14f26 DS |
10159 | } else if (argv_find(argv, argc, "message-stats", &idx)) { |
10160 | clr_type = BGP_CLEAR_MESSAGE_STATS; | |
d62a17ae | 10161 | } else |
10162 | clr_type = BGP_CLEAR_SOFT_NONE; | |
10163 | ||
1ca2fd11 | 10164 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 10165 | } |
01080f7c | 10166 | |
8ad7271d DS |
10167 | DEFUN (clear_ip_bgp_prefix, |
10168 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 10169 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
10170 | CLEAR_STR |
10171 | IP_STR | |
10172 | BGP_STR | |
838758ac | 10173 | BGP_INSTANCE_HELP_STR |
8ad7271d | 10174 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10175 | "IPv4 prefix\n") |
8ad7271d | 10176 | { |
d62a17ae | 10177 | char *vrf = NULL; |
10178 | char *prefix = NULL; | |
8ad7271d | 10179 | |
d62a17ae | 10180 | int idx = 0; |
01080f7c | 10181 | |
d62a17ae | 10182 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
10183 | if (argv_find(argv, argc, "vrf", &idx)) { |
10184 | vrf = argv[idx + 1]->arg; | |
10185 | idx += 2; | |
10186 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10187 | vrf = NULL; | |
10188 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10189 | /* [<view> VIEWVRFNAME] */ | |
10190 | vrf = argv[idx + 1]->arg; | |
10191 | idx += 2; | |
10192 | } | |
0c7b1b01 | 10193 | |
d62a17ae | 10194 | prefix = argv[argc - 1]->arg; |
8ad7271d | 10195 | |
d62a17ae | 10196 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 10197 | } |
8ad7271d | 10198 | |
b09b5ae0 DW |
10199 | DEFUN (clear_bgp_ipv6_safi_prefix, |
10200 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 10201 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10202 | CLEAR_STR |
3a2d747c | 10203 | IP_STR |
718e3744 | 10204 | BGP_STR |
00e6edb9 | 10205 | BGP_AF_STR |
46f296b4 | 10206 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10207 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10208 | "IPv6 prefix\n") |
718e3744 | 10209 | { |
9b475e76 PG |
10210 | int idx_safi = 0; |
10211 | int idx_ipv6_prefix = 0; | |
10212 | safi_t safi = SAFI_UNICAST; | |
10213 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10214 | argv[idx_ipv6_prefix]->arg : NULL; | |
10215 | ||
10216 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 10217 | return bgp_clear_prefix( |
9b475e76 PG |
10218 | vty, NULL, prefix, AFI_IP6, |
10219 | safi, NULL); | |
838758ac | 10220 | } |
01080f7c | 10221 | |
b09b5ae0 DW |
10222 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
10223 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 10224 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10225 | CLEAR_STR |
3a2d747c | 10226 | IP_STR |
718e3744 | 10227 | BGP_STR |
838758ac | 10228 | BGP_INSTANCE_HELP_STR |
00e6edb9 | 10229 | BGP_AF_STR |
46f296b4 | 10230 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10231 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10232 | "IPv6 prefix\n") |
718e3744 | 10233 | { |
9b475e76 | 10234 | int idx_safi = 0; |
9a8bdf1c | 10235 | int idx_vrfview = 0; |
9b475e76 PG |
10236 | int idx_ipv6_prefix = 0; |
10237 | safi_t safi = SAFI_UNICAST; | |
10238 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10239 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 10240 | char *vrfview = NULL; |
9b475e76 | 10241 | |
9a8bdf1c PG |
10242 | /* [<view|vrf> VIEWVRFNAME] */ |
10243 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
10244 | vrfview = argv[idx_vrfview + 1]->arg; | |
10245 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
10246 | vrfview = NULL; | |
10247 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
10248 | /* [<view> VIEWVRFNAME] */ | |
10249 | vrfview = argv[idx_vrfview + 1]->arg; | |
10250 | } | |
9b475e76 PG |
10251 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
10252 | ||
d62a17ae | 10253 | return bgp_clear_prefix( |
9b475e76 PG |
10254 | vty, vrfview, prefix, |
10255 | AFI_IP6, safi, NULL); | |
718e3744 | 10256 | } |
10257 | ||
b09b5ae0 DW |
10258 | DEFUN (show_bgp_views, |
10259 | show_bgp_views_cmd, | |
d6e3c605 | 10260 | "show [ip] bgp views", |
b09b5ae0 | 10261 | SHOW_STR |
d6e3c605 | 10262 | IP_STR |
01080f7c | 10263 | BGP_STR |
b09b5ae0 | 10264 | "Show the defined BGP views\n") |
01080f7c | 10265 | { |
d62a17ae | 10266 | struct list *inst = bm->bgp; |
10267 | struct listnode *node; | |
10268 | struct bgp *bgp; | |
01080f7c | 10269 | |
d62a17ae | 10270 | vty_out(vty, "Defined BGP views:\n"); |
10271 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10272 | /* Skip VRFs. */ | |
10273 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
10274 | continue; | |
10275 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
10276 | bgp->as); | |
10277 | } | |
e52702f2 | 10278 | |
d62a17ae | 10279 | return CMD_SUCCESS; |
e0081f70 ML |
10280 | } |
10281 | ||
4acd6bc9 SPG |
10282 | static inline void calc_peers_cfgd_estbd(struct bgp *bgp, int *peers_cfgd, |
10283 | int *peers_estbd) | |
10284 | { | |
10285 | struct peer *peer; | |
10286 | struct listnode *node; | |
10287 | ||
10288 | *peers_cfgd = *peers_estbd = 0; | |
10289 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { | |
10290 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10291 | continue; | |
10292 | (*peers_cfgd)++; | |
10293 | if (peer_established(peer)) | |
10294 | (*peers_estbd)++; | |
10295 | } | |
10296 | } | |
10297 | ||
10298 | static void print_bgp_vrfs(struct bgp *bgp, struct vty *vty, json_object *json, | |
10299 | const char *type) | |
10300 | { | |
10301 | int peers_cfg, peers_estb; | |
10302 | ||
10303 | calc_peers_cfgd_estbd(bgp, &peers_cfg, &peers_estb); | |
10304 | ||
10305 | if (json) { | |
10306 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) | |
10307 | ? -1 | |
10308 | : (int64_t)bgp->vrf_id; | |
10309 | json_object_string_add(json, "type", type); | |
10310 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
10311 | json_object_string_addf(json, "routerId", "%pI4", | |
10312 | &bgp->router_id); | |
10313 | json_object_int_add(json, "numConfiguredPeers", peers_cfg); | |
10314 | json_object_int_add(json, "numEstablishedPeers", peers_estb); | |
10315 | json_object_int_add(json, "l3vni", bgp->l3vni); | |
10316 | json_object_string_addf(json, "rmac", "%pEA", &bgp->rmac); | |
10317 | json_object_string_add( | |
10318 | json, "interface", | |
10319 | ifindex2ifname(bgp->l3vni_svi_ifindex, bgp->vrf_id)); | |
10320 | } | |
10321 | } | |
10322 | ||
10323 | static int show_bgp_vrfs_detail_common(struct vty *vty, struct bgp *bgp, | |
10324 | json_object *json, const char *name, | |
10325 | const char *type, bool use_vrf) | |
10326 | { | |
10327 | int peers_cfg, peers_estb; | |
10328 | ||
10329 | calc_peers_cfgd_estbd(bgp, &peers_cfg, &peers_estb); | |
10330 | ||
10331 | if (use_vrf) { | |
10332 | if (json) { | |
10333 | print_bgp_vrfs(bgp, vty, json, type); | |
10334 | } else { | |
10335 | vty_out(vty, "BGP instance %s VRF id %d\n", | |
10336 | bgp->name_pretty, | |
10337 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10338 | : (int)bgp->vrf_id); | |
10339 | vty_out(vty, "Router Id %pI4\n", &bgp->router_id); | |
10340 | vty_out(vty, | |
10341 | "Num Configured Peers %d, Established %d\n", | |
10342 | peers_cfg, peers_estb); | |
10343 | if (bgp->l3vni) { | |
10344 | vty_out(vty, | |
10345 | "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n", | |
10346 | bgp->l3vni, | |
10347 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10348 | bgp->vrf_id), | |
10349 | &bgp->rmac); | |
10350 | } | |
10351 | } | |
10352 | } else { | |
10353 | if (json) { | |
10354 | print_bgp_vrfs(bgp, vty, json, type); | |
10355 | } else { | |
10356 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", | |
10357 | type, | |
10358 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10359 | : (int)bgp->vrf_id, | |
10360 | &bgp->router_id, peers_cfg, peers_estb, name); | |
10361 | vty_out(vty, "%11s %-16u %-21pEA %-20s\n", " ", | |
10362 | bgp->l3vni, &bgp->rmac, | |
10363 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10364 | bgp->vrf_id)); | |
10365 | } | |
10366 | } | |
10367 | ||
10368 | return CMD_SUCCESS; | |
10369 | } | |
10370 | ||
10371 | DEFPY (show_bgp_vrfs, | |
8386ac43 | 10372 | show_bgp_vrfs_cmd, |
4acd6bc9 | 10373 | "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]", |
8386ac43 | 10374 | SHOW_STR |
d6e3c605 | 10375 | IP_STR |
8386ac43 | 10376 | BGP_STR |
10377 | "Show BGP VRFs\n" | |
4acd6bc9 | 10378 | "Specific VRF name\n" |
9973d184 | 10379 | JSON_STR) |
8386ac43 | 10380 | { |
d62a17ae | 10381 | struct list *inst = bm->bgp; |
10382 | struct listnode *node; | |
10383 | struct bgp *bgp; | |
9f049418 | 10384 | bool uj = use_json(argc, argv); |
d62a17ae | 10385 | json_object *json = NULL; |
10386 | json_object *json_vrfs = NULL; | |
4acd6bc9 | 10387 | json_object *json_vrf = NULL; |
d62a17ae | 10388 | int count = 0; |
4acd6bc9 SPG |
10389 | const char *name = vrf_name; |
10390 | const char *type; | |
d62a17ae | 10391 | |
4acd6bc9 | 10392 | if (uj) |
d62a17ae | 10393 | json = json_object_new_object(); |
4acd6bc9 SPG |
10394 | |
10395 | if (name) { | |
10396 | if (strmatch(name, VRF_DEFAULT_NAME)) { | |
10397 | bgp = bgp_get_default(); | |
10398 | type = "DFLT"; | |
10399 | } else { | |
10400 | bgp = bgp_lookup_by_name(name); | |
10401 | type = "VRF"; | |
10402 | } | |
10403 | if (!bgp) { | |
10404 | if (uj) | |
10405 | vty_json(vty, json); | |
10406 | else | |
10407 | vty_out(vty, | |
10408 | "%% Specified BGP instance not found\n"); | |
10409 | ||
10410 | return CMD_WARNING; | |
10411 | } | |
10412 | } | |
10413 | ||
10414 | if (vrf_name) { | |
10415 | if (uj) | |
10416 | json_vrf = json_object_new_object(); | |
10417 | ||
10418 | show_bgp_vrfs_detail_common(vty, bgp, json_vrf, name, type, | |
10419 | true); | |
10420 | ||
10421 | if (uj) { | |
10422 | json_object_object_add(json, name, json_vrf); | |
10423 | vty_json(vty, json); | |
10424 | } | |
10425 | ||
10426 | return CMD_SUCCESS; | |
d62a17ae | 10427 | } |
10428 | ||
4acd6bc9 SPG |
10429 | if (uj) |
10430 | json_vrfs = json_object_new_object(); | |
10431 | ||
d62a17ae | 10432 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { |
4acd6bc9 | 10433 | const char *name; |
d62a17ae | 10434 | |
10435 | /* Skip Views. */ | |
10436 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
10437 | continue; | |
10438 | ||
10439 | count++; | |
efb4077a | 10440 | if (!uj && count == 1) { |
fe1dc5a3 | 10441 | vty_out(vty, |
efb4077a | 10442 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 10443 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
10444 | "#PeersEstb", "Name"); |
10445 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
10446 | "L3-VNI", "RouterMAC", "Interface"); | |
10447 | } | |
d62a17ae | 10448 | if (uj) |
10449 | json_vrf = json_object_new_object(); | |
10450 | ||
d62a17ae | 10451 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { |
5742e42b | 10452 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10453 | type = "DFLT"; |
10454 | } else { | |
10455 | name = bgp->name; | |
10456 | type = "VRF"; | |
10457 | } | |
10458 | ||
4acd6bc9 SPG |
10459 | show_bgp_vrfs_detail_common(vty, bgp, json_vrf, name, type, |
10460 | false); | |
a8bf7d9c | 10461 | |
4acd6bc9 | 10462 | if (uj) |
d62a17ae | 10463 | json_object_object_add(json_vrfs, name, json_vrf); |
d62a17ae | 10464 | } |
10465 | ||
10466 | if (uj) { | |
10467 | json_object_object_add(json, "vrfs", json_vrfs); | |
d62a17ae | 10468 | json_object_int_add(json, "totalVrfs", count); |
75eeda93 | 10469 | vty_json(vty, json); |
d62a17ae | 10470 | } else { |
10471 | if (count) | |
10472 | vty_out(vty, | |
10473 | "\nTotal number of VRFs (including default): %d\n", | |
10474 | count); | |
10475 | } | |
10476 | ||
10477 | return CMD_SUCCESS; | |
8386ac43 | 10478 | } |
10479 | ||
48ecf8f5 DS |
10480 | DEFUN (show_bgp_mac_hash, |
10481 | show_bgp_mac_hash_cmd, | |
10482 | "show bgp mac hash", | |
10483 | SHOW_STR | |
10484 | BGP_STR | |
10485 | "Mac Address\n" | |
10486 | "Mac Address database\n") | |
10487 | { | |
10488 | bgp_mac_dump_table(vty); | |
10489 | ||
10490 | return CMD_SUCCESS; | |
10491 | } | |
acf71666 | 10492 | |
e3b78da8 | 10493 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10494 | { |
0291c246 | 10495 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10496 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10497 | |
23d0a753 | 10498 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10499 | } |
10500 | ||
10501 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10502 | { | |
10503 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10504 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10505 | |
10506 | vty_out(vty, "Tunnel-ip database:\n"); | |
10507 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10508 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10509 | vty); |
10510 | } | |
10511 | ||
15c81ca4 DS |
10512 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10513 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10514 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10515 | "martian next-hops\n" |
10516 | "martian next-hop database\n") | |
acf71666 | 10517 | { |
0291c246 | 10518 | struct bgp *bgp = NULL; |
15c81ca4 | 10519 | int idx = 0; |
9a8bdf1c PG |
10520 | char *name = NULL; |
10521 | ||
10522 | /* [<vrf> VIEWVRFNAME] */ | |
10523 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10524 | name = argv[idx + 1]->arg; | |
10525 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10526 | name = NULL; | |
10527 | } else if (argv_find(argv, argc, "view", &idx)) | |
10528 | /* [<view> VIEWVRFNAME] */ | |
10529 | name = argv[idx + 1]->arg; | |
10530 | if (name) | |
10531 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10532 | else |
10533 | bgp = bgp_get_default(); | |
acf71666 | 10534 | |
acf71666 MK |
10535 | if (!bgp) { |
10536 | vty_out(vty, "%% No BGP process is configured\n"); | |
10537 | return CMD_WARNING; | |
10538 | } | |
10539 | bgp_show_martian_nexthops(vty, bgp); | |
10540 | ||
10541 | return CMD_SUCCESS; | |
10542 | } | |
10543 | ||
f412b39a | 10544 | DEFUN (show_bgp_memory, |
4bf6a362 | 10545 | show_bgp_memory_cmd, |
7fa12b13 | 10546 | "show [ip] bgp memory", |
4bf6a362 | 10547 | SHOW_STR |
3a2d747c | 10548 | IP_STR |
4bf6a362 PJ |
10549 | BGP_STR |
10550 | "Global BGP memory statistics\n") | |
10551 | { | |
d62a17ae | 10552 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10553 | unsigned long count; | |
10554 | ||
10555 | /* RIB related usage stats */ | |
10556 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10557 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10558 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10559 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10560 | |
10561 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10562 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10563 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10564 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10565 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10566 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10567 | count, | |
4b7e6066 DS |
10568 | mtype_memstr( |
10569 | memstrbuf, sizeof(memstrbuf), | |
10570 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10571 | |
10572 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10573 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10574 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10575 | count * sizeof(struct bgp_static))); | |
10576 | ||
10577 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10578 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10579 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10580 | count * sizeof(struct bpacket))); | |
10581 | ||
10582 | /* Adj-In/Out */ | |
10583 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10584 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10585 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10586 | count * sizeof(struct bgp_adj_in))); | |
10587 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10588 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10589 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10590 | count * sizeof(struct bgp_adj_out))); | |
10591 | ||
10592 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10593 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10594 | count, | |
10595 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10596 | count * sizeof(struct bgp_nexthop_cache))); | |
10597 | ||
10598 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10599 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10600 | count, | |
10601 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10602 | count * sizeof(struct bgp_damp_info))); | |
10603 | ||
10604 | /* Attributes */ | |
10605 | count = attr_count(); | |
10606 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10607 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10608 | count * sizeof(struct attr))); | |
10609 | ||
10610 | if ((count = attr_unknown_count())) | |
10611 | vty_out(vty, "%ld unknown attributes\n", count); | |
10612 | ||
10613 | /* AS_PATH attributes */ | |
10614 | count = aspath_count(); | |
10615 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10616 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10617 | count * sizeof(struct aspath))); | |
10618 | ||
10619 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10620 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10621 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10622 | count * sizeof(struct assegment))); | |
10623 | ||
10624 | /* Other attributes */ | |
10625 | if ((count = community_count())) | |
10626 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10627 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10628 | count * sizeof(struct community))); | |
d62a17ae | 10629 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
145f7619 DA |
10630 | vty_out(vty, |
10631 | "%ld BGP ext-community entries, using %s of memory\n", | |
10632 | count, | |
10633 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10634 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10635 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10636 | vty_out(vty, | |
10637 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10638 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10639 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10640 | |
10641 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10642 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10643 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10644 | count * sizeof(struct cluster_list))); | |
10645 | ||
10646 | /* Peer related usage */ | |
10647 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10648 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10649 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10650 | count * sizeof(struct peer))); | |
10651 | ||
10652 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10653 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10654 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10655 | count * sizeof(struct peer_group))); | |
10656 | ||
10657 | /* Other */ | |
d62a17ae | 10658 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10659 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10660 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10661 | count * sizeof(regex_t))); | |
d62a17ae | 10662 | return CMD_SUCCESS; |
4bf6a362 | 10663 | } |
fee0f4c6 | 10664 | |
57a9c8a8 DS |
10665 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10666 | { | |
10667 | json_object *bestpath = json_object_new_object(); | |
10668 | ||
892fedb6 | 10669 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10670 | json_object_string_add(bestpath, "asPath", "ignore"); |
10671 | ||
892fedb6 | 10672 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10673 | json_object_string_add(bestpath, "asPath", "confed"); |
10674 | ||
892fedb6 DA |
10675 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10676 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10677 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10678 | "as-set"); |
10679 | else | |
a4d82a8a | 10680 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10681 | "true"); |
10682 | } else | |
a4d82a8a | 10683 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10684 | |
ee88563a JM |
10685 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
10686 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
10687 | ||
892fedb6 | 10688 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10689 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10690 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10691 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10692 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10693 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10694 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10695 | json_object_string_add(bestpath, "med", |
10696 | "missing-as-worst"); | |
10697 | else | |
10698 | json_object_string_add(bestpath, "med", "true"); | |
10699 | } | |
10700 | ||
10701 | json_object_object_add(json, "bestPath", bestpath); | |
10702 | } | |
10703 | ||
3577f1c5 DD |
10704 | /* Print the error code/subcode for why the peer is down */ |
10705 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10706 | json_object *json_peer, bool use_json) | |
10707 | { | |
10708 | const char *code_str; | |
10709 | const char *subcode_str; | |
10710 | ||
10711 | if (use_json) { | |
10712 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10713 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10714 | char errorcodesubcode_hexstr[5]; | |
10715 | char errorcodesubcode_str[256]; | |
10716 | ||
10717 | code_str = bgp_notify_code_str(peer->notify.code); | |
10718 | subcode_str = bgp_notify_subcode_str( | |
10719 | peer->notify.code, | |
10720 | peer->notify.subcode); | |
10721 | ||
772270f3 QY |
10722 | snprintf(errorcodesubcode_hexstr, |
10723 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10724 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10725 | json_object_string_add(json_peer, |
10726 | "lastErrorCodeSubcode", | |
10727 | errorcodesubcode_hexstr); | |
10728 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10729 | code_str, subcode_str); | |
10730 | json_object_string_add(json_peer, | |
10731 | "lastNotificationReason", | |
10732 | errorcodesubcode_str); | |
eea685b6 DA |
10733 | json_object_boolean_add(json_peer, |
10734 | "lastNotificationHardReset", | |
10735 | peer->notify.hard_reset); | |
3577f1c5 DD |
10736 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
10737 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10738 | && (peer->notify.subcode | |
10739 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10740 | || peer->notify.subcode | |
10741 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10742 | && peer->notify.length) { | |
10743 | char msgbuf[1024]; | |
10744 | const char *msg_str; | |
10745 | ||
10746 | msg_str = bgp_notify_admin_message( | |
10747 | msgbuf, sizeof(msgbuf), | |
10748 | (uint8_t *)peer->notify.data, | |
10749 | peer->notify.length); | |
10750 | if (msg_str) | |
10751 | json_object_string_add( | |
10752 | json_peer, | |
10753 | "lastShutdownDescription", | |
10754 | msg_str); | |
10755 | } | |
10756 | ||
c258527b | 10757 | } |
3577f1c5 DD |
10758 | json_object_string_add(json_peer, "lastResetDueTo", |
10759 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10760 | json_object_int_add(json_peer, "lastResetCode", |
10761 | peer->last_reset); | |
3577f1c5 DD |
10762 | } else { |
10763 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10764 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10765 | code_str = bgp_notify_code_str(peer->notify.code); | |
10766 | subcode_str = | |
10767 | bgp_notify_subcode_str(peer->notify.code, | |
10768 | peer->notify.subcode); | |
eea685b6 | 10769 | vty_out(vty, " Notification %s (%s%s%s)\n", |
3577f1c5 | 10770 | peer->last_reset == PEER_DOWN_NOTIFY_SEND |
eea685b6 DA |
10771 | ? "sent" |
10772 | : "received", | |
10773 | code_str, subcode_str, | |
10774 | peer->notify.hard_reset | |
10775 | ? bgp_notify_subcode_str( | |
10776 | BGP_NOTIFY_CEASE, | |
10777 | BGP_NOTIFY_CEASE_HARD_RESET) | |
10778 | : ""); | |
3577f1c5 | 10779 | } else { |
e91c24c8 | 10780 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10781 | peer_down_str[(int)peer->last_reset]); |
10782 | } | |
10783 | } | |
10784 | } | |
10785 | ||
10786 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10787 | safi_t safi) | |
10788 | { | |
feb17238 | 10789 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10790 | } |
10791 | ||
10792 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10793 | struct peer *peer, json_object *json_peer, | |
10794 | int max_neighbor_width, bool use_json) | |
10795 | { | |
10796 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10797 | int len; | |
10798 | ||
10799 | if (use_json) { | |
10800 | if (peer_dynamic_neighbor(peer)) | |
10801 | json_object_boolean_true_add(json_peer, | |
10802 | "dynamicPeer"); | |
10803 | if (peer->hostname) | |
10804 | json_object_string_add(json_peer, "hostname", | |
10805 | peer->hostname); | |
10806 | ||
10807 | if (peer->domainname) | |
10808 | json_object_string_add(json_peer, "domainname", | |
10809 | peer->domainname); | |
10810 | json_object_int_add(json_peer, "connectionsEstablished", | |
10811 | peer->established); | |
10812 | json_object_int_add(json_peer, "connectionsDropped", | |
10813 | peer->dropped); | |
10814 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10815 | use_json, json_peer); | |
feb17238 | 10816 | if (peer_established(peer)) |
3577f1c5 DD |
10817 | json_object_string_add(json_peer, "lastResetDueTo", |
10818 | "AFI/SAFI Not Negotiated"); | |
10819 | else | |
10820 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10821 | } else { | |
10822 | dn_flag[1] = '\0'; | |
10823 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10824 | if (peer->hostname | |
892fedb6 | 10825 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10826 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10827 | peer->hostname, peer->host); | |
10828 | else | |
10829 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10830 | ||
10831 | /* pad the neighbor column with spaces */ | |
10832 | if (len < max_neighbor_width) | |
10833 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10834 | " "); | |
e91c24c8 | 10835 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10836 | peer->dropped, |
10837 | peer_uptime(peer->uptime, timebuf, | |
10838 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10839 | if (peer_established(peer)) |
3577f1c5 DD |
10840 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10841 | else | |
10842 | bgp_show_peer_reset(vty, peer, NULL, | |
10843 | false); | |
10844 | } | |
10845 | } | |
c258527b | 10846 | |
565e9ddd | 10847 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10848 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10849 | { | |
10850 | static char stripped[BUFSIZ]; | |
64541ffa FD |
10851 | uint32_t i = 0; |
10852 | uint32_t last_space = 0; | |
cb75bb31 | 10853 | |
64541ffa FD |
10854 | while (i < size) { |
10855 | if (*(desc + i) == 0) { | |
10856 | stripped[i] = '\0'; | |
10857 | return stripped; | |
10858 | } | |
10859 | if (i != 0 && *(desc + i) == ' ' && last_space != i - 1) | |
10860 | last_space = i; | |
10861 | stripped[i] = *(desc + i); | |
10862 | i++; | |
10863 | } | |
10864 | ||
10865 | if (last_space > size) | |
10866 | stripped[size + 1] = '\0'; | |
10867 | else | |
10868 | stripped[last_space] = '\0'; | |
cb75bb31 DA |
10869 | |
10870 | return stripped; | |
10871 | } | |
3577f1c5 | 10872 | |
8c1d4cd5 LS |
10873 | /* Determine whether var peer should be filtered out of the summary. */ |
10874 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10875 | struct peer *fpeer, int as_type, | |
10876 | as_t as) | |
10877 | { | |
10878 | ||
10879 | /* filter neighbor XXXX */ | |
10880 | if (fpeer && fpeer != peer) | |
10881 | return true; | |
10882 | ||
10883 | /* filter remote-as (internal|external) */ | |
10884 | if (as_type != AS_UNSPECIFIED) { | |
10885 | if (peer->as_type == AS_SPECIFIED) { | |
10886 | if (as_type == AS_INTERNAL) { | |
10887 | if (peer->as != peer->local_as) | |
10888 | return true; | |
10889 | } else if (peer->as == peer->local_as) | |
10890 | return true; | |
10891 | } else if (as_type != peer->as_type) | |
10892 | return true; | |
10893 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10894 | return true; | |
10895 | ||
10896 | return false; | |
10897 | } | |
10898 | ||
565e9ddd DA |
10899 | /* Show BGP peer's summary information. |
10900 | * | |
10901 | * Peer's description is stripped according to if `wide` option is given | |
10902 | * or not. | |
10903 | * | |
10904 | * When adding new columns to `show bgp summary` output, please make | |
10905 | * sure `Desc` is the lastest column to show because it can contain | |
10906 | * whitespaces and the whole output will be tricky. | |
10907 | */ | |
d62a17ae | 10908 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10909 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10910 | uint16_t show_flags) |
d62a17ae | 10911 | { |
10912 | struct peer *peer; | |
10913 | struct listnode *node, *nnode; | |
10914 | unsigned int count = 0, dn_count = 0; | |
10915 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10916 | char neighbor_buf[VTY_BUFSIZ]; | |
10917 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10918 | int len, failed_count = 0; |
ce1944f0 | 10919 | unsigned int filtered_count = 0; |
d62a17ae | 10920 | int max_neighbor_width = 0; |
10921 | int pfx_rcd_safi; | |
3c13337d | 10922 | json_object *json = NULL; |
d62a17ae | 10923 | json_object *json_peer = NULL; |
10924 | json_object *json_peers = NULL; | |
50e05855 | 10925 | struct peer_af *paf; |
d3ada366 | 10926 | struct bgp_filter *filter; |
85eeb029 DA |
10927 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10928 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10929 | bool show_established = | |
10930 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10931 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10932 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10933 | |
10934 | /* labeled-unicast routes are installed in the unicast table so in order | |
10935 | * to | |
10936 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10937 | */ | |
3577f1c5 | 10938 | |
d62a17ae | 10939 | if (safi == SAFI_LABELED_UNICAST) |
10940 | pfx_rcd_safi = SAFI_UNICAST; | |
10941 | else | |
10942 | pfx_rcd_safi = safi; | |
10943 | ||
10944 | if (use_json) { | |
3c13337d | 10945 | json = json_object_new_object(); |
d62a17ae | 10946 | json_peers = json_object_new_object(); |
3577f1c5 | 10947 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10948 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10949 | as_type, as)) { | |
ce1944f0 | 10950 | filtered_count++; |
8c1d4cd5 LS |
10951 | count++; |
10952 | continue; | |
10953 | } | |
10954 | ||
3577f1c5 DD |
10955 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10956 | continue; | |
10957 | ||
10958 | if (peer->afc[afi][safi]) { | |
10959 | /* See if we have at least a single failed peer */ | |
10960 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10961 | failed_count++; | |
10962 | count++; | |
10963 | } | |
10964 | if (peer_dynamic_neighbor(peer)) | |
10965 | dn_count++; | |
10966 | } | |
c258527b | 10967 | |
d62a17ae | 10968 | } else { |
10969 | /* Loop over all neighbors that will be displayed to determine | |
10970 | * how many | |
10971 | * characters are needed for the Neighbor column | |
10972 | */ | |
10973 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10974 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10975 | as_type, as)) { | |
ce1944f0 | 10976 | filtered_count++; |
8c1d4cd5 LS |
10977 | count++; |
10978 | continue; | |
10979 | } | |
10980 | ||
d62a17ae | 10981 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10982 | continue; | |
10983 | ||
10984 | if (peer->afc[afi][safi]) { | |
10985 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10986 | if (peer_dynamic_neighbor(peer)) | |
10987 | dn_flag[0] = '*'; | |
10988 | ||
10989 | if (peer->hostname | |
892fedb6 DA |
10990 | && CHECK_FLAG(bgp->flags, |
10991 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10992 | snprintf(neighbor_buf, |
10993 | sizeof(neighbor_buf), | |
10994 | "%s%s(%s) ", dn_flag, | |
10995 | peer->hostname, peer->host); | |
d62a17ae | 10996 | else |
772270f3 QY |
10997 | snprintf(neighbor_buf, |
10998 | sizeof(neighbor_buf), "%s%s ", | |
10999 | dn_flag, peer->host); | |
d62a17ae | 11000 | |
11001 | len = strlen(neighbor_buf); | |
11002 | ||
11003 | if (len > max_neighbor_width) | |
11004 | max_neighbor_width = len; | |
c258527b | 11005 | |
3577f1c5 DD |
11006 | /* See if we have at least a single failed peer */ |
11007 | if (bgp_has_peer_failed(peer, afi, safi)) | |
11008 | failed_count++; | |
11009 | count++; | |
d62a17ae | 11010 | } |
11011 | } | |
f933309e | 11012 | |
d62a17ae | 11013 | /* Originally we displayed the Neighbor column as 16 |
11014 | * characters wide so make that the default | |
11015 | */ | |
11016 | if (max_neighbor_width < neighbor_col_default_width) | |
11017 | max_neighbor_width = neighbor_col_default_width; | |
11018 | } | |
f933309e | 11019 | |
3577f1c5 DD |
11020 | if (show_failed && !failed_count) { |
11021 | if (use_json) { | |
11022 | json_object_int_add(json, "failedPeersCount", 0); | |
11023 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 11024 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 | 11025 | |
75eeda93 | 11026 | vty_json(vty, json); |
3577f1c5 DD |
11027 | } else { |
11028 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
11029 | } |
11030 | return CMD_SUCCESS; | |
11031 | } | |
c258527b | 11032 | |
3577f1c5 | 11033 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 11034 | filtered_count = 0; |
800867d8 | 11035 | dn_count = 0; |
d62a17ae | 11036 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
11037 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
11038 | continue; | |
11039 | ||
ea47320b DL |
11040 | if (!peer->afc[afi][safi]) |
11041 | continue; | |
d62a17ae | 11042 | |
ea47320b DL |
11043 | if (!count) { |
11044 | unsigned long ents; | |
11045 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 11046 | int64_t vrf_id_ui; |
d62a17ae | 11047 | |
a4d82a8a PZ |
11048 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
11049 | ? -1 | |
11050 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
11051 | |
11052 | /* Usage summary and header */ | |
11053 | if (use_json) { | |
c949c771 DA |
11054 | json_object_string_addf(json, "routerId", |
11055 | "%pI4", | |
11056 | &bgp->router_id); | |
60466a63 QY |
11057 | json_object_int_add(json, "as", bgp->as); |
11058 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
11059 | json_object_string_add( |
11060 | json, "vrfName", | |
11061 | (bgp->inst_type | |
11062 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11063 | ? VRF_DEFAULT_NAME |
ea47320b DL |
11064 | : bgp->name); |
11065 | } else { | |
11066 | vty_out(vty, | |
23d0a753 DA |
11067 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
11068 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
11069 | bgp->vrf_id == VRF_UNKNOWN |
11070 | ? -1 | |
11071 | : (int)bgp->vrf_id); | |
ea47320b DL |
11072 | vty_out(vty, "\n"); |
11073 | } | |
d62a17ae | 11074 | |
ea47320b | 11075 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 11076 | if (use_json) { |
ea47320b | 11077 | json_object_int_add( |
60466a63 | 11078 | json, "updateDelayLimit", |
ea47320b | 11079 | bgp->v_update_delay); |
d62a17ae | 11080 | |
ea47320b DL |
11081 | if (bgp->v_update_delay |
11082 | != bgp->v_establish_wait) | |
d62a17ae | 11083 | json_object_int_add( |
11084 | json, | |
ea47320b DL |
11085 | "updateDelayEstablishWait", |
11086 | bgp->v_establish_wait); | |
d62a17ae | 11087 | |
60466a63 | 11088 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11089 | json_object_string_add( |
11090 | json, | |
11091 | "updateDelayFirstNeighbor", | |
11092 | bgp->update_delay_begin_time); | |
11093 | json_object_boolean_true_add( | |
11094 | json, | |
11095 | "updateDelayInProgress"); | |
11096 | } else { | |
11097 | if (bgp->update_delay_over) { | |
d62a17ae | 11098 | json_object_string_add( |
11099 | json, | |
11100 | "updateDelayFirstNeighbor", | |
11101 | bgp->update_delay_begin_time); | |
ea47320b | 11102 | json_object_string_add( |
d62a17ae | 11103 | json, |
ea47320b DL |
11104 | "updateDelayBestpathResumed", |
11105 | bgp->update_delay_end_time); | |
11106 | json_object_string_add( | |
d62a17ae | 11107 | json, |
ea47320b DL |
11108 | "updateDelayZebraUpdateResume", |
11109 | bgp->update_delay_zebra_resume_time); | |
11110 | json_object_string_add( | |
11111 | json, | |
11112 | "updateDelayPeerUpdateResume", | |
11113 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11114 | } |
ea47320b DL |
11115 | } |
11116 | } else { | |
11117 | vty_out(vty, | |
11118 | "Read-only mode update-delay limit: %d seconds\n", | |
11119 | bgp->v_update_delay); | |
11120 | if (bgp->v_update_delay | |
11121 | != bgp->v_establish_wait) | |
d62a17ae | 11122 | vty_out(vty, |
ea47320b DL |
11123 | " Establish wait: %d seconds\n", |
11124 | bgp->v_establish_wait); | |
d62a17ae | 11125 | |
60466a63 | 11126 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11127 | vty_out(vty, |
11128 | " First neighbor established: %s\n", | |
11129 | bgp->update_delay_begin_time); | |
11130 | vty_out(vty, | |
11131 | " Delay in progress\n"); | |
11132 | } else { | |
11133 | if (bgp->update_delay_over) { | |
d62a17ae | 11134 | vty_out(vty, |
11135 | " First neighbor established: %s\n", | |
11136 | bgp->update_delay_begin_time); | |
11137 | vty_out(vty, | |
ea47320b DL |
11138 | " Best-paths resumed: %s\n", |
11139 | bgp->update_delay_end_time); | |
11140 | vty_out(vty, | |
11141 | " zebra update resumed: %s\n", | |
11142 | bgp->update_delay_zebra_resume_time); | |
11143 | vty_out(vty, | |
11144 | " peers update resumed: %s\n", | |
11145 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11146 | } |
11147 | } | |
11148 | } | |
ea47320b | 11149 | } |
d62a17ae | 11150 | |
ea47320b DL |
11151 | if (use_json) { |
11152 | if (bgp_maxmed_onstartup_configured(bgp) | |
11153 | && bgp->maxmed_active) | |
11154 | json_object_boolean_true_add( | |
60466a63 | 11155 | json, "maxMedOnStartup"); |
ea47320b DL |
11156 | if (bgp->v_maxmed_admin) |
11157 | json_object_boolean_true_add( | |
60466a63 | 11158 | json, "maxMedAdministrative"); |
d62a17ae | 11159 | |
ea47320b DL |
11160 | json_object_int_add( |
11161 | json, "tableVersion", | |
60466a63 | 11162 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 11163 | |
60466a63 QY |
11164 | ents = bgp_table_count(bgp->rib[afi][safi]); |
11165 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
11166 | json_object_int_add( |
11167 | json, "ribMemory", | |
9bcb3eef | 11168 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 11169 | |
210ec2a0 | 11170 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
11171 | json_object_int_add(json, "peerCount", ents); |
11172 | json_object_int_add(json, "peerMemory", | |
11173 | ents * sizeof(struct peer)); | |
d62a17ae | 11174 | |
ea47320b DL |
11175 | if ((ents = listcount(bgp->group))) { |
11176 | json_object_int_add( | |
60466a63 | 11177 | json, "peerGroupCount", ents); |
ea47320b DL |
11178 | json_object_int_add( |
11179 | json, "peerGroupMemory", | |
996c9314 LB |
11180 | ents * sizeof(struct |
11181 | peer_group)); | |
ea47320b | 11182 | } |
d62a17ae | 11183 | |
ea47320b DL |
11184 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
11185 | BGP_CONFIG_DAMPENING)) | |
11186 | json_object_boolean_true_add( | |
60466a63 | 11187 | json, "dampeningEnabled"); |
ea47320b | 11188 | } else { |
96c81f66 LS |
11189 | if (!show_terse) { |
11190 | if (bgp_maxmed_onstartup_configured(bgp) | |
11191 | && bgp->maxmed_active) | |
11192 | vty_out(vty, | |
11193 | "Max-med on-startup active\n"); | |
11194 | if (bgp->v_maxmed_admin) | |
11195 | vty_out(vty, | |
11196 | "Max-med administrative active\n"); | |
d62a17ae | 11197 | |
96c81f66 LS |
11198 | vty_out(vty, |
11199 | "BGP table version %" PRIu64 | |
11200 | "\n", | |
11201 | bgp_table_version( | |
11202 | bgp->rib[afi][safi])); | |
ea47320b | 11203 | |
96c81f66 LS |
11204 | ents = bgp_table_count( |
11205 | bgp->rib[afi][safi]); | |
d62a17ae | 11206 | vty_out(vty, |
96c81f66 | 11207 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 11208 | ents, |
11209 | mtype_memstr( | |
11210 | memstrbuf, | |
11211 | sizeof(memstrbuf), | |
96c81f66 LS |
11212 | ents |
11213 | * sizeof( | |
11214 | struct | |
11215 | bgp_dest))); | |
d62a17ae | 11216 | |
96c81f66 LS |
11217 | /* Peer related usage */ |
11218 | ents = bgp->af_peer_count[afi][safi]; | |
11219 | vty_out(vty, | |
11220 | "Peers %ld, using %s of memory\n", | |
11221 | ents, | |
11222 | mtype_memstr( | |
11223 | memstrbuf, | |
11224 | sizeof(memstrbuf), | |
11225 | ents | |
11226 | * sizeof( | |
11227 | struct | |
11228 | peer))); | |
d62a17ae | 11229 | |
96c81f66 LS |
11230 | if ((ents = listcount(bgp->group))) |
11231 | vty_out(vty, | |
11232 | "Peer groups %ld, using %s of memory\n", | |
11233 | ents, | |
11234 | mtype_memstr( | |
11235 | memstrbuf, | |
11236 | sizeof(memstrbuf), | |
11237 | ents | |
11238 | * sizeof( | |
11239 | struct | |
11240 | peer_group))); | |
11241 | ||
11242 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
11243 | BGP_CONFIG_DAMPENING)) | |
11244 | vty_out(vty, | |
11245 | "Dampening enabled.\n"); | |
11246 | } | |
11247 | if (show_failed) { | |
11248 | vty_out(vty, "\n"); | |
11249 | ||
11250 | /* Subtract 8 here because 'Neighbor' is | |
11251 | * 8 characters */ | |
11252 | vty_out(vty, "Neighbor"); | |
11253 | vty_out(vty, "%*s", | |
11254 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
11255 | vty_out(vty, |
11256 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 11257 | } |
d62a17ae | 11258 | } |
ea47320b | 11259 | } |
d62a17ae | 11260 | |
d55811cc | 11261 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 11262 | filter = &peer->filter[afi][safi]; |
db92d226 | 11263 | |
ea47320b | 11264 | count++; |
3577f1c5 DD |
11265 | /* Works for both failed & successful cases */ |
11266 | if (peer_dynamic_neighbor(peer)) | |
11267 | dn_count++; | |
d62a17ae | 11268 | |
ea47320b | 11269 | if (use_json) { |
3577f1c5 | 11270 | json_peer = NULL; |
8c1d4cd5 | 11271 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11272 | as_type, as)) { |
11273 | filtered_count++; | |
8c1d4cd5 | 11274 | continue; |
ce1944f0 | 11275 | } |
3577f1c5 DD |
11276 | if (show_failed && |
11277 | bgp_has_peer_failed(peer, afi, safi)) { | |
11278 | json_peer = json_object_new_object(); | |
11279 | bgp_show_failed_summary(vty, bgp, peer, | |
11280 | json_peer, 0, use_json); | |
11281 | } else if (!show_failed) { | |
10b49f14 | 11282 | if (show_established |
ce1944f0 LS |
11283 | && bgp_has_peer_failed(peer, afi, safi)) { |
11284 | filtered_count++; | |
10b49f14 | 11285 | continue; |
ce1944f0 | 11286 | } |
10b49f14 | 11287 | |
3577f1c5 DD |
11288 | json_peer = json_object_new_object(); |
11289 | if (peer_dynamic_neighbor(peer)) { | |
11290 | json_object_boolean_true_add(json_peer, | |
11291 | "dynamicPeer"); | |
11292 | } | |
d62a17ae | 11293 | |
3577f1c5 DD |
11294 | if (peer->hostname) |
11295 | json_object_string_add(json_peer, "hostname", | |
11296 | peer->hostname); | |
11297 | ||
11298 | if (peer->domainname) | |
11299 | json_object_string_add(json_peer, "domainname", | |
11300 | peer->domainname); | |
11301 | ||
11302 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
11303 | json_object_int_add( |
11304 | json_peer, "localAs", | |
11305 | peer->change_local_as | |
11306 | ? peer->change_local_as | |
11307 | : peer->local_as); | |
3577f1c5 DD |
11308 | json_object_int_add(json_peer, "version", 4); |
11309 | json_object_int_add(json_peer, "msgRcvd", | |
11310 | PEER_TOTAL_RX(peer)); | |
11311 | json_object_int_add(json_peer, "msgSent", | |
11312 | PEER_TOTAL_TX(peer)); | |
11313 | ||
43aa5965 QY |
11314 | atomic_size_t outq_count, inq_count; |
11315 | outq_count = atomic_load_explicit( | |
11316 | &peer->obuf->count, | |
11317 | memory_order_relaxed); | |
11318 | inq_count = atomic_load_explicit( | |
11319 | &peer->ibuf->count, | |
11320 | memory_order_relaxed); | |
11321 | ||
3577f1c5 DD |
11322 | json_object_int_add(json_peer, "tableVersion", |
11323 | peer->version[afi][safi]); | |
11324 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
11325 | outq_count); |
11326 | json_object_int_add(json_peer, "inq", | |
11327 | inq_count); | |
3577f1c5 DD |
11328 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
11329 | use_json, json_peer); | |
11330 | ||
3577f1c5 DD |
11331 | json_object_int_add(json_peer, "pfxRcd", |
11332 | peer->pcount[afi][pfx_rcd_safi]); | |
11333 | ||
3577f1c5 | 11334 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
11335 | json_object_int_add( |
11336 | json_peer, "pfxSnt", | |
11337 | (PAF_SUBGRP(paf))->scount); | |
11338 | else | |
11339 | json_object_int_add(json_peer, "pfxSnt", | |
11340 | 0); | |
0e1f8ab5 DA |
11341 | |
11342 | /* BGP FSM state */ | |
cb9196e7 | 11343 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
11344 | || CHECK_FLAG(peer->bgp->flags, |
11345 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
11346 | json_object_string_add(json_peer, |
11347 | "state", | |
3577f1c5 DD |
11348 | "Idle (Admin)"); |
11349 | else if (peer->afc_recv[afi][safi]) | |
11350 | json_object_string_add( | |
0e1f8ab5 DA |
11351 | json_peer, "state", |
11352 | lookup_msg(bgp_status_msg, | |
11353 | peer->status, NULL)); | |
11354 | else if (CHECK_FLAG( | |
11355 | peer->sflags, | |
11356 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11357 | json_object_string_add(json_peer, | |
11358 | "state", | |
3577f1c5 DD |
11359 | "Idle (PfxCt)"); |
11360 | else | |
11361 | json_object_string_add( | |
0e1f8ab5 DA |
11362 | json_peer, "state", |
11363 | lookup_msg(bgp_status_msg, | |
11364 | peer->status, NULL)); | |
11365 | ||
11366 | /* BGP peer state */ | |
11367 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
11368 | || CHECK_FLAG(peer->bgp->flags, | |
11369 | BGP_FLAG_SHUTDOWN)) | |
11370 | json_object_string_add(json_peer, | |
11371 | "peerState", | |
11372 | "Admin"); | |
11373 | else if (CHECK_FLAG( | |
11374 | peer->sflags, | |
11375 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11376 | json_object_string_add(json_peer, | |
11377 | "peerState", | |
11378 | "PfxCt"); | |
11379 | else if (CHECK_FLAG(peer->flags, | |
11380 | PEER_FLAG_PASSIVE)) | |
11381 | json_object_string_add(json_peer, | |
11382 | "peerState", | |
11383 | "Passive"); | |
11384 | else if (CHECK_FLAG(peer->sflags, | |
11385 | PEER_STATUS_NSF_WAIT)) | |
11386 | json_object_string_add(json_peer, | |
11387 | "peerState", | |
11388 | "NSF passive"); | |
11389 | else if (CHECK_FLAG( | |
11390 | peer->bgp->flags, | |
11391 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11392 | && (!bgp_inbound_policy_exists(peer, | |
11393 | filter) | |
11394 | || !bgp_outbound_policy_exists( | |
11395 | peer, filter))) | |
11396 | json_object_string_add(json_peer, | |
11397 | "peerState", | |
11398 | "Policy"); | |
11399 | else | |
11400 | json_object_string_add( | |
11401 | json_peer, "peerState", "OK"); | |
11402 | ||
200116db DD |
11403 | json_object_int_add(json_peer, "connectionsEstablished", |
11404 | peer->established); | |
11405 | json_object_int_add(json_peer, "connectionsDropped", | |
11406 | peer->dropped); | |
aa72bd7e PG |
11407 | if (peer->desc) |
11408 | json_object_string_add( | |
11409 | json_peer, "desc", peer->desc); | |
b4e9dcba | 11410 | } |
3577f1c5 DD |
11411 | /* Avoid creating empty peer dicts in JSON */ |
11412 | if (json_peer == NULL) | |
11413 | continue; | |
ea47320b DL |
11414 | |
11415 | if (peer->conf_if) | |
60466a63 | 11416 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
11417 | "interface"); |
11418 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
11419 | json_object_string_add(json_peer, "idType", |
11420 | "ipv4"); | |
ea47320b | 11421 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
11422 | json_object_string_add(json_peer, "idType", |
11423 | "ipv6"); | |
ea47320b DL |
11424 | json_object_object_add(json_peers, peer->host, |
11425 | json_peer); | |
11426 | } else { | |
8c1d4cd5 | 11427 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11428 | as_type, as)) { |
11429 | filtered_count++; | |
8c1d4cd5 | 11430 | continue; |
ce1944f0 | 11431 | } |
3577f1c5 DD |
11432 | if (show_failed && |
11433 | bgp_has_peer_failed(peer, afi, safi)) { | |
11434 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
11435 | max_neighbor_width, | |
11436 | use_json); | |
11437 | } else if (!show_failed) { | |
10b49f14 | 11438 | if (show_established |
ce1944f0 LS |
11439 | && bgp_has_peer_failed(peer, afi, safi)) { |
11440 | filtered_count++; | |
10b49f14 | 11441 | continue; |
ce1944f0 | 11442 | } |
96c81f66 LS |
11443 | |
11444 | if ((count - filtered_count) == 1) { | |
11445 | /* display headline before the first | |
11446 | * neighbor line */ | |
11447 | vty_out(vty, "\n"); | |
11448 | ||
11449 | /* Subtract 8 here because 'Neighbor' is | |
11450 | * 8 characters */ | |
11451 | vty_out(vty, "Neighbor"); | |
11452 | vty_out(vty, "%*s", | |
11453 | max_neighbor_width - 8, " "); | |
11454 | vty_out(vty, | |
11455 | show_wide | |
11456 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
11457 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
11458 | } | |
11459 | ||
3577f1c5 DD |
11460 | memset(dn_flag, '\0', sizeof(dn_flag)); |
11461 | if (peer_dynamic_neighbor(peer)) { | |
11462 | dn_flag[0] = '*'; | |
11463 | } | |
d62a17ae | 11464 | |
3577f1c5 | 11465 | if (peer->hostname |
892fedb6 DA |
11466 | && CHECK_FLAG(bgp->flags, |
11467 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 11468 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
11469 | peer->hostname, |
11470 | peer->host); | |
d62a17ae | 11471 | else |
3577f1c5 DD |
11472 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
11473 | ||
11474 | /* pad the neighbor column with spaces */ | |
11475 | if (len < max_neighbor_width) | |
11476 | vty_out(vty, "%*s", max_neighbor_width - len, | |
11477 | " "); | |
11478 | ||
43aa5965 QY |
11479 | atomic_size_t outq_count, inq_count; |
11480 | outq_count = atomic_load_explicit( | |
11481 | &peer->obuf->count, | |
11482 | memory_order_relaxed); | |
11483 | inq_count = atomic_load_explicit( | |
11484 | &peer->ibuf->count, | |
11485 | memory_order_relaxed); | |
11486 | ||
85eeb029 DA |
11487 | if (show_wide) |
11488 | vty_out(vty, | |
11489 | "4 %10u %10u %9u %9u %8" PRIu64 | |
11490 | " %4zu %4zu %8s", | |
11491 | peer->as, | |
11492 | peer->change_local_as | |
11493 | ? peer->change_local_as | |
11494 | : peer->local_as, | |
11495 | PEER_TOTAL_RX(peer), | |
11496 | PEER_TOTAL_TX(peer), | |
11497 | peer->version[afi][safi], | |
11498 | inq_count, outq_count, | |
11499 | peer_uptime(peer->uptime, | |
11500 | timebuf, | |
11501 | BGP_UPTIME_LEN, 0, | |
11502 | NULL)); | |
11503 | else | |
11504 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
11505 | " %4zu %4zu %8s", | |
11506 | peer->as, PEER_TOTAL_RX(peer), | |
11507 | PEER_TOTAL_TX(peer), | |
11508 | peer->version[afi][safi], | |
11509 | inq_count, outq_count, | |
11510 | peer_uptime(peer->uptime, | |
11511 | timebuf, | |
11512 | BGP_UPTIME_LEN, 0, | |
11513 | NULL)); | |
3577f1c5 | 11514 | |
feb17238 | 11515 | if (peer_established(peer)) { |
d3ada366 DA |
11516 | if (peer->afc_recv[afi][safi]) { |
11517 | if (CHECK_FLAG( | |
11518 | bgp->flags, | |
11519 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11520 | && !bgp_inbound_policy_exists( | |
11521 | peer, filter)) | |
11522 | vty_out(vty, " %12s", | |
11523 | "(Policy)"); | |
11524 | else | |
11525 | vty_out(vty, | |
6cde4b45 | 11526 | " %12u", |
d3ada366 DA |
11527 | peer->pcount |
11528 | [afi] | |
11529 | [pfx_rcd_safi]); | |
11530 | } else { | |
749d0f27 | 11531 | vty_out(vty, " NoNeg"); |
d3ada366 | 11532 | } |
db92d226 | 11533 | |
d3ada366 DA |
11534 | if (paf && PAF_SUBGRP(paf)) { |
11535 | if (CHECK_FLAG( | |
11536 | bgp->flags, | |
11537 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11538 | && !bgp_outbound_policy_exists( | |
11539 | peer, filter)) | |
11540 | vty_out(vty, " %8s", | |
11541 | "(Policy)"); | |
11542 | else | |
11543 | vty_out(vty, | |
6cde4b45 | 11544 | " %8u", |
d3ada366 DA |
11545 | (PAF_SUBGRP( |
11546 | paf)) | |
11547 | ->scount); | |
749d0f27 DA |
11548 | } else { |
11549 | vty_out(vty, " NoNeg"); | |
d3ada366 | 11550 | } |
db92d226 | 11551 | } else { |
736b68f3 DS |
11552 | if (CHECK_FLAG(peer->flags, |
11553 | PEER_FLAG_SHUTDOWN) | |
11554 | || CHECK_FLAG(peer->bgp->flags, | |
11555 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
11556 | vty_out(vty, " Idle (Admin)"); |
11557 | else if (CHECK_FLAG( | |
11558 | peer->sflags, | |
11559 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11560 | vty_out(vty, " Idle (PfxCt)"); | |
11561 | else | |
11562 | vty_out(vty, " %12s", | |
11563 | lookup_msg(bgp_status_msg, | |
11564 | peer->status, NULL)); | |
db92d226 | 11565 | |
6cde4b45 | 11566 | vty_out(vty, " %8u", 0); |
3577f1c5 | 11567 | } |
565e9ddd DA |
11568 | /* Make sure `Desc` column is the lastest in |
11569 | * the output. | |
11570 | */ | |
aa72bd7e | 11571 | if (peer->desc) |
cb75bb31 DA |
11572 | vty_out(vty, " %s", |
11573 | bgp_peer_description_stripped( | |
85eeb029 DA |
11574 | peer->desc, |
11575 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
11576 | else |
11577 | vty_out(vty, " N/A"); | |
3577f1c5 | 11578 | vty_out(vty, "\n"); |
d62a17ae | 11579 | } |
3577f1c5 | 11580 | |
d62a17ae | 11581 | } |
11582 | } | |
f933309e | 11583 | |
d62a17ae | 11584 | if (use_json) { |
11585 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11586 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
11587 | json_object_int_add(json, "displayedPeers", |
11588 | count - filtered_count); | |
d62a17ae | 11589 | json_object_int_add(json, "totalPeers", count); |
11590 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11591 | ||
3577f1c5 DD |
11592 | if (!show_failed) |
11593 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11594 | |
75eeda93 | 11595 | vty_json(vty, json); |
d62a17ae | 11596 | } else { |
ce1944f0 | 11597 | if (count) { |
96c81f66 LS |
11598 | if (filtered_count == count) |
11599 | vty_out(vty, "\n%% No matching neighbor\n"); | |
11600 | else { | |
11601 | if (show_failed) | |
11602 | vty_out(vty, "\nDisplayed neighbors %d", | |
11603 | failed_count); | |
11604 | else if (as_type != AS_UNSPECIFIED || as | |
11605 | || fpeer || show_established) | |
ce1944f0 LS |
11606 | vty_out(vty, "\nDisplayed neighbors %d", |
11607 | count - filtered_count); | |
96c81f66 LS |
11608 | |
11609 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
11610 | count); | |
ce1944f0 | 11611 | } |
ce1944f0 | 11612 | } else { |
d6ceaca3 | 11613 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11614 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11615 | } |
b05a1c8b | 11616 | |
d6ceaca3 | 11617 | if (dn_count) { |
d62a17ae | 11618 | vty_out(vty, "* - dynamic neighbor\n"); |
11619 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11620 | dn_count, bgp->dynamic_neighbors_limit); | |
11621 | } | |
11622 | } | |
1ff9a340 | 11623 | |
d62a17ae | 11624 | return CMD_SUCCESS; |
718e3744 | 11625 | } |
11626 | ||
d62a17ae | 11627 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 11628 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 11629 | as_t as, uint16_t show_flags) |
d62a17ae | 11630 | { |
11631 | int is_first = 1; | |
11632 | int afi_wildcard = (afi == AFI_MAX); | |
11633 | int safi_wildcard = (safi == SAFI_MAX); | |
11634 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11635 | bool nbr_output = false; |
85eeb029 | 11636 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11637 | |
11638 | if (use_json && is_wildcard) | |
11639 | vty_out(vty, "{\n"); | |
11640 | if (afi_wildcard) | |
11641 | afi = 1; /* AFI_IP */ | |
11642 | while (afi < AFI_MAX) { | |
11643 | if (safi_wildcard) | |
11644 | safi = 1; /* SAFI_UNICAST */ | |
11645 | while (safi < SAFI_MAX) { | |
318cac96 | 11646 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11647 | nbr_output = true; |
f86897b9 | 11648 | |
d62a17ae | 11649 | if (is_wildcard) { |
11650 | /* | |
11651 | * So limit output to those afi/safi | |
11652 | * pairs that | |
11653 | * actualy have something interesting in | |
11654 | * them | |
11655 | */ | |
11656 | if (use_json) { | |
d62a17ae | 11657 | if (!is_first) |
11658 | vty_out(vty, ",\n"); | |
11659 | else | |
11660 | is_first = 0; | |
11661 | ||
11662 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11663 | get_afi_safi_str(afi, |
11664 | safi, | |
11665 | true)); | |
d62a17ae | 11666 | } else { |
6cac2fcc LS |
11667 | vty_out(vty, |
11668 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
11669 | get_afi_safi_str(afi, |
11670 | safi, | |
6cac2fcc LS |
11671 | false), |
11672 | bgp->name_pretty); | |
d62a17ae | 11673 | } |
11674 | } | |
8c1d4cd5 LS |
11675 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
11676 | as_type, as, show_flags); | |
d62a17ae | 11677 | } |
11678 | safi++; | |
d62a17ae | 11679 | if (!safi_wildcard) |
11680 | safi = SAFI_MAX; | |
11681 | } | |
11682 | afi++; | |
ee851c8c | 11683 | if (!afi_wildcard) |
d62a17ae | 11684 | afi = AFI_MAX; |
11685 | } | |
11686 | ||
11687 | if (use_json && is_wildcard) | |
11688 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11689 | else if (!nbr_output) { |
11690 | if (use_json) | |
11691 | vty_out(vty, "{}\n"); | |
11692 | else | |
6cac2fcc LS |
11693 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
11694 | bgp->name_pretty); | |
ca61fd25 | 11695 | } |
d62a17ae | 11696 | } |
11697 | ||
11698 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
11699 | safi_t safi, |
11700 | const char *neighbor, | |
11701 | int as_type, as_t as, | |
96c81f66 | 11702 | uint16_t show_flags) |
d62a17ae | 11703 | { |
11704 | struct listnode *node, *nnode; | |
11705 | struct bgp *bgp; | |
8c1d4cd5 | 11706 | struct peer *fpeer = NULL; |
d62a17ae | 11707 | int is_first = 1; |
9f049418 | 11708 | bool nbr_output = false; |
85eeb029 | 11709 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11710 | |
11711 | if (use_json) | |
11712 | vty_out(vty, "{\n"); | |
11713 | ||
11714 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11715 | nbr_output = true; |
d62a17ae | 11716 | if (use_json) { |
d62a17ae | 11717 | if (!is_first) |
11718 | vty_out(vty, ",\n"); | |
11719 | else | |
11720 | is_first = 0; | |
11721 | ||
11722 | vty_out(vty, "\"%s\":", | |
11723 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11724 | ? VRF_DEFAULT_NAME |
d62a17ae | 11725 | : bgp->name); |
d62a17ae | 11726 | } |
8c1d4cd5 LS |
11727 | if (neighbor) { |
11728 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11729 | use_json); | |
11730 | if (!fpeer) | |
11731 | continue; | |
11732 | } | |
11733 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11734 | as, show_flags); | |
d62a17ae | 11735 | } |
11736 | ||
11737 | if (use_json) | |
11738 | vty_out(vty, "}\n"); | |
9f049418 DS |
11739 | else if (!nbr_output) |
11740 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11741 | } |
11742 | ||
11743 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 11744 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 11745 | as_t as, uint16_t show_flags) |
d62a17ae | 11746 | { |
11747 | struct bgp *bgp; | |
85eeb029 | 11748 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 11749 | struct peer *fpeer = NULL; |
d62a17ae | 11750 | |
11751 | if (name) { | |
11752 | if (strmatch(name, "all")) { | |
85eeb029 | 11753 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
11754 | neighbor, as_type, |
11755 | as, show_flags); | |
d62a17ae | 11756 | return CMD_SUCCESS; |
11757 | } else { | |
11758 | bgp = bgp_lookup_by_name(name); | |
11759 | ||
11760 | if (!bgp) { | |
11761 | if (use_json) | |
11762 | vty_out(vty, "{}\n"); | |
11763 | else | |
11764 | vty_out(vty, | |
ca61fd25 | 11765 | "%% BGP instance not found\n"); |
d62a17ae | 11766 | return CMD_WARNING; |
11767 | } | |
11768 | ||
8c1d4cd5 LS |
11769 | if (neighbor) { |
11770 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11771 | use_json); | |
11772 | if (!fpeer) | |
11773 | return CMD_WARNING; | |
11774 | } | |
11775 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11776 | as_type, as, show_flags); | |
d62a17ae | 11777 | return CMD_SUCCESS; |
11778 | } | |
11779 | } | |
11780 | ||
11781 | bgp = bgp_get_default(); | |
11782 | ||
8c1d4cd5 LS |
11783 | if (bgp) { |
11784 | if (neighbor) { | |
11785 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11786 | use_json); | |
11787 | if (!fpeer) | |
11788 | return CMD_WARNING; | |
11789 | } | |
11790 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11791 | as, show_flags); | |
11792 | } else { | |
ca61fd25 DS |
11793 | if (use_json) |
11794 | vty_out(vty, "{}\n"); | |
11795 | else | |
11796 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11797 | return CMD_WARNING; |
11798 | } | |
d62a17ae | 11799 | |
11800 | return CMD_SUCCESS; | |
4fb25c53 DW |
11801 | } |
11802 | ||
716b2d8a | 11803 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11804 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11805 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11806 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11807 | "]] [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 |
11808 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11809 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11810 | "Display the entries for all address families\n" | |
11811 | "Summary of BGP neighbor status\n" | |
11812 | "Show only sessions in Established state\n" | |
11813 | "Show only sessions not in Established state\n" | |
11814 | "Show only the specified neighbor session\n" | |
11815 | "Neighbor to display information about\n" | |
11816 | "Neighbor to display information about\n" | |
11817 | "Neighbor on BGP configured interface\n" | |
11818 | "Show only the specified remote AS sessions\n" | |
11819 | "AS number\n" | |
11820 | "Internal (iBGP) AS sessions\n" | |
11821 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11822 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11823 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11824 | { |
d62a17ae | 11825 | char *vrf = NULL; |
11826 | afi_t afi = AFI_MAX; | |
11827 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11828 | as_t as = 0; /* 0 means AS filter not set */ |
11829 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11830 | uint16_t show_flags = 0; |
d62a17ae | 11831 | |
11832 | int idx = 0; | |
11833 | ||
11834 | /* show [ip] bgp */ | |
96f3485c | 11835 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11836 | afi = AFI_IP; |
9a8bdf1c PG |
11837 | /* [<vrf> VIEWVRFNAME] */ |
11838 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11839 | vrf = argv[idx + 1]->arg; | |
11840 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11841 | vrf = NULL; | |
11842 | } else if (argv_find(argv, argc, "view", &idx)) | |
11843 | /* [<view> VIEWVRFNAME] */ | |
11844 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11845 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11846 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11847 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11848 | } | |
11849 | ||
3577f1c5 | 11850 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11851 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11852 | ||
10b49f14 | 11853 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11854 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11855 | ||
8c1d4cd5 LS |
11856 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11857 | if (argv[idx + 1]->arg[0] == 'i') | |
11858 | as_type = AS_INTERNAL; | |
11859 | else if (argv[idx + 1]->arg[0] == 'e') | |
11860 | as_type = AS_EXTERNAL; | |
11861 | else | |
11862 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11863 | } | |
11864 | ||
96c81f66 LS |
11865 | if (argv_find(argv, argc, "terse", &idx)) |
11866 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11867 | ||
85eeb029 DA |
11868 | if (argv_find(argv, argc, "wide", &idx)) |
11869 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11870 | ||
11871 | if (argv_find(argv, argc, "json", &idx)) | |
11872 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11873 | |
8c1d4cd5 LS |
11874 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11875 | show_flags); | |
d62a17ae | 11876 | } |
11877 | ||
5cb5f4d0 | 11878 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11879 | { |
5cb5f4d0 DD |
11880 | if (for_json) |
11881 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11882 | else |
5cb5f4d0 | 11883 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11884 | } |
11885 | ||
d62a17ae | 11886 | |
11887 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11888 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11889 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11890 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11891 | bool use_json, json_object *json_pref) |
d62a17ae | 11892 | { |
11893 | /* Send-Mode */ | |
11894 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11895 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11896 | if (use_json) { | |
11897 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11898 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11899 | json_object_string_add(json_pref, "sendMode", | |
11900 | "advertisedAndReceived"); | |
11901 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11902 | json_object_string_add(json_pref, "sendMode", | |
11903 | "advertised"); | |
11904 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11905 | json_object_string_add(json_pref, "sendMode", | |
11906 | "received"); | |
11907 | } else { | |
11908 | vty_out(vty, " Send-mode: "); | |
11909 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11910 | vty_out(vty, "advertised"); | |
11911 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11912 | vty_out(vty, "%sreceived", | |
11913 | CHECK_FLAG(p->af_cap[afi][safi], | |
11914 | adv_smcap) | |
11915 | ? ", " | |
11916 | : ""); | |
11917 | vty_out(vty, "\n"); | |
11918 | } | |
11919 | } | |
11920 | ||
11921 | /* Receive-Mode */ | |
11922 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11923 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11924 | if (use_json) { | |
11925 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11926 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11927 | json_object_string_add(json_pref, "recvMode", | |
11928 | "advertisedAndReceived"); | |
11929 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11930 | json_object_string_add(json_pref, "recvMode", | |
11931 | "advertised"); | |
11932 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11933 | json_object_string_add(json_pref, "recvMode", | |
11934 | "received"); | |
11935 | } else { | |
11936 | vty_out(vty, " Receive-mode: "); | |
11937 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11938 | vty_out(vty, "advertised"); | |
11939 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11940 | vty_out(vty, "%sreceived", | |
11941 | CHECK_FLAG(p->af_cap[afi][safi], | |
11942 | adv_rmcap) | |
11943 | ? ", " | |
11944 | : ""); | |
11945 | vty_out(vty, "\n"); | |
11946 | } | |
11947 | } | |
11948 | } | |
11949 | ||
eea685b6 DA |
11950 | static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty, |
11951 | struct peer *p, | |
eea685b6 | 11952 | json_object *json) |
2986cac2 | 11953 | { |
eea685b6 DA |
11954 | bool rbit = false; |
11955 | bool nbit = false; | |
2986cac2 | 11956 | |
13909c4f DS |
11957 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11958 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11959 | && (peer_established(p))) { |
eea685b6 DA |
11960 | rbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV); |
11961 | nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV); | |
2986cac2 | 11962 | } |
11963 | ||
403e64f8 | 11964 | if (json) { |
eea685b6 DA |
11965 | json_object_boolean_add(json, "rBit", rbit); |
11966 | json_object_boolean_add(json, "nBit", nbit); | |
2986cac2 | 11967 | } else { |
eea685b6 DA |
11968 | vty_out(vty, "\n R bit: %s", rbit ? "True" : "False"); |
11969 | vty_out(vty, "\n N bit: %s\n", nbit ? "True" : "False"); | |
2986cac2 | 11970 | } |
11971 | } | |
11972 | ||
13909c4f DS |
11973 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11974 | struct peer *peer, | |
13909c4f | 11975 | json_object *json) |
2986cac2 | 11976 | { |
2bb5d39b | 11977 | const char *mode = "NotApplicable"; |
2986cac2 | 11978 | |
403e64f8 | 11979 | if (!json) |
a53ca37b | 11980 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11981 | |
13909c4f | 11982 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11983 | && (peer_established(peer))) { |
2986cac2 | 11984 | |
13909c4f DS |
11985 | if ((peer->nsf_af_count == 0) |
11986 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11987 | |
2986cac2 | 11988 | mode = "Disable"; |
11989 | ||
13909c4f DS |
11990 | } else if (peer->nsf_af_count == 0 |
11991 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11992 | |
2986cac2 | 11993 | mode = "Helper"; |
11994 | ||
13909c4f DS |
11995 | } else if (peer->nsf_af_count != 0 |
11996 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11997 | |
2986cac2 | 11998 | mode = "Restart"; |
2986cac2 | 11999 | } |
12000 | } | |
12001 | ||
403e64f8 | 12002 | if (json) |
13909c4f | 12003 | json_object_string_add(json, "remoteGrMode", mode); |
403e64f8 | 12004 | else |
0e4e879b | 12005 | vty_out(vty, "%s\n", mode); |
2986cac2 | 12006 | } |
12007 | ||
13909c4f DS |
12008 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
12009 | struct peer *p, | |
13909c4f | 12010 | json_object *json) |
2986cac2 | 12011 | { |
12012 | const char *mode = "Invalid"; | |
12013 | ||
403e64f8 | 12014 | if (!json) |
a53ca37b | 12015 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 12016 | |
12017 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
12018 | mode = "Helper"; | |
12019 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
12020 | mode = "Restart"; | |
12021 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
12022 | mode = "Disable"; | |
2ba1fe69 | 12023 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 12024 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
12025 | mode = "Helper*"; | |
12026 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
12027 | mode = "Restart*"; | |
12028 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
12029 | mode = "Disable*"; | |
12030 | else | |
12031 | mode = "Invalid*"; | |
2ba1fe69 | 12032 | } |
2986cac2 | 12033 | |
403e64f8 | 12034 | if (json) |
13909c4f | 12035 | json_object_string_add(json, "localGrMode", mode); |
403e64f8 | 12036 | else |
0e4e879b | 12037 | vty_out(vty, "%s\n", mode); |
2986cac2 | 12038 | } |
12039 | ||
13909c4f | 12040 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
403e64f8 | 12041 | struct vty *vty, struct peer *peer, json_object *json) |
2986cac2 | 12042 | { |
2ba1fe69 | 12043 | afi_t afi; |
12044 | safi_t safi; | |
2986cac2 | 12045 | json_object *json_afi_safi = NULL; |
12046 | json_object *json_timer = NULL; | |
12047 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 12048 | bool eor_flag = false; |
2986cac2 | 12049 | |
df8d723c DA |
12050 | FOREACH_AFI_SAFI_NSF (afi, safi) { |
12051 | if (!peer->afc[afi][safi]) | |
12052 | continue; | |
2986cac2 | 12053 | |
df8d723c DA |
12054 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) || |
12055 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
12056 | continue; | |
9e3b51a7 | 12057 | |
403e64f8 | 12058 | if (json) { |
df8d723c DA |
12059 | json_afi_safi = json_object_new_object(); |
12060 | json_endofrib_status = json_object_new_object(); | |
12061 | json_timer = json_object_new_object(); | |
12062 | } | |
2986cac2 | 12063 | |
df8d723c DA |
12064 | if (peer->eor_stime[afi][safi] >= peer->pkt_stime[afi][safi]) |
12065 | eor_flag = true; | |
12066 | else | |
12067 | eor_flag = false; | |
2986cac2 | 12068 | |
403e64f8 | 12069 | if (!json) { |
df8d723c DA |
12070 | vty_out(vty, " %s:\n", |
12071 | get_afi_safi_str(afi, safi, false)); | |
2986cac2 | 12072 | |
df8d723c DA |
12073 | vty_out(vty, " F bit: "); |
12074 | } | |
2986cac2 | 12075 | |
df8d723c DA |
12076 | if (peer->nsf[afi][safi] && |
12077 | CHECK_FLAG(peer->af_cap[afi][safi], | |
12078 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 12079 | |
403e64f8 | 12080 | if (json) { |
df8d723c DA |
12081 | json_object_boolean_true_add(json_afi_safi, |
12082 | "fBit"); | |
12083 | } else | |
12084 | vty_out(vty, "True\n"); | |
12085 | } else { | |
403e64f8 | 12086 | if (json) |
df8d723c DA |
12087 | json_object_boolean_false_add(json_afi_safi, |
12088 | "fBit"); | |
12089 | else | |
12090 | vty_out(vty, "False\n"); | |
12091 | } | |
2986cac2 | 12092 | |
403e64f8 | 12093 | if (!json) |
df8d723c | 12094 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 12095 | |
df8d723c DA |
12096 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12097 | PEER_STATUS_EOR_SEND)) { | |
403e64f8 | 12098 | if (json) { |
df8d723c DA |
12099 | json_object_boolean_true_add( |
12100 | json_endofrib_status, "endOfRibSend"); | |
9e3b51a7 | 12101 | |
df8d723c DA |
12102 | PRINT_EOR_JSON(eor_flag); |
12103 | } else { | |
12104 | vty_out(vty, "Yes\n"); | |
12105 | vty_out(vty, | |
12106 | " End-of-RIB sent after update: "); | |
2986cac2 | 12107 | |
df8d723c DA |
12108 | PRINT_EOR(eor_flag); |
12109 | } | |
12110 | } else { | |
403e64f8 | 12111 | if (json) { |
df8d723c DA |
12112 | json_object_boolean_false_add( |
12113 | json_endofrib_status, "endOfRibSend"); | |
12114 | json_object_boolean_false_add( | |
12115 | json_endofrib_status, | |
12116 | "endOfRibSentAfterUpdate"); | |
13909c4f | 12117 | } else { |
df8d723c DA |
12118 | vty_out(vty, "No\n"); |
12119 | vty_out(vty, | |
12120 | " End-of-RIB sent after update: "); | |
12121 | vty_out(vty, "No\n"); | |
13909c4f | 12122 | } |
df8d723c | 12123 | } |
2986cac2 | 12124 | |
403e64f8 | 12125 | if (!json) |
df8d723c | 12126 | vty_out(vty, " End-of-RIB received: "); |
a53ca37b | 12127 | |
df8d723c DA |
12128 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12129 | PEER_STATUS_EOR_RECEIVED)) { | |
403e64f8 | 12130 | if (json) |
df8d723c DA |
12131 | json_object_boolean_true_add( |
12132 | json_endofrib_status, "endOfRibRecv"); | |
12133 | else | |
12134 | vty_out(vty, "Yes\n"); | |
12135 | } else { | |
403e64f8 | 12136 | if (json) |
df8d723c DA |
12137 | json_object_boolean_false_add( |
12138 | json_endofrib_status, "endOfRibRecv"); | |
12139 | else | |
12140 | vty_out(vty, "No\n"); | |
12141 | } | |
12142 | ||
403e64f8 | 12143 | if (json) { |
df8d723c DA |
12144 | json_object_int_add(json_timer, "stalePathTimer", |
12145 | peer->bgp->stalepath_time); | |
12146 | ||
12147 | if (peer->t_gr_stale != NULL) { | |
12148 | json_object_int_add(json_timer, | |
12149 | "stalePathTimerRemaining", | |
12150 | thread_timer_remain_second( | |
12151 | peer->t_gr_stale)); | |
a53ca37b DA |
12152 | } |
12153 | ||
df8d723c DA |
12154 | /* Display Configured Selection |
12155 | * Deferral only when when | |
12156 | * Gr mode is enabled. | |
12157 | */ | |
12158 | if (CHECK_FLAG(peer->flags, | |
12159 | PEER_FLAG_GRACEFUL_RESTART)) { | |
13909c4f | 12160 | json_object_int_add(json_timer, |
df8d723c | 12161 | "selectionDeferralTimer", |
13909c4f | 12162 | peer->bgp->stalepath_time); |
df8d723c | 12163 | } |
2986cac2 | 12164 | |
df8d723c DA |
12165 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12166 | NULL) { | |
2986cac2 | 12167 | |
df8d723c DA |
12168 | json_object_int_add( |
12169 | json_timer, | |
12170 | "selectionDeferralTimerRemaining", | |
12171 | thread_timer_remain_second( | |
12172 | peer->bgp->gr_info[afi][safi] | |
12173 | .t_select_deferral)); | |
12174 | } | |
12175 | } else { | |
12176 | vty_out(vty, " Timers:\n"); | |
12177 | vty_out(vty, | |
12178 | " Configured Stale Path Time(sec): %u\n", | |
12179 | peer->bgp->stalepath_time); | |
2986cac2 | 12180 | |
df8d723c | 12181 | if (peer->t_gr_stale != NULL) |
13909c4f | 12182 | vty_out(vty, |
df8d723c DA |
12183 | " Stale Path Remaining(sec): %ld\n", |
12184 | thread_timer_remain_second( | |
12185 | peer->t_gr_stale)); | |
12186 | /* Display Configured Selection | |
12187 | * Deferral only when when | |
12188 | * Gr mode is enabled. | |
12189 | */ | |
12190 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
12191 | vty_out(vty, | |
12192 | " Configured Selection Deferral Time(sec): %u\n", | |
12193 | peer->bgp->select_defer_time); | |
2986cac2 | 12194 | |
df8d723c DA |
12195 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12196 | NULL) | |
12197 | vty_out(vty, | |
12198 | " Selection Deferral Time Remaining(sec): %ld\n", | |
12199 | thread_timer_remain_second( | |
12200 | peer->bgp->gr_info[afi][safi] | |
12201 | .t_select_deferral)); | |
12202 | } | |
403e64f8 | 12203 | if (json) { |
df8d723c DA |
12204 | json_object_object_add(json_afi_safi, "endOfRibStatus", |
12205 | json_endofrib_status); | |
12206 | json_object_object_add(json_afi_safi, "timers", | |
12207 | json_timer); | |
12208 | json_object_object_add( | |
12209 | json, get_afi_safi_str(afi, safi, true), | |
12210 | json_afi_safi); | |
2986cac2 | 12211 | } |
12212 | } | |
12213 | } | |
12214 | ||
36235319 QY |
12215 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
12216 | struct peer *p, | |
36235319 | 12217 | json_object *json) |
2986cac2 | 12218 | { |
403e64f8 | 12219 | if (json) { |
2986cac2 | 12220 | json_object *json_timer = NULL; |
12221 | ||
12222 | json_timer = json_object_new_object(); | |
12223 | ||
13909c4f DS |
12224 | json_object_int_add(json_timer, "configuredRestartTimer", |
12225 | p->bgp->restart_time); | |
2986cac2 | 12226 | |
13909c4f DS |
12227 | json_object_int_add(json_timer, "receivedRestartTimer", |
12228 | p->v_gr_restart); | |
2986cac2 | 12229 | |
13909c4f DS |
12230 | if (p->t_gr_restart != NULL) |
12231 | json_object_int_add( | |
12232 | json_timer, "restartTimerRemaining", | |
12233 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 12234 | |
12235 | json_object_object_add(json, "timers", json_timer); | |
12236 | } else { | |
12237 | ||
a53ca37b DA |
12238 | vty_out(vty, " Timers:\n"); |
12239 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 12240 | p->bgp->restart_time); |
2986cac2 | 12241 | |
a53ca37b | 12242 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
12243 | p->v_gr_restart); |
12244 | if (p->t_gr_restart != NULL) | |
a53ca37b | 12245 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 12246 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 12247 | if (p->t_gr_restart != NULL) { |
a53ca37b | 12248 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
12249 | thread_timer_remain_second(p->t_gr_restart)); |
12250 | } | |
2986cac2 | 12251 | } |
12252 | } | |
12253 | ||
12254 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
403e64f8 | 12255 | json_object *json) |
2986cac2 | 12256 | { |
2986cac2 | 12257 | char dn_flag[2] = {0}; |
2b7165e7 QY |
12258 | /* '*' + v6 address of neighbor */ |
12259 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 12260 | |
2986cac2 | 12261 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
12262 | dn_flag[0] = '*'; | |
12263 | ||
12264 | if (p->conf_if) { | |
403e64f8 | 12265 | if (json) |
47e12884 DA |
12266 | json_object_string_addf(json, "neighborAddr", "%pSU", |
12267 | &p->su); | |
2986cac2 | 12268 | else |
47e12884 DA |
12269 | vty_out(vty, "BGP neighbor on %s: %pSU\n", p->conf_if, |
12270 | &p->su); | |
2986cac2 | 12271 | } else { |
772270f3 QY |
12272 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
12273 | p->host); | |
2986cac2 | 12274 | |
403e64f8 | 12275 | if (json) |
36235319 QY |
12276 | json_object_string_add(json, "neighborAddr", |
12277 | neighborAddr); | |
2986cac2 | 12278 | else |
36235319 | 12279 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 12280 | } |
12281 | ||
12282 | /* more gr info in new format */ | |
403e64f8 | 12283 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json); |
2986cac2 | 12284 | } |
12285 | ||
d62a17ae | 12286 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 12287 | safi_t safi, bool use_json, |
d62a17ae | 12288 | json_object *json_neigh) |
12289 | { | |
0291c246 MK |
12290 | struct bgp_filter *filter; |
12291 | struct peer_af *paf; | |
12292 | char orf_pfx_name[BUFSIZ]; | |
12293 | int orf_pfx_count; | |
12294 | json_object *json_af = NULL; | |
12295 | json_object *json_prefA = NULL; | |
12296 | json_object *json_prefB = NULL; | |
12297 | json_object *json_addr = NULL; | |
fa36596c | 12298 | json_object *json_advmap = NULL; |
d62a17ae | 12299 | |
12300 | if (use_json) { | |
12301 | json_addr = json_object_new_object(); | |
12302 | json_af = json_object_new_object(); | |
12303 | filter = &p->filter[afi][safi]; | |
12304 | ||
12305 | if (peer_group_active(p)) | |
12306 | json_object_string_add(json_addr, "peerGroupMember", | |
12307 | p->group->name); | |
12308 | ||
12309 | paf = peer_af_find(p, afi, safi); | |
12310 | if (paf && PAF_SUBGRP(paf)) { | |
12311 | json_object_int_add(json_addr, "updateGroupId", | |
12312 | PAF_UPDGRP(paf)->id); | |
12313 | json_object_int_add(json_addr, "subGroupId", | |
12314 | PAF_SUBGRP(paf)->id); | |
12315 | json_object_int_add(json_addr, "packetQueueLength", | |
12316 | bpacket_queue_virtual_length(paf)); | |
12317 | } | |
12318 | ||
12319 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12320 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12321 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12322 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12323 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12324 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12325 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12326 | json_object_int_add(json_af, "orfType", | |
12327 | ORF_TYPE_PREFIX); | |
12328 | json_prefA = json_object_new_object(); | |
12329 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
12330 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
12331 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12332 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12333 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
12334 | use_json, json_prefA); | |
12335 | json_object_object_add(json_af, "orfPrefixList", | |
12336 | json_prefA); | |
12337 | } | |
12338 | ||
12339 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12340 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12341 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12342 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12343 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12344 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12345 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12346 | json_object_int_add(json_af, "orfOldType", | |
12347 | ORF_TYPE_PREFIX_OLD); | |
12348 | json_prefB = json_object_new_object(); | |
12349 | bgp_show_peer_afi_orf_cap( | |
12350 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12351 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12352 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12353 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
12354 | json_prefB); | |
12355 | json_object_object_add(json_af, "orfOldPrefixList", | |
12356 | json_prefB); | |
12357 | } | |
12358 | ||
12359 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12360 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12361 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12362 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12363 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12364 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12365 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12366 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12367 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12368 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12369 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12370 | json_object_object_add(json_addr, "afDependentCap", | |
12371 | json_af); | |
12372 | else | |
12373 | json_object_free(json_af); | |
12374 | ||
772270f3 QY |
12375 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12376 | p->host, afi, safi); | |
d62a17ae | 12377 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12378 | NULL, afi, orf_pfx_name, use_json); | |
12379 | ||
12380 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12381 | PEER_STATUS_ORF_PREFIX_SEND) | |
12382 | || orf_pfx_count) { | |
12383 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12384 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12385 | json_object_boolean_true_add(json_neigh, | |
12386 | "orfSent"); | |
12387 | if (orf_pfx_count) | |
12388 | json_object_int_add(json_addr, "orfRecvCounter", | |
12389 | orf_pfx_count); | |
12390 | } | |
12391 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12392 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12393 | json_object_string_add( | |
12394 | json_addr, "orfFirstUpdate", | |
12395 | "deferredUntilORFOrRouteRefreshRecvd"); | |
12396 | ||
12397 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12398 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12399 | json_object_boolean_true_add(json_addr, | |
12400 | "routeReflectorClient"); | |
12401 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12402 | PEER_FLAG_RSERVER_CLIENT)) | |
12403 | json_object_boolean_true_add(json_addr, | |
12404 | "routeServerClient"); | |
12405 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12406 | json_object_boolean_true_add(json_addr, | |
12407 | "inboundSoftConfigPermit"); | |
12408 | ||
12409 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12410 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12411 | json_object_boolean_true_add( | |
12412 | json_addr, | |
12413 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
12414 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12415 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12416 | json_object_boolean_true_add( | |
12417 | json_addr, | |
12418 | "privateAsNumsReplacedInUpdatesToNbr"); | |
12419 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12420 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12421 | json_object_boolean_true_add( | |
12422 | json_addr, | |
12423 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
12424 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12425 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12426 | json_object_boolean_true_add( | |
12427 | json_addr, | |
12428 | "privateAsNumsRemovedInUpdatesToNbr"); | |
12429 | ||
b2ac1d0d MS |
12430 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12431 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12432 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12433 | json_object_boolean_true_add(json_addr, | |
12434 | "allowAsInOrigin"); | |
12435 | else | |
12436 | json_object_int_add(json_addr, "allowAsInCount", | |
12437 | p->allowas_in[afi][safi]); | |
12438 | } | |
12439 | ||
dcc68b5e MS |
12440 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12441 | json_object_boolean_true_add( | |
12442 | json_addr, | |
12443 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12444 | ->type_json_name); | |
d62a17ae | 12445 | |
12446 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12447 | json_object_string_add(json_addr, | |
12448 | "overrideASNsInOutboundUpdates", | |
12449 | "ifAspathEqualRemoteAs"); | |
12450 | ||
12451 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12452 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12453 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12454 | json_object_boolean_true_add(json_addr, | |
12455 | "routerAlwaysNextHop"); | |
12456 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12457 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12458 | json_object_boolean_true_add( | |
12459 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
12460 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12461 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12462 | json_object_boolean_true_add( | |
12463 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
12464 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12465 | json_object_boolean_true_add( | |
12466 | json_addr, "unchangedMedPropogatedToNbr"); | |
12467 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12468 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12469 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
12470 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12471 | PEER_FLAG_SEND_COMMUNITY) | |
12472 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12473 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12474 | json_object_string_add(json_addr, | |
12475 | "commAttriSentToNbr", | |
12476 | "extendedAndStandard"); | |
12477 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12478 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12479 | json_object_string_add(json_addr, | |
12480 | "commAttriSentToNbr", | |
12481 | "extended"); | |
12482 | else | |
12483 | json_object_string_add(json_addr, | |
12484 | "commAttriSentToNbr", | |
12485 | "standard"); | |
12486 | } | |
12487 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12488 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12489 | if (p->default_rmap[afi][safi].name) | |
12490 | json_object_string_add( | |
12491 | json_addr, "defaultRouteMap", | |
12492 | p->default_rmap[afi][safi].name); | |
12493 | ||
12494 | if (paf && PAF_SUBGRP(paf) | |
12495 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12496 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12497 | json_object_boolean_true_add(json_addr, | |
12498 | "defaultSent"); | |
12499 | else | |
12500 | json_object_boolean_true_add(json_addr, | |
12501 | "defaultNotSent"); | |
12502 | } | |
12503 | ||
dff8f48d | 12504 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 12505 | if (is_evpn_enabled()) |
60466a63 QY |
12506 | json_object_boolean_true_add( |
12507 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
12508 | } |
12509 | ||
d62a17ae | 12510 | if (filter->plist[FILTER_IN].name |
12511 | || filter->dlist[FILTER_IN].name | |
12512 | || filter->aslist[FILTER_IN].name | |
12513 | || filter->map[RMAP_IN].name) | |
12514 | json_object_boolean_true_add(json_addr, | |
12515 | "inboundPathPolicyConfig"); | |
12516 | if (filter->plist[FILTER_OUT].name | |
12517 | || filter->dlist[FILTER_OUT].name | |
12518 | || filter->aslist[FILTER_OUT].name | |
12519 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12520 | json_object_boolean_true_add( | |
12521 | json_addr, "outboundPathPolicyConfig"); | |
12522 | ||
12523 | /* prefix-list */ | |
12524 | if (filter->plist[FILTER_IN].name) | |
12525 | json_object_string_add(json_addr, | |
12526 | "incomingUpdatePrefixFilterList", | |
12527 | filter->plist[FILTER_IN].name); | |
12528 | if (filter->plist[FILTER_OUT].name) | |
12529 | json_object_string_add(json_addr, | |
12530 | "outgoingUpdatePrefixFilterList", | |
12531 | filter->plist[FILTER_OUT].name); | |
12532 | ||
12533 | /* distribute-list */ | |
12534 | if (filter->dlist[FILTER_IN].name) | |
12535 | json_object_string_add( | |
12536 | json_addr, "incomingUpdateNetworkFilterList", | |
12537 | filter->dlist[FILTER_IN].name); | |
12538 | if (filter->dlist[FILTER_OUT].name) | |
12539 | json_object_string_add( | |
12540 | json_addr, "outgoingUpdateNetworkFilterList", | |
12541 | filter->dlist[FILTER_OUT].name); | |
12542 | ||
12543 | /* filter-list. */ | |
12544 | if (filter->aslist[FILTER_IN].name) | |
12545 | json_object_string_add(json_addr, | |
12546 | "incomingUpdateAsPathFilterList", | |
12547 | filter->aslist[FILTER_IN].name); | |
12548 | if (filter->aslist[FILTER_OUT].name) | |
12549 | json_object_string_add(json_addr, | |
12550 | "outgoingUpdateAsPathFilterList", | |
12551 | filter->aslist[FILTER_OUT].name); | |
12552 | ||
12553 | /* route-map. */ | |
12554 | if (filter->map[RMAP_IN].name) | |
12555 | json_object_string_add( | |
12556 | json_addr, "routeMapForIncomingAdvertisements", | |
12557 | filter->map[RMAP_IN].name); | |
12558 | if (filter->map[RMAP_OUT].name) | |
12559 | json_object_string_add( | |
12560 | json_addr, "routeMapForOutgoingAdvertisements", | |
12561 | filter->map[RMAP_OUT].name); | |
12562 | ||
9dac9fc8 | 12563 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12564 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12565 | && !bgp_inbound_policy_exists(p, filter)) |
12566 | json_object_string_add( | |
12567 | json_addr, "inboundEbgpRequiresPolicy", | |
12568 | "Inbound updates discarded due to missing policy"); | |
12569 | ||
12570 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12571 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12572 | && (!bgp_outbound_policy_exists(p, filter))) |
12573 | json_object_string_add( | |
12574 | json_addr, "outboundEbgpRequiresPolicy", | |
12575 | "Outbound updates discarded due to missing policy"); | |
12576 | ||
d62a17ae | 12577 | /* unsuppress-map */ |
12578 | if (filter->usmap.name) | |
12579 | json_object_string_add(json_addr, | |
12580 | "selectiveUnsuppressRouteMap", | |
12581 | filter->usmap.name); | |
12582 | ||
fa36596c MK |
12583 | /* advertise-map */ |
12584 | if (filter->advmap.aname) { | |
12585 | json_advmap = json_object_new_object(); | |
12586 | json_object_string_add(json_advmap, "condition", | |
12587 | filter->advmap.condition | |
12588 | ? "EXIST" | |
12589 | : "NON_EXIST"); | |
12590 | json_object_string_add(json_advmap, "conditionMap", | |
12591 | filter->advmap.cname); | |
12592 | json_object_string_add(json_advmap, "advertiseMap", | |
12593 | filter->advmap.aname); | |
ecf2b628 QY |
12594 | json_object_string_add( |
12595 | json_advmap, "advertiseStatus", | |
12596 | filter->advmap.update_type == | |
12597 | UPDATE_TYPE_ADVERTISE | |
12598 | ? "Advertise" | |
12599 | : "Withdraw"); | |
fa36596c MK |
12600 | json_object_object_add(json_addr, "advertiseMap", |
12601 | json_advmap); | |
12602 | } | |
12603 | ||
d62a17ae | 12604 | /* Receive prefix count */ |
12605 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
12606 | p->pcount[afi][safi]); | |
50e05855 AD |
12607 | if (paf && PAF_SUBGRP(paf)) |
12608 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12609 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12610 | |
fde246e8 DA |
12611 | /* Maximum prefix */ |
12612 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12613 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12614 | p->pmax_out[afi][safi]); | |
12615 | ||
d62a17ae | 12616 | /* Maximum prefix */ |
12617 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12618 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12619 | p->pmax[afi][safi]); | |
12620 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12621 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12622 | json_object_boolean_true_add( | |
12623 | json_addr, "prefixAllowedMaxWarning"); | |
12624 | json_object_int_add(json_addr, | |
12625 | "prefixAllowedWarningThresh", | |
12626 | p->pmax_threshold[afi][safi]); | |
12627 | if (p->pmax_restart[afi][safi]) | |
12628 | json_object_int_add( | |
12629 | json_addr, | |
12630 | "prefixAllowedRestartIntervalMsecs", | |
12631 | p->pmax_restart[afi][safi] * 60000); | |
12632 | } | |
2986cac2 | 12633 | json_object_object_add(json_neigh, |
36235319 | 12634 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12635 | json_addr); |
12636 | ||
12637 | } else { | |
12638 | filter = &p->filter[afi][safi]; | |
12639 | ||
12640 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12641 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12642 | |
12643 | if (peer_group_active(p)) | |
12644 | vty_out(vty, " %s peer-group member\n", | |
12645 | p->group->name); | |
12646 | ||
12647 | paf = peer_af_find(p, afi, safi); | |
12648 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12649 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12650 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12651 | vty_out(vty, " Packet Queue length %d\n", | |
12652 | bpacket_queue_virtual_length(paf)); | |
12653 | } else { | |
12654 | vty_out(vty, " Not part of any update group\n"); | |
12655 | } | |
12656 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12657 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12658 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12659 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12660 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12661 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12662 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12663 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12664 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12665 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12666 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12667 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12668 | ||
12669 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12670 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12671 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12672 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12673 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12674 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12675 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12676 | vty_out(vty, | |
12677 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12678 | ORF_TYPE_PREFIX); | |
12679 | bgp_show_peer_afi_orf_cap( | |
12680 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12681 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12682 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12683 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12684 | } | |
12685 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12686 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12687 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12688 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12689 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12690 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12691 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12692 | vty_out(vty, | |
12693 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12694 | ORF_TYPE_PREFIX_OLD); | |
12695 | bgp_show_peer_afi_orf_cap( | |
12696 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12697 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12698 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12699 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12700 | } | |
12701 | ||
772270f3 QY |
12702 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12703 | p->host, afi, safi); | |
d62a17ae | 12704 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12705 | NULL, afi, orf_pfx_name, use_json); | |
12706 | ||
12707 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12708 | PEER_STATUS_ORF_PREFIX_SEND) | |
12709 | || orf_pfx_count) { | |
12710 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12711 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12712 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12713 | vty_out(vty, " sent;"); | |
12714 | if (orf_pfx_count) | |
12715 | vty_out(vty, " received (%d entries)", | |
12716 | orf_pfx_count); | |
12717 | vty_out(vty, "\n"); | |
12718 | } | |
12719 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12720 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12721 | vty_out(vty, | |
12722 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12723 | ||
12724 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12725 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12726 | vty_out(vty, " Route-Reflector Client\n"); | |
12727 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12728 | PEER_FLAG_RSERVER_CLIENT)) | |
12729 | vty_out(vty, " Route-Server Client\n"); | |
12730 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12731 | vty_out(vty, | |
12732 | " Inbound soft reconfiguration allowed\n"); | |
12733 | ||
12734 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12735 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12736 | vty_out(vty, | |
12737 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12738 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12739 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12740 | vty_out(vty, | |
12741 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12742 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12743 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12744 | vty_out(vty, | |
12745 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12746 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12747 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12748 | vty_out(vty, | |
12749 | " Private AS numbers removed in updates to this neighbor\n"); | |
12750 | ||
b2ac1d0d MS |
12751 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12752 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12753 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12754 | vty_out(vty, | |
12755 | " Local AS allowed as path origin\n"); | |
12756 | else | |
12757 | vty_out(vty, | |
12758 | " Local AS allowed in path, %d occurrences\n", | |
12759 | p->allowas_in[afi][safi]); | |
12760 | } | |
12761 | ||
dcc68b5e MS |
12762 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12763 | vty_out(vty, " %s\n", | |
12764 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12765 | ->human_description); | |
d62a17ae | 12766 | |
12767 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12768 | vty_out(vty, | |
12769 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12770 | ||
12771 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12772 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12773 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12774 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12775 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12776 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12777 | vty_out(vty, | |
12778 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12779 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12780 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12781 | vty_out(vty, | |
12782 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12783 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12784 | vty_out(vty, | |
12785 | " MED is propagated unchanged to this neighbor\n"); | |
12786 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12787 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12788 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12789 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12790 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12791 | vty_out(vty, | |
12792 | " Community attribute sent to this neighbor"); | |
12793 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12794 | PEER_FLAG_SEND_COMMUNITY) | |
12795 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12796 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12797 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12798 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12799 | vty_out(vty, "(all)\n"); | |
12800 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12801 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12802 | vty_out(vty, "(large)\n"); | |
12803 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12804 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12805 | vty_out(vty, "(extended)\n"); | |
12806 | else | |
12807 | vty_out(vty, "(standard)\n"); | |
12808 | } | |
12809 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12810 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12811 | vty_out(vty, " Default information originate,"); | |
12812 | ||
12813 | if (p->default_rmap[afi][safi].name) | |
12814 | vty_out(vty, " default route-map %s%s,", | |
12815 | p->default_rmap[afi][safi].map ? "*" | |
12816 | : "", | |
12817 | p->default_rmap[afi][safi].name); | |
12818 | if (paf && PAF_SUBGRP(paf) | |
12819 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12820 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12821 | vty_out(vty, " default sent\n"); | |
12822 | else | |
12823 | vty_out(vty, " default not sent\n"); | |
12824 | } | |
12825 | ||
dff8f48d MK |
12826 | /* advertise-vni-all */ |
12827 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12828 | if (is_evpn_enabled()) |
dff8f48d MK |
12829 | vty_out(vty, " advertise-all-vni\n"); |
12830 | } | |
12831 | ||
d62a17ae | 12832 | if (filter->plist[FILTER_IN].name |
12833 | || filter->dlist[FILTER_IN].name | |
12834 | || filter->aslist[FILTER_IN].name | |
12835 | || filter->map[RMAP_IN].name) | |
12836 | vty_out(vty, " Inbound path policy configured\n"); | |
12837 | if (filter->plist[FILTER_OUT].name | |
12838 | || filter->dlist[FILTER_OUT].name | |
12839 | || filter->aslist[FILTER_OUT].name | |
12840 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12841 | vty_out(vty, " Outbound path policy configured\n"); | |
12842 | ||
12843 | /* prefix-list */ | |
12844 | if (filter->plist[FILTER_IN].name) | |
12845 | vty_out(vty, | |
12846 | " Incoming update prefix filter list is %s%s\n", | |
12847 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12848 | filter->plist[FILTER_IN].name); | |
12849 | if (filter->plist[FILTER_OUT].name) | |
12850 | vty_out(vty, | |
12851 | " Outgoing update prefix filter list is %s%s\n", | |
12852 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12853 | filter->plist[FILTER_OUT].name); | |
12854 | ||
12855 | /* distribute-list */ | |
12856 | if (filter->dlist[FILTER_IN].name) | |
12857 | vty_out(vty, | |
12858 | " Incoming update network filter list is %s%s\n", | |
12859 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12860 | filter->dlist[FILTER_IN].name); | |
12861 | if (filter->dlist[FILTER_OUT].name) | |
12862 | vty_out(vty, | |
12863 | " Outgoing update network filter list is %s%s\n", | |
12864 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12865 | filter->dlist[FILTER_OUT].name); | |
12866 | ||
12867 | /* filter-list. */ | |
12868 | if (filter->aslist[FILTER_IN].name) | |
12869 | vty_out(vty, | |
12870 | " Incoming update AS path filter list is %s%s\n", | |
12871 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12872 | filter->aslist[FILTER_IN].name); | |
12873 | if (filter->aslist[FILTER_OUT].name) | |
12874 | vty_out(vty, | |
12875 | " Outgoing update AS path filter list is %s%s\n", | |
12876 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12877 | filter->aslist[FILTER_OUT].name); | |
12878 | ||
12879 | /* route-map. */ | |
12880 | if (filter->map[RMAP_IN].name) | |
12881 | vty_out(vty, | |
12882 | " Route map for incoming advertisements is %s%s\n", | |
12883 | filter->map[RMAP_IN].map ? "*" : "", | |
12884 | filter->map[RMAP_IN].name); | |
12885 | if (filter->map[RMAP_OUT].name) | |
12886 | vty_out(vty, | |
12887 | " Route map for outgoing advertisements is %s%s\n", | |
12888 | filter->map[RMAP_OUT].map ? "*" : "", | |
12889 | filter->map[RMAP_OUT].name); | |
12890 | ||
9dac9fc8 | 12891 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12892 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12893 | && !bgp_inbound_policy_exists(p, filter)) |
12894 | vty_out(vty, | |
12895 | " Inbound updates discarded due to missing policy\n"); | |
12896 | ||
12897 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12898 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12899 | && !bgp_outbound_policy_exists(p, filter)) |
12900 | vty_out(vty, | |
12901 | " Outbound updates discarded due to missing policy\n"); | |
12902 | ||
d62a17ae | 12903 | /* unsuppress-map */ |
12904 | if (filter->usmap.name) | |
12905 | vty_out(vty, | |
12906 | " Route map for selective unsuppress is %s%s\n", | |
12907 | filter->usmap.map ? "*" : "", | |
12908 | filter->usmap.name); | |
12909 | ||
7f7940e6 MK |
12910 | /* advertise-map */ |
12911 | if (filter->advmap.aname && filter->advmap.cname) | |
12912 | vty_out(vty, | |
12913 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12914 | filter->advmap.condition ? "EXIST" | |
12915 | : "NON_EXIST", | |
12916 | filter->advmap.cmap ? "*" : "", | |
12917 | filter->advmap.cname, | |
12918 | filter->advmap.amap ? "*" : "", | |
12919 | filter->advmap.aname, | |
ecf2b628 QY |
12920 | filter->advmap.update_type == |
12921 | UPDATE_TYPE_ADVERTISE | |
c385f82a MK |
12922 | ? "Advertise" |
12923 | : "Withdraw"); | |
7f7940e6 | 12924 | |
d62a17ae | 12925 | /* Receive prefix count */ |
6cde4b45 | 12926 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12927 | p->pcount[afi][safi]); |
d62a17ae | 12928 | |
fde246e8 DA |
12929 | /* maximum-prefix-out */ |
12930 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12931 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12932 | vty_out(vty, | |
6cde4b45 | 12933 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12934 | p->pmax_out[afi][safi]); |
12935 | ||
d62a17ae | 12936 | /* Maximum prefix */ |
12937 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12938 | vty_out(vty, |
6cde4b45 | 12939 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12940 | p->pmax[afi][safi], |
12941 | CHECK_FLAG(p->af_flags[afi][safi], | |
12942 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12943 | ? " (warning-only)" | |
12944 | : ""); | |
12945 | vty_out(vty, " Threshold for warning message %d%%", | |
12946 | p->pmax_threshold[afi][safi]); | |
12947 | if (p->pmax_restart[afi][safi]) | |
12948 | vty_out(vty, ", restart interval %d min", | |
12949 | p->pmax_restart[afi][safi]); | |
12950 | vty_out(vty, "\n"); | |
12951 | } | |
12952 | ||
12953 | vty_out(vty, "\n"); | |
12954 | } | |
12955 | } | |
12956 | ||
9f049418 | 12957 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12958 | json_object *json) |
718e3744 | 12959 | { |
d62a17ae | 12960 | struct bgp *bgp; |
d62a17ae | 12961 | char timebuf[BGP_UPTIME_LEN]; |
12962 | char dn_flag[2]; | |
d62a17ae | 12963 | afi_t afi; |
12964 | safi_t safi; | |
d7c0a89a QY |
12965 | uint16_t i; |
12966 | uint8_t *msg; | |
d62a17ae | 12967 | json_object *json_neigh = NULL; |
12968 | time_t epoch_tbuf; | |
4ab46701 | 12969 | uint32_t sync_tcp_mss; |
718e3744 | 12970 | |
d62a17ae | 12971 | bgp = p->bgp; |
12972 | ||
12973 | if (use_json) | |
12974 | json_neigh = json_object_new_object(); | |
12975 | ||
12976 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12977 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12978 | dn_flag[0] = '*'; | |
12979 | ||
12980 | if (!use_json) { | |
12981 | if (p->conf_if) /* Configured interface name. */ | |
47e12884 DA |
12982 | vty_out(vty, "BGP neighbor on %s: %pSU, ", p->conf_if, |
12983 | &p->su); | |
d62a17ae | 12984 | else /* Configured IP address. */ |
12985 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12986 | p->host); | |
12987 | } | |
12988 | ||
12989 | if (use_json) { | |
12990 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12991 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12992 | "none"); | |
12993 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
47e12884 DA |
12994 | json_object_string_addf(json_neigh, "bgpNeighborAddr", |
12995 | "%pSU", &p->su); | |
d62a17ae | 12996 | |
12997 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12998 | ||
12999 | if (p->change_local_as) | |
13000 | json_object_int_add(json_neigh, "localAs", | |
13001 | p->change_local_as); | |
13002 | else | |
13003 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
13004 | ||
13005 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
13006 | json_object_boolean_true_add(json_neigh, | |
13007 | "localAsNoPrepend"); | |
13008 | ||
13009 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
13010 | json_object_boolean_true_add(json_neigh, | |
13011 | "localAsReplaceAs"); | |
13012 | } else { | |
13013 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
13014 | || (p->as_type == AS_INTERNAL)) | |
13015 | vty_out(vty, "remote AS %u, ", p->as); | |
13016 | else | |
13017 | vty_out(vty, "remote AS Unspecified, "); | |
13018 | vty_out(vty, "local AS %u%s%s, ", | |
13019 | p->change_local_as ? p->change_local_as : p->local_as, | |
13020 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
13021 | ? " no-prepend" | |
13022 | : "", | |
13023 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
13024 | ? " replace-as" | |
13025 | : ""); | |
13026 | } | |
faa16034 DS |
13027 | /* peer type internal or confed-internal */ |
13028 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 13029 | if (use_json) { |
13030 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13031 | json_object_boolean_true_add( | |
13032 | json_neigh, "nbrConfedInternalLink"); | |
13033 | else | |
13034 | json_object_boolean_true_add(json_neigh, | |
13035 | "nbrInternalLink"); | |
13036 | } else { | |
13037 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13038 | vty_out(vty, "confed-internal link\n"); | |
13039 | else | |
13040 | vty_out(vty, "internal link\n"); | |
13041 | } | |
faa16034 DS |
13042 | /* peer type external or confed-external */ |
13043 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 13044 | if (use_json) { |
13045 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13046 | json_object_boolean_true_add( | |
13047 | json_neigh, "nbrConfedExternalLink"); | |
13048 | else | |
13049 | json_object_boolean_true_add(json_neigh, | |
13050 | "nbrExternalLink"); | |
13051 | } else { | |
13052 | if (bgp_confederation_peers_check(bgp, p->as)) | |
13053 | vty_out(vty, "confed-external link\n"); | |
13054 | else | |
13055 | vty_out(vty, "external link\n"); | |
13056 | } | |
faa16034 DS |
13057 | } else { |
13058 | if (use_json) | |
13059 | json_object_boolean_true_add(json_neigh, | |
13060 | "nbrUnspecifiedLink"); | |
13061 | else | |
13062 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 13063 | } |
13064 | ||
d864dd9e EB |
13065 | /* Roles */ |
13066 | if (use_json) { | |
13067 | json_object_string_add(json_neigh, "localRole", | |
8f2d6021 EB |
13068 | bgp_get_name_by_role(p->local_role)); |
13069 | json_object_string_add(json_neigh, "remoteRole", | |
13070 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
13071 | } else { |
13072 | vty_out(vty, " Local Role: %s\n", | |
8f2d6021 EB |
13073 | bgp_get_name_by_role(p->local_role)); |
13074 | vty_out(vty, " Remote Role: %s\n", | |
13075 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
13076 | } |
13077 | ||
13078 | ||
d62a17ae | 13079 | /* Description. */ |
13080 | if (p->desc) { | |
13081 | if (use_json) | |
13082 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
13083 | else | |
13084 | vty_out(vty, " Description: %s\n", p->desc); | |
13085 | } | |
13086 | ||
13087 | if (p->hostname) { | |
13088 | if (use_json) { | |
432e7e46 KQ |
13089 | json_object_string_add(json_neigh, "hostname", |
13090 | p->hostname); | |
d62a17ae | 13091 | |
13092 | if (p->domainname) | |
13093 | json_object_string_add(json_neigh, "domainname", | |
13094 | p->domainname); | |
13095 | } else { | |
13096 | if (p->domainname && (p->domainname[0] != '\0')) | |
13097 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
13098 | p->domainname); | |
13099 | else | |
13100 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
13101 | } | |
432e7e46 KQ |
13102 | } else { |
13103 | if (use_json) | |
13104 | json_object_string_add(json_neigh, "hostname", | |
13105 | "Unknown"); | |
d62a17ae | 13106 | } |
13107 | ||
13108 | /* Peer-group */ | |
13109 | if (p->group) { | |
13110 | if (use_json) { | |
13111 | json_object_string_add(json_neigh, "peerGroup", | |
13112 | p->group->name); | |
13113 | ||
13114 | if (dn_flag[0]) { | |
13115 | struct prefix prefix, *range = NULL; | |
13116 | ||
0154d8ce DS |
13117 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13118 | range = peer_group_lookup_dynamic_neighbor_range( | |
13119 | p->group, &prefix); | |
d62a17ae | 13120 | |
13121 | if (range) { | |
67d7e256 | 13122 | json_object_string_addf( |
d62a17ae | 13123 | json_neigh, |
67d7e256 DA |
13124 | "peerSubnetRangeGroup", "%pFX", |
13125 | range); | |
d62a17ae | 13126 | } |
13127 | } | |
13128 | } else { | |
13129 | vty_out(vty, | |
13130 | " Member of peer-group %s for session parameters\n", | |
13131 | p->group->name); | |
13132 | ||
13133 | if (dn_flag[0]) { | |
13134 | struct prefix prefix, *range = NULL; | |
13135 | ||
0154d8ce DS |
13136 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13137 | range = peer_group_lookup_dynamic_neighbor_range( | |
13138 | p->group, &prefix); | |
d62a17ae | 13139 | |
13140 | if (range) { | |
d62a17ae | 13141 | vty_out(vty, |
1b78780b DL |
13142 | " Belongs to the subnet range group: %pFX\n", |
13143 | range); | |
d62a17ae | 13144 | } |
13145 | } | |
13146 | } | |
13147 | } | |
13148 | ||
13149 | if (use_json) { | |
13150 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13151 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13152 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13153 | json_object_boolean_true_add(json_neigh, |
13154 | "adminShutDown"); | |
13155 | ||
13156 | /* BGP Version. */ | |
13157 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
c949c771 DA |
13158 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", |
13159 | &p->remote_id); | |
13160 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
13161 | &bgp->router_id); | |
d62a17ae | 13162 | |
13163 | /* Confederation */ | |
13164 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13165 | && bgp_confederation_peers_check(bgp, p->as)) | |
13166 | json_object_boolean_true_add(json_neigh, | |
13167 | "nbrCommonAdmin"); | |
13168 | ||
13169 | /* Status. */ | |
13170 | json_object_string_add( | |
13171 | json_neigh, "bgpState", | |
13172 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13173 | ||
feb17238 | 13174 | if (peer_established(p)) { |
d62a17ae | 13175 | time_t uptime; |
d62a17ae | 13176 | |
083ec940 | 13177 | uptime = monotime(NULL); |
d62a17ae | 13178 | uptime -= p->uptime; |
d62a17ae | 13179 | epoch_tbuf = time(NULL) - uptime; |
13180 | ||
d3c7efed DS |
13181 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
13182 | uptime * 1000); | |
d62a17ae | 13183 | json_object_string_add(json_neigh, "bgpTimerUpString", |
13184 | peer_uptime(p->uptime, timebuf, | |
13185 | BGP_UPTIME_LEN, 0, | |
13186 | NULL)); | |
13187 | json_object_int_add(json_neigh, | |
13188 | "bgpTimerUpEstablishedEpoch", | |
13189 | epoch_tbuf); | |
13190 | } | |
13191 | ||
13192 | else if (p->status == Active) { | |
13193 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13194 | json_object_string_add(json_neigh, "bgpStateIs", | |
13195 | "passive"); | |
13196 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13197 | json_object_string_add(json_neigh, "bgpStateIs", | |
13198 | "passiveNSF"); | |
13199 | } | |
13200 | ||
13201 | /* read timer */ | |
13202 | time_t uptime; | |
a2700b50 | 13203 | struct tm tm; |
d62a17ae | 13204 | |
083ec940 | 13205 | uptime = monotime(NULL); |
d62a17ae | 13206 | uptime -= p->readtime; |
a2700b50 MS |
13207 | gmtime_r(&uptime, &tm); |
13208 | ||
d62a17ae | 13209 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
13210 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13211 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13212 | |
083ec940 | 13213 | uptime = monotime(NULL); |
d62a17ae | 13214 | uptime -= p->last_write; |
a2700b50 MS |
13215 | gmtime_r(&uptime, &tm); |
13216 | ||
d62a17ae | 13217 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
13218 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13219 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13220 | |
083ec940 | 13221 | uptime = monotime(NULL); |
d62a17ae | 13222 | uptime -= p->update_time; |
a2700b50 MS |
13223 | gmtime_r(&uptime, &tm); |
13224 | ||
d62a17ae | 13225 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
13226 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13227 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13228 | |
13229 | /* Configured timer values. */ | |
9b1b9623 TA |
13230 | json_object_int_add(json_neigh, |
13231 | "bgpTimerConfiguredHoldTimeMsecs", | |
e93d5c29 TA |
13232 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13233 | ? p->holdtime * 1000 | |
13234 | : bgp->default_holdtime * 1000); | |
13235 | json_object_int_add(json_neigh, | |
13236 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
13237 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13238 | ? p->keepalive * 1000 | |
13239 | : bgp->default_keepalive * 1000); | |
d62a17ae | 13240 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", |
13241 | p->v_holdtime * 1000); | |
13242 | json_object_int_add(json_neigh, | |
13243 | "bgpTimerKeepAliveIntervalMsecs", | |
13244 | p->v_keepalive * 1000); | |
d43114f3 DS |
13245 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
13246 | json_object_int_add(json_neigh, | |
13247 | "bgpTimerDelayOpenTimeMsecs", | |
13248 | p->v_delayopen * 1000); | |
13249 | } | |
13250 | ||
4ab46701 AR |
13251 | /* Configured and Synced tcp-mss value for peer */ |
13252 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13253 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13254 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
13255 | p->tcp_mss); | |
13256 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
13257 | sync_tcp_mss); | |
13258 | } | |
13259 | ||
d08c0c80 DA |
13260 | /* Extended Optional Parameters Length for BGP OPEN Message */ |
13261 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13262 | json_object_boolean_true_add( | |
13263 | json_neigh, "extendedOptionalParametersLength"); | |
13264 | else | |
13265 | json_object_boolean_false_add( | |
13266 | json_neigh, "extendedOptionalParametersLength"); | |
6e37924b DA |
13267 | |
13268 | /* Conditional advertisements */ | |
13269 | json_object_int_add( | |
13270 | json_neigh, | |
13271 | "bgpTimerConfiguredConditionalAdvertisementsSec", | |
13272 | bgp->condition_check_period); | |
13273 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13274 | json_object_int_add( | |
13275 | json_neigh, | |
13276 | "bgpTimerUntilConditionalAdvertisementsSec", | |
13277 | thread_timer_remain_second( | |
13278 | bgp->t_condition_check)); | |
d62a17ae | 13279 | } else { |
13280 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13281 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13282 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13283 | vty_out(vty, " Administratively shut down\n"); |
13284 | ||
13285 | /* BGP Version. */ | |
13286 | vty_out(vty, " BGP version 4"); | |
07380148 DA |
13287 | vty_out(vty, ", remote router ID %pI4", &p->remote_id); |
13288 | vty_out(vty, ", local router ID %pI4\n", &bgp->router_id); | |
d62a17ae | 13289 | |
13290 | /* Confederation */ | |
13291 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13292 | && bgp_confederation_peers_check(bgp, p->as)) | |
13293 | vty_out(vty, | |
13294 | " Neighbor under common administration\n"); | |
13295 | ||
13296 | /* Status. */ | |
13297 | vty_out(vty, " BGP state = %s", | |
13298 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13299 | ||
feb17238 | 13300 | if (peer_established(p)) |
d62a17ae | 13301 | vty_out(vty, ", up for %8s", |
13302 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
13303 | 0, NULL)); | |
13304 | ||
13305 | else if (p->status == Active) { | |
13306 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13307 | vty_out(vty, " (passive)"); | |
13308 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13309 | vty_out(vty, " (NSF passive)"); | |
13310 | } | |
13311 | vty_out(vty, "\n"); | |
13312 | ||
13313 | /* read timer */ | |
13314 | vty_out(vty, " Last read %s", | |
13315 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
13316 | NULL)); | |
13317 | vty_out(vty, ", Last write %s\n", | |
13318 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
13319 | NULL)); | |
13320 | ||
13321 | /* Configured timer values. */ | |
13322 | vty_out(vty, | |
e93d5c29 | 13323 | " Hold time is %d seconds, keepalive interval is %d seconds\n", |
d62a17ae | 13324 | p->v_holdtime, p->v_keepalive); |
e93d5c29 TA |
13325 | vty_out(vty, " Configured hold time is %d seconds", |
13326 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13327 | ? p->holdtime | |
13328 | : bgp->default_holdtime); | |
9b1b9623 | 13329 | vty_out(vty, ", keepalive interval is %d seconds\n", |
e93d5c29 TA |
13330 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13331 | ? p->keepalive | |
13332 | : bgp->default_keepalive); | |
d43114f3 DS |
13333 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
13334 | vty_out(vty, | |
13335 | " Configured DelayOpenTime is %d seconds\n", | |
13336 | p->delayopen); | |
4ab46701 AR |
13337 | |
13338 | /* Configured and synced tcp-mss value for peer */ | |
13339 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13340 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13341 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
13342 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
13343 | } | |
d08c0c80 DA |
13344 | |
13345 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
13346 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13347 | vty_out(vty, | |
13348 | " Extended Optional Parameters Length is enabled\n"); | |
6e37924b DA |
13349 | |
13350 | /* Conditional advertisements */ | |
13351 | vty_out(vty, | |
13352 | " Configured conditional advertisements interval is %d seconds\n", | |
13353 | bgp->condition_check_period); | |
13354 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13355 | vty_out(vty, | |
13356 | " Time until conditional advertisements begin is %lu seconds\n", | |
13357 | thread_timer_remain_second( | |
13358 | bgp->t_condition_check)); | |
d62a17ae | 13359 | } |
13360 | /* Capability. */ | |
10711563 DA |
13361 | if (peer_established(p) && |
13362 | (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) { | |
13363 | if (use_json) { | |
13364 | json_object *json_cap = NULL; | |
d62a17ae | 13365 | |
10711563 | 13366 | json_cap = json_object_new_object(); |
d62a17ae | 13367 | |
10711563 DA |
13368 | /* AS4 */ |
13369 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13370 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13371 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) && | |
13372 | CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
ef56aee4 | 13373 | json_object_string_add( |
10711563 | 13374 | json_cap, "4byteAs", |
ef56aee4 | 13375 | "advertisedAndReceived"); |
10711563 DA |
13376 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) |
13377 | json_object_string_add(json_cap, | |
13378 | "4byteAs", | |
13379 | "advertised"); | |
13380 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13381 | json_object_string_add(json_cap, | |
13382 | "4byteAs", | |
13383 | "received"); | |
13384 | } | |
ef56aee4 | 13385 | |
10711563 DA |
13386 | /* Extended Message Support */ |
13387 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV) && | |
13388 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13389 | json_object_string_add(json_cap, | |
13390 | "extendedMessage", | |
13391 | "advertisedAndReceived"); | |
13392 | else if (CHECK_FLAG(p->cap, | |
13393 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13394 | json_object_string_add(json_cap, | |
13395 | "extendedMessage", | |
13396 | "advertised"); | |
13397 | else if (CHECK_FLAG(p->cap, | |
13398 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13399 | json_object_string_add(json_cap, | |
13400 | "extendedMessage", | |
13401 | "received"); | |
ef56aee4 | 13402 | |
10711563 DA |
13403 | /* AddPath */ |
13404 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13405 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13406 | json_object *json_add = NULL; | |
13407 | const char *print_store; | |
d62a17ae | 13408 | |
10711563 | 13409 | json_add = json_object_new_object(); |
d62a17ae | 13410 | |
10711563 DA |
13411 | FOREACH_AFI_SAFI (afi, safi) { |
13412 | json_object *json_sub = NULL; | |
13413 | json_sub = json_object_new_object(); | |
13414 | print_store = get_afi_safi_str( | |
13415 | afi, safi, true); | |
d62a17ae | 13416 | |
10711563 DA |
13417 | if (CHECK_FLAG( |
13418 | p->af_cap[afi][safi], | |
13419 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13420 | CHECK_FLAG( | |
13421 | p->af_cap[afi][safi], | |
13422 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
05c7a1cc QY |
13423 | if (CHECK_FLAG( |
13424 | p->af_cap[afi] | |
13425 | [safi], | |
10711563 DA |
13426 | PEER_CAP_ADDPATH_AF_TX_ADV) && |
13427 | CHECK_FLAG( | |
05c7a1cc QY |
13428 | p->af_cap[afi] |
13429 | [safi], | |
10711563 DA |
13430 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
13431 | json_object_boolean_true_add( | |
13432 | json_sub, | |
13433 | "txAdvertisedAndReceived"); | |
13434 | else if ( | |
13435 | CHECK_FLAG( | |
13436 | p->af_cap[afi] | |
13437 | [safi], | |
13438 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13439 | json_object_boolean_true_add( | |
13440 | json_sub, | |
13441 | "txAdvertised"); | |
13442 | else if ( | |
13443 | CHECK_FLAG( | |
13444 | p->af_cap[afi] | |
13445 | [safi], | |
13446 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13447 | json_object_boolean_true_add( | |
13448 | json_sub, | |
13449 | "txReceived"); | |
13450 | } | |
d62a17ae | 13451 | |
10711563 DA |
13452 | if (CHECK_FLAG( |
13453 | p->af_cap[afi][safi], | |
13454 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13455 | CHECK_FLAG( | |
13456 | p->af_cap[afi][safi], | |
13457 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
05c7a1cc QY |
13458 | if (CHECK_FLAG( |
13459 | p->af_cap[afi] | |
13460 | [safi], | |
10711563 DA |
13461 | PEER_CAP_ADDPATH_AF_RX_ADV) && |
13462 | CHECK_FLAG( | |
13463 | p->af_cap[afi] | |
13464 | [safi], | |
13465 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13466 | json_object_boolean_true_add( | |
13467 | json_sub, | |
13468 | "rxAdvertisedAndReceived"); | |
13469 | else if ( | |
13470 | CHECK_FLAG( | |
13471 | p->af_cap[afi] | |
13472 | [safi], | |
13473 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
13474 | json_object_boolean_true_add( | |
13475 | json_sub, | |
13476 | "rxAdvertised"); | |
13477 | else if ( | |
13478 | CHECK_FLAG( | |
13479 | p->af_cap[afi] | |
13480 | [safi], | |
13481 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13482 | json_object_boolean_true_add( | |
13483 | json_sub, | |
13484 | "rxReceived"); | |
05c7a1cc QY |
13485 | } |
13486 | ||
10711563 DA |
13487 | if (CHECK_FLAG( |
13488 | p->af_cap[afi][safi], | |
13489 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13490 | CHECK_FLAG( | |
13491 | p->af_cap[afi][safi], | |
13492 | PEER_CAP_ADDPATH_AF_TX_RCV) || | |
13493 | CHECK_FLAG( | |
13494 | p->af_cap[afi][safi], | |
13495 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13496 | CHECK_FLAG( | |
13497 | p->af_cap[afi][safi], | |
13498 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13499 | json_object_object_add( | |
13500 | json_add, print_store, | |
13501 | json_sub); | |
13502 | else | |
13503 | json_object_free(json_sub); | |
d62a17ae | 13504 | } |
13505 | ||
10711563 DA |
13506 | json_object_object_add(json_cap, "addPath", |
13507 | json_add); | |
13508 | } | |
d62a17ae | 13509 | |
10711563 DA |
13510 | /* Dynamic */ |
13511 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13512 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13513 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV) && | |
13514 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13515 | json_object_string_add( | |
13516 | json_cap, "dynamic", | |
13517 | "advertisedAndReceived"); | |
13518 | else if (CHECK_FLAG(p->cap, | |
13519 | PEER_CAP_DYNAMIC_ADV)) | |
13520 | json_object_string_add(json_cap, | |
13521 | "dynamic", | |
13522 | "advertised"); | |
13523 | else if (CHECK_FLAG(p->cap, | |
13524 | PEER_CAP_DYNAMIC_RCV)) | |
13525 | json_object_string_add(json_cap, | |
13526 | "dynamic", | |
13527 | "received"); | |
13528 | } | |
d62a17ae | 13529 | |
d864dd9e EB |
13530 | /* Role */ |
13531 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
13532 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
13533 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV) && | |
13534 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13535 | json_object_string_add( | |
13536 | json_cap, "role", | |
13537 | "advertisedAndReceived"); | |
13538 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
13539 | json_object_string_add(json_cap, "role", | |
13540 | "advertised"); | |
13541 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13542 | json_object_string_add(json_cap, "role", | |
13543 | "received"); | |
13544 | } | |
13545 | ||
10711563 DA |
13546 | /* Extended nexthop */ |
13547 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13548 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13549 | json_object *json_nxt = NULL; | |
13550 | const char *print_store; | |
d62a17ae | 13551 | |
d62a17ae | 13552 | |
10711563 DA |
13553 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV) && |
13554 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13555 | json_object_string_add( | |
13556 | json_cap, "extendedNexthop", | |
13557 | "advertisedAndReceived"); | |
13558 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13559 | json_object_string_add( | |
13560 | json_cap, "extendedNexthop", | |
13561 | "advertised"); | |
13562 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13563 | json_object_string_add( | |
13564 | json_cap, "extendedNexthop", | |
13565 | "received"); | |
d62a17ae | 13566 | |
10711563 DA |
13567 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
13568 | json_nxt = json_object_new_object(); | |
d62a17ae | 13569 | |
10711563 DA |
13570 | for (safi = SAFI_UNICAST; |
13571 | safi < SAFI_MAX; safi++) { | |
13572 | if (CHECK_FLAG( | |
13573 | p->af_cap[AFI_IP] | |
13574 | [safi], | |
13575 | PEER_CAP_ENHE_AF_RCV)) { | |
13576 | print_store = | |
13577 | get_afi_safi_str( | |
d62a17ae | 13578 | AFI_IP, |
10711563 DA |
13579 | safi, |
13580 | true); | |
13581 | json_object_string_add( | |
13582 | json_nxt, | |
13583 | print_store, | |
13584 | "recieved"); /* misspelled for compatibility */ | |
d62a17ae | 13585 | } |
d62a17ae | 13586 | } |
10711563 DA |
13587 | json_object_object_add( |
13588 | json_cap, | |
13589 | "extendedNexthopFamililesByPeer", | |
13590 | json_nxt); | |
d62a17ae | 13591 | } |
10711563 | 13592 | } |
d62a17ae | 13593 | |
10711563 DA |
13594 | /* Long-lived Graceful Restart */ |
13595 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13596 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13597 | json_object *json_llgr = NULL; | |
13598 | const char *afi_safi_str; | |
8606be87 | 13599 | |
10711563 DA |
13600 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV) && |
13601 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13602 | json_object_string_add( | |
13603 | json_cap, | |
13604 | "longLivedGracefulRestart", | |
13605 | "advertisedAndReceived"); | |
13606 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13607 | json_object_string_add( | |
13608 | json_cap, | |
13609 | "longLivedGracefulRestart", | |
13610 | "advertised"); | |
13611 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13612 | json_object_string_add( | |
13613 | json_cap, | |
13614 | "longLivedGracefulRestart", | |
13615 | "received"); | |
8606be87 | 13616 | |
10711563 DA |
13617 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
13618 | json_llgr = json_object_new_object(); | |
8606be87 | 13619 | |
10711563 DA |
13620 | FOREACH_AFI_SAFI (afi, safi) { |
13621 | if (CHECK_FLAG( | |
13622 | p->af_cap[afi] | |
13623 | [safi], | |
13624 | PEER_CAP_ENHE_AF_RCV)) { | |
13625 | afi_safi_str = | |
13626 | get_afi_safi_str( | |
8606be87 DA |
13627 | afi, |
13628 | safi, | |
13629 | true); | |
10711563 DA |
13630 | json_object_string_add( |
13631 | json_llgr, | |
13632 | afi_safi_str, | |
13633 | "received"); | |
8606be87 | 13634 | } |
8606be87 | 13635 | } |
10711563 DA |
13636 | json_object_object_add( |
13637 | json_cap, | |
13638 | "longLivedGracefulRestartByPeer", | |
13639 | json_llgr); | |
8606be87 | 13640 | } |
10711563 | 13641 | } |
8606be87 | 13642 | |
10711563 DA |
13643 | /* Route Refresh */ |
13644 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13645 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13646 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13647 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && | |
13648 | (CHECK_FLAG(p->cap, | |
13649 | PEER_CAP_REFRESH_NEW_RCV) || | |
13650 | CHECK_FLAG(p->cap, | |
13651 | PEER_CAP_REFRESH_OLD_RCV))) { | |
13652 | if (CHECK_FLAG( | |
13653 | p->cap, | |
13654 | PEER_CAP_REFRESH_OLD_RCV) && | |
13655 | CHECK_FLAG( | |
13656 | p->cap, | |
13657 | PEER_CAP_REFRESH_NEW_RCV)) | |
13658 | json_object_string_add( | |
13659 | json_cap, | |
13660 | "routeRefresh", | |
13661 | "advertisedAndReceivedOldNew"); | |
13662 | else { | |
d62a17ae | 13663 | if (CHECK_FLAG( |
13664 | p->cap, | |
10711563 | 13665 | PEER_CAP_REFRESH_OLD_RCV)) |
d62a17ae | 13666 | json_object_string_add( |
13667 | json_cap, | |
13668 | "routeRefresh", | |
10711563 DA |
13669 | "advertisedAndReceivedOld"); |
13670 | else | |
13671 | json_object_string_add( | |
13672 | json_cap, | |
13673 | "routeRefresh", | |
13674 | "advertisedAndReceivedNew"); | |
d62a17ae | 13675 | } |
10711563 DA |
13676 | } else if (CHECK_FLAG(p->cap, |
13677 | PEER_CAP_REFRESH_ADV)) | |
13678 | json_object_string_add(json_cap, | |
13679 | "routeRefresh", | |
13680 | "advertised"); | |
13681 | else if (CHECK_FLAG(p->cap, | |
13682 | PEER_CAP_REFRESH_NEW_RCV) || | |
13683 | CHECK_FLAG(p->cap, | |
13684 | PEER_CAP_REFRESH_OLD_RCV)) | |
13685 | json_object_string_add(json_cap, | |
13686 | "routeRefresh", | |
13687 | "received"); | |
13688 | } | |
d62a17ae | 13689 | |
10711563 DA |
13690 | /* Enhanced Route Refresh */ |
13691 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13692 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13693 | if (CHECK_FLAG(p->cap, | |
13694 | PEER_CAP_ENHANCED_RR_ADV) && | |
13695 | CHECK_FLAG(p->cap, | |
13696 | PEER_CAP_ENHANCED_RR_RCV)) | |
d77114b7 | 13697 | json_object_string_add( |
10711563 DA |
13698 | json_cap, |
13699 | "enhancedRouteRefresh", | |
13700 | "advertisedAndReceived"); | |
13701 | else if (CHECK_FLAG(p->cap, | |
13702 | PEER_CAP_ENHANCED_RR_ADV)) | |
d77114b7 | 13703 | json_object_string_add( |
10711563 DA |
13704 | json_cap, |
13705 | "enhancedRouteRefresh", | |
13706 | "advertised"); | |
13707 | else if (CHECK_FLAG(p->cap, | |
9af52ccf | 13708 | PEER_CAP_ENHANCED_RR_RCV)) |
10711563 DA |
13709 | json_object_string_add( |
13710 | json_cap, | |
13711 | "enhancedRouteRefresh", | |
13712 | "received"); | |
13713 | } | |
d77114b7 | 13714 | |
10711563 DA |
13715 | /* Multiprotocol Extensions */ |
13716 | json_object *json_multi = NULL; | |
d77114b7 | 13717 | |
10711563 | 13718 | json_multi = json_object_new_object(); |
d77114b7 | 13719 | |
10711563 DA |
13720 | FOREACH_AFI_SAFI (afi, safi) { |
13721 | if (p->afc_adv[afi][safi] || | |
13722 | p->afc_recv[afi][safi]) { | |
13723 | json_object *json_exten = NULL; | |
13724 | json_exten = json_object_new_object(); | |
13725 | ||
13726 | if (p->afc_adv[afi][safi] && | |
13727 | p->afc_recv[afi][safi]) | |
13728 | json_object_boolean_true_add( | |
13729 | json_exten, | |
9af52ccf | 13730 | "advertisedAndReceived"); |
10711563 DA |
13731 | else if (p->afc_adv[afi][safi]) |
13732 | json_object_boolean_true_add( | |
13733 | json_exten, | |
9af52ccf | 13734 | "advertised"); |
10711563 DA |
13735 | else if (p->afc_recv[afi][safi]) |
13736 | json_object_boolean_true_add( | |
13737 | json_exten, "received"); | |
9af52ccf | 13738 | |
10711563 DA |
13739 | json_object_object_add( |
13740 | json_multi, | |
13741 | get_afi_safi_str(afi, safi, | |
13742 | true), | |
13743 | json_exten); | |
13744 | } | |
13745 | } | |
13746 | json_object_object_add(json_cap, | |
13747 | "multiprotocolExtensions", | |
13748 | json_multi); | |
d62a17ae | 13749 | |
10711563 DA |
13750 | /* Hostname capabilities */ |
13751 | json_object *json_hname = NULL; | |
d62a17ae | 13752 | |
10711563 | 13753 | json_hname = json_object_new_object(); |
d62a17ae | 13754 | |
10711563 DA |
13755 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
13756 | json_object_string_add( | |
13757 | json_hname, "advHostName", | |
13758 | bgp->peer_self->hostname | |
13759 | ? bgp->peer_self->hostname | |
13760 | : "n/a"); | |
13761 | json_object_string_add( | |
13762 | json_hname, "advDomainName", | |
13763 | bgp->peer_self->domainname | |
13764 | ? bgp->peer_self->domainname | |
13765 | : "n/a"); | |
13766 | } | |
d77114b7 | 13767 | |
d77114b7 | 13768 | |
10711563 DA |
13769 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13770 | json_object_string_add( | |
13771 | json_hname, "rcvHostName", | |
13772 | p->hostname ? p->hostname : "n/a"); | |
13773 | json_object_string_add( | |
13774 | json_hname, "rcvDomainName", | |
13775 | p->domainname ? p->domainname : "n/a"); | |
13776 | } | |
d77114b7 | 13777 | |
10711563 DA |
13778 | json_object_object_add(json_cap, "hostName", |
13779 | json_hname); | |
d77114b7 | 13780 | |
17be83bf | 13781 | /* Graceful Restart */ |
10711563 DA |
13782 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || |
13783 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13784 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
13785 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
d77114b7 | 13786 | json_object_string_add( |
10711563 DA |
13787 | json_cap, "gracefulRestart", |
13788 | "advertisedAndReceived"); | |
13789 | else if (CHECK_FLAG(p->cap, | |
13790 | PEER_CAP_RESTART_ADV)) | |
d77114b7 | 13791 | json_object_string_add( |
10711563 DA |
13792 | json_cap, |
13793 | "gracefulRestartCapability", | |
13794 | "advertised"); | |
13795 | else if (CHECK_FLAG(p->cap, | |
13796 | PEER_CAP_RESTART_RCV)) | |
13797 | json_object_string_add( | |
13798 | json_cap, | |
13799 | "gracefulRestartCapability", | |
13800 | "received"); | |
d77114b7 | 13801 | |
10711563 DA |
13802 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13803 | int restart_af_count = 0; | |
13804 | json_object *json_restart = NULL; | |
13805 | json_restart = json_object_new_object(); | |
d62a17ae | 13806 | |
10711563 DA |
13807 | json_object_int_add( |
13808 | json_cap, | |
13809 | "gracefulRestartRemoteTimerMsecs", | |
13810 | p->v_gr_restart * 1000); | |
d62a17ae | 13811 | |
10711563 | 13812 | FOREACH_AFI_SAFI (afi, safi) { |
05c7a1cc QY |
13813 | if (CHECK_FLAG( |
13814 | p->af_cap[afi] | |
13815 | [safi], | |
10711563 DA |
13816 | PEER_CAP_RESTART_AF_RCV)) { |
13817 | json_object *json_sub = | |
13818 | NULL; | |
13819 | json_sub = | |
13820 | json_object_new_object(); | |
d62a17ae | 13821 | |
05c7a1cc QY |
13822 | if (CHECK_FLAG( |
13823 | p->af_cap | |
13824 | [afi] | |
13825 | [safi], | |
10711563 DA |
13826 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13827 | json_object_boolean_true_add( | |
13828 | json_sub, | |
13829 | "preserved"); | |
13830 | restart_af_count++; | |
d62a17ae | 13831 | json_object_object_add( |
10711563 DA |
13832 | json_restart, |
13833 | get_afi_safi_str( | |
13834 | afi, | |
13835 | safi, | |
13836 | true), | |
13837 | json_sub); | |
d62a17ae | 13838 | } |
d62a17ae | 13839 | } |
10711563 DA |
13840 | if (!restart_af_count) { |
13841 | json_object_string_add( | |
13842 | json_cap, | |
13843 | "addressFamiliesByPeer", | |
13844 | "none"); | |
13845 | json_object_free(json_restart); | |
13846 | } else | |
13847 | json_object_object_add( | |
13848 | json_cap, | |
13849 | "addressFamiliesByPeer", | |
13850 | json_restart); | |
d62a17ae | 13851 | } |
10711563 DA |
13852 | } |
13853 | json_object_object_add( | |
13854 | json_neigh, "neighborCapabilities", json_cap); | |
13855 | } else { | |
13856 | vty_out(vty, " Neighbor capabilities:\n"); | |
13857 | ||
13858 | /* AS4 */ | |
13859 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13860 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13861 | vty_out(vty, " 4 Byte AS:"); | |
13862 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
13863 | vty_out(vty, " advertised"); | |
13864 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13865 | vty_out(vty, " %sreceived", | |
13866 | CHECK_FLAG(p->cap, | |
13867 | PEER_CAP_AS4_ADV) | |
13868 | ? "and " | |
13869 | : ""); | |
13870 | vty_out(vty, "\n"); | |
13871 | } | |
d62a17ae | 13872 | |
10711563 DA |
13873 | /* Extended Message Support */ |
13874 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) || | |
13875 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13876 | vty_out(vty, " Extended Message:"); | |
ef56aee4 | 13877 | if (CHECK_FLAG(p->cap, |
10711563 DA |
13878 | PEER_CAP_EXTENDED_MESSAGE_ADV)) |
13879 | vty_out(vty, " advertised"); | |
13880 | if (CHECK_FLAG(p->cap, | |
13881 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13882 | vty_out(vty, " %sreceived", | |
13883 | CHECK_FLAG( | |
13884 | p->cap, | |
13885 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13886 | ? "and " | |
13887 | : ""); | |
13888 | vty_out(vty, "\n"); | |
13889 | } | |
d62a17ae | 13890 | |
10711563 DA |
13891 | /* AddPath */ |
13892 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13893 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13894 | vty_out(vty, " AddPath:\n"); | |
d62a17ae | 13895 | |
10711563 | 13896 | FOREACH_AFI_SAFI (afi, safi) { |
ef56aee4 | 13897 | if (CHECK_FLAG( |
10711563 DA |
13898 | p->af_cap[afi][safi], |
13899 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13900 | CHECK_FLAG( | |
13901 | p->af_cap[afi][safi], | |
13902 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13903 | vty_out(vty, " %s: TX ", | |
13904 | get_afi_safi_str( | |
13905 | afi, safi, | |
13906 | false)); | |
ef56aee4 | 13907 | |
10711563 DA |
13908 | if (CHECK_FLAG( |
13909 | p->af_cap[afi] | |
13910 | [safi], | |
13911 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13912 | vty_out(vty, | |
13913 | "advertised"); | |
d62a17ae | 13914 | |
05c7a1cc QY |
13915 | if (CHECK_FLAG( |
13916 | p->af_cap[afi] | |
13917 | [safi], | |
10711563 | 13918 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
05c7a1cc | 13919 | vty_out(vty, |
10711563 DA |
13920 | "%sreceived", |
13921 | CHECK_FLAG( | |
13922 | p->af_cap | |
13923 | [afi] | |
13924 | [safi], | |
13925 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13926 | ? " and " | |
13927 | : ""); | |
05c7a1cc | 13928 | |
10711563 DA |
13929 | vty_out(vty, "\n"); |
13930 | } | |
d62a17ae | 13931 | |
9af52ccf | 13932 | if (CHECK_FLAG( |
10711563 DA |
13933 | p->af_cap[afi][safi], |
13934 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13935 | CHECK_FLAG( | |
13936 | p->af_cap[afi][safi], | |
13937 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13938 | vty_out(vty, " %s: RX ", | |
5cb5f4d0 | 13939 | get_afi_safi_str( |
10711563 DA |
13940 | afi, safi, |
13941 | false)); | |
d62a17ae | 13942 | |
05c7a1cc QY |
13943 | if (CHECK_FLAG( |
13944 | p->af_cap[afi] | |
13945 | [safi], | |
10711563 | 13946 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
05c7a1cc | 13947 | vty_out(vty, |
10711563 | 13948 | "advertised"); |
d62a17ae | 13949 | |
10711563 DA |
13950 | if (CHECK_FLAG( |
13951 | p->af_cap[afi] | |
13952 | [safi], | |
13953 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc | 13954 | vty_out(vty, |
10711563 DA |
13955 | "%sreceived", |
13956 | CHECK_FLAG( | |
13957 | p->af_cap | |
13958 | [afi] | |
13959 | [safi], | |
13960 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13961 | ? " and " | |
05c7a1cc | 13962 | : ""); |
d62a17ae | 13963 | |
05c7a1cc | 13964 | vty_out(vty, "\n"); |
05c7a1cc | 13965 | } |
d62a17ae | 13966 | } |
10711563 | 13967 | } |
d62a17ae | 13968 | |
10711563 DA |
13969 | /* Dynamic */ |
13970 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13971 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13972 | vty_out(vty, " Dynamic:"); | |
13973 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) | |
13974 | vty_out(vty, " advertised"); | |
13975 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13976 | vty_out(vty, " %sreceived", | |
13977 | CHECK_FLAG(p->cap, | |
13978 | PEER_CAP_DYNAMIC_ADV) | |
13979 | ? "and " | |
13980 | : ""); | |
13981 | vty_out(vty, "\n"); | |
13982 | } | |
d62a17ae | 13983 | |
d864dd9e EB |
13984 | /* Role */ |
13985 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
13986 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
13987 | vty_out(vty, " Role:"); | |
13988 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
13989 | vty_out(vty, " advertised"); | |
13990 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13991 | vty_out(vty, " %sreceived", | |
13992 | CHECK_FLAG(p->cap, | |
13993 | PEER_CAP_ROLE_ADV) | |
13994 | ? "and " | |
13995 | : ""); | |
13996 | vty_out(vty, "\n"); | |
13997 | } | |
13998 | ||
10711563 DA |
13999 | /* Extended nexthop */ |
14000 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
14001 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
14002 | vty_out(vty, " Extended nexthop:"); | |
14003 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
14004 | vty_out(vty, " advertised"); | |
14005 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
14006 | vty_out(vty, " %sreceived", | |
14007 | CHECK_FLAG(p->cap, | |
14008 | PEER_CAP_ENHE_ADV) | |
14009 | ? "and " | |
14010 | : ""); | |
14011 | vty_out(vty, "\n"); | |
d62a17ae | 14012 | |
10711563 | 14013 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
57f7feb6 | 14014 | vty_out(vty, |
10711563 DA |
14015 | " Address families by peer:\n "); |
14016 | for (safi = SAFI_UNICAST; | |
14017 | safi < SAFI_MAX; safi++) | |
14018 | if (CHECK_FLAG( | |
14019 | p->af_cap[AFI_IP] | |
14020 | [safi], | |
14021 | PEER_CAP_ENHE_AF_RCV)) | |
14022 | vty_out(vty, | |
14023 | " %s\n", | |
14024 | get_afi_safi_str( | |
14025 | AFI_IP, | |
14026 | safi, | |
14027 | false)); | |
d62a17ae | 14028 | } |
10711563 | 14029 | } |
d62a17ae | 14030 | |
10711563 DA |
14031 | /* Long-lived Graceful Restart */ |
14032 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
14033 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
14034 | vty_out(vty, | |
14035 | " Long-lived Graceful Restart:"); | |
14036 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
14037 | vty_out(vty, " advertised"); | |
14038 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
14039 | vty_out(vty, " %sreceived", | |
14040 | CHECK_FLAG(p->cap, | |
14041 | PEER_CAP_LLGR_ADV) | |
14042 | ? "and " | |
14043 | : ""); | |
14044 | vty_out(vty, "\n"); | |
8606be87 | 14045 | |
10711563 | 14046 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
57f7feb6 | 14047 | vty_out(vty, |
10711563 DA |
14048 | " Address families by peer:\n"); |
14049 | FOREACH_AFI_SAFI (afi, safi) | |
14050 | if (CHECK_FLAG( | |
14051 | p->af_cap[afi] | |
14052 | [safi], | |
14053 | PEER_CAP_LLGR_AF_RCV)) | |
14054 | vty_out(vty, | |
14055 | " %s\n", | |
14056 | get_afi_safi_str( | |
14057 | afi, | |
14058 | safi, | |
14059 | false)); | |
8606be87 | 14060 | } |
10711563 | 14061 | } |
8606be87 | 14062 | |
10711563 DA |
14063 | /* Route Refresh */ |
14064 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
14065 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
14066 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
14067 | vty_out(vty, " Route refresh:"); | |
14068 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV)) | |
14069 | vty_out(vty, " advertised"); | |
14070 | if (CHECK_FLAG(p->cap, | |
14071 | PEER_CAP_REFRESH_NEW_RCV) || | |
14072 | CHECK_FLAG(p->cap, | |
14073 | PEER_CAP_REFRESH_OLD_RCV)) | |
14074 | vty_out(vty, " %sreceived(%s)", | |
14075 | CHECK_FLAG(p->cap, | |
14076 | PEER_CAP_REFRESH_ADV) | |
14077 | ? "and " | |
14078 | : "", | |
14079 | (CHECK_FLAG( | |
14080 | p->cap, | |
14081 | PEER_CAP_REFRESH_OLD_RCV) && | |
14082 | CHECK_FLAG( | |
14083 | p->cap, | |
14084 | PEER_CAP_REFRESH_NEW_RCV)) | |
14085 | ? "old & new" | |
14086 | : CHECK_FLAG( | |
14087 | p->cap, | |
14088 | PEER_CAP_REFRESH_OLD_RCV) | |
14089 | ? "old" | |
14090 | : "new"); | |
d62a17ae | 14091 | |
d77114b7 | 14092 | vty_out(vty, "\n"); |
10711563 | 14093 | } |
d62a17ae | 14094 | |
10711563 DA |
14095 | /* Enhanced Route Refresh */ |
14096 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
14097 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
14098 | vty_out(vty, " Enhanced Route Refresh:"); | |
14099 | if (CHECK_FLAG(p->cap, | |
14100 | PEER_CAP_ENHANCED_RR_ADV)) | |
14101 | vty_out(vty, " advertised"); | |
14102 | if (CHECK_FLAG(p->cap, | |
14103 | PEER_CAP_ENHANCED_RR_RCV)) | |
14104 | vty_out(vty, " %sreceived", | |
14105 | CHECK_FLAG(p->cap, | |
14106 | PEER_CAP_REFRESH_ADV) | |
14107 | ? "and " | |
14108 | : ""); | |
14109 | vty_out(vty, "\n"); | |
14110 | } | |
14111 | ||
14112 | /* Multiprotocol Extensions */ | |
14113 | FOREACH_AFI_SAFI (afi, safi) | |
14114 | if (p->afc_adv[afi][safi] || | |
14115 | p->afc_recv[afi][safi]) { | |
14116 | vty_out(vty, " Address Family %s:", | |
14117 | get_afi_safi_str(afi, safi, | |
14118 | false)); | |
14119 | if (p->afc_adv[afi][safi]) | |
9af52ccf | 14120 | vty_out(vty, " advertised"); |
10711563 | 14121 | if (p->afc_recv[afi][safi]) |
9af52ccf | 14122 | vty_out(vty, " %sreceived", |
10711563 | 14123 | p->afc_adv[afi][safi] |
9af52ccf DA |
14124 | ? "and " |
14125 | : ""); | |
14126 | vty_out(vty, "\n"); | |
14127 | } | |
14128 | ||
10711563 DA |
14129 | /* Hostname capability */ |
14130 | vty_out(vty, " Hostname Capability:"); | |
d62a17ae | 14131 | |
10711563 DA |
14132 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
14133 | vty_out(vty, | |
14134 | " advertised (name: %s,domain name: %s)", | |
14135 | bgp->peer_self->hostname | |
14136 | ? bgp->peer_self->hostname | |
14137 | : "n/a", | |
14138 | bgp->peer_self->domainname | |
14139 | ? bgp->peer_self->domainname | |
14140 | : "n/a"); | |
14141 | } else { | |
14142 | vty_out(vty, " not advertised"); | |
14143 | } | |
d77114b7 | 14144 | |
10711563 DA |
14145 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
14146 | vty_out(vty, | |
14147 | " received (name: %s,domain name: %s)", | |
14148 | p->hostname ? p->hostname : "n/a", | |
14149 | p->domainname ? p->domainname : "n/a"); | |
14150 | } else { | |
14151 | vty_out(vty, " not received"); | |
d62a17ae | 14152 | } |
d62a17ae | 14153 | |
10711563 | 14154 | vty_out(vty, "\n"); |
d77114b7 | 14155 | |
10711563 DA |
14156 | /* Graceful Restart */ |
14157 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
14158 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
14159 | vty_out(vty, | |
14160 | " Graceful Restart Capability:"); | |
14161 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) | |
14162 | vty_out(vty, " advertised"); | |
14163 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
14164 | vty_out(vty, " %sreceived", | |
14165 | CHECK_FLAG(p->cap, | |
14166 | PEER_CAP_RESTART_ADV) | |
14167 | ? "and " | |
14168 | : ""); | |
d77114b7 MK |
14169 | vty_out(vty, "\n"); |
14170 | ||
10711563 DA |
14171 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
14172 | int restart_af_count = 0; | |
d62a17ae | 14173 | |
10711563 DA |
14174 | vty_out(vty, |
14175 | " Remote Restart timer is %d seconds\n", | |
14176 | p->v_gr_restart); | |
14177 | vty_out(vty, | |
14178 | " Address families by peer:\n "); | |
d62a17ae | 14179 | |
10711563 DA |
14180 | FOREACH_AFI_SAFI (afi, safi) |
14181 | if (CHECK_FLAG( | |
14182 | p->af_cap[afi] | |
14183 | [safi], | |
14184 | PEER_CAP_RESTART_AF_RCV)) { | |
14185 | vty_out(vty, "%s%s(%s)", | |
14186 | restart_af_count | |
14187 | ? ", " | |
14188 | : "", | |
14189 | get_afi_safi_str( | |
14190 | afi, | |
14191 | safi, | |
14192 | false), | |
14193 | CHECK_FLAG( | |
14194 | p->af_cap | |
14195 | [afi] | |
14196 | [safi], | |
14197 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
14198 | ? "preserved" | |
14199 | : "not preserved"); | |
14200 | restart_af_count++; | |
14201 | } | |
14202 | if (!restart_af_count) | |
14203 | vty_out(vty, "none"); | |
14204 | vty_out(vty, "\n"); | |
14205 | } | |
17be83bf | 14206 | } /* Graceful Restart */ |
d62a17ae | 14207 | } |
14208 | } | |
14209 | ||
14210 | /* graceful restart information */ | |
10711563 DA |
14211 | json_object *json_grace = NULL; |
14212 | json_object *json_grace_send = NULL; | |
14213 | json_object *json_grace_recv = NULL; | |
14214 | int eor_send_af_count = 0; | |
14215 | int eor_receive_af_count = 0; | |
d62a17ae | 14216 | |
10711563 DA |
14217 | if (use_json) { |
14218 | json_grace = json_object_new_object(); | |
14219 | json_grace_send = json_object_new_object(); | |
14220 | json_grace_recv = json_object_new_object(); | |
14221 | ||
14222 | if ((peer_established(p)) && | |
14223 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14224 | FOREACH_AFI_SAFI (afi, safi) { | |
14225 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14226 | PEER_STATUS_EOR_SEND)) { | |
14227 | json_object_boolean_true_add( | |
14228 | json_grace_send, | |
14229 | get_afi_safi_str(afi, safi, | |
14230 | true)); | |
14231 | eor_send_af_count++; | |
d62a17ae | 14232 | } |
10711563 DA |
14233 | } |
14234 | FOREACH_AFI_SAFI (afi, safi) { | |
14235 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14236 | PEER_STATUS_EOR_RECEIVED)) { | |
14237 | json_object_boolean_true_add( | |
14238 | json_grace_recv, | |
14239 | get_afi_safi_str(afi, safi, | |
14240 | true)); | |
14241 | eor_receive_af_count++; | |
d62a17ae | 14242 | } |
14243 | } | |
10711563 DA |
14244 | } |
14245 | json_object_object_add(json_grace, "endOfRibSend", | |
14246 | json_grace_send); | |
14247 | json_object_object_add(json_grace, "endOfRibRecv", | |
14248 | json_grace_recv); | |
d62a17ae | 14249 | |
d62a17ae | 14250 | |
10711563 DA |
14251 | if (p->t_gr_restart) |
14252 | json_object_int_add( | |
14253 | json_grace, "gracefulRestartTimerMsecs", | |
14254 | thread_timer_remain_second(p->t_gr_restart) * | |
14255 | 1000); | |
2986cac2 | 14256 | |
10711563 DA |
14257 | if (p->t_gr_stale) |
14258 | json_object_int_add( | |
14259 | json_grace, "gracefulStalepathTimerMsecs", | |
14260 | thread_timer_remain_second(p->t_gr_stale) * | |
14261 | 1000); | |
14262 | /* more gr info in new format */ | |
403e64f8 | 14263 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace); |
10711563 DA |
14264 | json_object_object_add(json_neigh, "gracefulRestartInfo", |
14265 | json_grace); | |
14266 | } else { | |
14267 | vty_out(vty, " Graceful restart information:\n"); | |
14268 | if ((peer_established(p)) && | |
14269 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14270 | ||
14271 | vty_out(vty, " End-of-RIB send: "); | |
14272 | FOREACH_AFI_SAFI (afi, safi) { | |
14273 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14274 | PEER_STATUS_EOR_SEND)) { | |
14275 | vty_out(vty, "%s%s", | |
14276 | eor_send_af_count ? ", " : "", | |
14277 | get_afi_safi_str(afi, safi, | |
14278 | false)); | |
14279 | eor_send_af_count++; | |
d62a17ae | 14280 | } |
10711563 DA |
14281 | } |
14282 | vty_out(vty, "\n"); | |
14283 | vty_out(vty, " End-of-RIB received: "); | |
14284 | FOREACH_AFI_SAFI (afi, safi) { | |
14285 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14286 | PEER_STATUS_EOR_RECEIVED)) { | |
14287 | vty_out(vty, "%s%s", | |
14288 | eor_receive_af_count ? ", " | |
14289 | : "", | |
14290 | get_afi_safi_str(afi, safi, | |
14291 | false)); | |
14292 | eor_receive_af_count++; | |
d62a17ae | 14293 | } |
d62a17ae | 14294 | } |
10711563 DA |
14295 | vty_out(vty, "\n"); |
14296 | } | |
d62a17ae | 14297 | |
10711563 DA |
14298 | if (p->t_gr_restart) |
14299 | vty_out(vty, | |
14300 | " The remaining time of restart timer is %ld\n", | |
14301 | thread_timer_remain_second(p->t_gr_restart)); | |
d62a17ae | 14302 | |
10711563 DA |
14303 | if (p->t_gr_stale) |
14304 | vty_out(vty, | |
14305 | " The remaining time of stalepath timer is %ld\n", | |
14306 | thread_timer_remain_second(p->t_gr_stale)); | |
2986cac2 | 14307 | |
10711563 | 14308 | /* more gr info in new format */ |
403e64f8 | 14309 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL); |
10711563 | 14310 | } |
2986cac2 | 14311 | |
d62a17ae | 14312 | if (use_json) { |
14313 | json_object *json_stat = NULL; | |
14314 | json_stat = json_object_new_object(); | |
14315 | /* Packet counts. */ | |
43aa5965 QY |
14316 | |
14317 | atomic_size_t outq_count, inq_count; | |
14318 | outq_count = atomic_load_explicit(&p->obuf->count, | |
14319 | memory_order_relaxed); | |
14320 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14321 | memory_order_relaxed); | |
14322 | ||
14323 | json_object_int_add(json_stat, "depthInq", | |
14324 | (unsigned long)inq_count); | |
d62a17ae | 14325 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 14326 | (unsigned long)outq_count); |
0112e9e0 QY |
14327 | json_object_int_add(json_stat, "opensSent", |
14328 | atomic_load_explicit(&p->open_out, | |
14329 | memory_order_relaxed)); | |
14330 | json_object_int_add(json_stat, "opensRecv", | |
14331 | atomic_load_explicit(&p->open_in, | |
14332 | memory_order_relaxed)); | |
d62a17ae | 14333 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
14334 | atomic_load_explicit(&p->notify_out, |
14335 | memory_order_relaxed)); | |
d62a17ae | 14336 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
14337 | atomic_load_explicit(&p->notify_in, |
14338 | memory_order_relaxed)); | |
14339 | json_object_int_add(json_stat, "updatesSent", | |
14340 | atomic_load_explicit(&p->update_out, | |
14341 | memory_order_relaxed)); | |
14342 | json_object_int_add(json_stat, "updatesRecv", | |
14343 | atomic_load_explicit(&p->update_in, | |
14344 | memory_order_relaxed)); | |
d62a17ae | 14345 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
14346 | atomic_load_explicit(&p->keepalive_out, |
14347 | memory_order_relaxed)); | |
d62a17ae | 14348 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
14349 | atomic_load_explicit(&p->keepalive_in, |
14350 | memory_order_relaxed)); | |
d62a17ae | 14351 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
14352 | atomic_load_explicit(&p->refresh_out, |
14353 | memory_order_relaxed)); | |
d62a17ae | 14354 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
14355 | atomic_load_explicit(&p->refresh_in, |
14356 | memory_order_relaxed)); | |
d62a17ae | 14357 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
14358 | atomic_load_explicit(&p->dynamic_cap_out, |
14359 | memory_order_relaxed)); | |
d62a17ae | 14360 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
14361 | atomic_load_explicit(&p->dynamic_cap_in, |
14362 | memory_order_relaxed)); | |
14363 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
14364 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 14365 | json_object_object_add(json_neigh, "messageStats", json_stat); |
14366 | } else { | |
cb93e0a2 IS |
14367 | atomic_size_t outq_count, inq_count, open_out, open_in, |
14368 | notify_out, notify_in, update_out, update_in, | |
14369 | keepalive_out, keepalive_in, refresh_out, refresh_in, | |
14370 | dynamic_cap_out, dynamic_cap_in; | |
43aa5965 QY |
14371 | outq_count = atomic_load_explicit(&p->obuf->count, |
14372 | memory_order_relaxed); | |
14373 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14374 | memory_order_relaxed); | |
cb93e0a2 IS |
14375 | open_out = atomic_load_explicit(&p->open_out, |
14376 | memory_order_relaxed); | |
14377 | open_in = | |
14378 | atomic_load_explicit(&p->open_in, memory_order_relaxed); | |
14379 | notify_out = atomic_load_explicit(&p->notify_out, | |
14380 | memory_order_relaxed); | |
14381 | notify_in = atomic_load_explicit(&p->notify_in, | |
14382 | memory_order_relaxed); | |
14383 | update_out = atomic_load_explicit(&p->update_out, | |
14384 | memory_order_relaxed); | |
14385 | update_in = atomic_load_explicit(&p->update_in, | |
14386 | memory_order_relaxed); | |
14387 | keepalive_out = atomic_load_explicit(&p->keepalive_out, | |
14388 | memory_order_relaxed); | |
14389 | keepalive_in = atomic_load_explicit(&p->keepalive_in, | |
14390 | memory_order_relaxed); | |
14391 | refresh_out = atomic_load_explicit(&p->refresh_out, | |
14392 | memory_order_relaxed); | |
14393 | refresh_in = atomic_load_explicit(&p->refresh_in, | |
14394 | memory_order_relaxed); | |
14395 | dynamic_cap_out = atomic_load_explicit(&p->dynamic_cap_out, | |
14396 | memory_order_relaxed); | |
14397 | dynamic_cap_in = atomic_load_explicit(&p->dynamic_cap_in, | |
14398 | memory_order_relaxed); | |
43aa5965 | 14399 | |
d62a17ae | 14400 | /* Packet counts. */ |
14401 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
14402 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
14403 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 14404 | vty_out(vty, " Sent Rcvd\n"); |
cb93e0a2 IS |
14405 | vty_out(vty, " Opens: %10zu %10zu\n", open_out, |
14406 | open_in); | |
14407 | vty_out(vty, " Notifications: %10zu %10zu\n", notify_out, | |
14408 | notify_in); | |
14409 | vty_out(vty, " Updates: %10zu %10zu\n", update_out, | |
14410 | update_in); | |
14411 | vty_out(vty, " Keepalives: %10zu %10zu\n", keepalive_out, | |
14412 | keepalive_in); | |
14413 | vty_out(vty, " Route Refresh: %10zu %10zu\n", refresh_out, | |
14414 | refresh_in); | |
14415 | vty_out(vty, " Capability: %10zu %10zu\n", | |
14416 | dynamic_cap_out, dynamic_cap_in); | |
14417 | vty_out(vty, " Total: %10u %10u\n", | |
14418 | (uint32_t)PEER_TOTAL_TX(p), (uint32_t)PEER_TOTAL_RX(p)); | |
d62a17ae | 14419 | } |
14420 | ||
14421 | if (use_json) { | |
14422 | /* advertisement-interval */ | |
14423 | json_object_int_add(json_neigh, | |
14424 | "minBtwnAdvertisementRunsTimerMsecs", | |
14425 | p->v_routeadv * 1000); | |
14426 | ||
14427 | /* Update-source. */ | |
14428 | if (p->update_if || p->update_source) { | |
14429 | if (p->update_if) | |
14430 | json_object_string_add(json_neigh, | |
14431 | "updateSource", | |
14432 | p->update_if); | |
14433 | else if (p->update_source) | |
47e12884 DA |
14434 | json_object_string_addf(json_neigh, |
14435 | "updateSource", "%pSU", | |
14436 | p->update_source); | |
d62a17ae | 14437 | } |
14438 | } else { | |
14439 | /* advertisement-interval */ | |
14440 | vty_out(vty, | |
14441 | " Minimum time between advertisement runs is %d seconds\n", | |
14442 | p->v_routeadv); | |
14443 | ||
14444 | /* Update-source. */ | |
14445 | if (p->update_if || p->update_source) { | |
14446 | vty_out(vty, " Update source is "); | |
14447 | if (p->update_if) | |
14448 | vty_out(vty, "%s", p->update_if); | |
14449 | else if (p->update_source) | |
47e12884 | 14450 | vty_out(vty, "%pSU", p->update_source); |
d62a17ae | 14451 | vty_out(vty, "\n"); |
14452 | } | |
14453 | ||
14454 | vty_out(vty, "\n"); | |
14455 | } | |
14456 | ||
14457 | /* Address Family Information */ | |
14458 | json_object *json_hold = NULL; | |
14459 | ||
14460 | if (use_json) | |
14461 | json_hold = json_object_new_object(); | |
14462 | ||
05c7a1cc QY |
14463 | FOREACH_AFI_SAFI (afi, safi) |
14464 | if (p->afc[afi][safi]) | |
14465 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
14466 | json_hold); | |
d62a17ae | 14467 | |
14468 | if (use_json) { | |
14469 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
14470 | json_hold); | |
14471 | json_object_int_add(json_neigh, "connectionsEstablished", | |
14472 | p->established); | |
14473 | json_object_int_add(json_neigh, "connectionsDropped", | |
14474 | p->dropped); | |
14475 | } else | |
14476 | vty_out(vty, " Connections established %d; dropped %d\n", | |
14477 | p->established, p->dropped); | |
14478 | ||
14479 | if (!p->last_reset) { | |
14480 | if (use_json) | |
14481 | json_object_string_add(json_neigh, "lastReset", | |
14482 | "never"); | |
14483 | else | |
14484 | vty_out(vty, " Last reset never\n"); | |
14485 | } else { | |
14486 | if (use_json) { | |
14487 | time_t uptime; | |
a2700b50 | 14488 | struct tm tm; |
d62a17ae | 14489 | |
083ec940 | 14490 | uptime = monotime(NULL); |
d62a17ae | 14491 | uptime -= p->resettime; |
a2700b50 MS |
14492 | gmtime_r(&uptime, &tm); |
14493 | ||
d62a17ae | 14494 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
14495 | (tm.tm_sec * 1000) |
14496 | + (tm.tm_min * 60000) | |
14497 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 14498 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 14499 | } else { |
14500 | vty_out(vty, " Last reset %s, ", | |
14501 | peer_uptime(p->resettime, timebuf, | |
14502 | BGP_UPTIME_LEN, 0, NULL)); | |
14503 | ||
3577f1c5 | 14504 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 14505 | if (p->last_reset_cause_size) { |
14506 | msg = p->last_reset_cause; | |
14507 | vty_out(vty, | |
14508 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
14509 | for (i = 1; i <= p->last_reset_cause_size; | |
14510 | i++) { | |
14511 | vty_out(vty, "%02X", *msg++); | |
14512 | ||
14513 | if (i != p->last_reset_cause_size) { | |
14514 | if (i % 16 == 0) { | |
14515 | vty_out(vty, "\n "); | |
14516 | } else if (i % 4 == 0) { | |
14517 | vty_out(vty, " "); | |
14518 | } | |
14519 | } | |
14520 | } | |
14521 | vty_out(vty, "\n"); | |
14522 | } | |
14523 | } | |
14524 | } | |
14525 | ||
14526 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
14527 | if (use_json) | |
14528 | json_object_boolean_true_add(json_neigh, | |
14529 | "prefixesConfigExceedMax"); | |
14530 | else | |
14531 | vty_out(vty, | |
14532 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
14533 | ||
14534 | if (p->t_pmax_restart) { | |
14535 | if (use_json) { | |
14536 | json_object_boolean_true_add( | |
14537 | json_neigh, "reducePrefixNumFrom"); | |
14538 | json_object_int_add(json_neigh, | |
14539 | "restartInTimerMsec", | |
14540 | thread_timer_remain_second( | |
14541 | p->t_pmax_restart) | |
14542 | * 1000); | |
14543 | } else | |
14544 | vty_out(vty, | |
14545 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
14546 | p->host, thread_timer_remain_second( |
14547 | p->t_pmax_restart)); | |
d62a17ae | 14548 | } else { |
14549 | if (use_json) | |
14550 | json_object_boolean_true_add( | |
14551 | json_neigh, | |
14552 | "reducePrefixNumAndClearIpBgp"); | |
14553 | else | |
14554 | vty_out(vty, | |
14555 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
14556 | p->host); | |
14557 | } | |
14558 | } | |
14559 | ||
14560 | /* EBGP Multihop and GTSM */ | |
14561 | if (p->sort != BGP_PEER_IBGP) { | |
14562 | if (use_json) { | |
e2521429 | 14563 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14564 | json_object_int_add(json_neigh, |
14565 | "externalBgpNbrMaxHopsAway", | |
14566 | p->gtsm_hops); | |
be8d1733 | 14567 | else |
d62a17ae | 14568 | json_object_int_add(json_neigh, |
14569 | "externalBgpNbrMaxHopsAway", | |
14570 | p->ttl); | |
14571 | } else { | |
e2521429 | 14572 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14573 | vty_out(vty, |
14574 | " External BGP neighbor may be up to %d hops away.\n", | |
14575 | p->gtsm_hops); | |
be8d1733 | 14576 | else |
d62a17ae | 14577 | vty_out(vty, |
14578 | " External BGP neighbor may be up to %d hops away.\n", | |
14579 | p->ttl); | |
14580 | } | |
14581 | } else { | |
be8d1733 DA |
14582 | if (use_json) { |
14583 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14584 | json_object_int_add(json_neigh, |
14585 | "internalBgpNbrMaxHopsAway", | |
14586 | p->gtsm_hops); | |
14587 | else | |
be8d1733 DA |
14588 | json_object_int_add(json_neigh, |
14589 | "internalBgpNbrMaxHopsAway", | |
14590 | p->ttl); | |
14591 | } else { | |
14592 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14593 | vty_out(vty, |
14594 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14595 | p->gtsm_hops); | |
be8d1733 DA |
14596 | else |
14597 | vty_out(vty, | |
14598 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14599 | p->ttl); | |
d62a17ae | 14600 | } |
14601 | } | |
14602 | ||
14603 | /* Local address. */ | |
14604 | if (p->su_local) { | |
14605 | if (use_json) { | |
47e12884 DA |
14606 | json_object_string_addf(json_neigh, "hostLocal", "%pSU", |
14607 | p->su_local); | |
d62a17ae | 14608 | json_object_int_add(json_neigh, "portLocal", |
14609 | ntohs(p->su_local->sin.sin_port)); | |
14610 | } else | |
47e12884 DA |
14611 | vty_out(vty, "Local host: %pSU, Local port: %d\n", |
14612 | p->su_local, ntohs(p->su_local->sin.sin_port)); | |
1e592331 DS |
14613 | } else { |
14614 | if (use_json) { | |
14615 | json_object_string_add(json_neigh, "hostLocal", | |
14616 | "Unknown"); | |
14617 | json_object_int_add(json_neigh, "portLocal", -1); | |
14618 | } | |
d62a17ae | 14619 | } |
14620 | ||
14621 | /* Remote address. */ | |
14622 | if (p->su_remote) { | |
14623 | if (use_json) { | |
47e12884 DA |
14624 | json_object_string_addf(json_neigh, "hostForeign", |
14625 | "%pSU", p->su_remote); | |
d62a17ae | 14626 | json_object_int_add(json_neigh, "portForeign", |
14627 | ntohs(p->su_remote->sin.sin_port)); | |
14628 | } else | |
47e12884 DA |
14629 | vty_out(vty, "Foreign host: %pSU, Foreign port: %d\n", |
14630 | p->su_remote, | |
d62a17ae | 14631 | ntohs(p->su_remote->sin.sin_port)); |
1e592331 DS |
14632 | } else { |
14633 | if (use_json) { | |
14634 | json_object_string_add(json_neigh, "hostForeign", | |
14635 | "Unknown"); | |
14636 | json_object_int_add(json_neigh, "portForeign", -1); | |
14637 | } | |
d62a17ae | 14638 | } |
14639 | ||
14640 | /* Nexthop display. */ | |
14641 | if (p->su_local) { | |
14642 | if (use_json) { | |
c949c771 DA |
14643 | json_object_string_addf(json_neigh, "nexthop", "%pI4", |
14644 | &p->nexthop.v4); | |
14645 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
14646 | "%pI6", &p->nexthop.v6_global); | |
14647 | json_object_string_addf(json_neigh, "nexthopLocal", | |
14648 | "%pI6", &p->nexthop.v6_local); | |
d62a17ae | 14649 | if (p->shared_network) |
14650 | json_object_string_add(json_neigh, | |
14651 | "bgpConnection", | |
14652 | "sharedNetwork"); | |
14653 | else | |
14654 | json_object_string_add(json_neigh, | |
14655 | "bgpConnection", | |
14656 | "nonSharedNetwork"); | |
14657 | } else { | |
07380148 DA |
14658 | vty_out(vty, "Nexthop: %pI4\n", &p->nexthop.v4); |
14659 | vty_out(vty, "Nexthop global: %pI6\n", | |
14660 | &p->nexthop.v6_global); | |
14661 | vty_out(vty, "Nexthop local: %pI6\n", | |
14662 | &p->nexthop.v6_local); | |
d62a17ae | 14663 | vty_out(vty, "BGP connection: %s\n", |
14664 | p->shared_network ? "shared network" | |
14665 | : "non shared network"); | |
14666 | } | |
432e7e46 KQ |
14667 | } else { |
14668 | if (use_json) { | |
14669 | json_object_string_add(json_neigh, "nexthop", | |
14670 | "Unknown"); | |
14671 | json_object_string_add(json_neigh, "nexthopGlobal", | |
14672 | "Unknown"); | |
14673 | json_object_string_add(json_neigh, "nexthopLocal", | |
14674 | "Unknown"); | |
14675 | json_object_string_add(json_neigh, "bgpConnection", | |
14676 | "Unknown"); | |
14677 | } | |
d62a17ae | 14678 | } |
14679 | ||
14680 | /* Timer information. */ | |
14681 | if (use_json) { | |
14682 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14683 | p->v_connect); | |
f41255a0 | 14684 | if (peer_established(p)) { |
d62a17ae | 14685 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
14686 | p->rtt); | |
f41255a0 DA |
14687 | if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) { |
14688 | json_object_int_add(json_neigh, | |
14689 | "shutdownRttInMsecs", | |
14690 | p->rtt_expected); | |
14691 | json_object_int_add(json_neigh, | |
14692 | "shutdownRttAfterCount", | |
14693 | p->rtt_keepalive_rcv); | |
14694 | } | |
14695 | } | |
d62a17ae | 14696 | if (p->t_start) |
14697 | json_object_int_add( | |
14698 | json_neigh, "nextStartTimerDueInMsecs", | |
14699 | thread_timer_remain_second(p->t_start) * 1000); | |
14700 | if (p->t_connect) | |
14701 | json_object_int_add( | |
14702 | json_neigh, "nextConnectTimerDueInMsecs", | |
14703 | thread_timer_remain_second(p->t_connect) | |
14704 | * 1000); | |
14705 | if (p->t_routeadv) { | |
14706 | json_object_int_add(json_neigh, "mraiInterval", | |
14707 | p->v_routeadv); | |
14708 | json_object_int_add( | |
14709 | json_neigh, "mraiTimerExpireInMsecs", | |
14710 | thread_timer_remain_second(p->t_routeadv) | |
14711 | * 1000); | |
14712 | } | |
14713 | if (p->password) | |
14714 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14715 | 1); | |
14716 | ||
14717 | if (p->t_read) | |
14718 | json_object_string_add(json_neigh, "readThread", "on"); | |
14719 | else | |
14720 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14721 | |
14722 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14723 | json_object_string_add(json_neigh, "writeThread", "on"); |
14724 | else | |
14725 | json_object_string_add(json_neigh, "writeThread", | |
14726 | "off"); | |
14727 | } else { | |
14728 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14729 | p->v_connect); | |
f41255a0 | 14730 | if (peer_established(p)) { |
d62a17ae | 14731 | vty_out(vty, "Estimated round trip time: %d ms\n", |
14732 | p->rtt); | |
f41255a0 DA |
14733 | if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) |
14734 | vty_out(vty, | |
14735 | "Shutdown when RTT > %dms, count > %u\n", | |
14736 | p->rtt_expected, p->rtt_keepalive_rcv); | |
14737 | } | |
d62a17ae | 14738 | if (p->t_start) |
14739 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14740 | thread_timer_remain_second(p->t_start)); | |
14741 | if (p->t_connect) | |
14742 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14743 | thread_timer_remain_second(p->t_connect)); | |
14744 | if (p->t_routeadv) | |
14745 | vty_out(vty, | |
14746 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14747 | p->v_routeadv, | |
14748 | thread_timer_remain_second(p->t_routeadv)); | |
14749 | if (p->password) | |
14750 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14751 | ||
cac9e917 | 14752 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14753 | p->t_read ? "on" : "off", |
14754 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14755 | ? "on" | |
cac9e917 | 14756 | : "off", p->fd); |
d62a17ae | 14757 | } |
14758 | ||
14759 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14760 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14761 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14762 | ||
14763 | if (!use_json) | |
14764 | vty_out(vty, "\n"); | |
14765 | ||
14766 | /* BFD information. */ | |
21bfce98 RZ |
14767 | if (p->bfd_config) |
14768 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 14769 | |
14770 | if (use_json) { | |
14771 | if (p->conf_if) /* Configured interface name. */ | |
14772 | json_object_object_add(json, p->conf_if, json_neigh); | |
14773 | else /* Configured IP address. */ | |
14774 | json_object_object_add(json, p->host, json_neigh); | |
14775 | } | |
14776 | } | |
14777 | ||
36235319 QY |
14778 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14779 | enum show_type type, | |
14780 | union sockunion *su, | |
14781 | const char *conf_if, afi_t afi, | |
403e64f8 | 14782 | json_object *json) |
2986cac2 | 14783 | { |
14784 | struct listnode *node, *nnode; | |
14785 | struct peer *peer; | |
5a59e9b2 | 14786 | bool found = false; |
2986cac2 | 14787 | safi_t safi = SAFI_UNICAST; |
14788 | json_object *json_neighbor = NULL; | |
14789 | ||
14790 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14791 | ||
14792 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14793 | continue; | |
14794 | ||
14795 | if ((peer->afc[afi][safi]) == 0) | |
14796 | continue; | |
14797 | ||
403e64f8 DA |
14798 | if (json) |
14799 | json_neighbor = json_object_new_object(); | |
14800 | ||
2ba1fe69 | 14801 | if (type == show_all) { |
403e64f8 | 14802 | bgp_show_peer_gr_status(vty, peer, json_neighbor); |
2986cac2 | 14803 | |
403e64f8 | 14804 | if (json) |
13909c4f DS |
14805 | json_object_object_add(json, peer->host, |
14806 | json_neighbor); | |
2986cac2 | 14807 | |
2ba1fe69 | 14808 | } else if (type == show_peer) { |
2986cac2 | 14809 | if (conf_if) { |
14810 | if ((peer->conf_if | |
13909c4f DS |
14811 | && !strcmp(peer->conf_if, conf_if)) |
14812 | || (peer->hostname | |
2986cac2 | 14813 | && !strcmp(peer->hostname, conf_if))) { |
5a59e9b2 | 14814 | found = true; |
13909c4f | 14815 | bgp_show_peer_gr_status(vty, peer, |
13909c4f | 14816 | json_neighbor); |
2986cac2 | 14817 | } |
14818 | } else { | |
14819 | if (sockunion_same(&peer->su, su)) { | |
5a59e9b2 | 14820 | found = true; |
13909c4f | 14821 | bgp_show_peer_gr_status(vty, peer, |
13909c4f | 14822 | json_neighbor); |
2986cac2 | 14823 | } |
14824 | } | |
5a59e9b2 DS |
14825 | if (json) { |
14826 | if (found) | |
14827 | json_object_object_add(json, peer->host, | |
14828 | json_neighbor); | |
14829 | else | |
14830 | json_object_free(json_neighbor); | |
14831 | } | |
2986cac2 | 14832 | } |
14833 | ||
5a59e9b2 | 14834 | if (found) |
2986cac2 | 14835 | break; |
14836 | } | |
14837 | ||
5a59e9b2 | 14838 | if (type == show_peer && !found) { |
403e64f8 | 14839 | if (json) |
13909c4f | 14840 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14841 | else |
14842 | vty_out(vty, "%% No such neighbor\n"); | |
14843 | } | |
403e64f8 DA |
14844 | |
14845 | if (!json) | |
2986cac2 | 14846 | vty_out(vty, "\n"); |
2986cac2 | 14847 | |
14848 | return CMD_SUCCESS; | |
14849 | } | |
14850 | ||
d62a17ae | 14851 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14852 | enum show_type type, union sockunion *su, | |
9f049418 | 14853 | const char *conf_if, bool use_json, |
d62a17ae | 14854 | json_object *json) |
14855 | { | |
14856 | struct listnode *node, *nnode; | |
14857 | struct peer *peer; | |
14858 | int find = 0; | |
9f049418 | 14859 | bool nbr_output = false; |
d1927ebe AS |
14860 | afi_t afi = AFI_MAX; |
14861 | safi_t safi = SAFI_MAX; | |
14862 | ||
14863 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14864 | afi = AFI_IP; | |
14865 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14866 | afi = AFI_IP6; | |
14867 | } | |
d62a17ae | 14868 | |
14869 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14870 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14871 | continue; | |
14872 | ||
14873 | switch (type) { | |
14874 | case show_all: | |
14875 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14876 | nbr_output = true; |
d62a17ae | 14877 | break; |
14878 | case show_peer: | |
14879 | if (conf_if) { | |
14880 | if ((peer->conf_if | |
14881 | && !strcmp(peer->conf_if, conf_if)) | |
14882 | || (peer->hostname | |
14883 | && !strcmp(peer->hostname, conf_if))) { | |
14884 | find = 1; | |
14885 | bgp_show_peer(vty, peer, use_json, | |
14886 | json); | |
14887 | } | |
14888 | } else { | |
14889 | if (sockunion_same(&peer->su, su)) { | |
14890 | find = 1; | |
14891 | bgp_show_peer(vty, peer, use_json, | |
14892 | json); | |
14893 | } | |
14894 | } | |
14895 | break; | |
d1927ebe AS |
14896 | case show_ipv4_peer: |
14897 | case show_ipv6_peer: | |
14898 | FOREACH_SAFI (safi) { | |
14899 | if (peer->afc[afi][safi]) { | |
14900 | if (conf_if) { | |
14901 | if ((peer->conf_if | |
14902 | && !strcmp(peer->conf_if, conf_if)) | |
14903 | || (peer->hostname | |
14904 | && !strcmp(peer->hostname, conf_if))) { | |
14905 | find = 1; | |
14906 | bgp_show_peer(vty, peer, use_json, | |
14907 | json); | |
14908 | break; | |
14909 | } | |
14910 | } else { | |
14911 | if (sockunion_same(&peer->su, su)) { | |
14912 | find = 1; | |
14913 | bgp_show_peer(vty, peer, use_json, | |
14914 | json); | |
14915 | break; | |
14916 | } | |
14917 | } | |
14918 | } | |
14919 | } | |
14920 | break; | |
14921 | case show_ipv4_all: | |
14922 | case show_ipv6_all: | |
14923 | FOREACH_SAFI (safi) { | |
14924 | if (peer->afc[afi][safi]) { | |
14925 | bgp_show_peer(vty, peer, use_json, json); | |
14926 | nbr_output = true; | |
14927 | break; | |
14928 | } | |
14929 | } | |
14930 | break; | |
d62a17ae | 14931 | } |
14932 | } | |
14933 | ||
d1927ebe AS |
14934 | if ((type == show_peer || type == show_ipv4_peer || |
14935 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14936 | if (use_json) |
14937 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14938 | else | |
88b7d255 | 14939 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14940 | } |
14941 | ||
d1927ebe AS |
14942 | if (type != show_peer && type != show_ipv4_peer && |
14943 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14944 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14945 | |
d62a17ae | 14946 | if (use_json) { |
996c9314 LB |
14947 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14948 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14949 | } else { |
14950 | vty_out(vty, "\n"); | |
14951 | } | |
14952 | ||
14953 | return CMD_SUCCESS; | |
14954 | } | |
14955 | ||
36235319 QY |
14956 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14957 | enum show_type type, | |
14958 | const char *ip_str, | |
403e64f8 | 14959 | afi_t afi, json_object *json) |
2986cac2 | 14960 | { |
14961 | ||
14962 | int ret; | |
14963 | struct bgp *bgp; | |
14964 | union sockunion su; | |
2986cac2 | 14965 | |
14966 | bgp = bgp_get_default(); | |
14967 | ||
13909c4f DS |
14968 | if (!bgp) |
14969 | return; | |
2986cac2 | 14970 | |
403e64f8 DA |
14971 | if (!json) |
14972 | bgp_show_global_graceful_restart_mode_vty(vty, bgp); | |
2986cac2 | 14973 | |
13909c4f DS |
14974 | if (ip_str) { |
14975 | ret = str2sockunion(ip_str, &su); | |
14976 | if (ret < 0) | |
403e64f8 DA |
14977 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, |
14978 | ip_str, afi, json); | |
74a630b6 NT |
14979 | else |
14980 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
403e64f8 | 14981 | NULL, afi, json); |
13909c4f DS |
14982 | } else |
14983 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
403e64f8 | 14984 | afi, json); |
2986cac2 | 14985 | } |
14986 | ||
d62a17ae | 14987 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14988 | enum show_type type, |
14989 | const char *ip_str, | |
9f049418 | 14990 | bool use_json) |
d62a17ae | 14991 | { |
0291c246 MK |
14992 | struct listnode *node, *nnode; |
14993 | struct bgp *bgp; | |
71aedaa3 | 14994 | union sockunion su; |
0291c246 | 14995 | json_object *json = NULL; |
71aedaa3 | 14996 | int ret, is_first = 1; |
9f049418 | 14997 | bool nbr_output = false; |
d62a17ae | 14998 | |
14999 | if (use_json) | |
15000 | vty_out(vty, "{\n"); | |
15001 | ||
15002 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 15003 | nbr_output = true; |
d62a17ae | 15004 | if (use_json) { |
15005 | if (!(json = json_object_new_object())) { | |
af4c2728 | 15006 | flog_err( |
e50f7cfd | 15007 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 15008 | "Unable to allocate memory for JSON object"); |
15009 | vty_out(vty, | |
15010 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
15011 | return; | |
15012 | } | |
15013 | ||
15014 | json_object_int_add(json, "vrfId", | |
15015 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
15016 | ? -1 |
15017 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 15018 | json_object_string_add( |
15019 | json, "vrfName", | |
15020 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15021 | ? VRF_DEFAULT_NAME |
d62a17ae | 15022 | : bgp->name); |
15023 | ||
15024 | if (!is_first) | |
15025 | vty_out(vty, ",\n"); | |
15026 | else | |
15027 | is_first = 0; | |
15028 | ||
15029 | vty_out(vty, "\"%s\":", | |
15030 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15031 | ? VRF_DEFAULT_NAME |
d62a17ae | 15032 | : bgp->name); |
15033 | } else { | |
15034 | vty_out(vty, "\nInstance %s:\n", | |
15035 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15036 | ? VRF_DEFAULT_NAME |
d62a17ae | 15037 | : bgp->name); |
15038 | } | |
71aedaa3 | 15039 | |
d1927ebe AS |
15040 | if (type == show_peer || type == show_ipv4_peer || |
15041 | type == show_ipv6_peer) { | |
71aedaa3 DS |
15042 | ret = str2sockunion(ip_str, &su); |
15043 | if (ret < 0) | |
15044 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
15045 | use_json, json); | |
15046 | else | |
15047 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
15048 | use_json, json); | |
15049 | } else { | |
d1927ebe | 15050 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
15051 | use_json, json); |
15052 | } | |
b77004d6 | 15053 | json_object_free(json); |
121067e9 | 15054 | json = NULL; |
d62a17ae | 15055 | } |
15056 | ||
3e78a6ce | 15057 | if (use_json) |
d62a17ae | 15058 | vty_out(vty, "}\n"); |
9f049418 DS |
15059 | else if (!nbr_output) |
15060 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 15061 | } |
15062 | ||
15063 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
15064 | enum show_type type, const char *ip_str, | |
9f049418 | 15065 | bool use_json) |
d62a17ae | 15066 | { |
15067 | int ret; | |
15068 | struct bgp *bgp; | |
15069 | union sockunion su; | |
15070 | json_object *json = NULL; | |
15071 | ||
15072 | if (name) { | |
15073 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
15074 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
15075 | use_json); | |
d62a17ae | 15076 | return CMD_SUCCESS; |
15077 | } else { | |
15078 | bgp = bgp_lookup_by_name(name); | |
15079 | if (!bgp) { | |
15080 | if (use_json) { | |
15081 | json = json_object_new_object(); | |
75eeda93 | 15082 | vty_json(vty, json); |
d62a17ae | 15083 | } else |
15084 | vty_out(vty, | |
9f049418 | 15085 | "%% BGP instance not found\n"); |
d62a17ae | 15086 | |
15087 | return CMD_WARNING; | |
15088 | } | |
15089 | } | |
15090 | } else { | |
15091 | bgp = bgp_get_default(); | |
15092 | } | |
15093 | ||
15094 | if (bgp) { | |
15095 | json = json_object_new_object(); | |
15096 | if (ip_str) { | |
15097 | ret = str2sockunion(ip_str, &su); | |
15098 | if (ret < 0) | |
15099 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
15100 | use_json, json); | |
15101 | else | |
15102 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
15103 | use_json, json); | |
15104 | } else { | |
15105 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
15106 | json); | |
15107 | } | |
15108 | json_object_free(json); | |
ca61fd25 DS |
15109 | } else { |
15110 | if (use_json) | |
15111 | vty_out(vty, "{}\n"); | |
15112 | else | |
15113 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 15114 | } |
15115 | ||
15116 | return CMD_SUCCESS; | |
4fb25c53 DW |
15117 | } |
15118 | ||
2986cac2 | 15119 | |
15120 | ||
15121 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
dcab9012 | 15122 | DEFUN (show_ip_bgp_neighbors_graceful_restart, |
2986cac2 | 15123 | show_ip_bgp_neighbors_graceful_restart_cmd, |
15124 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
15125 | SHOW_STR | |
15126 | BGP_STR | |
15127 | IP_STR | |
15128 | IPV6_STR | |
15129 | NEIGHBOR_STR | |
15130 | "Neighbor to display information about\n" | |
15131 | "Neighbor to display information about\n" | |
15132 | "Neighbor on BGP configured interface\n" | |
15133 | GR_SHOW | |
15134 | JSON_STR) | |
15135 | { | |
15136 | char *sh_arg = NULL; | |
15137 | enum show_type sh_type; | |
15138 | int idx = 0; | |
15139 | afi_t afi = AFI_MAX; | |
2986cac2 | 15140 | bool uj = use_json(argc, argv); |
15141 | ||
36235319 | 15142 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 15143 | afi = AFI_MAX; |
15144 | ||
15145 | idx++; | |
15146 | ||
15147 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
15148 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15149 | || argv_find(argv, argc, "WORD", &idx)) { | |
15150 | sh_type = show_peer; | |
15151 | sh_arg = argv[idx]->arg; | |
15152 | } else | |
15153 | sh_type = show_all; | |
15154 | ||
15155 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
15156 | return CMD_SUCCESS; | |
15157 | ||
15158 | ||
36235319 QY |
15159 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
15160 | afi, uj); | |
2986cac2 | 15161 | } |
15162 | ||
716b2d8a | 15163 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 15164 | DEFUN (show_ip_bgp_neighbors, |
15165 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 15166 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 15167 | SHOW_STR |
15168 | IP_STR | |
15169 | BGP_STR | |
f2a8972b | 15170 | BGP_INSTANCE_HELP_STR |
00e6edb9 DA |
15171 | BGP_AF_STR |
15172 | BGP_AF_STR | |
718e3744 | 15173 | "Detailed information on TCP and BGP neighbor connections\n" |
15174 | "Neighbor to display information about\n" | |
a80beece | 15175 | "Neighbor to display information about\n" |
91d37724 | 15176 | "Neighbor on BGP configured interface\n" |
9973d184 | 15177 | JSON_STR) |
718e3744 | 15178 | { |
d62a17ae | 15179 | char *vrf = NULL; |
15180 | char *sh_arg = NULL; | |
15181 | enum show_type sh_type; | |
d1927ebe | 15182 | afi_t afi = AFI_MAX; |
718e3744 | 15183 | |
9f049418 | 15184 | bool uj = use_json(argc, argv); |
718e3744 | 15185 | |
d62a17ae | 15186 | int idx = 0; |
718e3744 | 15187 | |
9a8bdf1c PG |
15188 | /* [<vrf> VIEWVRFNAME] */ |
15189 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15190 | vrf = argv[idx + 1]->arg; | |
15191 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15192 | vrf = NULL; | |
15193 | } else if (argv_find(argv, argc, "view", &idx)) | |
15194 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 15195 | vrf = argv[idx + 1]->arg; |
718e3744 | 15196 | |
d62a17ae | 15197 | idx++; |
d1927ebe AS |
15198 | |
15199 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
15200 | sh_type = show_ipv4_all; | |
15201 | afi = AFI_IP; | |
15202 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
15203 | sh_type = show_ipv6_all; | |
15204 | afi = AFI_IP6; | |
15205 | } else { | |
15206 | sh_type = show_all; | |
15207 | } | |
15208 | ||
d62a17ae | 15209 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
15210 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15211 | || argv_find(argv, argc, "WORD", &idx)) { | |
15212 | sh_type = show_peer; | |
15213 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
15214 | } |
15215 | ||
15216 | if (sh_type == show_peer && afi == AFI_IP) { | |
15217 | sh_type = show_ipv4_peer; | |
15218 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
15219 | sh_type = show_ipv6_peer; | |
15220 | } | |
856ca177 | 15221 | |
d62a17ae | 15222 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 15223 | } |
15224 | ||
716b2d8a | 15225 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 15226 | paths' and `show ip mbgp paths'. Those functions results are the |
15227 | same.*/ | |
f412b39a | 15228 | DEFUN (show_ip_bgp_paths, |
718e3744 | 15229 | show_ip_bgp_paths_cmd, |
46f296b4 | 15230 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 15231 | SHOW_STR |
15232 | IP_STR | |
15233 | BGP_STR | |
46f296b4 | 15234 | BGP_SAFI_HELP_STR |
718e3744 | 15235 | "Path information\n") |
15236 | { | |
d62a17ae | 15237 | vty_out(vty, "Address Refcnt Path\n"); |
15238 | aspath_print_all_vty(vty); | |
15239 | return CMD_SUCCESS; | |
718e3744 | 15240 | } |
15241 | ||
718e3744 | 15242 | #include "hash.h" |
15243 | ||
e3b78da8 | 15244 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15245 | struct vty *vty) |
718e3744 | 15246 | { |
d62a17ae | 15247 | struct community *com; |
718e3744 | 15248 | |
e3b78da8 | 15249 | com = (struct community *)bucket->data; |
3f65c5b1 | 15250 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
c0945b78 | 15251 | community_str(com, false, false)); |
718e3744 | 15252 | } |
15253 | ||
15254 | /* Show BGP's community internal data. */ | |
f412b39a | 15255 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 15256 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 15257 | "show [ip] bgp community-info", |
718e3744 | 15258 | SHOW_STR |
15259 | IP_STR | |
15260 | BGP_STR | |
15261 | "List all bgp community information\n") | |
15262 | { | |
d62a17ae | 15263 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 15264 | |
d62a17ae | 15265 | hash_iterate(community_hash(), |
e3b78da8 | 15266 | (void (*)(struct hash_bucket *, |
d62a17ae | 15267 | void *))community_show_all_iterator, |
15268 | vty); | |
718e3744 | 15269 | |
d62a17ae | 15270 | return CMD_SUCCESS; |
718e3744 | 15271 | } |
15272 | ||
e3b78da8 | 15273 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15274 | struct vty *vty) |
57d187bc | 15275 | { |
d62a17ae | 15276 | struct lcommunity *lcom; |
57d187bc | 15277 | |
e3b78da8 | 15278 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 15279 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
c0945b78 | 15280 | lcommunity_str(lcom, false, false)); |
57d187bc JS |
15281 | } |
15282 | ||
15283 | /* Show BGP's community internal data. */ | |
15284 | DEFUN (show_ip_bgp_lcommunity_info, | |
15285 | show_ip_bgp_lcommunity_info_cmd, | |
15286 | "show ip bgp large-community-info", | |
15287 | SHOW_STR | |
15288 | IP_STR | |
15289 | BGP_STR | |
15290 | "List all bgp large-community information\n") | |
15291 | { | |
d62a17ae | 15292 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 15293 | |
d62a17ae | 15294 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 15295 | (void (*)(struct hash_bucket *, |
d62a17ae | 15296 | void *))lcommunity_show_all_iterator, |
15297 | vty); | |
57d187bc | 15298 | |
d62a17ae | 15299 | return CMD_SUCCESS; |
57d187bc | 15300 | } |
2986cac2 | 15301 | /* Graceful Restart */ |
15302 | ||
15303 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
403e64f8 | 15304 | struct bgp *bgp) |
2986cac2 | 15305 | { |
57d187bc JS |
15306 | |
15307 | ||
2986cac2 | 15308 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
15309 | ||
7318ae88 | 15310 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 15311 | |
15312 | switch (bgp_global_gr_mode) { | |
15313 | ||
15314 | case GLOBAL_HELPER: | |
13909c4f | 15315 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 15316 | break; |
15317 | ||
15318 | case GLOBAL_GR: | |
13909c4f | 15319 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 15320 | break; |
15321 | ||
15322 | case GLOBAL_DISABLE: | |
13909c4f | 15323 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 15324 | break; |
15325 | ||
15326 | case GLOBAL_INVALID: | |
2986cac2 | 15327 | vty_out(vty, |
2ba1fe69 | 15328 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 15329 | break; |
15330 | } | |
15331 | vty_out(vty, "\n"); | |
15332 | } | |
15333 | ||
36235319 QY |
15334 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
15335 | enum show_type type, | |
15336 | const char *ip_str, | |
15337 | afi_t afi, bool use_json) | |
2986cac2 | 15338 | { |
403e64f8 DA |
15339 | json_object *json = NULL; |
15340 | ||
15341 | if (use_json) | |
15342 | json = json_object_new_object(); | |
15343 | ||
2986cac2 | 15344 | if ((afi == AFI_MAX) && (ip_str == NULL)) { |
15345 | afi = AFI_IP; | |
15346 | ||
15347 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
15348 | ||
36235319 | 15349 | bgp_show_neighbor_graceful_restart_vty( |
403e64f8 | 15350 | vty, type, ip_str, afi, json); |
2986cac2 | 15351 | afi++; |
15352 | } | |
15353 | } else if (afi != AFI_MAX) { | |
36235319 | 15354 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
403e64f8 | 15355 | json); |
2986cac2 | 15356 | } else { |
403e64f8 DA |
15357 | if (json) |
15358 | json_object_free(json); | |
2986cac2 | 15359 | return CMD_ERR_INCOMPLETE; |
15360 | } | |
15361 | ||
403e64f8 DA |
15362 | if (json) |
15363 | vty_json(vty, json); | |
15364 | ||
2986cac2 | 15365 | return CMD_SUCCESS; |
15366 | } | |
15367 | /* Graceful Restart */ | |
15368 | ||
f412b39a | 15369 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 15370 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 15371 | "show [ip] bgp attribute-info", |
718e3744 | 15372 | SHOW_STR |
15373 | IP_STR | |
15374 | BGP_STR | |
15375 | "List all bgp attribute information\n") | |
15376 | { | |
d62a17ae | 15377 | attr_show_all(vty); |
15378 | return CMD_SUCCESS; | |
718e3744 | 15379 | } |
6b0655a2 | 15380 | |
03915806 CS |
15381 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
15382 | afi_t afi, safi_t safi, | |
15383 | bool use_json, json_object *json) | |
53089bec | 15384 | { |
15385 | struct bgp *bgp; | |
15386 | struct listnode *node; | |
15387 | char *vname; | |
53089bec | 15388 | char *ecom_str; |
9c2fd3fe | 15389 | enum vpn_policy_direction dir; |
53089bec | 15390 | |
03915806 | 15391 | if (json) { |
b46dfd20 DS |
15392 | json_object *json_import_vrfs = NULL; |
15393 | json_object *json_export_vrfs = NULL; | |
15394 | ||
b46dfd20 DS |
15395 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15396 | ||
53089bec | 15397 | if (!bgp) { |
75eeda93 | 15398 | vty_json(vty, json); |
b46dfd20 | 15399 | |
53089bec | 15400 | return CMD_WARNING; |
15401 | } | |
b46dfd20 | 15402 | |
94d4c685 DS |
15403 | /* Provide context for the block */ |
15404 | json_object_string_add(json, "vrf", name ? name : "default"); | |
15405 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 15406 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 15407 | |
b46dfd20 DS |
15408 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15409 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15410 | json_object_string_add(json, "importFromVrfs", "none"); | |
15411 | json_object_string_add(json, "importRts", "none"); | |
15412 | } else { | |
6ce24e52 DS |
15413 | json_import_vrfs = json_object_new_array(); |
15414 | ||
b46dfd20 DS |
15415 | for (ALL_LIST_ELEMENTS_RO( |
15416 | bgp->vpn_policy[afi].import_vrf, | |
15417 | node, vname)) | |
15418 | json_object_array_add(json_import_vrfs, | |
15419 | json_object_new_string(vname)); | |
15420 | ||
b20875ea CS |
15421 | json_object_object_add(json, "importFromVrfs", |
15422 | json_import_vrfs); | |
b46dfd20 | 15423 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
15424 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15425 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15426 | bgp->vpn_policy[afi].rtlist[dir], |
15427 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15428 | json_object_string_add(json, "importRts", |
15429 | ecom_str); | |
15430 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15431 | } else | |
15432 | json_object_string_add(json, "importRts", | |
15433 | "none"); | |
b46dfd20 DS |
15434 | } |
15435 | ||
15436 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
15437 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
15438 | json_object_string_add(json, "exportToVrfs", "none"); | |
15439 | json_object_string_add(json, "routeDistinguisher", | |
15440 | "none"); | |
15441 | json_object_string_add(json, "exportRts", "none"); | |
15442 | } else { | |
6ce24e52 DS |
15443 | json_export_vrfs = json_object_new_array(); |
15444 | ||
b46dfd20 DS |
15445 | for (ALL_LIST_ELEMENTS_RO( |
15446 | bgp->vpn_policy[afi].export_vrf, | |
15447 | node, vname)) | |
15448 | json_object_array_add(json_export_vrfs, | |
15449 | json_object_new_string(vname)); | |
15450 | json_object_object_add(json, "exportToVrfs", | |
15451 | json_export_vrfs); | |
c4f64ea9 DA |
15452 | json_object_string_addf(json, "routeDistinguisher", |
15453 | "%pRD", | |
15454 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15455 | |
15456 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15457 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15458 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15459 | bgp->vpn_policy[afi].rtlist[dir], |
15460 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15461 | json_object_string_add(json, "exportRts", |
15462 | ecom_str); | |
15463 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15464 | } else | |
15465 | json_object_string_add(json, "exportRts", | |
15466 | "none"); | |
b46dfd20 DS |
15467 | } |
15468 | ||
03915806 | 15469 | if (use_json) { |
75eeda93 | 15470 | vty_json(vty, json); |
03915806 | 15471 | } |
53089bec | 15472 | } else { |
b46dfd20 DS |
15473 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15474 | ||
53089bec | 15475 | if (!bgp) { |
b46dfd20 | 15476 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 15477 | return CMD_WARNING; |
15478 | } | |
53089bec | 15479 | |
b46dfd20 DS |
15480 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15481 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
15482 | vty_out(vty, | |
15483 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 15484 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15485 | else { |
15486 | vty_out(vty, | |
15487 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 15488 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15489 | |
15490 | for (ALL_LIST_ELEMENTS_RO( | |
15491 | bgp->vpn_policy[afi].import_vrf, | |
15492 | node, vname)) | |
15493 | vty_out(vty, " %s\n", vname); | |
15494 | ||
15495 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
15496 | ecom_str = NULL; |
15497 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
15498 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15499 | bgp->vpn_policy[afi].rtlist[dir], |
15500 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 15501 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 15502 | |
b20875ea CS |
15503 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
15504 | } else | |
15505 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15506 | } |
53089bec | 15507 | |
b46dfd20 DS |
15508 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15509 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15510 | vty_out(vty, | |
15511 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 15512 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15513 | else { |
15514 | vty_out(vty, | |
04c9077f | 15515 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 15516 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15517 | |
15518 | for (ALL_LIST_ELEMENTS_RO( | |
15519 | bgp->vpn_policy[afi].export_vrf, | |
15520 | node, vname)) | |
15521 | vty_out(vty, " %s\n", vname); | |
15522 | ||
c4f64ea9 DA |
15523 | vty_out(vty, "RD: %pRD\n", |
15524 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15525 | |
15526 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15527 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15528 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15529 | bgp->vpn_policy[afi].rtlist[dir], |
15530 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15531 | vty_out(vty, "Export RT: %s\n", ecom_str); |
15532 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15533 | } else | |
15534 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15535 | } |
53089bec | 15536 | } |
15537 | ||
15538 | return CMD_SUCCESS; | |
15539 | } | |
15540 | ||
03915806 CS |
15541 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
15542 | safi_t safi, bool use_json) | |
15543 | { | |
15544 | struct listnode *node, *nnode; | |
15545 | struct bgp *bgp; | |
15546 | char *vrf_name = NULL; | |
15547 | json_object *json = NULL; | |
15548 | json_object *json_vrf = NULL; | |
15549 | json_object *json_vrfs = NULL; | |
15550 | ||
15551 | if (use_json) { | |
15552 | json = json_object_new_object(); | |
15553 | json_vrfs = json_object_new_object(); | |
15554 | } | |
15555 | ||
15556 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
15557 | ||
15558 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
15559 | vrf_name = bgp->name; | |
15560 | ||
15561 | if (use_json) { | |
15562 | json_vrf = json_object_new_object(); | |
15563 | } else { | |
15564 | vty_out(vty, "\nInstance %s:\n", | |
15565 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15566 | ? VRF_DEFAULT_NAME : bgp->name); | |
15567 | } | |
15568 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
15569 | if (use_json) { | |
15570 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15571 | json_object_object_add(json_vrfs, | |
15572 | VRF_DEFAULT_NAME, json_vrf); | |
15573 | else | |
15574 | json_object_object_add(json_vrfs, vrf_name, | |
15575 | json_vrf); | |
15576 | } | |
15577 | } | |
15578 | ||
15579 | if (use_json) { | |
15580 | json_object_object_add(json, "vrfs", json_vrfs); | |
75eeda93 | 15581 | vty_json(vty, json); |
03915806 CS |
15582 | } |
15583 | ||
15584 | return CMD_SUCCESS; | |
15585 | } | |
15586 | ||
53089bec | 15587 | /* "show [ip] bgp route-leak" command. */ |
15588 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
15589 | show_ip_bgp_route_leak_cmd, |
15590 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
15591 | SHOW_STR |
15592 | IP_STR | |
15593 | BGP_STR | |
15594 | BGP_INSTANCE_HELP_STR | |
15595 | BGP_AFI_HELP_STR | |
15596 | BGP_SAFI_HELP_STR | |
15597 | "Route leaking information\n" | |
15598 | JSON_STR) | |
53089bec | 15599 | { |
15600 | char *vrf = NULL; | |
15601 | afi_t afi = AFI_MAX; | |
15602 | safi_t safi = SAFI_MAX; | |
15603 | ||
9f049418 | 15604 | bool uj = use_json(argc, argv); |
53089bec | 15605 | int idx = 0; |
03915806 | 15606 | json_object *json = NULL; |
53089bec | 15607 | |
15608 | /* show [ip] bgp */ | |
15609 | if (argv_find(argv, argc, "ip", &idx)) { | |
15610 | afi = AFI_IP; | |
15611 | safi = SAFI_UNICAST; | |
15612 | } | |
15613 | /* [vrf VIEWVRFNAME] */ | |
15614 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
15615 | vty_out(vty, |
15616 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 15617 | return CMD_WARNING; |
15618 | } | |
15619 | ||
9a8bdf1c PG |
15620 | if (argv_find(argv, argc, "vrf", &idx)) { |
15621 | vrf = argv[idx + 1]->arg; | |
15622 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15623 | vrf = NULL; | |
15624 | } | |
53089bec | 15625 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
c48349e3 | 15626 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
53089bec | 15627 | argv_find_and_parse_safi(argv, argc, &idx, &safi); |
53089bec | 15628 | |
15629 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
15630 | vty_out(vty, |
15631 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 15632 | return CMD_WARNING; |
15633 | } | |
15634 | ||
03915806 CS |
15635 | if (vrf && strmatch(vrf, "all")) |
15636 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
15637 | ||
15638 | if (uj) | |
15639 | json = json_object_new_object(); | |
15640 | ||
15641 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 15642 | } |
15643 | ||
d62a17ae | 15644 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
fa5a9276 | 15645 | safi_t safi, bool uj) |
f186de26 | 15646 | { |
d62a17ae | 15647 | struct listnode *node, *nnode; |
15648 | struct bgp *bgp; | |
f186de26 | 15649 | |
d62a17ae | 15650 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
fa5a9276 AR |
15651 | if (!uj) |
15652 | vty_out(vty, "\nInstance %s:\n", | |
15653 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15654 | ? VRF_DEFAULT_NAME | |
15655 | : bgp->name); | |
15656 | ||
15657 | update_group_show(bgp, afi, safi, vty, 0, uj); | |
d62a17ae | 15658 | } |
f186de26 | 15659 | } |
15660 | ||
d62a17ae | 15661 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
fa5a9276 | 15662 | int safi, uint64_t subgrp_id, bool uj) |
4fb25c53 | 15663 | { |
d62a17ae | 15664 | struct bgp *bgp; |
4fb25c53 | 15665 | |
d62a17ae | 15666 | if (name) { |
15667 | if (strmatch(name, "all")) { | |
fa5a9276 | 15668 | bgp_show_all_instances_updgrps_vty(vty, afi, safi, uj); |
d62a17ae | 15669 | return CMD_SUCCESS; |
15670 | } else { | |
15671 | bgp = bgp_lookup_by_name(name); | |
15672 | } | |
15673 | } else { | |
15674 | bgp = bgp_get_default(); | |
15675 | } | |
4fb25c53 | 15676 | |
d62a17ae | 15677 | if (bgp) |
fa5a9276 | 15678 | update_group_show(bgp, afi, safi, vty, subgrp_id, uj); |
d62a17ae | 15679 | return CMD_SUCCESS; |
4fb25c53 DW |
15680 | } |
15681 | ||
8fe8a7f6 DS |
15682 | DEFUN (show_ip_bgp_updgrps, |
15683 | show_ip_bgp_updgrps_cmd, | |
fa5a9276 | 15684 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID] [json]", |
8386ac43 | 15685 | SHOW_STR |
15686 | IP_STR | |
15687 | BGP_STR | |
15688 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15689 | BGP_AFI_HELP_STR |
9bedbb1e | 15690 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 | 15691 | "Detailed info about dynamic update groups\n" |
fa5a9276 AR |
15692 | "Specific subgroup to display detailed info for\n" |
15693 | JSON_STR) | |
8386ac43 | 15694 | { |
d62a17ae | 15695 | char *vrf = NULL; |
15696 | afi_t afi = AFI_IP6; | |
15697 | safi_t safi = SAFI_UNICAST; | |
15698 | uint64_t subgrp_id = 0; | |
15699 | ||
15700 | int idx = 0; | |
15701 | ||
fa5a9276 AR |
15702 | bool uj = use_json(argc, argv); |
15703 | ||
d62a17ae | 15704 | /* show [ip] bgp */ |
15705 | if (argv_find(argv, argc, "ip", &idx)) | |
15706 | afi = AFI_IP; | |
9a8bdf1c PG |
15707 | /* [<vrf> VIEWVRFNAME] */ |
15708 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15709 | vrf = argv[idx + 1]->arg; | |
15710 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15711 | vrf = NULL; | |
15712 | } else if (argv_find(argv, argc, "view", &idx)) | |
15713 | /* [<view> VIEWVRFNAME] */ | |
15714 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15715 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15716 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15717 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15718 | } | |
5bf15956 | 15719 | |
d62a17ae | 15720 | /* get subgroup id, if provided */ |
15721 | idx = argc - 1; | |
15722 | if (argv[idx]->type == VARIABLE_TKN) | |
15723 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15724 | |
fa5a9276 | 15725 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id, uj)); |
8fe8a7f6 DS |
15726 | } |
15727 | ||
f186de26 | 15728 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15729 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
fa5a9276 | 15730 | "show [ip] bgp <view|vrf> all update-groups [json]", |
f186de26 | 15731 | SHOW_STR |
716b2d8a | 15732 | IP_STR |
f186de26 | 15733 | BGP_STR |
15734 | BGP_INSTANCE_ALL_HELP_STR | |
fa5a9276 AR |
15735 | "Detailed info about dynamic update groups\n" |
15736 | JSON_STR) | |
f186de26 | 15737 | { |
fa5a9276 AR |
15738 | bool uj = use_json(argc, argv); |
15739 | ||
15740 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST, uj); | |
d62a17ae | 15741 | return CMD_SUCCESS; |
f186de26 | 15742 | } |
15743 | ||
43d3f4fc DS |
15744 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15745 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15746 | "show [ip] bgp l2vpn evpn update-groups", | |
15747 | SHOW_STR | |
15748 | IP_STR | |
15749 | BGP_STR | |
15750 | "l2vpn address family\n" | |
15751 | "evpn sub-address family\n" | |
15752 | "Detailed info about dynamic update groups\n") | |
15753 | { | |
15754 | char *vrf = NULL; | |
15755 | uint64_t subgrp_id = 0; | |
15756 | ||
fa5a9276 | 15757 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id, 0); |
43d3f4fc DS |
15758 | return CMD_SUCCESS; |
15759 | } | |
15760 | ||
5bf15956 DW |
15761 | DEFUN (show_bgp_updgrps_stats, |
15762 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15763 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15764 | SHOW_STR |
716b2d8a | 15765 | IP_STR |
3f9c7369 | 15766 | BGP_STR |
0c7b1b01 | 15767 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15768 | "Statistics\n") |
15769 | { | |
d62a17ae | 15770 | struct bgp *bgp; |
3f9c7369 | 15771 | |
d62a17ae | 15772 | bgp = bgp_get_default(); |
15773 | if (bgp) | |
15774 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15775 | |
d62a17ae | 15776 | return CMD_SUCCESS; |
3f9c7369 DS |
15777 | } |
15778 | ||
8386ac43 | 15779 | DEFUN (show_bgp_instance_updgrps_stats, |
15780 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15781 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15782 | SHOW_STR |
716b2d8a | 15783 | IP_STR |
8386ac43 | 15784 | BGP_STR |
15785 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15786 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15787 | "Statistics\n") |
15788 | { | |
d62a17ae | 15789 | int idx_word = 3; |
15790 | struct bgp *bgp; | |
8386ac43 | 15791 | |
d62a17ae | 15792 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15793 | if (bgp) | |
15794 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15795 | |
d62a17ae | 15796 | return CMD_SUCCESS; |
8386ac43 | 15797 | } |
15798 | ||
d62a17ae | 15799 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15800 | afi_t afi, safi_t safi, | |
15801 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15802 | { |
d62a17ae | 15803 | struct bgp *bgp; |
8386ac43 | 15804 | |
d62a17ae | 15805 | if (name) |
15806 | bgp = bgp_lookup_by_name(name); | |
15807 | else | |
15808 | bgp = bgp_get_default(); | |
8386ac43 | 15809 | |
d62a17ae | 15810 | if (bgp) { |
15811 | if (!strcmp(what, "advertise-queue")) | |
15812 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15813 | subgrp_id); | |
15814 | else if (!strcmp(what, "advertised-routes")) | |
15815 | update_group_show_advertised(bgp, afi, safi, vty, | |
15816 | subgrp_id); | |
15817 | else if (!strcmp(what, "packet-queue")) | |
15818 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15819 | subgrp_id); | |
15820 | } | |
3f9c7369 DS |
15821 | } |
15822 | ||
dc64bdec QY |
15823 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15824 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15825 | "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", | |
15826 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15827 | BGP_SAFI_HELP_STR | |
15828 | "Detailed info about dynamic update groups\n" | |
15829 | "Specific subgroup to display info for\n" | |
15830 | "Advertisement queue\n" | |
15831 | "Announced routes\n" | |
15832 | "Packet queue\n") | |
3f9c7369 | 15833 | { |
dc64bdec QY |
15834 | uint64_t subgrp_id = 0; |
15835 | afi_t afiz; | |
15836 | safi_t safiz; | |
15837 | if (sgid) | |
15838 | subgrp_id = strtoull(sgid, NULL, 10); | |
15839 | ||
15840 | if (!ip && !afi) | |
15841 | afiz = AFI_IP6; | |
15842 | if (!ip && afi) | |
15843 | afiz = bgp_vty_afi_from_str(afi); | |
15844 | if (ip && !afi) | |
15845 | afiz = AFI_IP; | |
15846 | if (ip && afi) { | |
15847 | afiz = bgp_vty_afi_from_str(afi); | |
15848 | if (afiz != AFI_IP) | |
15849 | vty_out(vty, | |
15850 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15851 | return CMD_WARNING; | |
15852 | } | |
d62a17ae | 15853 | |
dc64bdec | 15854 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15855 | |
dc64bdec | 15856 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15857 | return CMD_SUCCESS; |
15858 | } | |
15859 | ||
6f4eacf3 DA |
15860 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15861 | json_object *json) | |
d62a17ae | 15862 | { |
15863 | struct listnode *node, *nnode; | |
15864 | struct prefix *range; | |
15865 | struct peer *conf; | |
15866 | struct peer *peer; | |
d62a17ae | 15867 | afi_t afi; |
15868 | safi_t safi; | |
15869 | const char *peer_status; | |
d62a17ae | 15870 | int lr_count; |
15871 | int dynamic; | |
6f4eacf3 DA |
15872 | bool af_cfgd; |
15873 | json_object *json_peer_group = NULL; | |
15874 | json_object *json_peer_group_afc = NULL; | |
15875 | json_object *json_peer_group_members = NULL; | |
15876 | json_object *json_peer_group_dynamic = NULL; | |
15877 | json_object *json_peer_group_dynamic_af = NULL; | |
15878 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15879 | |
15880 | conf = group->conf; | |
15881 | ||
6f4eacf3 DA |
15882 | if (json) { |
15883 | json_peer_group = json_object_new_object(); | |
15884 | json_peer_group_afc = json_object_new_array(); | |
15885 | } | |
15886 | ||
d62a17ae | 15887 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15888 | if (json) |
15889 | json_object_int_add(json_peer_group, "remoteAs", | |
15890 | conf->as); | |
15891 | else | |
15892 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15893 | group->name, conf->as); | |
d62a17ae | 15894 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15895 | if (json) |
15896 | json_object_int_add(json_peer_group, "remoteAs", | |
15897 | group->bgp->as); | |
15898 | else | |
15899 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15900 | group->name, group->bgp->as); | |
d62a17ae | 15901 | } else { |
6f4eacf3 DA |
15902 | if (!json) |
15903 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15904 | } |
f14e6fdb | 15905 | |
6f4eacf3 DA |
15906 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15907 | if (json) | |
15908 | json_object_string_add(json_peer_group, "type", | |
15909 | "internal"); | |
15910 | else | |
15911 | vty_out(vty, " Peer-group type is internal\n"); | |
15912 | } else { | |
15913 | if (json) | |
15914 | json_object_string_add(json_peer_group, "type", | |
15915 | "external"); | |
15916 | else | |
15917 | vty_out(vty, " Peer-group type is external\n"); | |
15918 | } | |
d62a17ae | 15919 | |
15920 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15921 | if (!json) |
15922 | vty_out(vty, " Configured address-families:"); | |
15923 | ||
05c7a1cc QY |
15924 | FOREACH_AFI_SAFI (afi, safi) { |
15925 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15926 | af_cfgd = true; |
15927 | if (json) | |
15928 | json_object_array_add( | |
15929 | json_peer_group_afc, | |
15930 | json_object_new_string(get_afi_safi_str( | |
15931 | afi, safi, false))); | |
15932 | else | |
15933 | vty_out(vty, " %s;", | |
15934 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15935 | } |
05c7a1cc | 15936 | } |
6f4eacf3 DA |
15937 | |
15938 | if (json) { | |
15939 | json_object_object_add(json_peer_group, | |
15940 | "addressFamiliesConfigured", | |
15941 | json_peer_group_afc); | |
15942 | } else { | |
15943 | if (!af_cfgd) | |
15944 | vty_out(vty, " none\n"); | |
15945 | else | |
15946 | vty_out(vty, "\n"); | |
15947 | } | |
d62a17ae | 15948 | |
15949 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15950 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15951 | lr_count = listcount(group->listen_range[afi]); |
15952 | if (lr_count) { | |
6f4eacf3 DA |
15953 | if (json) { |
15954 | if (!json_peer_group_dynamic) | |
15955 | json_peer_group_dynamic = | |
15956 | json_object_new_object(); | |
15957 | ||
15958 | json_peer_group_dynamic_af = | |
15959 | json_object_new_object(); | |
15960 | json_peer_group_ranges = | |
15961 | json_object_new_array(); | |
15962 | json_object_int_add(json_peer_group_dynamic_af, | |
15963 | "count", lr_count); | |
15964 | } else { | |
15965 | vty_out(vty, " %d %s listen range(s)\n", | |
15966 | lr_count, afi2str(afi)); | |
15967 | } | |
d62a17ae | 15968 | |
15969 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15970 | nnode, range)) { |
15971 | if (json) { | |
15972 | char buf[BUFSIZ]; | |
15973 | ||
15974 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15975 | range); | |
15976 | ||
15977 | json_object_array_add( | |
15978 | json_peer_group_ranges, | |
15979 | json_object_new_string(buf)); | |
15980 | } else { | |
15981 | vty_out(vty, " %pFX\n", range); | |
15982 | } | |
15983 | } | |
15984 | ||
15985 | if (json) { | |
15986 | json_object_object_add( | |
15987 | json_peer_group_dynamic_af, "ranges", | |
15988 | json_peer_group_ranges); | |
15989 | ||
15990 | json_object_object_add( | |
15991 | json_peer_group_dynamic, afi2str(afi), | |
15992 | json_peer_group_dynamic_af); | |
15993 | } | |
d62a17ae | 15994 | } |
15995 | } | |
f14e6fdb | 15996 | |
6f4eacf3 DA |
15997 | if (json_peer_group_dynamic) |
15998 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15999 | json_peer_group_dynamic); | |
16000 | ||
d62a17ae | 16001 | /* Display group members and their status */ |
16002 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
16003 | if (json) |
16004 | json_peer_group_members = json_object_new_object(); | |
16005 | else | |
16006 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 16007 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
16008 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
16009 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 16010 | peer_status = "Idle (Admin)"; |
16011 | else if (CHECK_FLAG(peer->sflags, | |
16012 | PEER_STATUS_PREFIX_OVERFLOW)) | |
16013 | peer_status = "Idle (PfxCt)"; | |
16014 | else | |
16015 | peer_status = lookup_msg(bgp_status_msg, | |
16016 | peer->status, NULL); | |
16017 | ||
16018 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
16019 | |
16020 | if (json) { | |
16021 | json_object *json_peer_group_member = | |
16022 | json_object_new_object(); | |
16023 | ||
16024 | json_object_string_add(json_peer_group_member, | |
16025 | "status", peer_status); | |
16026 | ||
16027 | if (dynamic) | |
16028 | json_object_boolean_true_add( | |
16029 | json_peer_group_member, | |
16030 | "dynamic"); | |
16031 | ||
16032 | json_object_object_add(json_peer_group_members, | |
16033 | peer->host, | |
16034 | json_peer_group_member); | |
16035 | } else { | |
16036 | vty_out(vty, " %s %s %s \n", peer->host, | |
16037 | dynamic ? "(dynamic)" : "", | |
16038 | peer_status); | |
16039 | } | |
d62a17ae | 16040 | } |
6f4eacf3 DA |
16041 | if (json) |
16042 | json_object_object_add(json_peer_group, "members", | |
16043 | json_peer_group_members); | |
d62a17ae | 16044 | } |
f14e6fdb | 16045 | |
6f4eacf3 DA |
16046 | if (json) |
16047 | json_object_object_add(json, group->name, json_peer_group); | |
16048 | ||
d62a17ae | 16049 | return CMD_SUCCESS; |
16050 | } | |
16051 | ||
ff9959b0 | 16052 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 16053 | const char *group_name, bool uj) |
d62a17ae | 16054 | { |
ff9959b0 | 16055 | struct bgp *bgp; |
d62a17ae | 16056 | struct listnode *node, *nnode; |
16057 | struct peer_group *group; | |
ff9959b0 | 16058 | bool found = false; |
6f4eacf3 DA |
16059 | json_object *json = NULL; |
16060 | ||
16061 | if (uj) | |
16062 | json = json_object_new_object(); | |
ff9959b0 QY |
16063 | |
16064 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
16065 | ||
16066 | if (!bgp) { | |
c48349e3 | 16067 | if (uj) |
75eeda93 | 16068 | vty_json(vty, json); |
c48349e3 | 16069 | else |
6f4eacf3 | 16070 | vty_out(vty, "%% BGP instance not found\n"); |
6f4eacf3 | 16071 | |
ff9959b0 QY |
16072 | return CMD_WARNING; |
16073 | } | |
d62a17ae | 16074 | |
16075 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
16076 | if (group_name) { |
16077 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 16078 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
16079 | found = true; |
16080 | break; | |
d62a17ae | 16081 | } |
ff9959b0 | 16082 | } else { |
6f4eacf3 | 16083 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 16084 | } |
f14e6fdb | 16085 | } |
f14e6fdb | 16086 | |
6f4eacf3 | 16087 | if (group_name && !found && !uj) |
d62a17ae | 16088 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 16089 | |
c48349e3 | 16090 | if (uj) |
75eeda93 | 16091 | vty_json(vty, json); |
6f4eacf3 | 16092 | |
d62a17ae | 16093 | return CMD_SUCCESS; |
f14e6fdb DS |
16094 | } |
16095 | ||
6f4eacf3 DA |
16096 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
16097 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
16098 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
16099 | "Detailed information on BGP peer groups\n" | |
16100 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 16101 | { |
d62a17ae | 16102 | char *vrf, *pg; |
d62a17ae | 16103 | int idx = 0; |
6f4eacf3 | 16104 | bool uj = use_json(argc, argv); |
f14e6fdb | 16105 | |
a4d82a8a PZ |
16106 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
16107 | : NULL; | |
d62a17ae | 16108 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 16109 | |
6f4eacf3 | 16110 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 16111 | } |
3f9c7369 | 16112 | |
d6e3c605 | 16113 | |
718e3744 | 16114 | /* Redistribute VTY commands. */ |
16115 | ||
585f1adc IR |
16116 | DEFUN (bgp_redistribute_ipv4, |
16117 | bgp_redistribute_ipv4_cmd, | |
16118 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16119 | "Redistribute information from another routing protocol\n" | |
16120 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 16121 | { |
585f1adc | 16122 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16123 | int idx_protocol = 1; |
585f1adc | 16124 | int type; |
37a87b8f | 16125 | |
585f1adc IR |
16126 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
16127 | if (type < 0) { | |
16128 | vty_out(vty, "%% Invalid route type\n"); | |
16129 | return CMD_WARNING_CONFIG_FAILED; | |
16130 | } | |
7f323236 | 16131 | |
585f1adc IR |
16132 | bgp_redist_add(bgp, AFI_IP, type, 0); |
16133 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 16134 | } |
16135 | ||
d62a17ae | 16136 | ALIAS_HIDDEN( |
16137 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
16138 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16139 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 16140 | |
585f1adc IR |
16141 | DEFUN (bgp_redistribute_ipv4_rmap, |
16142 | bgp_redistribute_ipv4_rmap_cmd, | |
70dd370f | 16143 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16144 | "Redistribute information from another routing protocol\n" |
16145 | FRR_IP_REDIST_HELP_STR_BGPD | |
16146 | "Route map reference\n" | |
16147 | "Pointer to route-map entries\n") | |
718e3744 | 16148 | { |
585f1adc | 16149 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16150 | int idx_protocol = 1; |
16151 | int idx_word = 3; | |
585f1adc IR |
16152 | int type; |
16153 | struct bgp_redist *red; | |
16154 | bool changed; | |
16155 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
16156 | vty, argv[idx_word]->arg); | |
16157 | ||
16158 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16159 | if (type < 0) { | |
16160 | vty_out(vty, "%% Invalid route type\n"); | |
16161 | return CMD_WARNING_CONFIG_FAILED; | |
16162 | } | |
37a87b8f | 16163 | |
585f1adc IR |
16164 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16165 | changed = | |
16166 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16167 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 16168 | } |
16169 | ||
d62a17ae | 16170 | ALIAS_HIDDEN( |
16171 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
70dd370f | 16172 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
d62a17ae | 16173 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16174 | "Route map reference\n" | |
16175 | "Pointer to route-map entries\n") | |
596c17ba | 16176 | |
585f1adc IR |
16177 | DEFUN (bgp_redistribute_ipv4_metric, |
16178 | bgp_redistribute_ipv4_metric_cmd, | |
16179 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16180 | "Redistribute information from another routing protocol\n" | |
16181 | FRR_IP_REDIST_HELP_STR_BGPD | |
16182 | "Metric for redistributed routes\n" | |
16183 | "Default metric\n") | |
718e3744 | 16184 | { |
585f1adc | 16185 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16186 | int idx_protocol = 1; |
16187 | int idx_number = 3; | |
585f1adc IR |
16188 | int type; |
16189 | uint32_t metric; | |
16190 | struct bgp_redist *red; | |
16191 | bool changed; | |
16192 | ||
16193 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16194 | if (type < 0) { | |
16195 | vty_out(vty, "%% Invalid route type\n"); | |
16196 | return CMD_WARNING_CONFIG_FAILED; | |
16197 | } | |
16198 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16199 | |
585f1adc IR |
16200 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16201 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16202 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16203 | } |
16204 | ||
16205 | ALIAS_HIDDEN( | |
16206 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
16207 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16208 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16209 | "Metric for redistributed routes\n" | |
16210 | "Default metric\n") | |
596c17ba | 16211 | |
585f1adc IR |
16212 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
16213 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
70dd370f | 16214 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16215 | "Redistribute information from another routing protocol\n" |
16216 | FRR_IP_REDIST_HELP_STR_BGPD | |
16217 | "Route map reference\n" | |
16218 | "Pointer to route-map entries\n" | |
16219 | "Metric for redistributed routes\n" | |
16220 | "Default metric\n") | |
718e3744 | 16221 | { |
585f1adc | 16222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16223 | int idx_protocol = 1; |
16224 | int idx_word = 3; | |
16225 | int idx_number = 5; | |
585f1adc IR |
16226 | int type; |
16227 | uint32_t metric; | |
16228 | struct bgp_redist *red; | |
16229 | bool changed; | |
16230 | struct route_map *route_map = | |
16231 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16232 | ||
16233 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16234 | if (type < 0) { | |
16235 | vty_out(vty, "%% Invalid route type\n"); | |
16236 | return CMD_WARNING_CONFIG_FAILED; | |
16237 | } | |
16238 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16239 | |
585f1adc IR |
16240 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16241 | changed = | |
16242 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16243 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16244 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16245 | } |
16246 | ||
16247 | ALIAS_HIDDEN( | |
16248 | bgp_redistribute_ipv4_rmap_metric, | |
16249 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
16250 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16251 | " route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16252 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16253 | "Route map reference\n" | |
16254 | "Pointer to route-map entries\n" | |
16255 | "Metric for redistributed routes\n" | |
16256 | "Default metric\n") | |
596c17ba | 16257 | |
585f1adc IR |
16258 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
16259 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
70dd370f | 16260 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16261 | "Redistribute information from another routing protocol\n" |
16262 | FRR_IP_REDIST_HELP_STR_BGPD | |
16263 | "Metric for redistributed routes\n" | |
16264 | "Default metric\n" | |
16265 | "Route map reference\n" | |
16266 | "Pointer to route-map entries\n") | |
718e3744 | 16267 | { |
585f1adc | 16268 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16269 | int idx_protocol = 1; |
37a87b8f | 16270 | int idx_number = 3; |
585f1adc IR |
16271 | int idx_word = 5; |
16272 | int type; | |
16273 | uint32_t metric; | |
16274 | struct bgp_redist *red; | |
16275 | bool changed; | |
16276 | struct route_map *route_map = | |
16277 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16278 | ||
16279 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16280 | if (type < 0) { | |
16281 | vty_out(vty, "%% Invalid route type\n"); | |
16282 | return CMD_WARNING_CONFIG_FAILED; | |
16283 | } | |
16284 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16285 | |
585f1adc IR |
16286 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16287 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16288 | changed |= | |
16289 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16290 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16291 | } |
16292 | ||
16293 | ALIAS_HIDDEN( | |
16294 | bgp_redistribute_ipv4_metric_rmap, | |
16295 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
16296 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16297 | " metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16298 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16299 | "Metric for redistributed routes\n" | |
16300 | "Default metric\n" | |
16301 | "Route map reference\n" | |
16302 | "Pointer to route-map entries\n") | |
596c17ba | 16303 | |
585f1adc IR |
16304 | DEFUN (bgp_redistribute_ipv4_ospf, |
16305 | bgp_redistribute_ipv4_ospf_cmd, | |
16306 | "redistribute <ospf|table> (1-65535)", | |
16307 | "Redistribute information from another routing protocol\n" | |
16308 | "Open Shortest Path First (OSPFv2)\n" | |
16309 | "Non-main Kernel Routing Table\n" | |
16310 | "Instance ID/Table ID\n") | |
7c8ff89e | 16311 | { |
585f1adc IR |
16312 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16313 | int idx_ospf_table = 1; | |
d62a17ae | 16314 | int idx_number = 2; |
585f1adc IR |
16315 | unsigned short instance; |
16316 | unsigned short protocol; | |
7c8ff89e | 16317 | |
585f1adc | 16318 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 16319 | |
585f1adc IR |
16320 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16321 | protocol = ZEBRA_ROUTE_OSPF; | |
16322 | else | |
16323 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 16324 | |
585f1adc IR |
16325 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16326 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
16327 | } |
16328 | ||
d62a17ae | 16329 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
16330 | "redistribute <ospf|table> (1-65535)", | |
16331 | "Redistribute information from another routing protocol\n" | |
16332 | "Open Shortest Path First (OSPFv2)\n" | |
16333 | "Non-main Kernel Routing Table\n" | |
16334 | "Instance ID/Table ID\n") | |
596c17ba | 16335 | |
585f1adc IR |
16336 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
16337 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
70dd370f | 16338 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
585f1adc IR |
16339 | "Redistribute information from another routing protocol\n" |
16340 | "Open Shortest Path First (OSPFv2)\n" | |
16341 | "Non-main Kernel Routing Table\n" | |
16342 | "Instance ID/Table ID\n" | |
16343 | "Route map reference\n" | |
16344 | "Pointer to route-map entries\n") | |
7c8ff89e | 16345 | { |
585f1adc IR |
16346 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16347 | int idx_ospf_table = 1; | |
d62a17ae | 16348 | int idx_number = 2; |
16349 | int idx_word = 4; | |
585f1adc IR |
16350 | struct bgp_redist *red; |
16351 | unsigned short instance; | |
16352 | int protocol; | |
16353 | bool changed; | |
16354 | struct route_map *route_map = | |
16355 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16356 | ||
16357 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16358 | protocol = ZEBRA_ROUTE_OSPF; | |
16359 | else | |
16360 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16361 | |
585f1adc IR |
16362 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16363 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
16364 | changed = | |
16365 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16366 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16367 | } |
16368 | ||
16369 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
16370 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
70dd370f | 16371 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
d62a17ae | 16372 | "Redistribute information from another routing protocol\n" |
16373 | "Open Shortest Path First (OSPFv2)\n" | |
16374 | "Non-main Kernel Routing Table\n" | |
16375 | "Instance ID/Table ID\n" | |
16376 | "Route map reference\n" | |
16377 | "Pointer to route-map entries\n") | |
596c17ba | 16378 | |
585f1adc IR |
16379 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
16380 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
16381 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16382 | "Redistribute information from another routing protocol\n" | |
16383 | "Open Shortest Path First (OSPFv2)\n" | |
16384 | "Non-main Kernel Routing Table\n" | |
16385 | "Instance ID/Table ID\n" | |
16386 | "Metric for redistributed routes\n" | |
16387 | "Default metric\n") | |
7c8ff89e | 16388 | { |
585f1adc IR |
16389 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16390 | int idx_ospf_table = 1; | |
d62a17ae | 16391 | int idx_number = 2; |
16392 | int idx_number_2 = 4; | |
585f1adc IR |
16393 | uint32_t metric; |
16394 | struct bgp_redist *red; | |
16395 | unsigned short instance; | |
16396 | int protocol; | |
16397 | bool changed; | |
16398 | ||
16399 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16400 | protocol = ZEBRA_ROUTE_OSPF; | |
16401 | else | |
16402 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16403 | |
585f1adc IR |
16404 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16405 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16406 | |
585f1adc IR |
16407 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16408 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16409 | metric); | |
16410 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16411 | } |
16412 | ||
16413 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
16414 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
16415 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16416 | "Redistribute information from another routing protocol\n" | |
16417 | "Open Shortest Path First (OSPFv2)\n" | |
16418 | "Non-main Kernel Routing Table\n" | |
16419 | "Instance ID/Table ID\n" | |
16420 | "Metric for redistributed routes\n" | |
16421 | "Default metric\n") | |
596c17ba | 16422 | |
585f1adc IR |
16423 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
16424 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
70dd370f | 16425 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16426 | "Redistribute information from another routing protocol\n" |
16427 | "Open Shortest Path First (OSPFv2)\n" | |
16428 | "Non-main Kernel Routing Table\n" | |
16429 | "Instance ID/Table ID\n" | |
16430 | "Route map reference\n" | |
16431 | "Pointer to route-map entries\n" | |
16432 | "Metric for redistributed routes\n" | |
16433 | "Default metric\n") | |
7c8ff89e | 16434 | { |
585f1adc IR |
16435 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16436 | int idx_ospf_table = 1; | |
d62a17ae | 16437 | int idx_number = 2; |
16438 | int idx_word = 4; | |
16439 | int idx_number_2 = 6; | |
585f1adc IR |
16440 | uint32_t metric; |
16441 | struct bgp_redist *red; | |
16442 | unsigned short instance; | |
16443 | int protocol; | |
16444 | bool changed; | |
16445 | struct route_map *route_map = | |
16446 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16447 | ||
16448 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16449 | protocol = ZEBRA_ROUTE_OSPF; | |
16450 | else | |
16451 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16452 | |
585f1adc IR |
16453 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16454 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16455 | |
585f1adc IR |
16456 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16457 | changed = | |
16458 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16459 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16460 | metric); | |
16461 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16462 | } |
16463 | ||
16464 | ALIAS_HIDDEN( | |
16465 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
16466 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
70dd370f | 16467 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16468 | "Redistribute information from another routing protocol\n" |
16469 | "Open Shortest Path First (OSPFv2)\n" | |
16470 | "Non-main Kernel Routing Table\n" | |
16471 | "Instance ID/Table ID\n" | |
16472 | "Route map reference\n" | |
16473 | "Pointer to route-map entries\n" | |
16474 | "Metric for redistributed routes\n" | |
16475 | "Default metric\n") | |
596c17ba | 16476 | |
585f1adc IR |
16477 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
16478 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
70dd370f | 16479 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16480 | "Redistribute information from another routing protocol\n" |
16481 | "Open Shortest Path First (OSPFv2)\n" | |
16482 | "Non-main Kernel Routing Table\n" | |
16483 | "Instance ID/Table ID\n" | |
16484 | "Metric for redistributed routes\n" | |
16485 | "Default metric\n" | |
16486 | "Route map reference\n" | |
16487 | "Pointer to route-map entries\n") | |
7c8ff89e | 16488 | { |
585f1adc IR |
16489 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16490 | int idx_ospf_table = 1; | |
d62a17ae | 16491 | int idx_number = 2; |
16492 | int idx_number_2 = 4; | |
16493 | int idx_word = 6; | |
585f1adc IR |
16494 | uint32_t metric; |
16495 | struct bgp_redist *red; | |
16496 | unsigned short instance; | |
16497 | int protocol; | |
16498 | bool changed; | |
16499 | struct route_map *route_map = | |
16500 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16501 | ||
16502 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16503 | protocol = ZEBRA_ROUTE_OSPF; | |
16504 | else | |
16505 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16506 | |
585f1adc IR |
16507 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16508 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16509 | |
585f1adc IR |
16510 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16511 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16512 | metric); | |
16513 | changed |= | |
16514 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16515 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16516 | } |
16517 | ||
16518 | ALIAS_HIDDEN( | |
16519 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
16520 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
70dd370f | 16521 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16522 | "Redistribute information from another routing protocol\n" |
16523 | "Open Shortest Path First (OSPFv2)\n" | |
16524 | "Non-main Kernel Routing Table\n" | |
16525 | "Instance ID/Table ID\n" | |
16526 | "Metric for redistributed routes\n" | |
16527 | "Default metric\n" | |
16528 | "Route map reference\n" | |
16529 | "Pointer to route-map entries\n") | |
596c17ba | 16530 | |
585f1adc IR |
16531 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
16532 | no_bgp_redistribute_ipv4_ospf_cmd, | |
70dd370f | 16533 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16534 | NO_STR |
16535 | "Redistribute information from another routing protocol\n" | |
16536 | "Open Shortest Path First (OSPFv2)\n" | |
16537 | "Non-main Kernel Routing Table\n" | |
16538 | "Instance ID/Table ID\n" | |
16539 | "Metric for redistributed routes\n" | |
16540 | "Default metric\n" | |
16541 | "Route map reference\n" | |
16542 | "Pointer to route-map entries\n") | |
7c8ff89e | 16543 | { |
585f1adc IR |
16544 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16545 | int idx_ospf_table = 2; | |
d62a17ae | 16546 | int idx_number = 3; |
585f1adc IR |
16547 | unsigned short instance; |
16548 | int protocol; | |
37a87b8f | 16549 | |
585f1adc IR |
16550 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16551 | protocol = ZEBRA_ROUTE_OSPF; | |
16552 | else | |
16553 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16554 | |
585f1adc IR |
16555 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16556 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 16557 | } |
16558 | ||
16559 | ALIAS_HIDDEN( | |
16560 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
70dd370f | 16561 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16562 | NO_STR |
16563 | "Redistribute information from another routing protocol\n" | |
16564 | "Open Shortest Path First (OSPFv2)\n" | |
16565 | "Non-main Kernel Routing Table\n" | |
16566 | "Instance ID/Table ID\n" | |
16567 | "Metric for redistributed routes\n" | |
16568 | "Default metric\n" | |
16569 | "Route map reference\n" | |
16570 | "Pointer to route-map entries\n") | |
596c17ba | 16571 | |
585f1adc IR |
16572 | DEFUN (no_bgp_redistribute_ipv4, |
16573 | no_bgp_redistribute_ipv4_cmd, | |
70dd370f | 16574 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16575 | NO_STR |
16576 | "Redistribute information from another routing protocol\n" | |
16577 | FRR_IP_REDIST_HELP_STR_BGPD | |
16578 | "Metric for redistributed routes\n" | |
16579 | "Default metric\n" | |
16580 | "Route map reference\n" | |
16581 | "Pointer to route-map entries\n") | |
718e3744 | 16582 | { |
585f1adc | 16583 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16584 | int idx_protocol = 2; |
585f1adc | 16585 | int type; |
d62a17ae | 16586 | |
585f1adc IR |
16587 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
16588 | if (type < 0) { | |
16589 | vty_out(vty, "%% Invalid route type\n"); | |
16590 | return CMD_WARNING_CONFIG_FAILED; | |
16591 | } | |
16592 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 16593 | } |
16594 | ||
16595 | ALIAS_HIDDEN( | |
16596 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
16597 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16598 | " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16599 | NO_STR |
16600 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16601 | "Metric for redistributed routes\n" | |
16602 | "Default metric\n" | |
16603 | "Route map reference\n" | |
16604 | "Pointer to route-map entries\n") | |
596c17ba | 16605 | |
585f1adc IR |
16606 | DEFUN (bgp_redistribute_ipv6, |
16607 | bgp_redistribute_ipv6_cmd, | |
16608 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
16609 | "Redistribute information from another routing protocol\n" | |
16610 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 16611 | { |
585f1adc | 16612 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16613 | int idx_protocol = 1; |
585f1adc | 16614 | int type; |
718e3744 | 16615 | |
585f1adc IR |
16616 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16617 | if (type < 0) { | |
16618 | vty_out(vty, "%% Invalid route type\n"); | |
16619 | return CMD_WARNING_CONFIG_FAILED; | |
16620 | } | |
718e3744 | 16621 | |
585f1adc IR |
16622 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
16623 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 16624 | } |
16625 | ||
585f1adc IR |
16626 | DEFUN (bgp_redistribute_ipv6_rmap, |
16627 | bgp_redistribute_ipv6_rmap_cmd, | |
70dd370f | 16628 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16629 | "Redistribute information from another routing protocol\n" |
16630 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16631 | "Route map reference\n" | |
16632 | "Pointer to route-map entries\n") | |
718e3744 | 16633 | { |
585f1adc | 16634 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16635 | int idx_protocol = 1; |
16636 | int idx_word = 3; | |
585f1adc IR |
16637 | int type; |
16638 | struct bgp_redist *red; | |
16639 | bool changed; | |
16640 | struct route_map *route_map = | |
16641 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16642 | ||
16643 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16644 | if (type < 0) { | |
16645 | vty_out(vty, "%% Invalid route type\n"); | |
16646 | return CMD_WARNING_CONFIG_FAILED; | |
16647 | } | |
37a87b8f | 16648 | |
585f1adc IR |
16649 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16650 | changed = | |
16651 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16652 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16653 | } |
16654 | ||
585f1adc | 16655 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 16656 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16657 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16658 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16659 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16660 | "Metric for redistributed routes\n" |
16661 | "Default metric\n") | |
16662 | { | |
585f1adc | 16663 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16664 | int idx_protocol = 1; |
16665 | int idx_number = 3; | |
585f1adc IR |
16666 | int type; |
16667 | uint32_t metric; | |
16668 | struct bgp_redist *red; | |
16669 | bool changed; | |
16670 | ||
16671 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16672 | if (type < 0) { | |
16673 | vty_out(vty, "%% Invalid route type\n"); | |
16674 | return CMD_WARNING_CONFIG_FAILED; | |
16675 | } | |
16676 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16677 | |
585f1adc IR |
16678 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16679 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
16680 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16681 | } |
16682 | ||
585f1adc IR |
16683 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
16684 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
70dd370f | 16685 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16686 | "Redistribute information from another routing protocol\n" |
16687 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16688 | "Route map reference\n" | |
16689 | "Pointer to route-map entries\n" | |
16690 | "Metric for redistributed routes\n" | |
16691 | "Default metric\n") | |
718e3744 | 16692 | { |
585f1adc | 16693 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16694 | int idx_protocol = 1; |
16695 | int idx_word = 3; | |
16696 | int idx_number = 5; | |
585f1adc IR |
16697 | int type; |
16698 | uint32_t metric; | |
16699 | struct bgp_redist *red; | |
16700 | bool changed; | |
16701 | struct route_map *route_map = | |
16702 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16703 | ||
16704 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16705 | if (type < 0) { | |
16706 | vty_out(vty, "%% Invalid route type\n"); | |
16707 | return CMD_WARNING_CONFIG_FAILED; | |
16708 | } | |
16709 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16710 | |
585f1adc IR |
16711 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16712 | changed = | |
16713 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16714 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
16715 | metric); | |
16716 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16717 | } |
16718 | ||
585f1adc IR |
16719 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
16720 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
70dd370f | 16721 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16722 | "Redistribute information from another routing protocol\n" |
16723 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16724 | "Metric for redistributed routes\n" | |
16725 | "Default metric\n" | |
16726 | "Route map reference\n" | |
16727 | "Pointer to route-map entries\n") | |
718e3744 | 16728 | { |
585f1adc | 16729 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16730 | int idx_protocol = 1; |
37a87b8f | 16731 | int idx_number = 3; |
585f1adc IR |
16732 | int idx_word = 5; |
16733 | int type; | |
16734 | uint32_t metric; | |
16735 | struct bgp_redist *red; | |
16736 | bool changed; | |
16737 | struct route_map *route_map = | |
16738 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16739 | ||
16740 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16741 | if (type < 0) { | |
16742 | vty_out(vty, "%% Invalid route type\n"); | |
16743 | return CMD_WARNING_CONFIG_FAILED; | |
16744 | } | |
16745 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16746 | |
585f1adc IR |
16747 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16748 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
16749 | metric); | |
16750 | changed |= | |
16751 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16752 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16753 | } |
16754 | ||
585f1adc IR |
16755 | DEFUN (no_bgp_redistribute_ipv6, |
16756 | no_bgp_redistribute_ipv6_cmd, | |
70dd370f | 16757 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16758 | NO_STR |
16759 | "Redistribute information from another routing protocol\n" | |
16760 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16761 | "Metric for redistributed routes\n" | |
16762 | "Default metric\n" | |
16763 | "Route map reference\n" | |
16764 | "Pointer to route-map entries\n") | |
718e3744 | 16765 | { |
585f1adc | 16766 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16767 | int idx_protocol = 2; |
585f1adc | 16768 | int type; |
37a87b8f | 16769 | |
585f1adc IR |
16770 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16771 | if (type < 0) { | |
16772 | vty_out(vty, "%% Invalid route type\n"); | |
16773 | return CMD_WARNING_CONFIG_FAILED; | |
16774 | } | |
718e3744 | 16775 | |
585f1adc | 16776 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 16777 | } |
16778 | ||
4ab46701 AR |
16779 | /* Neighbor update tcp-mss. */ |
16780 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16781 | const char *tcp_mss_str) | |
16782 | { | |
16783 | struct peer *peer; | |
16784 | uint32_t tcp_mss_val = 0; | |
16785 | ||
16786 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16787 | if (!peer) | |
16788 | return CMD_WARNING_CONFIG_FAILED; | |
16789 | ||
16790 | if (tcp_mss_str) { | |
16791 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16792 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16793 | } else { | |
16794 | peer_tcp_mss_unset(peer); | |
16795 | } | |
16796 | ||
16797 | return CMD_SUCCESS; | |
16798 | } | |
16799 | ||
16800 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16801 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16802 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16803 | "TCP max segment size\n" | |
16804 | "TCP MSS value\n") | |
16805 | { | |
16806 | int peer_index = 1; | |
16807 | int mss_index = 3; | |
16808 | ||
16809 | vty_out(vty, | |
16810 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16811 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16812 | argv[mss_index]->arg); | |
16813 | } | |
16814 | ||
16815 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16816 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16817 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16818 | "TCP max segment size\n" | |
16819 | "TCP MSS value\n") | |
16820 | { | |
16821 | int peer_index = 2; | |
16822 | ||
16823 | vty_out(vty, | |
16824 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16825 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16826 | } | |
16827 | ||
a486300b PG |
16828 | DEFPY(bgp_retain_route_target, bgp_retain_route_target_cmd, |
16829 | "[no$no] bgp retain route-target all", | |
16830 | NO_STR BGP_STR | |
16831 | "Retain BGP updates\n" | |
16832 | "Retain BGP updates based on route-target values\n" | |
16833 | "Retain all BGP updates\n") | |
16834 | { | |
16835 | bool check; | |
16836 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
16837 | ||
16838 | check = CHECK_FLAG(bgp->af_flags[bgp_node_afi(vty)][bgp_node_safi(vty)], | |
16839 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16840 | if (check != !no) { | |
16841 | if (!no) | |
16842 | SET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16843 | [bgp_node_safi(vty)], | |
16844 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16845 | else | |
16846 | UNSET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16847 | [bgp_node_safi(vty)], | |
16848 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16849 | /* trigger a flush to re-sync with ADJ-RIB-in */ | |
16850 | bgp_clear(vty, bgp, bgp_node_afi(vty), bgp_node_safi(vty), | |
16851 | clear_all, BGP_CLEAR_SOFT_IN, NULL); | |
16852 | } | |
16853 | return CMD_SUCCESS; | |
16854 | } | |
16855 | ||
dd65f45e DL |
16856 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16857 | afi_t afi, safi_t safi) | |
d62a17ae | 16858 | { |
16859 | int i; | |
16860 | ||
16861 | /* Unicast redistribution only. */ | |
16862 | if (safi != SAFI_UNICAST) | |
2b791107 | 16863 | return; |
d62a17ae | 16864 | |
16865 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16866 | /* Redistribute BGP does not make sense. */ | |
16867 | if (i != ZEBRA_ROUTE_BGP) { | |
16868 | struct list *red_list; | |
16869 | struct listnode *node; | |
16870 | struct bgp_redist *red; | |
16871 | ||
16872 | red_list = bgp->redist[afi][i]; | |
16873 | if (!red_list) | |
16874 | continue; | |
16875 | ||
16876 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16877 | /* "redistribute" configuration. */ |
16878 | vty_out(vty, " redistribute %s", | |
16879 | zebra_route_string(i)); | |
16880 | if (red->instance) | |
16881 | vty_out(vty, " %d", red->instance); | |
16882 | if (red->redist_metric_flag) | |
16883 | vty_out(vty, " metric %u", | |
16884 | red->redist_metric); | |
16885 | if (red->rmap.name) | |
16886 | vty_out(vty, " route-map %s", | |
16887 | red->rmap.name); | |
16888 | vty_out(vty, "\n"); | |
16889 | } | |
16890 | } | |
16891 | } | |
718e3744 | 16892 | } |
6b0655a2 | 16893 | |
dd65f45e DL |
16894 | /* peer-group helpers for config-write */ |
16895 | ||
83194f39 | 16896 | static bool peergroup_flag_check(struct peer *peer, uint64_t flag) |
dd65f45e DL |
16897 | { |
16898 | if (!peer_group_active(peer)) { | |
16899 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16900 | return !CHECK_FLAG(peer->flags, flag); | |
16901 | else | |
16902 | return !!CHECK_FLAG(peer->flags, flag); | |
16903 | } | |
16904 | ||
16905 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16906 | } | |
16907 | ||
16908 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
da5e1a58 | 16909 | uint64_t flag) |
dd65f45e DL |
16910 | { |
16911 | if (!peer_group_active(peer)) { | |
16912 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16913 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16914 | else | |
16915 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16916 | } | |
16917 | ||
16918 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16919 | } | |
16920 | ||
16921 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16922 | uint8_t type, int direct) | |
16923 | { | |
16924 | struct bgp_filter *filter; | |
16925 | ||
16926 | if (peer_group_active(peer)) | |
16927 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16928 | type); | |
16929 | ||
16930 | filter = &peer->filter[afi][safi]; | |
16931 | switch (type) { | |
16932 | case PEER_FT_DISTRIBUTE_LIST: | |
16933 | return !!(filter->dlist[direct].name); | |
16934 | case PEER_FT_FILTER_LIST: | |
16935 | return !!(filter->aslist[direct].name); | |
16936 | case PEER_FT_PREFIX_LIST: | |
16937 | return !!(filter->plist[direct].name); | |
16938 | case PEER_FT_ROUTE_MAP: | |
16939 | return !!(filter->map[direct].name); | |
16940 | case PEER_FT_UNSUPPRESS_MAP: | |
16941 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16942 | case PEER_FT_ADVERTISE_MAP: |
16943 | return !!(filter->advmap.aname | |
16944 | && ((filter->advmap.condition == direct) | |
16945 | && filter->advmap.cname)); | |
dd65f45e DL |
16946 | default: |
16947 | return false; | |
16948 | } | |
16949 | } | |
16950 | ||
16951 | /* Return true if the addpath type is set for peer and different from | |
16952 | * peer-group. | |
16953 | */ | |
3dc339cd DA |
16954 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16955 | safi_t safi) | |
dd65f45e DL |
16956 | { |
16957 | enum bgp_addpath_strat type, g_type; | |
16958 | ||
16959 | type = peer->addpath_type[afi][safi]; | |
16960 | ||
16961 | if (type != BGP_ADDPATH_NONE) { | |
16962 | if (peer_group_active(peer)) { | |
16963 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16964 | ||
16965 | if (type != g_type) | |
3dc339cd | 16966 | return true; |
dd65f45e | 16967 | else |
3dc339cd | 16968 | return false; |
dd65f45e DL |
16969 | } |
16970 | ||
3dc339cd | 16971 | return true; |
dd65f45e DL |
16972 | } |
16973 | ||
3dc339cd | 16974 | return false; |
dd65f45e DL |
16975 | } |
16976 | ||
b9c7bc5a | 16977 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16978 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16979 | afi_t afi) |
16980 | { | |
b9c7bc5a | 16981 | int indent = 2; |
53970de3 | 16982 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16983 | |
8a066a70 | 16984 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16985 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16986 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16987 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16988 | bgp->vpn_policy[afi] | |
bb4f6190 | 16989 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16990 | else |
16991 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16992 | bgp->vpn_policy[afi] | |
16993 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16994 | } | |
12a844a5 DS |
16995 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16996 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16997 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16998 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16999 | return; | |
17000 | ||
e70e9f8e PZ |
17001 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
17002 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
17003 | ||
17004 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
17005 | ||
17006 | } else { | |
17007 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
17008 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
17009 | bgp->vpn_policy[afi].tovpn_label); | |
17010 | } | |
ddb5b488 | 17011 | } |
53970de3 RS |
17012 | |
17013 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
17014 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
17015 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
17016 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
17017 | } else if (tovpn_sid_index != 0) { | |
17018 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
17019 | tovpn_sid_index); | |
17020 | } | |
17021 | ||
c4f64ea9 DA |
17022 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_RD_SET)) |
17023 | vty_out(vty, "%*srd vpn export %pRD\n", indent, "", | |
17024 | &bgp->vpn_policy[afi].tovpn_rd); | |
17025 | ||
ddb5b488 PZ |
17026 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
17027 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
17028 | ||
17029 | char buf[PREFIX_STRLEN]; | |
17030 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
17031 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
17032 | sizeof(buf))) { | |
17033 | ||
b9c7bc5a PZ |
17034 | vty_out(vty, "%*snexthop vpn export %s\n", |
17035 | indent, "", buf); | |
ddb5b488 PZ |
17036 | } |
17037 | } | |
17038 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
17039 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
17040 | && ecommunity_cmp( | |
17041 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
17042 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
17043 | ||
17044 | char *b = ecommunity_ecom2str( | |
17045 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
17046 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17047 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
17048 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17049 | } else { | |
17050 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
17051 | char *b = ecommunity_ecom2str( | |
17052 | bgp->vpn_policy[afi] | |
17053 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
17054 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17055 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17056 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
17057 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17058 | } | |
17059 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
17060 | char *b = ecommunity_ecom2str( | |
17061 | bgp->vpn_policy[afi] | |
17062 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
17063 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17064 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17065 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
17066 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17067 | } | |
17068 | } | |
bb4f6190 DS |
17069 | |
17070 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 17071 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
17072 | bgp->vpn_policy[afi] |
17073 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 17074 | |
301ad80a PG |
17075 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
17076 | char *b = ecommunity_ecom2str( | |
17077 | bgp->vpn_policy[afi] | |
17078 | .import_redirect_rtlist, | |
17079 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17080 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 17081 | |
9a659715 PG |
17082 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
17083 | != ECOMMUNITY_SIZE) | |
c6423c31 | 17084 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
17085 | indent, "", b); |
17086 | else | |
17087 | vty_out(vty, "%*srt redirect import %s\n", | |
17088 | indent, "", b); | |
301ad80a PG |
17089 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17090 | } | |
ddb5b488 PZ |
17091 | } |
17092 | ||
dd65f45e DL |
17093 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
17094 | afi_t afi, safi_t safi) | |
17095 | { | |
17096 | struct bgp_filter *filter; | |
17097 | char *addr; | |
17098 | ||
17099 | addr = peer->host; | |
17100 | filter = &peer->filter[afi][safi]; | |
17101 | ||
17102 | /* distribute-list. */ | |
17103 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17104 | FILTER_IN)) | |
17105 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
17106 | filter->dlist[FILTER_IN].name); | |
17107 | ||
17108 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17109 | FILTER_OUT)) | |
17110 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
17111 | filter->dlist[FILTER_OUT].name); | |
17112 | ||
17113 | /* prefix-list. */ | |
17114 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17115 | FILTER_IN)) | |
17116 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
17117 | filter->plist[FILTER_IN].name); | |
17118 | ||
17119 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17120 | FILTER_OUT)) | |
17121 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
17122 | filter->plist[FILTER_OUT].name); | |
17123 | ||
17124 | /* route-map. */ | |
17125 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
17126 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
17127 | filter->map[RMAP_IN].name); | |
17128 | ||
17129 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
17130 | RMAP_OUT)) | |
17131 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
17132 | filter->map[RMAP_OUT].name); | |
17133 | ||
17134 | /* unsuppress-map */ | |
17135 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
17136 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
17137 | filter->usmap.name); | |
17138 | ||
7f7940e6 MK |
17139 | /* advertise-map : always applied in OUT direction*/ |
17140 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17141 | CONDITION_NON_EXIST)) | |
17142 | vty_out(vty, | |
17143 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
17144 | addr, filter->advmap.aname, filter->advmap.cname); | |
17145 | ||
17146 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17147 | CONDITION_EXIST)) | |
17148 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
17149 | addr, filter->advmap.aname, filter->advmap.cname); | |
17150 | ||
dd65f45e DL |
17151 | /* filter-list. */ |
17152 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17153 | FILTER_IN)) | |
17154 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
17155 | filter->aslist[FILTER_IN].name); | |
17156 | ||
17157 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17158 | FILTER_OUT)) | |
17159 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
17160 | filter->aslist[FILTER_OUT].name); | |
17161 | } | |
17162 | ||
17163 | /* BGP peer configuration display function. */ | |
17164 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
17165 | struct peer *peer) | |
17166 | { | |
17167 | struct peer *g_peer = NULL; | |
dd65f45e DL |
17168 | char *addr; |
17169 | int if_pg_printed = false; | |
17170 | int if_ras_printed = false; | |
17171 | ||
17172 | /* Skip dynamic neighbors. */ | |
17173 | if (peer_dynamic_neighbor(peer)) | |
17174 | return; | |
17175 | ||
17176 | if (peer->conf_if) | |
17177 | addr = peer->conf_if; | |
17178 | else | |
17179 | addr = peer->host; | |
17180 | ||
17181 | /************************************ | |
17182 | ****** Global to the neighbor ****** | |
17183 | ************************************/ | |
17184 | if (peer->conf_if) { | |
17185 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
17186 | vty_out(vty, " neighbor %s interface v6only", addr); | |
17187 | else | |
17188 | vty_out(vty, " neighbor %s interface", addr); | |
17189 | ||
17190 | if (peer_group_active(peer)) { | |
17191 | vty_out(vty, " peer-group %s", peer->group->name); | |
17192 | if_pg_printed = true; | |
17193 | } else if (peer->as_type == AS_SPECIFIED) { | |
17194 | vty_out(vty, " remote-as %u", peer->as); | |
17195 | if_ras_printed = true; | |
17196 | } else if (peer->as_type == AS_INTERNAL) { | |
17197 | vty_out(vty, " remote-as internal"); | |
17198 | if_ras_printed = true; | |
17199 | } else if (peer->as_type == AS_EXTERNAL) { | |
17200 | vty_out(vty, " remote-as external"); | |
17201 | if_ras_printed = true; | |
17202 | } | |
17203 | ||
17204 | vty_out(vty, "\n"); | |
17205 | } | |
17206 | ||
17207 | /* remote-as and peer-group */ | |
17208 | /* peer is a member of a peer-group */ | |
17209 | if (peer_group_active(peer)) { | |
17210 | g_peer = peer->group->conf; | |
17211 | ||
17212 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
17213 | if (peer->as_type == AS_SPECIFIED) { | |
17214 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17215 | addr, peer->as); | |
17216 | } else if (peer->as_type == AS_INTERNAL) { | |
17217 | vty_out(vty, | |
17218 | " neighbor %s remote-as internal\n", | |
17219 | addr); | |
17220 | } else if (peer->as_type == AS_EXTERNAL) { | |
17221 | vty_out(vty, | |
17222 | " neighbor %s remote-as external\n", | |
17223 | addr); | |
17224 | } | |
17225 | } | |
17226 | ||
17227 | /* For swpX peers we displayed the peer-group | |
17228 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
17229 | if (!if_pg_printed) | |
17230 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
17231 | peer->group->name); | |
17232 | } | |
17233 | ||
17234 | /* peer is NOT a member of a peer-group */ | |
17235 | else { | |
17236 | /* peer is a peer-group, declare the peer-group */ | |
17237 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
17238 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
17239 | } | |
17240 | ||
17241 | if (!if_ras_printed) { | |
17242 | if (peer->as_type == AS_SPECIFIED) { | |
17243 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17244 | addr, peer->as); | |
17245 | } else if (peer->as_type == AS_INTERNAL) { | |
17246 | vty_out(vty, | |
17247 | " neighbor %s remote-as internal\n", | |
17248 | addr); | |
17249 | } else if (peer->as_type == AS_EXTERNAL) { | |
17250 | vty_out(vty, | |
17251 | " neighbor %s remote-as external\n", | |
17252 | addr); | |
17253 | } | |
17254 | } | |
17255 | } | |
17256 | ||
17257 | /* local-as */ | |
17258 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
17259 | vty_out(vty, " neighbor %s local-as %u", addr, | |
17260 | peer->change_local_as); | |
17261 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
17262 | vty_out(vty, " no-prepend"); | |
17263 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
17264 | vty_out(vty, " replace-as"); | |
17265 | vty_out(vty, "\n"); | |
17266 | } | |
17267 | ||
17268 | /* description */ | |
17269 | if (peer->desc) { | |
17270 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
17271 | } | |
17272 | ||
17273 | /* shutdown */ | |
17274 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
17275 | if (peer->tx_shutdown_message) | |
17276 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
17277 | peer->tx_shutdown_message); | |
17278 | else | |
17279 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
17280 | } | |
17281 | ||
8336c896 DA |
17282 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
17283 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
17284 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
17285 | ||
dd65f45e | 17286 | /* bfd */ |
21bfce98 RZ |
17287 | if (peer->bfd_config) |
17288 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
17289 | |
17290 | /* password */ | |
17291 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
17292 | vty_out(vty, " neighbor %s password %s\n", addr, | |
17293 | peer->password); | |
17294 | ||
17295 | /* neighbor solo */ | |
17296 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
17297 | if (!peer_group_active(peer)) { | |
17298 | vty_out(vty, " neighbor %s solo\n", addr); | |
17299 | } | |
17300 | } | |
17301 | ||
17302 | /* BGP port */ | |
17303 | if (peer->port != BGP_PORT_DEFAULT) { | |
17304 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
17305 | } | |
17306 | ||
17307 | /* Local interface name */ | |
17308 | if (peer->ifname) { | |
17309 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
17310 | } | |
17311 | ||
4ab46701 AR |
17312 | /* TCP max segment size */ |
17313 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
17314 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
17315 | ||
dd65f45e DL |
17316 | /* passive */ |
17317 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
17318 | vty_out(vty, " neighbor %s passive\n", addr); | |
17319 | ||
17320 | /* ebgp-multihop */ | |
17321 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
17322 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
17323 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
17324 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
17325 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
17326 | peer->ttl); | |
17327 | } | |
17328 | } | |
17329 | ||
97a52c82 DA |
17330 | /* aigp */ |
17331 | if (peergroup_flag_check(peer, PEER_FLAG_AIGP)) | |
17332 | vty_out(vty, " neighbor %s aigp\n", addr); | |
17333 | ||
4f770cf1 DA |
17334 | /* graceful-shutdown */ |
17335 | if (peergroup_flag_check(peer, PEER_FLAG_GRACEFUL_SHUTDOWN)) | |
17336 | vty_out(vty, " neighbor %s graceful-shutdown\n", addr); | |
17337 | ||
d864dd9e | 17338 | /* role */ |
7dddd1f7 DA |
17339 | if (peergroup_flag_check(peer, PEER_FLAG_ROLE) && |
17340 | peer->local_role != ROLE_UNDEFINED) | |
d864dd9e | 17341 | vty_out(vty, " neighbor %s local-role %s%s\n", addr, |
8f2d6021 | 17342 | bgp_get_name_by_role(peer->local_role), |
7dddd1f7 | 17343 | CHECK_FLAG(peer->flags, PEER_FLAG_ROLE_STRICT_MODE) |
d864dd9e EB |
17344 | ? " strict-mode" |
17345 | : ""); | |
d864dd9e | 17346 | |
dd65f45e | 17347 | /* ttl-security hops */ |
e2521429 | 17348 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
17349 | if (!peer_group_active(peer) |
17350 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
17351 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
17352 | addr, peer->gtsm_hops); | |
17353 | } | |
17354 | } | |
17355 | ||
17356 | /* disable-connected-check */ | |
17357 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
17358 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
17359 | ||
27aa23a4 DA |
17360 | /* link-bw-encoding-ieee */ |
17361 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
17362 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
17363 | addr); | |
17364 | ||
d08c0c80 DA |
17365 | /* extended-optional-parameters */ |
17366 | if (peergroup_flag_check(peer, PEER_FLAG_EXTENDED_OPT_PARAMS)) | |
17367 | vty_out(vty, " neighbor %s extended-optional-parameters\n", | |
17368 | addr); | |
17369 | ||
dd65f45e DL |
17370 | /* enforce-first-as */ |
17371 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
17372 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
17373 | ||
17374 | /* update-source */ | |
17375 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
17376 | if (peer->update_source) | |
47e12884 DA |
17377 | vty_out(vty, " neighbor %s update-source %pSU\n", addr, |
17378 | peer->update_source); | |
dd65f45e DL |
17379 | else if (peer->update_if) |
17380 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
17381 | peer->update_if); | |
17382 | } | |
17383 | ||
17384 | /* advertisement-interval */ | |
17385 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
17386 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
17387 | peer->routeadv); | |
17388 | ||
17389 | /* timers */ | |
17390 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
17391 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
17392 | peer->keepalive, peer->holdtime); | |
17393 | ||
17394 | /* timers connect */ | |
17395 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
17396 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17397 | peer->connect); | |
5d5393b9 DL |
17398 | /* need special-case handling for changed default values due to |
17399 | * config profile / version (because there is no "timers bgp connect" | |
17400 | * command, we need to save this per-peer :/) | |
17401 | */ | |
17402 | else if (!peer_group_active(peer) && !peer->connect && | |
17403 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
17404 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17405 | peer->bgp->default_connect_retry); | |
dd65f45e | 17406 | |
d43114f3 DS |
17407 | /* timers delayopen */ |
17408 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
17409 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17410 | peer->delayopen); | |
17411 | /* Save config even though flag is not set if default values have been | |
17412 | * changed | |
17413 | */ | |
17414 | else if (!peer_group_active(peer) && !peer->delayopen | |
17415 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
17416 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17417 | peer->bgp->default_delayopen); | |
17418 | ||
dd65f45e DL |
17419 | /* capability dynamic */ |
17420 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
17421 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
17422 | ||
17423 | /* capability extended-nexthop */ | |
17424 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
8e89adc1 DS |
17425 | if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE) && |
17426 | !peer->conf_if) | |
843770f6 DA |
17427 | vty_out(vty, |
17428 | " no neighbor %s capability extended-nexthop\n", | |
17429 | addr); | |
17430 | else if (!peer->conf_if) | |
17431 | vty_out(vty, | |
17432 | " neighbor %s capability extended-nexthop\n", | |
17433 | addr); | |
dd65f45e DL |
17434 | } |
17435 | ||
17436 | /* dont-capability-negotiation */ | |
17437 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
17438 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
17439 | ||
17440 | /* override-capability */ | |
17441 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
17442 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
17443 | ||
17444 | /* strict-capability-match */ | |
17445 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
17446 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
17447 | ||
17448 | /* Sender side AS path loop detection. */ | |
17449 | if (peer->as_path_loop_detection) | |
17450 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
17451 | addr); | |
cfd47646 | 17452 | |
a5c6a9b1 DA |
17453 | /* path-attribute discard */ |
17454 | char discard_attrs_str[BUFSIZ] = {0}; | |
17455 | bool discard_attrs = bgp_path_attribute_discard( | |
17456 | peer, discard_attrs_str, sizeof(discard_attrs_str)); | |
17457 | ||
17458 | if (discard_attrs) | |
17459 | vty_out(vty, " neighbor %s path-attribute discard %s\n", addr, | |
17460 | discard_attrs_str); | |
17461 | ||
cfd47646 | 17462 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, |
13909c4f | 17463 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 17464 | |
17465 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17466 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 17467 | vty_out(vty, |
17468 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
17469 | } else if (CHECK_FLAG( |
17470 | peer->peer_gr_new_status_flag, | |
17471 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 17472 | vty_out(vty, |
17473 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
17474 | } else if ( |
17475 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
17476 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
17477 | && !(CHECK_FLAG( | |
17478 | peer->peer_gr_new_status_flag, | |
17479 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
17480 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
17481 | addr); | |
cfd47646 | 17482 | } |
17483 | } | |
dd65f45e DL |
17484 | } |
17485 | ||
17486 | /* BGP peer configuration display function. */ | |
17487 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
17488 | struct peer *peer, afi_t afi, safi_t safi) | |
17489 | { | |
17490 | struct peer *g_peer = NULL; | |
17491 | char *addr; | |
17492 | bool flag_scomm, flag_secomm, flag_slcomm; | |
17493 | ||
17494 | /* Skip dynamic neighbors. */ | |
17495 | if (peer_dynamic_neighbor(peer)) | |
17496 | return; | |
17497 | ||
17498 | if (peer->conf_if) | |
17499 | addr = peer->conf_if; | |
17500 | else | |
17501 | addr = peer->host; | |
17502 | ||
17503 | /************************************ | |
17504 | ****** Per AF to the neighbor ****** | |
17505 | ************************************/ | |
17506 | if (peer_group_active(peer)) { | |
17507 | g_peer = peer->group->conf; | |
17508 | ||
17509 | /* If the peer-group is active but peer is not, print a 'no | |
17510 | * activate' */ | |
17511 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
17512 | vty_out(vty, " no neighbor %s activate\n", addr); | |
17513 | } | |
17514 | ||
17515 | /* If the peer-group is not active but peer is, print an | |
17516 | 'activate' */ | |
17517 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
17518 | vty_out(vty, " neighbor %s activate\n", addr); | |
17519 | } | |
17520 | } else { | |
17521 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
17522 | if (safi == SAFI_ENCAP) |
17523 | vty_out(vty, " neighbor %s activate\n", addr); | |
17524 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
17525 | vty_out(vty, " neighbor %s activate\n", addr); |
17526 | } else { | |
38d11af5 TA |
17527 | if (bgp->default_af[afi][safi]) |
17528 | vty_out(vty, " no neighbor %s activate\n", | |
17529 | addr); | |
dd65f45e DL |
17530 | } |
17531 | } | |
17532 | ||
17533 | /* addpath TX knobs */ | |
17534 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
17535 | switch (peer->addpath_type[afi][safi]) { | |
17536 | case BGP_ADDPATH_ALL: | |
17537 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
17538 | addr); | |
17539 | break; | |
17540 | case BGP_ADDPATH_BEST_PER_AS: | |
17541 | vty_out(vty, | |
17542 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
17543 | addr); | |
17544 | break; | |
17545 | case BGP_ADDPATH_MAX: | |
17546 | case BGP_ADDPATH_NONE: | |
17547 | break; | |
17548 | } | |
17549 | } | |
17550 | ||
7c0e4312 DA |
17551 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
17552 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
17553 | ||
dd65f45e DL |
17554 | /* ORF capability. */ |
17555 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
17556 | || peergroup_af_flag_check(peer, afi, safi, | |
17557 | PEER_FLAG_ORF_PREFIX_RM)) { | |
17558 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
17559 | ||
17560 | if (peergroup_af_flag_check(peer, afi, safi, | |
17561 | PEER_FLAG_ORF_PREFIX_SM) | |
17562 | && peergroup_af_flag_check(peer, afi, safi, | |
17563 | PEER_FLAG_ORF_PREFIX_RM)) | |
17564 | vty_out(vty, " both"); | |
17565 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17566 | PEER_FLAG_ORF_PREFIX_SM)) | |
17567 | vty_out(vty, " send"); | |
17568 | else | |
17569 | vty_out(vty, " receive"); | |
17570 | vty_out(vty, "\n"); | |
17571 | } | |
17572 | ||
dd65f45e DL |
17573 | /* Route reflector client. */ |
17574 | if (peergroup_af_flag_check(peer, afi, safi, | |
17575 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
17576 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
17577 | } | |
17578 | ||
17579 | /* next-hop-self force */ | |
17580 | if (peergroup_af_flag_check(peer, afi, safi, | |
17581 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
17582 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
17583 | } | |
17584 | ||
17585 | /* next-hop-self */ | |
17586 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
17587 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
17588 | } | |
17589 | ||
17590 | /* remove-private-AS */ | |
17591 | if (peergroup_af_flag_check(peer, afi, safi, | |
17592 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
17593 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
17594 | addr); | |
17595 | } | |
17596 | ||
17597 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17598 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
17599 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
17600 | addr); | |
17601 | } | |
17602 | ||
17603 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17604 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
17605 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
17606 | } | |
17607 | ||
17608 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17609 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
17610 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
17611 | } | |
17612 | ||
17613 | /* as-override */ | |
17614 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
17615 | vty_out(vty, " neighbor %s as-override\n", addr); | |
17616 | } | |
17617 | ||
17618 | /* send-community print. */ | |
17619 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
17620 | PEER_FLAG_SEND_COMMUNITY); | |
17621 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
17622 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
17623 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
17624 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
17625 | ||
17626 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
17627 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
17628 | } else { | |
17629 | if (flag_scomm) | |
17630 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
17631 | if (flag_secomm) | |
17632 | vty_out(vty, | |
17633 | " no neighbor %s send-community extended\n", | |
17634 | addr); | |
17635 | ||
17636 | if (flag_slcomm) | |
17637 | vty_out(vty, " no neighbor %s send-community large\n", | |
17638 | addr); | |
17639 | } | |
17640 | ||
17641 | /* Default information */ | |
17642 | if (peergroup_af_flag_check(peer, afi, safi, | |
17643 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
17644 | vty_out(vty, " neighbor %s default-originate", addr); | |
17645 | ||
17646 | if (peer->default_rmap[afi][safi].name) | |
17647 | vty_out(vty, " route-map %s", | |
17648 | peer->default_rmap[afi][safi].name); | |
17649 | ||
17650 | vty_out(vty, "\n"); | |
17651 | } | |
17652 | ||
17653 | /* Soft reconfiguration inbound. */ | |
17654 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
17655 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
17656 | addr); | |
17657 | } | |
17658 | ||
17659 | /* maximum-prefix. */ | |
17660 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 17661 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
17662 | peer->pmax[afi][safi]); |
17663 | ||
17664 | if (peer->pmax_threshold[afi][safi] | |
17665 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
17666 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
17667 | if (peer_af_flag_check(peer, afi, safi, | |
17668 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
17669 | vty_out(vty, " warning-only"); | |
17670 | if (peer->pmax_restart[afi][safi]) | |
17671 | vty_out(vty, " restart %u", | |
17672 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
17673 | if (peer_af_flag_check(peer, afi, safi, |
17674 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
17675 | vty_out(vty, " force"); | |
dd65f45e DL |
17676 | |
17677 | vty_out(vty, "\n"); | |
17678 | } | |
17679 | ||
fde246e8 DA |
17680 | /* maximum-prefix-out */ |
17681 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 17682 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
17683 | addr, peer->pmax_out[afi][safi]); |
17684 | ||
dd65f45e DL |
17685 | /* Route server client. */ |
17686 | if (peergroup_af_flag_check(peer, afi, safi, | |
17687 | PEER_FLAG_RSERVER_CLIENT)) { | |
17688 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
17689 | } | |
17690 | ||
17691 | /* Nexthop-local unchanged. */ | |
17692 | if (peergroup_af_flag_check(peer, afi, safi, | |
17693 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
17694 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
17695 | } | |
17696 | ||
17697 | /* allowas-in <1-10> */ | |
17698 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17699 | if (peer_af_flag_check(peer, afi, safi, | |
17700 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17701 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17702 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17703 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17704 | } else { | |
17705 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17706 | peer->allowas_in[afi][safi]); | |
17707 | } | |
17708 | } | |
17709 | ||
46dbf9d0 DA |
17710 | /* accept-own */ |
17711 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ACCEPT_OWN)) | |
17712 | vty_out(vty, " neighbor %s accept-own\n", addr); | |
17713 | ||
01da2d26 DA |
17714 | /* soo */ |
17715 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOO)) { | |
17716 | char *soo_str = ecommunity_ecom2str( | |
17717 | peer->soo[afi][safi], ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
17718 | ||
17719 | vty_out(vty, " neighbor %s soo %s\n", addr, soo_str); | |
17720 | XFREE(MTYPE_ECOMMUNITY_STR, soo_str); | |
17721 | } | |
17722 | ||
dd65f45e DL |
17723 | /* weight */ |
17724 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17725 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17726 | peer->weight[afi][safi]); | |
17727 | ||
17728 | /* Filter. */ | |
17729 | bgp_config_write_filter(vty, peer, afi, safi); | |
17730 | ||
17731 | /* atribute-unchanged. */ | |
17732 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17733 | || (safi != SAFI_EVPN | |
17734 | && peer_af_flag_check(peer, afi, safi, | |
17735 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17736 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17737 | ||
17738 | if (!peer_group_active(peer) | |
17739 | || peergroup_af_flag_check(peer, afi, safi, | |
17740 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17741 | || peergroup_af_flag_check(peer, afi, safi, | |
17742 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17743 | || peergroup_af_flag_check(peer, afi, safi, | |
17744 | PEER_FLAG_MED_UNCHANGED)) { | |
17745 | ||
17746 | vty_out(vty, | |
17747 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17748 | addr, | |
17749 | peer_af_flag_check(peer, afi, safi, | |
17750 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17751 | ? " as-path" | |
17752 | : "", | |
17753 | peer_af_flag_check(peer, afi, safi, | |
17754 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17755 | ? " next-hop" | |
17756 | : "", | |
17757 | peer_af_flag_check(peer, afi, safi, | |
17758 | PEER_FLAG_MED_UNCHANGED) | |
17759 | ? " med" | |
17760 | : ""); | |
17761 | } | |
17762 | } | |
17763 | } | |
17764 | ||
a486300b PG |
17765 | static void bgp_vpn_config_write(struct vty *vty, struct bgp *bgp, afi_t afi, |
17766 | safi_t safi) | |
17767 | { | |
17768 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
17769 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL)) | |
17770 | vty_out(vty, " no bgp retain route-target all\n"); | |
17771 | } | |
17772 | ||
dd65f45e DL |
17773 | /* Address family based peer configuration display. */ |
17774 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17775 | safi_t safi) | |
17776 | { | |
17777 | struct peer *peer; | |
17778 | struct peer_group *group; | |
17779 | struct listnode *node, *nnode; | |
17780 | ||
17781 | ||
17782 | vty_frame(vty, " !\n address-family "); | |
17783 | if (afi == AFI_IP) { | |
17784 | if (safi == SAFI_UNICAST) | |
17785 | vty_frame(vty, "ipv4 unicast"); | |
17786 | else if (safi == SAFI_LABELED_UNICAST) | |
17787 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17788 | else if (safi == SAFI_MULTICAST) | |
17789 | vty_frame(vty, "ipv4 multicast"); | |
17790 | else if (safi == SAFI_MPLS_VPN) | |
17791 | vty_frame(vty, "ipv4 vpn"); | |
17792 | else if (safi == SAFI_ENCAP) | |
17793 | vty_frame(vty, "ipv4 encap"); | |
17794 | else if (safi == SAFI_FLOWSPEC) | |
17795 | vty_frame(vty, "ipv4 flowspec"); | |
17796 | } else if (afi == AFI_IP6) { | |
17797 | if (safi == SAFI_UNICAST) | |
17798 | vty_frame(vty, "ipv6 unicast"); | |
17799 | else if (safi == SAFI_LABELED_UNICAST) | |
17800 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17801 | else if (safi == SAFI_MULTICAST) | |
17802 | vty_frame(vty, "ipv6 multicast"); | |
17803 | else if (safi == SAFI_MPLS_VPN) | |
17804 | vty_frame(vty, "ipv6 vpn"); | |
17805 | else if (safi == SAFI_ENCAP) | |
17806 | vty_frame(vty, "ipv6 encap"); | |
17807 | else if (safi == SAFI_FLOWSPEC) | |
17808 | vty_frame(vty, "ipv6 flowspec"); | |
17809 | } else if (afi == AFI_L2VPN) { | |
17810 | if (safi == SAFI_EVPN) | |
17811 | vty_frame(vty, "l2vpn evpn"); | |
17812 | } | |
17813 | vty_frame(vty, "\n"); | |
17814 | ||
17815 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17816 | ||
17817 | bgp_config_write_network(vty, bgp, afi, safi); | |
17818 | ||
17819 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17820 | ||
8a4e7fe6 DA |
17821 | /* BGP flag dampening. */ |
17822 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 17823 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 17824 | |
dd65f45e DL |
17825 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17826 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17827 | ||
17828 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17829 | /* Do not display doppelganger peers */ |
17830 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17831 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17832 | } | |
17833 | ||
17834 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17835 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17836 | ||
17837 | if (safi == SAFI_EVPN) | |
17838 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17839 | ||
17840 | if (safi == SAFI_FLOWSPEC) | |
17841 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17842 | ||
a486300b PG |
17843 | if (safi == SAFI_MPLS_VPN) |
17844 | bgp_vpn_config_write(vty, bgp, afi, safi); | |
17845 | ||
dd65f45e DL |
17846 | if (safi == SAFI_UNICAST) { |
17847 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17848 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17849 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17850 | ||
17851 | vty_out(vty, " export vpn\n"); | |
17852 | } | |
17853 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17854 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17855 | ||
17856 | vty_out(vty, " import vpn\n"); | |
17857 | } | |
17858 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17859 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17860 | char *name; | |
17861 | ||
17862 | for (ALL_LIST_ELEMENTS_RO( | |
17863 | bgp->vpn_policy[afi].import_vrf, node, | |
17864 | name)) | |
17865 | vty_out(vty, " import vrf %s\n", name); | |
17866 | } | |
17867 | } | |
17868 | ||
17869 | vty_endframe(vty, " exit-address-family\n"); | |
17870 | } | |
17871 | ||
17872 | int bgp_config_write(struct vty *vty) | |
17873 | { | |
17874 | struct bgp *bgp; | |
17875 | struct peer_group *group; | |
17876 | struct peer *peer; | |
17877 | struct listnode *node, *nnode; | |
17878 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17879 | afi_t afi; |
17880 | safi_t safi; | |
efc9b57d | 17881 | uint32_t tovpn_sid_index = 0; |
dd65f45e DL |
17882 | |
17883 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17884 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17885 | bm->rmap_update_timer); | |
17886 | ||
d70583f7 D |
17887 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17888 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17889 | if (bm->v_update_delay != bm->v_establish_wait) | |
17890 | vty_out(vty, " %d", bm->v_establish_wait); | |
17891 | vty_out(vty, "\n"); | |
17892 | } | |
17893 | ||
9acb67cb DS |
17894 | if (bm->wait_for_fib) |
17895 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17896 | ||
05bd726c | 17897 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17898 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17899 | ||
c163f297 DS |
17900 | /* No-RIB (Zebra) option flag configuration */ |
17901 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17902 | vty_out(vty, "bgp no-rib\n"); | |
17903 | ||
870791a3 IR |
17904 | if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
17905 | vty_out(vty, "bgp send-extra-data zebra\n"); | |
e46723a5 | 17906 | |
425bd64b PS |
17907 | /* BGP session DSCP value */ |
17908 | if (bm->tcp_dscp != IPTOS_PREC_INTERNETCONTROL) | |
17909 | vty_out(vty, "bgp session-dscp %u\n", bm->tcp_dscp >> 2); | |
17910 | ||
a0b937de | 17911 | /* BGP InQ limit */ |
963b7ee4 | 17912 | if (bm->inq_limit != BM_DEFAULT_Q_LIMIT) |
a0b937de SW |
17913 | vty_out(vty, "bgp input-queue-limit %u\n", bm->inq_limit); |
17914 | ||
963b7ee4 DS |
17915 | if (bm->outq_limit != BM_DEFAULT_Q_LIMIT) |
17916 | vty_out(vty, "bgp output-queue-limit %u\n", bm->outq_limit); | |
17917 | ||
dd65f45e DL |
17918 | /* BGP configuration. */ |
17919 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17920 | ||
17921 | /* skip all auto created vrf as they dont have user config */ | |
17922 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17923 | continue; | |
17924 | ||
17925 | /* Router bgp ASN */ | |
17926 | vty_out(vty, "router bgp %u", bgp->as); | |
17927 | ||
17928 | if (bgp->name) | |
17929 | vty_out(vty, " %s %s", | |
17930 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17931 | ? "view" : "vrf", bgp->name); | |
17932 | vty_out(vty, "\n"); | |
17933 | ||
17934 | /* BGP fast-external-failover. */ | |
17935 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17936 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17937 | ||
17938 | /* BGP router ID. */ | |
3a6290bd | 17939 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17940 | vty_out(vty, " bgp router-id %pI4\n", |
17941 | &bgp->router_id_static); | |
dd65f45e | 17942 | |
c208c586 S |
17943 | /* Suppress fib pending */ |
17944 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17945 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17946 | ||
dd65f45e | 17947 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17948 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17949 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17950 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17951 | CHECK_FLAG(bgp->flags, |
17952 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17953 | ? "" |
17954 | : "no "); | |
17955 | ||
17956 | /* BGP configuration. */ | |
892fedb6 | 17957 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17958 | vty_out(vty, " bgp always-compare-med\n"); |
17959 | ||
17960 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17961 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17962 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17963 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17964 | CHECK_FLAG(bgp->flags, | |
17965 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17966 | ? "" | |
17967 | : "no "); | |
dd65f45e DL |
17968 | |
17969 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17970 | if (bgp->reject_as_sets) |
dd65f45e DL |
17971 | vty_out(vty, " bgp reject-as-sets\n"); |
17972 | ||
2adac256 DA |
17973 | /* Suppress duplicate updates if the route actually not changed |
17974 | */ | |
17975 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17976 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17977 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17978 | CHECK_FLAG(bgp->flags, | |
17979 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17980 | ? "" | |
17981 | : "no "); | |
17982 | ||
1ae314be DA |
17983 | /* Send Hard Reset CEASE Notification for 'Administrative Reset' |
17984 | */ | |
17985 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET) != | |
17986 | SAVE_BGP_HARD_ADMIN_RESET) | |
17987 | vty_out(vty, " %sbgp hard-administrative-reset\n", | |
17988 | CHECK_FLAG(bgp->flags, | |
17989 | BGP_FLAG_HARD_ADMIN_RESET) | |
17990 | ? "" | |
17991 | : "no "); | |
17992 | ||
b16bcbba TA |
17993 | /* BGP default <afi>-<safi> */ |
17994 | FOREACH_AFI_SAFI (afi, safi) { | |
17995 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17996 | if (!bgp->default_af[afi][safi]) | |
17997 | vty_out(vty, " no bgp default %s\n", | |
17998 | get_bgp_default_af_flag(afi, | |
17999 | safi)); | |
18000 | } else if (bgp->default_af[afi][safi]) | |
18001 | vty_out(vty, " bgp default %s\n", | |
18002 | get_bgp_default_af_flag(afi, safi)); | |
18003 | } | |
e84c59af | 18004 | |
dd65f45e DL |
18005 | /* BGP default local-preference. */ |
18006 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
18007 | vty_out(vty, " bgp default local-preference %u\n", | |
18008 | bgp->default_local_pref); | |
18009 | ||
18010 | /* BGP default show-hostname */ | |
892fedb6 | 18011 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 18012 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 18013 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 18014 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
18015 | ? "" |
18016 | : "no "); | |
18017 | ||
aef999a2 DA |
18018 | /* BGP default show-nexthop-hostname */ |
18019 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
18020 | != SAVE_BGP_SHOW_HOSTNAME) | |
18021 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
18022 | CHECK_FLAG(bgp->flags, | |
18023 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
18024 | ? "" | |
18025 | : "no "); | |
18026 | ||
dd65f45e DL |
18027 | /* BGP default subgroup-pkt-queue-max. */ |
18028 | if (bgp->default_subgroup_pkt_queue_max | |
18029 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
18030 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
18031 | bgp->default_subgroup_pkt_queue_max); | |
18032 | ||
18033 | /* BGP client-to-client reflection. */ | |
892fedb6 | 18034 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
18035 | vty_out(vty, " no bgp client-to-client reflection\n"); |
18036 | ||
18037 | /* BGP cluster ID. */ | |
18038 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
18039 | vty_out(vty, " bgp cluster-id %pI4\n", |
18040 | &bgp->cluster_id); | |
dd65f45e DL |
18041 | |
18042 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 18043 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
18044 | vty_out(vty, |
18045 | " bgp disable-ebgp-connected-route-check\n"); | |
18046 | ||
18047 | /* Confederation identifier*/ | |
18048 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
18049 | vty_out(vty, " bgp confederation identifier %u\n", | |
18050 | bgp->confed_id); | |
18051 | ||
18052 | /* Confederation peer */ | |
18053 | if (bgp->confed_peers_cnt > 0) { | |
18054 | int i; | |
18055 | ||
18056 | vty_out(vty, " bgp confederation peers"); | |
18057 | ||
18058 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
18059 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
18060 | ||
18061 | vty_out(vty, "\n"); | |
18062 | } | |
18063 | ||
18064 | /* BGP deterministic-med. */ | |
892fedb6 | 18065 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 18066 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 18067 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
18068 | CHECK_FLAG(bgp->flags, |
18069 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
18070 | ? "" |
18071 | : "no "); | |
18072 | ||
18073 | /* BGP update-delay. */ | |
18074 | bgp_config_write_update_delay(vty, bgp); | |
18075 | ||
18076 | if (bgp->v_maxmed_onstartup | |
18077 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
18078 | vty_out(vty, " bgp max-med on-startup %u", | |
18079 | bgp->v_maxmed_onstartup); | |
18080 | if (bgp->maxmed_onstartup_value | |
18081 | != BGP_MAXMED_VALUE_DEFAULT) | |
18082 | vty_out(vty, " %u", | |
18083 | bgp->maxmed_onstartup_value); | |
18084 | vty_out(vty, "\n"); | |
18085 | } | |
18086 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
18087 | vty_out(vty, " bgp max-med administrative"); | |
18088 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
18089 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
18090 | vty_out(vty, "\n"); | |
18091 | } | |
18092 | ||
18093 | /* write quanta */ | |
18094 | bgp_config_write_wpkt_quanta(vty, bgp); | |
18095 | /* read quanta */ | |
18096 | bgp_config_write_rpkt_quanta(vty, bgp); | |
18097 | ||
18098 | /* coalesce time */ | |
18099 | bgp_config_write_coalesce_time(vty, bgp); | |
18100 | ||
05bd726c | 18101 | /* BGP per-instance graceful-shutdown */ |
18102 | /* BGP-wide settings and per-instance settings are mutually | |
18103 | * exclusive. | |
18104 | */ | |
18105 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
18106 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
18107 | vty_out(vty, " bgp graceful-shutdown\n"); | |
18108 | ||
8606be87 DA |
18109 | /* Long-lived Graceful Restart */ |
18110 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
18111 | vty_out(vty, | |
18112 | " bgp long-lived-graceful-restart stale-time %u\n", | |
18113 | bgp->llgr_stale_time); | |
18114 | ||
dd65f45e DL |
18115 | /* BGP graceful-restart. */ |
18116 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
18117 | vty_out(vty, | |
18118 | " bgp graceful-restart stalepath-time %u\n", | |
18119 | bgp->stalepath_time); | |
cfd47646 | 18120 | |
dd65f45e DL |
18121 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
18122 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
18123 | bgp->restart_time); | |
cfd47646 | 18124 | |
f2ca5c5b DA |
18125 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION) != |
18126 | SAVE_BGP_GRACEFUL_NOTIFICATION) | |
18127 | vty_out(vty, " %sbgp graceful-restart notification\n", | |
18128 | CHECK_FLAG(bgp->flags, | |
18129 | BGP_FLAG_GRACEFUL_NOTIFICATION) | |
18130 | ? "" | |
18131 | : "no "); | |
18132 | ||
cfd47646 | 18133 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) |
18134 | vty_out(vty, | |
18135 | " bgp graceful-restart select-defer-time %u\n", | |
18136 | bgp->select_defer_time); | |
18137 | ||
18138 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
18139 | vty_out(vty, " bgp graceful-restart\n"); |
18140 | ||
cfd47646 | 18141 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
18142 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
18143 | ||
dd65f45e | 18144 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 18145 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
18146 | vty_out(vty, |
18147 | " bgp graceful-restart preserve-fw-state\n"); | |
18148 | ||
d1adb448 PG |
18149 | /* BGP TCP keepalive */ |
18150 | bgp_config_tcp_keepalive(vty, bgp); | |
18151 | ||
dc95985f | 18152 | /* Stale timer for RIB */ |
18153 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
18154 | vty_out(vty, | |
18155 | " bgp graceful-restart rib-stale-time %u\n", | |
18156 | bgp->rib_stale_time); | |
18157 | ||
dd65f45e | 18158 | /* BGP bestpath method. */ |
892fedb6 | 18159 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 18160 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 18161 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
18162 | vty_out(vty, " bgp bestpath as-path confed\n"); |
18163 | ||
892fedb6 DA |
18164 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
18165 | if (CHECK_FLAG(bgp->flags, | |
18166 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
18167 | vty_out(vty, |
18168 | " bgp bestpath as-path multipath-relax as-set\n"); | |
18169 | } else { | |
18170 | vty_out(vty, | |
18171 | " bgp bestpath as-path multipath-relax\n"); | |
18172 | } | |
18173 | } | |
18174 | ||
892fedb6 | 18175 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
18176 | vty_out(vty, |
18177 | " bgp route-reflector allow-outbound-policy\n"); | |
18178 | } | |
892fedb6 | 18179 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 18180 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
97a52c82 DA |
18181 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP)) |
18182 | vty_out(vty, " bgp bestpath aigp\n"); | |
892fedb6 DA |
18183 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
18184 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 18185 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 18186 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 18187 | vty_out(vty, " confed"); |
892fedb6 DA |
18188 | if (CHECK_FLAG(bgp->flags, |
18189 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
18190 | vty_out(vty, " missing-as-worst"); |
18191 | vty_out(vty, "\n"); | |
18192 | } | |
18193 | ||
ee88563a JM |
18194 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
18195 | vty_out(vty, | |
18196 | " bgp bestpath peer-type multipath-relax\n"); | |
18197 | ||
f7e1c681 | 18198 | /* Link bandwidth handling. */ |
18199 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
18200 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
18201 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
18202 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
18203 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
18204 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
18205 | ||
dd65f45e | 18206 | /* BGP network import check. */ |
892fedb6 | 18207 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 18208 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 18209 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 18210 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
18211 | ? "" |
18212 | : "no "); | |
18213 | ||
18214 | /* BGP timers configuration. */ | |
5d5393b9 | 18215 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 18216 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
18217 | vty_out(vty, " timers bgp %u %u\n", |
18218 | bgp->default_keepalive, bgp->default_holdtime); | |
18219 | ||
b042667a TI |
18220 | /* BGP minimum holdtime configuration. */ |
18221 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
18222 | && bgp->default_min_holdtime != 0) | |
18223 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
18224 | bgp->default_min_holdtime); | |
18225 | ||
389e4f92 QY |
18226 | /* Conditional advertisement timer configuration */ |
18227 | if (bgp->condition_check_period | |
18228 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
18229 | vty_out(vty, | |
18230 | " bgp conditional-advertisement timer %u\n", | |
18231 | bgp->condition_check_period); | |
18232 | ||
dd65f45e DL |
18233 | /* peer-group */ |
18234 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
18235 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
18236 | } | |
18237 | ||
18238 | /* Normal neighbor configuration. */ | |
18239 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
18240 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
18241 | bgp_config_write_peer_global(vty, bgp, peer); | |
18242 | } | |
18243 | ||
18244 | /* listen range and limit for dynamic BGP neighbors */ | |
18245 | bgp_config_write_listen(vty, bgp); | |
18246 | ||
18247 | /* | |
18248 | * BGP default autoshutdown neighbors | |
18249 | * | |
18250 | * This must be placed after any peer and peer-group | |
18251 | * configuration, to avoid setting all peers to shutdown after | |
18252 | * a daemon restart, which is undesired behavior. (see #2286) | |
18253 | */ | |
18254 | if (bgp->autoshutdown) | |
18255 | vty_out(vty, " bgp default shutdown\n"); | |
18256 | ||
9cf59432 DS |
18257 | /* BGP instance administrative shutdown */ |
18258 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
18259 | vty_out(vty, " bgp shutdown\n"); | |
18260 | ||
8666265e DS |
18261 | if (bgp->allow_martian) |
18262 | vty_out(vty, " bgp allow-martian-nexthop\n"); | |
18263 | ||
f852eb98 PG |
18264 | if (bgp->fast_convergence) |
18265 | vty_out(vty, " bgp fast-convergence\n"); | |
18266 | ||
a0281b2e HS |
18267 | if (bgp->srv6_enabled) { |
18268 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 18269 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
18270 | vty_out(vty, " locator %s\n", |
18271 | bgp->srv6_locator_name); | |
ff7c3ee1 | 18272 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
18273 | } |
18274 | ||
efc9b57d CS |
18275 | tovpn_sid_index = bgp->tovpn_sid_index; |
18276 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
18277 | vty_out(vty, " sid vpn per-vrf export auto\n"); | |
18278 | } else if (tovpn_sid_index != 0) { | |
18279 | vty_out(vty, " sid vpn per-vrf export %d\n", | |
18280 | tovpn_sid_index); | |
18281 | } | |
a0281b2e | 18282 | |
dd65f45e DL |
18283 | /* IPv4 unicast configuration. */ |
18284 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
18285 | ||
18286 | /* IPv4 multicast configuration. */ | |
18287 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
18288 | ||
18289 | /* IPv4 labeled-unicast configuration. */ | |
18290 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
18291 | ||
18292 | /* IPv4 VPN configuration. */ | |
18293 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
18294 | ||
18295 | /* ENCAPv4 configuration. */ | |
18296 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
18297 | ||
18298 | /* FLOWSPEC v4 configuration. */ | |
18299 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
18300 | ||
18301 | /* IPv6 unicast configuration. */ | |
18302 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
18303 | ||
18304 | /* IPv6 multicast configuration. */ | |
18305 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
18306 | ||
18307 | /* IPv6 labeled-unicast configuration. */ | |
18308 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
18309 | SAFI_LABELED_UNICAST); | |
18310 | ||
18311 | /* IPv6 VPN configuration. */ | |
18312 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
18313 | ||
18314 | /* ENCAPv6 configuration. */ | |
18315 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
18316 | ||
18317 | /* FLOWSPEC v6 configuration. */ | |
18318 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
18319 | ||
18320 | /* EVPN configuration. */ | |
18321 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
18322 | ||
18323 | hook_call(bgp_inst_config_write, bgp, vty); | |
18324 | ||
49e5a4a0 | 18325 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
18326 | bgp_rfapi_cfg_write(vty, bgp); |
18327 | #endif | |
18328 | ||
07679ad9 | 18329 | vty_out(vty, "exit\n"); |
dd65f45e DL |
18330 | vty_out(vty, "!\n"); |
18331 | } | |
18332 | return 0; | |
18333 | } | |
18334 | ||
ddb5b488 | 18335 | |
718e3744 | 18336 | /* BGP node structure. */ |
d62a17ae | 18337 | static struct cmd_node bgp_node = { |
f4b8291f | 18338 | .name = "bgp", |
62b346ee | 18339 | .node = BGP_NODE, |
24389580 | 18340 | .parent_node = CONFIG_NODE, |
62b346ee | 18341 | .prompt = "%s(config-router)# ", |
612c2c15 | 18342 | .config_write = bgp_config_write, |
718e3744 | 18343 | }; |
18344 | ||
d62a17ae | 18345 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 18346 | .name = "bgp ipv4 unicast", |
62b346ee | 18347 | .node = BGP_IPV4_NODE, |
24389580 | 18348 | .parent_node = BGP_NODE, |
62b346ee | 18349 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18350 | .no_xpath = true, |
718e3744 | 18351 | }; |
18352 | ||
d62a17ae | 18353 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 18354 | .name = "bgp ipv4 multicast", |
62b346ee | 18355 | .node = BGP_IPV4M_NODE, |
24389580 | 18356 | .parent_node = BGP_NODE, |
62b346ee | 18357 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18358 | .no_xpath = true, |
718e3744 | 18359 | }; |
18360 | ||
d62a17ae | 18361 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 18362 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 18363 | .node = BGP_IPV4L_NODE, |
24389580 | 18364 | .parent_node = BGP_NODE, |
62b346ee | 18365 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18366 | .no_xpath = true, |
f51bae9c DS |
18367 | }; |
18368 | ||
d62a17ae | 18369 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 18370 | .name = "bgp ipv6 unicast", |
62b346ee | 18371 | .node = BGP_IPV6_NODE, |
24389580 | 18372 | .parent_node = BGP_NODE, |
62b346ee | 18373 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18374 | .no_xpath = true, |
718e3744 | 18375 | }; |
18376 | ||
d62a17ae | 18377 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 18378 | .name = "bgp ipv6 multicast", |
62b346ee | 18379 | .node = BGP_IPV6M_NODE, |
24389580 | 18380 | .parent_node = BGP_NODE, |
62b346ee | 18381 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18382 | .no_xpath = true, |
25ffbdc1 | 18383 | }; |
18384 | ||
d62a17ae | 18385 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 18386 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 18387 | .node = BGP_IPV6L_NODE, |
24389580 | 18388 | .parent_node = BGP_NODE, |
62b346ee | 18389 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18390 | .no_xpath = true, |
f51bae9c DS |
18391 | }; |
18392 | ||
62b346ee | 18393 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 18394 | .name = "bgp vpnv4", |
62b346ee | 18395 | .node = BGP_VPNV4_NODE, |
24389580 | 18396 | .parent_node = BGP_NODE, |
62b346ee | 18397 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18398 | .no_xpath = true, |
62b346ee | 18399 | }; |
6b0655a2 | 18400 | |
62b346ee | 18401 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 18402 | .name = "bgp vpnv6", |
62b346ee | 18403 | .node = BGP_VPNV6_NODE, |
24389580 | 18404 | .parent_node = BGP_NODE, |
62b346ee | 18405 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18406 | .no_xpath = true, |
62b346ee | 18407 | }; |
8ecd3266 | 18408 | |
62b346ee | 18409 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 18410 | .name = "bgp evpn", |
62b346ee | 18411 | .node = BGP_EVPN_NODE, |
24389580 | 18412 | .parent_node = BGP_NODE, |
62b346ee | 18413 | .prompt = "%s(config-router-evpn)# ", |
dd2c81b8 | 18414 | .no_xpath = true, |
62b346ee | 18415 | }; |
4e0b7b6d | 18416 | |
62b346ee | 18417 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 18418 | .name = "bgp evpn vni", |
62b346ee | 18419 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 18420 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 18421 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 18422 | }; |
90e60aa7 | 18423 | |
62b346ee | 18424 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 18425 | .name = "bgp ipv4 flowspec", |
62b346ee | 18426 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 18427 | .parent_node = BGP_NODE, |
62b346ee | 18428 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18429 | .no_xpath = true, |
62b346ee | 18430 | }; |
7c40bf39 | 18431 | |
62b346ee | 18432 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 18433 | .name = "bgp ipv6 flowspec", |
62b346ee | 18434 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 18435 | .parent_node = BGP_NODE, |
62b346ee | 18436 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18437 | .no_xpath = true, |
62b346ee | 18438 | }; |
7c40bf39 | 18439 | |
bfaab44d HS |
18440 | static struct cmd_node bgp_srv6_node = { |
18441 | .name = "bgp srv6", | |
18442 | .node = BGP_SRV6_NODE, | |
18443 | .parent_node = BGP_NODE, | |
18444 | .prompt = "%s(config-router-srv6)# ", | |
18445 | }; | |
18446 | ||
d62a17ae | 18447 | static void community_list_vty(void); |
1f8ae70b | 18448 | |
8c20061f DA |
18449 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
18450 | { | |
18451 | struct bgp *bgp; | |
18452 | struct peer_group *group; | |
18453 | struct listnode *lnbgp, *lnpeer; | |
18454 | ||
18455 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
18456 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
18457 | vector_set(comps, | |
18458 | XSTRDUP(MTYPE_COMPLETION, group->name)); | |
18459 | } | |
18460 | } | |
18461 | ||
18462 | static void bgp_ac_peer(vector comps, struct cmd_token *token) | |
b8a815e5 | 18463 | { |
d62a17ae | 18464 | struct bgp *bgp; |
18465 | struct peer *peer; | |
d62a17ae | 18466 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 18467 | |
d62a17ae | 18468 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
18469 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
18470 | /* only provide suggestions on the appropriate input | |
18471 | * token type, | |
18472 | * they'll otherwise show up multiple times */ | |
18473 | enum cmd_token_type match_type; | |
18474 | char *name = peer->host; | |
d48ed3e0 | 18475 | |
d62a17ae | 18476 | if (peer->conf_if) { |
18477 | match_type = VARIABLE_TKN; | |
18478 | name = peer->conf_if; | |
18479 | } else if (strchr(peer->host, ':')) | |
18480 | match_type = IPV6_TKN; | |
18481 | else | |
18482 | match_type = IPV4_TKN; | |
d48ed3e0 | 18483 | |
d62a17ae | 18484 | if (token->type != match_type) |
18485 | continue; | |
d48ed3e0 | 18486 | |
d62a17ae | 18487 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
18488 | } | |
d62a17ae | 18489 | } |
b8a815e5 DL |
18490 | } |
18491 | ||
8c20061f DA |
18492 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
18493 | { | |
18494 | bgp_ac_peer(comps, token); | |
84de1483 DA |
18495 | |
18496 | if (token->type == VARIABLE_TKN) | |
18497 | bgp_ac_peergroup(comps, token); | |
8c20061f DA |
18498 | } |
18499 | ||
b8a815e5 | 18500 | static const struct cmd_variable_handler bgp_var_neighbor[] = { |
d62a17ae | 18501 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
18502 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 18503 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 18504 | {.completions = NULL}}; |
18505 | ||
47a306a0 DS |
18506 | static const struct cmd_variable_handler bgp_var_peergroup[] = { |
18507 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
18508 | {.completions = NULL} }; | |
18509 | ||
aa24a36a DA |
18510 | DEFINE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp)); |
18511 | ||
18512 | static struct thread *t_bgp_cfg; | |
18513 | ||
18514 | bool bgp_config_inprocess(void) | |
18515 | { | |
18516 | return thread_is_scheduled(t_bgp_cfg); | |
18517 | } | |
18518 | ||
18519 | static void bgp_config_finish(struct thread *t) | |
18520 | { | |
18521 | struct listnode *node; | |
18522 | struct bgp *bgp; | |
18523 | ||
18524 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) | |
18525 | hook_call(bgp_config_end, bgp); | |
18526 | } | |
18527 | ||
18528 | static void bgp_config_start(void) | |
18529 | { | |
18530 | #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600 | |
18531 | THREAD_OFF(t_bgp_cfg); | |
18532 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18533 | BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg); | |
18534 | } | |
18535 | ||
18536 | /* When we receive a hook the configuration is read, | |
18537 | * we start a timer to make sure we postpone sending | |
18538 | * EoR before route-maps are processed. | |
18539 | * This is especially valid if using `bgp route-map delay-timer`. | |
18540 | */ | |
18541 | static void bgp_config_end(void) | |
18542 | { | |
18543 | #define BGP_POST_CONFIG_DELAY_SECONDS 1 | |
18544 | uint32_t bgp_post_config_delay = | |
18545 | thread_is_scheduled(bm->t_rmap_update) | |
18546 | ? thread_timer_remain_second(bm->t_rmap_update) | |
18547 | : BGP_POST_CONFIG_DELAY_SECONDS; | |
18548 | ||
18549 | /* If BGP config processing thread isn't running, then | |
18550 | * we can return and rely it's properly handled. | |
18551 | */ | |
18552 | if (!bgp_config_inprocess()) | |
18553 | return; | |
18554 | ||
18555 | THREAD_OFF(t_bgp_cfg); | |
18556 | ||
18557 | /* Start a new timer to make sure we don't send EoR | |
18558 | * before route-maps are processed. | |
18559 | */ | |
18560 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18561 | bgp_post_config_delay, &t_bgp_cfg); | |
18562 | } | |
18563 | ||
4cd690ae PG |
18564 | static int config_write_interface_one(struct vty *vty, struct vrf *vrf) |
18565 | { | |
18566 | int write = 0; | |
18567 | struct interface *ifp; | |
18568 | struct bgp_interface *iifp; | |
18569 | ||
18570 | FOR_ALL_INTERFACES (vrf, ifp) { | |
18571 | iifp = ifp->info; | |
18572 | if (!iifp) | |
18573 | continue; | |
18574 | ||
18575 | if_vty_config_start(vty, ifp); | |
18576 | ||
18577 | if (CHECK_FLAG(iifp->flags, | |
18578 | BGP_INTERFACE_MPLS_BGP_FORWARDING)) { | |
18579 | vty_out(vty, " mpls bgp forwarding\n"); | |
18580 | write++; | |
18581 | } | |
18582 | ||
18583 | if_vty_config_end(vty); | |
18584 | } | |
18585 | ||
18586 | return write; | |
18587 | } | |
18588 | ||
18589 | /* Configuration write function for bgpd. */ | |
18590 | static int config_write_interface(struct vty *vty) | |
18591 | { | |
18592 | int write = 0; | |
18593 | struct vrf *vrf = NULL; | |
18594 | ||
18595 | /* Display all VRF aware OSPF interface configuration */ | |
18596 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { | |
18597 | write += config_write_interface_one(vty, vrf); | |
18598 | } | |
18599 | ||
18600 | return write; | |
18601 | } | |
18602 | ||
18603 | DEFPY(mpls_bgp_forwarding, mpls_bgp_forwarding_cmd, | |
18604 | "[no$no] mpls bgp forwarding", | |
18605 | NO_STR MPLS_STR BGP_STR | |
18606 | "Enable MPLS forwarding for eBGP directly connected peers\n") | |
18607 | { | |
18608 | bool check; | |
18609 | struct bgp_interface *iifp; | |
18610 | ||
18611 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
18612 | iifp = ifp->info; | |
18613 | if (!iifp) { | |
18614 | vty_out(vty, "Interface %s not available\n", ifp->name); | |
18615 | return CMD_WARNING_CONFIG_FAILED; | |
18616 | } | |
18617 | check = CHECK_FLAG(iifp->flags, BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18618 | if (check != !no) { | |
18619 | if (no) | |
18620 | UNSET_FLAG(iifp->flags, | |
18621 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18622 | else | |
18623 | SET_FLAG(iifp->flags, | |
18624 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18625 | /* trigger a nht update on eBGP sessions */ | |
18626 | if (if_is_operative(ifp)) | |
18627 | bgp_nht_ifp_up(ifp); | |
18628 | } | |
18629 | return CMD_SUCCESS; | |
18630 | } | |
18631 | ||
a0b937de SW |
18632 | DEFPY (bgp_inq_limit, |
18633 | bgp_inq_limit_cmd, | |
18634 | "bgp input-queue-limit (1-4294967295)$limit", | |
18635 | BGP_STR | |
18636 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18637 | "Input-Queue limit\n") | |
18638 | { | |
18639 | bm->inq_limit = limit; | |
18640 | ||
18641 | return CMD_SUCCESS; | |
18642 | } | |
18643 | ||
18644 | DEFPY (no_bgp_inq_limit, | |
18645 | no_bgp_inq_limit_cmd, | |
18646 | "no bgp input-queue-limit [(1-4294967295)$limit]", | |
18647 | NO_STR | |
18648 | BGP_STR | |
18649 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18650 | "Input-Queue limit\n") | |
18651 | { | |
963b7ee4 DS |
18652 | bm->inq_limit = BM_DEFAULT_Q_LIMIT; |
18653 | ||
18654 | return CMD_SUCCESS; | |
18655 | } | |
18656 | ||
18657 | DEFPY (bgp_outq_limit, | |
18658 | bgp_outq_limit_cmd, | |
18659 | "bgp output-queue-limit (1-4294967295)$limit", | |
18660 | BGP_STR | |
18661 | "Set the BGP Output Queue limit for all peers when message parsing\n" | |
18662 | "Output-Queue limit\n") | |
18663 | { | |
18664 | bm->outq_limit = limit; | |
a0b937de SW |
18665 | |
18666 | return CMD_SUCCESS; | |
18667 | } | |
18668 | ||
963b7ee4 DS |
18669 | DEFPY (no_bgp_outq_limit, |
18670 | no_bgp_outq_limit_cmd, | |
18671 | "no bgp output-queue-limit [(1-4294967295)$limit]", | |
18672 | NO_STR | |
18673 | BGP_STR | |
18674 | "Set the BGP Output Queue limit for all peers when message parsing\n" | |
18675 | "Output-Queue limit\n") | |
18676 | { | |
18677 | bm->outq_limit = BM_DEFAULT_Q_LIMIT; | |
a0b937de SW |
18678 | |
18679 | return CMD_SUCCESS; | |
18680 | } | |
18681 | ||
963b7ee4 | 18682 | |
4cd690ae PG |
18683 | /* Initialization of BGP interface. */ |
18684 | static void bgp_vty_if_init(void) | |
18685 | { | |
18686 | /* Install interface node. */ | |
18687 | if_cmd_init(config_write_interface); | |
18688 | ||
18689 | /* "mpls bgp forwarding" commands. */ | |
18690 | install_element(INTERFACE_NODE, &mpls_bgp_forwarding_cmd); | |
18691 | } | |
18692 | ||
d62a17ae | 18693 | void bgp_vty_init(void) |
18694 | { | |
18695 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 18696 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 18697 | |
aa24a36a DA |
18698 | cmd_init_config_callbacks(bgp_config_start, bgp_config_end); |
18699 | ||
d62a17ae | 18700 | /* Install bgp top node. */ |
612c2c15 DL |
18701 | install_node(&bgp_node); |
18702 | install_node(&bgp_ipv4_unicast_node); | |
18703 | install_node(&bgp_ipv4_multicast_node); | |
18704 | install_node(&bgp_ipv4_labeled_unicast_node); | |
18705 | install_node(&bgp_ipv6_unicast_node); | |
18706 | install_node(&bgp_ipv6_multicast_node); | |
18707 | install_node(&bgp_ipv6_labeled_unicast_node); | |
18708 | install_node(&bgp_vpnv4_node); | |
18709 | install_node(&bgp_vpnv6_node); | |
18710 | install_node(&bgp_evpn_node); | |
18711 | install_node(&bgp_evpn_vni_node); | |
18712 | install_node(&bgp_flowspecv4_node); | |
18713 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 18714 | install_node(&bgp_srv6_node); |
d62a17ae | 18715 | |
18716 | /* Install default VTY commands to new nodes. */ | |
18717 | install_default(BGP_NODE); | |
18718 | install_default(BGP_IPV4_NODE); | |
18719 | install_default(BGP_IPV4M_NODE); | |
18720 | install_default(BGP_IPV4L_NODE); | |
18721 | install_default(BGP_IPV6_NODE); | |
18722 | install_default(BGP_IPV6M_NODE); | |
18723 | install_default(BGP_IPV6L_NODE); | |
18724 | install_default(BGP_VPNV4_NODE); | |
18725 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 18726 | install_default(BGP_FLOWSPECV4_NODE); |
18727 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 18728 | install_default(BGP_EVPN_NODE); |
18729 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 18730 | install_default(BGP_SRV6_NODE); |
d62a17ae | 18731 | |
a0b937de SW |
18732 | /* "global bgp inq-limit command */ |
18733 | install_element(CONFIG_NODE, &bgp_inq_limit_cmd); | |
18734 | install_element(CONFIG_NODE, &no_bgp_inq_limit_cmd); | |
963b7ee4 DS |
18735 | install_element(CONFIG_NODE, &bgp_outq_limit_cmd); |
18736 | install_element(CONFIG_NODE, &no_bgp_outq_limit_cmd); | |
a0b937de | 18737 | |
8029b216 AK |
18738 | /* "bgp local-mac" hidden commands. */ |
18739 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
18740 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
18741 | ||
9acb67cb DS |
18742 | /* "bgp suppress-fib-pending" global */ |
18743 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
18744 | ||
d62a17ae | 18745 | /* bgp route-map delay-timer commands. */ |
18746 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18747 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18748 | ||
8666265e DS |
18749 | install_element(BGP_NODE, &bgp_allow_martian_cmd); |
18750 | ||
f852eb98 PG |
18751 | /* bgp fast-convergence command */ |
18752 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
18753 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
18754 | ||
d70583f7 D |
18755 | /* global bgp update-delay command */ |
18756 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
18757 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
18758 | ||
05bd726c | 18759 | /* global bgp graceful-shutdown command */ |
18760 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
18761 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
18762 | ||
d62a17ae | 18763 | /* Dummy commands (Currently not supported) */ |
18764 | install_element(BGP_NODE, &no_synchronization_cmd); | |
18765 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
18766 | ||
18767 | /* "router bgp" commands. */ | |
18768 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
18769 | ||
18770 | /* "no router bgp" commands. */ | |
18771 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
18772 | ||
425bd64b PS |
18773 | /* "bgp session-dscp command */ |
18774 | install_element(CONFIG_NODE, &bgp_session_dscp_cmd); | |
18775 | install_element(CONFIG_NODE, &no_bgp_session_dscp_cmd); | |
18776 | ||
d62a17ae | 18777 | /* "bgp router-id" commands. */ |
18778 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
18779 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
18780 | ||
c208c586 S |
18781 | /* "bgp suppress-fib-pending" command */ |
18782 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
18783 | ||
d62a17ae | 18784 | /* "bgp cluster-id" commands. */ |
18785 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
18786 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
18787 | ||
c163f297 DS |
18788 | /* "bgp no-rib" commands. */ |
18789 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
18790 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
18791 | ||
e46723a5 DS |
18792 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
18793 | ||
d62a17ae | 18794 | /* "bgp confederation" commands. */ |
18795 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
18796 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
18797 | ||
18798 | /* "bgp confederation peers" commands. */ | |
18799 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
18800 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
18801 | ||
18802 | /* bgp max-med command */ | |
18803 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
18804 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
18805 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
18806 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
18807 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
18808 | ||
d864dd9e EB |
18809 | /* "neighbor role" commands. */ |
18810 | install_element(BGP_NODE, &neighbor_role_cmd); | |
18811 | install_element(BGP_NODE, &neighbor_role_strict_cmd); | |
18812 | install_element(BGP_NODE, &no_neighbor_role_cmd); | |
18813 | ||
97a52c82 DA |
18814 | /* "neighbor aigp" commands. */ |
18815 | install_element(BGP_NODE, &neighbor_aigp_cmd); | |
18816 | ||
4f770cf1 DA |
18817 | /* "neighbor graceful-shutdown" command */ |
18818 | install_element(BGP_NODE, &neighbor_graceful_shutdown_cmd); | |
18819 | ||
d62a17ae | 18820 | /* bgp disable-ebgp-connected-nh-check */ |
18821 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
18822 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
18823 | ||
18824 | /* bgp update-delay command */ | |
18825 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
18826 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 18827 | |
18828 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 18829 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 18830 | |
18831 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
18832 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
18833 | ||
18834 | /* "maximum-paths" commands. */ | |
18835 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
18836 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
18837 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
18838 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
18839 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
18840 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
18841 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
18842 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
18843 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
18844 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
18845 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18846 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18847 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
18848 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18849 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18850 | ||
39edabac PG |
18851 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
18852 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
18853 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18854 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18855 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 18856 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
18857 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
18858 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18859 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18860 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18861 | ||
18862 | /* "timers bgp" commands. */ | |
18863 | install_element(BGP_NODE, &bgp_timers_cmd); | |
18864 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
18865 | ||
b042667a TI |
18866 | /* "minimum-holdtime" commands. */ |
18867 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
18868 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
18869 | ||
d62a17ae | 18870 | /* route-map delay-timer commands - per instance for backwards compat. |
18871 | */ | |
18872 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18873 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18874 | ||
18875 | /* "bgp client-to-client reflection" commands */ | |
18876 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
18877 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
18878 | ||
18879 | /* "bgp always-compare-med" commands */ | |
18880 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
18881 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
18882 | ||
9dac9fc8 DA |
18883 | /* bgp ebgp-requires-policy */ |
18884 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
18885 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
18886 | ||
2adac256 DA |
18887 | /* bgp suppress-duplicates */ |
18888 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
18889 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
18890 | ||
fb29348a DA |
18891 | /* bgp reject-as-sets */ |
18892 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
18893 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
18894 | ||
d62a17ae | 18895 | /* "bgp deterministic-med" commands */ |
18896 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
18897 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
18898 | ||
055679e9 | 18899 | /* "bgp graceful-restart" command */ |
36235319 QY |
18900 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
18901 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 18902 | |
18903 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
18904 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
18905 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 18906 | |
18907 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
18908 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
18909 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 18910 | |
18911 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
18912 | install_element(BGP_NODE, | |
18913 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
18914 | install_element(BGP_NODE, | |
18915 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
18916 | ||
18917 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
18918 | install_element(BGP_NODE, | |
18919 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
18920 | install_element(BGP_NODE, | |
18921 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
18922 | ||
d62a17ae | 18923 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
18924 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
18925 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
18926 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 18927 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 18928 | install_element(BGP_NODE, |
18929 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 18930 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
18931 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
f2ca5c5b | 18932 | install_element(BGP_NODE, &bgp_graceful_restart_notification_cmd); |
d62a17ae | 18933 | |
d6e3c15b | 18934 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
18935 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 18936 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
18937 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 18938 | |
7f323236 DW |
18939 | /* "bgp graceful-shutdown" commands */ |
18940 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
18941 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
18942 | ||
1ae314be DA |
18943 | /* "bgp hard-administrative-reset" commands */ |
18944 | install_element(BGP_NODE, &bgp_administrative_reset_cmd); | |
18945 | ||
8606be87 DA |
18946 | /* "bgp long-lived-graceful-restart" commands */ |
18947 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
18948 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
18949 | ||
d62a17ae | 18950 | /* "bgp fast-external-failover" commands */ |
18951 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
18952 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
18953 | ||
97a52c82 DA |
18954 | /* "bgp bestpath aigp" commands */ |
18955 | install_element(BGP_NODE, &bgp_bestpath_aigp_cmd); | |
18956 | ||
d62a17ae | 18957 | /* "bgp bestpath compare-routerid" commands */ |
18958 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
18959 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
18960 | ||
18961 | /* "bgp bestpath as-path ignore" commands */ | |
18962 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
18963 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
18964 | ||
18965 | /* "bgp bestpath as-path confed" commands */ | |
18966 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
18967 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
18968 | ||
18969 | /* "bgp bestpath as-path multipath-relax" commands */ | |
18970 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
18971 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
18972 | ||
ee88563a JM |
18973 | /* "bgp bestpath peer-type multipath-relax" commands */ |
18974 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
18975 | install_element(BGP_NODE, | |
18976 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
18977 | ||
d62a17ae | 18978 | /* "bgp log-neighbor-changes" commands */ |
18979 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
18980 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
18981 | ||
18982 | /* "bgp bestpath med" commands */ | |
18983 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
18984 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
18985 | ||
f7e1c681 | 18986 | /* "bgp bestpath bandwidth" commands */ |
18987 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 18988 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 18989 | |
b16bcbba TA |
18990 | /* "no bgp default <afi>-<safi>" commands. */ |
18991 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 18992 | |
d62a17ae | 18993 | /* "bgp network import-check" commands. */ |
18994 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
18995 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
18996 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
18997 | ||
18998 | /* "bgp default local-preference" commands. */ | |
18999 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
19000 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
19001 | ||
19002 | /* bgp default show-hostname */ | |
19003 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
19004 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
19005 | ||
aef999a2 DA |
19006 | /* bgp default show-nexthop-hostname */ |
19007 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
19008 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
19009 | ||
d62a17ae | 19010 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
19011 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
19012 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
19013 | ||
19014 | /* bgp ibgp-allow-policy-mods command */ | |
19015 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
19016 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
19017 | ||
19018 | /* "bgp listen limit" commands. */ | |
19019 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
19020 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
19021 | ||
19022 | /* "bgp listen range" commands. */ | |
19023 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
19024 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
19025 | ||
8175f54a | 19026 | /* "bgp default shutdown" command */ |
f26845f9 | 19027 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
19028 | |
19029 | /* "bgp shutdown" commands */ | |
19030 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 19031 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 19032 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 19033 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 19034 | |
d62a17ae | 19035 | /* "neighbor remote-as" commands. */ |
19036 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
19037 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
19038 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
19039 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
19040 | install_element(BGP_NODE, | |
19041 | &neighbor_interface_v6only_config_remote_as_cmd); | |
19042 | install_element(BGP_NODE, &no_neighbor_cmd); | |
19043 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
19044 | ||
19045 | /* "neighbor peer-group" commands. */ | |
19046 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
19047 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
19048 | install_element(BGP_NODE, | |
19049 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
19050 | ||
19051 | /* "neighbor local-as" commands. */ | |
19052 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
19053 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
19054 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
19055 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
19056 | ||
19057 | /* "neighbor solo" commands. */ | |
19058 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
19059 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
19060 | ||
19061 | /* "neighbor password" commands. */ | |
19062 | install_element(BGP_NODE, &neighbor_password_cmd); | |
19063 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
19064 | ||
19065 | /* "neighbor activate" commands. */ | |
19066 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
19067 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
19068 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
19069 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
19070 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
19071 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
19072 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
19073 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
19074 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 19075 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
19076 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 19077 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
19078 | ||
19079 | /* "no neighbor activate" commands. */ | |
19080 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
19081 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
19082 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
19083 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
19084 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
19085 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
19086 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
19087 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
19088 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 19089 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
19090 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 19091 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
19092 | ||
19093 | /* "neighbor peer-group" set commands. */ | |
19094 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
19095 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19096 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19097 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19098 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19099 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19100 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19101 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 19102 | install_element(BGP_FLOWSPECV4_NODE, |
19103 | &neighbor_set_peer_group_hidden_cmd); | |
19104 | install_element(BGP_FLOWSPECV6_NODE, | |
19105 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 19106 | |
19107 | /* "no neighbor peer-group unset" commands. */ | |
19108 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
19109 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19110 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19111 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19112 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19113 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19114 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19115 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 19116 | install_element(BGP_FLOWSPECV4_NODE, |
19117 | &no_neighbor_set_peer_group_hidden_cmd); | |
19118 | install_element(BGP_FLOWSPECV6_NODE, | |
19119 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 19120 | |
19121 | /* "neighbor softreconfiguration inbound" commands.*/ | |
19122 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
19123 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
19124 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
19125 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19126 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
19127 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19128 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
19129 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19130 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
19131 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19132 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
19133 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19134 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
19135 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19136 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
19137 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19138 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
19139 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 19140 | install_element(BGP_FLOWSPECV4_NODE, |
19141 | &neighbor_soft_reconfiguration_cmd); | |
19142 | install_element(BGP_FLOWSPECV4_NODE, | |
19143 | &no_neighbor_soft_reconfiguration_cmd); | |
19144 | install_element(BGP_FLOWSPECV6_NODE, | |
19145 | &neighbor_soft_reconfiguration_cmd); | |
19146 | install_element(BGP_FLOWSPECV6_NODE, | |
19147 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
19148 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
19149 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 19150 | |
19151 | /* "neighbor attribute-unchanged" commands. */ | |
19152 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
19153 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
19154 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
19155 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19156 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
19157 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
19158 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
19159 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
19160 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
19161 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19162 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
19163 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
19164 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
19165 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
19166 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
19167 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19168 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
19169 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19170 | ||
19171 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
19172 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
19173 | ||
b8ad84d2 PG |
19174 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
19175 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19176 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
19177 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19178 | ||
d62a17ae | 19179 | /* "nexthop-local unchanged" commands */ |
19180 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
19181 | install_element(BGP_IPV6_NODE, | |
19182 | &no_neighbor_nexthop_local_unchanged_cmd); | |
19183 | ||
19184 | /* "neighbor next-hop-self" commands. */ | |
19185 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
19186 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
19187 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
19188 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19189 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
19190 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
19191 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
19192 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
19193 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
19194 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
19195 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
19196 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
19197 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
19198 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
19199 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
19200 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19201 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
19202 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
19203 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
19204 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 19205 | |
19206 | /* "neighbor next-hop-self force" commands. */ | |
19207 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
19208 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
19209 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19210 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19211 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
19212 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19213 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19214 | install_element(BGP_IPV4_NODE, | |
19215 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19216 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
19217 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19218 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19219 | install_element(BGP_IPV4M_NODE, | |
19220 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19221 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
19222 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19223 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19224 | install_element(BGP_IPV4L_NODE, | |
19225 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19226 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
19227 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19228 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19229 | install_element(BGP_IPV6_NODE, | |
19230 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19231 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
19232 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19233 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19234 | install_element(BGP_IPV6M_NODE, | |
19235 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19236 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
19237 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19238 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19239 | install_element(BGP_IPV6L_NODE, | |
19240 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19241 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
19242 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19243 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19244 | install_element(BGP_VPNV4_NODE, | |
19245 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19246 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
19247 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19248 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19249 | install_element(BGP_VPNV6_NODE, | |
19250 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
19251 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
19252 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 19253 | |
19254 | /* "neighbor as-override" commands. */ | |
19255 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
19256 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
19257 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
19258 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
19259 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
19260 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
19261 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
19262 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
19263 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
19264 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
19265 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
19266 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
19267 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
19268 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
19269 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
19270 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
19271 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
19272 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
19273 | ||
19274 | /* "neighbor remove-private-AS" commands. */ | |
19275 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
19276 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
19277 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
19278 | install_element(BGP_NODE, | |
19279 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
19280 | install_element(BGP_NODE, | |
19281 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
19282 | install_element(BGP_NODE, | |
19283 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
19284 | install_element(BGP_NODE, | |
19285 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19286 | install_element( | |
19287 | BGP_NODE, | |
19288 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19289 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
19290 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19291 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19292 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19293 | install_element(BGP_IPV4_NODE, | |
19294 | &neighbor_remove_private_as_replace_as_cmd); | |
19295 | install_element(BGP_IPV4_NODE, | |
19296 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19297 | install_element(BGP_IPV4_NODE, | |
19298 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19299 | install_element(BGP_IPV4_NODE, | |
19300 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19301 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
19302 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
19303 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
19304 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19305 | install_element(BGP_IPV4M_NODE, | |
19306 | &neighbor_remove_private_as_replace_as_cmd); | |
19307 | install_element(BGP_IPV4M_NODE, | |
19308 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19309 | install_element(BGP_IPV4M_NODE, | |
19310 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19311 | install_element(BGP_IPV4M_NODE, | |
19312 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19313 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
19314 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
19315 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
19316 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19317 | install_element(BGP_IPV4L_NODE, | |
19318 | &neighbor_remove_private_as_replace_as_cmd); | |
19319 | install_element(BGP_IPV4L_NODE, | |
19320 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19321 | install_element(BGP_IPV4L_NODE, | |
19322 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19323 | install_element(BGP_IPV4L_NODE, | |
19324 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19325 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
19326 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19327 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19328 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19329 | install_element(BGP_IPV6_NODE, | |
19330 | &neighbor_remove_private_as_replace_as_cmd); | |
19331 | install_element(BGP_IPV6_NODE, | |
19332 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19333 | install_element(BGP_IPV6_NODE, | |
19334 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19335 | install_element(BGP_IPV6_NODE, | |
19336 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19337 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
19338 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
19339 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
19340 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19341 | install_element(BGP_IPV6M_NODE, | |
19342 | &neighbor_remove_private_as_replace_as_cmd); | |
19343 | install_element(BGP_IPV6M_NODE, | |
19344 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19345 | install_element(BGP_IPV6M_NODE, | |
19346 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19347 | install_element(BGP_IPV6M_NODE, | |
19348 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19349 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
19350 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
19351 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
19352 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19353 | install_element(BGP_IPV6L_NODE, | |
19354 | &neighbor_remove_private_as_replace_as_cmd); | |
19355 | install_element(BGP_IPV6L_NODE, | |
19356 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19357 | install_element(BGP_IPV6L_NODE, | |
19358 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19359 | install_element(BGP_IPV6L_NODE, | |
19360 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19361 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
19362 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19363 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19364 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19365 | install_element(BGP_VPNV4_NODE, | |
19366 | &neighbor_remove_private_as_replace_as_cmd); | |
19367 | install_element(BGP_VPNV4_NODE, | |
19368 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19369 | install_element(BGP_VPNV4_NODE, | |
19370 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19371 | install_element(BGP_VPNV4_NODE, | |
19372 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19373 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
19374 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19375 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19376 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19377 | install_element(BGP_VPNV6_NODE, | |
19378 | &neighbor_remove_private_as_replace_as_cmd); | |
19379 | install_element(BGP_VPNV6_NODE, | |
19380 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19381 | install_element(BGP_VPNV6_NODE, | |
19382 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19383 | install_element(BGP_VPNV6_NODE, | |
19384 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19385 | ||
19386 | /* "neighbor send-community" commands.*/ | |
19387 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
19388 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
19389 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
19390 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
19391 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
19392 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
19393 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
19394 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
19395 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
19396 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
19397 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
19398 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
19399 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
19400 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
19401 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
19402 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
19403 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
19404 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
19405 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
19406 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
19407 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
19408 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
19409 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
19410 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
19411 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
19412 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
19413 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
19414 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
19415 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
19416 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
19417 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
19418 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
19419 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
19420 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
19421 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
19422 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
19423 | ||
19424 | /* "neighbor route-reflector" commands.*/ | |
19425 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
19426 | install_element(BGP_NODE, | |
19427 | &no_neighbor_route_reflector_client_hidden_cmd); | |
19428 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
19429 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
19430 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
19431 | install_element(BGP_IPV4M_NODE, | |
19432 | &no_neighbor_route_reflector_client_cmd); | |
19433 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
19434 | install_element(BGP_IPV4L_NODE, | |
19435 | &no_neighbor_route_reflector_client_cmd); | |
19436 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
19437 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
19438 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
19439 | install_element(BGP_IPV6M_NODE, | |
19440 | &no_neighbor_route_reflector_client_cmd); | |
19441 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
19442 | install_element(BGP_IPV6L_NODE, | |
19443 | &no_neighbor_route_reflector_client_cmd); | |
19444 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
19445 | install_element(BGP_VPNV4_NODE, | |
19446 | &no_neighbor_route_reflector_client_cmd); | |
19447 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
19448 | install_element(BGP_VPNV6_NODE, | |
19449 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 19450 | install_element(BGP_FLOWSPECV4_NODE, |
19451 | &neighbor_route_reflector_client_cmd); | |
19452 | install_element(BGP_FLOWSPECV4_NODE, | |
19453 | &no_neighbor_route_reflector_client_cmd); | |
19454 | install_element(BGP_FLOWSPECV6_NODE, | |
19455 | &neighbor_route_reflector_client_cmd); | |
19456 | install_element(BGP_FLOWSPECV6_NODE, | |
19457 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 19458 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
19459 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
19460 | ||
19461 | /* "neighbor route-server" commands.*/ | |
19462 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
19463 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
19464 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
19465 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
19466 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
19467 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
19468 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
19469 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
19470 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
19471 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
19472 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
19473 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
19474 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
19475 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
19476 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
19477 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
19478 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
19479 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
19480 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
19481 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 19482 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
19483 | install_element(BGP_FLOWSPECV4_NODE, | |
19484 | &no_neighbor_route_server_client_cmd); | |
19485 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
19486 | install_element(BGP_FLOWSPECV6_NODE, | |
19487 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 19488 | |
7c0e4312 DA |
19489 | /* "neighbor disable-addpath-rx" commands. */ |
19490 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19491 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19492 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19493 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19494 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19495 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19496 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19497 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19498 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19499 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19500 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19501 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19502 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19503 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19504 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19505 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19506 | ||
d62a17ae | 19507 | /* "neighbor addpath-tx-all-paths" commands.*/ |
19508 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
19509 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
19510 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19511 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19512 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19513 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19514 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19515 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19516 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19517 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19518 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19519 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19520 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19521 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19522 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19523 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19524 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19525 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19526 | ||
19527 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
19528 | install_element(BGP_NODE, | |
19529 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19530 | install_element(BGP_NODE, | |
19531 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19532 | install_element(BGP_IPV4_NODE, | |
19533 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19534 | install_element(BGP_IPV4_NODE, | |
19535 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19536 | install_element(BGP_IPV4M_NODE, | |
19537 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19538 | install_element(BGP_IPV4M_NODE, | |
19539 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19540 | install_element(BGP_IPV4L_NODE, | |
19541 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19542 | install_element(BGP_IPV4L_NODE, | |
19543 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19544 | install_element(BGP_IPV6_NODE, | |
19545 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19546 | install_element(BGP_IPV6_NODE, | |
19547 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19548 | install_element(BGP_IPV6M_NODE, | |
19549 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19550 | install_element(BGP_IPV6M_NODE, | |
19551 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19552 | install_element(BGP_IPV6L_NODE, | |
19553 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19554 | install_element(BGP_IPV6L_NODE, | |
19555 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19556 | install_element(BGP_VPNV4_NODE, | |
19557 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19558 | install_element(BGP_VPNV4_NODE, | |
19559 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19560 | install_element(BGP_VPNV6_NODE, | |
19561 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19562 | install_element(BGP_VPNV6_NODE, | |
19563 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19564 | ||
2b31007c RZ |
19565 | /* "neighbor sender-as-path-loop-detection" commands. */ |
19566 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
19567 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
19568 | ||
a5c6a9b1 DA |
19569 | /* "neighbor path-attribute discard" commands. */ |
19570 | install_element(BGP_NODE, &neighbor_path_attribute_discard_cmd); | |
b986d7f4 | 19571 | install_element(BGP_NODE, &no_neighbor_path_attribute_discard_cmd); |
a5c6a9b1 | 19572 | |
d62a17ae | 19573 | /* "neighbor passive" commands. */ |
19574 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
19575 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
19576 | ||
19577 | ||
19578 | /* "neighbor shutdown" commands. */ | |
19579 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
19580 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
19581 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
19582 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
19583 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
19584 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 19585 | |
19586 | /* "neighbor capability extended-nexthop" commands.*/ | |
19587 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
19588 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
19589 | ||
19590 | /* "neighbor capability orf prefix-list" commands.*/ | |
19591 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
19592 | install_element(BGP_NODE, | |
19593 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
19594 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
19595 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19596 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19597 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19598 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19599 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19600 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
19601 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19602 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19603 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19604 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19605 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19606 | ||
19607 | /* "neighbor capability dynamic" commands.*/ | |
19608 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
19609 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
19610 | ||
19611 | /* "neighbor dont-capability-negotiate" commands. */ | |
19612 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
19613 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
19614 | ||
19615 | /* "neighbor ebgp-multihop" commands. */ | |
19616 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
19617 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
19618 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
19619 | ||
19620 | /* "neighbor disable-connected-check" commands. */ | |
19621 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
19622 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
19623 | ||
7ab294ea DA |
19624 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
19625 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
19626 | install_element(BGP_NODE, | |
19627 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 19628 | |
d08c0c80 DA |
19629 | /* "neighbor extended-optional-parameters" commands. */ |
19630 | install_element(BGP_NODE, &neighbor_extended_optional_parameters_cmd); | |
19631 | install_element(BGP_NODE, | |
19632 | &no_neighbor_extended_optional_parameters_cmd); | |
19633 | ||
47cbc09b PM |
19634 | /* "neighbor enforce-first-as" commands. */ |
19635 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
19636 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
19637 | ||
d62a17ae | 19638 | /* "neighbor description" commands. */ |
19639 | install_element(BGP_NODE, &neighbor_description_cmd); | |
19640 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 19641 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 19642 | |
19643 | /* "neighbor update-source" commands. "*/ | |
19644 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
19645 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
19646 | ||
19647 | /* "neighbor default-originate" commands. */ | |
19648 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
19649 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
19650 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
19651 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
19652 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
19653 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
19654 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
19655 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
19656 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
19657 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
19658 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
19659 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
19660 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
19661 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
19662 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
19663 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
19664 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
19665 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
19666 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
19667 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
19668 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
19669 | ||
19670 | /* "neighbor port" commands. */ | |
19671 | install_element(BGP_NODE, &neighbor_port_cmd); | |
19672 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
19673 | ||
19674 | /* "neighbor weight" commands. */ | |
19675 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
19676 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
19677 | ||
19678 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
19679 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
19680 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
19681 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
19682 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
19683 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
19684 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
19685 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
19686 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
19687 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
19688 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
19689 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
19690 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
19691 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
19692 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
19693 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
19694 | ||
19695 | /* "neighbor override-capability" commands. */ | |
19696 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
19697 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
19698 | ||
19699 | /* "neighbor strict-capability-match" commands. */ | |
19700 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
19701 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
19702 | ||
19703 | /* "neighbor timers" commands. */ | |
19704 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
19705 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
19706 | ||
19707 | /* "neighbor timers connect" commands. */ | |
19708 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
19709 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
19710 | ||
d43114f3 DS |
19711 | /* "neighbor timers delayopen" commands. */ |
19712 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
19713 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
19714 | ||
d62a17ae | 19715 | /* "neighbor advertisement-interval" commands. */ |
19716 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
19717 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
19718 | ||
19719 | /* "neighbor interface" commands. */ | |
19720 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
19721 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
19722 | ||
19723 | /* "neighbor distribute" commands. */ | |
19724 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
19725 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
19726 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
19727 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
19728 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
19729 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
19730 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
19731 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
19732 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
19733 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
19734 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
19735 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
19736 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
19737 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
19738 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
19739 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
19740 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
19741 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
19742 | ||
19743 | /* "neighbor prefix-list" commands. */ | |
19744 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 19745 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 19746 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19747 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19748 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19749 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19750 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19751 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19752 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19753 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19754 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19755 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19756 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19757 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19758 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19759 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19760 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19761 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19762 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19763 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19764 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19765 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19766 | |
19767 | /* "neighbor filter-list" commands. */ | |
19768 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
19769 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
19770 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
19771 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
19772 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
19773 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
19774 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
19775 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
19776 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
19777 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
19778 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
19779 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
19780 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
19781 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
19782 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
19783 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
19784 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
19785 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 19786 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
19787 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
19788 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
19789 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 19790 | |
19791 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
19792 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
19793 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 19794 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19795 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19796 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19797 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19798 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19799 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19800 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19801 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19802 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19803 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19804 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19805 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19806 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19807 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19808 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19809 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19810 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19811 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19812 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19813 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 19814 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19815 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19816 | |
19817 | /* "neighbor unsuppress-map" commands. */ | |
19818 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
19819 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
19820 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
19821 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19822 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
19823 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19824 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
19825 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19826 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
19827 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19828 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
19829 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19830 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
19831 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19832 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
19833 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19834 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
19835 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19836 | ||
7f7940e6 | 19837 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 19838 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 19839 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 19840 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19841 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19842 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19843 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19844 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19845 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19846 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19847 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19848 | |
fde246e8 DA |
19849 | /* neighbor maximum-prefix-out commands. */ |
19850 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
19851 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19852 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19853 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19854 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19855 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19856 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19857 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19858 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19859 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19860 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19861 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19862 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19863 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19864 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19865 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19866 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19867 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19868 | ||
d62a17ae | 19869 | /* "neighbor maximum-prefix" commands. */ |
19870 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
19871 | install_element(BGP_NODE, | |
19872 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
19873 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
19874 | install_element(BGP_NODE, | |
19875 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
19876 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
19877 | install_element(BGP_NODE, | |
19878 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
19879 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
19880 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
19881 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19882 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19883 | install_element(BGP_IPV4_NODE, | |
19884 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19885 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19886 | install_element(BGP_IPV4_NODE, | |
19887 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19888 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19889 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
19890 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19891 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19892 | install_element(BGP_IPV4M_NODE, | |
19893 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19894 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19895 | install_element(BGP_IPV4M_NODE, | |
19896 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19897 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19898 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
19899 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19900 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19901 | install_element(BGP_IPV4L_NODE, | |
19902 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19903 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19904 | install_element(BGP_IPV4L_NODE, | |
19905 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19906 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19907 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
19908 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19909 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19910 | install_element(BGP_IPV6_NODE, | |
19911 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19912 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19913 | install_element(BGP_IPV6_NODE, | |
19914 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19915 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19916 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
19917 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19918 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19919 | install_element(BGP_IPV6M_NODE, | |
19920 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19921 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19922 | install_element(BGP_IPV6M_NODE, | |
19923 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19924 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19925 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
19926 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19927 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19928 | install_element(BGP_IPV6L_NODE, | |
19929 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19930 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19931 | install_element(BGP_IPV6L_NODE, | |
19932 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19933 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19934 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
19935 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19936 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19937 | install_element(BGP_VPNV4_NODE, | |
19938 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19939 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19940 | install_element(BGP_VPNV4_NODE, | |
19941 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19942 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19943 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
19944 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19945 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19946 | install_element(BGP_VPNV6_NODE, | |
19947 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19948 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19949 | install_element(BGP_VPNV6_NODE, | |
19950 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19951 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19952 | ||
19953 | /* "neighbor allowas-in" */ | |
19954 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
19955 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
19956 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
19957 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
19958 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
19959 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
19960 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
19961 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
19962 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
19963 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
19964 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
19965 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
19966 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
19967 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
19968 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
19969 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
19970 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
19971 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
19972 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
19973 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
19974 | ||
46dbf9d0 DA |
19975 | /* neighbor accept-own */ |
19976 | install_element(BGP_VPNV4_NODE, &neighbor_accept_own_cmd); | |
19977 | install_element(BGP_VPNV6_NODE, &neighbor_accept_own_cmd); | |
19978 | ||
01da2d26 DA |
19979 | /* "neighbor soo" */ |
19980 | install_element(BGP_IPV4_NODE, &neighbor_soo_cmd); | |
19981 | install_element(BGP_IPV4_NODE, &no_neighbor_soo_cmd); | |
19982 | install_element(BGP_IPV4M_NODE, &neighbor_soo_cmd); | |
19983 | install_element(BGP_IPV4M_NODE, &no_neighbor_soo_cmd); | |
19984 | install_element(BGP_IPV4L_NODE, &neighbor_soo_cmd); | |
19985 | install_element(BGP_IPV4L_NODE, &no_neighbor_soo_cmd); | |
19986 | install_element(BGP_IPV6_NODE, &neighbor_soo_cmd); | |
19987 | install_element(BGP_IPV6_NODE, &no_neighbor_soo_cmd); | |
19988 | install_element(BGP_IPV6M_NODE, &neighbor_soo_cmd); | |
19989 | install_element(BGP_IPV6M_NODE, &no_neighbor_soo_cmd); | |
19990 | install_element(BGP_IPV6L_NODE, &neighbor_soo_cmd); | |
19991 | install_element(BGP_IPV6L_NODE, &no_neighbor_soo_cmd); | |
19992 | install_element(BGP_VPNV4_NODE, &neighbor_soo_cmd); | |
19993 | install_element(BGP_VPNV4_NODE, &no_neighbor_soo_cmd); | |
19994 | install_element(BGP_VPNV6_NODE, &neighbor_soo_cmd); | |
19995 | install_element(BGP_VPNV6_NODE, &no_neighbor_soo_cmd); | |
19996 | install_element(BGP_EVPN_NODE, &neighbor_soo_cmd); | |
19997 | install_element(BGP_EVPN_NODE, &no_neighbor_soo_cmd); | |
19998 | ||
d62a17ae | 19999 | /* address-family commands. */ |
20000 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
20001 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 20002 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 20003 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
20004 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 20005 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 20006 | |
d62a17ae | 20007 | install_element(BGP_NODE, &address_family_evpn_cmd); |
20008 | ||
20009 | /* "exit-address-family" command. */ | |
20010 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
20011 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
20012 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
20013 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
20014 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
20015 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
20016 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
20017 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 20018 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
20019 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 20020 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
20021 | ||
a486300b PG |
20022 | /* BGP retain all route-target */ |
20023 | install_element(BGP_VPNV4_NODE, &bgp_retain_route_target_cmd); | |
20024 | install_element(BGP_VPNV6_NODE, &bgp_retain_route_target_cmd); | |
20025 | ||
d62a17ae | 20026 | /* "clear ip bgp commands" */ |
20027 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
20028 | ||
20029 | /* clear ip bgp prefix */ | |
20030 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
20031 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
20032 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
20033 | ||
20034 | /* "show [ip] bgp summary" commands. */ | |
20035 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 20036 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 20037 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 20038 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 20039 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
20040 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 20041 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
20042 | ||
20043 | /* "show [ip] bgp neighbors" commands. */ | |
20044 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
20045 | ||
36235319 | 20046 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 20047 | |
d62a17ae | 20048 | /* "show [ip] bgp peer-group" commands. */ |
20049 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
20050 | ||
20051 | /* "show [ip] bgp paths" commands. */ | |
20052 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
20053 | ||
20054 | /* "show [ip] bgp community" commands. */ | |
20055 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
20056 | ||
20057 | /* "show ip bgp large-community" commands. */ | |
20058 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
20059 | /* "show [ip] bgp attribute-info" commands. */ | |
20060 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 20061 | /* "show [ip] bgp route-leak" command */ |
20062 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 20063 | |
20064 | /* "redistribute" commands. */ | |
20065 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
20066 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
20067 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
20068 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
20069 | install_element(BGP_NODE, | |
20070 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
20071 | install_element(BGP_NODE, | |
20072 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
20073 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
20074 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
20075 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
20076 | install_element(BGP_NODE, | |
20077 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
20078 | install_element(BGP_NODE, | |
20079 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
20080 | install_element(BGP_NODE, | |
20081 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
20082 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
20083 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
20084 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
20085 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
20086 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
20087 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
20088 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
20089 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
20090 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
20091 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
20092 | install_element(BGP_IPV4_NODE, | |
20093 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
20094 | install_element(BGP_IPV4_NODE, | |
20095 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
20096 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
20097 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
20098 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
20099 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
20100 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
20101 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
20102 | ||
70dd370f | 20103 | /* import|export vpn [route-map RMAP_NAME] */ |
b9c7bc5a PZ |
20104 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); |
20105 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 20106 | |
12a844a5 DS |
20107 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
20108 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
20109 | ||
d62a17ae | 20110 | /* ttl_security commands */ |
20111 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
20112 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
20113 | ||
d1adb448 PG |
20114 | /* "bgp tcp-keepalive" commands */ |
20115 | install_element(BGP_NODE, &bgp_tcp_keepalive_cmd); | |
20116 | install_element(BGP_NODE, &no_bgp_tcp_keepalive_cmd); | |
20117 | ||
d62a17ae | 20118 | /* "show [ip] bgp memory" commands. */ |
20119 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
20120 | ||
acf71666 MK |
20121 | /* "show bgp martian next-hop" */ |
20122 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
20123 | ||
48ecf8f5 DS |
20124 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
20125 | ||
d62a17ae | 20126 | /* "show [ip] bgp views" commands. */ |
20127 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
20128 | ||
20129 | /* "show [ip] bgp vrfs" commands. */ | |
20130 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
20131 | ||
20132 | /* Community-list. */ | |
20133 | community_list_vty(); | |
ddb5b488 | 20134 | |
ed0e57e3 DA |
20135 | community_alias_vty(); |
20136 | ||
ddb5b488 | 20137 | /* vpn-policy commands */ |
b9c7bc5a PZ |
20138 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
20139 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
20140 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
20141 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
20142 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
20143 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
20144 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
20145 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
20146 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
20147 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20148 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
20149 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 20150 | |
301ad80a PG |
20151 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
20152 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
20153 | ||
b9c7bc5a PZ |
20154 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
20155 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
20156 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
20157 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
20158 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
20159 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
20160 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
20161 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20162 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
20163 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
20164 | |
20165 | /* tcp-mss command */ | |
20166 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
20167 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
20168 | |
20169 | /* srv6 commands */ | |
ea372e81 | 20170 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 20171 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 20172 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 20173 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 20174 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
20175 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
20176 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
527588aa | 20177 | install_element(BGP_NODE, &bgp_sid_vpn_export_cmd); |
e606d8ec | 20178 | install_element(BGP_NODE, &no_bgp_sid_vpn_export_cmd); |
4cd690ae PG |
20179 | |
20180 | bgp_vty_if_init(); | |
718e3744 | 20181 | } |
6b0655a2 | 20182 | |
718e3744 | 20183 | #include "memory.h" |
20184 | #include "bgp_regex.h" | |
20185 | #include "bgp_clist.h" | |
20186 | #include "bgp_ecommunity.h" | |
20187 | ||
20188 | /* VTY functions. */ | |
20189 | ||
20190 | /* Direction value to string conversion. */ | |
d62a17ae | 20191 | static const char *community_direct_str(int direct) |
20192 | { | |
20193 | switch (direct) { | |
20194 | case COMMUNITY_DENY: | |
20195 | return "deny"; | |
20196 | case COMMUNITY_PERMIT: | |
20197 | return "permit"; | |
20198 | default: | |
20199 | return "unknown"; | |
20200 | } | |
718e3744 | 20201 | } |
20202 | ||
20203 | /* Display error string. */ | |
d62a17ae | 20204 | static void community_list_perror(struct vty *vty, int ret) |
20205 | { | |
20206 | switch (ret) { | |
20207 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
20208 | vty_out(vty, "%% Can't find community-list\n"); | |
20209 | break; | |
20210 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
20211 | vty_out(vty, "%% Malformed community-list value\n"); | |
20212 | break; | |
20213 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
20214 | vty_out(vty, | |
20215 | "%% Community name conflict, previously defined as standard community\n"); | |
20216 | break; | |
20217 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
20218 | vty_out(vty, | |
20219 | "%% Community name conflict, previously defined as expanded community\n"); | |
20220 | break; | |
20221 | } | |
718e3744 | 20222 | } |
20223 | ||
5bf15956 DW |
20224 | /* "community-list" keyword help string. */ |
20225 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
20226 | ||
7336e101 SP |
20227 | /*community-list standard */ |
20228 | DEFUN (community_list_standard, | |
20229 | bgp_community_list_standard_cmd, | |
a2099c1d | 20230 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20231 | BGP_STR |
718e3744 | 20232 | COMMUNITY_LIST_STR |
20233 | "Community list number (standard)\n" | |
5bf15956 | 20234 | "Add an standard community-list entry\n" |
718e3744 | 20235 | "Community list name\n" |
2f8cc0e5 DA |
20236 | "Sequence number of an entry\n" |
20237 | "Sequence number\n" | |
718e3744 | 20238 | "Specify community to reject\n" |
20239 | "Specify community to accept\n" | |
20240 | COMMUNITY_VAL_STR) | |
20241 | { | |
d62a17ae | 20242 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20243 | char *seq = NULL; |
d62a17ae | 20244 | int direct = 0; |
20245 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 20246 | int idx = 0; |
7336e101 | 20247 | |
e34627f9 | 20248 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20249 | seq = argv[idx]->arg; |
20250 | ||
20251 | idx = 0; | |
d62a17ae | 20252 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20253 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20254 | cl_name_or_number = argv[idx]->arg; |
20255 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20256 | : COMMUNITY_DENY; | |
20257 | argv_find(argv, argc, "AA:NN", &idx); | |
20258 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20259 | |
2f8cc0e5 DA |
20260 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20261 | direct, style); | |
42f914d4 | 20262 | |
d62a17ae | 20263 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20264 | |
d62a17ae | 20265 | if (ret < 0) { |
20266 | /* Display error string. */ | |
20267 | community_list_perror(vty, ret); | |
20268 | return CMD_WARNING_CONFIG_FAILED; | |
20269 | } | |
42f914d4 | 20270 | |
d62a17ae | 20271 | return CMD_SUCCESS; |
718e3744 | 20272 | } |
20273 | ||
7336e101 SP |
20274 | DEFUN (no_community_list_standard_all, |
20275 | no_bgp_community_list_standard_all_cmd, | |
a2099c1d | 20276 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20277 | NO_STR |
20278 | BGP_STR | |
20279 | COMMUNITY_LIST_STR | |
20280 | "Community list number (standard)\n" | |
20281 | "Add an standard community-list entry\n" | |
20282 | "Community list name\n" | |
2f8cc0e5 DA |
20283 | "Sequence number of an entry\n" |
20284 | "Sequence number\n" | |
7336e101 SP |
20285 | "Specify community to reject\n" |
20286 | "Specify community to accept\n" | |
20287 | COMMUNITY_VAL_STR) | |
718e3744 | 20288 | { |
d62a17ae | 20289 | char *cl_name_or_number = NULL; |
174b5cb9 | 20290 | char *str = NULL; |
d62a17ae | 20291 | int direct = 0; |
20292 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 20293 | char *seq = NULL; |
d62a17ae | 20294 | int idx = 0; |
7336e101 | 20295 | |
e34627f9 | 20296 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20297 | seq = argv[idx]->arg; |
20298 | ||
20299 | idx = 0; | |
174b5cb9 DA |
20300 | argv_find(argv, argc, "permit", &idx); |
20301 | argv_find(argv, argc, "deny", &idx); | |
20302 | ||
20303 | if (idx) { | |
20304 | direct = argv_find(argv, argc, "permit", &idx) | |
20305 | ? COMMUNITY_PERMIT | |
20306 | : COMMUNITY_DENY; | |
20307 | ||
20308 | idx = 0; | |
20309 | argv_find(argv, argc, "AA:NN", &idx); | |
20310 | str = argv_concat(argv, argc, idx); | |
20311 | } | |
20312 | ||
20313 | idx = 0; | |
d62a17ae | 20314 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20315 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20316 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20317 | |
2f8cc0e5 | 20318 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20319 | direct, style); |
42f914d4 | 20320 | |
d62a17ae | 20321 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20322 | |
d62a17ae | 20323 | if (ret < 0) { |
20324 | community_list_perror(vty, ret); | |
20325 | return CMD_WARNING_CONFIG_FAILED; | |
20326 | } | |
42f914d4 | 20327 | |
d62a17ae | 20328 | return CMD_SUCCESS; |
718e3744 | 20329 | } |
7336e101 | 20330 | |
174b5cb9 | 20331 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
a2099c1d | 20332 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", |
174b5cb9 DA |
20333 | NO_STR BGP_STR COMMUNITY_LIST_STR |
20334 | "Community list number (standard)\n" | |
20335 | "Add an standard community-list entry\n" | |
20336 | "Community list name\n") | |
20337 | ||
7336e101 SP |
20338 | /*community-list expanded */ |
20339 | DEFUN (community_list_expanded_all, | |
20340 | bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20341 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20342 | BGP_STR |
20343 | COMMUNITY_LIST_STR | |
718e3744 | 20344 | "Community list number (expanded)\n" |
5bf15956 | 20345 | "Add an expanded community-list entry\n" |
718e3744 | 20346 | "Community list name\n" |
2f8cc0e5 DA |
20347 | "Sequence number of an entry\n" |
20348 | "Sequence number\n" | |
718e3744 | 20349 | "Specify community to reject\n" |
20350 | "Specify community to accept\n" | |
20351 | COMMUNITY_VAL_STR) | |
20352 | { | |
d62a17ae | 20353 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20354 | char *seq = NULL; |
d62a17ae | 20355 | int direct = 0; |
20356 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20357 | int idx = 0; |
7b9a4750 | 20358 | |
e34627f9 | 20359 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20360 | seq = argv[idx]->arg; |
20361 | ||
20362 | idx = 0; | |
20363 | ||
d62a17ae | 20364 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20365 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20366 | cl_name_or_number = argv[idx]->arg; |
20367 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20368 | : COMMUNITY_DENY; | |
20369 | argv_find(argv, argc, "AA:NN", &idx); | |
20370 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20371 | |
2f8cc0e5 DA |
20372 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20373 | direct, style); | |
42f914d4 | 20374 | |
d62a17ae | 20375 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20376 | |
d62a17ae | 20377 | if (ret < 0) { |
20378 | /* Display error string. */ | |
20379 | community_list_perror(vty, ret); | |
20380 | return CMD_WARNING_CONFIG_FAILED; | |
20381 | } | |
42f914d4 | 20382 | |
d62a17ae | 20383 | return CMD_SUCCESS; |
718e3744 | 20384 | } |
20385 | ||
7336e101 SP |
20386 | DEFUN (no_community_list_expanded_all, |
20387 | no_bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20388 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20389 | NO_STR |
20390 | BGP_STR | |
20391 | COMMUNITY_LIST_STR | |
20392 | "Community list number (expanded)\n" | |
20393 | "Add an expanded community-list entry\n" | |
20394 | "Community list name\n" | |
2f8cc0e5 DA |
20395 | "Sequence number of an entry\n" |
20396 | "Sequence number\n" | |
7336e101 SP |
20397 | "Specify community to reject\n" |
20398 | "Specify community to accept\n" | |
20399 | COMMUNITY_VAL_STR) | |
718e3744 | 20400 | { |
d62a17ae | 20401 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20402 | char *seq = NULL; |
174b5cb9 | 20403 | char *str = NULL; |
d62a17ae | 20404 | int direct = 0; |
20405 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20406 | int idx = 0; |
174b5cb9 | 20407 | |
e34627f9 | 20408 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20409 | seq = argv[idx]->arg; |
20410 | ||
20411 | idx = 0; | |
174b5cb9 DA |
20412 | argv_find(argv, argc, "permit", &idx); |
20413 | argv_find(argv, argc, "deny", &idx); | |
20414 | ||
20415 | if (idx) { | |
20416 | direct = argv_find(argv, argc, "permit", &idx) | |
20417 | ? COMMUNITY_PERMIT | |
20418 | : COMMUNITY_DENY; | |
20419 | ||
20420 | idx = 0; | |
20421 | argv_find(argv, argc, "AA:NN", &idx); | |
20422 | str = argv_concat(argv, argc, idx); | |
7336e101 | 20423 | } |
174b5cb9 DA |
20424 | |
20425 | idx = 0; | |
d62a17ae | 20426 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20427 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20428 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20429 | |
2f8cc0e5 | 20430 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20431 | direct, style); |
42f914d4 | 20432 | |
d62a17ae | 20433 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20434 | |
d62a17ae | 20435 | if (ret < 0) { |
20436 | community_list_perror(vty, ret); | |
20437 | return CMD_WARNING_CONFIG_FAILED; | |
20438 | } | |
42f914d4 | 20439 | |
d62a17ae | 20440 | return CMD_SUCCESS; |
718e3744 | 20441 | } |
20442 | ||
36d4bb44 EB |
20443 | ALIAS(no_community_list_expanded_all, |
20444 | no_bgp_community_list_expanded_all_list_cmd, | |
a2099c1d | 20445 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", |
36d4bb44 | 20446 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
20447 | "Community list number (expanded)\n" |
20448 | "Add an expanded community-list entry\n" | |
20449 | "Community list name\n") | |
20450 | ||
8d9b8ed9 PM |
20451 | /* Return configuration string of community-list entry. */ |
20452 | static const char *community_list_config_str(struct community_entry *entry) | |
20453 | { | |
20454 | const char *str; | |
20455 | ||
20456 | if (entry->any) | |
20457 | str = ""; | |
20458 | else { | |
20459 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
c0945b78 | 20460 | str = community_str(entry->u.com, false, false); |
8d9b8ed9 | 20461 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) |
c0945b78 | 20462 | str = lcommunity_str(entry->u.lcom, false, false); |
8d9b8ed9 PM |
20463 | else |
20464 | str = entry->config; | |
20465 | } | |
20466 | return str; | |
20467 | } | |
20468 | ||
d62a17ae | 20469 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20470 | { |
d62a17ae | 20471 | struct community_entry *entry; |
718e3744 | 20472 | |
d62a17ae | 20473 | for (entry = list->head; entry; entry = entry->next) { |
20474 | if (entry == list->head) { | |
20475 | if (all_digit(list->name)) | |
20476 | vty_out(vty, "Community %s list %s\n", | |
20477 | entry->style == COMMUNITY_LIST_STANDARD | |
20478 | ? "standard" | |
20479 | : "(expanded) access", | |
20480 | list->name); | |
20481 | else | |
20482 | vty_out(vty, "Named Community %s list %s\n", | |
20483 | entry->style == COMMUNITY_LIST_STANDARD | |
20484 | ? "standard" | |
20485 | : "expanded", | |
20486 | list->name); | |
20487 | } | |
20488 | if (entry->any) | |
20489 | vty_out(vty, " %s\n", | |
20490 | community_direct_str(entry->direct)); | |
20491 | else | |
20492 | vty_out(vty, " %s %s\n", | |
20493 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20494 | community_list_config_str(entry)); |
d62a17ae | 20495 | } |
718e3744 | 20496 | } |
20497 | ||
7336e101 SP |
20498 | DEFUN (show_community_list, |
20499 | show_bgp_community_list_cmd, | |
20500 | "show bgp community-list", | |
718e3744 | 20501 | SHOW_STR |
7336e101 | 20502 | BGP_STR |
718e3744 | 20503 | "List community-list\n") |
20504 | { | |
d62a17ae | 20505 | struct community_list *list; |
20506 | struct community_list_master *cm; | |
718e3744 | 20507 | |
d62a17ae | 20508 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
20509 | if (!cm) | |
20510 | return CMD_SUCCESS; | |
718e3744 | 20511 | |
d62a17ae | 20512 | for (list = cm->num.head; list; list = list->next) |
20513 | community_list_show(vty, list); | |
718e3744 | 20514 | |
d62a17ae | 20515 | for (list = cm->str.head; list; list = list->next) |
20516 | community_list_show(vty, list); | |
718e3744 | 20517 | |
d62a17ae | 20518 | return CMD_SUCCESS; |
718e3744 | 20519 | } |
20520 | ||
7336e101 SP |
20521 | DEFUN (show_community_list_arg, |
20522 | show_bgp_community_list_arg_cmd, | |
a2099c1d | 20523 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20524 | SHOW_STR |
20525 | BGP_STR | |
718e3744 | 20526 | "List community-list\n" |
20527 | "Community-list number\n" | |
960b69b9 | 20528 | "Community-list name\n" |
20529 | "Detailed information on community-list\n") | |
718e3744 | 20530 | { |
d62a17ae | 20531 | int idx_comm_list = 3; |
20532 | struct community_list *list; | |
718e3744 | 20533 | |
e237b0d2 | 20534 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20535 | COMMUNITY_LIST_MASTER); |
20536 | if (!list) { | |
20537 | vty_out(vty, "%% Can't find community-list\n"); | |
20538 | return CMD_WARNING; | |
20539 | } | |
718e3744 | 20540 | |
d62a17ae | 20541 | community_list_show(vty, list); |
718e3744 | 20542 | |
d62a17ae | 20543 | return CMD_SUCCESS; |
718e3744 | 20544 | } |
6b0655a2 | 20545 | |
57d187bc JS |
20546 | /* |
20547 | * Large Community code. | |
20548 | */ | |
d62a17ae | 20549 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
20550 | struct cmd_token **argv, int style, | |
20551 | int reject_all_digit_name) | |
20552 | { | |
20553 | int ret; | |
20554 | int direct; | |
20555 | char *str; | |
20556 | int idx = 0; | |
20557 | char *cl_name; | |
2f8cc0e5 DA |
20558 | char *seq = NULL; |
20559 | ||
a08032fe | 20560 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20561 | seq = argv[idx]->arg; |
d62a17ae | 20562 | |
2f8cc0e5 | 20563 | idx = 0; |
d62a17ae | 20564 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20565 | : COMMUNITY_DENY; | |
20566 | ||
20567 | /* All digit name check. */ | |
20568 | idx = 0; | |
a2099c1d | 20569 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20570 | argv_find(argv, argc, "(1-99)", &idx); |
20571 | argv_find(argv, argc, "(100-500)", &idx); | |
20572 | cl_name = argv[idx]->arg; | |
20573 | if (reject_all_digit_name && all_digit(cl_name)) { | |
20574 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
20575 | return CMD_WARNING_CONFIG_FAILED; | |
20576 | } | |
20577 | ||
20578 | idx = 0; | |
20579 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
20580 | argv_find(argv, argc, "LINE", &idx); | |
20581 | /* Concat community string argument. */ | |
20582 | if (idx) | |
20583 | str = argv_concat(argv, argc, idx); | |
20584 | else | |
20585 | str = NULL; | |
20586 | ||
2f8cc0e5 | 20587 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 20588 | |
20589 | /* Free temporary community list string allocated by | |
20590 | argv_concat(). */ | |
0a22ddfb | 20591 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20592 | |
20593 | if (ret < 0) { | |
20594 | community_list_perror(vty, ret); | |
20595 | return CMD_WARNING_CONFIG_FAILED; | |
20596 | } | |
20597 | return CMD_SUCCESS; | |
20598 | } | |
20599 | ||
20600 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
20601 | struct cmd_token **argv, int style) | |
20602 | { | |
20603 | int ret; | |
20604 | int direct = 0; | |
20605 | char *str = NULL; | |
20606 | int idx = 0; | |
2f8cc0e5 | 20607 | char *seq = NULL; |
d62a17ae | 20608 | |
a08032fe | 20609 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20610 | seq = argv[idx]->arg; |
d62a17ae | 20611 | |
2f8cc0e5 | 20612 | idx = 0; |
d62a17ae | 20613 | argv_find(argv, argc, "permit", &idx); |
20614 | argv_find(argv, argc, "deny", &idx); | |
20615 | ||
20616 | if (idx) { | |
20617 | /* Check the list direct. */ | |
20618 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
20619 | direct = COMMUNITY_PERMIT; | |
20620 | else | |
20621 | direct = COMMUNITY_DENY; | |
20622 | ||
20623 | idx = 0; | |
20624 | argv_find(argv, argc, "LINE", &idx); | |
20625 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
20626 | /* Concat community string argument. */ | |
20627 | str = argv_concat(argv, argc, idx); | |
20628 | } | |
20629 | ||
20630 | idx = 0; | |
20631 | argv_find(argv, argc, "(1-99)", &idx); | |
20632 | argv_find(argv, argc, "(100-500)", &idx); | |
a2099c1d | 20633 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20634 | |
20635 | /* Unset community list. */ | |
2f8cc0e5 | 20636 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 20637 | style); |
20638 | ||
20639 | /* Free temporary community list string allocated by | |
20640 | argv_concat(). */ | |
0a22ddfb | 20641 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20642 | |
20643 | if (ret < 0) { | |
20644 | community_list_perror(vty, ret); | |
20645 | return CMD_WARNING_CONFIG_FAILED; | |
20646 | } | |
20647 | ||
20648 | return CMD_SUCCESS; | |
57d187bc JS |
20649 | } |
20650 | ||
20651 | /* "large-community-list" keyword help string. */ | |
20652 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
20653 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
20654 | ||
7336e101 SP |
20655 | DEFUN (lcommunity_list_standard, |
20656 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20657 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20658 | BGP_STR |
20659 | LCOMMUNITY_LIST_STR | |
20660 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20661 | "Sequence number of an entry\n" |
20662 | "Sequence number\n" | |
7336e101 SP |
20663 | "Specify large community to reject\n" |
20664 | "Specify large community to accept\n" | |
20665 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20666 | { |
d62a17ae | 20667 | return lcommunity_list_set_vty(vty, argc, argv, |
20668 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
20669 | } |
20670 | ||
7336e101 SP |
20671 | DEFUN (lcommunity_list_expanded, |
20672 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20673 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20674 | BGP_STR |
20675 | LCOMMUNITY_LIST_STR | |
20676 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20677 | "Sequence number of an entry\n" |
20678 | "Sequence number\n" | |
7336e101 SP |
20679 | "Specify large community to reject\n" |
20680 | "Specify large community to accept\n" | |
20681 | "An ordered list as a regular-expression\n") | |
57d187bc | 20682 | { |
d62a17ae | 20683 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20684 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
20685 | } |
20686 | ||
7336e101 SP |
20687 | DEFUN (lcommunity_list_name_standard, |
20688 | bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20689 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20690 | BGP_STR |
20691 | LCOMMUNITY_LIST_STR | |
20692 | "Specify standard large-community-list\n" | |
20693 | "Large Community list name\n" | |
2f8cc0e5 DA |
20694 | "Sequence number of an entry\n" |
20695 | "Sequence number\n" | |
7336e101 SP |
20696 | "Specify large community to reject\n" |
20697 | "Specify large community to accept\n" | |
20698 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20699 | { |
d62a17ae | 20700 | return lcommunity_list_set_vty(vty, argc, argv, |
20701 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
20702 | } |
20703 | ||
7336e101 SP |
20704 | DEFUN (lcommunity_list_name_expanded, |
20705 | bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20706 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20707 | BGP_STR |
20708 | LCOMMUNITY_LIST_STR | |
20709 | "Specify expanded large-community-list\n" | |
20710 | "Large Community list name\n" | |
2f8cc0e5 DA |
20711 | "Sequence number of an entry\n" |
20712 | "Sequence number\n" | |
7336e101 SP |
20713 | "Specify large community to reject\n" |
20714 | "Specify large community to accept\n" | |
20715 | "An ordered list as a regular-expression\n") | |
57d187bc | 20716 | { |
d62a17ae | 20717 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20718 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
20719 | } |
20720 | ||
4378f57c DA |
20721 | DEFUN (no_lcommunity_list_all, |
20722 | no_bgp_lcommunity_list_all_cmd, | |
a2099c1d | 20723 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", |
7336e101 SP |
20724 | NO_STR |
20725 | BGP_STR | |
20726 | LCOMMUNITY_LIST_STR | |
20727 | "Large Community list number (standard)\n" | |
20728 | "Large Community list number (expanded)\n" | |
20729 | "Large Community list name\n") | |
57d187bc | 20730 | { |
7336e101 SP |
20731 | return lcommunity_list_unset_vty(vty, argc, argv, |
20732 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
20733 | } |
20734 | ||
4378f57c DA |
20735 | DEFUN (no_lcommunity_list_name_standard_all, |
20736 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
a2099c1d | 20737 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", |
4378f57c DA |
20738 | NO_STR |
20739 | BGP_STR | |
20740 | LCOMMUNITY_LIST_STR | |
20741 | "Specify standard large-community-list\n" | |
20742 | "Large Community list name\n") | |
20743 | { | |
20744 | return lcommunity_list_unset_vty(vty, argc, argv, | |
20745 | LARGE_COMMUNITY_LIST_STANDARD); | |
20746 | } | |
20747 | ||
7336e101 SP |
20748 | DEFUN (no_lcommunity_list_name_expanded_all, |
20749 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
a2099c1d | 20750 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", |
7336e101 SP |
20751 | NO_STR |
20752 | BGP_STR | |
20753 | LCOMMUNITY_LIST_STR | |
20754 | "Specify expanded large-community-list\n" | |
20755 | "Large Community list name\n") | |
57d187bc | 20756 | { |
d62a17ae | 20757 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20758 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20759 | } |
20760 | ||
7336e101 SP |
20761 | DEFUN (no_lcommunity_list_standard, |
20762 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20763 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20764 | NO_STR |
20765 | BGP_STR | |
20766 | LCOMMUNITY_LIST_STR | |
20767 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20768 | "Sequence number of an entry\n" |
20769 | "Sequence number\n" | |
7336e101 SP |
20770 | "Specify large community to reject\n" |
20771 | "Specify large community to accept\n" | |
20772 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20773 | { |
d62a17ae | 20774 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20775 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20776 | } |
20777 | ||
7336e101 SP |
20778 | DEFUN (no_lcommunity_list_expanded, |
20779 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20780 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20781 | NO_STR |
20782 | BGP_STR | |
20783 | LCOMMUNITY_LIST_STR | |
20784 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20785 | "Sequence number of an entry\n" |
20786 | "Sequence number\n" | |
7336e101 SP |
20787 | "Specify large community to reject\n" |
20788 | "Specify large community to accept\n" | |
20789 | "An ordered list as a regular-expression\n") | |
57d187bc | 20790 | { |
d62a17ae | 20791 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20792 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20793 | } |
20794 | ||
7336e101 SP |
20795 | DEFUN (no_lcommunity_list_name_standard, |
20796 | no_bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20797 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20798 | NO_STR |
20799 | BGP_STR | |
20800 | LCOMMUNITY_LIST_STR | |
20801 | "Specify standard large-community-list\n" | |
20802 | "Large Community list name\n" | |
2f8cc0e5 DA |
20803 | "Sequence number of an entry\n" |
20804 | "Sequence number\n" | |
7336e101 SP |
20805 | "Specify large community to reject\n" |
20806 | "Specify large community to accept\n" | |
20807 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20808 | { |
d62a17ae | 20809 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20810 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20811 | } |
20812 | ||
7336e101 SP |
20813 | DEFUN (no_lcommunity_list_name_expanded, |
20814 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20815 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20816 | NO_STR |
20817 | BGP_STR | |
20818 | LCOMMUNITY_LIST_STR | |
20819 | "Specify expanded large-community-list\n" | |
20820 | "Large community list name\n" | |
2f8cc0e5 DA |
20821 | "Sequence number of an entry\n" |
20822 | "Sequence number\n" | |
7336e101 SP |
20823 | "Specify large community to reject\n" |
20824 | "Specify large community to accept\n" | |
20825 | "An ordered list as a regular-expression\n") | |
57d187bc | 20826 | { |
d62a17ae | 20827 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20828 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20829 | } |
20830 | ||
d62a17ae | 20831 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
20832 | { | |
20833 | struct community_entry *entry; | |
20834 | ||
20835 | for (entry = list->head; entry; entry = entry->next) { | |
20836 | if (entry == list->head) { | |
20837 | if (all_digit(list->name)) | |
20838 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 20839 | entry->style == |
20840 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20841 | ? "standard" |
20842 | : "(expanded) access", | |
20843 | list->name); | |
20844 | else | |
20845 | vty_out(vty, | |
20846 | "Named large community %s list %s\n", | |
169b72c8 | 20847 | entry->style == |
20848 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20849 | ? "standard" |
20850 | : "expanded", | |
20851 | list->name); | |
20852 | } | |
20853 | if (entry->any) | |
20854 | vty_out(vty, " %s\n", | |
20855 | community_direct_str(entry->direct)); | |
20856 | else | |
20857 | vty_out(vty, " %s %s\n", | |
20858 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20859 | community_list_config_str(entry)); |
d62a17ae | 20860 | } |
57d187bc JS |
20861 | } |
20862 | ||
7336e101 SP |
20863 | DEFUN (show_lcommunity_list, |
20864 | show_bgp_lcommunity_list_cmd, | |
20865 | "show bgp large-community-list", | |
57d187bc | 20866 | SHOW_STR |
7336e101 | 20867 | BGP_STR |
57d187bc JS |
20868 | "List large-community list\n") |
20869 | { | |
d62a17ae | 20870 | struct community_list *list; |
20871 | struct community_list_master *cm; | |
57d187bc | 20872 | |
d62a17ae | 20873 | cm = community_list_master_lookup(bgp_clist, |
20874 | LARGE_COMMUNITY_LIST_MASTER); | |
20875 | if (!cm) | |
20876 | return CMD_SUCCESS; | |
57d187bc | 20877 | |
d62a17ae | 20878 | for (list = cm->num.head; list; list = list->next) |
20879 | lcommunity_list_show(vty, list); | |
57d187bc | 20880 | |
d62a17ae | 20881 | for (list = cm->str.head; list; list = list->next) |
20882 | lcommunity_list_show(vty, list); | |
57d187bc | 20883 | |
d62a17ae | 20884 | return CMD_SUCCESS; |
57d187bc JS |
20885 | } |
20886 | ||
7336e101 SP |
20887 | DEFUN (show_lcommunity_list_arg, |
20888 | show_bgp_lcommunity_list_arg_cmd, | |
a2099c1d | 20889 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20890 | SHOW_STR |
20891 | BGP_STR | |
57d187bc | 20892 | "List large-community list\n" |
960b69b9 | 20893 | "Large-community-list number\n" |
20894 | "Large-community-list name\n" | |
20895 | "Detailed information on large-community-list\n") | |
57d187bc | 20896 | { |
d62a17ae | 20897 | struct community_list *list; |
57d187bc | 20898 | |
e237b0d2 | 20899 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 20900 | LARGE_COMMUNITY_LIST_MASTER); |
20901 | if (!list) { | |
960b69b9 | 20902 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 20903 | return CMD_WARNING; |
20904 | } | |
57d187bc | 20905 | |
d62a17ae | 20906 | lcommunity_list_show(vty, list); |
57d187bc | 20907 | |
d62a17ae | 20908 | return CMD_SUCCESS; |
57d187bc JS |
20909 | } |
20910 | ||
718e3744 | 20911 | /* "extcommunity-list" keyword help string. */ |
20912 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
20913 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
20914 | ||
7336e101 SP |
20915 | DEFUN (extcommunity_list_standard, |
20916 | bgp_extcommunity_list_standard_cmd, | |
a2099c1d | 20917 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20918 | BGP_STR |
718e3744 | 20919 | EXTCOMMUNITY_LIST_STR |
20920 | "Extended Community list number (standard)\n" | |
718e3744 | 20921 | "Specify standard extcommunity-list\n" |
5bf15956 | 20922 | "Community list name\n" |
2f8cc0e5 DA |
20923 | "Sequence number of an entry\n" |
20924 | "Sequence number\n" | |
718e3744 | 20925 | "Specify community to reject\n" |
20926 | "Specify community to accept\n" | |
20927 | EXTCOMMUNITY_VAL_STR) | |
20928 | { | |
d62a17ae | 20929 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20930 | int direct = 0; | |
20931 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20932 | char *seq = NULL; |
42f914d4 | 20933 | |
d62a17ae | 20934 | int idx = 0; |
7b9a4750 | 20935 | |
d62a17ae | 20936 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20937 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20938 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20939 | |
a08032fe | 20940 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20941 | seq = argv[idx]->arg; |
20942 | ||
d62a17ae | 20943 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20944 | : COMMUNITY_DENY; | |
20945 | argv_find(argv, argc, "AA:NN", &idx); | |
20946 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20947 | |
2f8cc0e5 | 20948 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20949 | direct, style); |
42f914d4 | 20950 | |
d62a17ae | 20951 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20952 | |
d62a17ae | 20953 | if (ret < 0) { |
20954 | community_list_perror(vty, ret); | |
20955 | return CMD_WARNING_CONFIG_FAILED; | |
20956 | } | |
42f914d4 | 20957 | |
d62a17ae | 20958 | return CMD_SUCCESS; |
718e3744 | 20959 | } |
20960 | ||
7336e101 SP |
20961 | DEFUN (extcommunity_list_name_expanded, |
20962 | bgp_extcommunity_list_name_expanded_cmd, | |
a2099c1d | 20963 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20964 | BGP_STR |
20965 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 20966 | "Extended Community list number (expanded)\n" |
718e3744 | 20967 | "Specify expanded extcommunity-list\n" |
20968 | "Extended Community list name\n" | |
2f8cc0e5 DA |
20969 | "Sequence number of an entry\n" |
20970 | "Sequence number\n" | |
718e3744 | 20971 | "Specify community to reject\n" |
20972 | "Specify community to accept\n" | |
20973 | "An ordered list as a regular-expression\n") | |
20974 | { | |
d62a17ae | 20975 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20976 | int direct = 0; | |
20977 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20978 | char *seq = NULL; |
d62a17ae | 20979 | int idx = 0; |
7336e101 | 20980 | |
d62a17ae | 20981 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20982 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20983 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20984 | |
a08032fe | 20985 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20986 | seq = argv[idx]->arg; |
20987 | ||
d62a17ae | 20988 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20989 | : COMMUNITY_DENY; | |
20990 | argv_find(argv, argc, "LINE", &idx); | |
20991 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20992 | |
2f8cc0e5 | 20993 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20994 | direct, style); |
42f914d4 | 20995 | |
d62a17ae | 20996 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20997 | |
d62a17ae | 20998 | if (ret < 0) { |
20999 | community_list_perror(vty, ret); | |
21000 | return CMD_WARNING_CONFIG_FAILED; | |
21001 | } | |
42f914d4 | 21002 | |
d62a17ae | 21003 | return CMD_SUCCESS; |
718e3744 | 21004 | } |
21005 | ||
7336e101 SP |
21006 | DEFUN (no_extcommunity_list_standard_all, |
21007 | no_bgp_extcommunity_list_standard_all_cmd, | |
a2099c1d | 21008 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
21009 | NO_STR |
21010 | BGP_STR | |
21011 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 21012 | "Extended Community list number (standard)\n" |
718e3744 | 21013 | "Specify standard extcommunity-list\n" |
5bf15956 | 21014 | "Community list name\n" |
2f8cc0e5 DA |
21015 | "Sequence number of an entry\n" |
21016 | "Sequence number\n" | |
718e3744 | 21017 | "Specify community to reject\n" |
21018 | "Specify community to accept\n" | |
21019 | EXTCOMMUNITY_VAL_STR) | |
21020 | { | |
d62a17ae | 21021 | int style = EXTCOMMUNITY_LIST_STANDARD; |
21022 | int direct = 0; | |
21023 | char *cl_number_or_name = NULL; | |
d4455c89 | 21024 | char *str = NULL; |
2f8cc0e5 | 21025 | char *seq = NULL; |
d62a17ae | 21026 | int idx = 0; |
d4455c89 | 21027 | |
a08032fe | 21028 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
21029 | seq = argv[idx]->arg; |
21030 | ||
21031 | idx = 0; | |
d4455c89 DA |
21032 | argv_find(argv, argc, "permit", &idx); |
21033 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
21034 | if (idx) { |
21035 | direct = argv_find(argv, argc, "permit", &idx) | |
21036 | ? COMMUNITY_PERMIT | |
21037 | : COMMUNITY_DENY; | |
21038 | ||
21039 | idx = 0; | |
21040 | argv_find(argv, argc, "AA:NN", &idx); | |
21041 | str = argv_concat(argv, argc, idx); | |
21042 | } | |
21043 | ||
21044 | idx = 0; | |
d62a17ae | 21045 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 21046 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 21047 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 21048 | |
d62a17ae | 21049 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 21050 | seq, direct, style); |
42f914d4 | 21051 | |
d62a17ae | 21052 | XFREE(MTYPE_TMP, str); |
42f914d4 | 21053 | |
d62a17ae | 21054 | if (ret < 0) { |
21055 | community_list_perror(vty, ret); | |
21056 | return CMD_WARNING_CONFIG_FAILED; | |
21057 | } | |
42f914d4 | 21058 | |
d62a17ae | 21059 | return CMD_SUCCESS; |
718e3744 | 21060 | } |
21061 | ||
d4455c89 DA |
21062 | ALIAS(no_extcommunity_list_standard_all, |
21063 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
a2099c1d | 21064 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 21065 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
21066 | "Extended Community list number (standard)\n" |
21067 | "Specify standard extcommunity-list\n" | |
21068 | "Community list name\n") | |
21069 | ||
7336e101 SP |
21070 | DEFUN (no_extcommunity_list_expanded_all, |
21071 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a2099c1d | 21072 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
21073 | NO_STR |
21074 | BGP_STR | |
21075 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 21076 | "Extended Community list number (expanded)\n" |
718e3744 | 21077 | "Specify expanded extcommunity-list\n" |
5bf15956 | 21078 | "Extended Community list name\n" |
2f8cc0e5 DA |
21079 | "Sequence number of an entry\n" |
21080 | "Sequence number\n" | |
718e3744 | 21081 | "Specify community to reject\n" |
21082 | "Specify community to accept\n" | |
21083 | "An ordered list as a regular-expression\n") | |
21084 | { | |
d62a17ae | 21085 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
21086 | int direct = 0; | |
21087 | char *cl_number_or_name = NULL; | |
d4455c89 | 21088 | char *str = NULL; |
2f8cc0e5 | 21089 | char *seq = NULL; |
d62a17ae | 21090 | int idx = 0; |
d4455c89 | 21091 | |
a08032fe | 21092 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
21093 | seq = argv[idx]->arg; |
21094 | ||
21095 | idx = 0; | |
d4455c89 DA |
21096 | argv_find(argv, argc, "permit", &idx); |
21097 | argv_find(argv, argc, "deny", &idx); | |
21098 | ||
21099 | if (idx) { | |
21100 | direct = argv_find(argv, argc, "permit", &idx) | |
21101 | ? COMMUNITY_PERMIT | |
21102 | : COMMUNITY_DENY; | |
21103 | ||
21104 | idx = 0; | |
21105 | argv_find(argv, argc, "LINE", &idx); | |
21106 | str = argv_concat(argv, argc, idx); | |
21107 | } | |
21108 | ||
21109 | idx = 0; | |
d62a17ae | 21110 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 21111 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 21112 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 21113 | |
d62a17ae | 21114 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 21115 | seq, direct, style); |
42f914d4 | 21116 | |
d62a17ae | 21117 | XFREE(MTYPE_TMP, str); |
42f914d4 | 21118 | |
d62a17ae | 21119 | if (ret < 0) { |
21120 | community_list_perror(vty, ret); | |
21121 | return CMD_WARNING_CONFIG_FAILED; | |
21122 | } | |
42f914d4 | 21123 | |
d62a17ae | 21124 | return CMD_SUCCESS; |
718e3744 | 21125 | } |
21126 | ||
d4455c89 DA |
21127 | ALIAS(no_extcommunity_list_expanded_all, |
21128 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
a2099c1d | 21129 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 21130 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
21131 | "Extended Community list number (expanded)\n" |
21132 | "Specify expanded extcommunity-list\n" | |
21133 | "Extended Community list name\n") | |
21134 | ||
d62a17ae | 21135 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 21136 | { |
d62a17ae | 21137 | struct community_entry *entry; |
718e3744 | 21138 | |
d62a17ae | 21139 | for (entry = list->head; entry; entry = entry->next) { |
21140 | if (entry == list->head) { | |
21141 | if (all_digit(list->name)) | |
21142 | vty_out(vty, "Extended community %s list %s\n", | |
21143 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
21144 | ? "standard" | |
21145 | : "(expanded) access", | |
21146 | list->name); | |
21147 | else | |
21148 | vty_out(vty, | |
21149 | "Named extended community %s list %s\n", | |
21150 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
21151 | ? "standard" | |
21152 | : "expanded", | |
21153 | list->name); | |
21154 | } | |
21155 | if (entry->any) | |
21156 | vty_out(vty, " %s\n", | |
21157 | community_direct_str(entry->direct)); | |
21158 | else | |
21159 | vty_out(vty, " %s %s\n", | |
21160 | community_direct_str(entry->direct), | |
8d9b8ed9 | 21161 | community_list_config_str(entry)); |
d62a17ae | 21162 | } |
718e3744 | 21163 | } |
21164 | ||
7336e101 SP |
21165 | DEFUN (show_extcommunity_list, |
21166 | show_bgp_extcommunity_list_cmd, | |
21167 | "show bgp extcommunity-list", | |
718e3744 | 21168 | SHOW_STR |
7336e101 | 21169 | BGP_STR |
718e3744 | 21170 | "List extended-community list\n") |
21171 | { | |
d62a17ae | 21172 | struct community_list *list; |
21173 | struct community_list_master *cm; | |
718e3744 | 21174 | |
d62a17ae | 21175 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
21176 | if (!cm) | |
21177 | return CMD_SUCCESS; | |
718e3744 | 21178 | |
d62a17ae | 21179 | for (list = cm->num.head; list; list = list->next) |
21180 | extcommunity_list_show(vty, list); | |
718e3744 | 21181 | |
d62a17ae | 21182 | for (list = cm->str.head; list; list = list->next) |
21183 | extcommunity_list_show(vty, list); | |
718e3744 | 21184 | |
d62a17ae | 21185 | return CMD_SUCCESS; |
718e3744 | 21186 | } |
21187 | ||
7336e101 SP |
21188 | DEFUN (show_extcommunity_list_arg, |
21189 | show_bgp_extcommunity_list_arg_cmd, | |
a2099c1d | 21190 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
21191 | SHOW_STR |
21192 | BGP_STR | |
718e3744 | 21193 | "List extended-community list\n" |
21194 | "Extcommunity-list number\n" | |
960b69b9 | 21195 | "Extcommunity-list name\n" |
21196 | "Detailed information on extcommunity-list\n") | |
718e3744 | 21197 | { |
d62a17ae | 21198 | int idx_comm_list = 3; |
21199 | struct community_list *list; | |
718e3744 | 21200 | |
e237b0d2 | 21201 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 21202 | EXTCOMMUNITY_LIST_MASTER); |
21203 | if (!list) { | |
21204 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
21205 | return CMD_WARNING; | |
21206 | } | |
718e3744 | 21207 | |
d62a17ae | 21208 | extcommunity_list_show(vty, list); |
718e3744 | 21209 | |
d62a17ae | 21210 | return CMD_SUCCESS; |
718e3744 | 21211 | } |
6b0655a2 | 21212 | |
718e3744 | 21213 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 21214 | static int community_list_config_write(struct vty *vty) |
21215 | { | |
21216 | struct community_list *list; | |
21217 | struct community_entry *entry; | |
21218 | struct community_list_master *cm; | |
21219 | int write = 0; | |
21220 | ||
21221 | /* Community-list. */ | |
21222 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
21223 | ||
21224 | for (list = cm->num.head; list; list = list->next) | |
21225 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21226 | vty_out(vty, |
21227 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
21228 | list->name, entry->seq, | |
d62a17ae | 21229 | community_direct_str(entry->direct), |
21230 | community_list_config_str(entry)); | |
21231 | write++; | |
21232 | } | |
21233 | for (list = cm->str.head; list; list = list->next) | |
21234 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21235 | vty_out(vty, |
21236 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 21237 | entry->style == COMMUNITY_LIST_STANDARD |
21238 | ? "standard" | |
21239 | : "expanded", | |
2f8cc0e5 DA |
21240 | list->name, entry->seq, |
21241 | community_direct_str(entry->direct), | |
d62a17ae | 21242 | community_list_config_str(entry)); |
21243 | write++; | |
21244 | } | |
21245 | ||
21246 | /* Extcommunity-list. */ | |
21247 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
21248 | ||
21249 | for (list = cm->num.head; list; list = list->next) | |
21250 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21251 | vty_out(vty, |
21252 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
21253 | list->name, entry->seq, | |
21254 | community_direct_str(entry->direct), | |
d62a17ae | 21255 | community_list_config_str(entry)); |
21256 | write++; | |
21257 | } | |
21258 | for (list = cm->str.head; list; list = list->next) | |
21259 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21260 | vty_out(vty, |
6cde4b45 | 21261 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 21262 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
21263 | ? "standard" | |
21264 | : "expanded", | |
2f8cc0e5 DA |
21265 | list->name, entry->seq, |
21266 | community_direct_str(entry->direct), | |
d62a17ae | 21267 | community_list_config_str(entry)); |
21268 | write++; | |
21269 | } | |
21270 | ||
21271 | ||
21272 | /* lcommunity-list. */ | |
21273 | cm = community_list_master_lookup(bgp_clist, | |
21274 | LARGE_COMMUNITY_LIST_MASTER); | |
21275 | ||
21276 | for (list = cm->num.head; list; list = list->next) | |
21277 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21278 | vty_out(vty, |
6cde4b45 | 21279 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
21280 | list->name, entry->seq, |
21281 | community_direct_str(entry->direct), | |
d62a17ae | 21282 | community_list_config_str(entry)); |
21283 | write++; | |
21284 | } | |
21285 | for (list = cm->str.head; list; list = list->next) | |
21286 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21287 | vty_out(vty, |
6cde4b45 | 21288 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 21289 | |
d62a17ae | 21290 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
21291 | ? "standard" | |
21292 | : "expanded", | |
2f8cc0e5 | 21293 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 21294 | community_list_config_str(entry)); |
21295 | write++; | |
21296 | } | |
21297 | ||
21298 | return write; | |
21299 | } | |
21300 | ||
612c2c15 | 21301 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 21302 | static struct cmd_node community_list_node = { |
f4b8291f | 21303 | .name = "community list", |
62b346ee DL |
21304 | .node = COMMUNITY_LIST_NODE, |
21305 | .prompt = "", | |
612c2c15 | 21306 | .config_write = community_list_config_write, |
718e3744 | 21307 | }; |
21308 | ||
d62a17ae | 21309 | static void community_list_vty(void) |
21310 | { | |
612c2c15 | 21311 | install_node(&community_list_node); |
d62a17ae | 21312 | |
21313 | /* Community-list. */ | |
7336e101 SP |
21314 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
21315 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
21316 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 21317 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 21318 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 21319 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
21320 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
21321 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 21322 | |
21323 | /* Extcommunity-list. */ | |
7336e101 SP |
21324 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
21325 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
21326 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
21327 | install_element(CONFIG_NODE, |
21328 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 21329 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
21330 | install_element(CONFIG_NODE, |
21331 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
21332 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
21333 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 21334 | |
21335 | /* Large Community List */ | |
7336e101 | 21336 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
21337 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
21338 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 21339 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
21340 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
21341 | install_element(CONFIG_NODE, | |
21342 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
21343 | install_element(CONFIG_NODE, |
21344 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
21345 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
21346 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
21347 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
21348 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
21349 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
21350 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
21351 | |
21352 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 21353 | } |
ed0e57e3 DA |
21354 | |
21355 | static struct cmd_node community_alias_node = { | |
21356 | .name = "community alias", | |
21357 | .node = COMMUNITY_ALIAS_NODE, | |
21358 | .prompt = "", | |
21359 | .config_write = bgp_community_alias_write, | |
21360 | }; | |
21361 | ||
21362 | void community_alias_vty(void) | |
21363 | { | |
21364 | install_node(&community_alias_node); | |
21365 | ||
21366 | /* Community-list. */ | |
21367 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
21368 | |
21369 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 21370 | } |