]>
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 | |
70cd87ca MK |
81 | #include "bgpd/bgp_orr.h" |
82 | ||
dd65f45e | 83 | |
5d5393b9 | 84 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
85 | { |
86 | .val_bool = false, | |
87 | .match_profile = "traditional", | |
88 | .match_version = "< 7.4", | |
89 | }, | |
90 | { .val_bool = true }, | |
67b0f40c | 91 | ); |
5d5393b9 | 92 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
93 | { .val_bool = true, .match_profile = "datacenter", }, |
94 | { .val_bool = false }, | |
67b0f40c | 95 | ); |
aef999a2 DA |
96 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
97 | { .val_bool = true, .match_profile = "datacenter", }, | |
98 | { .val_bool = false }, | |
67b0f40c | 99 | ); |
5d5393b9 | 100 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
101 | { .val_bool = true, .match_profile = "datacenter", }, |
102 | { .val_bool = false }, | |
67b0f40c | 103 | ); |
5d5393b9 | 104 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
105 | { .val_bool = true, .match_profile = "datacenter", }, |
106 | { .val_bool = false }, | |
67b0f40c | 107 | ); |
5d5393b9 DL |
108 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
109 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
110 | { .val_ulong = 120 }, | |
67b0f40c | 111 | ); |
5d5393b9 DL |
112 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
113 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
114 | { .val_ulong = 180 }, | |
67b0f40c | 115 | ); |
5d5393b9 DL |
116 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
117 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
118 | { .val_ulong = 60 }, | |
67b0f40c | 119 | ); |
1d3fdccf DA |
120 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
121 | { .val_bool = false, .match_profile = "datacenter", }, | |
122 | { .val_bool = false, .match_version = "< 7.4", }, | |
123 | { .val_bool = true }, | |
67b0f40c | 124 | ); |
2adac256 DA |
125 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
126 | { .val_bool = false, .match_version = "< 7.6", }, | |
127 | { .val_bool = true }, | |
67b0f40c | 128 | ); |
f2ca5c5b DA |
129 | FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION, |
130 | { .val_bool = false, .match_version = "< 8.3", }, | |
131 | { .val_bool = true }, | |
132 | ); | |
1ae314be DA |
133 | FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET, |
134 | { .val_bool = false, .match_version = "< 8.3", }, | |
135 | { .val_bool = true }, | |
136 | ); | |
5d5393b9 | 137 | |
dd65f45e DL |
138 | DEFINE_HOOK(bgp_inst_config_write, |
139 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
140 | (bgp, vty)); |
141 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
1ca2fd11 | 142 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); |
718e3744 | 143 | |
d62a17ae | 144 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
145 | struct prefix *range, int exact); | |
146 | ||
055679e9 | 147 | /* Show BGP peer's information. */ |
148 | enum show_type { | |
149 | show_all, | |
150 | show_peer, | |
151 | show_ipv4_all, | |
152 | show_ipv6_all, | |
153 | show_ipv4_peer, | |
154 | show_ipv6_peer | |
155 | }; | |
156 | ||
36235319 QY |
157 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
158 | struct prefix *range, int exact); | |
2986cac2 | 159 | |
36235319 | 160 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
403e64f8 | 161 | struct bgp *bgp); |
2986cac2 | 162 | |
36235319 QY |
163 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
164 | enum show_type type, | |
165 | const char *ip_str, | |
166 | afi_t afi, bool use_json); | |
2986cac2 | 167 | |
d62a17ae | 168 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
169 | { | |
170 | switch (afi) { | |
171 | case AFI_IP: | |
172 | switch (safi) { | |
173 | case SAFI_UNICAST: | |
174 | return BGP_IPV4_NODE; | |
d62a17ae | 175 | case SAFI_MULTICAST: |
176 | return BGP_IPV4M_NODE; | |
d62a17ae | 177 | case SAFI_LABELED_UNICAST: |
178 | return BGP_IPV4L_NODE; | |
d62a17ae | 179 | case SAFI_MPLS_VPN: |
180 | return BGP_VPNV4_NODE; | |
7c40bf39 | 181 | case SAFI_FLOWSPEC: |
182 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
183 | default: |
184 | /* not expected */ | |
185 | return BGP_IPV4_NODE; | |
d62a17ae | 186 | } |
d62a17ae | 187 | case AFI_IP6: |
188 | switch (safi) { | |
189 | case SAFI_UNICAST: | |
190 | return BGP_IPV6_NODE; | |
d62a17ae | 191 | case SAFI_MULTICAST: |
192 | return BGP_IPV6M_NODE; | |
d62a17ae | 193 | case SAFI_LABELED_UNICAST: |
194 | return BGP_IPV6L_NODE; | |
d62a17ae | 195 | case SAFI_MPLS_VPN: |
196 | return BGP_VPNV6_NODE; | |
7c40bf39 | 197 | case SAFI_FLOWSPEC: |
198 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
199 | default: |
200 | /* not expected */ | |
201 | return BGP_IPV4_NODE; | |
d62a17ae | 202 | } |
d62a17ae | 203 | case AFI_L2VPN: |
204 | return BGP_EVPN_NODE; | |
b26f891d | 205 | case AFI_UNSPEC: |
d62a17ae | 206 | case AFI_MAX: |
207 | // We should never be here but to clarify the switch statement.. | |
208 | return BGP_IPV4_NODE; | |
d62a17ae | 209 | } |
210 | ||
211 | // Impossible to happen | |
212 | return BGP_IPV4_NODE; | |
f51bae9c | 213 | } |
20eb8864 | 214 | |
5cb5f4d0 DD |
215 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
216 | { | |
7d0d37de DS |
217 | if (afi == AFI_IP) { |
218 | if (safi == SAFI_UNICAST) | |
219 | return "IPv4 Unicast"; | |
220 | if (safi == SAFI_MULTICAST) | |
221 | return "IPv4 Multicast"; | |
222 | if (safi == SAFI_LABELED_UNICAST) | |
223 | return "IPv4 Labeled Unicast"; | |
224 | if (safi == SAFI_MPLS_VPN) | |
225 | return "IPv4 VPN"; | |
226 | if (safi == SAFI_ENCAP) | |
227 | return "IPv4 Encap"; | |
228 | if (safi == SAFI_FLOWSPEC) | |
229 | return "IPv4 Flowspec"; | |
230 | } else if (afi == AFI_IP6) { | |
231 | if (safi == SAFI_UNICAST) | |
232 | return "IPv6 Unicast"; | |
233 | if (safi == SAFI_MULTICAST) | |
234 | return "IPv6 Multicast"; | |
235 | if (safi == SAFI_LABELED_UNICAST) | |
236 | return "IPv6 Labeled Unicast"; | |
237 | if (safi == SAFI_MPLS_VPN) | |
238 | return "IPv6 VPN"; | |
239 | if (safi == SAFI_ENCAP) | |
240 | return "IPv6 Encap"; | |
241 | if (safi == SAFI_FLOWSPEC) | |
242 | return "IPv6 Flowspec"; | |
243 | } else if (afi == AFI_L2VPN) { | |
244 | if (safi == SAFI_EVPN) | |
245 | return "L2VPN EVPN"; | |
246 | } | |
247 | ||
248 | return "Unknown"; | |
5cb5f4d0 DD |
249 | } |
250 | ||
251 | /* | |
252 | * Please note that we have intentionally camelCased | |
253 | * the return strings here. So if you want | |
254 | * to use this function, please ensure you | |
255 | * are doing this within json output | |
256 | */ | |
257 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
258 | { | |
7d0d37de DS |
259 | if (afi == AFI_IP) { |
260 | if (safi == SAFI_UNICAST) | |
261 | return "ipv4Unicast"; | |
262 | if (safi == SAFI_MULTICAST) | |
263 | return "ipv4Multicast"; | |
264 | if (safi == SAFI_LABELED_UNICAST) | |
265 | return "ipv4LabeledUnicast"; | |
266 | if (safi == SAFI_MPLS_VPN) | |
267 | return "ipv4Vpn"; | |
268 | if (safi == SAFI_ENCAP) | |
269 | return "ipv4Encap"; | |
270 | if (safi == SAFI_FLOWSPEC) | |
271 | return "ipv4Flowspec"; | |
272 | } else if (afi == AFI_IP6) { | |
273 | if (safi == SAFI_UNICAST) | |
274 | return "ipv6Unicast"; | |
275 | if (safi == SAFI_MULTICAST) | |
276 | return "ipv6Multicast"; | |
277 | if (safi == SAFI_LABELED_UNICAST) | |
278 | return "ipv6LabeledUnicast"; | |
279 | if (safi == SAFI_MPLS_VPN) | |
280 | return "ipv6Vpn"; | |
281 | if (safi == SAFI_ENCAP) | |
282 | return "ipv6Encap"; | |
283 | if (safi == SAFI_FLOWSPEC) | |
284 | return "ipv6Flowspec"; | |
285 | } else if (afi == AFI_L2VPN) { | |
286 | if (safi == SAFI_EVPN) | |
287 | return "l2VpnEvpn"; | |
288 | } | |
289 | ||
290 | return "Unknown"; | |
5cb5f4d0 DD |
291 | } |
292 | ||
0249b8b6 HS |
293 | /* unset srv6 locator */ |
294 | static int bgp_srv6_locator_unset(struct bgp *bgp) | |
295 | { | |
296 | int ret; | |
297 | struct listnode *node, *nnode; | |
efae8c26 | 298 | struct srv6_locator_chunk *chunk; |
0249b8b6 HS |
299 | struct bgp_srv6_function *func; |
300 | struct bgp *bgp_vrf; | |
0249b8b6 HS |
301 | |
302 | /* release chunk notification via ZAPI */ | |
303 | ret = bgp_zebra_srv6_manager_release_locator_chunk( | |
304 | bgp->srv6_locator_name); | |
305 | if (ret < 0) | |
306 | return -1; | |
307 | ||
308 | /* refresh chunks */ | |
03852f67 | 309 | for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) { |
0249b8b6 | 310 | listnode_delete(bgp->srv6_locator_chunks, chunk); |
69467313 | 311 | srv6_locator_chunk_free(&chunk); |
03852f67 | 312 | } |
0249b8b6 HS |
313 | |
314 | /* refresh functions */ | |
bda15542 | 315 | for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) { |
0249b8b6 | 316 | listnode_delete(bgp->srv6_functions, func); |
bda15542 CS |
317 | XFREE(MTYPE_BGP_SRV6_FUNCTION, func); |
318 | } | |
0249b8b6 HS |
319 | |
320 | /* refresh tovpn_sid */ | |
321 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
322 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
323 | continue; | |
324 | ||
325 | /* refresh vpnv4 tovpn_sid */ | |
944909f4 CS |
326 | XFREE(MTYPE_BGP_SRV6_SID, |
327 | bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); | |
0249b8b6 HS |
328 | |
329 | /* refresh vpnv6 tovpn_sid */ | |
944909f4 CS |
330 | XFREE(MTYPE_BGP_SRV6_SID, |
331 | bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid); | |
527588aa CS |
332 | |
333 | /* refresh per-vrf tovpn_sid */ | |
334 | XFREE(MTYPE_BGP_SRV6_SID, bgp_vrf->tovpn_sid); | |
0249b8b6 HS |
335 | } |
336 | ||
337 | /* update vpn bgp processes */ | |
338 | vpn_leak_postchange_all(); | |
339 | ||
f8e9c702 CS |
340 | /* refresh tovpn_sid_locator */ |
341 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
342 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
343 | continue; | |
344 | ||
345 | /* refresh vpnv4 tovpn_sid_locator */ | |
efae8c26 CS |
346 | srv6_locator_chunk_free( |
347 | &bgp_vrf->vpn_policy[AFI_IP].tovpn_sid_locator); | |
f8e9c702 CS |
348 | |
349 | /* refresh vpnv6 tovpn_sid_locator */ | |
efae8c26 CS |
350 | srv6_locator_chunk_free( |
351 | &bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid_locator); | |
527588aa CS |
352 | |
353 | /* refresh per-vrf tovpn_sid_locator */ | |
69467313 | 354 | srv6_locator_chunk_free(&bgp_vrf->tovpn_sid_locator); |
f8e9c702 CS |
355 | } |
356 | ||
0249b8b6 HS |
357 | /* clear locator name */ |
358 | memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name)); | |
359 | ||
360 | return 0; | |
361 | } | |
362 | ||
718e3744 | 363 | /* Utility function to get address family from current node. */ |
d62a17ae | 364 | afi_t bgp_node_afi(struct vty *vty) |
365 | { | |
366 | afi_t afi; | |
367 | switch (vty->node) { | |
368 | case BGP_IPV6_NODE: | |
369 | case BGP_IPV6M_NODE: | |
370 | case BGP_IPV6L_NODE: | |
371 | case BGP_VPNV6_NODE: | |
7c40bf39 | 372 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 373 | afi = AFI_IP6; |
374 | break; | |
375 | case BGP_EVPN_NODE: | |
376 | afi = AFI_L2VPN; | |
377 | break; | |
378 | default: | |
379 | afi = AFI_IP; | |
380 | break; | |
381 | } | |
382 | return afi; | |
718e3744 | 383 | } |
384 | ||
385 | /* Utility function to get subsequent address family from current | |
386 | node. */ | |
d62a17ae | 387 | safi_t bgp_node_safi(struct vty *vty) |
388 | { | |
389 | safi_t safi; | |
390 | switch (vty->node) { | |
391 | case BGP_VPNV4_NODE: | |
392 | case BGP_VPNV6_NODE: | |
393 | safi = SAFI_MPLS_VPN; | |
394 | break; | |
395 | case BGP_IPV4M_NODE: | |
396 | case BGP_IPV6M_NODE: | |
397 | safi = SAFI_MULTICAST; | |
398 | break; | |
399 | case BGP_EVPN_NODE: | |
400 | safi = SAFI_EVPN; | |
401 | break; | |
402 | case BGP_IPV4L_NODE: | |
403 | case BGP_IPV6L_NODE: | |
404 | safi = SAFI_LABELED_UNICAST; | |
405 | break; | |
7c40bf39 | 406 | case BGP_FLOWSPECV4_NODE: |
407 | case BGP_FLOWSPECV6_NODE: | |
408 | safi = SAFI_FLOWSPEC; | |
409 | break; | |
d62a17ae | 410 | default: |
411 | safi = SAFI_UNICAST; | |
412 | break; | |
413 | } | |
414 | return safi; | |
718e3744 | 415 | } |
416 | ||
55f91488 QY |
417 | /** |
418 | * Converts an AFI in string form to afi_t | |
419 | * | |
420 | * @param afi string, one of | |
421 | * - "ipv4" | |
422 | * - "ipv6" | |
81cf0de5 | 423 | * - "l2vpn" |
55f91488 QY |
424 | * @return the corresponding afi_t |
425 | */ | |
d62a17ae | 426 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
427 | { | |
428 | afi_t afi = AFI_MAX; /* unknown */ | |
429 | if (strmatch(afi_str, "ipv4")) | |
430 | afi = AFI_IP; | |
431 | else if (strmatch(afi_str, "ipv6")) | |
432 | afi = AFI_IP6; | |
81cf0de5 CS |
433 | else if (strmatch(afi_str, "l2vpn")) |
434 | afi = AFI_L2VPN; | |
d62a17ae | 435 | return afi; |
436 | } | |
437 | ||
438 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
439 | afi_t *afi) | |
440 | { | |
441 | int ret = 0; | |
442 | if (argv_find(argv, argc, "ipv4", index)) { | |
443 | ret = 1; | |
444 | if (afi) | |
445 | *afi = AFI_IP; | |
446 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
447 | ret = 1; | |
448 | if (afi) | |
449 | *afi = AFI_IP6; | |
8688b3e7 DS |
450 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
451 | ret = 1; | |
452 | if (afi) | |
453 | *afi = AFI_L2VPN; | |
d62a17ae | 454 | } |
455 | return ret; | |
46f296b4 LB |
456 | } |
457 | ||
375a2e67 | 458 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 459 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
460 | { | |
461 | safi_t safi = SAFI_MAX; /* unknown */ | |
462 | if (strmatch(safi_str, "multicast")) | |
463 | safi = SAFI_MULTICAST; | |
464 | else if (strmatch(safi_str, "unicast")) | |
465 | safi = SAFI_UNICAST; | |
466 | else if (strmatch(safi_str, "vpn")) | |
467 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
468 | else if (strmatch(safi_str, "evpn")) |
469 | safi = SAFI_EVPN; | |
d62a17ae | 470 | else if (strmatch(safi_str, "labeled-unicast")) |
471 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 472 | else if (strmatch(safi_str, "flowspec")) |
473 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 474 | return safi; |
475 | } | |
476 | ||
477 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
478 | safi_t *safi) | |
479 | { | |
480 | int ret = 0; | |
481 | if (argv_find(argv, argc, "unicast", index)) { | |
482 | ret = 1; | |
483 | if (safi) | |
484 | *safi = SAFI_UNICAST; | |
485 | } else if (argv_find(argv, argc, "multicast", index)) { | |
486 | ret = 1; | |
487 | if (safi) | |
488 | *safi = SAFI_MULTICAST; | |
489 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
490 | ret = 1; | |
491 | if (safi) | |
492 | *safi = SAFI_LABELED_UNICAST; | |
493 | } else if (argv_find(argv, argc, "vpn", index)) { | |
494 | ret = 1; | |
495 | if (safi) | |
496 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
497 | } else if (argv_find(argv, argc, "evpn", index)) { |
498 | ret = 1; | |
499 | if (safi) | |
500 | *safi = SAFI_EVPN; | |
7c40bf39 | 501 | } else if (argv_find(argv, argc, "flowspec", index)) { |
502 | ret = 1; | |
503 | if (safi) | |
504 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 505 | } |
506 | return ret; | |
46f296b4 LB |
507 | } |
508 | ||
b16bcbba TA |
509 | /* |
510 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
511 | * | |
512 | * afi | |
513 | * address-family identifier | |
514 | * | |
515 | * safi | |
516 | * subsequent address-family identifier | |
517 | * | |
518 | * Returns: | |
519 | * default_af string corresponding to the supplied afi/safi pair. | |
520 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
521 | * return -1. | |
522 | */ | |
523 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
524 | { | |
525 | switch (afi) { | |
526 | case AFI_IP: | |
527 | switch (safi) { | |
528 | case SAFI_UNICAST: | |
529 | return "ipv4-unicast"; | |
530 | case SAFI_MULTICAST: | |
531 | return "ipv4-multicast"; | |
532 | case SAFI_MPLS_VPN: | |
533 | return "ipv4-vpn"; | |
534 | case SAFI_ENCAP: | |
535 | return "ipv4-encap"; | |
536 | case SAFI_LABELED_UNICAST: | |
537 | return "ipv4-labeled-unicast"; | |
538 | case SAFI_FLOWSPEC: | |
539 | return "ipv4-flowspec"; | |
540 | default: | |
541 | return "unknown-afi/safi"; | |
542 | } | |
543 | break; | |
544 | case AFI_IP6: | |
545 | switch (safi) { | |
546 | case SAFI_UNICAST: | |
547 | return "ipv6-unicast"; | |
548 | case SAFI_MULTICAST: | |
549 | return "ipv6-multicast"; | |
550 | case SAFI_MPLS_VPN: | |
551 | return "ipv6-vpn"; | |
552 | case SAFI_ENCAP: | |
553 | return "ipv6-encap"; | |
554 | case SAFI_LABELED_UNICAST: | |
555 | return "ipv6-labeled-unicast"; | |
556 | case SAFI_FLOWSPEC: | |
557 | return "ipv6-flowspec"; | |
558 | default: | |
559 | return "unknown-afi/safi"; | |
560 | } | |
561 | break; | |
562 | case AFI_L2VPN: | |
563 | switch (safi) { | |
564 | case SAFI_EVPN: | |
565 | return "l2vpn-evpn"; | |
566 | default: | |
567 | return "unknown-afi/safi"; | |
568 | } | |
569 | case AFI_UNSPEC: | |
570 | case AFI_MAX: | |
571 | return "unknown-afi/safi"; | |
572 | } | |
573 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
574 | return "unknown-afi/safi"; | |
575 | } | |
576 | ||
5d5393b9 DL |
577 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
578 | enum bgp_instance_type inst_type) | |
579 | { | |
580 | int ret = bgp_get(bgp, as, name, inst_type); | |
581 | ||
582 | if (ret == BGP_CREATED) { | |
583 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 584 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
585 | |
586 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 587 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 588 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 589 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
590 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
591 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 592 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 593 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 594 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 595 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
596 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
597 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
598 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
599 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
f2ca5c5b DA |
600 | if (DFLT_BGP_GRACEFUL_NOTIFICATION) |
601 | SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
1ae314be DA |
602 | if (DFLT_BGP_HARD_ADMIN_RESET) |
603 | SET_FLAG((*bgp)->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
5d5393b9 DL |
604 | |
605 | ret = BGP_SUCCESS; | |
606 | } | |
607 | return ret; | |
608 | } | |
609 | ||
7eeee51e | 610 | /* |
f212a857 | 611 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 612 | * |
f212a857 DS |
613 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
614 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
615 | * to appropriate values for the calling function. This is to allow the |
616 | * calling function to make decisions appropriate for the show command | |
617 | * that is being parsed. | |
618 | * | |
619 | * The show commands are generally of the form: | |
d62a17ae | 620 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
621 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
622 | * |
623 | * Since we use argv_find if the show command in particular doesn't have: | |
624 | * [ip] | |
18c57037 | 625 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 626 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
627 | * The command parsing should still be ok. |
628 | * | |
629 | * vty -> The vty for the command so we can output some useful data in | |
630 | * the event of a parse error in the vrf. | |
631 | * argv -> The command tokens | |
632 | * argc -> How many command tokens we have | |
d62a17ae | 633 | * idx -> The current place in the command, generally should be 0 for this |
634 | * function | |
7eeee51e DS |
635 | * afi -> The parsed afi if it was included in the show command, returned here |
636 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 637 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 638 | * use_json -> json is configured or not |
7eeee51e DS |
639 | * |
640 | * The function returns the correct location in the parse tree for the | |
641 | * last token found. | |
0e37c258 DS |
642 | * |
643 | * Returns 0 for failure to parse correctly, else the idx position of where | |
644 | * it found the last token. | |
7eeee51e | 645 | */ |
d62a17ae | 646 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
647 | struct cmd_token **argv, int argc, | |
648 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 649 | struct bgp **bgp, bool use_json) |
d62a17ae | 650 | { |
651 | char *vrf_name = NULL; | |
652 | ||
653 | assert(afi); | |
654 | assert(safi); | |
655 | assert(bgp); | |
656 | ||
657 | if (argv_find(argv, argc, "ip", idx)) | |
658 | *afi = AFI_IP; | |
659 | ||
9a8bdf1c | 660 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 661 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
662 | else if (argv_find(argv, argc, "vrf", idx)) { |
663 | vrf_name = argv[*idx + 1]->arg; | |
664 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
665 | vrf_name = NULL; | |
666 | } | |
667 | if (vrf_name) { | |
d62a17ae | 668 | if (strmatch(vrf_name, "all")) |
669 | *bgp = NULL; | |
670 | else { | |
671 | *bgp = bgp_lookup_by_name(vrf_name); | |
672 | if (!*bgp) { | |
52e5b8c4 SP |
673 | if (use_json) { |
674 | json_object *json = NULL; | |
675 | json = json_object_new_object(); | |
676 | json_object_string_add( | |
677 | json, "warning", | |
678 | "View/Vrf is unknown"); | |
75eeda93 | 679 | vty_json(vty, json); |
52e5b8c4 | 680 | } |
ca61fd25 DS |
681 | else |
682 | vty_out(vty, "View/Vrf %s is unknown\n", | |
683 | vrf_name); | |
d62a17ae | 684 | *idx = 0; |
685 | return 0; | |
686 | } | |
687 | } | |
688 | } else { | |
689 | *bgp = bgp_get_default(); | |
690 | if (!*bgp) { | |
52e5b8c4 SP |
691 | if (use_json) { |
692 | json_object *json = NULL; | |
693 | json = json_object_new_object(); | |
694 | json_object_string_add( | |
695 | json, "warning", | |
696 | "Default BGP instance not found"); | |
75eeda93 | 697 | vty_json(vty, json); |
52e5b8c4 | 698 | } |
ca61fd25 DS |
699 | else |
700 | vty_out(vty, | |
701 | "Default BGP instance not found\n"); | |
d62a17ae | 702 | *idx = 0; |
703 | return 0; | |
704 | } | |
705 | } | |
706 | ||
707 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
708 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
709 | ||
710 | *idx += 1; | |
711 | return *idx; | |
712 | } | |
713 | ||
28c6e247 | 714 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 715 | { |
716 | struct interface *ifp = NULL; | |
4122b697 DA |
717 | struct listnode *node; |
718 | struct bgp_listener *listener; | |
719 | union sockunion all_su; | |
d62a17ae | 720 | |
4122b697 | 721 | if (su->sa.sa_family == AF_INET) { |
3d2a2725 | 722 | (void)str2sockunion("0.0.0.0", &all_su); |
d62a17ae | 723 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); |
4122b697 | 724 | } else if (su->sa.sa_family == AF_INET6) { |
3d2a2725 | 725 | (void)str2sockunion("::", &all_su); |
d62a17ae | 726 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, |
727 | su->sin6.sin6_scope_id, | |
728 | bgp->vrf_id); | |
4122b697 | 729 | } |
d62a17ae | 730 | |
4122b697 DA |
731 | if (ifp) { |
732 | for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) { | |
733 | if (sockunion_family(su) != | |
734 | sockunion_family(&listener->su)) | |
735 | continue; | |
736 | ||
737 | /* If 0.0.0.0/:: is a listener, then treat as self and | |
738 | * reject. | |
739 | */ | |
740 | if (!sockunion_cmp(&listener->su, su) || | |
741 | !sockunion_cmp(&listener->su, &all_su)) | |
742 | return true; | |
743 | } | |
744 | } | |
d62a17ae | 745 | |
3dc339cd | 746 | return false; |
718e3744 | 747 | } |
748 | ||
28c6e247 IR |
749 | /* Utility function for looking up peer from VTY. */ |
750 | /* This is used only for configuration, so disallow if attempted on | |
751 | * a dynamic neighbor. | |
752 | */ | |
753 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
754 | { | |
755 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
756 | int ret; | |
757 | union sockunion su; | |
758 | struct peer *peer; | |
759 | ||
760 | if (!bgp) { | |
761 | return NULL; | |
762 | } | |
763 | ||
764 | ret = str2sockunion(ip_str, &su); | |
765 | if (ret < 0) { | |
766 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
767 | if (!peer) { | |
768 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
769 | == NULL) { | |
770 | vty_out(vty, | |
771 | "%% Malformed address or name: %s\n", | |
772 | ip_str); | |
773 | return NULL; | |
774 | } | |
775 | } | |
776 | } else { | |
777 | peer = peer_lookup(bgp, &su); | |
778 | if (!peer) { | |
779 | vty_out(vty, | |
780 | "%% Specify remote-as or peer-group commands first\n"); | |
781 | return NULL; | |
782 | } | |
783 | if (peer_dynamic_neighbor(peer)) { | |
784 | vty_out(vty, | |
785 | "%% Operation not allowed on a dynamic neighbor\n"); | |
786 | return NULL; | |
787 | } | |
788 | } | |
789 | return peer; | |
790 | } | |
791 | ||
718e3744 | 792 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
793 | /* This is used only for configuration, so disallow if attempted on |
794 | * a dynamic neighbor. | |
795 | */ | |
d62a17ae | 796 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
797 | { | |
798 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
799 | int ret; | |
800 | union sockunion su; | |
801 | struct peer *peer = NULL; | |
802 | struct peer_group *group = NULL; | |
803 | ||
804 | if (!bgp) { | |
805 | return NULL; | |
806 | } | |
807 | ||
808 | ret = str2sockunion(peer_str, &su); | |
809 | if (ret == 0) { | |
810 | /* IP address, locate peer. */ | |
811 | peer = peer_lookup(bgp, &su); | |
812 | } else { | |
813 | /* Not IP, could match either peer configured on interface or a | |
814 | * group. */ | |
815 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
816 | if (!peer) | |
817 | group = peer_group_lookup(bgp, peer_str); | |
818 | } | |
819 | ||
820 | if (peer) { | |
821 | if (peer_dynamic_neighbor(peer)) { | |
822 | vty_out(vty, | |
823 | "%% Operation not allowed on a dynamic neighbor\n"); | |
824 | return NULL; | |
825 | } | |
826 | ||
827 | return peer; | |
828 | } | |
829 | ||
830 | if (group) | |
831 | return group->conf; | |
832 | ||
833 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
834 | ||
835 | return NULL; | |
836 | } | |
837 | ||
4b7e23e9 | 838 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret) |
d62a17ae | 839 | { |
840 | const char *str = NULL; | |
841 | ||
842 | switch (ret) { | |
4b7e23e9 DS |
843 | case BGP_SUCCESS: |
844 | case BGP_CREATED: | |
845 | case BGP_GR_NO_OPERATION: | |
846 | break; | |
d62a17ae | 847 | case BGP_ERR_INVALID_VALUE: |
848 | str = "Invalid value"; | |
849 | break; | |
850 | case BGP_ERR_INVALID_FLAG: | |
851 | str = "Invalid flag"; | |
852 | break; | |
853 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
854 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
855 | break; | |
856 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
857 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
858 | break; | |
859 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
860 | str = "Specify remote-as or peer-group remote AS first"; | |
861 | break; | |
862 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
863 | str = "Cannot change the peer-group. Deconfigure first"; | |
864 | break; | |
865 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
866 | str = "Peer is not a member of this peer-group"; | |
867 | break; | |
868 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
869 | str = "Prefix/distribute list can not co-exist"; | |
870 | break; | |
871 | case BGP_ERR_NOT_INTERNAL_PEER: | |
872 | str = "Invalid command. Not an internal neighbor"; | |
873 | break; | |
874 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
875 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
876 | break; | |
d62a17ae | 877 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: |
878 | str = "Cannot have local-as same as BGP AS number"; | |
879 | break; | |
880 | case BGP_ERR_TCPSIG_FAILED: | |
881 | str = "Error while applying TCP-Sig to session(s)"; | |
882 | break; | |
883 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
884 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
885 | break; | |
886 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
887 | str = "ttl-security only allowed for EBGP peers"; | |
888 | break; | |
889 | case BGP_ERR_AS_OVERRIDE: | |
890 | str = "as-override cannot be configured for IBGP peers"; | |
891 | break; | |
892 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
893 | str = "Invalid limit for number of dynamic neighbors"; | |
894 | break; | |
895 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
896 | str = "Dynamic neighbor listen range already exists"; | |
897 | break; | |
898 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
899 | str = "Operation not allowed on a dynamic neighbor"; | |
900 | break; | |
901 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
902 | str = "Operation not allowed on a directly connected neighbor"; | |
903 | break; | |
904 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 905 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 906 | break; |
907 | case BGP_ERR_GR_INVALID_CMD: | |
908 | str = "The Graceful Restart command used is not valid at this moment."; | |
909 | break; | |
910 | case BGP_ERR_GR_OPERATION_FAILED: | |
911 | str = "The Graceful Restart Operation failed due to an err."; | |
912 | break; | |
6dcea6fe DS |
913 | case BGP_ERR_PEER_GROUP_MEMBER: |
914 | str = "Peer-group member cannot override remote-as of peer-group."; | |
915 | break; | |
916 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
917 | str = "Peer-group members must be all internal or all external."; | |
918 | break; | |
4b7e23e9 DS |
919 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND: |
920 | str = "Range specified cannot be deleted because it is not part of current config."; | |
921 | break; | |
922 | case BGP_ERR_INSTANCE_MISMATCH: | |
923 | str = "Instance specified does not match the current instance."; | |
924 | break; | |
925 | case BGP_ERR_NO_INTERFACE_CONFIG: | |
926 | str = "Interface specified is not being used for interface based peer."; | |
927 | break; | |
928 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
929 | str = "No configuration already specified for soft reconfiguration."; | |
930 | break; | |
931 | case BGP_ERR_AS_MISMATCH: | |
932 | str = "BGP is already running."; | |
933 | break; | |
934 | case BGP_ERR_AF_UNCONFIGURED: | |
935 | str = "AFI/SAFI specified is not currently configured."; | |
936 | break; | |
4b7e23e9 DS |
937 | case BGP_ERR_INVALID_AS: |
938 | str = "Confederation AS specified is the same AS as our AS."; | |
939 | break; | |
d864dd9e EB |
940 | case BGP_ERR_INVALID_ROLE_NAME: |
941 | str = "Invalid role name"; | |
942 | break; | |
943 | case BGP_ERR_INVALID_INTERNAL_ROLE: | |
8f2d6021 | 944 | str = "External roles can be set only on eBGP session"; |
d864dd9e | 945 | break; |
70cd87ca | 946 | case BGP_ERR_PEER_ORR_CONFIGURED: |
d6b27611 | 947 | str = "Deconfigure optimal-route-reflection on this peer first"; |
70cd87ca | 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 | |
70cd87ca MK |
6252 | /* optimal-route-reflection Root Routers configuration */ |
6253 | DEFPY (optimal_route_reflection, | |
6254 | optimal_route_reflection_cmd, | |
6255 | "[no$no] optimal-route-reflection WORD$orr_group [<A.B.C.D|X:X::X:X>$primary [<A.B.C.D|X:X::X:X>$secondary [<A.B.C.D|X:X::X:X>$tertiary]]]", | |
6256 | NO_STR | |
6257 | "Create ORR group and assign root router(s)\n" | |
6258 | "ORR Group name\n" | |
6259 | "Primary Root address\n" | |
6260 | "Primary Root IPv6 address\n" | |
6261 | "Secondary Root address\n" | |
6262 | "Secondary Root IPv6 address\n" | |
6263 | "Tertiary Root address\n" | |
6264 | "Tertiary Root IPv6 address\n") | |
6265 | { | |
6266 | if (!no && !primary) { | |
6267 | vty_out(vty, "%% Specify Primary Root address\n"); | |
6268 | return CMD_WARNING_CONFIG_FAILED; | |
6269 | } | |
6270 | return bgp_afi_safi_orr_group_set_vty( | |
6271 | vty, bgp_node_afi(vty), bgp_node_safi(vty), orr_group, | |
80f6ea8b | 6272 | primary_str, secondary_str, tertiary_str, !!no); |
70cd87ca MK |
6273 | } |
6274 | ||
6275 | /* neighbor optimal-route-reflection group*/ | |
6276 | DEFPY (neighbor_optimal_route_reflection, | |
6277 | neighbor_optimal_route_reflection_cmd, | |
6278 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor optimal-route-reflection WORD$orr_group", | |
6279 | NO_STR | |
6280 | NEIGHBOR_STR | |
6281 | NEIGHBOR_ADDR_STR2 | |
6282 | "Apply ORR group configuration to the neighbor\n" | |
6283 | "ORR group name\n") | |
6284 | { | |
6285 | return peer_orr_group_set_vty(vty, neighbor, bgp_node_afi(vty), | |
80f6ea8b | 6286 | bgp_node_safi(vty), orr_group, !!no); |
70cd87ca MK |
6287 | } |
6288 | ||
718e3744 | 6289 | /* neighbor route-server-client. */ |
28c6e247 IR |
6290 | DEFUN (neighbor_route_server_client, |
6291 | neighbor_route_server_client_cmd, | |
6292 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6293 | NEIGHBOR_STR | |
6294 | NEIGHBOR_ADDR_STR2 | |
6295 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6296 | { |
d62a17ae | 6297 | int idx_peer = 1; |
28c6e247 | 6298 | struct peer *peer; |
f4b8ec07 | 6299 | |
28c6e247 IR |
6300 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6301 | if (!peer) | |
d62a17ae | 6302 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
6303 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6304 | bgp_node_safi(vty), | |
6305 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 6306 | } |
6307 | ||
d62a17ae | 6308 | ALIAS_HIDDEN(neighbor_route_server_client, |
6309 | neighbor_route_server_client_hidden_cmd, | |
6310 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6311 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6312 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6313 | |
28c6e247 IR |
6314 | DEFUN (no_neighbor_route_server_client, |
6315 | no_neighbor_route_server_client_cmd, | |
6316 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6317 | NO_STR | |
6318 | NEIGHBOR_STR | |
6319 | NEIGHBOR_ADDR_STR2 | |
6320 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6321 | { |
d62a17ae | 6322 | int idx_peer = 2; |
28c6e247 IR |
6323 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6324 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6325 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 6326 | } |
6b0655a2 | 6327 | |
d62a17ae | 6328 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6329 | no_neighbor_route_server_client_hidden_cmd, | |
6330 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6331 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6332 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6333 | |
fee0f4c6 | 6334 | DEFUN (neighbor_nexthop_local_unchanged, |
6335 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6336 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6337 | NEIGHBOR_STR |
6338 | NEIGHBOR_ADDR_STR2 | |
6339 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6340 | "Leave link-local nexthop unchanged for this peer\n") | |
6341 | { | |
d62a17ae | 6342 | int idx_peer = 1; |
6343 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6344 | bgp_node_safi(vty), | |
6345 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6346 | } |
6b0655a2 | 6347 | |
fee0f4c6 | 6348 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6349 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6350 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6351 | NO_STR |
6352 | NEIGHBOR_STR | |
6353 | NEIGHBOR_ADDR_STR2 | |
6354 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6355 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6356 | { |
d62a17ae | 6357 | int idx_peer = 2; |
6358 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6359 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6360 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6361 | } |
6b0655a2 | 6362 | |
28c6e247 IR |
6363 | DEFUN (neighbor_attr_unchanged, |
6364 | neighbor_attr_unchanged_cmd, | |
6365 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6366 | NEIGHBOR_STR | |
6367 | NEIGHBOR_ADDR_STR2 | |
6368 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6369 | "As-path attribute\n" | |
6370 | "Nexthop attribute\n" | |
6371 | "Med attribute\n") | |
718e3744 | 6372 | { |
d62a17ae | 6373 | int idx = 0; |
8eeb0335 | 6374 | char *peer_str = argv[1]->arg; |
28c6e247 | 6375 | struct peer *peer; |
db45f64d DS |
6376 | bool aspath = false; |
6377 | bool nexthop = false; | |
6378 | bool med = false; | |
8eeb0335 DW |
6379 | afi_t afi = bgp_node_afi(vty); |
6380 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6381 | int ret = 0; |
f4b8ec07 | 6382 | |
28c6e247 IR |
6383 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6384 | if (!peer) | |
8eeb0335 | 6385 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6386 | |
6387 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6388 | aspath = true; |
6389 | ||
d62a17ae | 6390 | idx = 0; |
6391 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6392 | nexthop = true; |
6393 | ||
d62a17ae | 6394 | idx = 0; |
6395 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6396 | med = true; |
d62a17ae | 6397 | |
8eeb0335 | 6398 | /* no flags means all of them! */ |
db45f64d | 6399 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6400 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6401 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6402 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6403 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6404 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6405 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6406 | } else { |
28c6e247 IR |
6407 | if (!aspath) { |
6408 | if (peer_af_flag_check(peer, afi, safi, | |
6409 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6410 | ret |= peer_af_flag_unset_vty( | |
6411 | vty, peer_str, afi, safi, | |
6412 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6413 | } | |
6414 | } else | |
6415 | ret |= peer_af_flag_set_vty( | |
6416 | vty, peer_str, afi, safi, | |
6417 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6418 | ||
6419 | if (!nexthop) { | |
6420 | if (peer_af_flag_check(peer, afi, safi, | |
6421 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6422 | ret |= peer_af_flag_unset_vty( | |
6423 | vty, peer_str, afi, safi, | |
6424 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6425 | } | |
6426 | } else | |
6427 | ret |= peer_af_flag_set_vty( | |
6428 | vty, peer_str, afi, safi, | |
6429 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6430 | ||
6431 | if (!med) { | |
6432 | if (peer_af_flag_check(peer, afi, safi, | |
6433 | PEER_FLAG_MED_UNCHANGED)) { | |
6434 | ret |= peer_af_flag_unset_vty( | |
6435 | vty, peer_str, afi, safi, | |
6436 | PEER_FLAG_MED_UNCHANGED); | |
6437 | } | |
6438 | } else | |
6439 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6440 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6441 | } |
6442 | ||
28c6e247 | 6443 | return ret; |
d62a17ae | 6444 | } |
6445 | ||
6446 | ALIAS_HIDDEN( | |
6447 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6448 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6449 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6450 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6451 | "As-path attribute\n" | |
6452 | "Nexthop attribute\n" | |
6453 | "Med attribute\n") | |
596c17ba | 6454 | |
28c6e247 IR |
6455 | DEFUN (no_neighbor_attr_unchanged, |
6456 | no_neighbor_attr_unchanged_cmd, | |
6457 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6458 | NO_STR | |
6459 | NEIGHBOR_STR | |
6460 | NEIGHBOR_ADDR_STR2 | |
6461 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6462 | "As-path attribute\n" | |
6463 | "Nexthop attribute\n" | |
6464 | "Med attribute\n") | |
718e3744 | 6465 | { |
d62a17ae | 6466 | int idx = 0; |
db45f64d | 6467 | char *peer_str = argv[2]->arg; |
28c6e247 | 6468 | struct peer *peer; |
db45f64d DS |
6469 | bool aspath = false; |
6470 | bool nexthop = false; | |
6471 | bool med = false; | |
6472 | afi_t afi = bgp_node_afi(vty); | |
6473 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6474 | int ret = 0; |
f4b8ec07 | 6475 | |
28c6e247 IR |
6476 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6477 | if (!peer) | |
db45f64d | 6478 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6479 | |
6480 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6481 | aspath = true; |
6482 | ||
d62a17ae | 6483 | idx = 0; |
6484 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6485 | nexthop = true; |
6486 | ||
d62a17ae | 6487 | idx = 0; |
6488 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6489 | med = true; |
d62a17ae | 6490 | |
28c6e247 IR |
6491 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6492 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6493 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6494 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6495 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6496 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6497 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6498 | |
6499 | if (aspath) | |
28c6e247 IR |
6500 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6501 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6502 | |
6503 | if (nexthop) | |
28c6e247 IR |
6504 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6505 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6506 | |
db45f64d | 6507 | if (med) |
28c6e247 IR |
6508 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6509 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6510 | |
28c6e247 | 6511 | return ret; |
d62a17ae | 6512 | } |
6513 | ||
6514 | ALIAS_HIDDEN( | |
6515 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6516 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6517 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6518 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6519 | "As-path attribute\n" | |
6520 | "Nexthop attribute\n" | |
6521 | "Med attribute\n") | |
718e3744 | 6522 | |
28c6e247 IR |
6523 | /* EBGP multihop configuration. */ |
6524 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6525 | const char *ttl_str) | |
718e3744 | 6526 | { |
28c6e247 IR |
6527 | struct peer *peer; |
6528 | unsigned int ttl; | |
718e3744 | 6529 | |
28c6e247 IR |
6530 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6531 | if (!peer) | |
d62a17ae | 6532 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6533 | |
28c6e247 IR |
6534 | if (peer->conf_if) |
6535 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6536 | ||
6537 | if (!ttl_str) | |
6538 | ttl = MAXTTL; | |
6539 | else | |
6540 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6541 | |
28c6e247 | 6542 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6543 | } |
6544 | ||
28c6e247 | 6545 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6546 | { |
28c6e247 | 6547 | struct peer *peer; |
718e3744 | 6548 | |
28c6e247 IR |
6549 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6550 | if (!peer) | |
d62a17ae | 6551 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6552 | |
28c6e247 | 6553 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6554 | } |
6555 | ||
28c6e247 IR |
6556 | /* neighbor ebgp-multihop. */ |
6557 | DEFUN (neighbor_ebgp_multihop, | |
6558 | neighbor_ebgp_multihop_cmd, | |
6559 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6560 | NEIGHBOR_STR | |
6561 | NEIGHBOR_ADDR_STR2 | |
6562 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6563 | { |
28c6e247 IR |
6564 | int idx_peer = 1; |
6565 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6566 | } | |
f4b8ec07 | 6567 | |
28c6e247 IR |
6568 | DEFUN (neighbor_ebgp_multihop_ttl, |
6569 | neighbor_ebgp_multihop_ttl_cmd, | |
6570 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6571 | NEIGHBOR_STR | |
6572 | NEIGHBOR_ADDR_STR2 | |
6573 | "Allow EBGP neighbors not on directly connected networks\n" | |
6574 | "maximum hop count\n") | |
6575 | { | |
6576 | int idx_peer = 1; | |
6577 | int idx_number = 3; | |
6578 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6579 | argv[idx_number]->arg); | |
6580 | } | |
f4b8ec07 | 6581 | |
28c6e247 IR |
6582 | DEFUN (no_neighbor_ebgp_multihop, |
6583 | no_neighbor_ebgp_multihop_cmd, | |
6584 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6585 | NO_STR | |
6586 | NEIGHBOR_STR | |
6587 | NEIGHBOR_ADDR_STR2 | |
6588 | "Allow EBGP neighbors not on directly connected networks\n" | |
6589 | "maximum hop count\n") | |
6590 | { | |
6591 | int idx_peer = 2; | |
6592 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6593 | } |
6594 | ||
97a52c82 DA |
6595 | DEFPY (neighbor_aigp, |
6596 | neighbor_aigp_cmd, | |
6597 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp", | |
6598 | NO_STR | |
6599 | NEIGHBOR_STR | |
6600 | NEIGHBOR_ADDR_STR2 | |
6601 | "Enable send and receive of the AIGP attribute per neighbor\n") | |
6602 | { | |
6603 | struct peer *peer; | |
6604 | ||
6605 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6606 | if (!peer) | |
6607 | return CMD_WARNING_CONFIG_FAILED; | |
6608 | ||
6609 | if (no) | |
6610 | return peer_flag_unset_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6611 | else | |
6612 | return peer_flag_set_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6613 | } | |
6614 | ||
d864dd9e EB |
6615 | static uint8_t get_role_by_name(const char *role_str) |
6616 | { | |
6617 | if (strncmp(role_str, "peer", 2) == 0) | |
6618 | return ROLE_PEER; | |
6619 | if (strncmp(role_str, "provider", 2) == 0) | |
6620 | return ROLE_PROVIDER; | |
6621 | if (strncmp(role_str, "customer", 2) == 0) | |
6622 | return ROLE_CUSTOMER; | |
6623 | if (strncmp(role_str, "rs-server", 4) == 0) | |
6624 | return ROLE_RS_SERVER; | |
6625 | if (strncmp(role_str, "rs-client", 4) == 0) | |
6626 | return ROLE_RS_CLIENT; | |
8f2d6021 | 6627 | return ROLE_UNDEFINED; |
d864dd9e EB |
6628 | } |
6629 | ||
6630 | static int peer_role_set_vty(struct vty *vty, const char *ip_str, | |
8f2d6021 | 6631 | const char *role_str, bool strict_mode) |
d864dd9e EB |
6632 | { |
6633 | struct peer *peer; | |
6634 | ||
7dddd1f7 | 6635 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6636 | if (!peer) |
6637 | return CMD_WARNING_CONFIG_FAILED; | |
6638 | uint8_t role = get_role_by_name(role_str); | |
6639 | ||
8f2d6021 | 6640 | if (role == ROLE_UNDEFINED) |
d864dd9e EB |
6641 | return bgp_vty_return(vty, BGP_ERR_INVALID_ROLE_NAME); |
6642 | return bgp_vty_return(vty, peer_role_set(peer, role, strict_mode)); | |
6643 | } | |
6644 | ||
6645 | static int peer_role_unset_vty(struct vty *vty, const char *ip_str) | |
6646 | { | |
6647 | struct peer *peer; | |
6648 | ||
7dddd1f7 | 6649 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6650 | if (!peer) |
6651 | return CMD_WARNING_CONFIG_FAILED; | |
6652 | return bgp_vty_return(vty, peer_role_unset(peer)); | |
6653 | } | |
6654 | ||
8f2d6021 | 6655 | DEFPY(neighbor_role, |
d864dd9e EB |
6656 | neighbor_role_cmd, |
6657 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>", | |
6658 | NEIGHBOR_STR | |
6659 | NEIGHBOR_ADDR_STR2 | |
6660 | "Set session role\n" | |
6661 | ROLE_STR) | |
6662 | { | |
6663 | int idx_peer = 1; | |
6664 | int idx_role = 3; | |
6665 | ||
6666 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6667 | false); |
d864dd9e EB |
6668 | } |
6669 | ||
8f2d6021 | 6670 | DEFPY(neighbor_role_strict, |
d864dd9e EB |
6671 | neighbor_role_strict_cmd, |
6672 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode", | |
6673 | NEIGHBOR_STR | |
6674 | NEIGHBOR_ADDR_STR2 | |
6675 | "Set session role\n" | |
6676 | ROLE_STR | |
6677 | "Use additional restriction on peer\n") | |
6678 | { | |
6679 | int idx_peer = 1; | |
6680 | int idx_role = 3; | |
6681 | ||
6682 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6683 | true); |
d864dd9e EB |
6684 | } |
6685 | ||
8f2d6021 | 6686 | DEFPY(no_neighbor_role, |
d864dd9e EB |
6687 | no_neighbor_role_cmd, |
6688 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]", | |
6689 | NO_STR | |
6690 | NEIGHBOR_STR | |
6691 | NEIGHBOR_ADDR_STR2 | |
8f2d6021 | 6692 | "Set session role\n" |
d864dd9e | 6693 | ROLE_STR |
8f2d6021 | 6694 | "Use additional restriction on peer\n") |
d864dd9e EB |
6695 | { |
6696 | int idx_peer = 2; | |
6697 | ||
6698 | return peer_role_unset_vty(vty, argv[idx_peer]->arg); | |
6699 | } | |
6b0655a2 | 6700 | |
6ffd2079 | 6701 | /* disable-connected-check */ |
28c6e247 IR |
6702 | DEFUN (neighbor_disable_connected_check, |
6703 | neighbor_disable_connected_check_cmd, | |
6704 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6705 | NEIGHBOR_STR | |
6706 | NEIGHBOR_ADDR_STR2 | |
6707 | "one-hop away EBGP peer using loopback address\n" | |
6708 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6709 | { |
d62a17ae | 6710 | int idx_peer = 1; |
28c6e247 IR |
6711 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6712 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6713 | } |
6714 | ||
28c6e247 IR |
6715 | DEFUN (no_neighbor_disable_connected_check, |
6716 | no_neighbor_disable_connected_check_cmd, | |
6717 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6718 | NO_STR | |
6719 | NEIGHBOR_STR | |
6720 | NEIGHBOR_ADDR_STR2 | |
6721 | "one-hop away EBGP peer using loopback address\n" | |
6722 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6723 | { |
d62a17ae | 6724 | int idx_peer = 2; |
28c6e247 IR |
6725 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6726 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6727 | } |
6728 | ||
7ab294ea DA |
6729 | /* disable-link-bw-encoding-ieee */ |
6730 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6731 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6732 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6733 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6734 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6735 | { |
6736 | int idx_peer = 1; | |
6737 | ||
6738 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6739 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6740 | } | |
6741 | ||
7ab294ea DA |
6742 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6743 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6744 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6745 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6746 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6747 | { |
6748 | int idx_peer = 2; | |
6749 | ||
6750 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6751 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6752 | } | |
6753 | ||
d08c0c80 DA |
6754 | /* extended-optional-parameters */ |
6755 | DEFUN(neighbor_extended_optional_parameters, | |
6756 | neighbor_extended_optional_parameters_cmd, | |
6757 | "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6758 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6759 | "Force the extended optional parameters format for OPEN messages\n") | |
6760 | { | |
6761 | int idx_peer = 1; | |
6762 | ||
6763 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6764 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6765 | } | |
6766 | ||
6767 | DEFUN(no_neighbor_extended_optional_parameters, | |
6768 | no_neighbor_extended_optional_parameters_cmd, | |
6769 | "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6770 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6771 | "Force the extended optional parameters format for OPEN messages\n") | |
6772 | { | |
6773 | int idx_peer = 2; | |
6774 | ||
6775 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6776 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6777 | } | |
47cbc09b PM |
6778 | |
6779 | /* enforce-first-as */ | |
28c6e247 IR |
6780 | DEFUN (neighbor_enforce_first_as, |
6781 | neighbor_enforce_first_as_cmd, | |
6782 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6783 | NEIGHBOR_STR | |
6784 | NEIGHBOR_ADDR_STR2 | |
6785 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6786 | { |
6787 | int idx_peer = 1; | |
f4b8ec07 | 6788 | |
28c6e247 IR |
6789 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6790 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6791 | } |
6792 | ||
28c6e247 IR |
6793 | DEFUN (no_neighbor_enforce_first_as, |
6794 | no_neighbor_enforce_first_as_cmd, | |
6795 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6796 | NO_STR | |
6797 | NEIGHBOR_STR | |
6798 | NEIGHBOR_ADDR_STR2 | |
6799 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6800 | { |
6801 | int idx_peer = 2; | |
f4b8ec07 | 6802 | |
28c6e247 IR |
6803 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6804 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6805 | } |
6806 | ||
6807 | ||
28c6e247 IR |
6808 | DEFUN (neighbor_description, |
6809 | neighbor_description_cmd, | |
6810 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6811 | NEIGHBOR_STR | |
6812 | NEIGHBOR_ADDR_STR2 | |
6813 | "Neighbor specific description\n" | |
6814 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6815 | { |
d62a17ae | 6816 | int idx_peer = 1; |
6817 | int idx_line = 3; | |
28c6e247 | 6818 | struct peer *peer; |
d62a17ae | 6819 | char *str; |
718e3744 | 6820 | |
28c6e247 IR |
6821 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6822 | if (!peer) | |
d62a17ae | 6823 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6824 | |
d62a17ae | 6825 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6826 | |
28c6e247 | 6827 | peer_description_set(peer, str); |
718e3744 | 6828 | |
d62a17ae | 6829 | XFREE(MTYPE_TMP, str); |
718e3744 | 6830 | |
28c6e247 | 6831 | return CMD_SUCCESS; |
718e3744 | 6832 | } |
6833 | ||
28c6e247 IR |
6834 | DEFUN (no_neighbor_description, |
6835 | no_neighbor_description_cmd, | |
6836 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6837 | NO_STR | |
6838 | NEIGHBOR_STR | |
6839 | NEIGHBOR_ADDR_STR2 | |
6840 | "Neighbor specific description\n") | |
718e3744 | 6841 | { |
d62a17ae | 6842 | int idx_peer = 2; |
28c6e247 | 6843 | struct peer *peer; |
f4b8ec07 | 6844 | |
28c6e247 IR |
6845 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6846 | if (!peer) | |
d62a17ae | 6847 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6848 | |
28c6e247 | 6849 | peer_description_unset(peer); |
718e3744 | 6850 | |
28c6e247 | 6851 | return CMD_SUCCESS; |
718e3744 | 6852 | } |
6853 | ||
1d80f243 | 6854 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6855 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6856 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6857 | "Neighbor specific description\n" | |
6858 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6859 | |
28c6e247 IR |
6860 | /* Neighbor update-source. */ |
6861 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6862 | const char *source_str) | |
6863 | { | |
6864 | struct peer *peer; | |
6865 | struct prefix p; | |
6866 | union sockunion su; | |
6867 | ||
6868 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6869 | if (!peer) | |
6870 | return CMD_WARNING_CONFIG_FAILED; | |
6871 | ||
6872 | if (peer->conf_if) | |
6873 | return CMD_WARNING; | |
6874 | ||
6875 | if (source_str) { | |
6876 | if (str2sockunion(source_str, &su) == 0) | |
6877 | peer_update_source_addr_set(peer, &su); | |
6878 | else { | |
6879 | if (str2prefix(source_str, &p)) { | |
6880 | vty_out(vty, | |
6881 | "%% Invalid update-source, remove prefix length \n"); | |
6882 | return CMD_WARNING_CONFIG_FAILED; | |
6883 | } else | |
6884 | peer_update_source_if_set(peer, source_str); | |
6885 | } | |
6886 | } else | |
6887 | peer_update_source_unset(peer); | |
6888 | ||
6889 | return CMD_SUCCESS; | |
6890 | } | |
6891 | ||
d62a17ae | 6892 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6893 | "IPv4 address\n" \ | |
6894 | "IPv6 address\n" \ | |
6895 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6896 | |
28c6e247 IR |
6897 | DEFUN (neighbor_update_source, |
6898 | neighbor_update_source_cmd, | |
6899 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6900 | NEIGHBOR_STR | |
6901 | NEIGHBOR_ADDR_STR2 | |
6902 | "Source of routing updates\n" | |
6903 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6904 | { |
d62a17ae | 6905 | int idx_peer = 1; |
6906 | int idx_peer_2 = 3; | |
28c6e247 | 6907 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6908 | argv[idx_peer_2]->arg); |
718e3744 | 6909 | } |
6910 | ||
28c6e247 IR |
6911 | DEFUN (no_neighbor_update_source, |
6912 | no_neighbor_update_source_cmd, | |
6913 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6914 | NO_STR | |
6915 | NEIGHBOR_STR | |
6916 | NEIGHBOR_ADDR_STR2 | |
6917 | "Source of routing updates\n" | |
6918 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6919 | { |
d62a17ae | 6920 | int idx_peer = 2; |
28c6e247 | 6921 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6922 | } |
6b0655a2 | 6923 | |
d62a17ae | 6924 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6925 | afi_t afi, safi_t safi, | |
6926 | const char *rmap, int set) | |
718e3744 | 6927 | { |
d62a17ae | 6928 | int ret; |
6929 | struct peer *peer; | |
80912664 | 6930 | struct route_map *route_map = NULL; |
718e3744 | 6931 | |
d62a17ae | 6932 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6933 | if (!peer) | |
6934 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6935 | |
1de27621 | 6936 | if (set) { |
80912664 DS |
6937 | if (rmap) |
6938 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6939 | ret = peer_default_originate_set(peer, afi, safi, |
6940 | rmap, route_map); | |
6941 | } else | |
d62a17ae | 6942 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6943 | |
d62a17ae | 6944 | return bgp_vty_return(vty, ret); |
718e3744 | 6945 | } |
6946 | ||
6947 | /* neighbor default-originate. */ | |
6948 | DEFUN (neighbor_default_originate, | |
6949 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6950 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6951 | NEIGHBOR_STR |
6952 | NEIGHBOR_ADDR_STR2 | |
6953 | "Originate default route to this neighbor\n") | |
6954 | { | |
d62a17ae | 6955 | int idx_peer = 1; |
6956 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6957 | bgp_node_afi(vty), | |
6958 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6959 | } |
6960 | ||
d62a17ae | 6961 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6962 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6963 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6964 | "Originate default route to this neighbor\n") | |
596c17ba | 6965 | |
718e3744 | 6966 | DEFUN (neighbor_default_originate_rmap, |
6967 | neighbor_default_originate_rmap_cmd, | |
70dd370f | 6968 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
718e3744 | 6969 | NEIGHBOR_STR |
6970 | NEIGHBOR_ADDR_STR2 | |
6971 | "Originate default route to this neighbor\n" | |
6972 | "Route-map to specify criteria to originate default\n" | |
6973 | "route-map name\n") | |
6974 | { | |
d62a17ae | 6975 | int idx_peer = 1; |
6976 | int idx_word = 4; | |
6977 | return peer_default_originate_set_vty( | |
6978 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6979 | argv[idx_word]->arg, 1); | |
718e3744 | 6980 | } |
6981 | ||
d62a17ae | 6982 | ALIAS_HIDDEN( |
6983 | neighbor_default_originate_rmap, | |
6984 | neighbor_default_originate_rmap_hidden_cmd, | |
70dd370f | 6985 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
d62a17ae | 6986 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6987 | "Originate default route to this neighbor\n" | |
6988 | "Route-map to specify criteria to originate default\n" | |
6989 | "route-map name\n") | |
596c17ba | 6990 | |
718e3744 | 6991 | DEFUN (no_neighbor_default_originate, |
6992 | no_neighbor_default_originate_cmd, | |
70dd370f | 6993 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
718e3744 | 6994 | NO_STR |
6995 | NEIGHBOR_STR | |
6996 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6997 | "Originate default route to this neighbor\n" |
6998 | "Route-map to specify criteria to originate default\n" | |
6999 | "route-map name\n") | |
718e3744 | 7000 | { |
d62a17ae | 7001 | int idx_peer = 2; |
7002 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7003 | bgp_node_afi(vty), | |
7004 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 7005 | } |
7006 | ||
d62a17ae | 7007 | ALIAS_HIDDEN( |
7008 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
70dd370f | 7009 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
d62a17ae | 7010 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7011 | "Originate default route to this neighbor\n" | |
7012 | "Route-map to specify criteria to originate default\n" | |
7013 | "route-map name\n") | |
596c17ba | 7014 | |
6b0655a2 | 7015 | |
28c6e247 IR |
7016 | /* Set neighbor's BGP port. */ |
7017 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
7018 | const char *port_str) | |
718e3744 | 7019 | { |
28c6e247 IR |
7020 | struct peer *peer; |
7021 | uint16_t port; | |
7022 | struct servent *sp; | |
7023 | ||
a3aecc99 | 7024 | peer = peer_and_group_lookup_vty(vty, ip_str); |
28c6e247 IR |
7025 | if (!peer) |
7026 | return CMD_WARNING_CONFIG_FAILED; | |
7027 | ||
7028 | if (!port_str) { | |
7029 | sp = getservbyname("bgp", "tcp"); | |
7030 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
7031 | } else { | |
7032 | port = strtoul(port_str, NULL, 10); | |
7033 | } | |
718e3744 | 7034 | |
28c6e247 | 7035 | peer_port_set(peer, port); |
718e3744 | 7036 | |
28c6e247 IR |
7037 | return CMD_SUCCESS; |
7038 | } | |
f4b8ec07 | 7039 | |
28c6e247 IR |
7040 | /* Set specified peer's BGP port. */ |
7041 | DEFUN (neighbor_port, | |
7042 | neighbor_port_cmd, | |
a3aecc99 | 7043 | "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)", |
28c6e247 | 7044 | NEIGHBOR_STR |
a3aecc99 | 7045 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7046 | "Neighbor's BGP port\n" |
7047 | "TCP port number\n") | |
7048 | { | |
7049 | int idx_ip = 1; | |
7050 | int idx_number = 3; | |
7051 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
7052 | argv[idx_number]->arg); | |
f4b8ec07 | 7053 | } |
6b0655a2 | 7054 | |
28c6e247 IR |
7055 | DEFUN (no_neighbor_port, |
7056 | no_neighbor_port_cmd, | |
a3aecc99 | 7057 | "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]", |
28c6e247 IR |
7058 | NO_STR |
7059 | NEIGHBOR_STR | |
a3aecc99 | 7060 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7061 | "Neighbor's BGP port\n" |
7062 | "TCP port number\n") | |
718e3744 | 7063 | { |
f4b8ec07 | 7064 | int idx_ip = 2; |
28c6e247 IR |
7065 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
7066 | } | |
7067 | ||
7068 | ||
7069 | /* neighbor weight. */ | |
7070 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
7071 | safi_t safi, const char *weight_str) | |
7072 | { | |
7073 | int ret; | |
7074 | struct peer *peer; | |
7075 | unsigned long weight; | |
718e3744 | 7076 | |
28c6e247 IR |
7077 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7078 | if (!peer) | |
7079 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7080 | |
28c6e247 | 7081 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 7082 | |
28c6e247 IR |
7083 | ret = peer_weight_set(peer, afi, safi, weight); |
7084 | return bgp_vty_return(vty, ret); | |
718e3744 | 7085 | } |
7086 | ||
28c6e247 IR |
7087 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7088 | safi_t safi) | |
718e3744 | 7089 | { |
28c6e247 IR |
7090 | int ret; |
7091 | struct peer *peer; | |
f4b8ec07 | 7092 | |
28c6e247 IR |
7093 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7094 | if (!peer) | |
d62a17ae | 7095 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7096 | |
28c6e247 IR |
7097 | ret = peer_weight_unset(peer, afi, safi); |
7098 | return bgp_vty_return(vty, ret); | |
7099 | } | |
f4b8ec07 | 7100 | |
28c6e247 IR |
7101 | DEFUN (neighbor_weight, |
7102 | neighbor_weight_cmd, | |
7103 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7104 | NEIGHBOR_STR | |
7105 | NEIGHBOR_ADDR_STR2 | |
7106 | "Set default weight for routes from this neighbor\n" | |
7107 | "default weight\n") | |
7108 | { | |
7109 | int idx_peer = 1; | |
7110 | int idx_number = 3; | |
7111 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7112 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 7113 | } |
7114 | ||
d62a17ae | 7115 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7116 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7117 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7118 | "Set default weight for routes from this neighbor\n" | |
7119 | "default weight\n") | |
596c17ba | 7120 | |
28c6e247 IR |
7121 | DEFUN (no_neighbor_weight, |
7122 | no_neighbor_weight_cmd, | |
7123 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7124 | NO_STR | |
7125 | NEIGHBOR_STR | |
7126 | NEIGHBOR_ADDR_STR2 | |
7127 | "Set default weight for routes from this neighbor\n" | |
7128 | "default weight\n") | |
718e3744 | 7129 | { |
d62a17ae | 7130 | int idx_peer = 2; |
28c6e247 IR |
7131 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
7132 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 7133 | } |
7134 | ||
d62a17ae | 7135 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7136 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7137 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7138 | "Set default weight for routes from this neighbor\n" | |
7139 | "default weight\n") | |
596c17ba | 7140 | |
6b0655a2 | 7141 | |
718e3744 | 7142 | /* Override capability negotiation. */ |
c36bc05f IR |
7143 | DEFUN (neighbor_override_capability, |
7144 | neighbor_override_capability_cmd, | |
7145 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7146 | NEIGHBOR_STR | |
7147 | NEIGHBOR_ADDR_STR2 | |
7148 | "Override capability negotiation result\n") | |
718e3744 | 7149 | { |
d62a17ae | 7150 | int idx_peer = 1; |
c36bc05f IR |
7151 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7152 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7153 | } |
7154 | ||
c36bc05f IR |
7155 | DEFUN (no_neighbor_override_capability, |
7156 | no_neighbor_override_capability_cmd, | |
7157 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7158 | NO_STR | |
7159 | NEIGHBOR_STR | |
7160 | NEIGHBOR_ADDR_STR2 | |
7161 | "Override capability negotiation result\n") | |
718e3744 | 7162 | { |
d62a17ae | 7163 | int idx_peer = 2; |
c36bc05f IR |
7164 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7165 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7166 | } |
6b0655a2 | 7167 | |
c36bc05f IR |
7168 | DEFUN (neighbor_strict_capability, |
7169 | neighbor_strict_capability_cmd, | |
7170 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7171 | NEIGHBOR_STR | |
7172 | NEIGHBOR_ADDR_STR2 | |
7173 | "Strict capability negotiation match\n") | |
718e3744 | 7174 | { |
9fb964de PM |
7175 | int idx_peer = 1; |
7176 | ||
c36bc05f IR |
7177 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7178 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7179 | } |
7180 | ||
c36bc05f IR |
7181 | DEFUN (no_neighbor_strict_capability, |
7182 | no_neighbor_strict_capability_cmd, | |
7183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7184 | NO_STR | |
7185 | NEIGHBOR_STR | |
7186 | NEIGHBOR_ADDR_STR2 | |
7187 | "Strict capability negotiation match\n") | |
718e3744 | 7188 | { |
9fb964de | 7189 | int idx_peer = 2; |
8611c7f3 | 7190 | |
c36bc05f IR |
7191 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7192 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7193 | } |
6b0655a2 | 7194 | |
28c6e247 IR |
7195 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
7196 | const char *keep_str, const char *hold_str) | |
718e3744 | 7197 | { |
28c6e247 IR |
7198 | int ret; |
7199 | struct peer *peer; | |
7200 | uint32_t keepalive; | |
7201 | uint32_t holdtime; | |
718e3744 | 7202 | |
28c6e247 IR |
7203 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7204 | if (!peer) | |
d62a17ae | 7205 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7206 | |
28c6e247 IR |
7207 | keepalive = strtoul(keep_str, NULL, 10); |
7208 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 7209 | |
28c6e247 | 7210 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 7211 | |
28c6e247 | 7212 | return bgp_vty_return(vty, ret); |
718e3744 | 7213 | } |
6b0655a2 | 7214 | |
28c6e247 | 7215 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7216 | { |
28c6e247 IR |
7217 | int ret; |
7218 | struct peer *peer; | |
718e3744 | 7219 | |
28c6e247 IR |
7220 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7221 | if (!peer) | |
d62a17ae | 7222 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7223 | |
28c6e247 | 7224 | ret = peer_timers_unset(peer); |
718e3744 | 7225 | |
28c6e247 | 7226 | return bgp_vty_return(vty, ret); |
718e3744 | 7227 | } |
6b0655a2 | 7228 | |
28c6e247 IR |
7229 | DEFUN (neighbor_timers, |
7230 | neighbor_timers_cmd, | |
7231 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7232 | NEIGHBOR_STR | |
7233 | NEIGHBOR_ADDR_STR2 | |
7234 | "BGP per neighbor timers\n" | |
7235 | "Keepalive interval\n" | |
7236 | "Holdtime\n") | |
718e3744 | 7237 | { |
f4b8ec07 | 7238 | int idx_peer = 1; |
28c6e247 IR |
7239 | int idx_number = 3; |
7240 | int idx_number_2 = 4; | |
7241 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
7242 | argv[idx_number]->arg, | |
7243 | argv[idx_number_2]->arg); | |
7244 | } | |
7245 | ||
7246 | DEFUN (no_neighbor_timers, | |
7247 | no_neighbor_timers_cmd, | |
7248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7249 | NO_STR | |
7250 | NEIGHBOR_STR | |
7251 | NEIGHBOR_ADDR_STR2 | |
7252 | "BGP per neighbor timers\n" | |
7253 | "Keepalive interval\n" | |
7254 | "Holdtime\n") | |
7255 | { | |
7256 | int idx_peer = 2; | |
7257 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
7258 | } | |
7259 | ||
7260 | ||
7261 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
7262 | const char *time_str) | |
7263 | { | |
7264 | int ret; | |
7265 | struct peer *peer; | |
7266 | uint32_t connect; | |
718e3744 | 7267 | |
28c6e247 IR |
7268 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7269 | if (!peer) | |
d62a17ae | 7270 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7271 | |
28c6e247 IR |
7272 | connect = strtoul(time_str, NULL, 10); |
7273 | ||
7274 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 7275 | |
28c6e247 | 7276 | return bgp_vty_return(vty, ret); |
718e3744 | 7277 | } |
7278 | ||
28c6e247 | 7279 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7280 | { |
28c6e247 IR |
7281 | int ret; |
7282 | struct peer *peer; | |
718e3744 | 7283 | |
28c6e247 IR |
7284 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7285 | if (!peer) | |
d62a17ae | 7286 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7287 | |
28c6e247 IR |
7288 | ret = peer_timers_connect_unset(peer); |
7289 | ||
7290 | return bgp_vty_return(vty, ret); | |
7291 | } | |
7292 | ||
7293 | DEFUN (neighbor_timers_connect, | |
7294 | neighbor_timers_connect_cmd, | |
7295 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7296 | NEIGHBOR_STR | |
7297 | NEIGHBOR_ADDR_STR2 | |
7298 | "BGP per neighbor timers\n" | |
7299 | "BGP connect timer\n" | |
7300 | "Connect timer\n") | |
7301 | { | |
7302 | int idx_peer = 1; | |
7303 | int idx_number = 4; | |
7304 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
7305 | argv[idx_number]->arg); | |
7306 | } | |
718e3744 | 7307 | |
28c6e247 IR |
7308 | DEFUN (no_neighbor_timers_connect, |
7309 | no_neighbor_timers_connect_cmd, | |
7310 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7311 | NO_STR | |
7312 | NEIGHBOR_STR | |
7313 | NEIGHBOR_ADDR_STR2 | |
7314 | "BGP per neighbor timers\n" | |
7315 | "BGP connect timer\n" | |
7316 | "Connect timer\n") | |
7317 | { | |
7318 | int idx_peer = 2; | |
7319 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 7320 | } |
7321 | ||
d43114f3 DS |
7322 | DEFPY (neighbor_timers_delayopen, |
7323 | neighbor_timers_delayopen_cmd, | |
7324 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
7325 | NEIGHBOR_STR | |
7326 | NEIGHBOR_ADDR_STR2 | |
7327 | "BGP per neighbor timers\n" | |
7328 | "RFC 4271 DelayOpenTimer\n" | |
7329 | "DelayOpenTime timer interval\n") | |
7330 | { | |
7331 | struct peer *peer; | |
7332 | ||
7333 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7334 | if (!peer) | |
7335 | return CMD_WARNING_CONFIG_FAILED; | |
7336 | ||
7337 | if (!interval) { | |
7338 | if (peer_timers_delayopen_unset(peer)) | |
7339 | return CMD_WARNING_CONFIG_FAILED; | |
7340 | } else { | |
7341 | if (peer_timers_delayopen_set(peer, interval)) | |
7342 | return CMD_WARNING_CONFIG_FAILED; | |
7343 | } | |
7344 | ||
7345 | return CMD_SUCCESS; | |
7346 | } | |
7347 | ||
7348 | DEFPY (no_neighbor_timers_delayopen, | |
7349 | no_neighbor_timers_delayopen_cmd, | |
7350 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
7351 | NO_STR | |
7352 | NEIGHBOR_STR | |
7353 | NEIGHBOR_ADDR_STR2 | |
7354 | "BGP per neighbor timers\n" | |
7355 | "RFC 4271 DelayOpenTimer\n" | |
7356 | "DelayOpenTime timer interval\n") | |
7357 | { | |
7358 | struct peer *peer; | |
7359 | ||
7360 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7361 | if (!peer) | |
7362 | return CMD_WARNING_CONFIG_FAILED; | |
7363 | ||
7364 | if (peer_timers_delayopen_unset(peer)) | |
7365 | return CMD_WARNING_CONFIG_FAILED; | |
7366 | ||
7367 | return CMD_SUCCESS; | |
7368 | } | |
7369 | ||
28c6e247 IR |
7370 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
7371 | const char *time_str, int set) | |
718e3744 | 7372 | { |
28c6e247 IR |
7373 | int ret; |
7374 | struct peer *peer; | |
7375 | uint32_t routeadv = 0; | |
718e3744 | 7376 | |
28c6e247 IR |
7377 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7378 | if (!peer) | |
d62a17ae | 7379 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7380 | |
28c6e247 IR |
7381 | if (time_str) |
7382 | routeadv = strtoul(time_str, NULL, 10); | |
7383 | ||
7384 | if (set) | |
7385 | ret = peer_advertise_interval_set(peer, routeadv); | |
7386 | else | |
7387 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 7388 | |
28c6e247 | 7389 | return bgp_vty_return(vty, ret); |
718e3744 | 7390 | } |
7391 | ||
28c6e247 IR |
7392 | DEFUN (neighbor_advertise_interval, |
7393 | neighbor_advertise_interval_cmd, | |
7394 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7395 | NEIGHBOR_STR | |
7396 | NEIGHBOR_ADDR_STR2 | |
7397 | "Minimum interval between sending BGP routing updates\n" | |
7398 | "time in seconds\n") | |
718e3744 | 7399 | { |
28c6e247 IR |
7400 | int idx_peer = 1; |
7401 | int idx_number = 3; | |
7402 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
7403 | argv[idx_number]->arg, 1); | |
7404 | } | |
f4b8ec07 | 7405 | |
28c6e247 IR |
7406 | DEFUN (no_neighbor_advertise_interval, |
7407 | no_neighbor_advertise_interval_cmd, | |
7408 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7409 | NO_STR | |
7410 | NEIGHBOR_STR | |
7411 | NEIGHBOR_ADDR_STR2 | |
7412 | "Minimum interval between sending BGP routing updates\n" | |
7413 | "time in seconds\n") | |
7414 | { | |
7415 | int idx_peer = 2; | |
7416 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 7417 | } |
7418 | ||
6b0655a2 | 7419 | |
518f0eb1 DS |
7420 | /* Time to wait before processing route-map updates */ |
7421 | DEFUN (bgp_set_route_map_delay_timer, | |
7422 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7423 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7424 | SET_STR |
7425 | "BGP route-map delay timer\n" | |
7426 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7427 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7428 | { |
d62a17ae | 7429 | int idx_number = 3; |
d7c0a89a | 7430 | uint32_t rmap_delay_timer; |
d62a17ae | 7431 | |
7432 | if (argv[idx_number]->arg) { | |
7433 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7434 | bm->rmap_update_timer = rmap_delay_timer; | |
7435 | ||
7436 | /* if the dynamic update handling is being disabled, and a timer | |
7437 | * is | |
7438 | * running, stop the timer and act as if the timer has already | |
7439 | * fired. | |
7440 | */ | |
7441 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
fa5806c3 | 7442 | THREAD_OFF(bm->t_rmap_update); |
d62a17ae | 7443 | thread_execute(bm->master, bgp_route_map_update_timer, |
7444 | NULL, 0); | |
7445 | } | |
7446 | return CMD_SUCCESS; | |
7447 | } else { | |
7448 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7449 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7450 | } |
518f0eb1 DS |
7451 | } |
7452 | ||
7453 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7454 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7455 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7456 | NO_STR |
3a2d747c | 7457 | BGP_STR |
518f0eb1 | 7458 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7459 | "Reset to default time to wait for processing route-map changes\n" |
7460 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7461 | { |
518f0eb1 | 7462 | |
d62a17ae | 7463 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7464 | |
d62a17ae | 7465 | return CMD_SUCCESS; |
518f0eb1 DS |
7466 | } |
7467 | ||
28c6e247 IR |
7468 | /* neighbor interface */ |
7469 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7470 | const char *str) | |
718e3744 | 7471 | { |
28c6e247 | 7472 | struct peer *peer; |
718e3744 | 7473 | |
28c6e247 IR |
7474 | peer = peer_lookup_vty(vty, ip_str); |
7475 | if (!peer || peer->conf_if) { | |
7476 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7477 | return CMD_WARNING_CONFIG_FAILED; | |
7478 | } | |
718e3744 | 7479 | |
28c6e247 IR |
7480 | if (str) |
7481 | peer_interface_set(peer, str); | |
7482 | else | |
7483 | peer_interface_unset(peer); | |
718e3744 | 7484 | |
28c6e247 | 7485 | return CMD_SUCCESS; |
718e3744 | 7486 | } |
7487 | ||
28c6e247 IR |
7488 | DEFUN (neighbor_interface, |
7489 | neighbor_interface_cmd, | |
7490 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7491 | NEIGHBOR_STR | |
7492 | NEIGHBOR_ADDR_STR | |
7493 | "Interface\n" | |
7494 | "Interface name\n") | |
718e3744 | 7495 | { |
28c6e247 IR |
7496 | int idx_ip = 1; |
7497 | int idx_word = 3; | |
294d8425 | 7498 | |
28c6e247 IR |
7499 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7500 | } | |
f4b8ec07 | 7501 | |
28c6e247 IR |
7502 | DEFUN (no_neighbor_interface, |
7503 | no_neighbor_interface_cmd, | |
294d8425 | 7504 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7505 | NO_STR |
7506 | NEIGHBOR_STR | |
294d8425 | 7507 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7508 | "Interface\n" |
7509 | "Interface name\n") | |
7510 | { | |
7511 | int idx_peer = 2; | |
294d8425 | 7512 | |
28c6e247 | 7513 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7514 | } |
6b0655a2 | 7515 | |
718e3744 | 7516 | DEFUN (neighbor_distribute_list, |
7517 | neighbor_distribute_list_cmd, | |
c60dec36 | 7518 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7519 | NEIGHBOR_STR |
7520 | NEIGHBOR_ADDR_STR2 | |
7521 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7522 | "IP Access-list name\n" |
7523 | "Filter incoming updates\n" | |
7524 | "Filter outgoing updates\n") | |
7525 | { | |
d62a17ae | 7526 | int idx_peer = 1; |
7527 | int idx_acl = 3; | |
7528 | int direct, ret; | |
7529 | struct peer *peer; | |
a8206004 | 7530 | |
d62a17ae | 7531 | const char *pstr = argv[idx_peer]->arg; |
7532 | const char *acl = argv[idx_acl]->arg; | |
7533 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7534 | |
d62a17ae | 7535 | peer = peer_and_group_lookup_vty(vty, pstr); |
7536 | if (!peer) | |
7537 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7538 | |
d62a17ae | 7539 | /* Check filter direction. */ |
7540 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7541 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7542 | direct, acl); | |
a8206004 | 7543 | |
d62a17ae | 7544 | return bgp_vty_return(vty, ret); |
718e3744 | 7545 | } |
7546 | ||
d62a17ae | 7547 | ALIAS_HIDDEN( |
7548 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7549 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7550 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7551 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7552 | "IP Access-list name\n" |
7553 | "Filter incoming updates\n" | |
7554 | "Filter outgoing updates\n") | |
596c17ba | 7555 | |
718e3744 | 7556 | DEFUN (no_neighbor_distribute_list, |
7557 | no_neighbor_distribute_list_cmd, | |
c60dec36 | 7558 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7559 | NO_STR |
7560 | NEIGHBOR_STR | |
7561 | NEIGHBOR_ADDR_STR2 | |
7562 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7563 | "IP Access-list name\n" |
7564 | "Filter incoming updates\n" | |
7565 | "Filter outgoing updates\n") | |
7566 | { | |
d62a17ae | 7567 | int idx_peer = 2; |
7568 | int direct, ret; | |
7569 | struct peer *peer; | |
a8206004 | 7570 | |
d62a17ae | 7571 | const char *pstr = argv[idx_peer]->arg; |
7572 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7573 | |
d62a17ae | 7574 | peer = peer_and_group_lookup_vty(vty, pstr); |
7575 | if (!peer) | |
7576 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7577 | |
d62a17ae | 7578 | /* Check filter direction. */ |
7579 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7580 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7581 | direct); | |
a8206004 | 7582 | |
d62a17ae | 7583 | return bgp_vty_return(vty, ret); |
718e3744 | 7584 | } |
6b0655a2 | 7585 | |
d62a17ae | 7586 | ALIAS_HIDDEN( |
7587 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7588 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7589 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7590 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7591 | "IP Access-list name\n" |
7592 | "Filter incoming updates\n" | |
7593 | "Filter outgoing updates\n") | |
596c17ba | 7594 | |
718e3744 | 7595 | /* Set prefix list to the peer. */ |
642ef664 IR |
7596 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7597 | afi_t afi, safi_t safi, | |
7598 | const char *name_str, | |
7599 | const char *direct_str) | |
718e3744 | 7600 | { |
642ef664 IR |
7601 | int ret; |
7602 | int direct = FILTER_IN; | |
7603 | struct peer *peer; | |
718e3744 | 7604 | |
642ef664 IR |
7605 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7606 | if (!peer) | |
d62a17ae | 7607 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7608 | |
642ef664 IR |
7609 | /* Check filter direction. */ |
7610 | if (strncmp(direct_str, "i", 1) == 0) | |
7611 | direct = FILTER_IN; | |
7612 | else if (strncmp(direct_str, "o", 1) == 0) | |
7613 | direct = FILTER_OUT; | |
718e3744 | 7614 | |
642ef664 | 7615 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7616 | |
642ef664 IR |
7617 | return bgp_vty_return(vty, ret); |
7618 | } | |
7619 | ||
7620 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7621 | afi_t afi, safi_t safi, | |
7622 | const char *direct_str) | |
7623 | { | |
7624 | int ret; | |
7625 | struct peer *peer; | |
7626 | int direct = FILTER_IN; | |
7627 | ||
7628 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7629 | if (!peer) | |
7630 | return CMD_WARNING_CONFIG_FAILED; | |
7631 | ||
7632 | /* Check filter direction. */ | |
7633 | if (strncmp(direct_str, "i", 1) == 0) | |
7634 | direct = FILTER_IN; | |
7635 | else if (strncmp(direct_str, "o", 1) == 0) | |
7636 | direct = FILTER_OUT; | |
7637 | ||
7638 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7639 | ||
7640 | return bgp_vty_return(vty, ret); | |
7641 | } | |
7642 | ||
7643 | DEFUN (neighbor_prefix_list, | |
7644 | neighbor_prefix_list_cmd, | |
7645 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7646 | NEIGHBOR_STR | |
7647 | NEIGHBOR_ADDR_STR2 | |
7648 | "Filter updates to/from this neighbor\n" | |
7649 | "Name of a prefix list\n" | |
7650 | "Filter incoming updates\n" | |
7651 | "Filter outgoing updates\n") | |
7652 | { | |
7653 | int idx_peer = 1; | |
7654 | int idx_word = 3; | |
7655 | int idx_in_out = 4; | |
7656 | return peer_prefix_list_set_vty( | |
7657 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7658 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7659 | } |
7660 | ||
d62a17ae | 7661 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7662 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7663 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7664 | "Filter updates to/from this neighbor\n" | |
7665 | "Name of a prefix list\n" | |
7666 | "Filter incoming updates\n" | |
7667 | "Filter outgoing updates\n") | |
596c17ba | 7668 | |
642ef664 IR |
7669 | DEFUN (no_neighbor_prefix_list, |
7670 | no_neighbor_prefix_list_cmd, | |
7671 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7672 | NO_STR | |
7673 | NEIGHBOR_STR | |
7674 | NEIGHBOR_ADDR_STR2 | |
7675 | "Filter updates to/from this neighbor\n" | |
7676 | "Name of a prefix list\n" | |
7677 | "Filter incoming updates\n" | |
7678 | "Filter outgoing updates\n") | |
7679 | { | |
7680 | int idx_peer = 2; | |
7681 | int idx_in_out = 5; | |
7682 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7683 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7684 | argv[idx_in_out]->arg); | |
7685 | } | |
7686 | ||
7687 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7688 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7689 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7690 | "Filter updates to/from this neighbor\n" | |
7691 | "Name of a prefix list\n" | |
7692 | "Filter incoming updates\n" | |
7693 | "Filter outgoing updates\n") | |
7694 | ||
d62a17ae | 7695 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7696 | safi_t safi, const char *name_str, | |
7697 | const char *direct_str) | |
718e3744 | 7698 | { |
d62a17ae | 7699 | int ret; |
7700 | struct peer *peer; | |
7701 | int direct = FILTER_IN; | |
718e3744 | 7702 | |
d62a17ae | 7703 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7704 | if (!peer) | |
7705 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7706 | |
d62a17ae | 7707 | /* Check filter direction. */ |
7708 | if (strncmp(direct_str, "i", 1) == 0) | |
7709 | direct = FILTER_IN; | |
7710 | else if (strncmp(direct_str, "o", 1) == 0) | |
7711 | direct = FILTER_OUT; | |
718e3744 | 7712 | |
d62a17ae | 7713 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7714 | |
d62a17ae | 7715 | return bgp_vty_return(vty, ret); |
718e3744 | 7716 | } |
7717 | ||
d62a17ae | 7718 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7719 | safi_t safi, const char *direct_str) | |
718e3744 | 7720 | { |
d62a17ae | 7721 | int ret; |
7722 | struct peer *peer; | |
7723 | int direct = FILTER_IN; | |
718e3744 | 7724 | |
d62a17ae | 7725 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7726 | if (!peer) | |
7727 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7728 | |
d62a17ae | 7729 | /* Check filter direction. */ |
7730 | if (strncmp(direct_str, "i", 1) == 0) | |
7731 | direct = FILTER_IN; | |
7732 | else if (strncmp(direct_str, "o", 1) == 0) | |
7733 | direct = FILTER_OUT; | |
718e3744 | 7734 | |
d62a17ae | 7735 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7736 | |
d62a17ae | 7737 | return bgp_vty_return(vty, ret); |
718e3744 | 7738 | } |
7739 | ||
7740 | DEFUN (neighbor_filter_list, | |
7741 | neighbor_filter_list_cmd, | |
de71d43e | 7742 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7743 | NEIGHBOR_STR |
7744 | NEIGHBOR_ADDR_STR2 | |
7745 | "Establish BGP filters\n" | |
7746 | "AS path access-list name\n" | |
7747 | "Filter incoming routes\n" | |
7748 | "Filter outgoing routes\n") | |
7749 | { | |
d62a17ae | 7750 | int idx_peer = 1; |
7751 | int idx_word = 3; | |
7752 | int idx_in_out = 4; | |
7753 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7754 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7755 | argv[idx_in_out]->arg); | |
718e3744 | 7756 | } |
7757 | ||
d62a17ae | 7758 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
de71d43e | 7759 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7760 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7761 | "Establish BGP filters\n" | |
7762 | "AS path access-list name\n" | |
7763 | "Filter incoming routes\n" | |
7764 | "Filter outgoing routes\n") | |
596c17ba | 7765 | |
718e3744 | 7766 | DEFUN (no_neighbor_filter_list, |
7767 | no_neighbor_filter_list_cmd, | |
de71d43e | 7768 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7769 | NO_STR |
7770 | NEIGHBOR_STR | |
7771 | NEIGHBOR_ADDR_STR2 | |
7772 | "Establish BGP filters\n" | |
7773 | "AS path access-list name\n" | |
7774 | "Filter incoming routes\n" | |
7775 | "Filter outgoing routes\n") | |
7776 | { | |
d62a17ae | 7777 | int idx_peer = 2; |
7778 | int idx_in_out = 5; | |
7779 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7780 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7781 | argv[idx_in_out]->arg); | |
718e3744 | 7782 | } |
6b0655a2 | 7783 | |
d62a17ae | 7784 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
de71d43e | 7785 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7786 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7787 | "Establish BGP filters\n" | |
7788 | "AS path access-list name\n" | |
7789 | "Filter incoming routes\n" | |
7790 | "Filter outgoing routes\n") | |
596c17ba | 7791 | |
7f7940e6 MK |
7792 | /* Set advertise-map to the peer. */ |
7793 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7794 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7795 | const char *advertise_str, |
7796 | const char *condition_str, bool condition, | |
7797 | bool set) | |
7f7940e6 MK |
7798 | { |
7799 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7800 | struct peer *peer; | |
7801 | struct route_map *advertise_map; | |
7802 | struct route_map *condition_map; | |
7803 | ||
7804 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7805 | if (!peer) | |
7806 | return ret; | |
7807 | ||
7808 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7809 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7810 | ||
cf2ad4d8 MK |
7811 | if (set) |
7812 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7813 | advertise_map, condition_str, | |
7814 | condition_map, condition); | |
7815 | else | |
7816 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7817 | advertise_map, condition_str, | |
7818 | condition_map, condition); | |
7f7940e6 MK |
7819 | |
7820 | return bgp_vty_return(vty, ret); | |
7821 | } | |
7822 | ||
389e4f92 QY |
7823 | DEFPY (bgp_condadv_period, |
7824 | bgp_condadv_period_cmd, | |
7825 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7826 | NO_STR | |
7827 | BGP_STR | |
7828 | "Conditional advertisement settings\n" | |
7829 | "Set period to rescan BGP table to check if condition is met\n" | |
7830 | "Period between BGP table scans, in seconds; default 60\n") | |
7831 | { | |
7832 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7833 | ||
7834 | bgp->condition_check_period = | |
7835 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7836 | ||
7837 | return CMD_SUCCESS; | |
7838 | } | |
7839 | ||
cf2ad4d8 | 7840 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7841 | neighbor_advertise_map_cmd, |
3ccddc25 | 7842 | "[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 | 7843 | NO_STR |
7f7940e6 MK |
7844 | NEIGHBOR_STR |
7845 | NEIGHBOR_ADDR_STR2 | |
7846 | "Route-map to conditionally advertise routes\n" | |
7847 | "Name of advertise map\n" | |
7848 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7849 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7850 | "Name of the exist or non exist map\n") |
7f7940e6 | 7851 | { |
7f7940e6 MK |
7852 | bool condition = CONDITION_EXIST; |
7853 | ||
52b84062 | 7854 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7855 | condition = CONDITION_NON_EXIST; |
7856 | ||
52b84062 MK |
7857 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7858 | bgp_node_safi(vty), advertise_str, | |
7859 | condition_str, condition, !no); | |
7f7940e6 MK |
7860 | } |
7861 | ||
7862 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
3ccddc25 | 7863 | "[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 |
7864 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7865 | "Route-map to conditionally advertise routes\n" | |
7866 | "Name of advertise map\n" | |
7867 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7868 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7869 | "Name of the exist or non exist map\n") |
7f7940e6 | 7870 | |
718e3744 | 7871 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7872 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7873 | afi_t afi, safi_t safi, const char *name_str, | |
7874 | const char *direct_str) | |
718e3744 | 7875 | { |
0ea8d871 IR |
7876 | int ret; |
7877 | struct peer *peer; | |
7878 | int direct = RMAP_IN; | |
7879 | struct route_map *route_map; | |
718e3744 | 7880 | |
0ea8d871 IR |
7881 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7882 | if (!peer) | |
d62a17ae | 7883 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7884 | |
0ea8d871 IR |
7885 | /* Check filter direction. */ |
7886 | if (strncmp(direct_str, "in", 2) == 0) | |
7887 | direct = RMAP_IN; | |
7888 | else if (strncmp(direct_str, "o", 1) == 0) | |
7889 | direct = RMAP_OUT; | |
718e3744 | 7890 | |
0ea8d871 IR |
7891 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7892 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7893 | |
0ea8d871 IR |
7894 | return bgp_vty_return(vty, ret); |
7895 | } | |
7896 | ||
7897 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7898 | afi_t afi, safi_t safi, | |
7899 | const char *direct_str) | |
7900 | { | |
7901 | int ret; | |
7902 | struct peer *peer; | |
7903 | int direct = RMAP_IN; | |
7904 | ||
7905 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7906 | if (!peer) | |
7907 | return CMD_WARNING_CONFIG_FAILED; | |
7908 | ||
7909 | /* Check filter direction. */ | |
7910 | if (strncmp(direct_str, "in", 2) == 0) | |
7911 | direct = RMAP_IN; | |
7912 | else if (strncmp(direct_str, "o", 1) == 0) | |
7913 | direct = RMAP_OUT; | |
7914 | ||
7915 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7916 | ||
7917 | return bgp_vty_return(vty, ret); | |
7918 | } | |
7919 | ||
7920 | DEFUN (neighbor_route_map, | |
7921 | neighbor_route_map_cmd, | |
70dd370f | 7922 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7923 | NEIGHBOR_STR |
7924 | NEIGHBOR_ADDR_STR2 | |
7925 | "Apply route map to neighbor\n" | |
7926 | "Name of route map\n" | |
7927 | "Apply map to incoming routes\n" | |
7928 | "Apply map to outbound routes\n") | |
7929 | { | |
7930 | int idx_peer = 1; | |
7931 | int idx_word = 3; | |
7932 | int idx_in_out = 4; | |
7933 | return peer_route_map_set_vty( | |
7934 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7935 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7936 | } |
7937 | ||
d6d7ed37 | 7938 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
70dd370f | 7939 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7940 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7941 | "Apply route map to neighbor\n" | |
7942 | "Name of route map\n" | |
7943 | "Apply map to incoming routes\n" | |
7944 | "Apply map to outbound routes\n") | |
7945 | ||
0ea8d871 IR |
7946 | DEFUN (no_neighbor_route_map, |
7947 | no_neighbor_route_map_cmd, | |
70dd370f | 7948 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7949 | NO_STR |
7950 | NEIGHBOR_STR | |
7951 | NEIGHBOR_ADDR_STR2 | |
7952 | "Apply route map to neighbor\n" | |
7953 | "Name of route map\n" | |
7954 | "Apply map to incoming routes\n" | |
7955 | "Apply map to outbound routes\n") | |
7956 | { | |
7957 | int idx_peer = 2; | |
7958 | int idx_in_out = 5; | |
7959 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7960 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7961 | argv[idx_in_out]->arg); | |
7962 | } | |
7963 | ||
7964 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
70dd370f | 7965 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7966 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7967 | "Apply route map to neighbor\n" | |
7968 | "Name of route map\n" | |
7969 | "Apply map to incoming routes\n" | |
7970 | "Apply map to outbound routes\n") | |
7971 | ||
718e3744 | 7972 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7973 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7974 | afi_t afi, safi_t safi, | |
7975 | const char *name_str) | |
718e3744 | 7976 | { |
d62a17ae | 7977 | int ret; |
7978 | struct peer *peer; | |
1de27621 | 7979 | struct route_map *route_map; |
718e3744 | 7980 | |
d62a17ae | 7981 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7982 | if (!peer) | |
7983 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7984 | |
1de27621 DA |
7985 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7986 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7987 | |
d62a17ae | 7988 | return bgp_vty_return(vty, ret); |
718e3744 | 7989 | } |
7990 | ||
7991 | /* Unset route-map from the peer. */ | |
d62a17ae | 7992 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7993 | afi_t afi, safi_t safi) | |
718e3744 | 7994 | { |
d62a17ae | 7995 | int ret; |
7996 | struct peer *peer; | |
718e3744 | 7997 | |
d62a17ae | 7998 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7999 | if (!peer) | |
8000 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8001 | |
d62a17ae | 8002 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 8003 | |
d62a17ae | 8004 | return bgp_vty_return(vty, ret); |
718e3744 | 8005 | } |
8006 | ||
8007 | DEFUN (neighbor_unsuppress_map, | |
8008 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8009 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8010 | NEIGHBOR_STR |
8011 | NEIGHBOR_ADDR_STR2 | |
8012 | "Route-map to selectively unsuppress suppressed routes\n" | |
8013 | "Name of route map\n") | |
8014 | { | |
d62a17ae | 8015 | int idx_peer = 1; |
8016 | int idx_word = 3; | |
8017 | return peer_unsuppress_map_set_vty( | |
8018 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8019 | argv[idx_word]->arg); | |
718e3744 | 8020 | } |
8021 | ||
d62a17ae | 8022 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
8023 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8024 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8025 | "Route-map to selectively unsuppress suppressed routes\n" | |
8026 | "Name of route map\n") | |
596c17ba | 8027 | |
718e3744 | 8028 | DEFUN (no_neighbor_unsuppress_map, |
8029 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8030 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8031 | NO_STR |
8032 | NEIGHBOR_STR | |
8033 | NEIGHBOR_ADDR_STR2 | |
8034 | "Route-map to selectively unsuppress suppressed routes\n" | |
8035 | "Name of route map\n") | |
8036 | { | |
d62a17ae | 8037 | int idx_peer = 2; |
8038 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8039 | bgp_node_afi(vty), | |
8040 | bgp_node_safi(vty)); | |
718e3744 | 8041 | } |
6b0655a2 | 8042 | |
d62a17ae | 8043 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8044 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8045 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8046 | "Route-map to selectively unsuppress suppressed routes\n" | |
8047 | "Name of route map\n") | |
596c17ba | 8048 | |
7e62b792 IR |
8049 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
8050 | afi_t afi, safi_t safi, | |
8051 | const char *num_str, | |
8052 | const char *threshold_str, int warning, | |
8053 | const char *restart_str, | |
8054 | const char *force_str) | |
8055 | { | |
8056 | int ret; | |
8057 | struct peer *peer; | |
8058 | uint32_t max; | |
8059 | uint8_t threshold; | |
8060 | uint16_t restart; | |
8061 | ||
8062 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8063 | if (!peer) | |
8064 | return CMD_WARNING_CONFIG_FAILED; | |
8065 | ||
8066 | max = strtoul(num_str, NULL, 10); | |
8067 | if (threshold_str) | |
8068 | threshold = atoi(threshold_str); | |
8069 | else | |
8070 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
8071 | ||
8072 | if (restart_str) | |
8073 | restart = atoi(restart_str); | |
8074 | else | |
8075 | restart = 0; | |
8076 | ||
8077 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
8078 | restart, force_str ? true : false); | |
8079 | ||
8080 | return bgp_vty_return(vty, ret); | |
8081 | } | |
8082 | ||
8083 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
8084 | afi_t afi, safi_t safi) | |
8085 | { | |
8086 | int ret; | |
8087 | struct peer *peer; | |
8088 | ||
8089 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8090 | if (!peer) | |
8091 | return CMD_WARNING_CONFIG_FAILED; | |
8092 | ||
8093 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
8094 | ||
8095 | return bgp_vty_return(vty, ret); | |
8096 | } | |
8097 | ||
fde246e8 | 8098 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
8099 | DEFUN(neighbor_maximum_prefix_out, |
8100 | neighbor_maximum_prefix_out_cmd, | |
8101 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8102 | NEIGHBOR_STR | |
8103 | NEIGHBOR_ADDR_STR2 | |
8104 | "Maximum number of prefixes to be sent to this peer\n" | |
8105 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8106 | { |
80444d30 | 8107 | int ret; |
fde246e8 DA |
8108 | int idx_peer = 1; |
8109 | int idx_number = 3; | |
7e62b792 IR |
8110 | struct peer *peer; |
8111 | uint32_t max; | |
fde246e8 DA |
8112 | afi_t afi = bgp_node_afi(vty); |
8113 | safi_t safi = bgp_node_safi(vty); | |
8114 | ||
7e62b792 IR |
8115 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8116 | if (!peer) | |
fde246e8 DA |
8117 | return CMD_WARNING_CONFIG_FAILED; |
8118 | ||
7e62b792 | 8119 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 8120 | |
80444d30 | 8121 | ret = peer_maximum_prefix_out_set(peer, afi, safi, max); |
fde246e8 | 8122 | |
80444d30 | 8123 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8124 | } |
8125 | ||
1d80f243 IR |
8126 | DEFUN(no_neighbor_maximum_prefix_out, |
8127 | no_neighbor_maximum_prefix_out_cmd, | |
bc03c622 | 8128 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]", |
1d80f243 IR |
8129 | NO_STR |
8130 | NEIGHBOR_STR | |
8131 | NEIGHBOR_ADDR_STR2 | |
bc03c622 LS |
8132 | "Maximum number of prefixes to be sent to this peer\n" |
8133 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8134 | { |
80444d30 | 8135 | int ret; |
fde246e8 | 8136 | int idx_peer = 2; |
7e62b792 | 8137 | struct peer *peer; |
fde246e8 DA |
8138 | afi_t afi = bgp_node_afi(vty); |
8139 | safi_t safi = bgp_node_safi(vty); | |
8140 | ||
7e62b792 IR |
8141 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8142 | if (!peer) | |
fde246e8 DA |
8143 | return CMD_WARNING_CONFIG_FAILED; |
8144 | ||
80444d30 | 8145 | ret = peer_maximum_prefix_out_unset(peer, afi, safi); |
fde246e8 | 8146 | |
80444d30 | 8147 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8148 | } |
8149 | ||
9cbd06e0 DA |
8150 | /* Maximum number of prefix configuration. Prefix count is different |
8151 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8152 | each peer configuration. */ |
1d80f243 IR |
8153 | DEFUN (neighbor_maximum_prefix, |
8154 | neighbor_maximum_prefix_cmd, | |
8155 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
8156 | NEIGHBOR_STR | |
8157 | NEIGHBOR_ADDR_STR2 | |
8158 | "Maximum number of prefix accept from this peer\n" | |
8159 | "maximum no. of prefix limit\n" | |
8160 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8161 | { |
d62a17ae | 8162 | int idx_peer = 1; |
8163 | int idx_number = 3; | |
9cbd06e0 | 8164 | int idx_force = 0; |
7e62b792 | 8165 | char *force = NULL; |
9cbd06e0 DA |
8166 | |
8167 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8168 | force = argv[idx_force]->arg; |
9cbd06e0 | 8169 | |
7e62b792 IR |
8170 | return peer_maximum_prefix_set_vty( |
8171 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8172 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 8173 | } |
8174 | ||
d62a17ae | 8175 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8176 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8177 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8178 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8179 | "maximum no. of prefix limit\n" |
8180 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8181 | |
1d80f243 IR |
8182 | DEFUN (neighbor_maximum_prefix_threshold, |
8183 | neighbor_maximum_prefix_threshold_cmd, | |
8184 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
8185 | NEIGHBOR_STR | |
8186 | NEIGHBOR_ADDR_STR2 | |
8187 | "Maximum number of prefix accept from this peer\n" | |
8188 | "maximum no. of prefix limit\n" | |
8189 | "Threshold value (%) at which to generate a warning msg\n" | |
8190 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8191 | { |
d62a17ae | 8192 | int idx_peer = 1; |
8193 | int idx_number = 3; | |
8194 | int idx_number_2 = 4; | |
9cbd06e0 | 8195 | int idx_force = 0; |
7e62b792 | 8196 | char *force = NULL; |
9cbd06e0 DA |
8197 | |
8198 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8199 | force = argv[idx_force]->arg; |
9cbd06e0 | 8200 | |
7e62b792 IR |
8201 | return peer_maximum_prefix_set_vty( |
8202 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8203 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 8204 | } |
e0701b79 | 8205 | |
d62a17ae | 8206 | ALIAS_HIDDEN( |
8207 | neighbor_maximum_prefix_threshold, | |
8208 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8209 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8210 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8211 | "Maximum number of prefix accept from this peer\n" | |
8212 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8213 | "Threshold value (%) at which to generate a warning msg\n" |
8214 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8215 | |
1d80f243 IR |
8216 | DEFUN (neighbor_maximum_prefix_warning, |
8217 | neighbor_maximum_prefix_warning_cmd, | |
8218 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
8219 | NEIGHBOR_STR | |
8220 | NEIGHBOR_ADDR_STR2 | |
8221 | "Maximum number of prefix accept from this peer\n" | |
8222 | "maximum no. of prefix limit\n" | |
8223 | "Only give warning message when limit is exceeded\n" | |
8224 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8225 | { |
d62a17ae | 8226 | int idx_peer = 1; |
8227 | int idx_number = 3; | |
9cbd06e0 | 8228 | int idx_force = 0; |
7e62b792 | 8229 | char *force = NULL; |
9cbd06e0 DA |
8230 | |
8231 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8232 | force = argv[idx_force]->arg; |
9cbd06e0 | 8233 | |
7e62b792 IR |
8234 | return peer_maximum_prefix_set_vty( |
8235 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8236 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 8237 | } |
8238 | ||
d62a17ae | 8239 | ALIAS_HIDDEN( |
8240 | neighbor_maximum_prefix_warning, | |
8241 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8242 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8243 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8244 | "Maximum number of prefix accept from this peer\n" | |
8245 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8246 | "Only give warning message when limit is exceeded\n" |
8247 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8248 | |
1d80f243 IR |
8249 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
8250 | neighbor_maximum_prefix_threshold_warning_cmd, | |
8251 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
8252 | NEIGHBOR_STR | |
8253 | NEIGHBOR_ADDR_STR2 | |
8254 | "Maximum number of prefix accept from this peer\n" | |
8255 | "maximum no. of prefix limit\n" | |
8256 | "Threshold value (%) at which to generate a warning msg\n" | |
8257 | "Only give warning message when limit is exceeded\n" | |
8258 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8259 | { |
d62a17ae | 8260 | int idx_peer = 1; |
8261 | int idx_number = 3; | |
8262 | int idx_number_2 = 4; | |
9cbd06e0 | 8263 | int idx_force = 0; |
7e62b792 | 8264 | char *force = NULL; |
9cbd06e0 DA |
8265 | |
8266 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8267 | force = argv[idx_force]->arg; |
9cbd06e0 | 8268 | |
7e62b792 IR |
8269 | return peer_maximum_prefix_set_vty( |
8270 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8271 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 8272 | } |
8273 | ||
d62a17ae | 8274 | ALIAS_HIDDEN( |
8275 | neighbor_maximum_prefix_threshold_warning, | |
8276 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8277 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8278 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8279 | "Maximum number of prefix accept from this peer\n" | |
8280 | "maximum no. of prefix limit\n" | |
8281 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8282 | "Only give warning message when limit is exceeded\n" |
8283 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8284 | |
1d80f243 IR |
8285 | DEFUN (neighbor_maximum_prefix_restart, |
8286 | neighbor_maximum_prefix_restart_cmd, | |
8287 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
8288 | NEIGHBOR_STR | |
8289 | NEIGHBOR_ADDR_STR2 | |
8290 | "Maximum number of prefix accept from this peer\n" | |
8291 | "maximum no. of prefix limit\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 = 5; | |
9cbd06e0 | 8299 | int idx_force = 0; |
7e62b792 | 8300 | char *force = NULL; |
9cbd06e0 DA |
8301 | |
8302 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8303 | force = argv[idx_force]->arg; |
9cbd06e0 | 8304 | |
7e62b792 IR |
8305 | return peer_maximum_prefix_set_vty( |
8306 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8307 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 8308 | } |
8309 | ||
d62a17ae | 8310 | ALIAS_HIDDEN( |
8311 | neighbor_maximum_prefix_restart, | |
8312 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8313 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8314 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8315 | "Maximum number of prefix accept from this peer\n" | |
8316 | "maximum no. of prefix limit\n" | |
8317 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8318 | "Restart interval in minutes\n" |
8319 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8320 | |
1d80f243 IR |
8321 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
8322 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8323 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8324 | NEIGHBOR_STR | |
8325 | NEIGHBOR_ADDR_STR2 | |
8326 | "Maximum number of prefixes to accept from this peer\n" | |
8327 | "maximum no. of prefix limit\n" | |
8328 | "Threshold value (%) at which to generate a warning msg\n" | |
8329 | "Restart bgp connection after limit is exceeded\n" | |
8330 | "Restart interval in minutes\n" | |
8331 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8332 | { |
d62a17ae | 8333 | int idx_peer = 1; |
8334 | int idx_number = 3; | |
8335 | int idx_number_2 = 4; | |
8336 | int idx_number_3 = 6; | |
9cbd06e0 | 8337 | int idx_force = 0; |
7e62b792 | 8338 | char *force = NULL; |
9cbd06e0 DA |
8339 | |
8340 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8341 | force = argv[idx_force]->arg; |
9cbd06e0 | 8342 | |
7e62b792 IR |
8343 | return peer_maximum_prefix_set_vty( |
8344 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8345 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
8346 | argv[idx_number_3]->arg, force); | |
d62a17ae | 8347 | } |
8348 | ||
8349 | ALIAS_HIDDEN( | |
8350 | neighbor_maximum_prefix_threshold_restart, | |
8351 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8352 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8353 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8354 | "Maximum number of prefixes to accept from this peer\n" | |
8355 | "maximum no. of prefix limit\n" | |
8356 | "Threshold value (%) at which to generate a warning msg\n" | |
8357 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8358 | "Restart interval in minutes\n" |
8359 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8360 | |
1d80f243 IR |
8361 | DEFUN (no_neighbor_maximum_prefix, |
8362 | no_neighbor_maximum_prefix_cmd, | |
8363 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8364 | NO_STR | |
8365 | NEIGHBOR_STR | |
8366 | NEIGHBOR_ADDR_STR2 | |
8367 | "Maximum number of prefixes to accept from this peer\n" | |
8368 | "maximum no. of prefix limit\n" | |
8369 | "Threshold value (%) at which to generate a warning msg\n" | |
8370 | "Restart bgp connection after limit is exceeded\n" | |
8371 | "Restart interval in minutes\n" | |
8372 | "Only give warning message when limit is exceeded\n" | |
8373 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8374 | { |
d62a17ae | 8375 | int idx_peer = 2; |
7e62b792 IR |
8376 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
8377 | bgp_node_afi(vty), | |
8378 | bgp_node_safi(vty)); | |
718e3744 | 8379 | } |
e52702f2 | 8380 | |
d62a17ae | 8381 | ALIAS_HIDDEN( |
8382 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8383 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8384 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8385 | "Maximum number of prefixes to accept from this peer\n" | |
8386 | "maximum no. of prefix limit\n" | |
8387 | "Threshold value (%) at which to generate a warning msg\n" | |
8388 | "Restart bgp connection after limit is exceeded\n" | |
8389 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8390 | "Only give warning message when limit is exceeded\n" |
8391 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8392 | |
46dbf9d0 DA |
8393 | /* "neighbor accept-own" */ |
8394 | DEFPY (neighbor_accept_own, | |
8395 | neighbor_accept_own_cmd, | |
8396 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own", | |
8397 | NO_STR | |
8398 | NEIGHBOR_STR | |
8399 | NEIGHBOR_ADDR_STR2 | |
8400 | "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n") | |
8401 | { | |
8402 | struct peer *peer; | |
8403 | afi_t afi = bgp_node_afi(vty); | |
8404 | safi_t safi = bgp_node_safi(vty); | |
8405 | int ret; | |
8406 | ||
8407 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8408 | if (!peer) | |
8409 | return CMD_WARNING_CONFIG_FAILED; | |
8410 | ||
8411 | if (no) | |
8412 | ret = peer_af_flag_unset(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8413 | else | |
8414 | ret = peer_af_flag_set(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8415 | ||
8416 | return bgp_vty_return(vty, ret); | |
8417 | } | |
8418 | ||
01da2d26 DA |
8419 | /* "neighbor soo" */ |
8420 | DEFPY (neighbor_soo, | |
8421 | neighbor_soo_cmd, | |
8422 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo", | |
8423 | NEIGHBOR_STR | |
8424 | NEIGHBOR_ADDR_STR2 | |
8425 | "Set the Site-of-Origin (SoO) extended community\n" | |
8426 | "VPN extended community\n") | |
8427 | { | |
8428 | struct peer *peer; | |
8429 | afi_t afi = bgp_node_afi(vty); | |
8430 | safi_t safi = bgp_node_safi(vty); | |
8431 | struct ecommunity *ecomm_soo; | |
8432 | ||
8433 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8434 | if (!peer) | |
8435 | return CMD_WARNING_CONFIG_FAILED; | |
8436 | ||
8437 | ecomm_soo = ecommunity_str2com(soo, ECOMMUNITY_SITE_ORIGIN, 0); | |
8438 | if (!ecomm_soo) { | |
8439 | vty_out(vty, "%% Malformed SoO extended community\n"); | |
8440 | return CMD_WARNING; | |
8441 | } | |
8442 | ecommunity_str(ecomm_soo); | |
8443 | ||
8444 | if (!ecommunity_match(peer->soo[afi][safi], ecomm_soo)) { | |
8445 | ecommunity_free(&peer->soo[afi][safi]); | |
8446 | peer->soo[afi][safi] = ecomm_soo; | |
8447 | peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO); | |
8448 | } | |
8449 | ||
8450 | return bgp_vty_return(vty, | |
8451 | peer_af_flag_set(peer, afi, safi, PEER_FLAG_SOO)); | |
8452 | } | |
8453 | ||
8454 | DEFPY (no_neighbor_soo, | |
8455 | no_neighbor_soo_cmd, | |
8456 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]", | |
8457 | NO_STR | |
8458 | NEIGHBOR_STR | |
8459 | NEIGHBOR_ADDR_STR2 | |
8460 | "Set the Site-of-Origin (SoO) extended community\n" | |
8461 | "VPN extended community\n") | |
8462 | { | |
8463 | struct peer *peer; | |
8464 | afi_t afi = bgp_node_afi(vty); | |
8465 | safi_t safi = bgp_node_safi(vty); | |
8466 | ||
8467 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8468 | if (!peer) | |
8469 | return CMD_WARNING_CONFIG_FAILED; | |
8470 | ||
8471 | ecommunity_free(&peer->soo[afi][safi]); | |
8472 | ||
8473 | return bgp_vty_return( | |
8474 | vty, peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO)); | |
8475 | } | |
718e3744 | 8476 | |
718e3744 | 8477 | /* "neighbor allowas-in" */ |
8478 | DEFUN (neighbor_allowas_in, | |
8479 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8480 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8481 | NEIGHBOR_STR |
8482 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8483 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8484 | "Number of occurrences of AS number\n" |
fd8503f5 | 8485 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8486 | { |
d62a17ae | 8487 | int idx_peer = 1; |
8488 | int idx_number_origin = 3; | |
8489 | int ret; | |
8490 | int origin = 0; | |
8491 | struct peer *peer; | |
8492 | int allow_num = 0; | |
8493 | ||
8494 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8495 | if (!peer) | |
8496 | return CMD_WARNING_CONFIG_FAILED; | |
8497 | ||
8498 | if (argc <= idx_number_origin) | |
8499 | allow_num = 3; | |
8500 | else { | |
8501 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8502 | origin = 1; | |
8503 | else | |
8504 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8505 | } | |
8506 | ||
8507 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8508 | allow_num, origin); | |
8509 | ||
8510 | return bgp_vty_return(vty, ret); | |
8511 | } | |
8512 | ||
8513 | ALIAS_HIDDEN( | |
8514 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8515 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8516 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8517 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8518 | "Number of occurrences of AS number\n" |
d62a17ae | 8519 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8520 | |
718e3744 | 8521 | DEFUN (no_neighbor_allowas_in, |
8522 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8523 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8524 | NO_STR |
8525 | NEIGHBOR_STR | |
8526 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8527 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8528 | "Number of occurrences of AS number\n" |
fd8503f5 | 8529 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8530 | { |
d62a17ae | 8531 | int idx_peer = 2; |
8532 | int ret; | |
8533 | struct peer *peer; | |
718e3744 | 8534 | |
d62a17ae | 8535 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8536 | if (!peer) | |
8537 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8538 | |
d62a17ae | 8539 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8540 | bgp_node_safi(vty)); | |
718e3744 | 8541 | |
d62a17ae | 8542 | return bgp_vty_return(vty, ret); |
718e3744 | 8543 | } |
6b0655a2 | 8544 | |
d62a17ae | 8545 | ALIAS_HIDDEN( |
8546 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8548 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8549 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8550 | "Number of occurrences of AS number\n" |
d62a17ae | 8551 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8552 | |
28c6e247 IR |
8553 | DEFUN (neighbor_ttl_security, |
8554 | neighbor_ttl_security_cmd, | |
8555 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8556 | NEIGHBOR_STR | |
8557 | NEIGHBOR_ADDR_STR2 | |
8558 | "BGP ttl-security parameters\n" | |
8559 | "Specify the maximum number of hops to the BGP peer\n" | |
8560 | "Number of hops to BGP peer\n") | |
fa411a21 | 8561 | { |
d62a17ae | 8562 | int idx_peer = 1; |
8563 | int idx_number = 4; | |
28c6e247 IR |
8564 | struct peer *peer; |
8565 | int gtsm_hops; | |
d62a17ae | 8566 | |
28c6e247 IR |
8567 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8568 | if (!peer) | |
d62a17ae | 8569 | return CMD_WARNING_CONFIG_FAILED; |
8570 | ||
28c6e247 IR |
8571 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
8572 | ||
8573 | /* | |
8574 | * If 'neighbor swpX', then this is for directly connected peers, | |
8575 | * we should not accept a ttl-security hops value greater than 1. | |
8576 | */ | |
8577 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8578 | vty_out(vty, | |
8579 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8580 | argv[idx_peer]->arg); | |
8581 | return CMD_WARNING_CONFIG_FAILED; | |
8582 | } | |
7ebe625c | 8583 | |
28c6e247 | 8584 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8585 | } |
8586 | ||
1d80f243 IR |
8587 | DEFUN (no_neighbor_ttl_security, |
8588 | no_neighbor_ttl_security_cmd, | |
8589 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8590 | NO_STR | |
8591 | NEIGHBOR_STR | |
8592 | NEIGHBOR_ADDR_STR2 | |
8593 | "BGP ttl-security parameters\n" | |
8594 | "Specify the maximum number of hops to the BGP peer\n" | |
8595 | "Number of hops to BGP peer\n") | |
fa411a21 | 8596 | { |
d62a17ae | 8597 | int idx_peer = 2; |
28c6e247 | 8598 | struct peer *peer; |
fa411a21 | 8599 | |
28c6e247 IR |
8600 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8601 | if (!peer) | |
d62a17ae | 8602 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8603 | |
28c6e247 | 8604 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8605 | } |
6b0655a2 | 8606 | |
7c0e4312 DA |
8607 | /* disable-addpath-rx */ |
8608 | DEFUN(neighbor_disable_addpath_rx, | |
8609 | neighbor_disable_addpath_rx_cmd, | |
8610 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8611 | NEIGHBOR_STR | |
8612 | NEIGHBOR_ADDR_STR2 | |
8613 | "Do not accept additional paths\n") | |
8614 | { | |
8615 | char *peer_str = argv[1]->arg; | |
8616 | struct peer *peer; | |
8617 | afi_t afi = bgp_node_afi(vty); | |
8618 | safi_t safi = bgp_node_safi(vty); | |
8619 | ||
8620 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8621 | if (!peer) | |
8622 | return CMD_WARNING_CONFIG_FAILED; | |
8623 | ||
8624 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8625 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8626 | } | |
8627 | ||
8628 | DEFUN(no_neighbor_disable_addpath_rx, | |
8629 | no_neighbor_disable_addpath_rx_cmd, | |
8630 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8631 | NO_STR | |
8632 | NEIGHBOR_STR | |
8633 | NEIGHBOR_ADDR_STR2 | |
8634 | "Do not accept additional paths\n") | |
8635 | { | |
8636 | char *peer_str = argv[2]->arg; | |
8637 | struct peer *peer; | |
8638 | afi_t afi = bgp_node_afi(vty); | |
8639 | safi_t safi = bgp_node_safi(vty); | |
8640 | ||
8641 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8642 | if (!peer) | |
8643 | return CMD_WARNING_CONFIG_FAILED; | |
8644 | ||
8645 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8646 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8647 | } | |
8648 | ||
adbac85e DW |
8649 | DEFUN (neighbor_addpath_tx_all_paths, |
8650 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8651 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8652 | NEIGHBOR_STR |
8653 | NEIGHBOR_ADDR_STR2 | |
8654 | "Use addpath to advertise all paths to a neighbor\n") | |
8655 | { | |
d62a17ae | 8656 | int idx_peer = 1; |
8657 | struct peer *peer; | |
adbac85e | 8658 | |
d62a17ae | 8659 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8660 | if (!peer) | |
8661 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8662 | |
dcc68b5e MS |
8663 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8664 | BGP_ADDPATH_ALL); | |
8665 | return CMD_SUCCESS; | |
adbac85e DW |
8666 | } |
8667 | ||
d62a17ae | 8668 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8669 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8670 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8671 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8672 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8673 | |
adbac85e DW |
8674 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8675 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8676 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8677 | NO_STR |
8678 | NEIGHBOR_STR | |
8679 | NEIGHBOR_ADDR_STR2 | |
8680 | "Use addpath to advertise all paths to a neighbor\n") | |
8681 | { | |
d62a17ae | 8682 | int idx_peer = 2; |
dcc68b5e MS |
8683 | struct peer *peer; |
8684 | ||
8685 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8686 | if (!peer) | |
8687 | return CMD_WARNING_CONFIG_FAILED; | |
8688 | ||
8689 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8690 | != BGP_ADDPATH_ALL) { | |
8691 | vty_out(vty, | |
8692 | "%% Peer not currently configured to transmit all paths."); | |
8693 | return CMD_WARNING_CONFIG_FAILED; | |
8694 | } | |
8695 | ||
8696 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8697 | BGP_ADDPATH_NONE); | |
8698 | ||
8699 | return CMD_SUCCESS; | |
adbac85e DW |
8700 | } |
8701 | ||
d62a17ae | 8702 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8703 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8704 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8705 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8706 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8707 | |
06370dac DW |
8708 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8709 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8710 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8711 | NEIGHBOR_STR |
8712 | NEIGHBOR_ADDR_STR2 | |
8713 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8714 | { | |
d62a17ae | 8715 | int idx_peer = 1; |
8716 | struct peer *peer; | |
06370dac | 8717 | |
d62a17ae | 8718 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8719 | if (!peer) | |
8720 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8721 | |
dcc68b5e MS |
8722 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8723 | BGP_ADDPATH_BEST_PER_AS); | |
8724 | ||
8725 | return CMD_SUCCESS; | |
06370dac DW |
8726 | } |
8727 | ||
d62a17ae | 8728 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8729 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8730 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8731 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8732 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8733 | |
06370dac DW |
8734 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8735 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8736 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8737 | NO_STR |
8738 | NEIGHBOR_STR | |
8739 | NEIGHBOR_ADDR_STR2 | |
8740 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8741 | { | |
d62a17ae | 8742 | int idx_peer = 2; |
dcc68b5e MS |
8743 | struct peer *peer; |
8744 | ||
8745 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8746 | if (!peer) | |
8747 | return CMD_WARNING_CONFIG_FAILED; | |
8748 | ||
8749 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8750 | != BGP_ADDPATH_BEST_PER_AS) { | |
8751 | vty_out(vty, | |
8752 | "%% Peer not currently configured to transmit all best path per as."); | |
8753 | return CMD_WARNING_CONFIG_FAILED; | |
8754 | } | |
8755 | ||
8756 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8757 | BGP_ADDPATH_NONE); | |
8758 | ||
8759 | return CMD_SUCCESS; | |
06370dac DW |
8760 | } |
8761 | ||
d62a17ae | 8762 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8763 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8765 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8766 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8767 | |
2b31007c RZ |
8768 | DEFPY( |
8769 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8770 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8771 | NEIGHBOR_STR | |
8772 | NEIGHBOR_ADDR_STR2 | |
8773 | "Detect AS loops before sending to neighbor\n") | |
8774 | { | |
8775 | struct peer *peer; | |
8776 | ||
8777 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8778 | if (!peer) | |
8779 | return CMD_WARNING_CONFIG_FAILED; | |
8780 | ||
8781 | peer->as_path_loop_detection = true; | |
8782 | ||
8783 | return CMD_SUCCESS; | |
8784 | } | |
8785 | ||
8786 | DEFPY( | |
8787 | no_neighbor_aspath_loop_detection, | |
8788 | no_neighbor_aspath_loop_detection_cmd, | |
8789 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8790 | NO_STR | |
8791 | NEIGHBOR_STR | |
8792 | NEIGHBOR_ADDR_STR2 | |
8793 | "Detect AS loops before sending to neighbor\n") | |
8794 | { | |
8795 | struct peer *peer; | |
8796 | ||
8797 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8798 | if (!peer) | |
8799 | return CMD_WARNING_CONFIG_FAILED; | |
8800 | ||
8801 | peer->as_path_loop_detection = false; | |
8802 | ||
8803 | return CMD_SUCCESS; | |
8804 | } | |
8805 | ||
b9c7bc5a | 8806 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8807 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8808 | { |
b9c7bc5a PZ |
8809 | struct ecommunity *ecom = NULL; |
8810 | struct ecommunity *ecomadd; | |
ddb5b488 | 8811 | |
b9c7bc5a | 8812 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8813 | if (is_rt6) |
8814 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8815 | ECOMMUNITY_ROUTE_TARGET, | |
8816 | 0); | |
8817 | else | |
8818 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8819 | ECOMMUNITY_ROUTE_TARGET, | |
8820 | 0); | |
b9c7bc5a PZ |
8821 | if (!ecomadd) { |
8822 | vty_out(vty, "Malformed community-list value\n"); | |
8823 | if (ecom) | |
8824 | ecommunity_free(&ecom); | |
8825 | return CMD_WARNING_CONFIG_FAILED; | |
8826 | } | |
ddb5b488 | 8827 | |
b9c7bc5a PZ |
8828 | if (ecom) { |
8829 | ecommunity_merge(ecom, ecomadd); | |
8830 | ecommunity_free(&ecomadd); | |
8831 | } else { | |
8832 | ecom = ecomadd; | |
8833 | } | |
8834 | } | |
8835 | ||
8836 | if (*list) { | |
8837 | ecommunity_free(&*list); | |
ddb5b488 | 8838 | } |
b9c7bc5a PZ |
8839 | *list = ecom; |
8840 | ||
8841 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8842 | } |
8843 | ||
0ca70ba5 DS |
8844 | /* |
8845 | * v2vimport is true if we are handling a `import vrf ...` command | |
8846 | */ | |
8847 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8848 | { |
0ca70ba5 DS |
8849 | afi_t afi; |
8850 | ||
ddb5b488 | 8851 | switch (vty->node) { |
b9c7bc5a | 8852 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8853 | afi = AFI_IP; |
8854 | break; | |
b9c7bc5a | 8855 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8856 | afi = AFI_IP6; |
8857 | break; | |
ddb5b488 PZ |
8858 | default: |
8859 | vty_out(vty, | |
b9c7bc5a | 8860 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8861 | return AFI_MAX; |
ddb5b488 | 8862 | } |
69b07479 | 8863 | |
0ca70ba5 DS |
8864 | if (!v2vimport) { |
8865 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8866 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8867 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8868 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8869 | vty_out(vty, | |
8870 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8871 | return AFI_MAX; | |
8872 | } | |
8873 | } else { | |
8874 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8875 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8876 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8877 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8878 | vty_out(vty, | |
8879 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8880 | return AFI_MAX; | |
8881 | } | |
8882 | } | |
8883 | return afi; | |
ddb5b488 PZ |
8884 | } |
8885 | ||
585f1adc IR |
8886 | DEFPY (af_rd_vpn_export, |
8887 | af_rd_vpn_export_cmd, | |
8888 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8889 | NO_STR | |
8890 | "Specify route distinguisher\n" | |
8891 | "Between current address-family and vpn\n" | |
8892 | "For routes leaked from current address-family to vpn\n" | |
8893 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8894 | { |
585f1adc IR |
8895 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8896 | struct prefix_rd prd; | |
8897 | int ret; | |
ddb5b488 | 8898 | afi_t afi; |
b9c7bc5a | 8899 | int idx = 0; |
585f1adc | 8900 | bool yes = true; |
b9c7bc5a | 8901 | |
585f1adc IR |
8902 | if (argv_find(argv, argc, "no", &idx)) |
8903 | yes = false; | |
ddb5b488 | 8904 | |
585f1adc IR |
8905 | if (yes) { |
8906 | ret = str2prefix_rd(rd_str, &prd); | |
8907 | if (!ret) { | |
8908 | vty_out(vty, "%% Malformed rd\n"); | |
8909 | return CMD_WARNING_CONFIG_FAILED; | |
8910 | } | |
8911 | } | |
ddb5b488 | 8912 | |
585f1adc IR |
8913 | afi = vpn_policy_getafi(vty, bgp, false); |
8914 | if (afi == AFI_MAX) | |
8915 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8916 | |
585f1adc IR |
8917 | /* |
8918 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8919 | */ | |
8920 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8921 | bgp_get_default(), bgp); | |
ddb5b488 | 8922 | |
585f1adc IR |
8923 | if (yes) { |
8924 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8925 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8926 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8927 | } else { | |
8928 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8929 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8930 | } | |
69b07479 | 8931 | |
585f1adc IR |
8932 | /* post-change: re-export vpn routes */ |
8933 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8934 | bgp_get_default(), bgp); | |
8935 | ||
8936 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8937 | } |
8938 | ||
b9c7bc5a PZ |
8939 | ALIAS (af_rd_vpn_export, |
8940 | af_no_rd_vpn_export_cmd, | |
8941 | "no rd vpn export", | |
ddb5b488 | 8942 | NO_STR |
b9c7bc5a PZ |
8943 | "Specify route distinguisher\n" |
8944 | "Between current address-family and vpn\n" | |
8945 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8946 | |
b9c7bc5a PZ |
8947 | DEFPY (af_label_vpn_export, |
8948 | af_label_vpn_export_cmd, | |
e70e9f8e | 8949 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8950 | NO_STR |
ddb5b488 | 8951 | "label value for VRF\n" |
b9c7bc5a PZ |
8952 | "Between current address-family and vpn\n" |
8953 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8954 | "Label Value <0-1048575>\n" |
8955 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8956 | { |
8957 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8958 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8959 | afi_t afi; |
b9c7bc5a | 8960 | int idx = 0; |
c6423c31 | 8961 | bool yes = true; |
b9c7bc5a PZ |
8962 | |
8963 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8964 | yes = false; |
ddb5b488 | 8965 | |
21a16cc2 PZ |
8966 | /* If "no ...", squash trailing parameter */ |
8967 | if (!yes) | |
8968 | label_auto = NULL; | |
8969 | ||
e70e9f8e PZ |
8970 | if (yes) { |
8971 | if (!label_auto) | |
8972 | label = label_val; /* parser should force unsigned */ | |
8973 | } | |
ddb5b488 | 8974 | |
0ca70ba5 | 8975 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8976 | if (afi == AFI_MAX) |
8977 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8978 | |
e70e9f8e | 8979 | |
69b07479 DS |
8980 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8981 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8982 | /* no change */ | |
8983 | return CMD_SUCCESS; | |
e70e9f8e | 8984 | |
69b07479 DS |
8985 | /* |
8986 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8987 | */ | |
8988 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8989 | bgp_get_default(), bgp); | |
8990 | ||
8991 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8992 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8993 | ||
8994 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8995 | ||
8996 | /* | |
8997 | * label has previously been automatically | |
8998 | * assigned by labelpool: release it | |
8999 | * | |
9000 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
9001 | * means the automatic assignment is in flight | |
9002 | * and therefore the labelpool callback must | |
9003 | * detect that the auto label is not needed. | |
9004 | */ | |
9005 | ||
9006 | bgp_lp_release(LP_TYPE_VRF, | |
9007 | &bgp->vpn_policy[afi], | |
9008 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 9009 | } |
69b07479 DS |
9010 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
9011 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9012 | } | |
ddb5b488 | 9013 | |
69b07479 DS |
9014 | bgp->vpn_policy[afi].tovpn_label = label; |
9015 | if (label_auto) { | |
9016 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9017 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9018 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
9019 | vpn_leak_label_callback); | |
ddb5b488 PZ |
9020 | } |
9021 | ||
69b07479 DS |
9022 | /* post-change: re-export vpn routes */ |
9023 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9024 | bgp_get_default(), bgp); | |
9025 | ||
0d020cd6 | 9026 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
9027 | return CMD_SUCCESS; |
9028 | } | |
9029 | ||
b72c9e14 HS |
9030 | DEFPY (af_sid_vpn_export, |
9031 | af_sid_vpn_export_cmd, | |
46279a11 | 9032 | "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>", |
b72c9e14 HS |
9033 | NO_STR |
9034 | "sid value for VRF\n" | |
9035 | "Between current address-family and vpn\n" | |
9036 | "For routes leaked from current address-family to vpn\n" | |
9037 | "Sid allocation index\n" | |
9038 | "Automatically assign a label\n") | |
9039 | { | |
9040 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9041 | afi_t afi; | |
9042 | int debug = 0; | |
9043 | int idx = 0; | |
9044 | bool yes = true; | |
9045 | ||
9046 | if (argv_find(argv, argc, "no", &idx)) | |
9047 | yes = false; | |
9048 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9049 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9050 | ||
9051 | afi = vpn_policy_getafi(vty, bgp, false); | |
9052 | if (afi == AFI_MAX) | |
9053 | return CMD_WARNING_CONFIG_FAILED; | |
9054 | ||
9055 | if (!yes) { | |
9056 | /* implement me */ | |
4d4c404b | 9057 | vty_out(vty, "It's not implemented\n"); |
b72c9e14 HS |
9058 | return CMD_WARNING_CONFIG_FAILED; |
9059 | } | |
9060 | ||
527588aa CS |
9061 | if (bgp->tovpn_sid_index != 0 || |
9062 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
9063 | vty_out(vty, | |
9064 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9065 | "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n"); | |
9066 | return CMD_WARNING_CONFIG_FAILED; | |
9067 | } | |
9068 | ||
b72c9e14 HS |
9069 | /* skip when it's already configured */ |
9070 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
9071 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9072 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
9073 | return CMD_SUCCESS; | |
9074 | ||
7de4c885 HS |
9075 | /* |
9076 | * mode change between sid_idx and sid_auto isn't supported. | |
9077 | * user must negate sid vpn export when they want to change the mode | |
9078 | */ | |
b72c9e14 HS |
9079 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
9080 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9081 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
9082 | vty_out(vty, "it's already configured as %s.\n", | |
9083 | sid_auto ? "auto-mode" : "idx-mode"); | |
9084 | return CMD_WARNING_CONFIG_FAILED; | |
9085 | } | |
9086 | ||
9087 | /* pre-change */ | |
9088 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9089 | bgp_get_default(), bgp); | |
9090 | ||
9091 | if (sid_auto) { | |
9092 | /* SID allocation auto-mode */ | |
9093 | if (debug) | |
9094 | zlog_debug("%s: auto sid alloc.", __func__); | |
9095 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9096 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
9097 | } else { | |
9098 | /* SID allocation index-mode */ | |
9099 | if (debug) | |
9100 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
9101 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
9102 | } | |
9103 | ||
9104 | /* post-change */ | |
9105 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9106 | bgp_get_default(), bgp); | |
9107 | return CMD_SUCCESS; | |
9108 | } | |
9109 | ||
527588aa CS |
9110 | DEFPY (bgp_sid_vpn_export, |
9111 | bgp_sid_vpn_export_cmd, | |
346bbb39 | 9112 | "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>", |
527588aa CS |
9113 | NO_STR |
9114 | "sid value for VRF\n" | |
9115 | "Between current vrf and vpn\n" | |
9116 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9117 | "For routes leaked from current vrf to vpn\n" | |
9118 | "Sid allocation index\n" | |
9119 | "Automatically assign a label\n") | |
9120 | { | |
9121 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9122 | int debug; | |
9123 | ||
9124 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9125 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9126 | ||
9127 | if (no) { | |
e606d8ec CS |
9128 | /* when per-VRF SID is not set, do nothing */ |
9129 | if (bgp->tovpn_sid_index == 0 && | |
9130 | !CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) | |
9131 | return CMD_SUCCESS; | |
9132 | ||
9133 | sid_idx = 0; | |
9134 | sid_auto = false; | |
9135 | bgp->tovpn_sid_index = 0; | |
9136 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
527588aa CS |
9137 | } |
9138 | ||
9139 | if (bgp->vpn_policy[AFI_IP].tovpn_sid_index != 0 || | |
9140 | CHECK_FLAG(bgp->vpn_policy[AFI_IP].flags, | |
9141 | BGP_VPN_POLICY_TOVPN_SID_AUTO) || | |
9142 | bgp->vpn_policy[AFI_IP6].tovpn_sid_index != 0 || | |
9143 | CHECK_FLAG(bgp->vpn_policy[AFI_IP6].flags, | |
9144 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
9145 | vty_out(vty, | |
9146 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9147 | "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n"); | |
9148 | return CMD_WARNING_CONFIG_FAILED; | |
9149 | } | |
9150 | ||
9151 | /* skip when it's already configured */ | |
9152 | if ((sid_idx != 0 && bgp->tovpn_sid_index != 0) || | |
9153 | (sid_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) | |
9154 | return CMD_SUCCESS; | |
9155 | ||
9156 | /* | |
9157 | * mode change between sid_idx and sid_auto isn't supported. | |
9158 | * user must negate sid vpn export when they want to change the mode | |
9159 | */ | |
9160 | if ((sid_auto && bgp->tovpn_sid_index != 0) || | |
9161 | (sid_idx != 0 && | |
9162 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) { | |
9163 | vty_out(vty, "it's already configured as %s.\n", | |
9164 | sid_auto ? "auto-mode" : "idx-mode"); | |
9165 | return CMD_WARNING_CONFIG_FAILED; | |
9166 | } | |
9167 | ||
9168 | /* pre-change */ | |
9169 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9170 | bgp); | |
9171 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp_get_default(), | |
9172 | bgp); | |
9173 | ||
9174 | if (sid_auto) { | |
9175 | /* SID allocation auto-mode */ | |
9176 | if (debug) | |
9177 | zlog_debug("%s: auto per-vrf sid alloc.", __func__); | |
9178 | SET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
e606d8ec | 9179 | } else if (sid_idx != 0) { |
527588aa CS |
9180 | /* SID allocation index-mode */ |
9181 | if (debug) | |
9182 | zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__, | |
9183 | sid_idx); | |
9184 | bgp->tovpn_sid_index = sid_idx; | |
9185 | } | |
9186 | ||
9187 | /* post-change */ | |
9188 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9189 | bgp); | |
9190 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, | |
9191 | bgp_get_default(), bgp); | |
9192 | ||
9193 | return CMD_SUCCESS; | |
9194 | } | |
9195 | ||
b9c7bc5a PZ |
9196 | ALIAS (af_label_vpn_export, |
9197 | af_no_label_vpn_export_cmd, | |
9198 | "no label vpn export", | |
9199 | NO_STR | |
9200 | "label value for VRF\n" | |
9201 | "Between current address-family and vpn\n" | |
9202 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9203 | |
e606d8ec CS |
9204 | ALIAS (bgp_sid_vpn_export, |
9205 | no_bgp_sid_vpn_export_cmd, | |
9206 | "no$no sid vpn per-vrf export", | |
9207 | NO_STR | |
9208 | "sid value for VRF\n" | |
9209 | "Between current vrf and vpn\n" | |
9210 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9211 | "For routes leaked from current vrf to vpn\n") | |
9212 | ||
585f1adc | 9213 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 9214 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9215 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9216 | NO_STR |
ddb5b488 | 9217 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9218 | "Between current address-family and vpn\n" |
9219 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9220 | "IPv4 prefix\n" |
9221 | "IPv6 prefix\n") | |
9222 | { | |
585f1adc | 9223 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 9224 | afi_t afi; |
ddb5b488 PZ |
9225 | struct prefix p; |
9226 | ||
8c85ca28 QY |
9227 | if (!no) { |
9228 | if (!nexthop_su) { | |
9229 | vty_out(vty, "%% Nexthop required\n"); | |
9230 | return CMD_WARNING_CONFIG_FAILED; | |
9231 | } | |
8c85ca28 | 9232 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9233 | return CMD_WARNING_CONFIG_FAILED; |
9234 | } | |
ddb5b488 | 9235 | |
585f1adc IR |
9236 | afi = vpn_policy_getafi(vty, bgp, false); |
9237 | if (afi == AFI_MAX) | |
9238 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9239 | |
585f1adc IR |
9240 | /* |
9241 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9242 | */ | |
9243 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9244 | bgp_get_default(), bgp); | |
ddb5b488 | 9245 | |
585f1adc IR |
9246 | if (!no) { |
9247 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
9248 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9249 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9250 | } else { | |
9251 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
9252 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9253 | } | |
69b07479 | 9254 | |
585f1adc IR |
9255 | /* post-change: re-export vpn routes */ |
9256 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9257 | bgp_get_default(), bgp); | |
37a87b8f | 9258 | |
585f1adc | 9259 | return CMD_SUCCESS; |
ddb5b488 PZ |
9260 | } |
9261 | ||
b9c7bc5a | 9262 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9263 | { |
b9c7bc5a PZ |
9264 | if (!strcmp(dstr, "import")) { |
9265 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9266 | } else if (!strcmp(dstr, "export")) { | |
9267 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9268 | } else if (!strcmp(dstr, "both")) { | |
9269 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9270 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9271 | } else { | |
9272 | vty_out(vty, "%% direction parse error\n"); | |
9273 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9274 | } |
ddb5b488 PZ |
9275 | return CMD_SUCCESS; |
9276 | } | |
9277 | ||
b9c7bc5a PZ |
9278 | DEFPY (af_rt_vpn_imexport, |
9279 | af_rt_vpn_imexport_cmd, | |
9280 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9281 | NO_STR | |
9282 | "Specify route target list\n" | |
ddb5b488 | 9283 | "Specify route target list\n" |
b9c7bc5a PZ |
9284 | "Between current address-family and vpn\n" |
9285 | "For routes leaked from vpn to current address-family: match any\n" | |
9286 | "For routes leaked from current address-family to vpn: set\n" | |
9287 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9288 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9289 | { | |
9290 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9291 | int ret; | |
9292 | struct ecommunity *ecom = NULL; | |
9293 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9294 | enum vpn_policy_direction dir; |
ddb5b488 PZ |
9295 | afi_t afi; |
9296 | int idx = 0; | |
c6423c31 | 9297 | bool yes = true; |
ddb5b488 | 9298 | |
b9c7bc5a | 9299 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9300 | yes = false; |
b9c7bc5a | 9301 | |
0ca70ba5 | 9302 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9303 | if (afi == AFI_MAX) |
9304 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9305 | |
b9c7bc5a | 9306 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9307 | if (ret != CMD_SUCCESS) |
9308 | return ret; | |
9309 | ||
b9c7bc5a PZ |
9310 | if (yes) { |
9311 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9312 | vty_out(vty, "%% Missing RTLIST\n"); | |
9313 | return CMD_WARNING_CONFIG_FAILED; | |
9314 | } | |
c6423c31 | 9315 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9316 | if (ret != CMD_SUCCESS) { |
9317 | return ret; | |
9318 | } | |
ddb5b488 PZ |
9319 | } |
9320 | ||
69b07479 DS |
9321 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9322 | if (!dodir[dir]) | |
ddb5b488 | 9323 | continue; |
ddb5b488 | 9324 | |
69b07479 | 9325 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9326 | |
69b07479 DS |
9327 | if (yes) { |
9328 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9329 | ecommunity_free( | |
9330 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9331 | bgp->vpn_policy[afi].rtlist[dir] = | |
9332 | ecommunity_dup(ecom); | |
9333 | } else { | |
9334 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9335 | ecommunity_free( | |
9336 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9337 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9338 | } |
69b07479 DS |
9339 | |
9340 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9341 | } |
69b07479 | 9342 | |
d555f3e9 PZ |
9343 | if (ecom) |
9344 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9345 | |
9346 | return CMD_SUCCESS; | |
9347 | } | |
9348 | ||
b9c7bc5a PZ |
9349 | ALIAS (af_rt_vpn_imexport, |
9350 | af_no_rt_vpn_imexport_cmd, | |
9351 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9352 | NO_STR |
9353 | "Specify route target list\n" | |
b9c7bc5a PZ |
9354 | "Specify route target list\n" |
9355 | "Between current address-family and vpn\n" | |
9356 | "For routes leaked from vpn to current address-family\n" | |
9357 | "For routes leaked from current address-family to vpn\n" | |
9358 | "both import and export\n") | |
9359 | ||
585f1adc | 9360 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9361 | af_route_map_vpn_imexport_cmd, |
9362 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9363 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9364 | NO_STR | |
ddb5b488 | 9365 | "Specify route map\n" |
b9c7bc5a PZ |
9366 | "Between current address-family and vpn\n" |
9367 | "For routes leaked from vpn to current address-family\n" | |
9368 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9369 | "name of route-map\n") |
9370 | { | |
585f1adc IR |
9371 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9372 | int ret; | |
9373 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9374 | enum vpn_policy_direction dir; |
ddb5b488 | 9375 | afi_t afi; |
ddb5b488 | 9376 | int idx = 0; |
585f1adc | 9377 | bool yes = true; |
ddb5b488 | 9378 | |
585f1adc IR |
9379 | if (argv_find(argv, argc, "no", &idx)) |
9380 | yes = false; | |
ddb5b488 | 9381 | |
585f1adc IR |
9382 | afi = vpn_policy_getafi(vty, bgp, false); |
9383 | if (afi == AFI_MAX) | |
9384 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9385 | |
585f1adc IR |
9386 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
9387 | if (ret != CMD_SUCCESS) | |
9388 | return ret; | |
ddb5b488 | 9389 | |
585f1adc IR |
9390 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9391 | if (!dodir[dir]) | |
9392 | continue; | |
69b07479 | 9393 | |
585f1adc IR |
9394 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
9395 | ||
9396 | if (yes) { | |
9397 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9398 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9399 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9400 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
9401 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9402 | bgp->vpn_policy[afi].rmap[dir] = | |
9403 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9404 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9405 | return CMD_SUCCESS; | |
9406 | } else { | |
9407 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9408 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9409 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9410 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9411 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9412 | } | |
9413 | ||
9414 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9415 | } | |
ddb5b488 | 9416 | |
585f1adc | 9417 | return CMD_SUCCESS; |
ddb5b488 PZ |
9418 | } |
9419 | ||
b9c7bc5a PZ |
9420 | ALIAS (af_route_map_vpn_imexport, |
9421 | af_no_route_map_vpn_imexport_cmd, | |
9422 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9423 | NO_STR |
9424 | "Specify route map\n" | |
b9c7bc5a PZ |
9425 | "Between current address-family and vpn\n" |
9426 | "For routes leaked from vpn to current address-family\n" | |
9427 | "For routes leaked from current address-family to vpn\n") | |
9428 | ||
bb4f6190 | 9429 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9430 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9431 | "Import routes from another VRF\n" |
9432 | "Vrf routes being filtered\n" | |
9433 | "Specify route map\n" | |
9434 | "name of route-map\n") | |
9435 | { | |
9436 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9437 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
bb4f6190 | 9438 | afi_t afi; |
bb4f6190 DS |
9439 | struct bgp *bgp_default; |
9440 | ||
0ca70ba5 | 9441 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9442 | if (afi == AFI_MAX) |
9443 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9444 | |
9445 | bgp_default = bgp_get_default(); | |
9446 | if (!bgp_default) { | |
9447 | int32_t ret; | |
9448 | as_t as = bgp->as; | |
9449 | ||
9450 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
9451 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
9452 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
9453 | |
9454 | if (ret) { | |
9455 | vty_out(vty, | |
9456 | "VRF default is not configured as a bgp instance\n"); | |
9457 | return CMD_WARNING; | |
9458 | } | |
9459 | } | |
9460 | ||
69b07479 | 9461 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9462 | |
ae6a6fb4 DS |
9463 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9464 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9465 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9466 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9467 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9468 | bgp->vpn_policy[afi].rmap[dir] = | |
9469 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9470 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9471 | return CMD_SUCCESS; | |
9472 | ||
9473 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9474 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9475 | |
69b07479 DS |
9476 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9477 | ||
bb4f6190 DS |
9478 | return CMD_SUCCESS; |
9479 | } | |
9480 | ||
ae6a6fb4 DS |
9481 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9482 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9483 | NO_STR |
9484 | "Import routes from another VRF\n" | |
9485 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9486 | "Specify route map\n" |
9487 | "name of route-map\n") | |
9488 | { | |
9489 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9490 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
ae6a6fb4 DS |
9491 | afi_t afi; |
9492 | ||
9493 | afi = vpn_policy_getafi(vty, bgp, true); | |
9494 | if (afi == AFI_MAX) | |
9495 | return CMD_WARNING_CONFIG_FAILED; | |
9496 | ||
9497 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9498 | ||
9499 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9500 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9501 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9502 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9503 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9504 | ||
9505 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9506 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9507 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9508 | ||
9509 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9510 | ||
9511 | return CMD_SUCCESS; | |
9512 | } | |
bb4f6190 | 9513 | |
585f1adc IR |
9514 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
9515 | "[no] import vrf VIEWVRFNAME$import_name", | |
9516 | NO_STR | |
9517 | "Import routes from another VRF\n" | |
9518 | "VRF to import from\n" | |
9519 | "The name of the VRF\n") | |
12a844a5 | 9520 | { |
585f1adc IR |
9521 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9522 | struct listnode *node; | |
9523 | struct bgp *vrf_bgp, *bgp_default; | |
9524 | int32_t ret = 0; | |
9525 | as_t as = bgp->as; | |
9526 | bool remove = false; | |
9527 | int32_t idx = 0; | |
9528 | char *vname; | |
9529 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
9530 | safi_t safi; |
9531 | afi_t afi; | |
9532 | ||
867f0cca | 9533 | if (import_name == NULL) { |
9534 | vty_out(vty, "%% Missing import name\n"); | |
9535 | return CMD_WARNING; | |
9536 | } | |
9537 | ||
ae6a6fb4 DS |
9538 | if (strcmp(import_name, "route-map") == 0) { |
9539 | vty_out(vty, "%% Must include route-map name\n"); | |
9540 | return CMD_WARNING; | |
9541 | } | |
9542 | ||
585f1adc IR |
9543 | if (argv_find(argv, argc, "no", &idx)) |
9544 | remove = true; | |
9545 | ||
9546 | afi = vpn_policy_getafi(vty, bgp, true); | |
9547 | if (afi == AFI_MAX) | |
9548 | return CMD_WARNING_CONFIG_FAILED; | |
9549 | ||
12a844a5 DS |
9550 | safi = bgp_node_safi(vty); |
9551 | ||
585f1adc IR |
9552 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
9553 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
9554 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
9555 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
9556 | remove ? "unimport" : "import", import_name); | |
9557 | return CMD_WARNING; | |
9558 | } | |
25679caa | 9559 | |
585f1adc IR |
9560 | bgp_default = bgp_get_default(); |
9561 | if (!bgp_default) { | |
9562 | /* Auto-create assuming the same AS */ | |
9563 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
9564 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 9565 | |
585f1adc IR |
9566 | if (ret) { |
9567 | vty_out(vty, | |
9568 | "VRF default is not configured as a bgp instance\n"); | |
9569 | return CMD_WARNING; | |
9570 | } | |
9571 | } | |
12a844a5 | 9572 | |
585f1adc IR |
9573 | vrf_bgp = bgp_lookup_by_name(import_name); |
9574 | if (!vrf_bgp) { | |
9575 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
9576 | vrf_bgp = bgp_default; | |
9577 | else | |
9578 | /* Auto-create assuming the same AS */ | |
9579 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
9580 | ||
9581 | if (ret) { | |
9582 | vty_out(vty, | |
9583 | "VRF %s is not configured as a bgp instance\n", | |
9584 | import_name); | |
9585 | return CMD_WARNING; | |
9586 | } | |
9587 | } | |
9588 | ||
9589 | if (remove) { | |
9590 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
9591 | } else { | |
9592 | /* Already importing from "import_vrf"? */ | |
9593 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
9594 | vname)) { | |
9595 | if (strcmp(vname, import_name) == 0) | |
9596 | return CMD_WARNING; | |
9597 | } | |
9598 | ||
9599 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
9600 | } | |
9601 | ||
9602 | return CMD_SUCCESS; | |
12a844a5 DS |
9603 | } |
9604 | ||
b9c7bc5a | 9605 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 9606 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
9607 | bgp_imexport_vpn_cmd, |
9608 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9609 | NO_STR |
9610 | "Import routes to this address-family\n" | |
9611 | "Export routes from this address-family\n" | |
9612 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9613 | { |
585f1adc IR |
9614 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9615 | int previous_state; | |
37a87b8f | 9616 | afi_t afi; |
585f1adc IR |
9617 | safi_t safi; |
9618 | int idx = 0; | |
9619 | bool yes = true; | |
9620 | int flag; | |
9c2fd3fe | 9621 | enum vpn_policy_direction dir; |
585f1adc IR |
9622 | |
9623 | if (argv_find(argv, argc, "no", &idx)) | |
9624 | yes = false; | |
9625 | ||
9626 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
9627 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
9628 | ||
9629 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
9630 | return CMD_WARNING_CONFIG_FAILED; | |
9631 | } | |
ddb5b488 | 9632 | |
b9c7bc5a PZ |
9633 | afi = bgp_node_afi(vty); |
9634 | safi = bgp_node_safi(vty); | |
585f1adc IR |
9635 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
9636 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
9637 | return CMD_WARNING_CONFIG_FAILED; | |
9638 | } | |
ddb5b488 | 9639 | |
b9c7bc5a | 9640 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
9641 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
9642 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 9643 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
9644 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
9645 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
9646 | } else { |
9647 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9648 | return CMD_WARNING_CONFIG_FAILED; | |
9649 | } | |
9650 | ||
585f1adc | 9651 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 9652 | |
585f1adc IR |
9653 | if (yes) { |
9654 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9655 | if (!previous_state) { | |
9656 | /* trigger export current vrf */ | |
9657 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9658 | } | |
9659 | } else { | |
9660 | if (previous_state) { | |
9661 | /* trigger un-export current vrf */ | |
9662 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9663 | } | |
9664 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9665 | } | |
37a87b8f | 9666 | |
1ca2fd11 IR |
9667 | hook_call(bgp_snmp_init_stats, bgp); |
9668 | ||
585f1adc | 9669 | return CMD_SUCCESS; |
ddb5b488 PZ |
9670 | } |
9671 | ||
301ad80a PG |
9672 | DEFPY (af_routetarget_import, |
9673 | af_routetarget_import_cmd, | |
9a659715 | 9674 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9675 | NO_STR |
9676 | "Specify route target list\n" | |
9677 | "Specify route target list\n" | |
9a659715 PG |
9678 | "Specify route target list\n" |
9679 | "Specify route target list\n" | |
301ad80a PG |
9680 | "Flow-spec redirect type route target\n" |
9681 | "Import routes to this address-family\n" | |
9a659715 | 9682 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9683 | { |
9684 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9685 | int ret; | |
9686 | struct ecommunity *ecom = NULL; | |
301ad80a | 9687 | afi_t afi; |
9a659715 | 9688 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9689 | bool yes = true; |
9690 | bool rt6 = false; | |
301ad80a PG |
9691 | |
9692 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9693 | yes = false; |
301ad80a | 9694 | |
9a659715 PG |
9695 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9696 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9697 | rt6 = true; |
301ad80a | 9698 | |
0ca70ba5 | 9699 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9700 | if (afi == AFI_MAX) |
9701 | return CMD_WARNING_CONFIG_FAILED; | |
9702 | ||
9a659715 PG |
9703 | if (rt6 && afi != AFI_IP6) |
9704 | return CMD_WARNING_CONFIG_FAILED; | |
9705 | ||
301ad80a PG |
9706 | if (yes) { |
9707 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9708 | vty_out(vty, "%% Missing RTLIST\n"); | |
9709 | return CMD_WARNING_CONFIG_FAILED; | |
9710 | } | |
9a659715 | 9711 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9712 | if (ret != CMD_SUCCESS) |
9713 | return ret; | |
9714 | } | |
69b07479 DS |
9715 | |
9716 | if (yes) { | |
9717 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9718 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9719 | .import_redirect_rtlist); |
69b07479 DS |
9720 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9721 | ecommunity_dup(ecom); | |
9722 | } else { | |
9723 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9724 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9725 | .import_redirect_rtlist); |
69b07479 | 9726 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9727 | } |
69b07479 | 9728 | |
301ad80a PG |
9729 | if (ecom) |
9730 | ecommunity_free(&ecom); | |
9731 | ||
9732 | return CMD_SUCCESS; | |
9733 | } | |
9734 | ||
505e5056 | 9735 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9736 | address_family_ipv4_safi_cmd, |
9737 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9738 | "Enter Address Family command mode\n" | |
00e6edb9 | 9739 | BGP_AF_STR |
7c40bf39 | 9740 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 9741 | { |
f51bae9c | 9742 | |
d62a17ae | 9743 | if (argc == 3) { |
585f1adc IR |
9744 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9745 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9746 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9747 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9748 | && safi != SAFI_EVPN) { |
31947174 MK |
9749 | vty_out(vty, |
9750 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9751 | return CMD_WARNING_CONFIG_FAILED; |
9752 | } | |
585f1adc IR |
9753 | vty->node = bgp_node_type(AFI_IP, safi); |
9754 | } else | |
9755 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9756 | |
d62a17ae | 9757 | return CMD_SUCCESS; |
718e3744 | 9758 | } |
9759 | ||
505e5056 | 9760 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9761 | address_family_ipv6_safi_cmd, |
9762 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9763 | "Enter Address Family command mode\n" | |
00e6edb9 | 9764 | BGP_AF_STR |
7c40bf39 | 9765 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 9766 | { |
d62a17ae | 9767 | if (argc == 3) { |
585f1adc IR |
9768 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9769 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9770 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9771 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9772 | && safi != SAFI_EVPN) { |
31947174 MK |
9773 | vty_out(vty, |
9774 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9775 | return CMD_WARNING_CONFIG_FAILED; |
9776 | } | |
585f1adc IR |
9777 | vty->node = bgp_node_type(AFI_IP6, safi); |
9778 | } else | |
9779 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9780 | |
d62a17ae | 9781 | return CMD_SUCCESS; |
25ffbdc1 | 9782 | } |
718e3744 | 9783 | |
d6902373 | 9784 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9785 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9786 | address_family_vpnv4_cmd, |
8334fd5a | 9787 | "address-family vpnv4 [unicast]", |
718e3744 | 9788 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9789 | BGP_AF_STR |
9790 | BGP_AF_MODIFIER_STR) | |
718e3744 | 9791 | { |
d62a17ae | 9792 | vty->node = BGP_VPNV4_NODE; |
9793 | return CMD_SUCCESS; | |
718e3744 | 9794 | } |
9795 | ||
505e5056 | 9796 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9797 | address_family_vpnv6_cmd, |
8334fd5a | 9798 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9799 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9800 | BGP_AF_STR |
9801 | BGP_AF_MODIFIER_STR) | |
8ecd3266 | 9802 | { |
d62a17ae | 9803 | vty->node = BGP_VPNV6_NODE; |
9804 | return CMD_SUCCESS; | |
8ecd3266 | 9805 | } |
64e4a6c5 | 9806 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9807 | |
505e5056 | 9808 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9809 | address_family_evpn_cmd, |
7111c1a0 | 9810 | "address-family l2vpn evpn", |
4e0b7b6d | 9811 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9812 | BGP_AF_STR |
9813 | BGP_AF_MODIFIER_STR) | |
4e0b7b6d | 9814 | { |
2131d5cf | 9815 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9816 | vty->node = BGP_EVPN_NODE; |
9817 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9818 | } |
9819 | ||
bfaab44d HS |
9820 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9821 | bgp_segment_routing_srv6_cmd, | |
9822 | "segment-routing srv6", | |
9823 | "Segment-Routing configuration\n" | |
9824 | "Segment-Routing SRv6 configuration\n") | |
9825 | { | |
9826 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9827 | bgp->srv6_enabled = true; |
bfaab44d HS |
9828 | vty->node = BGP_SRV6_NODE; |
9829 | return CMD_SUCCESS; | |
9830 | } | |
9831 | ||
0249b8b6 HS |
9832 | DEFUN (no_bgp_segment_routing_srv6, |
9833 | no_bgp_segment_routing_srv6_cmd, | |
9834 | "no segment-routing srv6", | |
9835 | NO_STR | |
9836 | "Segment-Routing configuration\n" | |
9837 | "Segment-Routing SRv6 configuration\n") | |
9838 | { | |
9839 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9840 | ||
9841 | if (strlen(bgp->srv6_locator_name) > 0) | |
9842 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9843 | return CMD_WARNING_CONFIG_FAILED; | |
9844 | ||
9845 | bgp->srv6_enabled = false; | |
9846 | return CMD_SUCCESS; | |
9847 | } | |
9848 | ||
a0281b2e HS |
9849 | DEFPY (bgp_srv6_locator, |
9850 | bgp_srv6_locator_cmd, | |
9851 | "locator NAME$name", | |
9852 | "Specify SRv6 locator\n" | |
9853 | "Specify SRv6 locator\n") | |
9854 | { | |
9855 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9856 | int ret; |
a0281b2e HS |
9857 | |
9858 | if (strlen(bgp->srv6_locator_name) > 0 | |
9859 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9860 | vty_out(vty, "srv6 locator is already configured\n"); | |
9861 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9862 | } |
9863 | ||
9864 | snprintf(bgp->srv6_locator_name, | |
9865 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9866 | |
7de4c885 | 9867 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9868 | if (ret < 0) |
9869 | return CMD_WARNING_CONFIG_FAILED; | |
9870 | ||
9871 | return CMD_SUCCESS; | |
9872 | } | |
9873 | ||
0249b8b6 HS |
9874 | DEFPY (no_bgp_srv6_locator, |
9875 | no_bgp_srv6_locator_cmd, | |
9876 | "no locator NAME$name", | |
9877 | NO_STR | |
9878 | "Specify SRv6 locator\n" | |
9879 | "Specify SRv6 locator\n") | |
9880 | { | |
9881 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9882 | ||
9883 | /* when locator isn't configured, do nothing */ | |
9884 | if (strlen(bgp->srv6_locator_name) < 1) | |
9885 | return CMD_SUCCESS; | |
9886 | ||
9887 | /* name validation */ | |
9888 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9889 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9890 | return CMD_WARNING_CONFIG_FAILED; | |
9891 | } | |
9892 | ||
9893 | /* unset locator */ | |
9894 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9895 | return CMD_WARNING_CONFIG_FAILED; | |
9896 | ||
9897 | return CMD_SUCCESS; | |
9898 | } | |
9899 | ||
ea372e81 HS |
9900 | DEFPY (show_bgp_srv6, |
9901 | show_bgp_srv6_cmd, | |
9902 | "show bgp segment-routing srv6", | |
9903 | SHOW_STR | |
9904 | BGP_STR | |
9905 | "BGP Segment Routing\n" | |
9906 | "BGP Segment Routing SRv6\n") | |
9907 | { | |
9908 | struct bgp *bgp; | |
9909 | struct listnode *node; | |
1c21a234 | 9910 | struct srv6_locator_chunk *chunk; |
ea372e81 | 9911 | struct bgp_srv6_function *func; |
ea372e81 HS |
9912 | |
9913 | bgp = bgp_get_default(); | |
96db4340 | 9914 | if (!bgp) |
ea372e81 HS |
9915 | return CMD_SUCCESS; |
9916 | ||
9917 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9918 | vty_out(vty, "locator_chunks:\n"); | |
dccef127 | 9919 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { |
511211bf | 9920 | vty_out(vty, "- %pFX\n", &chunk->prefix); |
dccef127 CS |
9921 | vty_out(vty, " block-length: %d\n", chunk->block_bits_length); |
9922 | vty_out(vty, " node-length: %d\n", chunk->node_bits_length); | |
9923 | vty_out(vty, " func-length: %d\n", | |
9924 | chunk->function_bits_length); | |
9925 | vty_out(vty, " arg-length: %d\n", chunk->argument_bits_length); | |
9926 | } | |
ea372e81 HS |
9927 | |
9928 | vty_out(vty, "functions:\n"); | |
9929 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
07380148 | 9930 | vty_out(vty, "- sid: %pI6\n", &func->sid); |
ea372e81 HS |
9931 | vty_out(vty, " locator: %s\n", func->locator_name); |
9932 | } | |
9933 | ||
9934 | vty_out(vty, "bgps:\n"); | |
9935 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9936 | vty_out(vty, "- name: %s\n", | |
9937 | bgp->name ? bgp->name : "default"); | |
9938 | ||
1830895a CS |
9939 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n", |
9940 | bgp->vpn_policy[AFI_IP].tovpn_sid); | |
9941 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n", | |
9942 | bgp->vpn_policy[AFI_IP6].tovpn_sid); | |
9f5d4430 | 9943 | vty_out(vty, " per-vrf tovpn_sid: %pI6\n", bgp->tovpn_sid); |
ea372e81 HS |
9944 | } |
9945 | ||
9946 | return CMD_SUCCESS; | |
9947 | } | |
9948 | ||
505e5056 | 9949 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9950 | exit_address_family_cmd, |
9951 | "exit-address-family", | |
9952 | "Exit from Address Family configuration mode\n") | |
9953 | { | |
d62a17ae | 9954 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9955 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9956 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9957 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9958 | || vty->node == BGP_EVPN_NODE |
9959 | || vty->node == BGP_FLOWSPECV4_NODE | |
9960 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9961 | vty->node = BGP_NODE; |
9962 | return CMD_SUCCESS; | |
718e3744 | 9963 | } |
6b0655a2 | 9964 | |
8ad7271d | 9965 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9966 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9967 | const char *ip_str, afi_t afi, safi_t safi, | |
9968 | struct prefix_rd *prd) | |
9969 | { | |
9970 | int ret; | |
9971 | struct prefix match; | |
9bcb3eef DS |
9972 | struct bgp_dest *dest; |
9973 | struct bgp_dest *rm; | |
d62a17ae | 9974 | struct bgp *bgp; |
9975 | struct bgp_table *table; | |
9976 | struct bgp_table *rib; | |
9977 | ||
9978 | /* BGP structure lookup. */ | |
9979 | if (view_name) { | |
9980 | bgp = bgp_lookup_by_name(view_name); | |
9981 | if (bgp == NULL) { | |
9982 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9983 | view_name); | |
9984 | return CMD_WARNING; | |
9985 | } | |
9986 | } else { | |
9987 | bgp = bgp_get_default(); | |
9988 | if (bgp == NULL) { | |
9989 | vty_out(vty, "%% No BGP process is configured\n"); | |
9990 | return CMD_WARNING; | |
9991 | } | |
9992 | } | |
9993 | ||
9994 | /* Check IP address argument. */ | |
9995 | ret = str2prefix(ip_str, &match); | |
9996 | if (!ret) { | |
9997 | vty_out(vty, "%% address is malformed\n"); | |
9998 | return CMD_WARNING; | |
9999 | } | |
10000 | ||
10001 | match.family = afi2family(afi); | |
10002 | rib = bgp->rib[afi][safi]; | |
10003 | ||
10004 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
10005 | for (dest = bgp_table_top(rib); dest; |
10006 | dest = bgp_route_next(dest)) { | |
10007 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 10008 | |
9bcb3eef | 10009 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 10010 | continue; |
10011 | ||
9bcb3eef | 10012 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
10013 | if (table == NULL) |
10014 | continue; | |
10015 | ||
4953391b DA |
10016 | rm = bgp_node_match(table, &match); |
10017 | if (rm != NULL) { | |
b54892e0 | 10018 | const struct prefix *rm_p = |
9bcb3eef | 10019 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
10020 | |
10021 | if (rm_p->prefixlen == match.prefixlen) { | |
10022 | SET_FLAG(rm->flags, | |
10023 | BGP_NODE_USER_CLEAR); | |
10024 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 10025 | } |
9bcb3eef | 10026 | bgp_dest_unlock_node(rm); |
d62a17ae | 10027 | } |
10028 | } | |
10029 | } else { | |
4953391b DA |
10030 | dest = bgp_node_match(rib, &match); |
10031 | if (dest != NULL) { | |
9bcb3eef | 10032 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 10033 | |
9bcb3eef DS |
10034 | if (dest_p->prefixlen == match.prefixlen) { |
10035 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
10036 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 10037 | } |
9bcb3eef | 10038 | bgp_dest_unlock_node(dest); |
d62a17ae | 10039 | } |
10040 | } | |
10041 | ||
10042 | return CMD_SUCCESS; | |
8ad7271d DS |
10043 | } |
10044 | ||
b09b5ae0 | 10045 | /* one clear bgp command to rule them all */ |
718e3744 | 10046 | DEFUN (clear_ip_bgp_all, |
10047 | clear_ip_bgp_all_cmd, | |
3cb14f26 | 10048 | "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 | 10049 | CLEAR_STR |
10050 | IP_STR | |
10051 | BGP_STR | |
838758ac | 10052 | BGP_INSTANCE_HELP_STR |
510afcd6 | 10053 | BGP_AFI_HELP_STR |
00e6edb9 | 10054 | BGP_AF_STR |
510afcd6 | 10055 | BGP_SAFI_WITH_LABEL_HELP_STR |
00e6edb9 | 10056 | BGP_AF_MODIFIER_STR |
b09b5ae0 | 10057 | "Clear all peers\n" |
453c92f6 | 10058 | "BGP IPv4 neighbor to clear\n" |
a80beece | 10059 | "BGP IPv6 neighbor to clear\n" |
838758ac | 10060 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
10061 | "Clear peers with the AS number\n" |
10062 | "Clear all external peers\n" | |
718e3744 | 10063 | "Clear all members of peer-group\n" |
b09b5ae0 | 10064 | "BGP peer-group name\n" |
b09b5ae0 DW |
10065 | BGP_SOFT_STR |
10066 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
10067 | BGP_SOFT_OUT_STR |
10068 | BGP_SOFT_IN_STR | |
10069 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
3cb14f26 DS |
10070 | BGP_SOFT_OUT_STR |
10071 | "Reset message statistics\n") | |
718e3744 | 10072 | { |
d62a17ae | 10073 | char *vrf = NULL; |
10074 | ||
dc912615 DS |
10075 | afi_t afi = AFI_UNSPEC; |
10076 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 10077 | enum clear_sort clr_sort = clear_peer; |
10078 | enum bgp_clear_type clr_type; | |
10079 | char *clr_arg = NULL; | |
10080 | ||
10081 | int idx = 0; | |
10082 | ||
10083 | /* clear [ip] bgp */ | |
10084 | if (argv_find(argv, argc, "ip", &idx)) | |
10085 | afi = AFI_IP; | |
10086 | ||
9a8bdf1c PG |
10087 | /* [<vrf> VIEWVRFNAME] */ |
10088 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10089 | vrf = argv[idx + 1]->arg; | |
10090 | idx += 2; | |
10091 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10092 | vrf = NULL; | |
10093 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10094 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 10095 | vrf = argv[idx + 1]->arg; |
10096 | idx += 2; | |
10097 | } | |
d62a17ae | 10098 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10099 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
10100 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10101 | ||
d7b9898c | 10102 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 10103 | if (argv_find(argv, argc, "*", &idx)) { |
10104 | clr_sort = clear_all; | |
10105 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
10106 | clr_sort = clear_peer; | |
10107 | clr_arg = argv[idx]->arg; | |
10108 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
10109 | clr_sort = clear_peer; | |
10110 | clr_arg = argv[idx]->arg; | |
10111 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
10112 | clr_sort = clear_group; | |
10113 | idx++; | |
10114 | clr_arg = argv[idx]->arg; | |
d7b9898c | 10115 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 10116 | clr_sort = clear_peer; |
10117 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
10118 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
10119 | clr_sort = clear_peer; | |
10120 | clr_arg = argv[idx]->arg; | |
d62a17ae | 10121 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
10122 | clr_sort = clear_as; | |
10123 | clr_arg = argv[idx]->arg; | |
10124 | } else if (argv_find(argv, argc, "external", &idx)) { | |
10125 | clr_sort = clear_external; | |
10126 | } | |
10127 | ||
3cb14f26 | 10128 | /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */ |
d62a17ae | 10129 | if (argv_find(argv, argc, "soft", &idx)) { |
10130 | if (argv_find(argv, argc, "in", &idx) | |
10131 | || argv_find(argv, argc, "out", &idx)) | |
10132 | clr_type = strmatch(argv[idx]->text, "in") | |
10133 | ? BGP_CLEAR_SOFT_IN | |
10134 | : BGP_CLEAR_SOFT_OUT; | |
10135 | else | |
10136 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
10137 | } else if (argv_find(argv, argc, "in", &idx)) { | |
10138 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
10139 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
10140 | : BGP_CLEAR_SOFT_IN; | |
10141 | } else if (argv_find(argv, argc, "out", &idx)) { | |
10142 | clr_type = BGP_CLEAR_SOFT_OUT; | |
3cb14f26 DS |
10143 | } else if (argv_find(argv, argc, "message-stats", &idx)) { |
10144 | clr_type = BGP_CLEAR_MESSAGE_STATS; | |
d62a17ae | 10145 | } else |
10146 | clr_type = BGP_CLEAR_SOFT_NONE; | |
10147 | ||
1ca2fd11 | 10148 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 10149 | } |
01080f7c | 10150 | |
8ad7271d DS |
10151 | DEFUN (clear_ip_bgp_prefix, |
10152 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 10153 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
10154 | CLEAR_STR |
10155 | IP_STR | |
10156 | BGP_STR | |
838758ac | 10157 | BGP_INSTANCE_HELP_STR |
8ad7271d | 10158 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10159 | "IPv4 prefix\n") |
8ad7271d | 10160 | { |
d62a17ae | 10161 | char *vrf = NULL; |
10162 | char *prefix = NULL; | |
8ad7271d | 10163 | |
d62a17ae | 10164 | int idx = 0; |
01080f7c | 10165 | |
d62a17ae | 10166 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
10167 | if (argv_find(argv, argc, "vrf", &idx)) { |
10168 | vrf = argv[idx + 1]->arg; | |
10169 | idx += 2; | |
10170 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10171 | vrf = NULL; | |
10172 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10173 | /* [<view> VIEWVRFNAME] */ | |
10174 | vrf = argv[idx + 1]->arg; | |
10175 | idx += 2; | |
10176 | } | |
0c7b1b01 | 10177 | |
d62a17ae | 10178 | prefix = argv[argc - 1]->arg; |
8ad7271d | 10179 | |
d62a17ae | 10180 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 10181 | } |
8ad7271d | 10182 | |
b09b5ae0 DW |
10183 | DEFUN (clear_bgp_ipv6_safi_prefix, |
10184 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 10185 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10186 | CLEAR_STR |
3a2d747c | 10187 | IP_STR |
718e3744 | 10188 | BGP_STR |
00e6edb9 | 10189 | BGP_AF_STR |
46f296b4 | 10190 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10191 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10192 | "IPv6 prefix\n") |
718e3744 | 10193 | { |
9b475e76 PG |
10194 | int idx_safi = 0; |
10195 | int idx_ipv6_prefix = 0; | |
10196 | safi_t safi = SAFI_UNICAST; | |
10197 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10198 | argv[idx_ipv6_prefix]->arg : NULL; | |
10199 | ||
10200 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 10201 | return bgp_clear_prefix( |
9b475e76 PG |
10202 | vty, NULL, prefix, AFI_IP6, |
10203 | safi, NULL); | |
838758ac | 10204 | } |
01080f7c | 10205 | |
b09b5ae0 DW |
10206 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
10207 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 10208 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10209 | CLEAR_STR |
3a2d747c | 10210 | IP_STR |
718e3744 | 10211 | BGP_STR |
838758ac | 10212 | BGP_INSTANCE_HELP_STR |
00e6edb9 | 10213 | BGP_AF_STR |
46f296b4 | 10214 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10215 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10216 | "IPv6 prefix\n") |
718e3744 | 10217 | { |
9b475e76 | 10218 | int idx_safi = 0; |
9a8bdf1c | 10219 | int idx_vrfview = 0; |
9b475e76 PG |
10220 | int idx_ipv6_prefix = 0; |
10221 | safi_t safi = SAFI_UNICAST; | |
10222 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10223 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 10224 | char *vrfview = NULL; |
9b475e76 | 10225 | |
9a8bdf1c PG |
10226 | /* [<view|vrf> VIEWVRFNAME] */ |
10227 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
10228 | vrfview = argv[idx_vrfview + 1]->arg; | |
10229 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
10230 | vrfview = NULL; | |
10231 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
10232 | /* [<view> VIEWVRFNAME] */ | |
10233 | vrfview = argv[idx_vrfview + 1]->arg; | |
10234 | } | |
9b475e76 PG |
10235 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
10236 | ||
d62a17ae | 10237 | return bgp_clear_prefix( |
9b475e76 PG |
10238 | vty, vrfview, prefix, |
10239 | AFI_IP6, safi, NULL); | |
718e3744 | 10240 | } |
10241 | ||
b09b5ae0 DW |
10242 | DEFUN (show_bgp_views, |
10243 | show_bgp_views_cmd, | |
d6e3c605 | 10244 | "show [ip] bgp views", |
b09b5ae0 | 10245 | SHOW_STR |
d6e3c605 | 10246 | IP_STR |
01080f7c | 10247 | BGP_STR |
b09b5ae0 | 10248 | "Show the defined BGP views\n") |
01080f7c | 10249 | { |
d62a17ae | 10250 | struct list *inst = bm->bgp; |
10251 | struct listnode *node; | |
10252 | struct bgp *bgp; | |
01080f7c | 10253 | |
d62a17ae | 10254 | vty_out(vty, "Defined BGP views:\n"); |
10255 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10256 | /* Skip VRFs. */ | |
10257 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
10258 | continue; | |
10259 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
10260 | bgp->as); | |
10261 | } | |
e52702f2 | 10262 | |
d62a17ae | 10263 | return CMD_SUCCESS; |
e0081f70 ML |
10264 | } |
10265 | ||
8386ac43 | 10266 | DEFUN (show_bgp_vrfs, |
10267 | show_bgp_vrfs_cmd, | |
d6e3c605 | 10268 | "show [ip] bgp vrfs [json]", |
8386ac43 | 10269 | SHOW_STR |
d6e3c605 | 10270 | IP_STR |
8386ac43 | 10271 | BGP_STR |
10272 | "Show BGP VRFs\n" | |
9973d184 | 10273 | JSON_STR) |
8386ac43 | 10274 | { |
fe1dc5a3 | 10275 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 10276 | struct list *inst = bm->bgp; |
10277 | struct listnode *node; | |
10278 | struct bgp *bgp; | |
9f049418 | 10279 | bool uj = use_json(argc, argv); |
d62a17ae | 10280 | json_object *json = NULL; |
10281 | json_object *json_vrfs = NULL; | |
10282 | int count = 0; | |
d62a17ae | 10283 | |
d62a17ae | 10284 | if (uj) { |
10285 | json = json_object_new_object(); | |
10286 | json_vrfs = json_object_new_object(); | |
10287 | } | |
10288 | ||
10289 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10290 | const char *name, *type; | |
10291 | struct peer *peer; | |
7fe96307 | 10292 | struct listnode *node2, *nnode2; |
d62a17ae | 10293 | int peers_cfg, peers_estb; |
10294 | json_object *json_vrf = NULL; | |
d62a17ae | 10295 | |
10296 | /* Skip Views. */ | |
10297 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
10298 | continue; | |
10299 | ||
10300 | count++; | |
efb4077a | 10301 | if (!uj && count == 1) { |
fe1dc5a3 | 10302 | vty_out(vty, |
efb4077a | 10303 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 10304 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
10305 | "#PeersEstb", "Name"); |
10306 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
10307 | "L3-VNI", "RouterMAC", "Interface"); | |
10308 | } | |
d62a17ae | 10309 | |
10310 | peers_cfg = peers_estb = 0; | |
10311 | if (uj) | |
10312 | json_vrf = json_object_new_object(); | |
10313 | ||
10314 | ||
7fe96307 | 10315 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 10316 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10317 | continue; | |
10318 | peers_cfg++; | |
feb17238 | 10319 | if (peer_established(peer)) |
d62a17ae | 10320 | peers_estb++; |
10321 | } | |
10322 | ||
10323 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 10324 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10325 | type = "DFLT"; |
10326 | } else { | |
10327 | name = bgp->name; | |
10328 | type = "VRF"; | |
10329 | } | |
10330 | ||
a8bf7d9c | 10331 | |
d62a17ae | 10332 | if (uj) { |
a4d82a8a PZ |
10333 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10334 | ? -1 | |
10335 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
10336 | char buf[BUFSIZ] = {0}; |
10337 | ||
d62a17ae | 10338 | json_object_string_add(json_vrf, "type", type); |
10339 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
c949c771 DA |
10340 | json_object_string_addf(json_vrf, "routerId", "%pI4", |
10341 | &bgp->router_id); | |
d62a17ae | 10342 | json_object_int_add(json_vrf, "numConfiguredPeers", |
10343 | peers_cfg); | |
10344 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
10345 | peers_estb); | |
10346 | ||
fe1dc5a3 | 10347 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
10348 | json_object_string_add( |
10349 | json_vrf, "rmac", | |
10350 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
10351 | json_object_string_add(json_vrf, "interface", |
10352 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10353 | bgp->vrf_id)); | |
d62a17ae | 10354 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 10355 | } else { |
23d0a753 | 10356 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
10357 | type, |
10358 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10359 | : (int)bgp->vrf_id, | |
23d0a753 | 10360 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
10361 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
10362 | bgp->l3vni, | |
10363 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
10364 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10365 | bgp->vrf_id)); | |
10366 | } | |
d62a17ae | 10367 | } |
10368 | ||
10369 | if (uj) { | |
10370 | json_object_object_add(json, "vrfs", json_vrfs); | |
10371 | ||
10372 | json_object_int_add(json, "totalVrfs", count); | |
10373 | ||
75eeda93 | 10374 | vty_json(vty, json); |
d62a17ae | 10375 | } else { |
10376 | if (count) | |
10377 | vty_out(vty, | |
10378 | "\nTotal number of VRFs (including default): %d\n", | |
10379 | count); | |
10380 | } | |
10381 | ||
10382 | return CMD_SUCCESS; | |
8386ac43 | 10383 | } |
10384 | ||
48ecf8f5 DS |
10385 | DEFUN (show_bgp_mac_hash, |
10386 | show_bgp_mac_hash_cmd, | |
10387 | "show bgp mac hash", | |
10388 | SHOW_STR | |
10389 | BGP_STR | |
10390 | "Mac Address\n" | |
10391 | "Mac Address database\n") | |
10392 | { | |
10393 | bgp_mac_dump_table(vty); | |
10394 | ||
10395 | return CMD_SUCCESS; | |
10396 | } | |
acf71666 | 10397 | |
e3b78da8 | 10398 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10399 | { |
0291c246 | 10400 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10401 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10402 | |
23d0a753 | 10403 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10404 | } |
10405 | ||
10406 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10407 | { | |
10408 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10409 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10410 | |
10411 | vty_out(vty, "Tunnel-ip database:\n"); | |
10412 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10413 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10414 | vty); |
10415 | } | |
10416 | ||
15c81ca4 DS |
10417 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10418 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10419 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10420 | "martian next-hops\n" |
10421 | "martian next-hop database\n") | |
acf71666 | 10422 | { |
0291c246 | 10423 | struct bgp *bgp = NULL; |
15c81ca4 | 10424 | int idx = 0; |
9a8bdf1c PG |
10425 | char *name = NULL; |
10426 | ||
10427 | /* [<vrf> VIEWVRFNAME] */ | |
10428 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10429 | name = argv[idx + 1]->arg; | |
10430 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10431 | name = NULL; | |
10432 | } else if (argv_find(argv, argc, "view", &idx)) | |
10433 | /* [<view> VIEWVRFNAME] */ | |
10434 | name = argv[idx + 1]->arg; | |
10435 | if (name) | |
10436 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10437 | else |
10438 | bgp = bgp_get_default(); | |
acf71666 | 10439 | |
acf71666 MK |
10440 | if (!bgp) { |
10441 | vty_out(vty, "%% No BGP process is configured\n"); | |
10442 | return CMD_WARNING; | |
10443 | } | |
10444 | bgp_show_martian_nexthops(vty, bgp); | |
10445 | ||
10446 | return CMD_SUCCESS; | |
10447 | } | |
10448 | ||
f412b39a | 10449 | DEFUN (show_bgp_memory, |
4bf6a362 | 10450 | show_bgp_memory_cmd, |
7fa12b13 | 10451 | "show [ip] bgp memory", |
4bf6a362 | 10452 | SHOW_STR |
3a2d747c | 10453 | IP_STR |
4bf6a362 PJ |
10454 | BGP_STR |
10455 | "Global BGP memory statistics\n") | |
10456 | { | |
d62a17ae | 10457 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10458 | unsigned long count; | |
10459 | ||
10460 | /* RIB related usage stats */ | |
10461 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10462 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10463 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10464 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10465 | |
10466 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10467 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10468 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10469 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10470 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10471 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10472 | count, | |
4b7e6066 DS |
10473 | mtype_memstr( |
10474 | memstrbuf, sizeof(memstrbuf), | |
10475 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10476 | |
10477 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10478 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10479 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10480 | count * sizeof(struct bgp_static))); | |
10481 | ||
10482 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10483 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10484 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10485 | count * sizeof(struct bpacket))); | |
10486 | ||
10487 | /* Adj-In/Out */ | |
10488 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10489 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10490 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10491 | count * sizeof(struct bgp_adj_in))); | |
10492 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10493 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10494 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10495 | count * sizeof(struct bgp_adj_out))); | |
10496 | ||
10497 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10498 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10499 | count, | |
10500 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10501 | count * sizeof(struct bgp_nexthop_cache))); | |
10502 | ||
10503 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10504 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10505 | count, | |
10506 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10507 | count * sizeof(struct bgp_damp_info))); | |
10508 | ||
10509 | /* Attributes */ | |
10510 | count = attr_count(); | |
10511 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10512 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10513 | count * sizeof(struct attr))); | |
10514 | ||
10515 | if ((count = attr_unknown_count())) | |
10516 | vty_out(vty, "%ld unknown attributes\n", count); | |
10517 | ||
10518 | /* AS_PATH attributes */ | |
10519 | count = aspath_count(); | |
10520 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10521 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10522 | count * sizeof(struct aspath))); | |
10523 | ||
10524 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10525 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10526 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10527 | count * sizeof(struct assegment))); | |
10528 | ||
10529 | /* Other attributes */ | |
10530 | if ((count = community_count())) | |
10531 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10532 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10533 | count * sizeof(struct community))); | |
d62a17ae | 10534 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
145f7619 DA |
10535 | vty_out(vty, |
10536 | "%ld BGP ext-community entries, using %s of memory\n", | |
10537 | count, | |
10538 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10539 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10540 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10541 | vty_out(vty, | |
10542 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10543 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10544 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10545 | |
10546 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10547 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10548 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10549 | count * sizeof(struct cluster_list))); | |
10550 | ||
10551 | /* Peer related usage */ | |
10552 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10553 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10554 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10555 | count * sizeof(struct peer))); | |
10556 | ||
10557 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10558 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10559 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10560 | count * sizeof(struct peer_group))); | |
10561 | ||
10562 | /* Other */ | |
d62a17ae | 10563 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10564 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10565 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10566 | count * sizeof(regex_t))); | |
d62a17ae | 10567 | return CMD_SUCCESS; |
4bf6a362 | 10568 | } |
fee0f4c6 | 10569 | |
57a9c8a8 DS |
10570 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10571 | { | |
10572 | json_object *bestpath = json_object_new_object(); | |
10573 | ||
892fedb6 | 10574 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10575 | json_object_string_add(bestpath, "asPath", "ignore"); |
10576 | ||
892fedb6 | 10577 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10578 | json_object_string_add(bestpath, "asPath", "confed"); |
10579 | ||
892fedb6 DA |
10580 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10581 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10582 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10583 | "as-set"); |
10584 | else | |
a4d82a8a | 10585 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10586 | "true"); |
10587 | } else | |
a4d82a8a | 10588 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10589 | |
ee88563a JM |
10590 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
10591 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
10592 | ||
892fedb6 | 10593 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10594 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10595 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10596 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10597 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10598 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10599 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10600 | json_object_string_add(bestpath, "med", |
10601 | "missing-as-worst"); | |
10602 | else | |
10603 | json_object_string_add(bestpath, "med", "true"); | |
10604 | } | |
10605 | ||
10606 | json_object_object_add(json, "bestPath", bestpath); | |
10607 | } | |
10608 | ||
3577f1c5 DD |
10609 | /* Print the error code/subcode for why the peer is down */ |
10610 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10611 | json_object *json_peer, bool use_json) | |
10612 | { | |
10613 | const char *code_str; | |
10614 | const char *subcode_str; | |
10615 | ||
10616 | if (use_json) { | |
10617 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10618 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10619 | char errorcodesubcode_hexstr[5]; | |
10620 | char errorcodesubcode_str[256]; | |
10621 | ||
10622 | code_str = bgp_notify_code_str(peer->notify.code); | |
10623 | subcode_str = bgp_notify_subcode_str( | |
10624 | peer->notify.code, | |
10625 | peer->notify.subcode); | |
10626 | ||
772270f3 QY |
10627 | snprintf(errorcodesubcode_hexstr, |
10628 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10629 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10630 | json_object_string_add(json_peer, |
10631 | "lastErrorCodeSubcode", | |
10632 | errorcodesubcode_hexstr); | |
10633 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10634 | code_str, subcode_str); | |
10635 | json_object_string_add(json_peer, | |
10636 | "lastNotificationReason", | |
10637 | errorcodesubcode_str); | |
eea685b6 DA |
10638 | json_object_boolean_add(json_peer, |
10639 | "lastNotificationHardReset", | |
10640 | peer->notify.hard_reset); | |
3577f1c5 DD |
10641 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
10642 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10643 | && (peer->notify.subcode | |
10644 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10645 | || peer->notify.subcode | |
10646 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10647 | && peer->notify.length) { | |
10648 | char msgbuf[1024]; | |
10649 | const char *msg_str; | |
10650 | ||
10651 | msg_str = bgp_notify_admin_message( | |
10652 | msgbuf, sizeof(msgbuf), | |
10653 | (uint8_t *)peer->notify.data, | |
10654 | peer->notify.length); | |
10655 | if (msg_str) | |
10656 | json_object_string_add( | |
10657 | json_peer, | |
10658 | "lastShutdownDescription", | |
10659 | msg_str); | |
10660 | } | |
10661 | ||
c258527b | 10662 | } |
3577f1c5 DD |
10663 | json_object_string_add(json_peer, "lastResetDueTo", |
10664 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10665 | json_object_int_add(json_peer, "lastResetCode", |
10666 | peer->last_reset); | |
3577f1c5 DD |
10667 | } else { |
10668 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10669 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10670 | code_str = bgp_notify_code_str(peer->notify.code); | |
10671 | subcode_str = | |
10672 | bgp_notify_subcode_str(peer->notify.code, | |
10673 | peer->notify.subcode); | |
eea685b6 | 10674 | vty_out(vty, " Notification %s (%s%s%s)\n", |
3577f1c5 | 10675 | peer->last_reset == PEER_DOWN_NOTIFY_SEND |
eea685b6 DA |
10676 | ? "sent" |
10677 | : "received", | |
10678 | code_str, subcode_str, | |
10679 | peer->notify.hard_reset | |
10680 | ? bgp_notify_subcode_str( | |
10681 | BGP_NOTIFY_CEASE, | |
10682 | BGP_NOTIFY_CEASE_HARD_RESET) | |
10683 | : ""); | |
3577f1c5 | 10684 | } else { |
e91c24c8 | 10685 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10686 | peer_down_str[(int)peer->last_reset]); |
10687 | } | |
10688 | } | |
10689 | } | |
10690 | ||
10691 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10692 | safi_t safi) | |
10693 | { | |
feb17238 | 10694 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10695 | } |
10696 | ||
10697 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10698 | struct peer *peer, json_object *json_peer, | |
10699 | int max_neighbor_width, bool use_json) | |
10700 | { | |
10701 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10702 | int len; | |
10703 | ||
10704 | if (use_json) { | |
10705 | if (peer_dynamic_neighbor(peer)) | |
10706 | json_object_boolean_true_add(json_peer, | |
10707 | "dynamicPeer"); | |
10708 | if (peer->hostname) | |
10709 | json_object_string_add(json_peer, "hostname", | |
10710 | peer->hostname); | |
10711 | ||
10712 | if (peer->domainname) | |
10713 | json_object_string_add(json_peer, "domainname", | |
10714 | peer->domainname); | |
10715 | json_object_int_add(json_peer, "connectionsEstablished", | |
10716 | peer->established); | |
10717 | json_object_int_add(json_peer, "connectionsDropped", | |
10718 | peer->dropped); | |
10719 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10720 | use_json, json_peer); | |
feb17238 | 10721 | if (peer_established(peer)) |
3577f1c5 DD |
10722 | json_object_string_add(json_peer, "lastResetDueTo", |
10723 | "AFI/SAFI Not Negotiated"); | |
10724 | else | |
10725 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10726 | } else { | |
10727 | dn_flag[1] = '\0'; | |
10728 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10729 | if (peer->hostname | |
892fedb6 | 10730 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10731 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10732 | peer->hostname, peer->host); | |
10733 | else | |
10734 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10735 | ||
10736 | /* pad the neighbor column with spaces */ | |
10737 | if (len < max_neighbor_width) | |
10738 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10739 | " "); | |
e91c24c8 | 10740 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10741 | peer->dropped, |
10742 | peer_uptime(peer->uptime, timebuf, | |
10743 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10744 | if (peer_established(peer)) |
3577f1c5 DD |
10745 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10746 | else | |
10747 | bgp_show_peer_reset(vty, peer, NULL, | |
10748 | false); | |
10749 | } | |
10750 | } | |
c258527b | 10751 | |
565e9ddd | 10752 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10753 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10754 | { | |
10755 | static char stripped[BUFSIZ]; | |
64541ffa FD |
10756 | uint32_t i = 0; |
10757 | uint32_t last_space = 0; | |
cb75bb31 | 10758 | |
64541ffa FD |
10759 | while (i < size) { |
10760 | if (*(desc + i) == 0) { | |
10761 | stripped[i] = '\0'; | |
10762 | return stripped; | |
10763 | } | |
10764 | if (i != 0 && *(desc + i) == ' ' && last_space != i - 1) | |
10765 | last_space = i; | |
10766 | stripped[i] = *(desc + i); | |
10767 | i++; | |
10768 | } | |
10769 | ||
10770 | if (last_space > size) | |
10771 | stripped[size + 1] = '\0'; | |
10772 | else | |
10773 | stripped[last_space] = '\0'; | |
cb75bb31 DA |
10774 | |
10775 | return stripped; | |
10776 | } | |
3577f1c5 | 10777 | |
8c1d4cd5 LS |
10778 | /* Determine whether var peer should be filtered out of the summary. */ |
10779 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10780 | struct peer *fpeer, int as_type, | |
10781 | as_t as) | |
10782 | { | |
10783 | ||
10784 | /* filter neighbor XXXX */ | |
10785 | if (fpeer && fpeer != peer) | |
10786 | return true; | |
10787 | ||
10788 | /* filter remote-as (internal|external) */ | |
10789 | if (as_type != AS_UNSPECIFIED) { | |
10790 | if (peer->as_type == AS_SPECIFIED) { | |
10791 | if (as_type == AS_INTERNAL) { | |
10792 | if (peer->as != peer->local_as) | |
10793 | return true; | |
10794 | } else if (peer->as == peer->local_as) | |
10795 | return true; | |
10796 | } else if (as_type != peer->as_type) | |
10797 | return true; | |
10798 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10799 | return true; | |
10800 | ||
10801 | return false; | |
10802 | } | |
10803 | ||
565e9ddd DA |
10804 | /* Show BGP peer's summary information. |
10805 | * | |
10806 | * Peer's description is stripped according to if `wide` option is given | |
10807 | * or not. | |
10808 | * | |
10809 | * When adding new columns to `show bgp summary` output, please make | |
10810 | * sure `Desc` is the lastest column to show because it can contain | |
10811 | * whitespaces and the whole output will be tricky. | |
10812 | */ | |
d62a17ae | 10813 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10814 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10815 | uint16_t show_flags) |
d62a17ae | 10816 | { |
10817 | struct peer *peer; | |
10818 | struct listnode *node, *nnode; | |
10819 | unsigned int count = 0, dn_count = 0; | |
10820 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10821 | char neighbor_buf[VTY_BUFSIZ]; | |
10822 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10823 | int len, failed_count = 0; |
ce1944f0 | 10824 | unsigned int filtered_count = 0; |
d62a17ae | 10825 | int max_neighbor_width = 0; |
10826 | int pfx_rcd_safi; | |
3c13337d | 10827 | json_object *json = NULL; |
d62a17ae | 10828 | json_object *json_peer = NULL; |
10829 | json_object *json_peers = NULL; | |
50e05855 | 10830 | struct peer_af *paf; |
d3ada366 | 10831 | struct bgp_filter *filter; |
85eeb029 DA |
10832 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10833 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10834 | bool show_established = | |
10835 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10836 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10837 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10838 | |
10839 | /* labeled-unicast routes are installed in the unicast table so in order | |
10840 | * to | |
10841 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10842 | */ | |
3577f1c5 | 10843 | |
d62a17ae | 10844 | if (safi == SAFI_LABELED_UNICAST) |
10845 | pfx_rcd_safi = SAFI_UNICAST; | |
10846 | else | |
10847 | pfx_rcd_safi = safi; | |
10848 | ||
10849 | if (use_json) { | |
3c13337d | 10850 | json = json_object_new_object(); |
d62a17ae | 10851 | json_peers = json_object_new_object(); |
3577f1c5 | 10852 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10853 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10854 | as_type, as)) { | |
ce1944f0 | 10855 | filtered_count++; |
8c1d4cd5 LS |
10856 | count++; |
10857 | continue; | |
10858 | } | |
10859 | ||
3577f1c5 DD |
10860 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10861 | continue; | |
10862 | ||
10863 | if (peer->afc[afi][safi]) { | |
10864 | /* See if we have at least a single failed peer */ | |
10865 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10866 | failed_count++; | |
10867 | count++; | |
10868 | } | |
10869 | if (peer_dynamic_neighbor(peer)) | |
10870 | dn_count++; | |
10871 | } | |
c258527b | 10872 | |
d62a17ae | 10873 | } else { |
10874 | /* Loop over all neighbors that will be displayed to determine | |
10875 | * how many | |
10876 | * characters are needed for the Neighbor column | |
10877 | */ | |
10878 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10879 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10880 | as_type, as)) { | |
ce1944f0 | 10881 | filtered_count++; |
8c1d4cd5 LS |
10882 | count++; |
10883 | continue; | |
10884 | } | |
10885 | ||
d62a17ae | 10886 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10887 | continue; | |
10888 | ||
10889 | if (peer->afc[afi][safi]) { | |
10890 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10891 | if (peer_dynamic_neighbor(peer)) | |
10892 | dn_flag[0] = '*'; | |
10893 | ||
10894 | if (peer->hostname | |
892fedb6 DA |
10895 | && CHECK_FLAG(bgp->flags, |
10896 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10897 | snprintf(neighbor_buf, |
10898 | sizeof(neighbor_buf), | |
10899 | "%s%s(%s) ", dn_flag, | |
10900 | peer->hostname, peer->host); | |
d62a17ae | 10901 | else |
772270f3 QY |
10902 | snprintf(neighbor_buf, |
10903 | sizeof(neighbor_buf), "%s%s ", | |
10904 | dn_flag, peer->host); | |
d62a17ae | 10905 | |
10906 | len = strlen(neighbor_buf); | |
10907 | ||
10908 | if (len > max_neighbor_width) | |
10909 | max_neighbor_width = len; | |
c258527b | 10910 | |
3577f1c5 DD |
10911 | /* See if we have at least a single failed peer */ |
10912 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10913 | failed_count++; | |
10914 | count++; | |
d62a17ae | 10915 | } |
10916 | } | |
f933309e | 10917 | |
d62a17ae | 10918 | /* Originally we displayed the Neighbor column as 16 |
10919 | * characters wide so make that the default | |
10920 | */ | |
10921 | if (max_neighbor_width < neighbor_col_default_width) | |
10922 | max_neighbor_width = neighbor_col_default_width; | |
10923 | } | |
f933309e | 10924 | |
3577f1c5 DD |
10925 | if (show_failed && !failed_count) { |
10926 | if (use_json) { | |
10927 | json_object_int_add(json, "failedPeersCount", 0); | |
10928 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10929 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 | 10930 | |
75eeda93 | 10931 | vty_json(vty, json); |
3577f1c5 DD |
10932 | } else { |
10933 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
10934 | } |
10935 | return CMD_SUCCESS; | |
10936 | } | |
c258527b | 10937 | |
3577f1c5 | 10938 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 10939 | filtered_count = 0; |
800867d8 | 10940 | dn_count = 0; |
d62a17ae | 10941 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10942 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10943 | continue; | |
10944 | ||
ea47320b DL |
10945 | if (!peer->afc[afi][safi]) |
10946 | continue; | |
d62a17ae | 10947 | |
ea47320b DL |
10948 | if (!count) { |
10949 | unsigned long ents; | |
10950 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10951 | int64_t vrf_id_ui; |
d62a17ae | 10952 | |
a4d82a8a PZ |
10953 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10954 | ? -1 | |
10955 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10956 | |
10957 | /* Usage summary and header */ | |
10958 | if (use_json) { | |
c949c771 DA |
10959 | json_object_string_addf(json, "routerId", |
10960 | "%pI4", | |
10961 | &bgp->router_id); | |
60466a63 QY |
10962 | json_object_int_add(json, "as", bgp->as); |
10963 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10964 | json_object_string_add( |
10965 | json, "vrfName", | |
10966 | (bgp->inst_type | |
10967 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10968 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10969 | : bgp->name); |
10970 | } else { | |
10971 | vty_out(vty, | |
23d0a753 DA |
10972 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10973 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10974 | bgp->vrf_id == VRF_UNKNOWN |
10975 | ? -1 | |
10976 | : (int)bgp->vrf_id); | |
ea47320b DL |
10977 | vty_out(vty, "\n"); |
10978 | } | |
d62a17ae | 10979 | |
ea47320b | 10980 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10981 | if (use_json) { |
ea47320b | 10982 | json_object_int_add( |
60466a63 | 10983 | json, "updateDelayLimit", |
ea47320b | 10984 | bgp->v_update_delay); |
d62a17ae | 10985 | |
ea47320b DL |
10986 | if (bgp->v_update_delay |
10987 | != bgp->v_establish_wait) | |
d62a17ae | 10988 | json_object_int_add( |
10989 | json, | |
ea47320b DL |
10990 | "updateDelayEstablishWait", |
10991 | bgp->v_establish_wait); | |
d62a17ae | 10992 | |
60466a63 | 10993 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10994 | json_object_string_add( |
10995 | json, | |
10996 | "updateDelayFirstNeighbor", | |
10997 | bgp->update_delay_begin_time); | |
10998 | json_object_boolean_true_add( | |
10999 | json, | |
11000 | "updateDelayInProgress"); | |
11001 | } else { | |
11002 | if (bgp->update_delay_over) { | |
d62a17ae | 11003 | json_object_string_add( |
11004 | json, | |
11005 | "updateDelayFirstNeighbor", | |
11006 | bgp->update_delay_begin_time); | |
ea47320b | 11007 | json_object_string_add( |
d62a17ae | 11008 | json, |
ea47320b DL |
11009 | "updateDelayBestpathResumed", |
11010 | bgp->update_delay_end_time); | |
11011 | json_object_string_add( | |
d62a17ae | 11012 | json, |
ea47320b DL |
11013 | "updateDelayZebraUpdateResume", |
11014 | bgp->update_delay_zebra_resume_time); | |
11015 | json_object_string_add( | |
11016 | json, | |
11017 | "updateDelayPeerUpdateResume", | |
11018 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11019 | } |
ea47320b DL |
11020 | } |
11021 | } else { | |
11022 | vty_out(vty, | |
11023 | "Read-only mode update-delay limit: %d seconds\n", | |
11024 | bgp->v_update_delay); | |
11025 | if (bgp->v_update_delay | |
11026 | != bgp->v_establish_wait) | |
d62a17ae | 11027 | vty_out(vty, |
ea47320b DL |
11028 | " Establish wait: %d seconds\n", |
11029 | bgp->v_establish_wait); | |
d62a17ae | 11030 | |
60466a63 | 11031 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11032 | vty_out(vty, |
11033 | " First neighbor established: %s\n", | |
11034 | bgp->update_delay_begin_time); | |
11035 | vty_out(vty, | |
11036 | " Delay in progress\n"); | |
11037 | } else { | |
11038 | if (bgp->update_delay_over) { | |
d62a17ae | 11039 | vty_out(vty, |
11040 | " First neighbor established: %s\n", | |
11041 | bgp->update_delay_begin_time); | |
11042 | vty_out(vty, | |
ea47320b DL |
11043 | " Best-paths resumed: %s\n", |
11044 | bgp->update_delay_end_time); | |
11045 | vty_out(vty, | |
11046 | " zebra update resumed: %s\n", | |
11047 | bgp->update_delay_zebra_resume_time); | |
11048 | vty_out(vty, | |
11049 | " peers update resumed: %s\n", | |
11050 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11051 | } |
11052 | } | |
11053 | } | |
ea47320b | 11054 | } |
d62a17ae | 11055 | |
ea47320b DL |
11056 | if (use_json) { |
11057 | if (bgp_maxmed_onstartup_configured(bgp) | |
11058 | && bgp->maxmed_active) | |
11059 | json_object_boolean_true_add( | |
60466a63 | 11060 | json, "maxMedOnStartup"); |
ea47320b DL |
11061 | if (bgp->v_maxmed_admin) |
11062 | json_object_boolean_true_add( | |
60466a63 | 11063 | json, "maxMedAdministrative"); |
d62a17ae | 11064 | |
ea47320b DL |
11065 | json_object_int_add( |
11066 | json, "tableVersion", | |
60466a63 | 11067 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 11068 | |
60466a63 QY |
11069 | ents = bgp_table_count(bgp->rib[afi][safi]); |
11070 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
11071 | json_object_int_add( |
11072 | json, "ribMemory", | |
9bcb3eef | 11073 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 11074 | |
210ec2a0 | 11075 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
11076 | json_object_int_add(json, "peerCount", ents); |
11077 | json_object_int_add(json, "peerMemory", | |
11078 | ents * sizeof(struct peer)); | |
d62a17ae | 11079 | |
ea47320b DL |
11080 | if ((ents = listcount(bgp->group))) { |
11081 | json_object_int_add( | |
60466a63 | 11082 | json, "peerGroupCount", ents); |
ea47320b DL |
11083 | json_object_int_add( |
11084 | json, "peerGroupMemory", | |
996c9314 LB |
11085 | ents * sizeof(struct |
11086 | peer_group)); | |
ea47320b | 11087 | } |
d62a17ae | 11088 | |
ea47320b DL |
11089 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
11090 | BGP_CONFIG_DAMPENING)) | |
11091 | json_object_boolean_true_add( | |
60466a63 | 11092 | json, "dampeningEnabled"); |
ea47320b | 11093 | } else { |
96c81f66 LS |
11094 | if (!show_terse) { |
11095 | if (bgp_maxmed_onstartup_configured(bgp) | |
11096 | && bgp->maxmed_active) | |
11097 | vty_out(vty, | |
11098 | "Max-med on-startup active\n"); | |
11099 | if (bgp->v_maxmed_admin) | |
11100 | vty_out(vty, | |
11101 | "Max-med administrative active\n"); | |
d62a17ae | 11102 | |
96c81f66 LS |
11103 | vty_out(vty, |
11104 | "BGP table version %" PRIu64 | |
11105 | "\n", | |
11106 | bgp_table_version( | |
11107 | bgp->rib[afi][safi])); | |
ea47320b | 11108 | |
96c81f66 LS |
11109 | ents = bgp_table_count( |
11110 | bgp->rib[afi][safi]); | |
d62a17ae | 11111 | vty_out(vty, |
96c81f66 | 11112 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 11113 | ents, |
11114 | mtype_memstr( | |
11115 | memstrbuf, | |
11116 | sizeof(memstrbuf), | |
96c81f66 LS |
11117 | ents |
11118 | * sizeof( | |
11119 | struct | |
11120 | bgp_dest))); | |
d62a17ae | 11121 | |
96c81f66 LS |
11122 | /* Peer related usage */ |
11123 | ents = bgp->af_peer_count[afi][safi]; | |
11124 | vty_out(vty, | |
11125 | "Peers %ld, using %s of memory\n", | |
11126 | ents, | |
11127 | mtype_memstr( | |
11128 | memstrbuf, | |
11129 | sizeof(memstrbuf), | |
11130 | ents | |
11131 | * sizeof( | |
11132 | struct | |
11133 | peer))); | |
d62a17ae | 11134 | |
96c81f66 LS |
11135 | if ((ents = listcount(bgp->group))) |
11136 | vty_out(vty, | |
11137 | "Peer groups %ld, using %s of memory\n", | |
11138 | ents, | |
11139 | mtype_memstr( | |
11140 | memstrbuf, | |
11141 | sizeof(memstrbuf), | |
11142 | ents | |
11143 | * sizeof( | |
11144 | struct | |
11145 | peer_group))); | |
11146 | ||
11147 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
11148 | BGP_CONFIG_DAMPENING)) | |
11149 | vty_out(vty, | |
11150 | "Dampening enabled.\n"); | |
11151 | } | |
11152 | if (show_failed) { | |
11153 | vty_out(vty, "\n"); | |
11154 | ||
11155 | /* Subtract 8 here because 'Neighbor' is | |
11156 | * 8 characters */ | |
11157 | vty_out(vty, "Neighbor"); | |
11158 | vty_out(vty, "%*s", | |
11159 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
11160 | vty_out(vty, |
11161 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 11162 | } |
d62a17ae | 11163 | } |
ea47320b | 11164 | } |
d62a17ae | 11165 | |
d55811cc | 11166 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 11167 | filter = &peer->filter[afi][safi]; |
db92d226 | 11168 | |
ea47320b | 11169 | count++; |
3577f1c5 DD |
11170 | /* Works for both failed & successful cases */ |
11171 | if (peer_dynamic_neighbor(peer)) | |
11172 | dn_count++; | |
d62a17ae | 11173 | |
ea47320b | 11174 | if (use_json) { |
3577f1c5 | 11175 | json_peer = NULL; |
8c1d4cd5 | 11176 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11177 | as_type, as)) { |
11178 | filtered_count++; | |
8c1d4cd5 | 11179 | continue; |
ce1944f0 | 11180 | } |
3577f1c5 DD |
11181 | if (show_failed && |
11182 | bgp_has_peer_failed(peer, afi, safi)) { | |
11183 | json_peer = json_object_new_object(); | |
11184 | bgp_show_failed_summary(vty, bgp, peer, | |
11185 | json_peer, 0, use_json); | |
11186 | } else if (!show_failed) { | |
10b49f14 | 11187 | if (show_established |
ce1944f0 LS |
11188 | && bgp_has_peer_failed(peer, afi, safi)) { |
11189 | filtered_count++; | |
10b49f14 | 11190 | continue; |
ce1944f0 | 11191 | } |
10b49f14 | 11192 | |
3577f1c5 DD |
11193 | json_peer = json_object_new_object(); |
11194 | if (peer_dynamic_neighbor(peer)) { | |
11195 | json_object_boolean_true_add(json_peer, | |
11196 | "dynamicPeer"); | |
11197 | } | |
d62a17ae | 11198 | |
3577f1c5 DD |
11199 | if (peer->hostname) |
11200 | json_object_string_add(json_peer, "hostname", | |
11201 | peer->hostname); | |
11202 | ||
11203 | if (peer->domainname) | |
11204 | json_object_string_add(json_peer, "domainname", | |
11205 | peer->domainname); | |
11206 | ||
11207 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
11208 | json_object_int_add( |
11209 | json_peer, "localAs", | |
11210 | peer->change_local_as | |
11211 | ? peer->change_local_as | |
11212 | : peer->local_as); | |
3577f1c5 DD |
11213 | json_object_int_add(json_peer, "version", 4); |
11214 | json_object_int_add(json_peer, "msgRcvd", | |
11215 | PEER_TOTAL_RX(peer)); | |
11216 | json_object_int_add(json_peer, "msgSent", | |
11217 | PEER_TOTAL_TX(peer)); | |
11218 | ||
43aa5965 QY |
11219 | atomic_size_t outq_count, inq_count; |
11220 | outq_count = atomic_load_explicit( | |
11221 | &peer->obuf->count, | |
11222 | memory_order_relaxed); | |
11223 | inq_count = atomic_load_explicit( | |
11224 | &peer->ibuf->count, | |
11225 | memory_order_relaxed); | |
11226 | ||
3577f1c5 DD |
11227 | json_object_int_add(json_peer, "tableVersion", |
11228 | peer->version[afi][safi]); | |
11229 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
11230 | outq_count); |
11231 | json_object_int_add(json_peer, "inq", | |
11232 | inq_count); | |
3577f1c5 DD |
11233 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
11234 | use_json, json_peer); | |
11235 | ||
3577f1c5 DD |
11236 | json_object_int_add(json_peer, "pfxRcd", |
11237 | peer->pcount[afi][pfx_rcd_safi]); | |
11238 | ||
3577f1c5 | 11239 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
11240 | json_object_int_add( |
11241 | json_peer, "pfxSnt", | |
11242 | (PAF_SUBGRP(paf))->scount); | |
11243 | else | |
11244 | json_object_int_add(json_peer, "pfxSnt", | |
11245 | 0); | |
0e1f8ab5 DA |
11246 | |
11247 | /* BGP FSM state */ | |
cb9196e7 | 11248 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
11249 | || CHECK_FLAG(peer->bgp->flags, |
11250 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
11251 | json_object_string_add(json_peer, |
11252 | "state", | |
3577f1c5 DD |
11253 | "Idle (Admin)"); |
11254 | else if (peer->afc_recv[afi][safi]) | |
11255 | json_object_string_add( | |
0e1f8ab5 DA |
11256 | json_peer, "state", |
11257 | lookup_msg(bgp_status_msg, | |
11258 | peer->status, NULL)); | |
11259 | else if (CHECK_FLAG( | |
11260 | peer->sflags, | |
11261 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11262 | json_object_string_add(json_peer, | |
11263 | "state", | |
3577f1c5 DD |
11264 | "Idle (PfxCt)"); |
11265 | else | |
11266 | json_object_string_add( | |
0e1f8ab5 DA |
11267 | json_peer, "state", |
11268 | lookup_msg(bgp_status_msg, | |
11269 | peer->status, NULL)); | |
11270 | ||
11271 | /* BGP peer state */ | |
11272 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
11273 | || CHECK_FLAG(peer->bgp->flags, | |
11274 | BGP_FLAG_SHUTDOWN)) | |
11275 | json_object_string_add(json_peer, | |
11276 | "peerState", | |
11277 | "Admin"); | |
11278 | else if (CHECK_FLAG( | |
11279 | peer->sflags, | |
11280 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11281 | json_object_string_add(json_peer, | |
11282 | "peerState", | |
11283 | "PfxCt"); | |
11284 | else if (CHECK_FLAG(peer->flags, | |
11285 | PEER_FLAG_PASSIVE)) | |
11286 | json_object_string_add(json_peer, | |
11287 | "peerState", | |
11288 | "Passive"); | |
11289 | else if (CHECK_FLAG(peer->sflags, | |
11290 | PEER_STATUS_NSF_WAIT)) | |
11291 | json_object_string_add(json_peer, | |
11292 | "peerState", | |
11293 | "NSF passive"); | |
11294 | else if (CHECK_FLAG( | |
11295 | peer->bgp->flags, | |
11296 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11297 | && (!bgp_inbound_policy_exists(peer, | |
11298 | filter) | |
11299 | || !bgp_outbound_policy_exists( | |
11300 | peer, filter))) | |
11301 | json_object_string_add(json_peer, | |
11302 | "peerState", | |
11303 | "Policy"); | |
11304 | else | |
11305 | json_object_string_add( | |
11306 | json_peer, "peerState", "OK"); | |
11307 | ||
200116db DD |
11308 | json_object_int_add(json_peer, "connectionsEstablished", |
11309 | peer->established); | |
11310 | json_object_int_add(json_peer, "connectionsDropped", | |
11311 | peer->dropped); | |
aa72bd7e PG |
11312 | if (peer->desc) |
11313 | json_object_string_add( | |
11314 | json_peer, "desc", peer->desc); | |
b4e9dcba | 11315 | } |
3577f1c5 DD |
11316 | /* Avoid creating empty peer dicts in JSON */ |
11317 | if (json_peer == NULL) | |
11318 | continue; | |
ea47320b DL |
11319 | |
11320 | if (peer->conf_if) | |
60466a63 | 11321 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
11322 | "interface"); |
11323 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
11324 | json_object_string_add(json_peer, "idType", |
11325 | "ipv4"); | |
ea47320b | 11326 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
11327 | json_object_string_add(json_peer, "idType", |
11328 | "ipv6"); | |
ea47320b DL |
11329 | json_object_object_add(json_peers, peer->host, |
11330 | json_peer); | |
11331 | } else { | |
8c1d4cd5 | 11332 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11333 | as_type, as)) { |
11334 | filtered_count++; | |
8c1d4cd5 | 11335 | continue; |
ce1944f0 | 11336 | } |
3577f1c5 DD |
11337 | if (show_failed && |
11338 | bgp_has_peer_failed(peer, afi, safi)) { | |
11339 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
11340 | max_neighbor_width, | |
11341 | use_json); | |
11342 | } else if (!show_failed) { | |
10b49f14 | 11343 | if (show_established |
ce1944f0 LS |
11344 | && bgp_has_peer_failed(peer, afi, safi)) { |
11345 | filtered_count++; | |
10b49f14 | 11346 | continue; |
ce1944f0 | 11347 | } |
96c81f66 LS |
11348 | |
11349 | if ((count - filtered_count) == 1) { | |
11350 | /* display headline before the first | |
11351 | * neighbor line */ | |
11352 | vty_out(vty, "\n"); | |
11353 | ||
11354 | /* Subtract 8 here because 'Neighbor' is | |
11355 | * 8 characters */ | |
11356 | vty_out(vty, "Neighbor"); | |
11357 | vty_out(vty, "%*s", | |
11358 | max_neighbor_width - 8, " "); | |
11359 | vty_out(vty, | |
11360 | show_wide | |
11361 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
11362 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
11363 | } | |
11364 | ||
3577f1c5 DD |
11365 | memset(dn_flag, '\0', sizeof(dn_flag)); |
11366 | if (peer_dynamic_neighbor(peer)) { | |
11367 | dn_flag[0] = '*'; | |
11368 | } | |
d62a17ae | 11369 | |
3577f1c5 | 11370 | if (peer->hostname |
892fedb6 DA |
11371 | && CHECK_FLAG(bgp->flags, |
11372 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 11373 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
11374 | peer->hostname, |
11375 | peer->host); | |
d62a17ae | 11376 | else |
3577f1c5 DD |
11377 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
11378 | ||
11379 | /* pad the neighbor column with spaces */ | |
11380 | if (len < max_neighbor_width) | |
11381 | vty_out(vty, "%*s", max_neighbor_width - len, | |
11382 | " "); | |
11383 | ||
43aa5965 QY |
11384 | atomic_size_t outq_count, inq_count; |
11385 | outq_count = atomic_load_explicit( | |
11386 | &peer->obuf->count, | |
11387 | memory_order_relaxed); | |
11388 | inq_count = atomic_load_explicit( | |
11389 | &peer->ibuf->count, | |
11390 | memory_order_relaxed); | |
11391 | ||
85eeb029 DA |
11392 | if (show_wide) |
11393 | vty_out(vty, | |
11394 | "4 %10u %10u %9u %9u %8" PRIu64 | |
11395 | " %4zu %4zu %8s", | |
11396 | peer->as, | |
11397 | peer->change_local_as | |
11398 | ? peer->change_local_as | |
11399 | : peer->local_as, | |
11400 | PEER_TOTAL_RX(peer), | |
11401 | PEER_TOTAL_TX(peer), | |
11402 | peer->version[afi][safi], | |
11403 | inq_count, outq_count, | |
11404 | peer_uptime(peer->uptime, | |
11405 | timebuf, | |
11406 | BGP_UPTIME_LEN, 0, | |
11407 | NULL)); | |
11408 | else | |
11409 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
11410 | " %4zu %4zu %8s", | |
11411 | peer->as, PEER_TOTAL_RX(peer), | |
11412 | PEER_TOTAL_TX(peer), | |
11413 | peer->version[afi][safi], | |
11414 | inq_count, outq_count, | |
11415 | peer_uptime(peer->uptime, | |
11416 | timebuf, | |
11417 | BGP_UPTIME_LEN, 0, | |
11418 | NULL)); | |
3577f1c5 | 11419 | |
feb17238 | 11420 | if (peer_established(peer)) { |
d3ada366 DA |
11421 | if (peer->afc_recv[afi][safi]) { |
11422 | if (CHECK_FLAG( | |
11423 | bgp->flags, | |
11424 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11425 | && !bgp_inbound_policy_exists( | |
11426 | peer, filter)) | |
11427 | vty_out(vty, " %12s", | |
11428 | "(Policy)"); | |
11429 | else | |
11430 | vty_out(vty, | |
6cde4b45 | 11431 | " %12u", |
d3ada366 DA |
11432 | peer->pcount |
11433 | [afi] | |
11434 | [pfx_rcd_safi]); | |
11435 | } else { | |
749d0f27 | 11436 | vty_out(vty, " NoNeg"); |
d3ada366 | 11437 | } |
db92d226 | 11438 | |
d3ada366 DA |
11439 | if (paf && PAF_SUBGRP(paf)) { |
11440 | if (CHECK_FLAG( | |
11441 | bgp->flags, | |
11442 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11443 | && !bgp_outbound_policy_exists( | |
11444 | peer, filter)) | |
11445 | vty_out(vty, " %8s", | |
11446 | "(Policy)"); | |
11447 | else | |
11448 | vty_out(vty, | |
6cde4b45 | 11449 | " %8u", |
d3ada366 DA |
11450 | (PAF_SUBGRP( |
11451 | paf)) | |
11452 | ->scount); | |
749d0f27 DA |
11453 | } else { |
11454 | vty_out(vty, " NoNeg"); | |
d3ada366 | 11455 | } |
db92d226 | 11456 | } else { |
736b68f3 DS |
11457 | if (CHECK_FLAG(peer->flags, |
11458 | PEER_FLAG_SHUTDOWN) | |
11459 | || CHECK_FLAG(peer->bgp->flags, | |
11460 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
11461 | vty_out(vty, " Idle (Admin)"); |
11462 | else if (CHECK_FLAG( | |
11463 | peer->sflags, | |
11464 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11465 | vty_out(vty, " Idle (PfxCt)"); | |
11466 | else | |
11467 | vty_out(vty, " %12s", | |
11468 | lookup_msg(bgp_status_msg, | |
11469 | peer->status, NULL)); | |
db92d226 | 11470 | |
6cde4b45 | 11471 | vty_out(vty, " %8u", 0); |
3577f1c5 | 11472 | } |
565e9ddd DA |
11473 | /* Make sure `Desc` column is the lastest in |
11474 | * the output. | |
11475 | */ | |
aa72bd7e | 11476 | if (peer->desc) |
cb75bb31 DA |
11477 | vty_out(vty, " %s", |
11478 | bgp_peer_description_stripped( | |
85eeb029 DA |
11479 | peer->desc, |
11480 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
11481 | else |
11482 | vty_out(vty, " N/A"); | |
3577f1c5 | 11483 | vty_out(vty, "\n"); |
d62a17ae | 11484 | } |
3577f1c5 | 11485 | |
d62a17ae | 11486 | } |
11487 | } | |
f933309e | 11488 | |
d62a17ae | 11489 | if (use_json) { |
11490 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11491 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
11492 | json_object_int_add(json, "displayedPeers", |
11493 | count - filtered_count); | |
d62a17ae | 11494 | json_object_int_add(json, "totalPeers", count); |
11495 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11496 | ||
3577f1c5 DD |
11497 | if (!show_failed) |
11498 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11499 | |
75eeda93 | 11500 | vty_json(vty, json); |
d62a17ae | 11501 | } else { |
ce1944f0 | 11502 | if (count) { |
96c81f66 LS |
11503 | if (filtered_count == count) |
11504 | vty_out(vty, "\n%% No matching neighbor\n"); | |
11505 | else { | |
11506 | if (show_failed) | |
11507 | vty_out(vty, "\nDisplayed neighbors %d", | |
11508 | failed_count); | |
11509 | else if (as_type != AS_UNSPECIFIED || as | |
11510 | || fpeer || show_established) | |
ce1944f0 LS |
11511 | vty_out(vty, "\nDisplayed neighbors %d", |
11512 | count - filtered_count); | |
96c81f66 LS |
11513 | |
11514 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
11515 | count); | |
ce1944f0 | 11516 | } |
ce1944f0 | 11517 | } else { |
d6ceaca3 | 11518 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11519 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11520 | } |
b05a1c8b | 11521 | |
d6ceaca3 | 11522 | if (dn_count) { |
d62a17ae | 11523 | vty_out(vty, "* - dynamic neighbor\n"); |
11524 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11525 | dn_count, bgp->dynamic_neighbors_limit); | |
11526 | } | |
11527 | } | |
1ff9a340 | 11528 | |
d62a17ae | 11529 | return CMD_SUCCESS; |
718e3744 | 11530 | } |
11531 | ||
d62a17ae | 11532 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 11533 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 11534 | as_t as, uint16_t show_flags) |
d62a17ae | 11535 | { |
11536 | int is_first = 1; | |
11537 | int afi_wildcard = (afi == AFI_MAX); | |
11538 | int safi_wildcard = (safi == SAFI_MAX); | |
11539 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11540 | bool nbr_output = false; |
85eeb029 | 11541 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11542 | |
11543 | if (use_json && is_wildcard) | |
11544 | vty_out(vty, "{\n"); | |
11545 | if (afi_wildcard) | |
11546 | afi = 1; /* AFI_IP */ | |
11547 | while (afi < AFI_MAX) { | |
11548 | if (safi_wildcard) | |
11549 | safi = 1; /* SAFI_UNICAST */ | |
11550 | while (safi < SAFI_MAX) { | |
318cac96 | 11551 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11552 | nbr_output = true; |
f86897b9 | 11553 | |
d62a17ae | 11554 | if (is_wildcard) { |
11555 | /* | |
11556 | * So limit output to those afi/safi | |
11557 | * pairs that | |
11558 | * actualy have something interesting in | |
11559 | * them | |
11560 | */ | |
11561 | if (use_json) { | |
d62a17ae | 11562 | if (!is_first) |
11563 | vty_out(vty, ",\n"); | |
11564 | else | |
11565 | is_first = 0; | |
11566 | ||
11567 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11568 | get_afi_safi_str(afi, |
11569 | safi, | |
11570 | true)); | |
d62a17ae | 11571 | } else { |
6cac2fcc LS |
11572 | vty_out(vty, |
11573 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
11574 | get_afi_safi_str(afi, |
11575 | safi, | |
6cac2fcc LS |
11576 | false), |
11577 | bgp->name_pretty); | |
d62a17ae | 11578 | } |
11579 | } | |
8c1d4cd5 LS |
11580 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
11581 | as_type, as, show_flags); | |
d62a17ae | 11582 | } |
11583 | safi++; | |
d62a17ae | 11584 | if (!safi_wildcard) |
11585 | safi = SAFI_MAX; | |
11586 | } | |
11587 | afi++; | |
ee851c8c | 11588 | if (!afi_wildcard) |
d62a17ae | 11589 | afi = AFI_MAX; |
11590 | } | |
11591 | ||
11592 | if (use_json && is_wildcard) | |
11593 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11594 | else if (!nbr_output) { |
11595 | if (use_json) | |
11596 | vty_out(vty, "{}\n"); | |
11597 | else | |
6cac2fcc LS |
11598 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
11599 | bgp->name_pretty); | |
ca61fd25 | 11600 | } |
d62a17ae | 11601 | } |
11602 | ||
11603 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
11604 | safi_t safi, |
11605 | const char *neighbor, | |
11606 | int as_type, as_t as, | |
96c81f66 | 11607 | uint16_t show_flags) |
d62a17ae | 11608 | { |
11609 | struct listnode *node, *nnode; | |
11610 | struct bgp *bgp; | |
8c1d4cd5 | 11611 | struct peer *fpeer = NULL; |
d62a17ae | 11612 | int is_first = 1; |
9f049418 | 11613 | bool nbr_output = false; |
85eeb029 | 11614 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11615 | |
11616 | if (use_json) | |
11617 | vty_out(vty, "{\n"); | |
11618 | ||
11619 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11620 | nbr_output = true; |
d62a17ae | 11621 | if (use_json) { |
d62a17ae | 11622 | if (!is_first) |
11623 | vty_out(vty, ",\n"); | |
11624 | else | |
11625 | is_first = 0; | |
11626 | ||
11627 | vty_out(vty, "\"%s\":", | |
11628 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11629 | ? VRF_DEFAULT_NAME |
d62a17ae | 11630 | : bgp->name); |
d62a17ae | 11631 | } |
8c1d4cd5 LS |
11632 | if (neighbor) { |
11633 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11634 | use_json); | |
11635 | if (!fpeer) | |
11636 | continue; | |
11637 | } | |
11638 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11639 | as, show_flags); | |
d62a17ae | 11640 | } |
11641 | ||
11642 | if (use_json) | |
11643 | vty_out(vty, "}\n"); | |
9f049418 DS |
11644 | else if (!nbr_output) |
11645 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11646 | } |
11647 | ||
11648 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 11649 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 11650 | as_t as, uint16_t show_flags) |
d62a17ae | 11651 | { |
11652 | struct bgp *bgp; | |
85eeb029 | 11653 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 11654 | struct peer *fpeer = NULL; |
d62a17ae | 11655 | |
11656 | if (name) { | |
11657 | if (strmatch(name, "all")) { | |
85eeb029 | 11658 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
11659 | neighbor, as_type, |
11660 | as, show_flags); | |
d62a17ae | 11661 | return CMD_SUCCESS; |
11662 | } else { | |
11663 | bgp = bgp_lookup_by_name(name); | |
11664 | ||
11665 | if (!bgp) { | |
11666 | if (use_json) | |
11667 | vty_out(vty, "{}\n"); | |
11668 | else | |
11669 | vty_out(vty, | |
ca61fd25 | 11670 | "%% BGP instance not found\n"); |
d62a17ae | 11671 | return CMD_WARNING; |
11672 | } | |
11673 | ||
8c1d4cd5 LS |
11674 | if (neighbor) { |
11675 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11676 | use_json); | |
11677 | if (!fpeer) | |
11678 | return CMD_WARNING; | |
11679 | } | |
11680 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11681 | as_type, as, show_flags); | |
d62a17ae | 11682 | return CMD_SUCCESS; |
11683 | } | |
11684 | } | |
11685 | ||
11686 | bgp = bgp_get_default(); | |
11687 | ||
8c1d4cd5 LS |
11688 | if (bgp) { |
11689 | if (neighbor) { | |
11690 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11691 | use_json); | |
11692 | if (!fpeer) | |
11693 | return CMD_WARNING; | |
11694 | } | |
11695 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11696 | as, show_flags); | |
11697 | } else { | |
ca61fd25 DS |
11698 | if (use_json) |
11699 | vty_out(vty, "{}\n"); | |
11700 | else | |
11701 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11702 | return CMD_WARNING; |
11703 | } | |
d62a17ae | 11704 | |
11705 | return CMD_SUCCESS; | |
4fb25c53 DW |
11706 | } |
11707 | ||
716b2d8a | 11708 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11709 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11710 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11711 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11712 | "]] [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 |
11713 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11714 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11715 | "Display the entries for all address families\n" | |
11716 | "Summary of BGP neighbor status\n" | |
11717 | "Show only sessions in Established state\n" | |
11718 | "Show only sessions not in Established state\n" | |
11719 | "Show only the specified neighbor session\n" | |
11720 | "Neighbor to display information about\n" | |
11721 | "Neighbor to display information about\n" | |
11722 | "Neighbor on BGP configured interface\n" | |
11723 | "Show only the specified remote AS sessions\n" | |
11724 | "AS number\n" | |
11725 | "Internal (iBGP) AS sessions\n" | |
11726 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11727 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11728 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11729 | { |
d62a17ae | 11730 | char *vrf = NULL; |
11731 | afi_t afi = AFI_MAX; | |
11732 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11733 | as_t as = 0; /* 0 means AS filter not set */ |
11734 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11735 | uint16_t show_flags = 0; |
d62a17ae | 11736 | |
11737 | int idx = 0; | |
11738 | ||
11739 | /* show [ip] bgp */ | |
96f3485c | 11740 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11741 | afi = AFI_IP; |
9a8bdf1c PG |
11742 | /* [<vrf> VIEWVRFNAME] */ |
11743 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11744 | vrf = argv[idx + 1]->arg; | |
11745 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11746 | vrf = NULL; | |
11747 | } else if (argv_find(argv, argc, "view", &idx)) | |
11748 | /* [<view> VIEWVRFNAME] */ | |
11749 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11750 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11751 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11752 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11753 | } | |
11754 | ||
3577f1c5 | 11755 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11756 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11757 | ||
10b49f14 | 11758 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11759 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11760 | ||
8c1d4cd5 LS |
11761 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11762 | if (argv[idx + 1]->arg[0] == 'i') | |
11763 | as_type = AS_INTERNAL; | |
11764 | else if (argv[idx + 1]->arg[0] == 'e') | |
11765 | as_type = AS_EXTERNAL; | |
11766 | else | |
11767 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11768 | } | |
11769 | ||
96c81f66 LS |
11770 | if (argv_find(argv, argc, "terse", &idx)) |
11771 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11772 | ||
85eeb029 DA |
11773 | if (argv_find(argv, argc, "wide", &idx)) |
11774 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11775 | ||
11776 | if (argv_find(argv, argc, "json", &idx)) | |
11777 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11778 | |
8c1d4cd5 LS |
11779 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11780 | show_flags); | |
d62a17ae | 11781 | } |
11782 | ||
5cb5f4d0 | 11783 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11784 | { |
5cb5f4d0 DD |
11785 | if (for_json) |
11786 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11787 | else |
5cb5f4d0 | 11788 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11789 | } |
11790 | ||
d62a17ae | 11791 | |
11792 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11793 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11794 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11795 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11796 | bool use_json, json_object *json_pref) |
d62a17ae | 11797 | { |
11798 | /* Send-Mode */ | |
11799 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11800 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11801 | if (use_json) { | |
11802 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11803 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11804 | json_object_string_add(json_pref, "sendMode", | |
11805 | "advertisedAndReceived"); | |
11806 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11807 | json_object_string_add(json_pref, "sendMode", | |
11808 | "advertised"); | |
11809 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11810 | json_object_string_add(json_pref, "sendMode", | |
11811 | "received"); | |
11812 | } else { | |
11813 | vty_out(vty, " Send-mode: "); | |
11814 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11815 | vty_out(vty, "advertised"); | |
11816 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11817 | vty_out(vty, "%sreceived", | |
11818 | CHECK_FLAG(p->af_cap[afi][safi], | |
11819 | adv_smcap) | |
11820 | ? ", " | |
11821 | : ""); | |
11822 | vty_out(vty, "\n"); | |
11823 | } | |
11824 | } | |
11825 | ||
11826 | /* Receive-Mode */ | |
11827 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11828 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11829 | if (use_json) { | |
11830 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11831 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11832 | json_object_string_add(json_pref, "recvMode", | |
11833 | "advertisedAndReceived"); | |
11834 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11835 | json_object_string_add(json_pref, "recvMode", | |
11836 | "advertised"); | |
11837 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11838 | json_object_string_add(json_pref, "recvMode", | |
11839 | "received"); | |
11840 | } else { | |
11841 | vty_out(vty, " Receive-mode: "); | |
11842 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11843 | vty_out(vty, "advertised"); | |
11844 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11845 | vty_out(vty, "%sreceived", | |
11846 | CHECK_FLAG(p->af_cap[afi][safi], | |
11847 | adv_rmcap) | |
11848 | ? ", " | |
11849 | : ""); | |
11850 | vty_out(vty, "\n"); | |
11851 | } | |
11852 | } | |
11853 | } | |
11854 | ||
eea685b6 DA |
11855 | static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty, |
11856 | struct peer *p, | |
eea685b6 | 11857 | json_object *json) |
2986cac2 | 11858 | { |
eea685b6 DA |
11859 | bool rbit = false; |
11860 | bool nbit = false; | |
2986cac2 | 11861 | |
13909c4f DS |
11862 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11863 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11864 | && (peer_established(p))) { |
eea685b6 DA |
11865 | rbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV); |
11866 | nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV); | |
2986cac2 | 11867 | } |
11868 | ||
403e64f8 | 11869 | if (json) { |
eea685b6 DA |
11870 | json_object_boolean_add(json, "rBit", rbit); |
11871 | json_object_boolean_add(json, "nBit", nbit); | |
2986cac2 | 11872 | } else { |
eea685b6 DA |
11873 | vty_out(vty, "\n R bit: %s", rbit ? "True" : "False"); |
11874 | vty_out(vty, "\n N bit: %s\n", nbit ? "True" : "False"); | |
2986cac2 | 11875 | } |
11876 | } | |
11877 | ||
13909c4f DS |
11878 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11879 | struct peer *peer, | |
13909c4f | 11880 | json_object *json) |
2986cac2 | 11881 | { |
2bb5d39b | 11882 | const char *mode = "NotApplicable"; |
2986cac2 | 11883 | |
403e64f8 | 11884 | if (!json) |
a53ca37b | 11885 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11886 | |
13909c4f | 11887 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11888 | && (peer_established(peer))) { |
2986cac2 | 11889 | |
13909c4f DS |
11890 | if ((peer->nsf_af_count == 0) |
11891 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11892 | |
2986cac2 | 11893 | mode = "Disable"; |
11894 | ||
13909c4f DS |
11895 | } else if (peer->nsf_af_count == 0 |
11896 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11897 | |
2986cac2 | 11898 | mode = "Helper"; |
11899 | ||
13909c4f DS |
11900 | } else if (peer->nsf_af_count != 0 |
11901 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11902 | |
2986cac2 | 11903 | mode = "Restart"; |
2986cac2 | 11904 | } |
11905 | } | |
11906 | ||
403e64f8 | 11907 | if (json) |
13909c4f | 11908 | json_object_string_add(json, "remoteGrMode", mode); |
403e64f8 | 11909 | else |
2986cac2 | 11910 | vty_out(vty, mode, "\n"); |
11911 | } | |
11912 | ||
13909c4f DS |
11913 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11914 | struct peer *p, | |
13909c4f | 11915 | json_object *json) |
2986cac2 | 11916 | { |
11917 | const char *mode = "Invalid"; | |
11918 | ||
403e64f8 | 11919 | if (!json) |
a53ca37b | 11920 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11921 | |
11922 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11923 | mode = "Helper"; | |
11924 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11925 | mode = "Restart"; | |
11926 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11927 | mode = "Disable"; | |
2ba1fe69 | 11928 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11929 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11930 | mode = "Helper*"; | |
11931 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11932 | mode = "Restart*"; | |
11933 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11934 | mode = "Disable*"; | |
11935 | else | |
11936 | mode = "Invalid*"; | |
2ba1fe69 | 11937 | } |
2986cac2 | 11938 | |
403e64f8 | 11939 | if (json) |
13909c4f | 11940 | json_object_string_add(json, "localGrMode", mode); |
403e64f8 | 11941 | else |
2986cac2 | 11942 | vty_out(vty, mode, "\n"); |
2986cac2 | 11943 | } |
11944 | ||
13909c4f | 11945 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
403e64f8 | 11946 | struct vty *vty, struct peer *peer, json_object *json) |
2986cac2 | 11947 | { |
2ba1fe69 | 11948 | afi_t afi; |
11949 | safi_t safi; | |
2986cac2 | 11950 | json_object *json_afi_safi = NULL; |
11951 | json_object *json_timer = NULL; | |
11952 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11953 | bool eor_flag = false; |
2986cac2 | 11954 | |
df8d723c DA |
11955 | FOREACH_AFI_SAFI_NSF (afi, safi) { |
11956 | if (!peer->afc[afi][safi]) | |
11957 | continue; | |
2986cac2 | 11958 | |
df8d723c DA |
11959 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) || |
11960 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11961 | continue; | |
9e3b51a7 | 11962 | |
403e64f8 | 11963 | if (json) { |
df8d723c DA |
11964 | json_afi_safi = json_object_new_object(); |
11965 | json_endofrib_status = json_object_new_object(); | |
11966 | json_timer = json_object_new_object(); | |
11967 | } | |
2986cac2 | 11968 | |
df8d723c DA |
11969 | if (peer->eor_stime[afi][safi] >= peer->pkt_stime[afi][safi]) |
11970 | eor_flag = true; | |
11971 | else | |
11972 | eor_flag = false; | |
2986cac2 | 11973 | |
403e64f8 | 11974 | if (!json) { |
df8d723c DA |
11975 | vty_out(vty, " %s:\n", |
11976 | get_afi_safi_str(afi, safi, false)); | |
2986cac2 | 11977 | |
df8d723c DA |
11978 | vty_out(vty, " F bit: "); |
11979 | } | |
2986cac2 | 11980 | |
df8d723c DA |
11981 | if (peer->nsf[afi][safi] && |
11982 | CHECK_FLAG(peer->af_cap[afi][safi], | |
11983 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11984 | |
403e64f8 | 11985 | if (json) { |
df8d723c DA |
11986 | json_object_boolean_true_add(json_afi_safi, |
11987 | "fBit"); | |
11988 | } else | |
11989 | vty_out(vty, "True\n"); | |
11990 | } else { | |
403e64f8 | 11991 | if (json) |
df8d723c DA |
11992 | json_object_boolean_false_add(json_afi_safi, |
11993 | "fBit"); | |
11994 | else | |
11995 | vty_out(vty, "False\n"); | |
11996 | } | |
2986cac2 | 11997 | |
403e64f8 | 11998 | if (!json) |
df8d723c | 11999 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 12000 | |
df8d723c DA |
12001 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12002 | PEER_STATUS_EOR_SEND)) { | |
403e64f8 | 12003 | if (json) { |
df8d723c DA |
12004 | json_object_boolean_true_add( |
12005 | json_endofrib_status, "endOfRibSend"); | |
9e3b51a7 | 12006 | |
df8d723c DA |
12007 | PRINT_EOR_JSON(eor_flag); |
12008 | } else { | |
12009 | vty_out(vty, "Yes\n"); | |
12010 | vty_out(vty, | |
12011 | " End-of-RIB sent after update: "); | |
2986cac2 | 12012 | |
df8d723c DA |
12013 | PRINT_EOR(eor_flag); |
12014 | } | |
12015 | } else { | |
403e64f8 | 12016 | if (json) { |
df8d723c DA |
12017 | json_object_boolean_false_add( |
12018 | json_endofrib_status, "endOfRibSend"); | |
12019 | json_object_boolean_false_add( | |
12020 | json_endofrib_status, | |
12021 | "endOfRibSentAfterUpdate"); | |
13909c4f | 12022 | } else { |
df8d723c DA |
12023 | vty_out(vty, "No\n"); |
12024 | vty_out(vty, | |
12025 | " End-of-RIB sent after update: "); | |
12026 | vty_out(vty, "No\n"); | |
13909c4f | 12027 | } |
df8d723c | 12028 | } |
2986cac2 | 12029 | |
403e64f8 | 12030 | if (!json) |
df8d723c | 12031 | vty_out(vty, " End-of-RIB received: "); |
a53ca37b | 12032 | |
df8d723c DA |
12033 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12034 | PEER_STATUS_EOR_RECEIVED)) { | |
403e64f8 | 12035 | if (json) |
df8d723c DA |
12036 | json_object_boolean_true_add( |
12037 | json_endofrib_status, "endOfRibRecv"); | |
12038 | else | |
12039 | vty_out(vty, "Yes\n"); | |
12040 | } else { | |
403e64f8 | 12041 | if (json) |
df8d723c DA |
12042 | json_object_boolean_false_add( |
12043 | json_endofrib_status, "endOfRibRecv"); | |
12044 | else | |
12045 | vty_out(vty, "No\n"); | |
12046 | } | |
12047 | ||
403e64f8 | 12048 | if (json) { |
df8d723c DA |
12049 | json_object_int_add(json_timer, "stalePathTimer", |
12050 | peer->bgp->stalepath_time); | |
12051 | ||
12052 | if (peer->t_gr_stale != NULL) { | |
12053 | json_object_int_add(json_timer, | |
12054 | "stalePathTimerRemaining", | |
12055 | thread_timer_remain_second( | |
12056 | peer->t_gr_stale)); | |
a53ca37b DA |
12057 | } |
12058 | ||
df8d723c DA |
12059 | /* Display Configured Selection |
12060 | * Deferral only when when | |
12061 | * Gr mode is enabled. | |
12062 | */ | |
12063 | if (CHECK_FLAG(peer->flags, | |
12064 | PEER_FLAG_GRACEFUL_RESTART)) { | |
13909c4f | 12065 | json_object_int_add(json_timer, |
df8d723c | 12066 | "selectionDeferralTimer", |
13909c4f | 12067 | peer->bgp->stalepath_time); |
df8d723c | 12068 | } |
2986cac2 | 12069 | |
df8d723c DA |
12070 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12071 | NULL) { | |
2986cac2 | 12072 | |
df8d723c DA |
12073 | json_object_int_add( |
12074 | json_timer, | |
12075 | "selectionDeferralTimerRemaining", | |
12076 | thread_timer_remain_second( | |
12077 | peer->bgp->gr_info[afi][safi] | |
12078 | .t_select_deferral)); | |
12079 | } | |
12080 | } else { | |
12081 | vty_out(vty, " Timers:\n"); | |
12082 | vty_out(vty, | |
12083 | " Configured Stale Path Time(sec): %u\n", | |
12084 | peer->bgp->stalepath_time); | |
2986cac2 | 12085 | |
df8d723c | 12086 | if (peer->t_gr_stale != NULL) |
13909c4f | 12087 | vty_out(vty, |
df8d723c DA |
12088 | " Stale Path Remaining(sec): %ld\n", |
12089 | thread_timer_remain_second( | |
12090 | peer->t_gr_stale)); | |
12091 | /* Display Configured Selection | |
12092 | * Deferral only when when | |
12093 | * Gr mode is enabled. | |
12094 | */ | |
12095 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
12096 | vty_out(vty, | |
12097 | " Configured Selection Deferral Time(sec): %u\n", | |
12098 | peer->bgp->select_defer_time); | |
2986cac2 | 12099 | |
df8d723c DA |
12100 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12101 | NULL) | |
12102 | vty_out(vty, | |
12103 | " Selection Deferral Time Remaining(sec): %ld\n", | |
12104 | thread_timer_remain_second( | |
12105 | peer->bgp->gr_info[afi][safi] | |
12106 | .t_select_deferral)); | |
12107 | } | |
403e64f8 | 12108 | if (json) { |
df8d723c DA |
12109 | json_object_object_add(json_afi_safi, "endOfRibStatus", |
12110 | json_endofrib_status); | |
12111 | json_object_object_add(json_afi_safi, "timers", | |
12112 | json_timer); | |
12113 | json_object_object_add( | |
12114 | json, get_afi_safi_str(afi, safi, true), | |
12115 | json_afi_safi); | |
2986cac2 | 12116 | } |
12117 | } | |
12118 | } | |
12119 | ||
36235319 QY |
12120 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
12121 | struct peer *p, | |
36235319 | 12122 | json_object *json) |
2986cac2 | 12123 | { |
403e64f8 | 12124 | if (json) { |
2986cac2 | 12125 | json_object *json_timer = NULL; |
12126 | ||
12127 | json_timer = json_object_new_object(); | |
12128 | ||
13909c4f DS |
12129 | json_object_int_add(json_timer, "configuredRestartTimer", |
12130 | p->bgp->restart_time); | |
2986cac2 | 12131 | |
13909c4f DS |
12132 | json_object_int_add(json_timer, "receivedRestartTimer", |
12133 | p->v_gr_restart); | |
2986cac2 | 12134 | |
13909c4f DS |
12135 | if (p->t_gr_restart != NULL) |
12136 | json_object_int_add( | |
12137 | json_timer, "restartTimerRemaining", | |
12138 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 12139 | |
12140 | json_object_object_add(json, "timers", json_timer); | |
12141 | } else { | |
12142 | ||
a53ca37b DA |
12143 | vty_out(vty, " Timers:\n"); |
12144 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 12145 | p->bgp->restart_time); |
2986cac2 | 12146 | |
a53ca37b | 12147 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
12148 | p->v_gr_restart); |
12149 | if (p->t_gr_restart != NULL) | |
a53ca37b | 12150 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 12151 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 12152 | if (p->t_gr_restart != NULL) { |
a53ca37b | 12153 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
12154 | thread_timer_remain_second(p->t_gr_restart)); |
12155 | } | |
2986cac2 | 12156 | } |
12157 | } | |
12158 | ||
12159 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
403e64f8 | 12160 | json_object *json) |
2986cac2 | 12161 | { |
2986cac2 | 12162 | char dn_flag[2] = {0}; |
2b7165e7 QY |
12163 | /* '*' + v6 address of neighbor */ |
12164 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 12165 | |
2986cac2 | 12166 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
12167 | dn_flag[0] = '*'; | |
12168 | ||
12169 | if (p->conf_if) { | |
403e64f8 | 12170 | if (json) |
47e12884 DA |
12171 | json_object_string_addf(json, "neighborAddr", "%pSU", |
12172 | &p->su); | |
2986cac2 | 12173 | else |
47e12884 DA |
12174 | vty_out(vty, "BGP neighbor on %s: %pSU\n", p->conf_if, |
12175 | &p->su); | |
2986cac2 | 12176 | } else { |
772270f3 QY |
12177 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
12178 | p->host); | |
2986cac2 | 12179 | |
403e64f8 | 12180 | if (json) |
36235319 QY |
12181 | json_object_string_add(json, "neighborAddr", |
12182 | neighborAddr); | |
2986cac2 | 12183 | else |
36235319 | 12184 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 12185 | } |
12186 | ||
12187 | /* more gr info in new format */ | |
403e64f8 | 12188 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json); |
2986cac2 | 12189 | } |
12190 | ||
d62a17ae | 12191 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 12192 | safi_t safi, bool use_json, |
d62a17ae | 12193 | json_object *json_neigh) |
12194 | { | |
0291c246 MK |
12195 | struct bgp_filter *filter; |
12196 | struct peer_af *paf; | |
12197 | char orf_pfx_name[BUFSIZ]; | |
12198 | int orf_pfx_count; | |
12199 | json_object *json_af = NULL; | |
12200 | json_object *json_prefA = NULL; | |
12201 | json_object *json_prefB = NULL; | |
12202 | json_object *json_addr = NULL; | |
fa36596c | 12203 | json_object *json_advmap = NULL; |
d62a17ae | 12204 | |
12205 | if (use_json) { | |
12206 | json_addr = json_object_new_object(); | |
12207 | json_af = json_object_new_object(); | |
12208 | filter = &p->filter[afi][safi]; | |
12209 | ||
12210 | if (peer_group_active(p)) | |
12211 | json_object_string_add(json_addr, "peerGroupMember", | |
12212 | p->group->name); | |
12213 | ||
12214 | paf = peer_af_find(p, afi, safi); | |
12215 | if (paf && PAF_SUBGRP(paf)) { | |
12216 | json_object_int_add(json_addr, "updateGroupId", | |
12217 | PAF_UPDGRP(paf)->id); | |
12218 | json_object_int_add(json_addr, "subGroupId", | |
12219 | PAF_SUBGRP(paf)->id); | |
12220 | json_object_int_add(json_addr, "packetQueueLength", | |
12221 | bpacket_queue_virtual_length(paf)); | |
12222 | } | |
12223 | ||
12224 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12225 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12226 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12227 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12228 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12229 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12230 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12231 | json_object_int_add(json_af, "orfType", | |
12232 | ORF_TYPE_PREFIX); | |
12233 | json_prefA = json_object_new_object(); | |
12234 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
12235 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
12236 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12237 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12238 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
12239 | use_json, json_prefA); | |
12240 | json_object_object_add(json_af, "orfPrefixList", | |
12241 | json_prefA); | |
12242 | } | |
12243 | ||
12244 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12245 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12246 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12247 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12248 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12249 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12250 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12251 | json_object_int_add(json_af, "orfOldType", | |
12252 | ORF_TYPE_PREFIX_OLD); | |
12253 | json_prefB = json_object_new_object(); | |
12254 | bgp_show_peer_afi_orf_cap( | |
12255 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12256 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12257 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12258 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
12259 | json_prefB); | |
12260 | json_object_object_add(json_af, "orfOldPrefixList", | |
12261 | json_prefB); | |
12262 | } | |
12263 | ||
12264 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12265 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12266 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12267 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12268 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12269 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12270 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12271 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12272 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12273 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12274 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12275 | json_object_object_add(json_addr, "afDependentCap", | |
12276 | json_af); | |
12277 | else | |
12278 | json_object_free(json_af); | |
12279 | ||
772270f3 QY |
12280 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12281 | p->host, afi, safi); | |
d62a17ae | 12282 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12283 | NULL, afi, orf_pfx_name, use_json); | |
12284 | ||
12285 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12286 | PEER_STATUS_ORF_PREFIX_SEND) | |
12287 | || orf_pfx_count) { | |
12288 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12289 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12290 | json_object_boolean_true_add(json_neigh, | |
12291 | "orfSent"); | |
12292 | if (orf_pfx_count) | |
12293 | json_object_int_add(json_addr, "orfRecvCounter", | |
12294 | orf_pfx_count); | |
12295 | } | |
12296 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12297 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12298 | json_object_string_add( | |
12299 | json_addr, "orfFirstUpdate", | |
12300 | "deferredUntilORFOrRouteRefreshRecvd"); | |
12301 | ||
12302 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12303 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12304 | json_object_boolean_true_add(json_addr, | |
12305 | "routeReflectorClient"); | |
12306 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12307 | PEER_FLAG_RSERVER_CLIENT)) | |
12308 | json_object_boolean_true_add(json_addr, | |
12309 | "routeServerClient"); | |
12310 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12311 | json_object_boolean_true_add(json_addr, | |
12312 | "inboundSoftConfigPermit"); | |
12313 | ||
12314 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12315 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12316 | json_object_boolean_true_add( | |
12317 | json_addr, | |
12318 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
12319 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12320 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12321 | json_object_boolean_true_add( | |
12322 | json_addr, | |
12323 | "privateAsNumsReplacedInUpdatesToNbr"); | |
12324 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12325 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12326 | json_object_boolean_true_add( | |
12327 | json_addr, | |
12328 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
12329 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12330 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12331 | json_object_boolean_true_add( | |
12332 | json_addr, | |
12333 | "privateAsNumsRemovedInUpdatesToNbr"); | |
12334 | ||
b2ac1d0d MS |
12335 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12336 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12337 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12338 | json_object_boolean_true_add(json_addr, | |
12339 | "allowAsInOrigin"); | |
12340 | else | |
12341 | json_object_int_add(json_addr, "allowAsInCount", | |
12342 | p->allowas_in[afi][safi]); | |
12343 | } | |
12344 | ||
dcc68b5e MS |
12345 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12346 | json_object_boolean_true_add( | |
12347 | json_addr, | |
12348 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12349 | ->type_json_name); | |
d62a17ae | 12350 | |
12351 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12352 | json_object_string_add(json_addr, | |
12353 | "overrideASNsInOutboundUpdates", | |
12354 | "ifAspathEqualRemoteAs"); | |
12355 | ||
12356 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12357 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12358 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12359 | json_object_boolean_true_add(json_addr, | |
12360 | "routerAlwaysNextHop"); | |
12361 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12362 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12363 | json_object_boolean_true_add( | |
12364 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
12365 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12366 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12367 | json_object_boolean_true_add( | |
12368 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
12369 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12370 | json_object_boolean_true_add( | |
12371 | json_addr, "unchangedMedPropogatedToNbr"); | |
12372 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12373 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12374 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
12375 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12376 | PEER_FLAG_SEND_COMMUNITY) | |
12377 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12378 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12379 | json_object_string_add(json_addr, | |
12380 | "commAttriSentToNbr", | |
12381 | "extendedAndStandard"); | |
12382 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12383 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12384 | json_object_string_add(json_addr, | |
12385 | "commAttriSentToNbr", | |
12386 | "extended"); | |
12387 | else | |
12388 | json_object_string_add(json_addr, | |
12389 | "commAttriSentToNbr", | |
12390 | "standard"); | |
12391 | } | |
12392 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12393 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12394 | if (p->default_rmap[afi][safi].name) | |
12395 | json_object_string_add( | |
12396 | json_addr, "defaultRouteMap", | |
12397 | p->default_rmap[afi][safi].name); | |
12398 | ||
12399 | if (paf && PAF_SUBGRP(paf) | |
12400 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12401 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12402 | json_object_boolean_true_add(json_addr, | |
12403 | "defaultSent"); | |
12404 | else | |
12405 | json_object_boolean_true_add(json_addr, | |
12406 | "defaultNotSent"); | |
12407 | } | |
12408 | ||
dff8f48d | 12409 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 12410 | if (is_evpn_enabled()) |
60466a63 QY |
12411 | json_object_boolean_true_add( |
12412 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
12413 | } |
12414 | ||
d62a17ae | 12415 | if (filter->plist[FILTER_IN].name |
12416 | || filter->dlist[FILTER_IN].name | |
12417 | || filter->aslist[FILTER_IN].name | |
12418 | || filter->map[RMAP_IN].name) | |
12419 | json_object_boolean_true_add(json_addr, | |
12420 | "inboundPathPolicyConfig"); | |
12421 | if (filter->plist[FILTER_OUT].name | |
12422 | || filter->dlist[FILTER_OUT].name | |
12423 | || filter->aslist[FILTER_OUT].name | |
12424 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12425 | json_object_boolean_true_add( | |
12426 | json_addr, "outboundPathPolicyConfig"); | |
12427 | ||
12428 | /* prefix-list */ | |
12429 | if (filter->plist[FILTER_IN].name) | |
12430 | json_object_string_add(json_addr, | |
12431 | "incomingUpdatePrefixFilterList", | |
12432 | filter->plist[FILTER_IN].name); | |
12433 | if (filter->plist[FILTER_OUT].name) | |
12434 | json_object_string_add(json_addr, | |
12435 | "outgoingUpdatePrefixFilterList", | |
12436 | filter->plist[FILTER_OUT].name); | |
12437 | ||
12438 | /* distribute-list */ | |
12439 | if (filter->dlist[FILTER_IN].name) | |
12440 | json_object_string_add( | |
12441 | json_addr, "incomingUpdateNetworkFilterList", | |
12442 | filter->dlist[FILTER_IN].name); | |
12443 | if (filter->dlist[FILTER_OUT].name) | |
12444 | json_object_string_add( | |
12445 | json_addr, "outgoingUpdateNetworkFilterList", | |
12446 | filter->dlist[FILTER_OUT].name); | |
12447 | ||
12448 | /* filter-list. */ | |
12449 | if (filter->aslist[FILTER_IN].name) | |
12450 | json_object_string_add(json_addr, | |
12451 | "incomingUpdateAsPathFilterList", | |
12452 | filter->aslist[FILTER_IN].name); | |
12453 | if (filter->aslist[FILTER_OUT].name) | |
12454 | json_object_string_add(json_addr, | |
12455 | "outgoingUpdateAsPathFilterList", | |
12456 | filter->aslist[FILTER_OUT].name); | |
12457 | ||
12458 | /* route-map. */ | |
12459 | if (filter->map[RMAP_IN].name) | |
12460 | json_object_string_add( | |
12461 | json_addr, "routeMapForIncomingAdvertisements", | |
12462 | filter->map[RMAP_IN].name); | |
12463 | if (filter->map[RMAP_OUT].name) | |
12464 | json_object_string_add( | |
12465 | json_addr, "routeMapForOutgoingAdvertisements", | |
12466 | filter->map[RMAP_OUT].name); | |
12467 | ||
9dac9fc8 | 12468 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12469 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12470 | && !bgp_inbound_policy_exists(p, filter)) |
12471 | json_object_string_add( | |
12472 | json_addr, "inboundEbgpRequiresPolicy", | |
12473 | "Inbound updates discarded due to missing policy"); | |
12474 | ||
12475 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12476 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12477 | && (!bgp_outbound_policy_exists(p, filter))) |
12478 | json_object_string_add( | |
12479 | json_addr, "outboundEbgpRequiresPolicy", | |
12480 | "Outbound updates discarded due to missing policy"); | |
12481 | ||
d62a17ae | 12482 | /* unsuppress-map */ |
12483 | if (filter->usmap.name) | |
12484 | json_object_string_add(json_addr, | |
12485 | "selectiveUnsuppressRouteMap", | |
12486 | filter->usmap.name); | |
12487 | ||
fa36596c MK |
12488 | /* advertise-map */ |
12489 | if (filter->advmap.aname) { | |
12490 | json_advmap = json_object_new_object(); | |
12491 | json_object_string_add(json_advmap, "condition", | |
12492 | filter->advmap.condition | |
12493 | ? "EXIST" | |
12494 | : "NON_EXIST"); | |
12495 | json_object_string_add(json_advmap, "conditionMap", | |
12496 | filter->advmap.cname); | |
12497 | json_object_string_add(json_advmap, "advertiseMap", | |
12498 | filter->advmap.aname); | |
ecf2b628 QY |
12499 | json_object_string_add( |
12500 | json_advmap, "advertiseStatus", | |
12501 | filter->advmap.update_type == | |
12502 | UPDATE_TYPE_ADVERTISE | |
12503 | ? "Advertise" | |
12504 | : "Withdraw"); | |
fa36596c MK |
12505 | json_object_object_add(json_addr, "advertiseMap", |
12506 | json_advmap); | |
12507 | } | |
12508 | ||
d62a17ae | 12509 | /* Receive prefix count */ |
12510 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
12511 | p->pcount[afi][safi]); | |
50e05855 AD |
12512 | if (paf && PAF_SUBGRP(paf)) |
12513 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12514 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12515 | |
fde246e8 DA |
12516 | /* Maximum prefix */ |
12517 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12518 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12519 | p->pmax_out[afi][safi]); | |
12520 | ||
d62a17ae | 12521 | /* Maximum prefix */ |
12522 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12523 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12524 | p->pmax[afi][safi]); | |
12525 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12526 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12527 | json_object_boolean_true_add( | |
12528 | json_addr, "prefixAllowedMaxWarning"); | |
12529 | json_object_int_add(json_addr, | |
12530 | "prefixAllowedWarningThresh", | |
12531 | p->pmax_threshold[afi][safi]); | |
12532 | if (p->pmax_restart[afi][safi]) | |
12533 | json_object_int_add( | |
12534 | json_addr, | |
12535 | "prefixAllowedRestartIntervalMsecs", | |
12536 | p->pmax_restart[afi][safi] * 60000); | |
12537 | } | |
2986cac2 | 12538 | json_object_object_add(json_neigh, |
36235319 | 12539 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12540 | json_addr); |
12541 | ||
12542 | } else { | |
12543 | filter = &p->filter[afi][safi]; | |
12544 | ||
12545 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12546 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12547 | |
12548 | if (peer_group_active(p)) | |
12549 | vty_out(vty, " %s peer-group member\n", | |
12550 | p->group->name); | |
12551 | ||
12552 | paf = peer_af_find(p, afi, safi); | |
12553 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12554 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12555 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12556 | vty_out(vty, " Packet Queue length %d\n", | |
12557 | bpacket_queue_virtual_length(paf)); | |
12558 | } else { | |
12559 | vty_out(vty, " Not part of any update group\n"); | |
12560 | } | |
12561 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12562 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12563 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12564 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12565 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12566 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12567 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12568 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12569 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12570 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12571 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12572 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12573 | ||
12574 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12575 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12576 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12577 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12578 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12579 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12580 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12581 | vty_out(vty, | |
12582 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12583 | ORF_TYPE_PREFIX); | |
12584 | bgp_show_peer_afi_orf_cap( | |
12585 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12586 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12587 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12588 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12589 | } | |
12590 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12591 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12592 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12593 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12594 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12595 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12596 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12597 | vty_out(vty, | |
12598 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12599 | ORF_TYPE_PREFIX_OLD); | |
12600 | bgp_show_peer_afi_orf_cap( | |
12601 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12602 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12603 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12604 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12605 | } | |
12606 | ||
772270f3 QY |
12607 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12608 | p->host, afi, safi); | |
d62a17ae | 12609 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12610 | NULL, afi, orf_pfx_name, use_json); | |
12611 | ||
12612 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12613 | PEER_STATUS_ORF_PREFIX_SEND) | |
12614 | || orf_pfx_count) { | |
12615 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12616 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12617 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12618 | vty_out(vty, " sent;"); | |
12619 | if (orf_pfx_count) | |
12620 | vty_out(vty, " received (%d entries)", | |
12621 | orf_pfx_count); | |
12622 | vty_out(vty, "\n"); | |
12623 | } | |
12624 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12625 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12626 | vty_out(vty, | |
12627 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12628 | ||
12629 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12630 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12631 | vty_out(vty, " Route-Reflector Client\n"); | |
12632 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12633 | PEER_FLAG_RSERVER_CLIENT)) | |
12634 | vty_out(vty, " Route-Server Client\n"); | |
70cd87ca MK |
12635 | |
12636 | if (peer_af_flag_check(p, afi, safi, PEER_FLAG_ORR_GROUP)) | |
12637 | vty_out(vty, " ORR group (configured) : %s\n", | |
12638 | p->orr_group_name[afi][safi]); | |
12639 | ||
d62a17ae | 12640 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) |
12641 | vty_out(vty, | |
12642 | " Inbound soft reconfiguration allowed\n"); | |
12643 | ||
12644 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12645 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12646 | vty_out(vty, | |
12647 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12648 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12649 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12650 | vty_out(vty, | |
12651 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12652 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12653 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12654 | vty_out(vty, | |
12655 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12656 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12657 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12658 | vty_out(vty, | |
12659 | " Private AS numbers removed in updates to this neighbor\n"); | |
12660 | ||
b2ac1d0d MS |
12661 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12662 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12663 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12664 | vty_out(vty, | |
12665 | " Local AS allowed as path origin\n"); | |
12666 | else | |
12667 | vty_out(vty, | |
12668 | " Local AS allowed in path, %d occurrences\n", | |
12669 | p->allowas_in[afi][safi]); | |
12670 | } | |
12671 | ||
dcc68b5e MS |
12672 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12673 | vty_out(vty, " %s\n", | |
12674 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12675 | ->human_description); | |
d62a17ae | 12676 | |
12677 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12678 | vty_out(vty, | |
12679 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12680 | ||
12681 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12682 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12683 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12684 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12685 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12686 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12687 | vty_out(vty, | |
12688 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12689 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12690 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12691 | vty_out(vty, | |
12692 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12693 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12694 | vty_out(vty, | |
12695 | " MED is propagated unchanged to this neighbor\n"); | |
12696 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12697 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12698 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12699 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12700 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12701 | vty_out(vty, | |
12702 | " Community attribute sent to this neighbor"); | |
12703 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12704 | PEER_FLAG_SEND_COMMUNITY) | |
12705 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12706 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12707 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12708 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12709 | vty_out(vty, "(all)\n"); | |
12710 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12711 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12712 | vty_out(vty, "(large)\n"); | |
12713 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12714 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12715 | vty_out(vty, "(extended)\n"); | |
12716 | else | |
12717 | vty_out(vty, "(standard)\n"); | |
12718 | } | |
12719 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12720 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12721 | vty_out(vty, " Default information originate,"); | |
12722 | ||
12723 | if (p->default_rmap[afi][safi].name) | |
12724 | vty_out(vty, " default route-map %s%s,", | |
12725 | p->default_rmap[afi][safi].map ? "*" | |
12726 | : "", | |
12727 | p->default_rmap[afi][safi].name); | |
12728 | if (paf && PAF_SUBGRP(paf) | |
12729 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12730 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12731 | vty_out(vty, " default sent\n"); | |
12732 | else | |
12733 | vty_out(vty, " default not sent\n"); | |
12734 | } | |
12735 | ||
dff8f48d MK |
12736 | /* advertise-vni-all */ |
12737 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12738 | if (is_evpn_enabled()) |
dff8f48d MK |
12739 | vty_out(vty, " advertise-all-vni\n"); |
12740 | } | |
12741 | ||
d62a17ae | 12742 | if (filter->plist[FILTER_IN].name |
12743 | || filter->dlist[FILTER_IN].name | |
12744 | || filter->aslist[FILTER_IN].name | |
12745 | || filter->map[RMAP_IN].name) | |
12746 | vty_out(vty, " Inbound path policy configured\n"); | |
12747 | if (filter->plist[FILTER_OUT].name | |
12748 | || filter->dlist[FILTER_OUT].name | |
12749 | || filter->aslist[FILTER_OUT].name | |
12750 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12751 | vty_out(vty, " Outbound path policy configured\n"); | |
12752 | ||
12753 | /* prefix-list */ | |
12754 | if (filter->plist[FILTER_IN].name) | |
12755 | vty_out(vty, | |
12756 | " Incoming update prefix filter list is %s%s\n", | |
12757 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12758 | filter->plist[FILTER_IN].name); | |
12759 | if (filter->plist[FILTER_OUT].name) | |
12760 | vty_out(vty, | |
12761 | " Outgoing update prefix filter list is %s%s\n", | |
12762 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12763 | filter->plist[FILTER_OUT].name); | |
12764 | ||
12765 | /* distribute-list */ | |
12766 | if (filter->dlist[FILTER_IN].name) | |
12767 | vty_out(vty, | |
12768 | " Incoming update network filter list is %s%s\n", | |
12769 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12770 | filter->dlist[FILTER_IN].name); | |
12771 | if (filter->dlist[FILTER_OUT].name) | |
12772 | vty_out(vty, | |
12773 | " Outgoing update network filter list is %s%s\n", | |
12774 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12775 | filter->dlist[FILTER_OUT].name); | |
12776 | ||
12777 | /* filter-list. */ | |
12778 | if (filter->aslist[FILTER_IN].name) | |
12779 | vty_out(vty, | |
12780 | " Incoming update AS path filter list is %s%s\n", | |
12781 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12782 | filter->aslist[FILTER_IN].name); | |
12783 | if (filter->aslist[FILTER_OUT].name) | |
12784 | vty_out(vty, | |
12785 | " Outgoing update AS path filter list is %s%s\n", | |
12786 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12787 | filter->aslist[FILTER_OUT].name); | |
12788 | ||
12789 | /* route-map. */ | |
12790 | if (filter->map[RMAP_IN].name) | |
12791 | vty_out(vty, | |
12792 | " Route map for incoming advertisements is %s%s\n", | |
12793 | filter->map[RMAP_IN].map ? "*" : "", | |
12794 | filter->map[RMAP_IN].name); | |
12795 | if (filter->map[RMAP_OUT].name) | |
12796 | vty_out(vty, | |
12797 | " Route map for outgoing advertisements is %s%s\n", | |
12798 | filter->map[RMAP_OUT].map ? "*" : "", | |
12799 | filter->map[RMAP_OUT].name); | |
12800 | ||
9dac9fc8 | 12801 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12802 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12803 | && !bgp_inbound_policy_exists(p, filter)) |
12804 | vty_out(vty, | |
12805 | " Inbound updates discarded due to missing policy\n"); | |
12806 | ||
12807 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12808 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12809 | && !bgp_outbound_policy_exists(p, filter)) |
12810 | vty_out(vty, | |
12811 | " Outbound updates discarded due to missing policy\n"); | |
12812 | ||
d62a17ae | 12813 | /* unsuppress-map */ |
12814 | if (filter->usmap.name) | |
12815 | vty_out(vty, | |
12816 | " Route map for selective unsuppress is %s%s\n", | |
12817 | filter->usmap.map ? "*" : "", | |
12818 | filter->usmap.name); | |
12819 | ||
7f7940e6 MK |
12820 | /* advertise-map */ |
12821 | if (filter->advmap.aname && filter->advmap.cname) | |
12822 | vty_out(vty, | |
12823 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12824 | filter->advmap.condition ? "EXIST" | |
12825 | : "NON_EXIST", | |
12826 | filter->advmap.cmap ? "*" : "", | |
12827 | filter->advmap.cname, | |
12828 | filter->advmap.amap ? "*" : "", | |
12829 | filter->advmap.aname, | |
ecf2b628 QY |
12830 | filter->advmap.update_type == |
12831 | UPDATE_TYPE_ADVERTISE | |
c385f82a MK |
12832 | ? "Advertise" |
12833 | : "Withdraw"); | |
7f7940e6 | 12834 | |
d62a17ae | 12835 | /* Receive prefix count */ |
6cde4b45 | 12836 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12837 | p->pcount[afi][safi]); |
d62a17ae | 12838 | |
fde246e8 DA |
12839 | /* maximum-prefix-out */ |
12840 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12841 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12842 | vty_out(vty, | |
6cde4b45 | 12843 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12844 | p->pmax_out[afi][safi]); |
12845 | ||
d62a17ae | 12846 | /* Maximum prefix */ |
12847 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12848 | vty_out(vty, |
6cde4b45 | 12849 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12850 | p->pmax[afi][safi], |
12851 | CHECK_FLAG(p->af_flags[afi][safi], | |
12852 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12853 | ? " (warning-only)" | |
12854 | : ""); | |
12855 | vty_out(vty, " Threshold for warning message %d%%", | |
12856 | p->pmax_threshold[afi][safi]); | |
12857 | if (p->pmax_restart[afi][safi]) | |
12858 | vty_out(vty, ", restart interval %d min", | |
12859 | p->pmax_restart[afi][safi]); | |
12860 | vty_out(vty, "\n"); | |
12861 | } | |
12862 | ||
12863 | vty_out(vty, "\n"); | |
12864 | } | |
12865 | } | |
12866 | ||
9f049418 | 12867 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12868 | json_object *json) |
718e3744 | 12869 | { |
d62a17ae | 12870 | struct bgp *bgp; |
d62a17ae | 12871 | char timebuf[BGP_UPTIME_LEN]; |
12872 | char dn_flag[2]; | |
d62a17ae | 12873 | afi_t afi; |
12874 | safi_t safi; | |
d7c0a89a QY |
12875 | uint16_t i; |
12876 | uint8_t *msg; | |
d62a17ae | 12877 | json_object *json_neigh = NULL; |
12878 | time_t epoch_tbuf; | |
4ab46701 | 12879 | uint32_t sync_tcp_mss; |
718e3744 | 12880 | |
d62a17ae | 12881 | bgp = p->bgp; |
12882 | ||
12883 | if (use_json) | |
12884 | json_neigh = json_object_new_object(); | |
12885 | ||
12886 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12887 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12888 | dn_flag[0] = '*'; | |
12889 | ||
12890 | if (!use_json) { | |
12891 | if (p->conf_if) /* Configured interface name. */ | |
47e12884 DA |
12892 | vty_out(vty, "BGP neighbor on %s: %pSU, ", p->conf_if, |
12893 | &p->su); | |
d62a17ae | 12894 | else /* Configured IP address. */ |
12895 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12896 | p->host); | |
12897 | } | |
12898 | ||
12899 | if (use_json) { | |
12900 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12901 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12902 | "none"); | |
12903 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
47e12884 DA |
12904 | json_object_string_addf(json_neigh, "bgpNeighborAddr", |
12905 | "%pSU", &p->su); | |
d62a17ae | 12906 | |
12907 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12908 | ||
12909 | if (p->change_local_as) | |
12910 | json_object_int_add(json_neigh, "localAs", | |
12911 | p->change_local_as); | |
12912 | else | |
12913 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12914 | ||
12915 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12916 | json_object_boolean_true_add(json_neigh, | |
12917 | "localAsNoPrepend"); | |
12918 | ||
12919 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12920 | json_object_boolean_true_add(json_neigh, | |
12921 | "localAsReplaceAs"); | |
12922 | } else { | |
12923 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12924 | || (p->as_type == AS_INTERNAL)) | |
12925 | vty_out(vty, "remote AS %u, ", p->as); | |
12926 | else | |
12927 | vty_out(vty, "remote AS Unspecified, "); | |
12928 | vty_out(vty, "local AS %u%s%s, ", | |
12929 | p->change_local_as ? p->change_local_as : p->local_as, | |
12930 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12931 | ? " no-prepend" | |
12932 | : "", | |
12933 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12934 | ? " replace-as" | |
12935 | : ""); | |
12936 | } | |
faa16034 DS |
12937 | /* peer type internal or confed-internal */ |
12938 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12939 | if (use_json) { |
12940 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12941 | json_object_boolean_true_add( | |
12942 | json_neigh, "nbrConfedInternalLink"); | |
12943 | else | |
12944 | json_object_boolean_true_add(json_neigh, | |
12945 | "nbrInternalLink"); | |
12946 | } else { | |
12947 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12948 | vty_out(vty, "confed-internal link\n"); | |
12949 | else | |
12950 | vty_out(vty, "internal link\n"); | |
12951 | } | |
faa16034 DS |
12952 | /* peer type external or confed-external */ |
12953 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12954 | if (use_json) { |
12955 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12956 | json_object_boolean_true_add( | |
12957 | json_neigh, "nbrConfedExternalLink"); | |
12958 | else | |
12959 | json_object_boolean_true_add(json_neigh, | |
12960 | "nbrExternalLink"); | |
12961 | } else { | |
12962 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12963 | vty_out(vty, "confed-external link\n"); | |
12964 | else | |
12965 | vty_out(vty, "external link\n"); | |
12966 | } | |
faa16034 DS |
12967 | } else { |
12968 | if (use_json) | |
12969 | json_object_boolean_true_add(json_neigh, | |
12970 | "nbrUnspecifiedLink"); | |
12971 | else | |
12972 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12973 | } |
12974 | ||
d864dd9e EB |
12975 | /* Roles */ |
12976 | if (use_json) { | |
12977 | json_object_string_add(json_neigh, "localRole", | |
8f2d6021 EB |
12978 | bgp_get_name_by_role(p->local_role)); |
12979 | json_object_string_add(json_neigh, "remoteRole", | |
12980 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
12981 | } else { |
12982 | vty_out(vty, " Local Role: %s\n", | |
8f2d6021 EB |
12983 | bgp_get_name_by_role(p->local_role)); |
12984 | vty_out(vty, " Remote Role: %s\n", | |
12985 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
12986 | } |
12987 | ||
12988 | ||
d62a17ae | 12989 | /* Description. */ |
12990 | if (p->desc) { | |
12991 | if (use_json) | |
12992 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12993 | else | |
12994 | vty_out(vty, " Description: %s\n", p->desc); | |
12995 | } | |
12996 | ||
12997 | if (p->hostname) { | |
12998 | if (use_json) { | |
432e7e46 KQ |
12999 | json_object_string_add(json_neigh, "hostname", |
13000 | p->hostname); | |
d62a17ae | 13001 | |
13002 | if (p->domainname) | |
13003 | json_object_string_add(json_neigh, "domainname", | |
13004 | p->domainname); | |
13005 | } else { | |
13006 | if (p->domainname && (p->domainname[0] != '\0')) | |
13007 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
13008 | p->domainname); | |
13009 | else | |
13010 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
13011 | } | |
432e7e46 KQ |
13012 | } else { |
13013 | if (use_json) | |
13014 | json_object_string_add(json_neigh, "hostname", | |
13015 | "Unknown"); | |
d62a17ae | 13016 | } |
13017 | ||
13018 | /* Peer-group */ | |
13019 | if (p->group) { | |
13020 | if (use_json) { | |
13021 | json_object_string_add(json_neigh, "peerGroup", | |
13022 | p->group->name); | |
13023 | ||
13024 | if (dn_flag[0]) { | |
13025 | struct prefix prefix, *range = NULL; | |
13026 | ||
0154d8ce DS |
13027 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13028 | range = peer_group_lookup_dynamic_neighbor_range( | |
13029 | p->group, &prefix); | |
d62a17ae | 13030 | |
13031 | if (range) { | |
67d7e256 | 13032 | json_object_string_addf( |
d62a17ae | 13033 | json_neigh, |
67d7e256 DA |
13034 | "peerSubnetRangeGroup", "%pFX", |
13035 | range); | |
d62a17ae | 13036 | } |
13037 | } | |
13038 | } else { | |
13039 | vty_out(vty, | |
13040 | " Member of peer-group %s for session parameters\n", | |
13041 | p->group->name); | |
13042 | ||
13043 | if (dn_flag[0]) { | |
13044 | struct prefix prefix, *range = NULL; | |
13045 | ||
0154d8ce DS |
13046 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13047 | range = peer_group_lookup_dynamic_neighbor_range( | |
13048 | p->group, &prefix); | |
d62a17ae | 13049 | |
13050 | if (range) { | |
d62a17ae | 13051 | vty_out(vty, |
1b78780b DL |
13052 | " Belongs to the subnet range group: %pFX\n", |
13053 | range); | |
d62a17ae | 13054 | } |
13055 | } | |
13056 | } | |
13057 | } | |
13058 | ||
13059 | if (use_json) { | |
13060 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13061 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13062 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13063 | json_object_boolean_true_add(json_neigh, |
13064 | "adminShutDown"); | |
13065 | ||
13066 | /* BGP Version. */ | |
13067 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
c949c771 DA |
13068 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", |
13069 | &p->remote_id); | |
13070 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
13071 | &bgp->router_id); | |
d62a17ae | 13072 | |
13073 | /* Confederation */ | |
13074 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13075 | && bgp_confederation_peers_check(bgp, p->as)) | |
13076 | json_object_boolean_true_add(json_neigh, | |
13077 | "nbrCommonAdmin"); | |
13078 | ||
13079 | /* Status. */ | |
13080 | json_object_string_add( | |
13081 | json_neigh, "bgpState", | |
13082 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13083 | ||
feb17238 | 13084 | if (peer_established(p)) { |
d62a17ae | 13085 | time_t uptime; |
d62a17ae | 13086 | |
083ec940 | 13087 | uptime = monotime(NULL); |
d62a17ae | 13088 | uptime -= p->uptime; |
d62a17ae | 13089 | epoch_tbuf = time(NULL) - uptime; |
13090 | ||
d3c7efed DS |
13091 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
13092 | uptime * 1000); | |
d62a17ae | 13093 | json_object_string_add(json_neigh, "bgpTimerUpString", |
13094 | peer_uptime(p->uptime, timebuf, | |
13095 | BGP_UPTIME_LEN, 0, | |
13096 | NULL)); | |
13097 | json_object_int_add(json_neigh, | |
13098 | "bgpTimerUpEstablishedEpoch", | |
13099 | epoch_tbuf); | |
13100 | } | |
13101 | ||
13102 | else if (p->status == Active) { | |
13103 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13104 | json_object_string_add(json_neigh, "bgpStateIs", | |
13105 | "passive"); | |
13106 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13107 | json_object_string_add(json_neigh, "bgpStateIs", | |
13108 | "passiveNSF"); | |
13109 | } | |
13110 | ||
13111 | /* read timer */ | |
13112 | time_t uptime; | |
a2700b50 | 13113 | struct tm tm; |
d62a17ae | 13114 | |
083ec940 | 13115 | uptime = monotime(NULL); |
d62a17ae | 13116 | uptime -= p->readtime; |
a2700b50 MS |
13117 | gmtime_r(&uptime, &tm); |
13118 | ||
d62a17ae | 13119 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
13120 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13121 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13122 | |
083ec940 | 13123 | uptime = monotime(NULL); |
d62a17ae | 13124 | uptime -= p->last_write; |
a2700b50 MS |
13125 | gmtime_r(&uptime, &tm); |
13126 | ||
d62a17ae | 13127 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
13128 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13129 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13130 | |
083ec940 | 13131 | uptime = monotime(NULL); |
d62a17ae | 13132 | uptime -= p->update_time; |
a2700b50 MS |
13133 | gmtime_r(&uptime, &tm); |
13134 | ||
d62a17ae | 13135 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
13136 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13137 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13138 | |
13139 | /* Configured timer values. */ | |
9b1b9623 TA |
13140 | json_object_int_add(json_neigh, |
13141 | "bgpTimerConfiguredHoldTimeMsecs", | |
e93d5c29 TA |
13142 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13143 | ? p->holdtime * 1000 | |
13144 | : bgp->default_holdtime * 1000); | |
13145 | json_object_int_add(json_neigh, | |
13146 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
13147 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13148 | ? p->keepalive * 1000 | |
13149 | : bgp->default_keepalive * 1000); | |
d62a17ae | 13150 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", |
13151 | p->v_holdtime * 1000); | |
13152 | json_object_int_add(json_neigh, | |
13153 | "bgpTimerKeepAliveIntervalMsecs", | |
13154 | p->v_keepalive * 1000); | |
d43114f3 DS |
13155 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
13156 | json_object_int_add(json_neigh, | |
13157 | "bgpTimerDelayOpenTimeMsecs", | |
13158 | p->v_delayopen * 1000); | |
13159 | } | |
13160 | ||
4ab46701 AR |
13161 | /* Configured and Synced tcp-mss value for peer */ |
13162 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13163 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13164 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
13165 | p->tcp_mss); | |
13166 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
13167 | sync_tcp_mss); | |
13168 | } | |
13169 | ||
d08c0c80 DA |
13170 | /* Extended Optional Parameters Length for BGP OPEN Message */ |
13171 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13172 | json_object_boolean_true_add( | |
13173 | json_neigh, "extendedOptionalParametersLength"); | |
13174 | else | |
13175 | json_object_boolean_false_add( | |
13176 | json_neigh, "extendedOptionalParametersLength"); | |
6e37924b DA |
13177 | |
13178 | /* Conditional advertisements */ | |
13179 | json_object_int_add( | |
13180 | json_neigh, | |
13181 | "bgpTimerConfiguredConditionalAdvertisementsSec", | |
13182 | bgp->condition_check_period); | |
13183 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13184 | json_object_int_add( | |
13185 | json_neigh, | |
13186 | "bgpTimerUntilConditionalAdvertisementsSec", | |
13187 | thread_timer_remain_second( | |
13188 | bgp->t_condition_check)); | |
d62a17ae | 13189 | } else { |
13190 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13191 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13192 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13193 | vty_out(vty, " Administratively shut down\n"); |
13194 | ||
13195 | /* BGP Version. */ | |
13196 | vty_out(vty, " BGP version 4"); | |
07380148 DA |
13197 | vty_out(vty, ", remote router ID %pI4", &p->remote_id); |
13198 | vty_out(vty, ", local router ID %pI4\n", &bgp->router_id); | |
d62a17ae | 13199 | |
13200 | /* Confederation */ | |
13201 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13202 | && bgp_confederation_peers_check(bgp, p->as)) | |
13203 | vty_out(vty, | |
13204 | " Neighbor under common administration\n"); | |
13205 | ||
13206 | /* Status. */ | |
13207 | vty_out(vty, " BGP state = %s", | |
13208 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13209 | ||
feb17238 | 13210 | if (peer_established(p)) |
d62a17ae | 13211 | vty_out(vty, ", up for %8s", |
13212 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
13213 | 0, NULL)); | |
13214 | ||
13215 | else if (p->status == Active) { | |
13216 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13217 | vty_out(vty, " (passive)"); | |
13218 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13219 | vty_out(vty, " (NSF passive)"); | |
13220 | } | |
13221 | vty_out(vty, "\n"); | |
13222 | ||
13223 | /* read timer */ | |
13224 | vty_out(vty, " Last read %s", | |
13225 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
13226 | NULL)); | |
13227 | vty_out(vty, ", Last write %s\n", | |
13228 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
13229 | NULL)); | |
13230 | ||
13231 | /* Configured timer values. */ | |
13232 | vty_out(vty, | |
e93d5c29 | 13233 | " Hold time is %d seconds, keepalive interval is %d seconds\n", |
d62a17ae | 13234 | p->v_holdtime, p->v_keepalive); |
e93d5c29 TA |
13235 | vty_out(vty, " Configured hold time is %d seconds", |
13236 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13237 | ? p->holdtime | |
13238 | : bgp->default_holdtime); | |
9b1b9623 | 13239 | vty_out(vty, ", keepalive interval is %d seconds\n", |
e93d5c29 TA |
13240 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13241 | ? p->keepalive | |
13242 | : bgp->default_keepalive); | |
d43114f3 DS |
13243 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
13244 | vty_out(vty, | |
13245 | " Configured DelayOpenTime is %d seconds\n", | |
13246 | p->delayopen); | |
4ab46701 AR |
13247 | |
13248 | /* Configured and synced tcp-mss value for peer */ | |
13249 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13250 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13251 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
13252 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
13253 | } | |
d08c0c80 DA |
13254 | |
13255 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
13256 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13257 | vty_out(vty, | |
13258 | " Extended Optional Parameters Length is enabled\n"); | |
6e37924b DA |
13259 | |
13260 | /* Conditional advertisements */ | |
13261 | vty_out(vty, | |
13262 | " Configured conditional advertisements interval is %d seconds\n", | |
13263 | bgp->condition_check_period); | |
13264 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13265 | vty_out(vty, | |
13266 | " Time until conditional advertisements begin is %lu seconds\n", | |
13267 | thread_timer_remain_second( | |
13268 | bgp->t_condition_check)); | |
d62a17ae | 13269 | } |
13270 | /* Capability. */ | |
10711563 DA |
13271 | if (peer_established(p) && |
13272 | (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) { | |
13273 | if (use_json) { | |
13274 | json_object *json_cap = NULL; | |
d62a17ae | 13275 | |
10711563 | 13276 | json_cap = json_object_new_object(); |
d62a17ae | 13277 | |
10711563 DA |
13278 | /* AS4 */ |
13279 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13280 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13281 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) && | |
13282 | CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
ef56aee4 | 13283 | json_object_string_add( |
10711563 | 13284 | json_cap, "4byteAs", |
ef56aee4 | 13285 | "advertisedAndReceived"); |
10711563 DA |
13286 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) |
13287 | json_object_string_add(json_cap, | |
13288 | "4byteAs", | |
13289 | "advertised"); | |
13290 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13291 | json_object_string_add(json_cap, | |
13292 | "4byteAs", | |
13293 | "received"); | |
13294 | } | |
ef56aee4 | 13295 | |
10711563 DA |
13296 | /* Extended Message Support */ |
13297 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV) && | |
13298 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13299 | json_object_string_add(json_cap, | |
13300 | "extendedMessage", | |
13301 | "advertisedAndReceived"); | |
13302 | else if (CHECK_FLAG(p->cap, | |
13303 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13304 | json_object_string_add(json_cap, | |
13305 | "extendedMessage", | |
13306 | "advertised"); | |
13307 | else if (CHECK_FLAG(p->cap, | |
13308 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13309 | json_object_string_add(json_cap, | |
13310 | "extendedMessage", | |
13311 | "received"); | |
ef56aee4 | 13312 | |
10711563 DA |
13313 | /* AddPath */ |
13314 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13315 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13316 | json_object *json_add = NULL; | |
13317 | const char *print_store; | |
d62a17ae | 13318 | |
10711563 | 13319 | json_add = json_object_new_object(); |
d62a17ae | 13320 | |
10711563 DA |
13321 | FOREACH_AFI_SAFI (afi, safi) { |
13322 | json_object *json_sub = NULL; | |
13323 | json_sub = json_object_new_object(); | |
13324 | print_store = get_afi_safi_str( | |
13325 | afi, safi, true); | |
d62a17ae | 13326 | |
10711563 DA |
13327 | if (CHECK_FLAG( |
13328 | p->af_cap[afi][safi], | |
13329 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13330 | CHECK_FLAG( | |
13331 | p->af_cap[afi][safi], | |
13332 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
05c7a1cc QY |
13333 | if (CHECK_FLAG( |
13334 | p->af_cap[afi] | |
13335 | [safi], | |
10711563 DA |
13336 | PEER_CAP_ADDPATH_AF_TX_ADV) && |
13337 | CHECK_FLAG( | |
05c7a1cc QY |
13338 | p->af_cap[afi] |
13339 | [safi], | |
10711563 DA |
13340 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
13341 | json_object_boolean_true_add( | |
13342 | json_sub, | |
13343 | "txAdvertisedAndReceived"); | |
13344 | else if ( | |
13345 | CHECK_FLAG( | |
13346 | p->af_cap[afi] | |
13347 | [safi], | |
13348 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13349 | json_object_boolean_true_add( | |
13350 | json_sub, | |
13351 | "txAdvertised"); | |
13352 | else if ( | |
13353 | CHECK_FLAG( | |
13354 | p->af_cap[afi] | |
13355 | [safi], | |
13356 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13357 | json_object_boolean_true_add( | |
13358 | json_sub, | |
13359 | "txReceived"); | |
13360 | } | |
d62a17ae | 13361 | |
10711563 DA |
13362 | if (CHECK_FLAG( |
13363 | p->af_cap[afi][safi], | |
13364 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13365 | CHECK_FLAG( | |
13366 | p->af_cap[afi][safi], | |
13367 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
05c7a1cc QY |
13368 | if (CHECK_FLAG( |
13369 | p->af_cap[afi] | |
13370 | [safi], | |
10711563 DA |
13371 | PEER_CAP_ADDPATH_AF_RX_ADV) && |
13372 | CHECK_FLAG( | |
13373 | p->af_cap[afi] | |
13374 | [safi], | |
13375 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13376 | json_object_boolean_true_add( | |
13377 | json_sub, | |
13378 | "rxAdvertisedAndReceived"); | |
13379 | else if ( | |
13380 | CHECK_FLAG( | |
13381 | p->af_cap[afi] | |
13382 | [safi], | |
13383 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
13384 | json_object_boolean_true_add( | |
13385 | json_sub, | |
13386 | "rxAdvertised"); | |
13387 | else if ( | |
13388 | CHECK_FLAG( | |
13389 | p->af_cap[afi] | |
13390 | [safi], | |
13391 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13392 | json_object_boolean_true_add( | |
13393 | json_sub, | |
13394 | "rxReceived"); | |
05c7a1cc QY |
13395 | } |
13396 | ||
10711563 DA |
13397 | if (CHECK_FLAG( |
13398 | p->af_cap[afi][safi], | |
13399 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13400 | CHECK_FLAG( | |
13401 | p->af_cap[afi][safi], | |
13402 | PEER_CAP_ADDPATH_AF_TX_RCV) || | |
13403 | CHECK_FLAG( | |
13404 | p->af_cap[afi][safi], | |
13405 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13406 | CHECK_FLAG( | |
13407 | p->af_cap[afi][safi], | |
13408 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13409 | json_object_object_add( | |
13410 | json_add, print_store, | |
13411 | json_sub); | |
13412 | else | |
13413 | json_object_free(json_sub); | |
d62a17ae | 13414 | } |
13415 | ||
10711563 DA |
13416 | json_object_object_add(json_cap, "addPath", |
13417 | json_add); | |
13418 | } | |
d62a17ae | 13419 | |
10711563 DA |
13420 | /* Dynamic */ |
13421 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13422 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13423 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV) && | |
13424 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13425 | json_object_string_add( | |
13426 | json_cap, "dynamic", | |
13427 | "advertisedAndReceived"); | |
13428 | else if (CHECK_FLAG(p->cap, | |
13429 | PEER_CAP_DYNAMIC_ADV)) | |
13430 | json_object_string_add(json_cap, | |
13431 | "dynamic", | |
13432 | "advertised"); | |
13433 | else if (CHECK_FLAG(p->cap, | |
13434 | PEER_CAP_DYNAMIC_RCV)) | |
13435 | json_object_string_add(json_cap, | |
13436 | "dynamic", | |
13437 | "received"); | |
13438 | } | |
d62a17ae | 13439 | |
d864dd9e EB |
13440 | /* Role */ |
13441 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
13442 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
13443 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV) && | |
13444 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13445 | json_object_string_add( | |
13446 | json_cap, "role", | |
13447 | "advertisedAndReceived"); | |
13448 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
13449 | json_object_string_add(json_cap, "role", | |
13450 | "advertised"); | |
13451 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13452 | json_object_string_add(json_cap, "role", | |
13453 | "received"); | |
13454 | } | |
13455 | ||
10711563 DA |
13456 | /* Extended nexthop */ |
13457 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13458 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13459 | json_object *json_nxt = NULL; | |
13460 | const char *print_store; | |
d62a17ae | 13461 | |
d62a17ae | 13462 | |
10711563 DA |
13463 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV) && |
13464 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13465 | json_object_string_add( | |
13466 | json_cap, "extendedNexthop", | |
13467 | "advertisedAndReceived"); | |
13468 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13469 | json_object_string_add( | |
13470 | json_cap, "extendedNexthop", | |
13471 | "advertised"); | |
13472 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13473 | json_object_string_add( | |
13474 | json_cap, "extendedNexthop", | |
13475 | "received"); | |
d62a17ae | 13476 | |
10711563 DA |
13477 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
13478 | json_nxt = json_object_new_object(); | |
d62a17ae | 13479 | |
10711563 DA |
13480 | for (safi = SAFI_UNICAST; |
13481 | safi < SAFI_MAX; safi++) { | |
13482 | if (CHECK_FLAG( | |
13483 | p->af_cap[AFI_IP] | |
13484 | [safi], | |
13485 | PEER_CAP_ENHE_AF_RCV)) { | |
13486 | print_store = | |
13487 | get_afi_safi_str( | |
d62a17ae | 13488 | AFI_IP, |
10711563 DA |
13489 | safi, |
13490 | true); | |
13491 | json_object_string_add( | |
13492 | json_nxt, | |
13493 | print_store, | |
13494 | "recieved"); /* misspelled for compatibility */ | |
d62a17ae | 13495 | } |
d62a17ae | 13496 | } |
10711563 DA |
13497 | json_object_object_add( |
13498 | json_cap, | |
13499 | "extendedNexthopFamililesByPeer", | |
13500 | json_nxt); | |
d62a17ae | 13501 | } |
10711563 | 13502 | } |
d62a17ae | 13503 | |
10711563 DA |
13504 | /* Long-lived Graceful Restart */ |
13505 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13506 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13507 | json_object *json_llgr = NULL; | |
13508 | const char *afi_safi_str; | |
8606be87 | 13509 | |
10711563 DA |
13510 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV) && |
13511 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13512 | json_object_string_add( | |
13513 | json_cap, | |
13514 | "longLivedGracefulRestart", | |
13515 | "advertisedAndReceived"); | |
13516 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13517 | json_object_string_add( | |
13518 | json_cap, | |
13519 | "longLivedGracefulRestart", | |
13520 | "advertised"); | |
13521 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13522 | json_object_string_add( | |
13523 | json_cap, | |
13524 | "longLivedGracefulRestart", | |
13525 | "received"); | |
8606be87 | 13526 | |
10711563 DA |
13527 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
13528 | json_llgr = json_object_new_object(); | |
8606be87 | 13529 | |
10711563 DA |
13530 | FOREACH_AFI_SAFI (afi, safi) { |
13531 | if (CHECK_FLAG( | |
13532 | p->af_cap[afi] | |
13533 | [safi], | |
13534 | PEER_CAP_ENHE_AF_RCV)) { | |
13535 | afi_safi_str = | |
13536 | get_afi_safi_str( | |
8606be87 DA |
13537 | afi, |
13538 | safi, | |
13539 | true); | |
10711563 DA |
13540 | json_object_string_add( |
13541 | json_llgr, | |
13542 | afi_safi_str, | |
13543 | "received"); | |
8606be87 | 13544 | } |
8606be87 | 13545 | } |
10711563 DA |
13546 | json_object_object_add( |
13547 | json_cap, | |
13548 | "longLivedGracefulRestartByPeer", | |
13549 | json_llgr); | |
8606be87 | 13550 | } |
10711563 | 13551 | } |
8606be87 | 13552 | |
10711563 DA |
13553 | /* Route Refresh */ |
13554 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13555 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13556 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13557 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && | |
13558 | (CHECK_FLAG(p->cap, | |
13559 | PEER_CAP_REFRESH_NEW_RCV) || | |
13560 | CHECK_FLAG(p->cap, | |
13561 | PEER_CAP_REFRESH_OLD_RCV))) { | |
13562 | if (CHECK_FLAG( | |
13563 | p->cap, | |
13564 | PEER_CAP_REFRESH_OLD_RCV) && | |
13565 | CHECK_FLAG( | |
13566 | p->cap, | |
13567 | PEER_CAP_REFRESH_NEW_RCV)) | |
13568 | json_object_string_add( | |
13569 | json_cap, | |
13570 | "routeRefresh", | |
13571 | "advertisedAndReceivedOldNew"); | |
13572 | else { | |
d62a17ae | 13573 | if (CHECK_FLAG( |
13574 | p->cap, | |
10711563 | 13575 | PEER_CAP_REFRESH_OLD_RCV)) |
d62a17ae | 13576 | json_object_string_add( |
13577 | json_cap, | |
13578 | "routeRefresh", | |
10711563 DA |
13579 | "advertisedAndReceivedOld"); |
13580 | else | |
13581 | json_object_string_add( | |
13582 | json_cap, | |
13583 | "routeRefresh", | |
13584 | "advertisedAndReceivedNew"); | |
d62a17ae | 13585 | } |
10711563 DA |
13586 | } else if (CHECK_FLAG(p->cap, |
13587 | PEER_CAP_REFRESH_ADV)) | |
13588 | json_object_string_add(json_cap, | |
13589 | "routeRefresh", | |
13590 | "advertised"); | |
13591 | else if (CHECK_FLAG(p->cap, | |
13592 | PEER_CAP_REFRESH_NEW_RCV) || | |
13593 | CHECK_FLAG(p->cap, | |
13594 | PEER_CAP_REFRESH_OLD_RCV)) | |
13595 | json_object_string_add(json_cap, | |
13596 | "routeRefresh", | |
13597 | "received"); | |
13598 | } | |
d62a17ae | 13599 | |
10711563 DA |
13600 | /* Enhanced Route Refresh */ |
13601 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13602 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13603 | if (CHECK_FLAG(p->cap, | |
13604 | PEER_CAP_ENHANCED_RR_ADV) && | |
13605 | CHECK_FLAG(p->cap, | |
13606 | PEER_CAP_ENHANCED_RR_RCV)) | |
d77114b7 | 13607 | json_object_string_add( |
10711563 DA |
13608 | json_cap, |
13609 | "enhancedRouteRefresh", | |
13610 | "advertisedAndReceived"); | |
13611 | else if (CHECK_FLAG(p->cap, | |
13612 | PEER_CAP_ENHANCED_RR_ADV)) | |
d77114b7 | 13613 | json_object_string_add( |
10711563 DA |
13614 | json_cap, |
13615 | "enhancedRouteRefresh", | |
13616 | "advertised"); | |
13617 | else if (CHECK_FLAG(p->cap, | |
9af52ccf | 13618 | PEER_CAP_ENHANCED_RR_RCV)) |
10711563 DA |
13619 | json_object_string_add( |
13620 | json_cap, | |
13621 | "enhancedRouteRefresh", | |
13622 | "received"); | |
13623 | } | |
d77114b7 | 13624 | |
10711563 DA |
13625 | /* Multiprotocol Extensions */ |
13626 | json_object *json_multi = NULL; | |
d77114b7 | 13627 | |
10711563 | 13628 | json_multi = json_object_new_object(); |
d77114b7 | 13629 | |
10711563 DA |
13630 | FOREACH_AFI_SAFI (afi, safi) { |
13631 | if (p->afc_adv[afi][safi] || | |
13632 | p->afc_recv[afi][safi]) { | |
13633 | json_object *json_exten = NULL; | |
13634 | json_exten = json_object_new_object(); | |
13635 | ||
13636 | if (p->afc_adv[afi][safi] && | |
13637 | p->afc_recv[afi][safi]) | |
13638 | json_object_boolean_true_add( | |
13639 | json_exten, | |
9af52ccf | 13640 | "advertisedAndReceived"); |
10711563 DA |
13641 | else if (p->afc_adv[afi][safi]) |
13642 | json_object_boolean_true_add( | |
13643 | json_exten, | |
9af52ccf | 13644 | "advertised"); |
10711563 DA |
13645 | else if (p->afc_recv[afi][safi]) |
13646 | json_object_boolean_true_add( | |
13647 | json_exten, "received"); | |
9af52ccf | 13648 | |
10711563 DA |
13649 | json_object_object_add( |
13650 | json_multi, | |
13651 | get_afi_safi_str(afi, safi, | |
13652 | true), | |
13653 | json_exten); | |
13654 | } | |
13655 | } | |
13656 | json_object_object_add(json_cap, | |
13657 | "multiprotocolExtensions", | |
13658 | json_multi); | |
d62a17ae | 13659 | |
10711563 DA |
13660 | /* Hostname capabilities */ |
13661 | json_object *json_hname = NULL; | |
d62a17ae | 13662 | |
10711563 | 13663 | json_hname = json_object_new_object(); |
d62a17ae | 13664 | |
10711563 DA |
13665 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
13666 | json_object_string_add( | |
13667 | json_hname, "advHostName", | |
13668 | bgp->peer_self->hostname | |
13669 | ? bgp->peer_self->hostname | |
13670 | : "n/a"); | |
13671 | json_object_string_add( | |
13672 | json_hname, "advDomainName", | |
13673 | bgp->peer_self->domainname | |
13674 | ? bgp->peer_self->domainname | |
13675 | : "n/a"); | |
13676 | } | |
d77114b7 | 13677 | |
d77114b7 | 13678 | |
10711563 DA |
13679 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13680 | json_object_string_add( | |
13681 | json_hname, "rcvHostName", | |
13682 | p->hostname ? p->hostname : "n/a"); | |
13683 | json_object_string_add( | |
13684 | json_hname, "rcvDomainName", | |
13685 | p->domainname ? p->domainname : "n/a"); | |
13686 | } | |
d77114b7 | 13687 | |
10711563 DA |
13688 | json_object_object_add(json_cap, "hostName", |
13689 | json_hname); | |
d77114b7 | 13690 | |
17be83bf | 13691 | /* Graceful Restart */ |
10711563 DA |
13692 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || |
13693 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13694 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
13695 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
d77114b7 | 13696 | json_object_string_add( |
10711563 DA |
13697 | json_cap, "gracefulRestart", |
13698 | "advertisedAndReceived"); | |
13699 | else if (CHECK_FLAG(p->cap, | |
13700 | PEER_CAP_RESTART_ADV)) | |
d77114b7 | 13701 | json_object_string_add( |
10711563 DA |
13702 | json_cap, |
13703 | "gracefulRestartCapability", | |
13704 | "advertised"); | |
13705 | else if (CHECK_FLAG(p->cap, | |
13706 | PEER_CAP_RESTART_RCV)) | |
13707 | json_object_string_add( | |
13708 | json_cap, | |
13709 | "gracefulRestartCapability", | |
13710 | "received"); | |
d77114b7 | 13711 | |
10711563 DA |
13712 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13713 | int restart_af_count = 0; | |
13714 | json_object *json_restart = NULL; | |
13715 | json_restart = json_object_new_object(); | |
d62a17ae | 13716 | |
10711563 DA |
13717 | json_object_int_add( |
13718 | json_cap, | |
13719 | "gracefulRestartRemoteTimerMsecs", | |
13720 | p->v_gr_restart * 1000); | |
d62a17ae | 13721 | |
10711563 | 13722 | FOREACH_AFI_SAFI (afi, safi) { |
05c7a1cc QY |
13723 | if (CHECK_FLAG( |
13724 | p->af_cap[afi] | |
13725 | [safi], | |
10711563 DA |
13726 | PEER_CAP_RESTART_AF_RCV)) { |
13727 | json_object *json_sub = | |
13728 | NULL; | |
13729 | json_sub = | |
13730 | json_object_new_object(); | |
d62a17ae | 13731 | |
05c7a1cc QY |
13732 | if (CHECK_FLAG( |
13733 | p->af_cap | |
13734 | [afi] | |
13735 | [safi], | |
10711563 DA |
13736 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13737 | json_object_boolean_true_add( | |
13738 | json_sub, | |
13739 | "preserved"); | |
13740 | restart_af_count++; | |
d62a17ae | 13741 | json_object_object_add( |
10711563 DA |
13742 | json_restart, |
13743 | get_afi_safi_str( | |
13744 | afi, | |
13745 | safi, | |
13746 | true), | |
13747 | json_sub); | |
d62a17ae | 13748 | } |
d62a17ae | 13749 | } |
10711563 DA |
13750 | if (!restart_af_count) { |
13751 | json_object_string_add( | |
13752 | json_cap, | |
13753 | "addressFamiliesByPeer", | |
13754 | "none"); | |
13755 | json_object_free(json_restart); | |
13756 | } else | |
13757 | json_object_object_add( | |
13758 | json_cap, | |
13759 | "addressFamiliesByPeer", | |
13760 | json_restart); | |
d62a17ae | 13761 | } |
10711563 DA |
13762 | } |
13763 | json_object_object_add( | |
13764 | json_neigh, "neighborCapabilities", json_cap); | |
13765 | } else { | |
13766 | vty_out(vty, " Neighbor capabilities:\n"); | |
13767 | ||
13768 | /* AS4 */ | |
13769 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13770 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13771 | vty_out(vty, " 4 Byte AS:"); | |
13772 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
13773 | vty_out(vty, " advertised"); | |
13774 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13775 | vty_out(vty, " %sreceived", | |
13776 | CHECK_FLAG(p->cap, | |
13777 | PEER_CAP_AS4_ADV) | |
13778 | ? "and " | |
13779 | : ""); | |
13780 | vty_out(vty, "\n"); | |
13781 | } | |
d62a17ae | 13782 | |
10711563 DA |
13783 | /* Extended Message Support */ |
13784 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) || | |
13785 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13786 | vty_out(vty, " Extended Message:"); | |
ef56aee4 | 13787 | if (CHECK_FLAG(p->cap, |
10711563 DA |
13788 | PEER_CAP_EXTENDED_MESSAGE_ADV)) |
13789 | vty_out(vty, " advertised"); | |
13790 | if (CHECK_FLAG(p->cap, | |
13791 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13792 | vty_out(vty, " %sreceived", | |
13793 | CHECK_FLAG( | |
13794 | p->cap, | |
13795 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13796 | ? "and " | |
13797 | : ""); | |
13798 | vty_out(vty, "\n"); | |
13799 | } | |
d62a17ae | 13800 | |
10711563 DA |
13801 | /* AddPath */ |
13802 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13803 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13804 | vty_out(vty, " AddPath:\n"); | |
d62a17ae | 13805 | |
10711563 | 13806 | FOREACH_AFI_SAFI (afi, safi) { |
ef56aee4 | 13807 | if (CHECK_FLAG( |
10711563 DA |
13808 | p->af_cap[afi][safi], |
13809 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13810 | CHECK_FLAG( | |
13811 | p->af_cap[afi][safi], | |
13812 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13813 | vty_out(vty, " %s: TX ", | |
13814 | get_afi_safi_str( | |
13815 | afi, safi, | |
13816 | false)); | |
ef56aee4 | 13817 | |
10711563 DA |
13818 | if (CHECK_FLAG( |
13819 | p->af_cap[afi] | |
13820 | [safi], | |
13821 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13822 | vty_out(vty, | |
13823 | "advertised"); | |
d62a17ae | 13824 | |
05c7a1cc QY |
13825 | if (CHECK_FLAG( |
13826 | p->af_cap[afi] | |
13827 | [safi], | |
10711563 | 13828 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
05c7a1cc | 13829 | vty_out(vty, |
10711563 DA |
13830 | "%sreceived", |
13831 | CHECK_FLAG( | |
13832 | p->af_cap | |
13833 | [afi] | |
13834 | [safi], | |
13835 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13836 | ? " and " | |
13837 | : ""); | |
05c7a1cc | 13838 | |
10711563 DA |
13839 | vty_out(vty, "\n"); |
13840 | } | |
d62a17ae | 13841 | |
9af52ccf | 13842 | if (CHECK_FLAG( |
10711563 DA |
13843 | p->af_cap[afi][safi], |
13844 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13845 | CHECK_FLAG( | |
13846 | p->af_cap[afi][safi], | |
13847 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13848 | vty_out(vty, " %s: RX ", | |
5cb5f4d0 | 13849 | get_afi_safi_str( |
10711563 DA |
13850 | afi, safi, |
13851 | false)); | |
d62a17ae | 13852 | |
05c7a1cc QY |
13853 | if (CHECK_FLAG( |
13854 | p->af_cap[afi] | |
13855 | [safi], | |
10711563 | 13856 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
05c7a1cc | 13857 | vty_out(vty, |
10711563 | 13858 | "advertised"); |
d62a17ae | 13859 | |
10711563 DA |
13860 | if (CHECK_FLAG( |
13861 | p->af_cap[afi] | |
13862 | [safi], | |
13863 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc | 13864 | vty_out(vty, |
10711563 DA |
13865 | "%sreceived", |
13866 | CHECK_FLAG( | |
13867 | p->af_cap | |
13868 | [afi] | |
13869 | [safi], | |
13870 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13871 | ? " and " | |
05c7a1cc | 13872 | : ""); |
d62a17ae | 13873 | |
05c7a1cc | 13874 | vty_out(vty, "\n"); |
05c7a1cc | 13875 | } |
d62a17ae | 13876 | } |
10711563 | 13877 | } |
d62a17ae | 13878 | |
10711563 DA |
13879 | /* Dynamic */ |
13880 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13881 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13882 | vty_out(vty, " Dynamic:"); | |
13883 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) | |
13884 | vty_out(vty, " advertised"); | |
13885 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13886 | vty_out(vty, " %sreceived", | |
13887 | CHECK_FLAG(p->cap, | |
13888 | PEER_CAP_DYNAMIC_ADV) | |
13889 | ? "and " | |
13890 | : ""); | |
13891 | vty_out(vty, "\n"); | |
13892 | } | |
d62a17ae | 13893 | |
d864dd9e EB |
13894 | /* Role */ |
13895 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
13896 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
13897 | vty_out(vty, " Role:"); | |
13898 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
13899 | vty_out(vty, " advertised"); | |
13900 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13901 | vty_out(vty, " %sreceived", | |
13902 | CHECK_FLAG(p->cap, | |
13903 | PEER_CAP_ROLE_ADV) | |
13904 | ? "and " | |
13905 | : ""); | |
13906 | vty_out(vty, "\n"); | |
13907 | } | |
13908 | ||
10711563 DA |
13909 | /* Extended nexthop */ |
13910 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13911 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13912 | vty_out(vty, " Extended nexthop:"); | |
13913 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13914 | vty_out(vty, " advertised"); | |
13915 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13916 | vty_out(vty, " %sreceived", | |
13917 | CHECK_FLAG(p->cap, | |
13918 | PEER_CAP_ENHE_ADV) | |
13919 | ? "and " | |
13920 | : ""); | |
13921 | vty_out(vty, "\n"); | |
d62a17ae | 13922 | |
10711563 | 13923 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
57f7feb6 | 13924 | vty_out(vty, |
10711563 DA |
13925 | " Address families by peer:\n "); |
13926 | for (safi = SAFI_UNICAST; | |
13927 | safi < SAFI_MAX; safi++) | |
13928 | if (CHECK_FLAG( | |
13929 | p->af_cap[AFI_IP] | |
13930 | [safi], | |
13931 | PEER_CAP_ENHE_AF_RCV)) | |
13932 | vty_out(vty, | |
13933 | " %s\n", | |
13934 | get_afi_safi_str( | |
13935 | AFI_IP, | |
13936 | safi, | |
13937 | false)); | |
d62a17ae | 13938 | } |
10711563 | 13939 | } |
d62a17ae | 13940 | |
10711563 DA |
13941 | /* Long-lived Graceful Restart */ |
13942 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13943 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13944 | vty_out(vty, | |
13945 | " Long-lived Graceful Restart:"); | |
13946 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13947 | vty_out(vty, " advertised"); | |
13948 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13949 | vty_out(vty, " %sreceived", | |
13950 | CHECK_FLAG(p->cap, | |
13951 | PEER_CAP_LLGR_ADV) | |
13952 | ? "and " | |
13953 | : ""); | |
13954 | vty_out(vty, "\n"); | |
8606be87 | 13955 | |
10711563 | 13956 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
57f7feb6 | 13957 | vty_out(vty, |
10711563 DA |
13958 | " Address families by peer:\n"); |
13959 | FOREACH_AFI_SAFI (afi, safi) | |
13960 | if (CHECK_FLAG( | |
13961 | p->af_cap[afi] | |
13962 | [safi], | |
13963 | PEER_CAP_LLGR_AF_RCV)) | |
13964 | vty_out(vty, | |
13965 | " %s\n", | |
13966 | get_afi_safi_str( | |
13967 | afi, | |
13968 | safi, | |
13969 | false)); | |
8606be87 | 13970 | } |
10711563 | 13971 | } |
8606be87 | 13972 | |
10711563 DA |
13973 | /* Route Refresh */ |
13974 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13975 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13976 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13977 | vty_out(vty, " Route refresh:"); | |
13978 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV)) | |
13979 | vty_out(vty, " advertised"); | |
13980 | if (CHECK_FLAG(p->cap, | |
13981 | PEER_CAP_REFRESH_NEW_RCV) || | |
13982 | CHECK_FLAG(p->cap, | |
13983 | PEER_CAP_REFRESH_OLD_RCV)) | |
13984 | vty_out(vty, " %sreceived(%s)", | |
13985 | CHECK_FLAG(p->cap, | |
13986 | PEER_CAP_REFRESH_ADV) | |
13987 | ? "and " | |
13988 | : "", | |
13989 | (CHECK_FLAG( | |
13990 | p->cap, | |
13991 | PEER_CAP_REFRESH_OLD_RCV) && | |
13992 | CHECK_FLAG( | |
13993 | p->cap, | |
13994 | PEER_CAP_REFRESH_NEW_RCV)) | |
13995 | ? "old & new" | |
13996 | : CHECK_FLAG( | |
13997 | p->cap, | |
13998 | PEER_CAP_REFRESH_OLD_RCV) | |
13999 | ? "old" | |
14000 | : "new"); | |
d62a17ae | 14001 | |
d77114b7 | 14002 | vty_out(vty, "\n"); |
10711563 | 14003 | } |
d62a17ae | 14004 | |
10711563 DA |
14005 | /* Enhanced Route Refresh */ |
14006 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
14007 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
14008 | vty_out(vty, " Enhanced Route Refresh:"); | |
14009 | if (CHECK_FLAG(p->cap, | |
14010 | PEER_CAP_ENHANCED_RR_ADV)) | |
14011 | vty_out(vty, " advertised"); | |
14012 | if (CHECK_FLAG(p->cap, | |
14013 | PEER_CAP_ENHANCED_RR_RCV)) | |
14014 | vty_out(vty, " %sreceived", | |
14015 | CHECK_FLAG(p->cap, | |
14016 | PEER_CAP_REFRESH_ADV) | |
14017 | ? "and " | |
14018 | : ""); | |
14019 | vty_out(vty, "\n"); | |
14020 | } | |
14021 | ||
14022 | /* Multiprotocol Extensions */ | |
14023 | FOREACH_AFI_SAFI (afi, safi) | |
14024 | if (p->afc_adv[afi][safi] || | |
14025 | p->afc_recv[afi][safi]) { | |
14026 | vty_out(vty, " Address Family %s:", | |
14027 | get_afi_safi_str(afi, safi, | |
14028 | false)); | |
14029 | if (p->afc_adv[afi][safi]) | |
9af52ccf | 14030 | vty_out(vty, " advertised"); |
10711563 | 14031 | if (p->afc_recv[afi][safi]) |
9af52ccf | 14032 | vty_out(vty, " %sreceived", |
10711563 | 14033 | p->afc_adv[afi][safi] |
9af52ccf DA |
14034 | ? "and " |
14035 | : ""); | |
14036 | vty_out(vty, "\n"); | |
14037 | } | |
14038 | ||
10711563 DA |
14039 | /* Hostname capability */ |
14040 | vty_out(vty, " Hostname Capability:"); | |
d62a17ae | 14041 | |
10711563 DA |
14042 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
14043 | vty_out(vty, | |
14044 | " advertised (name: %s,domain name: %s)", | |
14045 | bgp->peer_self->hostname | |
14046 | ? bgp->peer_self->hostname | |
14047 | : "n/a", | |
14048 | bgp->peer_self->domainname | |
14049 | ? bgp->peer_self->domainname | |
14050 | : "n/a"); | |
14051 | } else { | |
14052 | vty_out(vty, " not advertised"); | |
14053 | } | |
d77114b7 | 14054 | |
10711563 DA |
14055 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
14056 | vty_out(vty, | |
14057 | " received (name: %s,domain name: %s)", | |
14058 | p->hostname ? p->hostname : "n/a", | |
14059 | p->domainname ? p->domainname : "n/a"); | |
14060 | } else { | |
14061 | vty_out(vty, " not received"); | |
d62a17ae | 14062 | } |
d62a17ae | 14063 | |
10711563 | 14064 | vty_out(vty, "\n"); |
d77114b7 | 14065 | |
10711563 DA |
14066 | /* Graceful Restart */ |
14067 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
14068 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
14069 | vty_out(vty, | |
14070 | " Graceful Restart Capability:"); | |
14071 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) | |
14072 | vty_out(vty, " advertised"); | |
14073 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
14074 | vty_out(vty, " %sreceived", | |
14075 | CHECK_FLAG(p->cap, | |
14076 | PEER_CAP_RESTART_ADV) | |
14077 | ? "and " | |
14078 | : ""); | |
d77114b7 MK |
14079 | vty_out(vty, "\n"); |
14080 | ||
10711563 DA |
14081 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
14082 | int restart_af_count = 0; | |
d62a17ae | 14083 | |
10711563 DA |
14084 | vty_out(vty, |
14085 | " Remote Restart timer is %d seconds\n", | |
14086 | p->v_gr_restart); | |
14087 | vty_out(vty, | |
14088 | " Address families by peer:\n "); | |
d62a17ae | 14089 | |
10711563 DA |
14090 | FOREACH_AFI_SAFI (afi, safi) |
14091 | if (CHECK_FLAG( | |
14092 | p->af_cap[afi] | |
14093 | [safi], | |
14094 | PEER_CAP_RESTART_AF_RCV)) { | |
14095 | vty_out(vty, "%s%s(%s)", | |
14096 | restart_af_count | |
14097 | ? ", " | |
14098 | : "", | |
14099 | get_afi_safi_str( | |
14100 | afi, | |
14101 | safi, | |
14102 | false), | |
14103 | CHECK_FLAG( | |
14104 | p->af_cap | |
14105 | [afi] | |
14106 | [safi], | |
14107 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
14108 | ? "preserved" | |
14109 | : "not preserved"); | |
14110 | restart_af_count++; | |
14111 | } | |
14112 | if (!restart_af_count) | |
14113 | vty_out(vty, "none"); | |
14114 | vty_out(vty, "\n"); | |
14115 | } | |
17be83bf | 14116 | } /* Graceful Restart */ |
d62a17ae | 14117 | } |
14118 | } | |
14119 | ||
14120 | /* graceful restart information */ | |
10711563 DA |
14121 | json_object *json_grace = NULL; |
14122 | json_object *json_grace_send = NULL; | |
14123 | json_object *json_grace_recv = NULL; | |
14124 | int eor_send_af_count = 0; | |
14125 | int eor_receive_af_count = 0; | |
d62a17ae | 14126 | |
10711563 DA |
14127 | if (use_json) { |
14128 | json_grace = json_object_new_object(); | |
14129 | json_grace_send = json_object_new_object(); | |
14130 | json_grace_recv = json_object_new_object(); | |
14131 | ||
14132 | if ((peer_established(p)) && | |
14133 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14134 | FOREACH_AFI_SAFI (afi, safi) { | |
14135 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14136 | PEER_STATUS_EOR_SEND)) { | |
14137 | json_object_boolean_true_add( | |
14138 | json_grace_send, | |
14139 | get_afi_safi_str(afi, safi, | |
14140 | true)); | |
14141 | eor_send_af_count++; | |
d62a17ae | 14142 | } |
10711563 DA |
14143 | } |
14144 | FOREACH_AFI_SAFI (afi, safi) { | |
14145 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14146 | PEER_STATUS_EOR_RECEIVED)) { | |
14147 | json_object_boolean_true_add( | |
14148 | json_grace_recv, | |
14149 | get_afi_safi_str(afi, safi, | |
14150 | true)); | |
14151 | eor_receive_af_count++; | |
d62a17ae | 14152 | } |
14153 | } | |
10711563 DA |
14154 | } |
14155 | json_object_object_add(json_grace, "endOfRibSend", | |
14156 | json_grace_send); | |
14157 | json_object_object_add(json_grace, "endOfRibRecv", | |
14158 | json_grace_recv); | |
d62a17ae | 14159 | |
d62a17ae | 14160 | |
10711563 DA |
14161 | if (p->t_gr_restart) |
14162 | json_object_int_add( | |
14163 | json_grace, "gracefulRestartTimerMsecs", | |
14164 | thread_timer_remain_second(p->t_gr_restart) * | |
14165 | 1000); | |
2986cac2 | 14166 | |
10711563 DA |
14167 | if (p->t_gr_stale) |
14168 | json_object_int_add( | |
14169 | json_grace, "gracefulStalepathTimerMsecs", | |
14170 | thread_timer_remain_second(p->t_gr_stale) * | |
14171 | 1000); | |
14172 | /* more gr info in new format */ | |
403e64f8 | 14173 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace); |
10711563 DA |
14174 | json_object_object_add(json_neigh, "gracefulRestartInfo", |
14175 | json_grace); | |
14176 | } else { | |
14177 | vty_out(vty, " Graceful restart information:\n"); | |
14178 | if ((peer_established(p)) && | |
14179 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14180 | ||
14181 | vty_out(vty, " End-of-RIB send: "); | |
14182 | FOREACH_AFI_SAFI (afi, safi) { | |
14183 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14184 | PEER_STATUS_EOR_SEND)) { | |
14185 | vty_out(vty, "%s%s", | |
14186 | eor_send_af_count ? ", " : "", | |
14187 | get_afi_safi_str(afi, safi, | |
14188 | false)); | |
14189 | eor_send_af_count++; | |
d62a17ae | 14190 | } |
10711563 DA |
14191 | } |
14192 | vty_out(vty, "\n"); | |
14193 | vty_out(vty, " End-of-RIB received: "); | |
14194 | FOREACH_AFI_SAFI (afi, safi) { | |
14195 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14196 | PEER_STATUS_EOR_RECEIVED)) { | |
14197 | vty_out(vty, "%s%s", | |
14198 | eor_receive_af_count ? ", " | |
14199 | : "", | |
14200 | get_afi_safi_str(afi, safi, | |
14201 | false)); | |
14202 | eor_receive_af_count++; | |
d62a17ae | 14203 | } |
d62a17ae | 14204 | } |
10711563 DA |
14205 | vty_out(vty, "\n"); |
14206 | } | |
d62a17ae | 14207 | |
10711563 DA |
14208 | if (p->t_gr_restart) |
14209 | vty_out(vty, | |
14210 | " The remaining time of restart timer is %ld\n", | |
14211 | thread_timer_remain_second(p->t_gr_restart)); | |
d62a17ae | 14212 | |
10711563 DA |
14213 | if (p->t_gr_stale) |
14214 | vty_out(vty, | |
14215 | " The remaining time of stalepath timer is %ld\n", | |
14216 | thread_timer_remain_second(p->t_gr_stale)); | |
2986cac2 | 14217 | |
10711563 | 14218 | /* more gr info in new format */ |
403e64f8 | 14219 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL); |
10711563 | 14220 | } |
2986cac2 | 14221 | |
d62a17ae | 14222 | if (use_json) { |
14223 | json_object *json_stat = NULL; | |
14224 | json_stat = json_object_new_object(); | |
14225 | /* Packet counts. */ | |
43aa5965 QY |
14226 | |
14227 | atomic_size_t outq_count, inq_count; | |
14228 | outq_count = atomic_load_explicit(&p->obuf->count, | |
14229 | memory_order_relaxed); | |
14230 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14231 | memory_order_relaxed); | |
14232 | ||
14233 | json_object_int_add(json_stat, "depthInq", | |
14234 | (unsigned long)inq_count); | |
d62a17ae | 14235 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 14236 | (unsigned long)outq_count); |
0112e9e0 QY |
14237 | json_object_int_add(json_stat, "opensSent", |
14238 | atomic_load_explicit(&p->open_out, | |
14239 | memory_order_relaxed)); | |
14240 | json_object_int_add(json_stat, "opensRecv", | |
14241 | atomic_load_explicit(&p->open_in, | |
14242 | memory_order_relaxed)); | |
d62a17ae | 14243 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
14244 | atomic_load_explicit(&p->notify_out, |
14245 | memory_order_relaxed)); | |
d62a17ae | 14246 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
14247 | atomic_load_explicit(&p->notify_in, |
14248 | memory_order_relaxed)); | |
14249 | json_object_int_add(json_stat, "updatesSent", | |
14250 | atomic_load_explicit(&p->update_out, | |
14251 | memory_order_relaxed)); | |
14252 | json_object_int_add(json_stat, "updatesRecv", | |
14253 | atomic_load_explicit(&p->update_in, | |
14254 | memory_order_relaxed)); | |
d62a17ae | 14255 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
14256 | atomic_load_explicit(&p->keepalive_out, |
14257 | memory_order_relaxed)); | |
d62a17ae | 14258 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
14259 | atomic_load_explicit(&p->keepalive_in, |
14260 | memory_order_relaxed)); | |
d62a17ae | 14261 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
14262 | atomic_load_explicit(&p->refresh_out, |
14263 | memory_order_relaxed)); | |
d62a17ae | 14264 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
14265 | atomic_load_explicit(&p->refresh_in, |
14266 | memory_order_relaxed)); | |
d62a17ae | 14267 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
14268 | atomic_load_explicit(&p->dynamic_cap_out, |
14269 | memory_order_relaxed)); | |
d62a17ae | 14270 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
14271 | atomic_load_explicit(&p->dynamic_cap_in, |
14272 | memory_order_relaxed)); | |
14273 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
14274 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 14275 | json_object_object_add(json_neigh, "messageStats", json_stat); |
14276 | } else { | |
cb93e0a2 IS |
14277 | atomic_size_t outq_count, inq_count, open_out, open_in, |
14278 | notify_out, notify_in, update_out, update_in, | |
14279 | keepalive_out, keepalive_in, refresh_out, refresh_in, | |
14280 | dynamic_cap_out, dynamic_cap_in; | |
43aa5965 QY |
14281 | outq_count = atomic_load_explicit(&p->obuf->count, |
14282 | memory_order_relaxed); | |
14283 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14284 | memory_order_relaxed); | |
cb93e0a2 IS |
14285 | open_out = atomic_load_explicit(&p->open_out, |
14286 | memory_order_relaxed); | |
14287 | open_in = | |
14288 | atomic_load_explicit(&p->open_in, memory_order_relaxed); | |
14289 | notify_out = atomic_load_explicit(&p->notify_out, | |
14290 | memory_order_relaxed); | |
14291 | notify_in = atomic_load_explicit(&p->notify_in, | |
14292 | memory_order_relaxed); | |
14293 | update_out = atomic_load_explicit(&p->update_out, | |
14294 | memory_order_relaxed); | |
14295 | update_in = atomic_load_explicit(&p->update_in, | |
14296 | memory_order_relaxed); | |
14297 | keepalive_out = atomic_load_explicit(&p->keepalive_out, | |
14298 | memory_order_relaxed); | |
14299 | keepalive_in = atomic_load_explicit(&p->keepalive_in, | |
14300 | memory_order_relaxed); | |
14301 | refresh_out = atomic_load_explicit(&p->refresh_out, | |
14302 | memory_order_relaxed); | |
14303 | refresh_in = atomic_load_explicit(&p->refresh_in, | |
14304 | memory_order_relaxed); | |
14305 | dynamic_cap_out = atomic_load_explicit(&p->dynamic_cap_out, | |
14306 | memory_order_relaxed); | |
14307 | dynamic_cap_in = atomic_load_explicit(&p->dynamic_cap_in, | |
14308 | memory_order_relaxed); | |
43aa5965 | 14309 | |
d62a17ae | 14310 | /* Packet counts. */ |
14311 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
14312 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
14313 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 14314 | vty_out(vty, " Sent Rcvd\n"); |
cb93e0a2 IS |
14315 | vty_out(vty, " Opens: %10zu %10zu\n", open_out, |
14316 | open_in); | |
14317 | vty_out(vty, " Notifications: %10zu %10zu\n", notify_out, | |
14318 | notify_in); | |
14319 | vty_out(vty, " Updates: %10zu %10zu\n", update_out, | |
14320 | update_in); | |
14321 | vty_out(vty, " Keepalives: %10zu %10zu\n", keepalive_out, | |
14322 | keepalive_in); | |
14323 | vty_out(vty, " Route Refresh: %10zu %10zu\n", refresh_out, | |
14324 | refresh_in); | |
14325 | vty_out(vty, " Capability: %10zu %10zu\n", | |
14326 | dynamic_cap_out, dynamic_cap_in); | |
14327 | vty_out(vty, " Total: %10u %10u\n", | |
14328 | (uint32_t)PEER_TOTAL_TX(p), (uint32_t)PEER_TOTAL_RX(p)); | |
d62a17ae | 14329 | } |
14330 | ||
14331 | if (use_json) { | |
14332 | /* advertisement-interval */ | |
14333 | json_object_int_add(json_neigh, | |
14334 | "minBtwnAdvertisementRunsTimerMsecs", | |
14335 | p->v_routeadv * 1000); | |
14336 | ||
14337 | /* Update-source. */ | |
14338 | if (p->update_if || p->update_source) { | |
14339 | if (p->update_if) | |
14340 | json_object_string_add(json_neigh, | |
14341 | "updateSource", | |
14342 | p->update_if); | |
14343 | else if (p->update_source) | |
47e12884 DA |
14344 | json_object_string_addf(json_neigh, |
14345 | "updateSource", "%pSU", | |
14346 | p->update_source); | |
d62a17ae | 14347 | } |
14348 | } else { | |
14349 | /* advertisement-interval */ | |
14350 | vty_out(vty, | |
14351 | " Minimum time between advertisement runs is %d seconds\n", | |
14352 | p->v_routeadv); | |
14353 | ||
14354 | /* Update-source. */ | |
14355 | if (p->update_if || p->update_source) { | |
14356 | vty_out(vty, " Update source is "); | |
14357 | if (p->update_if) | |
14358 | vty_out(vty, "%s", p->update_if); | |
14359 | else if (p->update_source) | |
47e12884 | 14360 | vty_out(vty, "%pSU", p->update_source); |
d62a17ae | 14361 | vty_out(vty, "\n"); |
14362 | } | |
14363 | ||
14364 | vty_out(vty, "\n"); | |
14365 | } | |
14366 | ||
14367 | /* Address Family Information */ | |
14368 | json_object *json_hold = NULL; | |
14369 | ||
14370 | if (use_json) | |
14371 | json_hold = json_object_new_object(); | |
14372 | ||
05c7a1cc QY |
14373 | FOREACH_AFI_SAFI (afi, safi) |
14374 | if (p->afc[afi][safi]) | |
14375 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
14376 | json_hold); | |
d62a17ae | 14377 | |
14378 | if (use_json) { | |
14379 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
14380 | json_hold); | |
14381 | json_object_int_add(json_neigh, "connectionsEstablished", | |
14382 | p->established); | |
14383 | json_object_int_add(json_neigh, "connectionsDropped", | |
14384 | p->dropped); | |
14385 | } else | |
14386 | vty_out(vty, " Connections established %d; dropped %d\n", | |
14387 | p->established, p->dropped); | |
14388 | ||
14389 | if (!p->last_reset) { | |
14390 | if (use_json) | |
14391 | json_object_string_add(json_neigh, "lastReset", | |
14392 | "never"); | |
14393 | else | |
14394 | vty_out(vty, " Last reset never\n"); | |
14395 | } else { | |
14396 | if (use_json) { | |
14397 | time_t uptime; | |
a2700b50 | 14398 | struct tm tm; |
d62a17ae | 14399 | |
083ec940 | 14400 | uptime = monotime(NULL); |
d62a17ae | 14401 | uptime -= p->resettime; |
a2700b50 MS |
14402 | gmtime_r(&uptime, &tm); |
14403 | ||
d62a17ae | 14404 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
14405 | (tm.tm_sec * 1000) |
14406 | + (tm.tm_min * 60000) | |
14407 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 14408 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 14409 | } else { |
14410 | vty_out(vty, " Last reset %s, ", | |
14411 | peer_uptime(p->resettime, timebuf, | |
14412 | BGP_UPTIME_LEN, 0, NULL)); | |
14413 | ||
3577f1c5 | 14414 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 14415 | if (p->last_reset_cause_size) { |
14416 | msg = p->last_reset_cause; | |
14417 | vty_out(vty, | |
14418 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
14419 | for (i = 1; i <= p->last_reset_cause_size; | |
14420 | i++) { | |
14421 | vty_out(vty, "%02X", *msg++); | |
14422 | ||
14423 | if (i != p->last_reset_cause_size) { | |
14424 | if (i % 16 == 0) { | |
14425 | vty_out(vty, "\n "); | |
14426 | } else if (i % 4 == 0) { | |
14427 | vty_out(vty, " "); | |
14428 | } | |
14429 | } | |
14430 | } | |
14431 | vty_out(vty, "\n"); | |
14432 | } | |
14433 | } | |
14434 | } | |
14435 | ||
14436 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
14437 | if (use_json) | |
14438 | json_object_boolean_true_add(json_neigh, | |
14439 | "prefixesConfigExceedMax"); | |
14440 | else | |
14441 | vty_out(vty, | |
14442 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
14443 | ||
14444 | if (p->t_pmax_restart) { | |
14445 | if (use_json) { | |
14446 | json_object_boolean_true_add( | |
14447 | json_neigh, "reducePrefixNumFrom"); | |
14448 | json_object_int_add(json_neigh, | |
14449 | "restartInTimerMsec", | |
14450 | thread_timer_remain_second( | |
14451 | p->t_pmax_restart) | |
14452 | * 1000); | |
14453 | } else | |
14454 | vty_out(vty, | |
14455 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
14456 | p->host, thread_timer_remain_second( |
14457 | p->t_pmax_restart)); | |
d62a17ae | 14458 | } else { |
14459 | if (use_json) | |
14460 | json_object_boolean_true_add( | |
14461 | json_neigh, | |
14462 | "reducePrefixNumAndClearIpBgp"); | |
14463 | else | |
14464 | vty_out(vty, | |
14465 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
14466 | p->host); | |
14467 | } | |
14468 | } | |
14469 | ||
14470 | /* EBGP Multihop and GTSM */ | |
14471 | if (p->sort != BGP_PEER_IBGP) { | |
14472 | if (use_json) { | |
e2521429 | 14473 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14474 | json_object_int_add(json_neigh, |
14475 | "externalBgpNbrMaxHopsAway", | |
14476 | p->gtsm_hops); | |
be8d1733 | 14477 | else |
d62a17ae | 14478 | json_object_int_add(json_neigh, |
14479 | "externalBgpNbrMaxHopsAway", | |
14480 | p->ttl); | |
14481 | } else { | |
e2521429 | 14482 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14483 | vty_out(vty, |
14484 | " External BGP neighbor may be up to %d hops away.\n", | |
14485 | p->gtsm_hops); | |
be8d1733 | 14486 | else |
d62a17ae | 14487 | vty_out(vty, |
14488 | " External BGP neighbor may be up to %d hops away.\n", | |
14489 | p->ttl); | |
14490 | } | |
14491 | } else { | |
be8d1733 DA |
14492 | if (use_json) { |
14493 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14494 | json_object_int_add(json_neigh, |
14495 | "internalBgpNbrMaxHopsAway", | |
14496 | p->gtsm_hops); | |
14497 | else | |
be8d1733 DA |
14498 | json_object_int_add(json_neigh, |
14499 | "internalBgpNbrMaxHopsAway", | |
14500 | p->ttl); | |
14501 | } else { | |
14502 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14503 | vty_out(vty, |
14504 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14505 | p->gtsm_hops); | |
be8d1733 DA |
14506 | else |
14507 | vty_out(vty, | |
14508 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14509 | p->ttl); | |
d62a17ae | 14510 | } |
14511 | } | |
14512 | ||
14513 | /* Local address. */ | |
14514 | if (p->su_local) { | |
14515 | if (use_json) { | |
47e12884 DA |
14516 | json_object_string_addf(json_neigh, "hostLocal", "%pSU", |
14517 | p->su_local); | |
d62a17ae | 14518 | json_object_int_add(json_neigh, "portLocal", |
14519 | ntohs(p->su_local->sin.sin_port)); | |
14520 | } else | |
47e12884 DA |
14521 | vty_out(vty, "Local host: %pSU, Local port: %d\n", |
14522 | p->su_local, ntohs(p->su_local->sin.sin_port)); | |
1e592331 DS |
14523 | } else { |
14524 | if (use_json) { | |
14525 | json_object_string_add(json_neigh, "hostLocal", | |
14526 | "Unknown"); | |
14527 | json_object_int_add(json_neigh, "portLocal", -1); | |
14528 | } | |
d62a17ae | 14529 | } |
14530 | ||
14531 | /* Remote address. */ | |
14532 | if (p->su_remote) { | |
14533 | if (use_json) { | |
47e12884 DA |
14534 | json_object_string_addf(json_neigh, "hostForeign", |
14535 | "%pSU", p->su_remote); | |
d62a17ae | 14536 | json_object_int_add(json_neigh, "portForeign", |
14537 | ntohs(p->su_remote->sin.sin_port)); | |
14538 | } else | |
47e12884 DA |
14539 | vty_out(vty, "Foreign host: %pSU, Foreign port: %d\n", |
14540 | p->su_remote, | |
d62a17ae | 14541 | ntohs(p->su_remote->sin.sin_port)); |
1e592331 DS |
14542 | } else { |
14543 | if (use_json) { | |
14544 | json_object_string_add(json_neigh, "hostForeign", | |
14545 | "Unknown"); | |
14546 | json_object_int_add(json_neigh, "portForeign", -1); | |
14547 | } | |
d62a17ae | 14548 | } |
14549 | ||
14550 | /* Nexthop display. */ | |
14551 | if (p->su_local) { | |
14552 | if (use_json) { | |
c949c771 DA |
14553 | json_object_string_addf(json_neigh, "nexthop", "%pI4", |
14554 | &p->nexthop.v4); | |
14555 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
14556 | "%pI6", &p->nexthop.v6_global); | |
14557 | json_object_string_addf(json_neigh, "nexthopLocal", | |
14558 | "%pI6", &p->nexthop.v6_local); | |
d62a17ae | 14559 | if (p->shared_network) |
14560 | json_object_string_add(json_neigh, | |
14561 | "bgpConnection", | |
14562 | "sharedNetwork"); | |
14563 | else | |
14564 | json_object_string_add(json_neigh, | |
14565 | "bgpConnection", | |
14566 | "nonSharedNetwork"); | |
14567 | } else { | |
07380148 DA |
14568 | vty_out(vty, "Nexthop: %pI4\n", &p->nexthop.v4); |
14569 | vty_out(vty, "Nexthop global: %pI6\n", | |
14570 | &p->nexthop.v6_global); | |
14571 | vty_out(vty, "Nexthop local: %pI6\n", | |
14572 | &p->nexthop.v6_local); | |
d62a17ae | 14573 | vty_out(vty, "BGP connection: %s\n", |
14574 | p->shared_network ? "shared network" | |
14575 | : "non shared network"); | |
14576 | } | |
432e7e46 KQ |
14577 | } else { |
14578 | if (use_json) { | |
14579 | json_object_string_add(json_neigh, "nexthop", | |
14580 | "Unknown"); | |
14581 | json_object_string_add(json_neigh, "nexthopGlobal", | |
14582 | "Unknown"); | |
14583 | json_object_string_add(json_neigh, "nexthopLocal", | |
14584 | "Unknown"); | |
14585 | json_object_string_add(json_neigh, "bgpConnection", | |
14586 | "Unknown"); | |
14587 | } | |
d62a17ae | 14588 | } |
14589 | ||
14590 | /* Timer information. */ | |
14591 | if (use_json) { | |
14592 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14593 | p->v_connect); | |
f41255a0 | 14594 | if (peer_established(p)) { |
d62a17ae | 14595 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
14596 | p->rtt); | |
f41255a0 DA |
14597 | if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) { |
14598 | json_object_int_add(json_neigh, | |
14599 | "shutdownRttInMsecs", | |
14600 | p->rtt_expected); | |
14601 | json_object_int_add(json_neigh, | |
14602 | "shutdownRttAfterCount", | |
14603 | p->rtt_keepalive_rcv); | |
14604 | } | |
14605 | } | |
d62a17ae | 14606 | if (p->t_start) |
14607 | json_object_int_add( | |
14608 | json_neigh, "nextStartTimerDueInMsecs", | |
14609 | thread_timer_remain_second(p->t_start) * 1000); | |
14610 | if (p->t_connect) | |
14611 | json_object_int_add( | |
14612 | json_neigh, "nextConnectTimerDueInMsecs", | |
14613 | thread_timer_remain_second(p->t_connect) | |
14614 | * 1000); | |
14615 | if (p->t_routeadv) { | |
14616 | json_object_int_add(json_neigh, "mraiInterval", | |
14617 | p->v_routeadv); | |
14618 | json_object_int_add( | |
14619 | json_neigh, "mraiTimerExpireInMsecs", | |
14620 | thread_timer_remain_second(p->t_routeadv) | |
14621 | * 1000); | |
14622 | } | |
14623 | if (p->password) | |
14624 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14625 | 1); | |
14626 | ||
14627 | if (p->t_read) | |
14628 | json_object_string_add(json_neigh, "readThread", "on"); | |
14629 | else | |
14630 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14631 | |
14632 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14633 | json_object_string_add(json_neigh, "writeThread", "on"); |
14634 | else | |
14635 | json_object_string_add(json_neigh, "writeThread", | |
14636 | "off"); | |
14637 | } else { | |
14638 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14639 | p->v_connect); | |
f41255a0 | 14640 | if (peer_established(p)) { |
d62a17ae | 14641 | vty_out(vty, "Estimated round trip time: %d ms\n", |
14642 | p->rtt); | |
f41255a0 DA |
14643 | if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) |
14644 | vty_out(vty, | |
14645 | "Shutdown when RTT > %dms, count > %u\n", | |
14646 | p->rtt_expected, p->rtt_keepalive_rcv); | |
14647 | } | |
d62a17ae | 14648 | if (p->t_start) |
14649 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14650 | thread_timer_remain_second(p->t_start)); | |
14651 | if (p->t_connect) | |
14652 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14653 | thread_timer_remain_second(p->t_connect)); | |
14654 | if (p->t_routeadv) | |
14655 | vty_out(vty, | |
14656 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14657 | p->v_routeadv, | |
14658 | thread_timer_remain_second(p->t_routeadv)); | |
14659 | if (p->password) | |
14660 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14661 | ||
cac9e917 | 14662 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14663 | p->t_read ? "on" : "off", |
14664 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14665 | ? "on" | |
cac9e917 | 14666 | : "off", p->fd); |
d62a17ae | 14667 | } |
14668 | ||
14669 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14670 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14671 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14672 | ||
14673 | if (!use_json) | |
14674 | vty_out(vty, "\n"); | |
14675 | ||
14676 | /* BFD information. */ | |
21bfce98 RZ |
14677 | if (p->bfd_config) |
14678 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 14679 | |
14680 | if (use_json) { | |
14681 | if (p->conf_if) /* Configured interface name. */ | |
14682 | json_object_object_add(json, p->conf_if, json_neigh); | |
14683 | else /* Configured IP address. */ | |
14684 | json_object_object_add(json, p->host, json_neigh); | |
14685 | } | |
14686 | } | |
14687 | ||
36235319 QY |
14688 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14689 | enum show_type type, | |
14690 | union sockunion *su, | |
14691 | const char *conf_if, afi_t afi, | |
403e64f8 | 14692 | json_object *json) |
2986cac2 | 14693 | { |
14694 | struct listnode *node, *nnode; | |
14695 | struct peer *peer; | |
14696 | int find = 0; | |
14697 | safi_t safi = SAFI_UNICAST; | |
14698 | json_object *json_neighbor = NULL; | |
14699 | ||
14700 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14701 | ||
14702 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14703 | continue; | |
14704 | ||
14705 | if ((peer->afc[afi][safi]) == 0) | |
14706 | continue; | |
14707 | ||
403e64f8 DA |
14708 | if (json) |
14709 | json_neighbor = json_object_new_object(); | |
14710 | ||
2ba1fe69 | 14711 | if (type == show_all) { |
403e64f8 | 14712 | bgp_show_peer_gr_status(vty, peer, json_neighbor); |
2986cac2 | 14713 | |
403e64f8 | 14714 | if (json) |
13909c4f DS |
14715 | json_object_object_add(json, peer->host, |
14716 | json_neighbor); | |
2986cac2 | 14717 | |
2ba1fe69 | 14718 | } else if (type == show_peer) { |
2986cac2 | 14719 | if (conf_if) { |
14720 | if ((peer->conf_if | |
13909c4f DS |
14721 | && !strcmp(peer->conf_if, conf_if)) |
14722 | || (peer->hostname | |
2986cac2 | 14723 | && !strcmp(peer->hostname, conf_if))) { |
14724 | find = 1; | |
13909c4f | 14725 | bgp_show_peer_gr_status(vty, peer, |
13909c4f | 14726 | json_neighbor); |
2986cac2 | 14727 | } |
14728 | } else { | |
14729 | if (sockunion_same(&peer->su, su)) { | |
14730 | find = 1; | |
13909c4f | 14731 | bgp_show_peer_gr_status(vty, peer, |
13909c4f | 14732 | json_neighbor); |
2986cac2 | 14733 | } |
14734 | } | |
403e64f8 | 14735 | if (json && find) |
13909c4f DS |
14736 | json_object_object_add(json, peer->host, |
14737 | json_neighbor); | |
2986cac2 | 14738 | } |
14739 | ||
403e64f8 | 14740 | if (find) |
2986cac2 | 14741 | break; |
14742 | } | |
14743 | ||
14744 | if (type == show_peer && !find) { | |
403e64f8 | 14745 | if (json) |
13909c4f | 14746 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14747 | else |
14748 | vty_out(vty, "%% No such neighbor\n"); | |
14749 | } | |
403e64f8 DA |
14750 | |
14751 | if (!json) | |
2986cac2 | 14752 | vty_out(vty, "\n"); |
2986cac2 | 14753 | |
14754 | return CMD_SUCCESS; | |
14755 | } | |
14756 | ||
d62a17ae | 14757 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14758 | enum show_type type, union sockunion *su, | |
9f049418 | 14759 | const char *conf_if, bool use_json, |
d62a17ae | 14760 | json_object *json) |
14761 | { | |
14762 | struct listnode *node, *nnode; | |
14763 | struct peer *peer; | |
14764 | int find = 0; | |
9f049418 | 14765 | bool nbr_output = false; |
d1927ebe AS |
14766 | afi_t afi = AFI_MAX; |
14767 | safi_t safi = SAFI_MAX; | |
14768 | ||
14769 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14770 | afi = AFI_IP; | |
14771 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14772 | afi = AFI_IP6; | |
14773 | } | |
d62a17ae | 14774 | |
14775 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14776 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14777 | continue; | |
14778 | ||
14779 | switch (type) { | |
14780 | case show_all: | |
14781 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14782 | nbr_output = true; |
d62a17ae | 14783 | break; |
14784 | case show_peer: | |
14785 | if (conf_if) { | |
14786 | if ((peer->conf_if | |
14787 | && !strcmp(peer->conf_if, conf_if)) | |
14788 | || (peer->hostname | |
14789 | && !strcmp(peer->hostname, conf_if))) { | |
14790 | find = 1; | |
14791 | bgp_show_peer(vty, peer, use_json, | |
14792 | json); | |
14793 | } | |
14794 | } else { | |
14795 | if (sockunion_same(&peer->su, su)) { | |
14796 | find = 1; | |
14797 | bgp_show_peer(vty, peer, use_json, | |
14798 | json); | |
14799 | } | |
14800 | } | |
14801 | break; | |
d1927ebe AS |
14802 | case show_ipv4_peer: |
14803 | case show_ipv6_peer: | |
14804 | FOREACH_SAFI (safi) { | |
14805 | if (peer->afc[afi][safi]) { | |
14806 | if (conf_if) { | |
14807 | if ((peer->conf_if | |
14808 | && !strcmp(peer->conf_if, conf_if)) | |
14809 | || (peer->hostname | |
14810 | && !strcmp(peer->hostname, conf_if))) { | |
14811 | find = 1; | |
14812 | bgp_show_peer(vty, peer, use_json, | |
14813 | json); | |
14814 | break; | |
14815 | } | |
14816 | } else { | |
14817 | if (sockunion_same(&peer->su, su)) { | |
14818 | find = 1; | |
14819 | bgp_show_peer(vty, peer, use_json, | |
14820 | json); | |
14821 | break; | |
14822 | } | |
14823 | } | |
14824 | } | |
14825 | } | |
14826 | break; | |
14827 | case show_ipv4_all: | |
14828 | case show_ipv6_all: | |
14829 | FOREACH_SAFI (safi) { | |
14830 | if (peer->afc[afi][safi]) { | |
14831 | bgp_show_peer(vty, peer, use_json, json); | |
14832 | nbr_output = true; | |
14833 | break; | |
14834 | } | |
14835 | } | |
14836 | break; | |
d62a17ae | 14837 | } |
14838 | } | |
14839 | ||
d1927ebe AS |
14840 | if ((type == show_peer || type == show_ipv4_peer || |
14841 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14842 | if (use_json) |
14843 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14844 | else | |
88b7d255 | 14845 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14846 | } |
14847 | ||
d1927ebe AS |
14848 | if (type != show_peer && type != show_ipv4_peer && |
14849 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14850 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14851 | |
d62a17ae | 14852 | if (use_json) { |
996c9314 LB |
14853 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14854 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14855 | } else { |
14856 | vty_out(vty, "\n"); | |
14857 | } | |
14858 | ||
14859 | return CMD_SUCCESS; | |
14860 | } | |
14861 | ||
36235319 QY |
14862 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14863 | enum show_type type, | |
14864 | const char *ip_str, | |
403e64f8 | 14865 | afi_t afi, json_object *json) |
2986cac2 | 14866 | { |
14867 | ||
14868 | int ret; | |
14869 | struct bgp *bgp; | |
14870 | union sockunion su; | |
2986cac2 | 14871 | |
14872 | bgp = bgp_get_default(); | |
14873 | ||
13909c4f DS |
14874 | if (!bgp) |
14875 | return; | |
2986cac2 | 14876 | |
403e64f8 DA |
14877 | if (!json) |
14878 | bgp_show_global_graceful_restart_mode_vty(vty, bgp); | |
2986cac2 | 14879 | |
13909c4f DS |
14880 | if (ip_str) { |
14881 | ret = str2sockunion(ip_str, &su); | |
14882 | if (ret < 0) | |
403e64f8 DA |
14883 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, |
14884 | ip_str, afi, json); | |
74a630b6 NT |
14885 | else |
14886 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
403e64f8 | 14887 | NULL, afi, json); |
13909c4f DS |
14888 | } else |
14889 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
403e64f8 | 14890 | afi, json); |
2986cac2 | 14891 | } |
14892 | ||
d62a17ae | 14893 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14894 | enum show_type type, |
14895 | const char *ip_str, | |
9f049418 | 14896 | bool use_json) |
d62a17ae | 14897 | { |
0291c246 MK |
14898 | struct listnode *node, *nnode; |
14899 | struct bgp *bgp; | |
71aedaa3 | 14900 | union sockunion su; |
0291c246 | 14901 | json_object *json = NULL; |
71aedaa3 | 14902 | int ret, is_first = 1; |
9f049418 | 14903 | bool nbr_output = false; |
d62a17ae | 14904 | |
14905 | if (use_json) | |
14906 | vty_out(vty, "{\n"); | |
14907 | ||
14908 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14909 | nbr_output = true; |
d62a17ae | 14910 | if (use_json) { |
14911 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14912 | flog_err( |
e50f7cfd | 14913 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14914 | "Unable to allocate memory for JSON object"); |
14915 | vty_out(vty, | |
14916 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14917 | return; | |
14918 | } | |
14919 | ||
14920 | json_object_int_add(json, "vrfId", | |
14921 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14922 | ? -1 |
14923 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14924 | json_object_string_add( |
14925 | json, "vrfName", | |
14926 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14927 | ? VRF_DEFAULT_NAME |
d62a17ae | 14928 | : bgp->name); |
14929 | ||
14930 | if (!is_first) | |
14931 | vty_out(vty, ",\n"); | |
14932 | else | |
14933 | is_first = 0; | |
14934 | ||
14935 | vty_out(vty, "\"%s\":", | |
14936 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14937 | ? VRF_DEFAULT_NAME |
d62a17ae | 14938 | : bgp->name); |
14939 | } else { | |
14940 | vty_out(vty, "\nInstance %s:\n", | |
14941 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14942 | ? VRF_DEFAULT_NAME |
d62a17ae | 14943 | : bgp->name); |
14944 | } | |
71aedaa3 | 14945 | |
d1927ebe AS |
14946 | if (type == show_peer || type == show_ipv4_peer || |
14947 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14948 | ret = str2sockunion(ip_str, &su); |
14949 | if (ret < 0) | |
14950 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14951 | use_json, json); | |
14952 | else | |
14953 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14954 | use_json, json); | |
14955 | } else { | |
d1927ebe | 14956 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14957 | use_json, json); |
14958 | } | |
b77004d6 | 14959 | json_object_free(json); |
121067e9 | 14960 | json = NULL; |
d62a17ae | 14961 | } |
14962 | ||
3e78a6ce | 14963 | if (use_json) |
d62a17ae | 14964 | vty_out(vty, "}\n"); |
9f049418 DS |
14965 | else if (!nbr_output) |
14966 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14967 | } |
14968 | ||
14969 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14970 | enum show_type type, const char *ip_str, | |
9f049418 | 14971 | bool use_json) |
d62a17ae | 14972 | { |
14973 | int ret; | |
14974 | struct bgp *bgp; | |
14975 | union sockunion su; | |
14976 | json_object *json = NULL; | |
14977 | ||
14978 | if (name) { | |
14979 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14980 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14981 | use_json); | |
d62a17ae | 14982 | return CMD_SUCCESS; |
14983 | } else { | |
14984 | bgp = bgp_lookup_by_name(name); | |
14985 | if (!bgp) { | |
14986 | if (use_json) { | |
14987 | json = json_object_new_object(); | |
75eeda93 | 14988 | vty_json(vty, json); |
d62a17ae | 14989 | } else |
14990 | vty_out(vty, | |
9f049418 | 14991 | "%% BGP instance not found\n"); |
d62a17ae | 14992 | |
14993 | return CMD_WARNING; | |
14994 | } | |
14995 | } | |
14996 | } else { | |
14997 | bgp = bgp_get_default(); | |
14998 | } | |
14999 | ||
15000 | if (bgp) { | |
15001 | json = json_object_new_object(); | |
15002 | if (ip_str) { | |
15003 | ret = str2sockunion(ip_str, &su); | |
15004 | if (ret < 0) | |
15005 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
15006 | use_json, json); | |
15007 | else | |
15008 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
15009 | use_json, json); | |
15010 | } else { | |
15011 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
15012 | json); | |
15013 | } | |
15014 | json_object_free(json); | |
ca61fd25 DS |
15015 | } else { |
15016 | if (use_json) | |
15017 | vty_out(vty, "{}\n"); | |
15018 | else | |
15019 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 15020 | } |
15021 | ||
15022 | return CMD_SUCCESS; | |
4fb25c53 DW |
15023 | } |
15024 | ||
2986cac2 | 15025 | |
15026 | ||
15027 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
dcab9012 | 15028 | DEFUN (show_ip_bgp_neighbors_graceful_restart, |
2986cac2 | 15029 | show_ip_bgp_neighbors_graceful_restart_cmd, |
15030 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
15031 | SHOW_STR | |
15032 | BGP_STR | |
15033 | IP_STR | |
15034 | IPV6_STR | |
15035 | NEIGHBOR_STR | |
15036 | "Neighbor to display information about\n" | |
15037 | "Neighbor to display information about\n" | |
15038 | "Neighbor on BGP configured interface\n" | |
15039 | GR_SHOW | |
15040 | JSON_STR) | |
15041 | { | |
15042 | char *sh_arg = NULL; | |
15043 | enum show_type sh_type; | |
15044 | int idx = 0; | |
15045 | afi_t afi = AFI_MAX; | |
2986cac2 | 15046 | bool uj = use_json(argc, argv); |
15047 | ||
36235319 | 15048 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 15049 | afi = AFI_MAX; |
15050 | ||
15051 | idx++; | |
15052 | ||
15053 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
15054 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15055 | || argv_find(argv, argc, "WORD", &idx)) { | |
15056 | sh_type = show_peer; | |
15057 | sh_arg = argv[idx]->arg; | |
15058 | } else | |
15059 | sh_type = show_all; | |
15060 | ||
15061 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
15062 | return CMD_SUCCESS; | |
15063 | ||
15064 | ||
36235319 QY |
15065 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
15066 | afi, uj); | |
2986cac2 | 15067 | } |
15068 | ||
716b2d8a | 15069 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 15070 | DEFUN (show_ip_bgp_neighbors, |
15071 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 15072 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 15073 | SHOW_STR |
15074 | IP_STR | |
15075 | BGP_STR | |
f2a8972b | 15076 | BGP_INSTANCE_HELP_STR |
00e6edb9 DA |
15077 | BGP_AF_STR |
15078 | BGP_AF_STR | |
718e3744 | 15079 | "Detailed information on TCP and BGP neighbor connections\n" |
15080 | "Neighbor to display information about\n" | |
a80beece | 15081 | "Neighbor to display information about\n" |
91d37724 | 15082 | "Neighbor on BGP configured interface\n" |
9973d184 | 15083 | JSON_STR) |
718e3744 | 15084 | { |
d62a17ae | 15085 | char *vrf = NULL; |
15086 | char *sh_arg = NULL; | |
15087 | enum show_type sh_type; | |
d1927ebe | 15088 | afi_t afi = AFI_MAX; |
718e3744 | 15089 | |
9f049418 | 15090 | bool uj = use_json(argc, argv); |
718e3744 | 15091 | |
d62a17ae | 15092 | int idx = 0; |
718e3744 | 15093 | |
9a8bdf1c PG |
15094 | /* [<vrf> VIEWVRFNAME] */ |
15095 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15096 | vrf = argv[idx + 1]->arg; | |
15097 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15098 | vrf = NULL; | |
15099 | } else if (argv_find(argv, argc, "view", &idx)) | |
15100 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 15101 | vrf = argv[idx + 1]->arg; |
718e3744 | 15102 | |
d62a17ae | 15103 | idx++; |
d1927ebe AS |
15104 | |
15105 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
15106 | sh_type = show_ipv4_all; | |
15107 | afi = AFI_IP; | |
15108 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
15109 | sh_type = show_ipv6_all; | |
15110 | afi = AFI_IP6; | |
15111 | } else { | |
15112 | sh_type = show_all; | |
15113 | } | |
15114 | ||
d62a17ae | 15115 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
15116 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15117 | || argv_find(argv, argc, "WORD", &idx)) { | |
15118 | sh_type = show_peer; | |
15119 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
15120 | } |
15121 | ||
15122 | if (sh_type == show_peer && afi == AFI_IP) { | |
15123 | sh_type = show_ipv4_peer; | |
15124 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
15125 | sh_type = show_ipv6_peer; | |
15126 | } | |
856ca177 | 15127 | |
d62a17ae | 15128 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 15129 | } |
15130 | ||
716b2d8a | 15131 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 15132 | paths' and `show ip mbgp paths'. Those functions results are the |
15133 | same.*/ | |
f412b39a | 15134 | DEFUN (show_ip_bgp_paths, |
718e3744 | 15135 | show_ip_bgp_paths_cmd, |
46f296b4 | 15136 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 15137 | SHOW_STR |
15138 | IP_STR | |
15139 | BGP_STR | |
46f296b4 | 15140 | BGP_SAFI_HELP_STR |
718e3744 | 15141 | "Path information\n") |
15142 | { | |
d62a17ae | 15143 | vty_out(vty, "Address Refcnt Path\n"); |
15144 | aspath_print_all_vty(vty); | |
15145 | return CMD_SUCCESS; | |
718e3744 | 15146 | } |
15147 | ||
718e3744 | 15148 | #include "hash.h" |
15149 | ||
e3b78da8 | 15150 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15151 | struct vty *vty) |
718e3744 | 15152 | { |
d62a17ae | 15153 | struct community *com; |
718e3744 | 15154 | |
e3b78da8 | 15155 | com = (struct community *)bucket->data; |
3f65c5b1 | 15156 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
c0945b78 | 15157 | community_str(com, false, false)); |
718e3744 | 15158 | } |
15159 | ||
15160 | /* Show BGP's community internal data. */ | |
f412b39a | 15161 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 15162 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 15163 | "show [ip] bgp community-info", |
718e3744 | 15164 | SHOW_STR |
15165 | IP_STR | |
15166 | BGP_STR | |
15167 | "List all bgp community information\n") | |
15168 | { | |
d62a17ae | 15169 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 15170 | |
d62a17ae | 15171 | hash_iterate(community_hash(), |
e3b78da8 | 15172 | (void (*)(struct hash_bucket *, |
d62a17ae | 15173 | void *))community_show_all_iterator, |
15174 | vty); | |
718e3744 | 15175 | |
d62a17ae | 15176 | return CMD_SUCCESS; |
718e3744 | 15177 | } |
15178 | ||
e3b78da8 | 15179 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15180 | struct vty *vty) |
57d187bc | 15181 | { |
d62a17ae | 15182 | struct lcommunity *lcom; |
57d187bc | 15183 | |
e3b78da8 | 15184 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 15185 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
c0945b78 | 15186 | lcommunity_str(lcom, false, false)); |
57d187bc JS |
15187 | } |
15188 | ||
15189 | /* Show BGP's community internal data. */ | |
15190 | DEFUN (show_ip_bgp_lcommunity_info, | |
15191 | show_ip_bgp_lcommunity_info_cmd, | |
15192 | "show ip bgp large-community-info", | |
15193 | SHOW_STR | |
15194 | IP_STR | |
15195 | BGP_STR | |
15196 | "List all bgp large-community information\n") | |
15197 | { | |
d62a17ae | 15198 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 15199 | |
d62a17ae | 15200 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 15201 | (void (*)(struct hash_bucket *, |
d62a17ae | 15202 | void *))lcommunity_show_all_iterator, |
15203 | vty); | |
57d187bc | 15204 | |
d62a17ae | 15205 | return CMD_SUCCESS; |
57d187bc | 15206 | } |
2986cac2 | 15207 | /* Graceful Restart */ |
15208 | ||
15209 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
403e64f8 | 15210 | struct bgp *bgp) |
2986cac2 | 15211 | { |
57d187bc JS |
15212 | |
15213 | ||
2986cac2 | 15214 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
15215 | ||
7318ae88 | 15216 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 15217 | |
15218 | switch (bgp_global_gr_mode) { | |
15219 | ||
15220 | case GLOBAL_HELPER: | |
13909c4f | 15221 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 15222 | break; |
15223 | ||
15224 | case GLOBAL_GR: | |
13909c4f | 15225 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 15226 | break; |
15227 | ||
15228 | case GLOBAL_DISABLE: | |
13909c4f | 15229 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 15230 | break; |
15231 | ||
15232 | case GLOBAL_INVALID: | |
2986cac2 | 15233 | vty_out(vty, |
2ba1fe69 | 15234 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 15235 | break; |
15236 | } | |
15237 | vty_out(vty, "\n"); | |
15238 | } | |
15239 | ||
36235319 QY |
15240 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
15241 | enum show_type type, | |
15242 | const char *ip_str, | |
15243 | afi_t afi, bool use_json) | |
2986cac2 | 15244 | { |
403e64f8 DA |
15245 | json_object *json = NULL; |
15246 | ||
15247 | if (use_json) | |
15248 | json = json_object_new_object(); | |
15249 | ||
2986cac2 | 15250 | if ((afi == AFI_MAX) && (ip_str == NULL)) { |
15251 | afi = AFI_IP; | |
15252 | ||
15253 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
15254 | ||
36235319 | 15255 | bgp_show_neighbor_graceful_restart_vty( |
403e64f8 | 15256 | vty, type, ip_str, afi, json); |
2986cac2 | 15257 | afi++; |
15258 | } | |
15259 | } else if (afi != AFI_MAX) { | |
36235319 | 15260 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
403e64f8 | 15261 | json); |
2986cac2 | 15262 | } else { |
403e64f8 DA |
15263 | if (json) |
15264 | json_object_free(json); | |
2986cac2 | 15265 | return CMD_ERR_INCOMPLETE; |
15266 | } | |
15267 | ||
403e64f8 DA |
15268 | if (json) |
15269 | vty_json(vty, json); | |
15270 | ||
2986cac2 | 15271 | return CMD_SUCCESS; |
15272 | } | |
15273 | /* Graceful Restart */ | |
15274 | ||
f412b39a | 15275 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 15276 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 15277 | "show [ip] bgp attribute-info", |
718e3744 | 15278 | SHOW_STR |
15279 | IP_STR | |
15280 | BGP_STR | |
15281 | "List all bgp attribute information\n") | |
15282 | { | |
d62a17ae | 15283 | attr_show_all(vty); |
15284 | return CMD_SUCCESS; | |
718e3744 | 15285 | } |
6b0655a2 | 15286 | |
03915806 CS |
15287 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
15288 | afi_t afi, safi_t safi, | |
15289 | bool use_json, json_object *json) | |
53089bec | 15290 | { |
15291 | struct bgp *bgp; | |
15292 | struct listnode *node; | |
15293 | char *vname; | |
53089bec | 15294 | char *ecom_str; |
9c2fd3fe | 15295 | enum vpn_policy_direction dir; |
53089bec | 15296 | |
03915806 | 15297 | if (json) { |
b46dfd20 DS |
15298 | json_object *json_import_vrfs = NULL; |
15299 | json_object *json_export_vrfs = NULL; | |
15300 | ||
b46dfd20 DS |
15301 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15302 | ||
53089bec | 15303 | if (!bgp) { |
75eeda93 | 15304 | vty_json(vty, json); |
b46dfd20 | 15305 | |
53089bec | 15306 | return CMD_WARNING; |
15307 | } | |
b46dfd20 | 15308 | |
94d4c685 DS |
15309 | /* Provide context for the block */ |
15310 | json_object_string_add(json, "vrf", name ? name : "default"); | |
15311 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 15312 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 15313 | |
b46dfd20 DS |
15314 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15315 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15316 | json_object_string_add(json, "importFromVrfs", "none"); | |
15317 | json_object_string_add(json, "importRts", "none"); | |
15318 | } else { | |
6ce24e52 DS |
15319 | json_import_vrfs = json_object_new_array(); |
15320 | ||
b46dfd20 DS |
15321 | for (ALL_LIST_ELEMENTS_RO( |
15322 | bgp->vpn_policy[afi].import_vrf, | |
15323 | node, vname)) | |
15324 | json_object_array_add(json_import_vrfs, | |
15325 | json_object_new_string(vname)); | |
15326 | ||
b20875ea CS |
15327 | json_object_object_add(json, "importFromVrfs", |
15328 | json_import_vrfs); | |
b46dfd20 | 15329 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
15330 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15331 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15332 | bgp->vpn_policy[afi].rtlist[dir], |
15333 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15334 | json_object_string_add(json, "importRts", |
15335 | ecom_str); | |
15336 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15337 | } else | |
15338 | json_object_string_add(json, "importRts", | |
15339 | "none"); | |
b46dfd20 DS |
15340 | } |
15341 | ||
15342 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
15343 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
15344 | json_object_string_add(json, "exportToVrfs", "none"); | |
15345 | json_object_string_add(json, "routeDistinguisher", | |
15346 | "none"); | |
15347 | json_object_string_add(json, "exportRts", "none"); | |
15348 | } else { | |
6ce24e52 DS |
15349 | json_export_vrfs = json_object_new_array(); |
15350 | ||
b46dfd20 DS |
15351 | for (ALL_LIST_ELEMENTS_RO( |
15352 | bgp->vpn_policy[afi].export_vrf, | |
15353 | node, vname)) | |
15354 | json_object_array_add(json_export_vrfs, | |
15355 | json_object_new_string(vname)); | |
15356 | json_object_object_add(json, "exportToVrfs", | |
15357 | json_export_vrfs); | |
c4f64ea9 DA |
15358 | json_object_string_addf(json, "routeDistinguisher", |
15359 | "%pRD", | |
15360 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15361 | |
15362 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15363 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15364 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15365 | bgp->vpn_policy[afi].rtlist[dir], |
15366 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15367 | json_object_string_add(json, "exportRts", |
15368 | ecom_str); | |
15369 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15370 | } else | |
15371 | json_object_string_add(json, "exportRts", | |
15372 | "none"); | |
b46dfd20 DS |
15373 | } |
15374 | ||
03915806 | 15375 | if (use_json) { |
75eeda93 | 15376 | vty_json(vty, json); |
03915806 | 15377 | } |
53089bec | 15378 | } else { |
b46dfd20 DS |
15379 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15380 | ||
53089bec | 15381 | if (!bgp) { |
b46dfd20 | 15382 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 15383 | return CMD_WARNING; |
15384 | } | |
53089bec | 15385 | |
b46dfd20 DS |
15386 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15387 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
15388 | vty_out(vty, | |
15389 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 15390 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15391 | else { |
15392 | vty_out(vty, | |
15393 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 15394 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15395 | |
15396 | for (ALL_LIST_ELEMENTS_RO( | |
15397 | bgp->vpn_policy[afi].import_vrf, | |
15398 | node, vname)) | |
15399 | vty_out(vty, " %s\n", vname); | |
15400 | ||
15401 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
15402 | ecom_str = NULL; |
15403 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
15404 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15405 | bgp->vpn_policy[afi].rtlist[dir], |
15406 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 15407 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 15408 | |
b20875ea CS |
15409 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
15410 | } else | |
15411 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15412 | } |
53089bec | 15413 | |
b46dfd20 DS |
15414 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15415 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15416 | vty_out(vty, | |
15417 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 15418 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15419 | else { |
15420 | vty_out(vty, | |
04c9077f | 15421 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 15422 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15423 | |
15424 | for (ALL_LIST_ELEMENTS_RO( | |
15425 | bgp->vpn_policy[afi].export_vrf, | |
15426 | node, vname)) | |
15427 | vty_out(vty, " %s\n", vname); | |
15428 | ||
c4f64ea9 DA |
15429 | vty_out(vty, "RD: %pRD\n", |
15430 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15431 | |
15432 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15433 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15434 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15435 | bgp->vpn_policy[afi].rtlist[dir], |
15436 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15437 | vty_out(vty, "Export RT: %s\n", ecom_str); |
15438 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15439 | } else | |
15440 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15441 | } |
53089bec | 15442 | } |
15443 | ||
15444 | return CMD_SUCCESS; | |
15445 | } | |
15446 | ||
03915806 CS |
15447 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
15448 | safi_t safi, bool use_json) | |
15449 | { | |
15450 | struct listnode *node, *nnode; | |
15451 | struct bgp *bgp; | |
15452 | char *vrf_name = NULL; | |
15453 | json_object *json = NULL; | |
15454 | json_object *json_vrf = NULL; | |
15455 | json_object *json_vrfs = NULL; | |
15456 | ||
15457 | if (use_json) { | |
15458 | json = json_object_new_object(); | |
15459 | json_vrfs = json_object_new_object(); | |
15460 | } | |
15461 | ||
15462 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
15463 | ||
15464 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
15465 | vrf_name = bgp->name; | |
15466 | ||
15467 | if (use_json) { | |
15468 | json_vrf = json_object_new_object(); | |
15469 | } else { | |
15470 | vty_out(vty, "\nInstance %s:\n", | |
15471 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15472 | ? VRF_DEFAULT_NAME : bgp->name); | |
15473 | } | |
15474 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
15475 | if (use_json) { | |
15476 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15477 | json_object_object_add(json_vrfs, | |
15478 | VRF_DEFAULT_NAME, json_vrf); | |
15479 | else | |
15480 | json_object_object_add(json_vrfs, vrf_name, | |
15481 | json_vrf); | |
15482 | } | |
15483 | } | |
15484 | ||
15485 | if (use_json) { | |
15486 | json_object_object_add(json, "vrfs", json_vrfs); | |
75eeda93 | 15487 | vty_json(vty, json); |
03915806 CS |
15488 | } |
15489 | ||
15490 | return CMD_SUCCESS; | |
15491 | } | |
15492 | ||
53089bec | 15493 | /* "show [ip] bgp route-leak" command. */ |
15494 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
15495 | show_ip_bgp_route_leak_cmd, |
15496 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
15497 | SHOW_STR |
15498 | IP_STR | |
15499 | BGP_STR | |
15500 | BGP_INSTANCE_HELP_STR | |
15501 | BGP_AFI_HELP_STR | |
15502 | BGP_SAFI_HELP_STR | |
15503 | "Route leaking information\n" | |
15504 | JSON_STR) | |
53089bec | 15505 | { |
15506 | char *vrf = NULL; | |
15507 | afi_t afi = AFI_MAX; | |
15508 | safi_t safi = SAFI_MAX; | |
15509 | ||
9f049418 | 15510 | bool uj = use_json(argc, argv); |
53089bec | 15511 | int idx = 0; |
03915806 | 15512 | json_object *json = NULL; |
53089bec | 15513 | |
15514 | /* show [ip] bgp */ | |
15515 | if (argv_find(argv, argc, "ip", &idx)) { | |
15516 | afi = AFI_IP; | |
15517 | safi = SAFI_UNICAST; | |
15518 | } | |
15519 | /* [vrf VIEWVRFNAME] */ | |
15520 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
15521 | vty_out(vty, |
15522 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 15523 | return CMD_WARNING; |
15524 | } | |
15525 | ||
9a8bdf1c PG |
15526 | if (argv_find(argv, argc, "vrf", &idx)) { |
15527 | vrf = argv[idx + 1]->arg; | |
15528 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15529 | vrf = NULL; | |
15530 | } | |
53089bec | 15531 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
c48349e3 | 15532 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
53089bec | 15533 | argv_find_and_parse_safi(argv, argc, &idx, &safi); |
53089bec | 15534 | |
15535 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
15536 | vty_out(vty, |
15537 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 15538 | return CMD_WARNING; |
15539 | } | |
15540 | ||
03915806 CS |
15541 | if (vrf && strmatch(vrf, "all")) |
15542 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
15543 | ||
15544 | if (uj) | |
15545 | json = json_object_new_object(); | |
15546 | ||
15547 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 15548 | } |
15549 | ||
d62a17ae | 15550 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
fa5a9276 | 15551 | safi_t safi, bool uj) |
f186de26 | 15552 | { |
d62a17ae | 15553 | struct listnode *node, *nnode; |
15554 | struct bgp *bgp; | |
f186de26 | 15555 | |
d62a17ae | 15556 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
fa5a9276 AR |
15557 | if (!uj) |
15558 | vty_out(vty, "\nInstance %s:\n", | |
15559 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15560 | ? VRF_DEFAULT_NAME | |
15561 | : bgp->name); | |
15562 | ||
15563 | update_group_show(bgp, afi, safi, vty, 0, uj); | |
d62a17ae | 15564 | } |
f186de26 | 15565 | } |
15566 | ||
d62a17ae | 15567 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
fa5a9276 | 15568 | int safi, uint64_t subgrp_id, bool uj) |
4fb25c53 | 15569 | { |
d62a17ae | 15570 | struct bgp *bgp; |
4fb25c53 | 15571 | |
d62a17ae | 15572 | if (name) { |
15573 | if (strmatch(name, "all")) { | |
fa5a9276 | 15574 | bgp_show_all_instances_updgrps_vty(vty, afi, safi, uj); |
d62a17ae | 15575 | return CMD_SUCCESS; |
15576 | } else { | |
15577 | bgp = bgp_lookup_by_name(name); | |
15578 | } | |
15579 | } else { | |
15580 | bgp = bgp_get_default(); | |
15581 | } | |
4fb25c53 | 15582 | |
d62a17ae | 15583 | if (bgp) |
fa5a9276 | 15584 | update_group_show(bgp, afi, safi, vty, subgrp_id, uj); |
d62a17ae | 15585 | return CMD_SUCCESS; |
4fb25c53 DW |
15586 | } |
15587 | ||
8fe8a7f6 DS |
15588 | DEFUN (show_ip_bgp_updgrps, |
15589 | show_ip_bgp_updgrps_cmd, | |
fa5a9276 | 15590 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID] [json]", |
8386ac43 | 15591 | SHOW_STR |
15592 | IP_STR | |
15593 | BGP_STR | |
15594 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15595 | BGP_AFI_HELP_STR |
9bedbb1e | 15596 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 | 15597 | "Detailed info about dynamic update groups\n" |
fa5a9276 AR |
15598 | "Specific subgroup to display detailed info for\n" |
15599 | JSON_STR) | |
8386ac43 | 15600 | { |
d62a17ae | 15601 | char *vrf = NULL; |
15602 | afi_t afi = AFI_IP6; | |
15603 | safi_t safi = SAFI_UNICAST; | |
15604 | uint64_t subgrp_id = 0; | |
15605 | ||
15606 | int idx = 0; | |
15607 | ||
fa5a9276 AR |
15608 | bool uj = use_json(argc, argv); |
15609 | ||
d62a17ae | 15610 | /* show [ip] bgp */ |
15611 | if (argv_find(argv, argc, "ip", &idx)) | |
15612 | afi = AFI_IP; | |
9a8bdf1c PG |
15613 | /* [<vrf> VIEWVRFNAME] */ |
15614 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15615 | vrf = argv[idx + 1]->arg; | |
15616 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15617 | vrf = NULL; | |
15618 | } else if (argv_find(argv, argc, "view", &idx)) | |
15619 | /* [<view> VIEWVRFNAME] */ | |
15620 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15621 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15622 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15623 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15624 | } | |
5bf15956 | 15625 | |
d62a17ae | 15626 | /* get subgroup id, if provided */ |
15627 | idx = argc - 1; | |
15628 | if (argv[idx]->type == VARIABLE_TKN) | |
15629 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15630 | |
fa5a9276 | 15631 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id, uj)); |
8fe8a7f6 DS |
15632 | } |
15633 | ||
f186de26 | 15634 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15635 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
fa5a9276 | 15636 | "show [ip] bgp <view|vrf> all update-groups [json]", |
f186de26 | 15637 | SHOW_STR |
716b2d8a | 15638 | IP_STR |
f186de26 | 15639 | BGP_STR |
15640 | BGP_INSTANCE_ALL_HELP_STR | |
fa5a9276 AR |
15641 | "Detailed info about dynamic update groups\n" |
15642 | JSON_STR) | |
f186de26 | 15643 | { |
fa5a9276 AR |
15644 | bool uj = use_json(argc, argv); |
15645 | ||
15646 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST, uj); | |
d62a17ae | 15647 | return CMD_SUCCESS; |
f186de26 | 15648 | } |
15649 | ||
43d3f4fc DS |
15650 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15651 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15652 | "show [ip] bgp l2vpn evpn update-groups", | |
15653 | SHOW_STR | |
15654 | IP_STR | |
15655 | BGP_STR | |
15656 | "l2vpn address family\n" | |
15657 | "evpn sub-address family\n" | |
15658 | "Detailed info about dynamic update groups\n") | |
15659 | { | |
15660 | char *vrf = NULL; | |
15661 | uint64_t subgrp_id = 0; | |
15662 | ||
fa5a9276 | 15663 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id, 0); |
43d3f4fc DS |
15664 | return CMD_SUCCESS; |
15665 | } | |
15666 | ||
5bf15956 DW |
15667 | DEFUN (show_bgp_updgrps_stats, |
15668 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15669 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15670 | SHOW_STR |
716b2d8a | 15671 | IP_STR |
3f9c7369 | 15672 | BGP_STR |
0c7b1b01 | 15673 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15674 | "Statistics\n") |
15675 | { | |
d62a17ae | 15676 | struct bgp *bgp; |
3f9c7369 | 15677 | |
d62a17ae | 15678 | bgp = bgp_get_default(); |
15679 | if (bgp) | |
15680 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15681 | |
d62a17ae | 15682 | return CMD_SUCCESS; |
3f9c7369 DS |
15683 | } |
15684 | ||
8386ac43 | 15685 | DEFUN (show_bgp_instance_updgrps_stats, |
15686 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15687 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15688 | SHOW_STR |
716b2d8a | 15689 | IP_STR |
8386ac43 | 15690 | BGP_STR |
15691 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15692 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15693 | "Statistics\n") |
15694 | { | |
d62a17ae | 15695 | int idx_word = 3; |
15696 | struct bgp *bgp; | |
8386ac43 | 15697 | |
d62a17ae | 15698 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15699 | if (bgp) | |
15700 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15701 | |
d62a17ae | 15702 | return CMD_SUCCESS; |
8386ac43 | 15703 | } |
15704 | ||
d62a17ae | 15705 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15706 | afi_t afi, safi_t safi, | |
15707 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15708 | { |
d62a17ae | 15709 | struct bgp *bgp; |
8386ac43 | 15710 | |
d62a17ae | 15711 | if (name) |
15712 | bgp = bgp_lookup_by_name(name); | |
15713 | else | |
15714 | bgp = bgp_get_default(); | |
8386ac43 | 15715 | |
d62a17ae | 15716 | if (bgp) { |
15717 | if (!strcmp(what, "advertise-queue")) | |
15718 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15719 | subgrp_id); | |
15720 | else if (!strcmp(what, "advertised-routes")) | |
15721 | update_group_show_advertised(bgp, afi, safi, vty, | |
15722 | subgrp_id); | |
15723 | else if (!strcmp(what, "packet-queue")) | |
15724 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15725 | subgrp_id); | |
15726 | } | |
3f9c7369 DS |
15727 | } |
15728 | ||
dc64bdec QY |
15729 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15730 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15731 | "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", | |
15732 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15733 | BGP_SAFI_HELP_STR | |
15734 | "Detailed info about dynamic update groups\n" | |
15735 | "Specific subgroup to display info for\n" | |
15736 | "Advertisement queue\n" | |
15737 | "Announced routes\n" | |
15738 | "Packet queue\n") | |
3f9c7369 | 15739 | { |
dc64bdec QY |
15740 | uint64_t subgrp_id = 0; |
15741 | afi_t afiz; | |
15742 | safi_t safiz; | |
15743 | if (sgid) | |
15744 | subgrp_id = strtoull(sgid, NULL, 10); | |
15745 | ||
15746 | if (!ip && !afi) | |
15747 | afiz = AFI_IP6; | |
15748 | if (!ip && afi) | |
15749 | afiz = bgp_vty_afi_from_str(afi); | |
15750 | if (ip && !afi) | |
15751 | afiz = AFI_IP; | |
15752 | if (ip && afi) { | |
15753 | afiz = bgp_vty_afi_from_str(afi); | |
15754 | if (afiz != AFI_IP) | |
15755 | vty_out(vty, | |
15756 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15757 | return CMD_WARNING; | |
15758 | } | |
d62a17ae | 15759 | |
dc64bdec | 15760 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15761 | |
dc64bdec | 15762 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15763 | return CMD_SUCCESS; |
15764 | } | |
15765 | ||
6f4eacf3 DA |
15766 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15767 | json_object *json) | |
d62a17ae | 15768 | { |
15769 | struct listnode *node, *nnode; | |
15770 | struct prefix *range; | |
15771 | struct peer *conf; | |
15772 | struct peer *peer; | |
d62a17ae | 15773 | afi_t afi; |
15774 | safi_t safi; | |
15775 | const char *peer_status; | |
d62a17ae | 15776 | int lr_count; |
15777 | int dynamic; | |
6f4eacf3 DA |
15778 | bool af_cfgd; |
15779 | json_object *json_peer_group = NULL; | |
15780 | json_object *json_peer_group_afc = NULL; | |
15781 | json_object *json_peer_group_members = NULL; | |
15782 | json_object *json_peer_group_dynamic = NULL; | |
15783 | json_object *json_peer_group_dynamic_af = NULL; | |
15784 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15785 | |
15786 | conf = group->conf; | |
15787 | ||
6f4eacf3 DA |
15788 | if (json) { |
15789 | json_peer_group = json_object_new_object(); | |
15790 | json_peer_group_afc = json_object_new_array(); | |
15791 | } | |
15792 | ||
d62a17ae | 15793 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15794 | if (json) |
15795 | json_object_int_add(json_peer_group, "remoteAs", | |
15796 | conf->as); | |
15797 | else | |
15798 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15799 | group->name, conf->as); | |
d62a17ae | 15800 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15801 | if (json) |
15802 | json_object_int_add(json_peer_group, "remoteAs", | |
15803 | group->bgp->as); | |
15804 | else | |
15805 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15806 | group->name, group->bgp->as); | |
d62a17ae | 15807 | } else { |
6f4eacf3 DA |
15808 | if (!json) |
15809 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15810 | } |
f14e6fdb | 15811 | |
6f4eacf3 DA |
15812 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15813 | if (json) | |
15814 | json_object_string_add(json_peer_group, "type", | |
15815 | "internal"); | |
15816 | else | |
15817 | vty_out(vty, " Peer-group type is internal\n"); | |
15818 | } else { | |
15819 | if (json) | |
15820 | json_object_string_add(json_peer_group, "type", | |
15821 | "external"); | |
15822 | else | |
15823 | vty_out(vty, " Peer-group type is external\n"); | |
15824 | } | |
d62a17ae | 15825 | |
15826 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15827 | if (!json) |
15828 | vty_out(vty, " Configured address-families:"); | |
15829 | ||
05c7a1cc QY |
15830 | FOREACH_AFI_SAFI (afi, safi) { |
15831 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15832 | af_cfgd = true; |
15833 | if (json) | |
15834 | json_object_array_add( | |
15835 | json_peer_group_afc, | |
15836 | json_object_new_string(get_afi_safi_str( | |
15837 | afi, safi, false))); | |
15838 | else | |
15839 | vty_out(vty, " %s;", | |
15840 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15841 | } |
05c7a1cc | 15842 | } |
6f4eacf3 DA |
15843 | |
15844 | if (json) { | |
15845 | json_object_object_add(json_peer_group, | |
15846 | "addressFamiliesConfigured", | |
15847 | json_peer_group_afc); | |
15848 | } else { | |
15849 | if (!af_cfgd) | |
15850 | vty_out(vty, " none\n"); | |
15851 | else | |
15852 | vty_out(vty, "\n"); | |
15853 | } | |
d62a17ae | 15854 | |
15855 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15856 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15857 | lr_count = listcount(group->listen_range[afi]); |
15858 | if (lr_count) { | |
6f4eacf3 DA |
15859 | if (json) { |
15860 | if (!json_peer_group_dynamic) | |
15861 | json_peer_group_dynamic = | |
15862 | json_object_new_object(); | |
15863 | ||
15864 | json_peer_group_dynamic_af = | |
15865 | json_object_new_object(); | |
15866 | json_peer_group_ranges = | |
15867 | json_object_new_array(); | |
15868 | json_object_int_add(json_peer_group_dynamic_af, | |
15869 | "count", lr_count); | |
15870 | } else { | |
15871 | vty_out(vty, " %d %s listen range(s)\n", | |
15872 | lr_count, afi2str(afi)); | |
15873 | } | |
d62a17ae | 15874 | |
15875 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15876 | nnode, range)) { |
15877 | if (json) { | |
15878 | char buf[BUFSIZ]; | |
15879 | ||
15880 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15881 | range); | |
15882 | ||
15883 | json_object_array_add( | |
15884 | json_peer_group_ranges, | |
15885 | json_object_new_string(buf)); | |
15886 | } else { | |
15887 | vty_out(vty, " %pFX\n", range); | |
15888 | } | |
15889 | } | |
15890 | ||
15891 | if (json) { | |
15892 | json_object_object_add( | |
15893 | json_peer_group_dynamic_af, "ranges", | |
15894 | json_peer_group_ranges); | |
15895 | ||
15896 | json_object_object_add( | |
15897 | json_peer_group_dynamic, afi2str(afi), | |
15898 | json_peer_group_dynamic_af); | |
15899 | } | |
d62a17ae | 15900 | } |
15901 | } | |
f14e6fdb | 15902 | |
6f4eacf3 DA |
15903 | if (json_peer_group_dynamic) |
15904 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15905 | json_peer_group_dynamic); | |
15906 | ||
d62a17ae | 15907 | /* Display group members and their status */ |
15908 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
15909 | if (json) |
15910 | json_peer_group_members = json_object_new_object(); | |
15911 | else | |
15912 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 15913 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
15914 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15915 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15916 | peer_status = "Idle (Admin)"; |
15917 | else if (CHECK_FLAG(peer->sflags, | |
15918 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15919 | peer_status = "Idle (PfxCt)"; | |
15920 | else | |
15921 | peer_status = lookup_msg(bgp_status_msg, | |
15922 | peer->status, NULL); | |
15923 | ||
15924 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
15925 | |
15926 | if (json) { | |
15927 | json_object *json_peer_group_member = | |
15928 | json_object_new_object(); | |
15929 | ||
15930 | json_object_string_add(json_peer_group_member, | |
15931 | "status", peer_status); | |
15932 | ||
15933 | if (dynamic) | |
15934 | json_object_boolean_true_add( | |
15935 | json_peer_group_member, | |
15936 | "dynamic"); | |
15937 | ||
15938 | json_object_object_add(json_peer_group_members, | |
15939 | peer->host, | |
15940 | json_peer_group_member); | |
15941 | } else { | |
15942 | vty_out(vty, " %s %s %s \n", peer->host, | |
15943 | dynamic ? "(dynamic)" : "", | |
15944 | peer_status); | |
15945 | } | |
d62a17ae | 15946 | } |
6f4eacf3 DA |
15947 | if (json) |
15948 | json_object_object_add(json_peer_group, "members", | |
15949 | json_peer_group_members); | |
d62a17ae | 15950 | } |
f14e6fdb | 15951 | |
6f4eacf3 DA |
15952 | if (json) |
15953 | json_object_object_add(json, group->name, json_peer_group); | |
15954 | ||
d62a17ae | 15955 | return CMD_SUCCESS; |
15956 | } | |
15957 | ||
ff9959b0 | 15958 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 15959 | const char *group_name, bool uj) |
d62a17ae | 15960 | { |
ff9959b0 | 15961 | struct bgp *bgp; |
d62a17ae | 15962 | struct listnode *node, *nnode; |
15963 | struct peer_group *group; | |
ff9959b0 | 15964 | bool found = false; |
6f4eacf3 DA |
15965 | json_object *json = NULL; |
15966 | ||
15967 | if (uj) | |
15968 | json = json_object_new_object(); | |
ff9959b0 QY |
15969 | |
15970 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15971 | ||
15972 | if (!bgp) { | |
c48349e3 | 15973 | if (uj) |
75eeda93 | 15974 | vty_json(vty, json); |
c48349e3 | 15975 | else |
6f4eacf3 | 15976 | vty_out(vty, "%% BGP instance not found\n"); |
6f4eacf3 | 15977 | |
ff9959b0 QY |
15978 | return CMD_WARNING; |
15979 | } | |
d62a17ae | 15980 | |
15981 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15982 | if (group_name) { |
15983 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 15984 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
15985 | found = true; |
15986 | break; | |
d62a17ae | 15987 | } |
ff9959b0 | 15988 | } else { |
6f4eacf3 | 15989 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 15990 | } |
f14e6fdb | 15991 | } |
f14e6fdb | 15992 | |
6f4eacf3 | 15993 | if (group_name && !found && !uj) |
d62a17ae | 15994 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15995 | |
c48349e3 | 15996 | if (uj) |
75eeda93 | 15997 | vty_json(vty, json); |
6f4eacf3 | 15998 | |
d62a17ae | 15999 | return CMD_SUCCESS; |
f14e6fdb DS |
16000 | } |
16001 | ||
6f4eacf3 DA |
16002 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
16003 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
16004 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
16005 | "Detailed information on BGP peer groups\n" | |
16006 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 16007 | { |
d62a17ae | 16008 | char *vrf, *pg; |
d62a17ae | 16009 | int idx = 0; |
6f4eacf3 | 16010 | bool uj = use_json(argc, argv); |
f14e6fdb | 16011 | |
a4d82a8a PZ |
16012 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
16013 | : NULL; | |
d62a17ae | 16014 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 16015 | |
6f4eacf3 | 16016 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 16017 | } |
3f9c7369 | 16018 | |
d6e3c605 | 16019 | |
718e3744 | 16020 | /* Redistribute VTY commands. */ |
16021 | ||
585f1adc IR |
16022 | DEFUN (bgp_redistribute_ipv4, |
16023 | bgp_redistribute_ipv4_cmd, | |
16024 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16025 | "Redistribute information from another routing protocol\n" | |
16026 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 16027 | { |
585f1adc | 16028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16029 | int idx_protocol = 1; |
585f1adc | 16030 | int type; |
37a87b8f | 16031 | |
585f1adc IR |
16032 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
16033 | if (type < 0) { | |
16034 | vty_out(vty, "%% Invalid route type\n"); | |
16035 | return CMD_WARNING_CONFIG_FAILED; | |
16036 | } | |
7f323236 | 16037 | |
585f1adc IR |
16038 | bgp_redist_add(bgp, AFI_IP, type, 0); |
16039 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 16040 | } |
16041 | ||
d62a17ae | 16042 | ALIAS_HIDDEN( |
16043 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
16044 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16045 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 16046 | |
585f1adc IR |
16047 | DEFUN (bgp_redistribute_ipv4_rmap, |
16048 | bgp_redistribute_ipv4_rmap_cmd, | |
70dd370f | 16049 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16050 | "Redistribute information from another routing protocol\n" |
16051 | FRR_IP_REDIST_HELP_STR_BGPD | |
16052 | "Route map reference\n" | |
16053 | "Pointer to route-map entries\n") | |
718e3744 | 16054 | { |
585f1adc | 16055 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16056 | int idx_protocol = 1; |
16057 | int idx_word = 3; | |
585f1adc IR |
16058 | int type; |
16059 | struct bgp_redist *red; | |
16060 | bool changed; | |
16061 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
16062 | vty, argv[idx_word]->arg); | |
16063 | ||
16064 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16065 | if (type < 0) { | |
16066 | vty_out(vty, "%% Invalid route type\n"); | |
16067 | return CMD_WARNING_CONFIG_FAILED; | |
16068 | } | |
37a87b8f | 16069 | |
585f1adc IR |
16070 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16071 | changed = | |
16072 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16073 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 16074 | } |
16075 | ||
d62a17ae | 16076 | ALIAS_HIDDEN( |
16077 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
70dd370f | 16078 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
d62a17ae | 16079 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16080 | "Route map reference\n" | |
16081 | "Pointer to route-map entries\n") | |
596c17ba | 16082 | |
585f1adc IR |
16083 | DEFUN (bgp_redistribute_ipv4_metric, |
16084 | bgp_redistribute_ipv4_metric_cmd, | |
16085 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16086 | "Redistribute information from another routing protocol\n" | |
16087 | FRR_IP_REDIST_HELP_STR_BGPD | |
16088 | "Metric for redistributed routes\n" | |
16089 | "Default metric\n") | |
718e3744 | 16090 | { |
585f1adc | 16091 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16092 | int idx_protocol = 1; |
16093 | int idx_number = 3; | |
585f1adc IR |
16094 | int type; |
16095 | uint32_t metric; | |
16096 | struct bgp_redist *red; | |
16097 | bool changed; | |
16098 | ||
16099 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16100 | if (type < 0) { | |
16101 | vty_out(vty, "%% Invalid route type\n"); | |
16102 | return CMD_WARNING_CONFIG_FAILED; | |
16103 | } | |
16104 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16105 | |
585f1adc IR |
16106 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16107 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16108 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16109 | } |
16110 | ||
16111 | ALIAS_HIDDEN( | |
16112 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
16113 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16114 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16115 | "Metric for redistributed routes\n" | |
16116 | "Default metric\n") | |
596c17ba | 16117 | |
585f1adc IR |
16118 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
16119 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
70dd370f | 16120 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16121 | "Redistribute information from another routing protocol\n" |
16122 | FRR_IP_REDIST_HELP_STR_BGPD | |
16123 | "Route map reference\n" | |
16124 | "Pointer to route-map entries\n" | |
16125 | "Metric for redistributed routes\n" | |
16126 | "Default metric\n") | |
718e3744 | 16127 | { |
585f1adc | 16128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16129 | int idx_protocol = 1; |
16130 | int idx_word = 3; | |
16131 | int idx_number = 5; | |
585f1adc IR |
16132 | int type; |
16133 | uint32_t metric; | |
16134 | struct bgp_redist *red; | |
16135 | bool changed; | |
16136 | struct route_map *route_map = | |
16137 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16138 | ||
16139 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16140 | if (type < 0) { | |
16141 | vty_out(vty, "%% Invalid route type\n"); | |
16142 | return CMD_WARNING_CONFIG_FAILED; | |
16143 | } | |
16144 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16145 | |
585f1adc IR |
16146 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16147 | changed = | |
16148 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16149 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16150 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16151 | } |
16152 | ||
16153 | ALIAS_HIDDEN( | |
16154 | bgp_redistribute_ipv4_rmap_metric, | |
16155 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
16156 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16157 | " route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16158 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16159 | "Route map reference\n" | |
16160 | "Pointer to route-map entries\n" | |
16161 | "Metric for redistributed routes\n" | |
16162 | "Default metric\n") | |
596c17ba | 16163 | |
585f1adc IR |
16164 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
16165 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
70dd370f | 16166 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16167 | "Redistribute information from another routing protocol\n" |
16168 | FRR_IP_REDIST_HELP_STR_BGPD | |
16169 | "Metric for redistributed routes\n" | |
16170 | "Default metric\n" | |
16171 | "Route map reference\n" | |
16172 | "Pointer to route-map entries\n") | |
718e3744 | 16173 | { |
585f1adc | 16174 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16175 | int idx_protocol = 1; |
37a87b8f | 16176 | int idx_number = 3; |
585f1adc IR |
16177 | int idx_word = 5; |
16178 | int type; | |
16179 | uint32_t metric; | |
16180 | struct bgp_redist *red; | |
16181 | bool changed; | |
16182 | struct route_map *route_map = | |
16183 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16184 | ||
16185 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16186 | if (type < 0) { | |
16187 | vty_out(vty, "%% Invalid route type\n"); | |
16188 | return CMD_WARNING_CONFIG_FAILED; | |
16189 | } | |
16190 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16191 | |
585f1adc IR |
16192 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16193 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16194 | changed |= | |
16195 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16196 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16197 | } |
16198 | ||
16199 | ALIAS_HIDDEN( | |
16200 | bgp_redistribute_ipv4_metric_rmap, | |
16201 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
16202 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16203 | " metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16204 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16205 | "Metric for redistributed routes\n" | |
16206 | "Default metric\n" | |
16207 | "Route map reference\n" | |
16208 | "Pointer to route-map entries\n") | |
596c17ba | 16209 | |
585f1adc IR |
16210 | DEFUN (bgp_redistribute_ipv4_ospf, |
16211 | bgp_redistribute_ipv4_ospf_cmd, | |
16212 | "redistribute <ospf|table> (1-65535)", | |
16213 | "Redistribute information from another routing protocol\n" | |
16214 | "Open Shortest Path First (OSPFv2)\n" | |
16215 | "Non-main Kernel Routing Table\n" | |
16216 | "Instance ID/Table ID\n") | |
7c8ff89e | 16217 | { |
585f1adc IR |
16218 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16219 | int idx_ospf_table = 1; | |
d62a17ae | 16220 | int idx_number = 2; |
585f1adc IR |
16221 | unsigned short instance; |
16222 | unsigned short protocol; | |
7c8ff89e | 16223 | |
585f1adc | 16224 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 16225 | |
585f1adc IR |
16226 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16227 | protocol = ZEBRA_ROUTE_OSPF; | |
16228 | else | |
16229 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 16230 | |
585f1adc IR |
16231 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16232 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
16233 | } |
16234 | ||
d62a17ae | 16235 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
16236 | "redistribute <ospf|table> (1-65535)", | |
16237 | "Redistribute information from another routing protocol\n" | |
16238 | "Open Shortest Path First (OSPFv2)\n" | |
16239 | "Non-main Kernel Routing Table\n" | |
16240 | "Instance ID/Table ID\n") | |
596c17ba | 16241 | |
585f1adc IR |
16242 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
16243 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
70dd370f | 16244 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
585f1adc IR |
16245 | "Redistribute information from another routing protocol\n" |
16246 | "Open Shortest Path First (OSPFv2)\n" | |
16247 | "Non-main Kernel Routing Table\n" | |
16248 | "Instance ID/Table ID\n" | |
16249 | "Route map reference\n" | |
16250 | "Pointer to route-map entries\n") | |
7c8ff89e | 16251 | { |
585f1adc IR |
16252 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16253 | int idx_ospf_table = 1; | |
d62a17ae | 16254 | int idx_number = 2; |
16255 | int idx_word = 4; | |
585f1adc IR |
16256 | struct bgp_redist *red; |
16257 | unsigned short instance; | |
16258 | int protocol; | |
16259 | bool changed; | |
16260 | struct route_map *route_map = | |
16261 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16262 | ||
16263 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16264 | protocol = ZEBRA_ROUTE_OSPF; | |
16265 | else | |
16266 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16267 | |
585f1adc IR |
16268 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16269 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
16270 | changed = | |
16271 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16272 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16273 | } |
16274 | ||
16275 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
16276 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
70dd370f | 16277 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
d62a17ae | 16278 | "Redistribute information from another routing protocol\n" |
16279 | "Open Shortest Path First (OSPFv2)\n" | |
16280 | "Non-main Kernel Routing Table\n" | |
16281 | "Instance ID/Table ID\n" | |
16282 | "Route map reference\n" | |
16283 | "Pointer to route-map entries\n") | |
596c17ba | 16284 | |
585f1adc IR |
16285 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
16286 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
16287 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16288 | "Redistribute information from another routing protocol\n" | |
16289 | "Open Shortest Path First (OSPFv2)\n" | |
16290 | "Non-main Kernel Routing Table\n" | |
16291 | "Instance ID/Table ID\n" | |
16292 | "Metric for redistributed routes\n" | |
16293 | "Default metric\n") | |
7c8ff89e | 16294 | { |
585f1adc IR |
16295 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16296 | int idx_ospf_table = 1; | |
d62a17ae | 16297 | int idx_number = 2; |
16298 | int idx_number_2 = 4; | |
585f1adc IR |
16299 | uint32_t metric; |
16300 | struct bgp_redist *red; | |
16301 | unsigned short instance; | |
16302 | int protocol; | |
16303 | bool changed; | |
16304 | ||
16305 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16306 | protocol = ZEBRA_ROUTE_OSPF; | |
16307 | else | |
16308 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16309 | |
585f1adc IR |
16310 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16311 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16312 | |
585f1adc IR |
16313 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16314 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16315 | metric); | |
16316 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16317 | } |
16318 | ||
16319 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
16320 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
16321 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16322 | "Redistribute information from another routing protocol\n" | |
16323 | "Open Shortest Path First (OSPFv2)\n" | |
16324 | "Non-main Kernel Routing Table\n" | |
16325 | "Instance ID/Table ID\n" | |
16326 | "Metric for redistributed routes\n" | |
16327 | "Default metric\n") | |
596c17ba | 16328 | |
585f1adc IR |
16329 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
16330 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
70dd370f | 16331 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16332 | "Redistribute information from another routing protocol\n" |
16333 | "Open Shortest Path First (OSPFv2)\n" | |
16334 | "Non-main Kernel Routing Table\n" | |
16335 | "Instance ID/Table ID\n" | |
16336 | "Route map reference\n" | |
16337 | "Pointer to route-map entries\n" | |
16338 | "Metric for redistributed routes\n" | |
16339 | "Default metric\n") | |
7c8ff89e | 16340 | { |
585f1adc IR |
16341 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16342 | int idx_ospf_table = 1; | |
d62a17ae | 16343 | int idx_number = 2; |
16344 | int idx_word = 4; | |
16345 | int idx_number_2 = 6; | |
585f1adc IR |
16346 | uint32_t metric; |
16347 | struct bgp_redist *red; | |
16348 | unsigned short instance; | |
16349 | int protocol; | |
16350 | bool changed; | |
16351 | struct route_map *route_map = | |
16352 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16353 | ||
16354 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16355 | protocol = ZEBRA_ROUTE_OSPF; | |
16356 | else | |
16357 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16358 | |
585f1adc IR |
16359 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16360 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16361 | |
585f1adc IR |
16362 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16363 | changed = | |
16364 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16365 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16366 | metric); | |
16367 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16368 | } |
16369 | ||
16370 | ALIAS_HIDDEN( | |
16371 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
16372 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
70dd370f | 16373 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16374 | "Redistribute information from another routing protocol\n" |
16375 | "Open Shortest Path First (OSPFv2)\n" | |
16376 | "Non-main Kernel Routing Table\n" | |
16377 | "Instance ID/Table ID\n" | |
16378 | "Route map reference\n" | |
16379 | "Pointer to route-map entries\n" | |
16380 | "Metric for redistributed routes\n" | |
16381 | "Default metric\n") | |
596c17ba | 16382 | |
585f1adc IR |
16383 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
16384 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
70dd370f | 16385 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16386 | "Redistribute information from another routing protocol\n" |
16387 | "Open Shortest Path First (OSPFv2)\n" | |
16388 | "Non-main Kernel Routing Table\n" | |
16389 | "Instance ID/Table ID\n" | |
16390 | "Metric for redistributed routes\n" | |
16391 | "Default metric\n" | |
16392 | "Route map reference\n" | |
16393 | "Pointer to route-map entries\n") | |
7c8ff89e | 16394 | { |
585f1adc IR |
16395 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16396 | int idx_ospf_table = 1; | |
d62a17ae | 16397 | int idx_number = 2; |
16398 | int idx_number_2 = 4; | |
16399 | int idx_word = 6; | |
585f1adc IR |
16400 | uint32_t metric; |
16401 | struct bgp_redist *red; | |
16402 | unsigned short instance; | |
16403 | int protocol; | |
16404 | bool changed; | |
16405 | struct route_map *route_map = | |
16406 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16407 | ||
16408 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16409 | protocol = ZEBRA_ROUTE_OSPF; | |
16410 | else | |
16411 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16412 | |
585f1adc IR |
16413 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16414 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16415 | |
585f1adc IR |
16416 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16417 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16418 | metric); | |
16419 | changed |= | |
16420 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16421 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16422 | } |
16423 | ||
16424 | ALIAS_HIDDEN( | |
16425 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
16426 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
70dd370f | 16427 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16428 | "Redistribute information from another routing protocol\n" |
16429 | "Open Shortest Path First (OSPFv2)\n" | |
16430 | "Non-main Kernel Routing Table\n" | |
16431 | "Instance ID/Table ID\n" | |
16432 | "Metric for redistributed routes\n" | |
16433 | "Default metric\n" | |
16434 | "Route map reference\n" | |
16435 | "Pointer to route-map entries\n") | |
596c17ba | 16436 | |
585f1adc IR |
16437 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
16438 | no_bgp_redistribute_ipv4_ospf_cmd, | |
70dd370f | 16439 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16440 | NO_STR |
16441 | "Redistribute information from another routing protocol\n" | |
16442 | "Open Shortest Path First (OSPFv2)\n" | |
16443 | "Non-main Kernel Routing Table\n" | |
16444 | "Instance ID/Table ID\n" | |
16445 | "Metric for redistributed routes\n" | |
16446 | "Default metric\n" | |
16447 | "Route map reference\n" | |
16448 | "Pointer to route-map entries\n") | |
7c8ff89e | 16449 | { |
585f1adc IR |
16450 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16451 | int idx_ospf_table = 2; | |
d62a17ae | 16452 | int idx_number = 3; |
585f1adc IR |
16453 | unsigned short instance; |
16454 | int protocol; | |
37a87b8f | 16455 | |
585f1adc IR |
16456 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16457 | protocol = ZEBRA_ROUTE_OSPF; | |
16458 | else | |
16459 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16460 | |
585f1adc IR |
16461 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16462 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 16463 | } |
16464 | ||
16465 | ALIAS_HIDDEN( | |
16466 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
70dd370f | 16467 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16468 | NO_STR |
16469 | "Redistribute information from another routing protocol\n" | |
16470 | "Open Shortest Path First (OSPFv2)\n" | |
16471 | "Non-main Kernel Routing Table\n" | |
16472 | "Instance ID/Table ID\n" | |
16473 | "Metric for redistributed routes\n" | |
16474 | "Default metric\n" | |
16475 | "Route map reference\n" | |
16476 | "Pointer to route-map entries\n") | |
596c17ba | 16477 | |
585f1adc IR |
16478 | DEFUN (no_bgp_redistribute_ipv4, |
16479 | no_bgp_redistribute_ipv4_cmd, | |
70dd370f | 16480 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16481 | NO_STR |
16482 | "Redistribute information from another routing protocol\n" | |
16483 | FRR_IP_REDIST_HELP_STR_BGPD | |
16484 | "Metric for redistributed routes\n" | |
16485 | "Default metric\n" | |
16486 | "Route map reference\n" | |
16487 | "Pointer to route-map entries\n") | |
718e3744 | 16488 | { |
585f1adc | 16489 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16490 | int idx_protocol = 2; |
585f1adc | 16491 | int type; |
d62a17ae | 16492 | |
585f1adc IR |
16493 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
16494 | if (type < 0) { | |
16495 | vty_out(vty, "%% Invalid route type\n"); | |
16496 | return CMD_WARNING_CONFIG_FAILED; | |
16497 | } | |
16498 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 16499 | } |
16500 | ||
16501 | ALIAS_HIDDEN( | |
16502 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
16503 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16504 | " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16505 | NO_STR |
16506 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16507 | "Metric for redistributed routes\n" | |
16508 | "Default metric\n" | |
16509 | "Route map reference\n" | |
16510 | "Pointer to route-map entries\n") | |
596c17ba | 16511 | |
585f1adc IR |
16512 | DEFUN (bgp_redistribute_ipv6, |
16513 | bgp_redistribute_ipv6_cmd, | |
16514 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
16515 | "Redistribute information from another routing protocol\n" | |
16516 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 16517 | { |
585f1adc | 16518 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16519 | int idx_protocol = 1; |
585f1adc | 16520 | int type; |
718e3744 | 16521 | |
585f1adc IR |
16522 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16523 | if (type < 0) { | |
16524 | vty_out(vty, "%% Invalid route type\n"); | |
16525 | return CMD_WARNING_CONFIG_FAILED; | |
16526 | } | |
718e3744 | 16527 | |
585f1adc IR |
16528 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
16529 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 16530 | } |
16531 | ||
585f1adc IR |
16532 | DEFUN (bgp_redistribute_ipv6_rmap, |
16533 | bgp_redistribute_ipv6_rmap_cmd, | |
70dd370f | 16534 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16535 | "Redistribute information from another routing protocol\n" |
16536 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16537 | "Route map reference\n" | |
16538 | "Pointer to route-map entries\n") | |
718e3744 | 16539 | { |
585f1adc | 16540 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16541 | int idx_protocol = 1; |
16542 | int idx_word = 3; | |
585f1adc IR |
16543 | int type; |
16544 | struct bgp_redist *red; | |
16545 | bool changed; | |
16546 | struct route_map *route_map = | |
16547 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16548 | ||
16549 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16550 | if (type < 0) { | |
16551 | vty_out(vty, "%% Invalid route type\n"); | |
16552 | return CMD_WARNING_CONFIG_FAILED; | |
16553 | } | |
37a87b8f | 16554 | |
585f1adc IR |
16555 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16556 | changed = | |
16557 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16558 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16559 | } |
16560 | ||
585f1adc | 16561 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 16562 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16563 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16564 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16565 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16566 | "Metric for redistributed routes\n" |
16567 | "Default metric\n") | |
16568 | { | |
585f1adc | 16569 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16570 | int idx_protocol = 1; |
16571 | int idx_number = 3; | |
585f1adc IR |
16572 | int type; |
16573 | uint32_t metric; | |
16574 | struct bgp_redist *red; | |
16575 | bool changed; | |
16576 | ||
16577 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16578 | if (type < 0) { | |
16579 | vty_out(vty, "%% Invalid route type\n"); | |
16580 | return CMD_WARNING_CONFIG_FAILED; | |
16581 | } | |
16582 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16583 | |
585f1adc IR |
16584 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16585 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
16586 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16587 | } |
16588 | ||
585f1adc IR |
16589 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
16590 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
70dd370f | 16591 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16592 | "Redistribute information from another routing protocol\n" |
16593 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16594 | "Route map reference\n" | |
16595 | "Pointer to route-map entries\n" | |
16596 | "Metric for redistributed routes\n" | |
16597 | "Default metric\n") | |
718e3744 | 16598 | { |
585f1adc | 16599 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16600 | int idx_protocol = 1; |
16601 | int idx_word = 3; | |
16602 | int idx_number = 5; | |
585f1adc IR |
16603 | int type; |
16604 | uint32_t metric; | |
16605 | struct bgp_redist *red; | |
16606 | bool changed; | |
16607 | struct route_map *route_map = | |
16608 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16609 | ||
16610 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16611 | if (type < 0) { | |
16612 | vty_out(vty, "%% Invalid route type\n"); | |
16613 | return CMD_WARNING_CONFIG_FAILED; | |
16614 | } | |
16615 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16616 | |
585f1adc IR |
16617 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16618 | changed = | |
16619 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16620 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
16621 | metric); | |
16622 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16623 | } |
16624 | ||
585f1adc IR |
16625 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
16626 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
70dd370f | 16627 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16628 | "Redistribute information from another routing protocol\n" |
16629 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16630 | "Metric for redistributed routes\n" | |
16631 | "Default metric\n" | |
16632 | "Route map reference\n" | |
16633 | "Pointer to route-map entries\n") | |
718e3744 | 16634 | { |
585f1adc | 16635 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16636 | int idx_protocol = 1; |
37a87b8f | 16637 | int idx_number = 3; |
585f1adc IR |
16638 | int idx_word = 5; |
16639 | int type; | |
16640 | uint32_t metric; | |
16641 | struct bgp_redist *red; | |
16642 | bool changed; | |
16643 | struct route_map *route_map = | |
16644 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16645 | ||
16646 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16647 | if (type < 0) { | |
16648 | vty_out(vty, "%% Invalid route type\n"); | |
16649 | return CMD_WARNING_CONFIG_FAILED; | |
16650 | } | |
16651 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16652 | |
585f1adc IR |
16653 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16654 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
16655 | metric); | |
16656 | changed |= | |
16657 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16658 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16659 | } |
16660 | ||
585f1adc IR |
16661 | DEFUN (no_bgp_redistribute_ipv6, |
16662 | no_bgp_redistribute_ipv6_cmd, | |
70dd370f | 16663 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16664 | NO_STR |
16665 | "Redistribute information from another routing protocol\n" | |
16666 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16667 | "Metric for redistributed routes\n" | |
16668 | "Default metric\n" | |
16669 | "Route map reference\n" | |
16670 | "Pointer to route-map entries\n") | |
718e3744 | 16671 | { |
585f1adc | 16672 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16673 | int idx_protocol = 2; |
585f1adc | 16674 | int type; |
37a87b8f | 16675 | |
585f1adc IR |
16676 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16677 | if (type < 0) { | |
16678 | vty_out(vty, "%% Invalid route type\n"); | |
16679 | return CMD_WARNING_CONFIG_FAILED; | |
16680 | } | |
718e3744 | 16681 | |
585f1adc | 16682 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 16683 | } |
16684 | ||
4ab46701 AR |
16685 | /* Neighbor update tcp-mss. */ |
16686 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16687 | const char *tcp_mss_str) | |
16688 | { | |
16689 | struct peer *peer; | |
16690 | uint32_t tcp_mss_val = 0; | |
16691 | ||
16692 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16693 | if (!peer) | |
16694 | return CMD_WARNING_CONFIG_FAILED; | |
16695 | ||
16696 | if (tcp_mss_str) { | |
16697 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16698 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16699 | } else { | |
16700 | peer_tcp_mss_unset(peer); | |
16701 | } | |
16702 | ||
16703 | return CMD_SUCCESS; | |
16704 | } | |
16705 | ||
16706 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16707 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16708 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16709 | "TCP max segment size\n" | |
16710 | "TCP MSS value\n") | |
16711 | { | |
16712 | int peer_index = 1; | |
16713 | int mss_index = 3; | |
16714 | ||
16715 | vty_out(vty, | |
16716 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16717 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16718 | argv[mss_index]->arg); | |
16719 | } | |
16720 | ||
16721 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16722 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16723 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16724 | "TCP max segment size\n" | |
16725 | "TCP MSS value\n") | |
16726 | { | |
16727 | int peer_index = 2; | |
16728 | ||
16729 | vty_out(vty, | |
16730 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16731 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16732 | } | |
16733 | ||
a486300b PG |
16734 | DEFPY(bgp_retain_route_target, bgp_retain_route_target_cmd, |
16735 | "[no$no] bgp retain route-target all", | |
16736 | NO_STR BGP_STR | |
16737 | "Retain BGP updates\n" | |
16738 | "Retain BGP updates based on route-target values\n" | |
16739 | "Retain all BGP updates\n") | |
16740 | { | |
16741 | bool check; | |
16742 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
16743 | ||
16744 | check = CHECK_FLAG(bgp->af_flags[bgp_node_afi(vty)][bgp_node_safi(vty)], | |
16745 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16746 | if (check != !no) { | |
16747 | if (!no) | |
16748 | SET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16749 | [bgp_node_safi(vty)], | |
16750 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16751 | else | |
16752 | UNSET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16753 | [bgp_node_safi(vty)], | |
16754 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16755 | /* trigger a flush to re-sync with ADJ-RIB-in */ | |
16756 | bgp_clear(vty, bgp, bgp_node_afi(vty), bgp_node_safi(vty), | |
16757 | clear_all, BGP_CLEAR_SOFT_IN, NULL); | |
16758 | } | |
16759 | return CMD_SUCCESS; | |
16760 | } | |
16761 | ||
dd65f45e DL |
16762 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16763 | afi_t afi, safi_t safi) | |
d62a17ae | 16764 | { |
16765 | int i; | |
16766 | ||
16767 | /* Unicast redistribution only. */ | |
16768 | if (safi != SAFI_UNICAST) | |
2b791107 | 16769 | return; |
d62a17ae | 16770 | |
16771 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16772 | /* Redistribute BGP does not make sense. */ | |
16773 | if (i != ZEBRA_ROUTE_BGP) { | |
16774 | struct list *red_list; | |
16775 | struct listnode *node; | |
16776 | struct bgp_redist *red; | |
16777 | ||
16778 | red_list = bgp->redist[afi][i]; | |
16779 | if (!red_list) | |
16780 | continue; | |
16781 | ||
16782 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16783 | /* "redistribute" configuration. */ |
16784 | vty_out(vty, " redistribute %s", | |
16785 | zebra_route_string(i)); | |
16786 | if (red->instance) | |
16787 | vty_out(vty, " %d", red->instance); | |
16788 | if (red->redist_metric_flag) | |
16789 | vty_out(vty, " metric %u", | |
16790 | red->redist_metric); | |
16791 | if (red->rmap.name) | |
16792 | vty_out(vty, " route-map %s", | |
16793 | red->rmap.name); | |
16794 | vty_out(vty, "\n"); | |
16795 | } | |
16796 | } | |
16797 | } | |
718e3744 | 16798 | } |
6b0655a2 | 16799 | |
dd65f45e DL |
16800 | /* peer-group helpers for config-write */ |
16801 | ||
83194f39 | 16802 | static bool peergroup_flag_check(struct peer *peer, uint64_t flag) |
dd65f45e DL |
16803 | { |
16804 | if (!peer_group_active(peer)) { | |
16805 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16806 | return !CHECK_FLAG(peer->flags, flag); | |
16807 | else | |
16808 | return !!CHECK_FLAG(peer->flags, flag); | |
16809 | } | |
16810 | ||
16811 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16812 | } | |
16813 | ||
16814 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
da5e1a58 | 16815 | uint64_t flag) |
dd65f45e DL |
16816 | { |
16817 | if (!peer_group_active(peer)) { | |
16818 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16819 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16820 | else | |
16821 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16822 | } | |
16823 | ||
16824 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16825 | } | |
16826 | ||
16827 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16828 | uint8_t type, int direct) | |
16829 | { | |
16830 | struct bgp_filter *filter; | |
16831 | ||
16832 | if (peer_group_active(peer)) | |
16833 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16834 | type); | |
16835 | ||
16836 | filter = &peer->filter[afi][safi]; | |
16837 | switch (type) { | |
16838 | case PEER_FT_DISTRIBUTE_LIST: | |
16839 | return !!(filter->dlist[direct].name); | |
16840 | case PEER_FT_FILTER_LIST: | |
16841 | return !!(filter->aslist[direct].name); | |
16842 | case PEER_FT_PREFIX_LIST: | |
16843 | return !!(filter->plist[direct].name); | |
16844 | case PEER_FT_ROUTE_MAP: | |
16845 | return !!(filter->map[direct].name); | |
16846 | case PEER_FT_UNSUPPRESS_MAP: | |
16847 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16848 | case PEER_FT_ADVERTISE_MAP: |
16849 | return !!(filter->advmap.aname | |
16850 | && ((filter->advmap.condition == direct) | |
16851 | && filter->advmap.cname)); | |
dd65f45e DL |
16852 | default: |
16853 | return false; | |
16854 | } | |
16855 | } | |
16856 | ||
16857 | /* Return true if the addpath type is set for peer and different from | |
16858 | * peer-group. | |
16859 | */ | |
3dc339cd DA |
16860 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16861 | safi_t safi) | |
dd65f45e DL |
16862 | { |
16863 | enum bgp_addpath_strat type, g_type; | |
16864 | ||
16865 | type = peer->addpath_type[afi][safi]; | |
16866 | ||
16867 | if (type != BGP_ADDPATH_NONE) { | |
16868 | if (peer_group_active(peer)) { | |
16869 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16870 | ||
16871 | if (type != g_type) | |
3dc339cd | 16872 | return true; |
dd65f45e | 16873 | else |
3dc339cd | 16874 | return false; |
dd65f45e DL |
16875 | } |
16876 | ||
3dc339cd | 16877 | return true; |
dd65f45e DL |
16878 | } |
16879 | ||
3dc339cd | 16880 | return false; |
dd65f45e DL |
16881 | } |
16882 | ||
b9c7bc5a | 16883 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16884 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16885 | afi_t afi) |
16886 | { | |
b9c7bc5a | 16887 | int indent = 2; |
53970de3 | 16888 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16889 | |
8a066a70 | 16890 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16891 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16892 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16893 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16894 | bgp->vpn_policy[afi] | |
bb4f6190 | 16895 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16896 | else |
16897 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16898 | bgp->vpn_policy[afi] | |
16899 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16900 | } | |
12a844a5 DS |
16901 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16902 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16903 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16904 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16905 | return; | |
16906 | ||
e70e9f8e PZ |
16907 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16908 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16909 | ||
16910 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16911 | ||
16912 | } else { | |
16913 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16914 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16915 | bgp->vpn_policy[afi].tovpn_label); | |
16916 | } | |
ddb5b488 | 16917 | } |
53970de3 RS |
16918 | |
16919 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16920 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16921 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16922 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16923 | } else if (tovpn_sid_index != 0) { | |
16924 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16925 | tovpn_sid_index); | |
16926 | } | |
16927 | ||
c4f64ea9 DA |
16928 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_RD_SET)) |
16929 | vty_out(vty, "%*srd vpn export %pRD\n", indent, "", | |
16930 | &bgp->vpn_policy[afi].tovpn_rd); | |
16931 | ||
ddb5b488 PZ |
16932 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16933 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16934 | ||
16935 | char buf[PREFIX_STRLEN]; | |
16936 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16937 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16938 | sizeof(buf))) { | |
16939 | ||
b9c7bc5a PZ |
16940 | vty_out(vty, "%*snexthop vpn export %s\n", |
16941 | indent, "", buf); | |
ddb5b488 PZ |
16942 | } |
16943 | } | |
16944 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16945 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16946 | && ecommunity_cmp( | |
16947 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16948 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16949 | ||
16950 | char *b = ecommunity_ecom2str( | |
16951 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16952 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16953 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16954 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16955 | } else { | |
16956 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16957 | char *b = ecommunity_ecom2str( | |
16958 | bgp->vpn_policy[afi] | |
16959 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16960 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16961 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16962 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16963 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16964 | } | |
16965 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16966 | char *b = ecommunity_ecom2str( | |
16967 | bgp->vpn_policy[afi] | |
16968 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16969 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16970 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16971 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16972 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16973 | } | |
16974 | } | |
bb4f6190 DS |
16975 | |
16976 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16977 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16978 | bgp->vpn_policy[afi] |
16979 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16980 | |
301ad80a PG |
16981 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16982 | char *b = ecommunity_ecom2str( | |
16983 | bgp->vpn_policy[afi] | |
16984 | .import_redirect_rtlist, | |
16985 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16986 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16987 | |
9a659715 PG |
16988 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16989 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16990 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16991 | indent, "", b); |
16992 | else | |
16993 | vty_out(vty, "%*srt redirect import %s\n", | |
16994 | indent, "", b); | |
301ad80a PG |
16995 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16996 | } | |
ddb5b488 PZ |
16997 | } |
16998 | ||
dd65f45e DL |
16999 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
17000 | afi_t afi, safi_t safi) | |
17001 | { | |
17002 | struct bgp_filter *filter; | |
17003 | char *addr; | |
17004 | ||
17005 | addr = peer->host; | |
17006 | filter = &peer->filter[afi][safi]; | |
17007 | ||
17008 | /* distribute-list. */ | |
17009 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17010 | FILTER_IN)) | |
17011 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
17012 | filter->dlist[FILTER_IN].name); | |
17013 | ||
17014 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17015 | FILTER_OUT)) | |
17016 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
17017 | filter->dlist[FILTER_OUT].name); | |
17018 | ||
17019 | /* prefix-list. */ | |
17020 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17021 | FILTER_IN)) | |
17022 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
17023 | filter->plist[FILTER_IN].name); | |
17024 | ||
17025 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17026 | FILTER_OUT)) | |
17027 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
17028 | filter->plist[FILTER_OUT].name); | |
17029 | ||
17030 | /* route-map. */ | |
17031 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
17032 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
17033 | filter->map[RMAP_IN].name); | |
17034 | ||
17035 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
17036 | RMAP_OUT)) | |
17037 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
17038 | filter->map[RMAP_OUT].name); | |
17039 | ||
17040 | /* unsuppress-map */ | |
17041 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
17042 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
17043 | filter->usmap.name); | |
17044 | ||
7f7940e6 MK |
17045 | /* advertise-map : always applied in OUT direction*/ |
17046 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17047 | CONDITION_NON_EXIST)) | |
17048 | vty_out(vty, | |
17049 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
17050 | addr, filter->advmap.aname, filter->advmap.cname); | |
17051 | ||
17052 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17053 | CONDITION_EXIST)) | |
17054 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
17055 | addr, filter->advmap.aname, filter->advmap.cname); | |
17056 | ||
dd65f45e DL |
17057 | /* filter-list. */ |
17058 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17059 | FILTER_IN)) | |
17060 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
17061 | filter->aslist[FILTER_IN].name); | |
17062 | ||
17063 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17064 | FILTER_OUT)) | |
17065 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
17066 | filter->aslist[FILTER_OUT].name); | |
17067 | } | |
17068 | ||
17069 | /* BGP peer configuration display function. */ | |
17070 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
17071 | struct peer *peer) | |
17072 | { | |
17073 | struct peer *g_peer = NULL; | |
dd65f45e DL |
17074 | char *addr; |
17075 | int if_pg_printed = false; | |
17076 | int if_ras_printed = false; | |
17077 | ||
17078 | /* Skip dynamic neighbors. */ | |
17079 | if (peer_dynamic_neighbor(peer)) | |
17080 | return; | |
17081 | ||
17082 | if (peer->conf_if) | |
17083 | addr = peer->conf_if; | |
17084 | else | |
17085 | addr = peer->host; | |
17086 | ||
17087 | /************************************ | |
17088 | ****** Global to the neighbor ****** | |
17089 | ************************************/ | |
17090 | if (peer->conf_if) { | |
17091 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
17092 | vty_out(vty, " neighbor %s interface v6only", addr); | |
17093 | else | |
17094 | vty_out(vty, " neighbor %s interface", addr); | |
17095 | ||
17096 | if (peer_group_active(peer)) { | |
17097 | vty_out(vty, " peer-group %s", peer->group->name); | |
17098 | if_pg_printed = true; | |
17099 | } else if (peer->as_type == AS_SPECIFIED) { | |
17100 | vty_out(vty, " remote-as %u", peer->as); | |
17101 | if_ras_printed = true; | |
17102 | } else if (peer->as_type == AS_INTERNAL) { | |
17103 | vty_out(vty, " remote-as internal"); | |
17104 | if_ras_printed = true; | |
17105 | } else if (peer->as_type == AS_EXTERNAL) { | |
17106 | vty_out(vty, " remote-as external"); | |
17107 | if_ras_printed = true; | |
17108 | } | |
17109 | ||
17110 | vty_out(vty, "\n"); | |
17111 | } | |
17112 | ||
17113 | /* remote-as and peer-group */ | |
17114 | /* peer is a member of a peer-group */ | |
17115 | if (peer_group_active(peer)) { | |
17116 | g_peer = peer->group->conf; | |
17117 | ||
17118 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
17119 | if (peer->as_type == AS_SPECIFIED) { | |
17120 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17121 | addr, peer->as); | |
17122 | } else if (peer->as_type == AS_INTERNAL) { | |
17123 | vty_out(vty, | |
17124 | " neighbor %s remote-as internal\n", | |
17125 | addr); | |
17126 | } else if (peer->as_type == AS_EXTERNAL) { | |
17127 | vty_out(vty, | |
17128 | " neighbor %s remote-as external\n", | |
17129 | addr); | |
17130 | } | |
17131 | } | |
17132 | ||
17133 | /* For swpX peers we displayed the peer-group | |
17134 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
17135 | if (!if_pg_printed) | |
17136 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
17137 | peer->group->name); | |
17138 | } | |
17139 | ||
17140 | /* peer is NOT a member of a peer-group */ | |
17141 | else { | |
17142 | /* peer is a peer-group, declare the peer-group */ | |
17143 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
17144 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
17145 | } | |
17146 | ||
17147 | if (!if_ras_printed) { | |
17148 | if (peer->as_type == AS_SPECIFIED) { | |
17149 | vty_out(vty, " neighbor %s remote-as %u\n", | |
17150 | addr, peer->as); | |
17151 | } else if (peer->as_type == AS_INTERNAL) { | |
17152 | vty_out(vty, | |
17153 | " neighbor %s remote-as internal\n", | |
17154 | addr); | |
17155 | } else if (peer->as_type == AS_EXTERNAL) { | |
17156 | vty_out(vty, | |
17157 | " neighbor %s remote-as external\n", | |
17158 | addr); | |
17159 | } | |
17160 | } | |
17161 | } | |
17162 | ||
17163 | /* local-as */ | |
17164 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
17165 | vty_out(vty, " neighbor %s local-as %u", addr, | |
17166 | peer->change_local_as); | |
17167 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
17168 | vty_out(vty, " no-prepend"); | |
17169 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
17170 | vty_out(vty, " replace-as"); | |
17171 | vty_out(vty, "\n"); | |
17172 | } | |
17173 | ||
17174 | /* description */ | |
17175 | if (peer->desc) { | |
17176 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
17177 | } | |
17178 | ||
17179 | /* shutdown */ | |
17180 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
17181 | if (peer->tx_shutdown_message) | |
17182 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
17183 | peer->tx_shutdown_message); | |
17184 | else | |
17185 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
17186 | } | |
17187 | ||
8336c896 DA |
17188 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
17189 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
17190 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
17191 | ||
dd65f45e | 17192 | /* bfd */ |
21bfce98 RZ |
17193 | if (peer->bfd_config) |
17194 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
17195 | |
17196 | /* password */ | |
17197 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
17198 | vty_out(vty, " neighbor %s password %s\n", addr, | |
17199 | peer->password); | |
17200 | ||
17201 | /* neighbor solo */ | |
17202 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
17203 | if (!peer_group_active(peer)) { | |
17204 | vty_out(vty, " neighbor %s solo\n", addr); | |
17205 | } | |
17206 | } | |
17207 | ||
17208 | /* BGP port */ | |
17209 | if (peer->port != BGP_PORT_DEFAULT) { | |
17210 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
17211 | } | |
17212 | ||
17213 | /* Local interface name */ | |
17214 | if (peer->ifname) { | |
17215 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
17216 | } | |
17217 | ||
4ab46701 AR |
17218 | /* TCP max segment size */ |
17219 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
17220 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
17221 | ||
dd65f45e DL |
17222 | /* passive */ |
17223 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
17224 | vty_out(vty, " neighbor %s passive\n", addr); | |
17225 | ||
17226 | /* ebgp-multihop */ | |
17227 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
17228 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
17229 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
17230 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
17231 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
17232 | peer->ttl); | |
17233 | } | |
17234 | } | |
17235 | ||
97a52c82 DA |
17236 | /* aigp */ |
17237 | if (peergroup_flag_check(peer, PEER_FLAG_AIGP)) | |
17238 | vty_out(vty, " neighbor %s aigp\n", addr); | |
17239 | ||
4f770cf1 DA |
17240 | /* graceful-shutdown */ |
17241 | if (peergroup_flag_check(peer, PEER_FLAG_GRACEFUL_SHUTDOWN)) | |
17242 | vty_out(vty, " neighbor %s graceful-shutdown\n", addr); | |
17243 | ||
d864dd9e | 17244 | /* role */ |
7dddd1f7 DA |
17245 | if (peergroup_flag_check(peer, PEER_FLAG_ROLE) && |
17246 | peer->local_role != ROLE_UNDEFINED) | |
d864dd9e | 17247 | vty_out(vty, " neighbor %s local-role %s%s\n", addr, |
8f2d6021 | 17248 | bgp_get_name_by_role(peer->local_role), |
7dddd1f7 | 17249 | CHECK_FLAG(peer->flags, PEER_FLAG_ROLE_STRICT_MODE) |
d864dd9e EB |
17250 | ? " strict-mode" |
17251 | : ""); | |
d864dd9e | 17252 | |
dd65f45e | 17253 | /* ttl-security hops */ |
e2521429 | 17254 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
17255 | if (!peer_group_active(peer) |
17256 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
17257 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
17258 | addr, peer->gtsm_hops); | |
17259 | } | |
17260 | } | |
17261 | ||
17262 | /* disable-connected-check */ | |
17263 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
17264 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
17265 | ||
27aa23a4 DA |
17266 | /* link-bw-encoding-ieee */ |
17267 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
17268 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
17269 | addr); | |
17270 | ||
d08c0c80 DA |
17271 | /* extended-optional-parameters */ |
17272 | if (peergroup_flag_check(peer, PEER_FLAG_EXTENDED_OPT_PARAMS)) | |
17273 | vty_out(vty, " neighbor %s extended-optional-parameters\n", | |
17274 | addr); | |
17275 | ||
dd65f45e DL |
17276 | /* enforce-first-as */ |
17277 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
17278 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
17279 | ||
17280 | /* update-source */ | |
17281 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
17282 | if (peer->update_source) | |
47e12884 DA |
17283 | vty_out(vty, " neighbor %s update-source %pSU\n", addr, |
17284 | peer->update_source); | |
dd65f45e DL |
17285 | else if (peer->update_if) |
17286 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
17287 | peer->update_if); | |
17288 | } | |
17289 | ||
17290 | /* advertisement-interval */ | |
17291 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
17292 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
17293 | peer->routeadv); | |
17294 | ||
17295 | /* timers */ | |
17296 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
17297 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
17298 | peer->keepalive, peer->holdtime); | |
17299 | ||
17300 | /* timers connect */ | |
17301 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
17302 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17303 | peer->connect); | |
5d5393b9 DL |
17304 | /* need special-case handling for changed default values due to |
17305 | * config profile / version (because there is no "timers bgp connect" | |
17306 | * command, we need to save this per-peer :/) | |
17307 | */ | |
17308 | else if (!peer_group_active(peer) && !peer->connect && | |
17309 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
17310 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17311 | peer->bgp->default_connect_retry); | |
dd65f45e | 17312 | |
d43114f3 DS |
17313 | /* timers delayopen */ |
17314 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
17315 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17316 | peer->delayopen); | |
17317 | /* Save config even though flag is not set if default values have been | |
17318 | * changed | |
17319 | */ | |
17320 | else if (!peer_group_active(peer) && !peer->delayopen | |
17321 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
17322 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17323 | peer->bgp->default_delayopen); | |
17324 | ||
dd65f45e DL |
17325 | /* capability dynamic */ |
17326 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
17327 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
17328 | ||
17329 | /* capability extended-nexthop */ | |
17330 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
8e89adc1 DS |
17331 | if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE) && |
17332 | !peer->conf_if) | |
843770f6 DA |
17333 | vty_out(vty, |
17334 | " no neighbor %s capability extended-nexthop\n", | |
17335 | addr); | |
17336 | else if (!peer->conf_if) | |
17337 | vty_out(vty, | |
17338 | " neighbor %s capability extended-nexthop\n", | |
17339 | addr); | |
dd65f45e DL |
17340 | } |
17341 | ||
17342 | /* dont-capability-negotiation */ | |
17343 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
17344 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
17345 | ||
17346 | /* override-capability */ | |
17347 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
17348 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
17349 | ||
17350 | /* strict-capability-match */ | |
17351 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
17352 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
17353 | ||
17354 | /* Sender side AS path loop detection. */ | |
17355 | if (peer->as_path_loop_detection) | |
17356 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
17357 | addr); | |
cfd47646 | 17358 | |
17359 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17360 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 17361 | |
17362 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17363 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 17364 | vty_out(vty, |
17365 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
17366 | } else if (CHECK_FLAG( |
17367 | peer->peer_gr_new_status_flag, | |
17368 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 17369 | vty_out(vty, |
17370 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
17371 | } else if ( |
17372 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
17373 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
17374 | && !(CHECK_FLAG( | |
17375 | peer->peer_gr_new_status_flag, | |
17376 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
17377 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
17378 | addr); | |
cfd47646 | 17379 | } |
17380 | } | |
dd65f45e DL |
17381 | } |
17382 | ||
17383 | /* BGP peer configuration display function. */ | |
17384 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
17385 | struct peer *peer, afi_t afi, safi_t safi) | |
17386 | { | |
17387 | struct peer *g_peer = NULL; | |
17388 | char *addr; | |
17389 | bool flag_scomm, flag_secomm, flag_slcomm; | |
17390 | ||
17391 | /* Skip dynamic neighbors. */ | |
17392 | if (peer_dynamic_neighbor(peer)) | |
17393 | return; | |
17394 | ||
17395 | if (peer->conf_if) | |
17396 | addr = peer->conf_if; | |
17397 | else | |
17398 | addr = peer->host; | |
17399 | ||
17400 | /************************************ | |
17401 | ****** Per AF to the neighbor ****** | |
17402 | ************************************/ | |
17403 | if (peer_group_active(peer)) { | |
17404 | g_peer = peer->group->conf; | |
17405 | ||
17406 | /* If the peer-group is active but peer is not, print a 'no | |
17407 | * activate' */ | |
17408 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
17409 | vty_out(vty, " no neighbor %s activate\n", addr); | |
17410 | } | |
17411 | ||
17412 | /* If the peer-group is not active but peer is, print an | |
17413 | 'activate' */ | |
17414 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
17415 | vty_out(vty, " neighbor %s activate\n", addr); | |
17416 | } | |
17417 | } else { | |
17418 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
17419 | if (safi == SAFI_ENCAP) |
17420 | vty_out(vty, " neighbor %s activate\n", addr); | |
17421 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
17422 | vty_out(vty, " neighbor %s activate\n", addr); |
17423 | } else { | |
38d11af5 TA |
17424 | if (bgp->default_af[afi][safi]) |
17425 | vty_out(vty, " no neighbor %s activate\n", | |
17426 | addr); | |
dd65f45e DL |
17427 | } |
17428 | } | |
17429 | ||
17430 | /* addpath TX knobs */ | |
17431 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
17432 | switch (peer->addpath_type[afi][safi]) { | |
17433 | case BGP_ADDPATH_ALL: | |
17434 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
17435 | addr); | |
17436 | break; | |
17437 | case BGP_ADDPATH_BEST_PER_AS: | |
17438 | vty_out(vty, | |
17439 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
17440 | addr); | |
17441 | break; | |
17442 | case BGP_ADDPATH_MAX: | |
17443 | case BGP_ADDPATH_NONE: | |
17444 | break; | |
17445 | } | |
17446 | } | |
17447 | ||
7c0e4312 DA |
17448 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
17449 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
17450 | ||
dd65f45e DL |
17451 | /* ORF capability. */ |
17452 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
17453 | || peergroup_af_flag_check(peer, afi, safi, | |
17454 | PEER_FLAG_ORF_PREFIX_RM)) { | |
17455 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
17456 | ||
17457 | if (peergroup_af_flag_check(peer, afi, safi, | |
17458 | PEER_FLAG_ORF_PREFIX_SM) | |
17459 | && peergroup_af_flag_check(peer, afi, safi, | |
17460 | PEER_FLAG_ORF_PREFIX_RM)) | |
17461 | vty_out(vty, " both"); | |
17462 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17463 | PEER_FLAG_ORF_PREFIX_SM)) | |
17464 | vty_out(vty, " send"); | |
17465 | else | |
17466 | vty_out(vty, " receive"); | |
17467 | vty_out(vty, "\n"); | |
17468 | } | |
17469 | ||
dd65f45e DL |
17470 | /* Route reflector client. */ |
17471 | if (peergroup_af_flag_check(peer, afi, safi, | |
17472 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
17473 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
17474 | } | |
17475 | ||
17476 | /* next-hop-self force */ | |
17477 | if (peergroup_af_flag_check(peer, afi, safi, | |
17478 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
17479 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
17480 | } | |
17481 | ||
17482 | /* next-hop-self */ | |
17483 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
17484 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
17485 | } | |
17486 | ||
17487 | /* remove-private-AS */ | |
17488 | if (peergroup_af_flag_check(peer, afi, safi, | |
17489 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
17490 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
17491 | addr); | |
17492 | } | |
17493 | ||
17494 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17495 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
17496 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
17497 | addr); | |
17498 | } | |
17499 | ||
17500 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17501 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
17502 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
17503 | } | |
17504 | ||
17505 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17506 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
17507 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
17508 | } | |
17509 | ||
17510 | /* as-override */ | |
17511 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
17512 | vty_out(vty, " neighbor %s as-override\n", addr); | |
17513 | } | |
17514 | ||
17515 | /* send-community print. */ | |
17516 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
17517 | PEER_FLAG_SEND_COMMUNITY); | |
17518 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
17519 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
17520 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
17521 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
17522 | ||
17523 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
17524 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
17525 | } else { | |
17526 | if (flag_scomm) | |
17527 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
17528 | if (flag_secomm) | |
17529 | vty_out(vty, | |
17530 | " no neighbor %s send-community extended\n", | |
17531 | addr); | |
17532 | ||
17533 | if (flag_slcomm) | |
17534 | vty_out(vty, " no neighbor %s send-community large\n", | |
17535 | addr); | |
17536 | } | |
17537 | ||
17538 | /* Default information */ | |
17539 | if (peergroup_af_flag_check(peer, afi, safi, | |
17540 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
17541 | vty_out(vty, " neighbor %s default-originate", addr); | |
17542 | ||
17543 | if (peer->default_rmap[afi][safi].name) | |
17544 | vty_out(vty, " route-map %s", | |
17545 | peer->default_rmap[afi][safi].name); | |
17546 | ||
17547 | vty_out(vty, "\n"); | |
17548 | } | |
17549 | ||
17550 | /* Soft reconfiguration inbound. */ | |
17551 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
17552 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
17553 | addr); | |
17554 | } | |
17555 | ||
17556 | /* maximum-prefix. */ | |
17557 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 17558 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
17559 | peer->pmax[afi][safi]); |
17560 | ||
17561 | if (peer->pmax_threshold[afi][safi] | |
17562 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
17563 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
17564 | if (peer_af_flag_check(peer, afi, safi, | |
17565 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
17566 | vty_out(vty, " warning-only"); | |
17567 | if (peer->pmax_restart[afi][safi]) | |
17568 | vty_out(vty, " restart %u", | |
17569 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
17570 | if (peer_af_flag_check(peer, afi, safi, |
17571 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
17572 | vty_out(vty, " force"); | |
dd65f45e DL |
17573 | |
17574 | vty_out(vty, "\n"); | |
17575 | } | |
17576 | ||
fde246e8 DA |
17577 | /* maximum-prefix-out */ |
17578 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 17579 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
17580 | addr, peer->pmax_out[afi][safi]); |
17581 | ||
dd65f45e DL |
17582 | /* Route server client. */ |
17583 | if (peergroup_af_flag_check(peer, afi, safi, | |
17584 | PEER_FLAG_RSERVER_CLIENT)) { | |
17585 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
17586 | } | |
17587 | ||
17588 | /* Nexthop-local unchanged. */ | |
17589 | if (peergroup_af_flag_check(peer, afi, safi, | |
17590 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
17591 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
17592 | } | |
17593 | ||
17594 | /* allowas-in <1-10> */ | |
17595 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17596 | if (peer_af_flag_check(peer, afi, safi, | |
17597 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17598 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17599 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17600 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17601 | } else { | |
17602 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17603 | peer->allowas_in[afi][safi]); | |
17604 | } | |
17605 | } | |
17606 | ||
46dbf9d0 DA |
17607 | /* accept-own */ |
17608 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ACCEPT_OWN)) | |
17609 | vty_out(vty, " neighbor %s accept-own\n", addr); | |
17610 | ||
01da2d26 DA |
17611 | /* soo */ |
17612 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOO)) { | |
17613 | char *soo_str = ecommunity_ecom2str( | |
17614 | peer->soo[afi][safi], ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
17615 | ||
17616 | vty_out(vty, " neighbor %s soo %s\n", addr, soo_str); | |
17617 | XFREE(MTYPE_ECOMMUNITY_STR, soo_str); | |
17618 | } | |
17619 | ||
dd65f45e DL |
17620 | /* weight */ |
17621 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17622 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17623 | peer->weight[afi][safi]); | |
17624 | ||
17625 | /* Filter. */ | |
17626 | bgp_config_write_filter(vty, peer, afi, safi); | |
17627 | ||
17628 | /* atribute-unchanged. */ | |
17629 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17630 | || (safi != SAFI_EVPN | |
17631 | && peer_af_flag_check(peer, afi, safi, | |
17632 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17633 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17634 | ||
17635 | if (!peer_group_active(peer) | |
17636 | || peergroup_af_flag_check(peer, afi, safi, | |
17637 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17638 | || peergroup_af_flag_check(peer, afi, safi, | |
17639 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17640 | || peergroup_af_flag_check(peer, afi, safi, | |
17641 | PEER_FLAG_MED_UNCHANGED)) { | |
17642 | ||
17643 | vty_out(vty, | |
17644 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17645 | addr, | |
17646 | peer_af_flag_check(peer, afi, safi, | |
17647 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17648 | ? " as-path" | |
17649 | : "", | |
17650 | peer_af_flag_check(peer, afi, safi, | |
17651 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17652 | ? " next-hop" | |
17653 | : "", | |
17654 | peer_af_flag_check(peer, afi, safi, | |
17655 | PEER_FLAG_MED_UNCHANGED) | |
17656 | ? " med" | |
17657 | : ""); | |
17658 | } | |
17659 | } | |
70cd87ca MK |
17660 | |
17661 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_ORR_GROUP)) | |
17662 | vty_out(vty, " neighbor %s optimal-route-reflection %s\n", | |
5fcf01c9 | 17663 | addr, peer->orr_group_name[afi][safi]); |
dd65f45e DL |
17664 | } |
17665 | ||
a486300b PG |
17666 | static void bgp_vpn_config_write(struct vty *vty, struct bgp *bgp, afi_t afi, |
17667 | safi_t safi) | |
17668 | { | |
17669 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
17670 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL)) | |
17671 | vty_out(vty, " no bgp retain route-target all\n"); | |
17672 | } | |
17673 | ||
dd65f45e DL |
17674 | /* Address family based peer configuration display. */ |
17675 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17676 | safi_t safi) | |
17677 | { | |
17678 | struct peer *peer; | |
17679 | struct peer_group *group; | |
17680 | struct listnode *node, *nnode; | |
17681 | ||
17682 | ||
17683 | vty_frame(vty, " !\n address-family "); | |
17684 | if (afi == AFI_IP) { | |
17685 | if (safi == SAFI_UNICAST) | |
17686 | vty_frame(vty, "ipv4 unicast"); | |
17687 | else if (safi == SAFI_LABELED_UNICAST) | |
17688 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17689 | else if (safi == SAFI_MULTICAST) | |
17690 | vty_frame(vty, "ipv4 multicast"); | |
17691 | else if (safi == SAFI_MPLS_VPN) | |
17692 | vty_frame(vty, "ipv4 vpn"); | |
17693 | else if (safi == SAFI_ENCAP) | |
17694 | vty_frame(vty, "ipv4 encap"); | |
17695 | else if (safi == SAFI_FLOWSPEC) | |
17696 | vty_frame(vty, "ipv4 flowspec"); | |
17697 | } else if (afi == AFI_IP6) { | |
17698 | if (safi == SAFI_UNICAST) | |
17699 | vty_frame(vty, "ipv6 unicast"); | |
17700 | else if (safi == SAFI_LABELED_UNICAST) | |
17701 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17702 | else if (safi == SAFI_MULTICAST) | |
17703 | vty_frame(vty, "ipv6 multicast"); | |
17704 | else if (safi == SAFI_MPLS_VPN) | |
17705 | vty_frame(vty, "ipv6 vpn"); | |
17706 | else if (safi == SAFI_ENCAP) | |
17707 | vty_frame(vty, "ipv6 encap"); | |
17708 | else if (safi == SAFI_FLOWSPEC) | |
17709 | vty_frame(vty, "ipv6 flowspec"); | |
17710 | } else if (afi == AFI_L2VPN) { | |
17711 | if (safi == SAFI_EVPN) | |
17712 | vty_frame(vty, "l2vpn evpn"); | |
17713 | } | |
17714 | vty_frame(vty, "\n"); | |
17715 | ||
17716 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17717 | ||
17718 | bgp_config_write_network(vty, bgp, afi, safi); | |
17719 | ||
17720 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17721 | ||
8a4e7fe6 DA |
17722 | /* BGP flag dampening. */ |
17723 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 17724 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 17725 | |
dd65f45e DL |
17726 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17727 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17728 | ||
17729 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17730 | /* Do not display doppelganger peers */ |
17731 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17732 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17733 | } | |
17734 | ||
17735 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17736 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17737 | ||
17738 | if (safi == SAFI_EVPN) | |
17739 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17740 | ||
17741 | if (safi == SAFI_FLOWSPEC) | |
17742 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17743 | ||
a486300b PG |
17744 | if (safi == SAFI_MPLS_VPN) |
17745 | bgp_vpn_config_write(vty, bgp, afi, safi); | |
17746 | ||
dd65f45e DL |
17747 | if (safi == SAFI_UNICAST) { |
17748 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17749 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17750 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17751 | ||
17752 | vty_out(vty, " export vpn\n"); | |
17753 | } | |
17754 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17755 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17756 | ||
17757 | vty_out(vty, " import vpn\n"); | |
17758 | } | |
17759 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17760 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17761 | char *name; | |
17762 | ||
17763 | for (ALL_LIST_ELEMENTS_RO( | |
17764 | bgp->vpn_policy[afi].import_vrf, node, | |
17765 | name)) | |
17766 | vty_out(vty, " import vrf %s\n", name); | |
17767 | } | |
17768 | } | |
17769 | ||
70cd87ca MK |
17770 | /* Optimal Route Reflection */ |
17771 | bgp_config_write_orr(vty, bgp, afi, safi); | |
17772 | ||
dd65f45e DL |
17773 | vty_endframe(vty, " exit-address-family\n"); |
17774 | } | |
17775 | ||
17776 | int bgp_config_write(struct vty *vty) | |
17777 | { | |
17778 | struct bgp *bgp; | |
17779 | struct peer_group *group; | |
17780 | struct peer *peer; | |
17781 | struct listnode *node, *nnode; | |
17782 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17783 | afi_t afi; |
17784 | safi_t safi; | |
efc9b57d | 17785 | uint32_t tovpn_sid_index = 0; |
dd65f45e DL |
17786 | |
17787 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17788 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17789 | bm->rmap_update_timer); | |
17790 | ||
d70583f7 D |
17791 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17792 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17793 | if (bm->v_update_delay != bm->v_establish_wait) | |
17794 | vty_out(vty, " %d", bm->v_establish_wait); | |
17795 | vty_out(vty, "\n"); | |
17796 | } | |
17797 | ||
9acb67cb DS |
17798 | if (bm->wait_for_fib) |
17799 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17800 | ||
05bd726c | 17801 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17802 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17803 | ||
c163f297 DS |
17804 | /* No-RIB (Zebra) option flag configuration */ |
17805 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17806 | vty_out(vty, "bgp no-rib\n"); | |
17807 | ||
870791a3 IR |
17808 | if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
17809 | vty_out(vty, "bgp send-extra-data zebra\n"); | |
e46723a5 | 17810 | |
425bd64b PS |
17811 | /* BGP session DSCP value */ |
17812 | if (bm->tcp_dscp != IPTOS_PREC_INTERNETCONTROL) | |
17813 | vty_out(vty, "bgp session-dscp %u\n", bm->tcp_dscp >> 2); | |
17814 | ||
a0b937de SW |
17815 | /* BGP InQ limit */ |
17816 | if (bm->inq_limit != BM_DEFAULT_INQ_LIMIT) | |
17817 | vty_out(vty, "bgp input-queue-limit %u\n", bm->inq_limit); | |
17818 | ||
dd65f45e DL |
17819 | /* BGP configuration. */ |
17820 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17821 | ||
17822 | /* skip all auto created vrf as they dont have user config */ | |
17823 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17824 | continue; | |
17825 | ||
17826 | /* Router bgp ASN */ | |
17827 | vty_out(vty, "router bgp %u", bgp->as); | |
17828 | ||
17829 | if (bgp->name) | |
17830 | vty_out(vty, " %s %s", | |
17831 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17832 | ? "view" : "vrf", bgp->name); | |
17833 | vty_out(vty, "\n"); | |
17834 | ||
17835 | /* BGP fast-external-failover. */ | |
17836 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17837 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17838 | ||
17839 | /* BGP router ID. */ | |
3a6290bd | 17840 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17841 | vty_out(vty, " bgp router-id %pI4\n", |
17842 | &bgp->router_id_static); | |
dd65f45e | 17843 | |
c208c586 S |
17844 | /* Suppress fib pending */ |
17845 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17846 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17847 | ||
dd65f45e | 17848 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17849 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17850 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17851 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17852 | CHECK_FLAG(bgp->flags, |
17853 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17854 | ? "" |
17855 | : "no "); | |
17856 | ||
17857 | /* BGP configuration. */ | |
892fedb6 | 17858 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17859 | vty_out(vty, " bgp always-compare-med\n"); |
17860 | ||
17861 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17862 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17863 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17864 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17865 | CHECK_FLAG(bgp->flags, | |
17866 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17867 | ? "" | |
17868 | : "no "); | |
dd65f45e DL |
17869 | |
17870 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17871 | if (bgp->reject_as_sets) |
dd65f45e DL |
17872 | vty_out(vty, " bgp reject-as-sets\n"); |
17873 | ||
2adac256 DA |
17874 | /* Suppress duplicate updates if the route actually not changed |
17875 | */ | |
17876 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17877 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17878 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17879 | CHECK_FLAG(bgp->flags, | |
17880 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17881 | ? "" | |
17882 | : "no "); | |
17883 | ||
1ae314be DA |
17884 | /* Send Hard Reset CEASE Notification for 'Administrative Reset' |
17885 | */ | |
17886 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET) != | |
17887 | SAVE_BGP_HARD_ADMIN_RESET) | |
17888 | vty_out(vty, " %sbgp hard-administrative-reset\n", | |
17889 | CHECK_FLAG(bgp->flags, | |
17890 | BGP_FLAG_HARD_ADMIN_RESET) | |
17891 | ? "" | |
17892 | : "no "); | |
17893 | ||
b16bcbba TA |
17894 | /* BGP default <afi>-<safi> */ |
17895 | FOREACH_AFI_SAFI (afi, safi) { | |
17896 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17897 | if (!bgp->default_af[afi][safi]) | |
17898 | vty_out(vty, " no bgp default %s\n", | |
17899 | get_bgp_default_af_flag(afi, | |
17900 | safi)); | |
17901 | } else if (bgp->default_af[afi][safi]) | |
17902 | vty_out(vty, " bgp default %s\n", | |
17903 | get_bgp_default_af_flag(afi, safi)); | |
17904 | } | |
e84c59af | 17905 | |
dd65f45e DL |
17906 | /* BGP default local-preference. */ |
17907 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17908 | vty_out(vty, " bgp default local-preference %u\n", | |
17909 | bgp->default_local_pref); | |
17910 | ||
17911 | /* BGP default show-hostname */ | |
892fedb6 | 17912 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17913 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17914 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17915 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17916 | ? "" |
17917 | : "no "); | |
17918 | ||
aef999a2 DA |
17919 | /* BGP default show-nexthop-hostname */ |
17920 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17921 | != SAVE_BGP_SHOW_HOSTNAME) | |
17922 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17923 | CHECK_FLAG(bgp->flags, | |
17924 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17925 | ? "" | |
17926 | : "no "); | |
17927 | ||
dd65f45e DL |
17928 | /* BGP default subgroup-pkt-queue-max. */ |
17929 | if (bgp->default_subgroup_pkt_queue_max | |
17930 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17931 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17932 | bgp->default_subgroup_pkt_queue_max); | |
17933 | ||
17934 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17935 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17936 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17937 | ||
17938 | /* BGP cluster ID. */ | |
17939 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17940 | vty_out(vty, " bgp cluster-id %pI4\n", |
17941 | &bgp->cluster_id); | |
dd65f45e DL |
17942 | |
17943 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17944 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17945 | vty_out(vty, |
17946 | " bgp disable-ebgp-connected-route-check\n"); | |
17947 | ||
17948 | /* Confederation identifier*/ | |
17949 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17950 | vty_out(vty, " bgp confederation identifier %u\n", | |
17951 | bgp->confed_id); | |
17952 | ||
17953 | /* Confederation peer */ | |
17954 | if (bgp->confed_peers_cnt > 0) { | |
17955 | int i; | |
17956 | ||
17957 | vty_out(vty, " bgp confederation peers"); | |
17958 | ||
17959 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17960 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17961 | ||
17962 | vty_out(vty, "\n"); | |
17963 | } | |
17964 | ||
17965 | /* BGP deterministic-med. */ | |
892fedb6 | 17966 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17967 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17968 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17969 | CHECK_FLAG(bgp->flags, |
17970 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17971 | ? "" |
17972 | : "no "); | |
17973 | ||
17974 | /* BGP update-delay. */ | |
17975 | bgp_config_write_update_delay(vty, bgp); | |
17976 | ||
17977 | if (bgp->v_maxmed_onstartup | |
17978 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17979 | vty_out(vty, " bgp max-med on-startup %u", | |
17980 | bgp->v_maxmed_onstartup); | |
17981 | if (bgp->maxmed_onstartup_value | |
17982 | != BGP_MAXMED_VALUE_DEFAULT) | |
17983 | vty_out(vty, " %u", | |
17984 | bgp->maxmed_onstartup_value); | |
17985 | vty_out(vty, "\n"); | |
17986 | } | |
17987 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17988 | vty_out(vty, " bgp max-med administrative"); | |
17989 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17990 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17991 | vty_out(vty, "\n"); | |
17992 | } | |
17993 | ||
17994 | /* write quanta */ | |
17995 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17996 | /* read quanta */ | |
17997 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17998 | ||
17999 | /* coalesce time */ | |
18000 | bgp_config_write_coalesce_time(vty, bgp); | |
18001 | ||
05bd726c | 18002 | /* BGP per-instance graceful-shutdown */ |
18003 | /* BGP-wide settings and per-instance settings are mutually | |
18004 | * exclusive. | |
18005 | */ | |
18006 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
18007 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
18008 | vty_out(vty, " bgp graceful-shutdown\n"); | |
18009 | ||
8606be87 DA |
18010 | /* Long-lived Graceful Restart */ |
18011 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
18012 | vty_out(vty, | |
18013 | " bgp long-lived-graceful-restart stale-time %u\n", | |
18014 | bgp->llgr_stale_time); | |
18015 | ||
dd65f45e DL |
18016 | /* BGP graceful-restart. */ |
18017 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
18018 | vty_out(vty, | |
18019 | " bgp graceful-restart stalepath-time %u\n", | |
18020 | bgp->stalepath_time); | |
cfd47646 | 18021 | |
dd65f45e DL |
18022 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
18023 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
18024 | bgp->restart_time); | |
cfd47646 | 18025 | |
f2ca5c5b DA |
18026 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION) != |
18027 | SAVE_BGP_GRACEFUL_NOTIFICATION) | |
18028 | vty_out(vty, " %sbgp graceful-restart notification\n", | |
18029 | CHECK_FLAG(bgp->flags, | |
18030 | BGP_FLAG_GRACEFUL_NOTIFICATION) | |
18031 | ? "" | |
18032 | : "no "); | |
18033 | ||
cfd47646 | 18034 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) |
18035 | vty_out(vty, | |
18036 | " bgp graceful-restart select-defer-time %u\n", | |
18037 | bgp->select_defer_time); | |
18038 | ||
18039 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
18040 | vty_out(vty, " bgp graceful-restart\n"); |
18041 | ||
cfd47646 | 18042 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
18043 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
18044 | ||
dd65f45e | 18045 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 18046 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
18047 | vty_out(vty, |
18048 | " bgp graceful-restart preserve-fw-state\n"); | |
18049 | ||
d1adb448 PG |
18050 | /* BGP TCP keepalive */ |
18051 | bgp_config_tcp_keepalive(vty, bgp); | |
18052 | ||
dc95985f | 18053 | /* Stale timer for RIB */ |
18054 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
18055 | vty_out(vty, | |
18056 | " bgp graceful-restart rib-stale-time %u\n", | |
18057 | bgp->rib_stale_time); | |
18058 | ||
dd65f45e | 18059 | /* BGP bestpath method. */ |
892fedb6 | 18060 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 18061 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 18062 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
18063 | vty_out(vty, " bgp bestpath as-path confed\n"); |
18064 | ||
892fedb6 DA |
18065 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
18066 | if (CHECK_FLAG(bgp->flags, | |
18067 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
18068 | vty_out(vty, |
18069 | " bgp bestpath as-path multipath-relax as-set\n"); | |
18070 | } else { | |
18071 | vty_out(vty, | |
18072 | " bgp bestpath as-path multipath-relax\n"); | |
18073 | } | |
18074 | } | |
18075 | ||
892fedb6 | 18076 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
18077 | vty_out(vty, |
18078 | " bgp route-reflector allow-outbound-policy\n"); | |
18079 | } | |
892fedb6 | 18080 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 18081 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
97a52c82 DA |
18082 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP)) |
18083 | vty_out(vty, " bgp bestpath aigp\n"); | |
892fedb6 DA |
18084 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
18085 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 18086 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 18087 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 18088 | vty_out(vty, " confed"); |
892fedb6 DA |
18089 | if (CHECK_FLAG(bgp->flags, |
18090 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
18091 | vty_out(vty, " missing-as-worst"); |
18092 | vty_out(vty, "\n"); | |
18093 | } | |
18094 | ||
ee88563a JM |
18095 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
18096 | vty_out(vty, | |
18097 | " bgp bestpath peer-type multipath-relax\n"); | |
18098 | ||
f7e1c681 | 18099 | /* Link bandwidth handling. */ |
18100 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
18101 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
18102 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
18103 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
18104 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
18105 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
18106 | ||
dd65f45e | 18107 | /* BGP network import check. */ |
892fedb6 | 18108 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 18109 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 18110 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 18111 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
18112 | ? "" |
18113 | : "no "); | |
18114 | ||
18115 | /* BGP timers configuration. */ | |
5d5393b9 | 18116 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 18117 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
18118 | vty_out(vty, " timers bgp %u %u\n", |
18119 | bgp->default_keepalive, bgp->default_holdtime); | |
18120 | ||
b042667a TI |
18121 | /* BGP minimum holdtime configuration. */ |
18122 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
18123 | && bgp->default_min_holdtime != 0) | |
18124 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
18125 | bgp->default_min_holdtime); | |
18126 | ||
389e4f92 QY |
18127 | /* Conditional advertisement timer configuration */ |
18128 | if (bgp->condition_check_period | |
18129 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
18130 | vty_out(vty, | |
18131 | " bgp conditional-advertisement timer %u\n", | |
18132 | bgp->condition_check_period); | |
18133 | ||
dd65f45e DL |
18134 | /* peer-group */ |
18135 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
18136 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
18137 | } | |
18138 | ||
18139 | /* Normal neighbor configuration. */ | |
18140 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
18141 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
18142 | bgp_config_write_peer_global(vty, bgp, peer); | |
18143 | } | |
18144 | ||
18145 | /* listen range and limit for dynamic BGP neighbors */ | |
18146 | bgp_config_write_listen(vty, bgp); | |
18147 | ||
18148 | /* | |
18149 | * BGP default autoshutdown neighbors | |
18150 | * | |
18151 | * This must be placed after any peer and peer-group | |
18152 | * configuration, to avoid setting all peers to shutdown after | |
18153 | * a daemon restart, which is undesired behavior. (see #2286) | |
18154 | */ | |
18155 | if (bgp->autoshutdown) | |
18156 | vty_out(vty, " bgp default shutdown\n"); | |
18157 | ||
9cf59432 DS |
18158 | /* BGP instance administrative shutdown */ |
18159 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
18160 | vty_out(vty, " bgp shutdown\n"); | |
18161 | ||
8666265e DS |
18162 | if (bgp->allow_martian) |
18163 | vty_out(vty, " bgp allow-martian-nexthop\n"); | |
18164 | ||
f852eb98 PG |
18165 | if (bgp->fast_convergence) |
18166 | vty_out(vty, " bgp fast-convergence\n"); | |
18167 | ||
a0281b2e HS |
18168 | if (bgp->srv6_enabled) { |
18169 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 18170 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
18171 | vty_out(vty, " locator %s\n", |
18172 | bgp->srv6_locator_name); | |
ff7c3ee1 | 18173 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
18174 | } |
18175 | ||
efc9b57d CS |
18176 | tovpn_sid_index = bgp->tovpn_sid_index; |
18177 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
18178 | vty_out(vty, " sid vpn per-vrf export auto\n"); | |
18179 | } else if (tovpn_sid_index != 0) { | |
18180 | vty_out(vty, " sid vpn per-vrf export %d\n", | |
18181 | tovpn_sid_index); | |
18182 | } | |
a0281b2e | 18183 | |
dd65f45e DL |
18184 | /* IPv4 unicast configuration. */ |
18185 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
18186 | ||
18187 | /* IPv4 multicast configuration. */ | |
18188 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
18189 | ||
18190 | /* IPv4 labeled-unicast configuration. */ | |
18191 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
18192 | ||
18193 | /* IPv4 VPN configuration. */ | |
18194 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
18195 | ||
18196 | /* ENCAPv4 configuration. */ | |
18197 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
18198 | ||
18199 | /* FLOWSPEC v4 configuration. */ | |
18200 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
18201 | ||
18202 | /* IPv6 unicast configuration. */ | |
18203 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
18204 | ||
18205 | /* IPv6 multicast configuration. */ | |
18206 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
18207 | ||
18208 | /* IPv6 labeled-unicast configuration. */ | |
18209 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
18210 | SAFI_LABELED_UNICAST); | |
18211 | ||
18212 | /* IPv6 VPN configuration. */ | |
18213 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
18214 | ||
18215 | /* ENCAPv6 configuration. */ | |
18216 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
18217 | ||
18218 | /* FLOWSPEC v6 configuration. */ | |
18219 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
18220 | ||
18221 | /* EVPN configuration. */ | |
18222 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
18223 | ||
18224 | hook_call(bgp_inst_config_write, bgp, vty); | |
18225 | ||
49e5a4a0 | 18226 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
18227 | bgp_rfapi_cfg_write(vty, bgp); |
18228 | #endif | |
18229 | ||
07679ad9 | 18230 | vty_out(vty, "exit\n"); |
dd65f45e DL |
18231 | vty_out(vty, "!\n"); |
18232 | } | |
18233 | return 0; | |
18234 | } | |
18235 | ||
ddb5b488 | 18236 | |
718e3744 | 18237 | /* BGP node structure. */ |
d62a17ae | 18238 | static struct cmd_node bgp_node = { |
f4b8291f | 18239 | .name = "bgp", |
62b346ee | 18240 | .node = BGP_NODE, |
24389580 | 18241 | .parent_node = CONFIG_NODE, |
62b346ee | 18242 | .prompt = "%s(config-router)# ", |
612c2c15 | 18243 | .config_write = bgp_config_write, |
718e3744 | 18244 | }; |
18245 | ||
d62a17ae | 18246 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 18247 | .name = "bgp ipv4 unicast", |
62b346ee | 18248 | .node = BGP_IPV4_NODE, |
24389580 | 18249 | .parent_node = BGP_NODE, |
62b346ee | 18250 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18251 | .no_xpath = true, |
718e3744 | 18252 | }; |
18253 | ||
d62a17ae | 18254 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 18255 | .name = "bgp ipv4 multicast", |
62b346ee | 18256 | .node = BGP_IPV4M_NODE, |
24389580 | 18257 | .parent_node = BGP_NODE, |
62b346ee | 18258 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18259 | .no_xpath = true, |
718e3744 | 18260 | }; |
18261 | ||
d62a17ae | 18262 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 18263 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 18264 | .node = BGP_IPV4L_NODE, |
24389580 | 18265 | .parent_node = BGP_NODE, |
62b346ee | 18266 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18267 | .no_xpath = true, |
f51bae9c DS |
18268 | }; |
18269 | ||
d62a17ae | 18270 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 18271 | .name = "bgp ipv6 unicast", |
62b346ee | 18272 | .node = BGP_IPV6_NODE, |
24389580 | 18273 | .parent_node = BGP_NODE, |
62b346ee | 18274 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18275 | .no_xpath = true, |
718e3744 | 18276 | }; |
18277 | ||
d62a17ae | 18278 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 18279 | .name = "bgp ipv6 multicast", |
62b346ee | 18280 | .node = BGP_IPV6M_NODE, |
24389580 | 18281 | .parent_node = BGP_NODE, |
62b346ee | 18282 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18283 | .no_xpath = true, |
25ffbdc1 | 18284 | }; |
18285 | ||
d62a17ae | 18286 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 18287 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 18288 | .node = BGP_IPV6L_NODE, |
24389580 | 18289 | .parent_node = BGP_NODE, |
62b346ee | 18290 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18291 | .no_xpath = true, |
f51bae9c DS |
18292 | }; |
18293 | ||
62b346ee | 18294 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 18295 | .name = "bgp vpnv4", |
62b346ee | 18296 | .node = BGP_VPNV4_NODE, |
24389580 | 18297 | .parent_node = BGP_NODE, |
62b346ee | 18298 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18299 | .no_xpath = true, |
62b346ee | 18300 | }; |
6b0655a2 | 18301 | |
62b346ee | 18302 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 18303 | .name = "bgp vpnv6", |
62b346ee | 18304 | .node = BGP_VPNV6_NODE, |
24389580 | 18305 | .parent_node = BGP_NODE, |
62b346ee | 18306 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18307 | .no_xpath = true, |
62b346ee | 18308 | }; |
8ecd3266 | 18309 | |
62b346ee | 18310 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 18311 | .name = "bgp evpn", |
62b346ee | 18312 | .node = BGP_EVPN_NODE, |
24389580 | 18313 | .parent_node = BGP_NODE, |
62b346ee | 18314 | .prompt = "%s(config-router-evpn)# ", |
dd2c81b8 | 18315 | .no_xpath = true, |
62b346ee | 18316 | }; |
4e0b7b6d | 18317 | |
62b346ee | 18318 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 18319 | .name = "bgp evpn vni", |
62b346ee | 18320 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 18321 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 18322 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 18323 | }; |
90e60aa7 | 18324 | |
62b346ee | 18325 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 18326 | .name = "bgp ipv4 flowspec", |
62b346ee | 18327 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 18328 | .parent_node = BGP_NODE, |
62b346ee | 18329 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18330 | .no_xpath = true, |
62b346ee | 18331 | }; |
7c40bf39 | 18332 | |
62b346ee | 18333 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 18334 | .name = "bgp ipv6 flowspec", |
62b346ee | 18335 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 18336 | .parent_node = BGP_NODE, |
62b346ee | 18337 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18338 | .no_xpath = true, |
62b346ee | 18339 | }; |
7c40bf39 | 18340 | |
bfaab44d HS |
18341 | static struct cmd_node bgp_srv6_node = { |
18342 | .name = "bgp srv6", | |
18343 | .node = BGP_SRV6_NODE, | |
18344 | .parent_node = BGP_NODE, | |
18345 | .prompt = "%s(config-router-srv6)# ", | |
18346 | }; | |
18347 | ||
d62a17ae | 18348 | static void community_list_vty(void); |
1f8ae70b | 18349 | |
8c20061f DA |
18350 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
18351 | { | |
18352 | struct bgp *bgp; | |
18353 | struct peer_group *group; | |
18354 | struct listnode *lnbgp, *lnpeer; | |
18355 | ||
18356 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
18357 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
18358 | vector_set(comps, | |
18359 | XSTRDUP(MTYPE_COMPLETION, group->name)); | |
18360 | } | |
18361 | } | |
18362 | ||
18363 | static void bgp_ac_peer(vector comps, struct cmd_token *token) | |
b8a815e5 | 18364 | { |
d62a17ae | 18365 | struct bgp *bgp; |
18366 | struct peer *peer; | |
d62a17ae | 18367 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 18368 | |
d62a17ae | 18369 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
18370 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
18371 | /* only provide suggestions on the appropriate input | |
18372 | * token type, | |
18373 | * they'll otherwise show up multiple times */ | |
18374 | enum cmd_token_type match_type; | |
18375 | char *name = peer->host; | |
d48ed3e0 | 18376 | |
d62a17ae | 18377 | if (peer->conf_if) { |
18378 | match_type = VARIABLE_TKN; | |
18379 | name = peer->conf_if; | |
18380 | } else if (strchr(peer->host, ':')) | |
18381 | match_type = IPV6_TKN; | |
18382 | else | |
18383 | match_type = IPV4_TKN; | |
d48ed3e0 | 18384 | |
d62a17ae | 18385 | if (token->type != match_type) |
18386 | continue; | |
d48ed3e0 | 18387 | |
d62a17ae | 18388 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
18389 | } | |
d62a17ae | 18390 | } |
b8a815e5 DL |
18391 | } |
18392 | ||
8c20061f DA |
18393 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
18394 | { | |
18395 | bgp_ac_peer(comps, token); | |
84de1483 DA |
18396 | |
18397 | if (token->type == VARIABLE_TKN) | |
18398 | bgp_ac_peergroup(comps, token); | |
8c20061f DA |
18399 | } |
18400 | ||
b8a815e5 | 18401 | static const struct cmd_variable_handler bgp_var_neighbor[] = { |
d62a17ae | 18402 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
18403 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 18404 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 18405 | {.completions = NULL}}; |
18406 | ||
47a306a0 DS |
18407 | static const struct cmd_variable_handler bgp_var_peergroup[] = { |
18408 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
18409 | {.completions = NULL} }; | |
18410 | ||
aa24a36a DA |
18411 | DEFINE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp)); |
18412 | ||
18413 | static struct thread *t_bgp_cfg; | |
18414 | ||
18415 | bool bgp_config_inprocess(void) | |
18416 | { | |
18417 | return thread_is_scheduled(t_bgp_cfg); | |
18418 | } | |
18419 | ||
18420 | static void bgp_config_finish(struct thread *t) | |
18421 | { | |
18422 | struct listnode *node; | |
18423 | struct bgp *bgp; | |
18424 | ||
18425 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) | |
18426 | hook_call(bgp_config_end, bgp); | |
18427 | } | |
18428 | ||
18429 | static void bgp_config_start(void) | |
18430 | { | |
18431 | #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600 | |
18432 | THREAD_OFF(t_bgp_cfg); | |
18433 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18434 | BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg); | |
18435 | } | |
18436 | ||
18437 | /* When we receive a hook the configuration is read, | |
18438 | * we start a timer to make sure we postpone sending | |
18439 | * EoR before route-maps are processed. | |
18440 | * This is especially valid if using `bgp route-map delay-timer`. | |
18441 | */ | |
18442 | static void bgp_config_end(void) | |
18443 | { | |
18444 | #define BGP_POST_CONFIG_DELAY_SECONDS 1 | |
18445 | uint32_t bgp_post_config_delay = | |
18446 | thread_is_scheduled(bm->t_rmap_update) | |
18447 | ? thread_timer_remain_second(bm->t_rmap_update) | |
18448 | : BGP_POST_CONFIG_DELAY_SECONDS; | |
18449 | ||
18450 | /* If BGP config processing thread isn't running, then | |
18451 | * we can return and rely it's properly handled. | |
18452 | */ | |
18453 | if (!bgp_config_inprocess()) | |
18454 | return; | |
18455 | ||
18456 | THREAD_OFF(t_bgp_cfg); | |
18457 | ||
18458 | /* Start a new timer to make sure we don't send EoR | |
18459 | * before route-maps are processed. | |
18460 | */ | |
18461 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18462 | bgp_post_config_delay, &t_bgp_cfg); | |
18463 | } | |
18464 | ||
4cd690ae PG |
18465 | static int config_write_interface_one(struct vty *vty, struct vrf *vrf) |
18466 | { | |
18467 | int write = 0; | |
18468 | struct interface *ifp; | |
18469 | struct bgp_interface *iifp; | |
18470 | ||
18471 | FOR_ALL_INTERFACES (vrf, ifp) { | |
18472 | iifp = ifp->info; | |
18473 | if (!iifp) | |
18474 | continue; | |
18475 | ||
18476 | if_vty_config_start(vty, ifp); | |
18477 | ||
18478 | if (CHECK_FLAG(iifp->flags, | |
18479 | BGP_INTERFACE_MPLS_BGP_FORWARDING)) { | |
18480 | vty_out(vty, " mpls bgp forwarding\n"); | |
18481 | write++; | |
18482 | } | |
18483 | ||
18484 | if_vty_config_end(vty); | |
18485 | } | |
18486 | ||
18487 | return write; | |
18488 | } | |
18489 | ||
18490 | /* Configuration write function for bgpd. */ | |
18491 | static int config_write_interface(struct vty *vty) | |
18492 | { | |
18493 | int write = 0; | |
18494 | struct vrf *vrf = NULL; | |
18495 | ||
18496 | /* Display all VRF aware OSPF interface configuration */ | |
18497 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { | |
18498 | write += config_write_interface_one(vty, vrf); | |
18499 | } | |
18500 | ||
18501 | return write; | |
18502 | } | |
18503 | ||
18504 | DEFPY(mpls_bgp_forwarding, mpls_bgp_forwarding_cmd, | |
18505 | "[no$no] mpls bgp forwarding", | |
18506 | NO_STR MPLS_STR BGP_STR | |
18507 | "Enable MPLS forwarding for eBGP directly connected peers\n") | |
18508 | { | |
18509 | bool check; | |
18510 | struct bgp_interface *iifp; | |
18511 | ||
18512 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
18513 | iifp = ifp->info; | |
18514 | if (!iifp) { | |
18515 | vty_out(vty, "Interface %s not available\n", ifp->name); | |
18516 | return CMD_WARNING_CONFIG_FAILED; | |
18517 | } | |
18518 | check = CHECK_FLAG(iifp->flags, BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18519 | if (check != !no) { | |
18520 | if (no) | |
18521 | UNSET_FLAG(iifp->flags, | |
18522 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18523 | else | |
18524 | SET_FLAG(iifp->flags, | |
18525 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18526 | /* trigger a nht update on eBGP sessions */ | |
18527 | if (if_is_operative(ifp)) | |
18528 | bgp_nht_ifp_up(ifp); | |
18529 | } | |
18530 | return CMD_SUCCESS; | |
18531 | } | |
18532 | ||
a0b937de SW |
18533 | DEFPY (bgp_inq_limit, |
18534 | bgp_inq_limit_cmd, | |
18535 | "bgp input-queue-limit (1-4294967295)$limit", | |
18536 | BGP_STR | |
18537 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18538 | "Input-Queue limit\n") | |
18539 | { | |
18540 | bm->inq_limit = limit; | |
18541 | ||
18542 | return CMD_SUCCESS; | |
18543 | } | |
18544 | ||
18545 | DEFPY (no_bgp_inq_limit, | |
18546 | no_bgp_inq_limit_cmd, | |
18547 | "no bgp input-queue-limit [(1-4294967295)$limit]", | |
18548 | NO_STR | |
18549 | BGP_STR | |
18550 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18551 | "Input-Queue limit\n") | |
18552 | { | |
18553 | bm->inq_limit = BM_DEFAULT_INQ_LIMIT; | |
18554 | ||
18555 | return CMD_SUCCESS; | |
18556 | } | |
18557 | ||
4cd690ae PG |
18558 | /* Initialization of BGP interface. */ |
18559 | static void bgp_vty_if_init(void) | |
18560 | { | |
18561 | /* Install interface node. */ | |
18562 | if_cmd_init(config_write_interface); | |
18563 | ||
18564 | /* "mpls bgp forwarding" commands. */ | |
18565 | install_element(INTERFACE_NODE, &mpls_bgp_forwarding_cmd); | |
18566 | } | |
18567 | ||
d62a17ae | 18568 | void bgp_vty_init(void) |
18569 | { | |
18570 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 18571 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 18572 | |
aa24a36a DA |
18573 | cmd_init_config_callbacks(bgp_config_start, bgp_config_end); |
18574 | ||
d62a17ae | 18575 | /* Install bgp top node. */ |
612c2c15 DL |
18576 | install_node(&bgp_node); |
18577 | install_node(&bgp_ipv4_unicast_node); | |
18578 | install_node(&bgp_ipv4_multicast_node); | |
18579 | install_node(&bgp_ipv4_labeled_unicast_node); | |
18580 | install_node(&bgp_ipv6_unicast_node); | |
18581 | install_node(&bgp_ipv6_multicast_node); | |
18582 | install_node(&bgp_ipv6_labeled_unicast_node); | |
18583 | install_node(&bgp_vpnv4_node); | |
18584 | install_node(&bgp_vpnv6_node); | |
18585 | install_node(&bgp_evpn_node); | |
18586 | install_node(&bgp_evpn_vni_node); | |
18587 | install_node(&bgp_flowspecv4_node); | |
18588 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 18589 | install_node(&bgp_srv6_node); |
d62a17ae | 18590 | |
18591 | /* Install default VTY commands to new nodes. */ | |
18592 | install_default(BGP_NODE); | |
18593 | install_default(BGP_IPV4_NODE); | |
18594 | install_default(BGP_IPV4M_NODE); | |
18595 | install_default(BGP_IPV4L_NODE); | |
18596 | install_default(BGP_IPV6_NODE); | |
18597 | install_default(BGP_IPV6M_NODE); | |
18598 | install_default(BGP_IPV6L_NODE); | |
18599 | install_default(BGP_VPNV4_NODE); | |
18600 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 18601 | install_default(BGP_FLOWSPECV4_NODE); |
18602 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 18603 | install_default(BGP_EVPN_NODE); |
18604 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 18605 | install_default(BGP_SRV6_NODE); |
d62a17ae | 18606 | |
a0b937de SW |
18607 | /* "global bgp inq-limit command */ |
18608 | install_element(CONFIG_NODE, &bgp_inq_limit_cmd); | |
18609 | install_element(CONFIG_NODE, &no_bgp_inq_limit_cmd); | |
18610 | ||
8029b216 AK |
18611 | /* "bgp local-mac" hidden commands. */ |
18612 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
18613 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
18614 | ||
9acb67cb DS |
18615 | /* "bgp suppress-fib-pending" global */ |
18616 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
18617 | ||
d62a17ae | 18618 | /* bgp route-map delay-timer commands. */ |
18619 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18620 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18621 | ||
8666265e DS |
18622 | install_element(BGP_NODE, &bgp_allow_martian_cmd); |
18623 | ||
f852eb98 PG |
18624 | /* bgp fast-convergence command */ |
18625 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
18626 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
18627 | ||
d70583f7 D |
18628 | /* global bgp update-delay command */ |
18629 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
18630 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
18631 | ||
05bd726c | 18632 | /* global bgp graceful-shutdown command */ |
18633 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
18634 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
18635 | ||
d62a17ae | 18636 | /* Dummy commands (Currently not supported) */ |
18637 | install_element(BGP_NODE, &no_synchronization_cmd); | |
18638 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
18639 | ||
18640 | /* "router bgp" commands. */ | |
18641 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
18642 | ||
18643 | /* "no router bgp" commands. */ | |
18644 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
18645 | ||
425bd64b PS |
18646 | /* "bgp session-dscp command */ |
18647 | install_element(CONFIG_NODE, &bgp_session_dscp_cmd); | |
18648 | install_element(CONFIG_NODE, &no_bgp_session_dscp_cmd); | |
18649 | ||
d62a17ae | 18650 | /* "bgp router-id" commands. */ |
18651 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
18652 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
18653 | ||
c208c586 S |
18654 | /* "bgp suppress-fib-pending" command */ |
18655 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
18656 | ||
d62a17ae | 18657 | /* "bgp cluster-id" commands. */ |
18658 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
18659 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
18660 | ||
c163f297 DS |
18661 | /* "bgp no-rib" commands. */ |
18662 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
18663 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
18664 | ||
e46723a5 DS |
18665 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
18666 | ||
d62a17ae | 18667 | /* "bgp confederation" commands. */ |
18668 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
18669 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
18670 | ||
18671 | /* "bgp confederation peers" commands. */ | |
18672 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
18673 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
18674 | ||
18675 | /* bgp max-med command */ | |
18676 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
18677 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
18678 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
18679 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
18680 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
18681 | ||
d864dd9e EB |
18682 | /* "neighbor role" commands. */ |
18683 | install_element(BGP_NODE, &neighbor_role_cmd); | |
18684 | install_element(BGP_NODE, &neighbor_role_strict_cmd); | |
18685 | install_element(BGP_NODE, &no_neighbor_role_cmd); | |
18686 | ||
97a52c82 DA |
18687 | /* "neighbor aigp" commands. */ |
18688 | install_element(BGP_NODE, &neighbor_aigp_cmd); | |
18689 | ||
4f770cf1 DA |
18690 | /* "neighbor graceful-shutdown" command */ |
18691 | install_element(BGP_NODE, &neighbor_graceful_shutdown_cmd); | |
18692 | ||
d62a17ae | 18693 | /* bgp disable-ebgp-connected-nh-check */ |
18694 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
18695 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
18696 | ||
18697 | /* bgp update-delay command */ | |
18698 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
18699 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 18700 | |
18701 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 18702 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 18703 | |
18704 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
18705 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
18706 | ||
18707 | /* "maximum-paths" commands. */ | |
18708 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
18709 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
18710 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
18711 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
18712 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
18713 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
18714 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
18715 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
18716 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
18717 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
18718 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18719 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18720 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
18721 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18722 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18723 | ||
39edabac PG |
18724 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
18725 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
18726 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18727 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18728 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 18729 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
18730 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
18731 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18732 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18733 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18734 | ||
18735 | /* "timers bgp" commands. */ | |
18736 | install_element(BGP_NODE, &bgp_timers_cmd); | |
18737 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
18738 | ||
b042667a TI |
18739 | /* "minimum-holdtime" commands. */ |
18740 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
18741 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
18742 | ||
d62a17ae | 18743 | /* route-map delay-timer commands - per instance for backwards compat. |
18744 | */ | |
18745 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18746 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18747 | ||
18748 | /* "bgp client-to-client reflection" commands */ | |
18749 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
18750 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
18751 | ||
18752 | /* "bgp always-compare-med" commands */ | |
18753 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
18754 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
18755 | ||
9dac9fc8 DA |
18756 | /* bgp ebgp-requires-policy */ |
18757 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
18758 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
18759 | ||
2adac256 DA |
18760 | /* bgp suppress-duplicates */ |
18761 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
18762 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
18763 | ||
fb29348a DA |
18764 | /* bgp reject-as-sets */ |
18765 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
18766 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
18767 | ||
d62a17ae | 18768 | /* "bgp deterministic-med" commands */ |
18769 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
18770 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
18771 | ||
055679e9 | 18772 | /* "bgp graceful-restart" command */ |
36235319 QY |
18773 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
18774 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 18775 | |
18776 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
18777 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
18778 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 18779 | |
18780 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
18781 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
18782 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 18783 | |
18784 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
18785 | install_element(BGP_NODE, | |
18786 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
18787 | install_element(BGP_NODE, | |
18788 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
18789 | ||
18790 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
18791 | install_element(BGP_NODE, | |
18792 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
18793 | install_element(BGP_NODE, | |
18794 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
18795 | ||
d62a17ae | 18796 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
18797 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
18798 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
18799 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 18800 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 18801 | install_element(BGP_NODE, |
18802 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 18803 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
18804 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
f2ca5c5b | 18805 | install_element(BGP_NODE, &bgp_graceful_restart_notification_cmd); |
d62a17ae | 18806 | |
d6e3c15b | 18807 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
18808 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 18809 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
18810 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 18811 | |
a0b937de SW |
18812 | /* "bgp inq-limit command */ |
18813 | install_element(BGP_NODE, &bgp_inq_limit_cmd); | |
18814 | install_element(BGP_NODE, &no_bgp_inq_limit_cmd); | |
18815 | ||
7f323236 DW |
18816 | /* "bgp graceful-shutdown" commands */ |
18817 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
18818 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
18819 | ||
1ae314be DA |
18820 | /* "bgp hard-administrative-reset" commands */ |
18821 | install_element(BGP_NODE, &bgp_administrative_reset_cmd); | |
18822 | ||
8606be87 DA |
18823 | /* "bgp long-lived-graceful-restart" commands */ |
18824 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
18825 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
18826 | ||
d62a17ae | 18827 | /* "bgp fast-external-failover" commands */ |
18828 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
18829 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
18830 | ||
97a52c82 DA |
18831 | /* "bgp bestpath aigp" commands */ |
18832 | install_element(BGP_NODE, &bgp_bestpath_aigp_cmd); | |
18833 | ||
d62a17ae | 18834 | /* "bgp bestpath compare-routerid" commands */ |
18835 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
18836 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
18837 | ||
18838 | /* "bgp bestpath as-path ignore" commands */ | |
18839 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
18840 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
18841 | ||
18842 | /* "bgp bestpath as-path confed" commands */ | |
18843 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
18844 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
18845 | ||
18846 | /* "bgp bestpath as-path multipath-relax" commands */ | |
18847 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
18848 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
18849 | ||
ee88563a JM |
18850 | /* "bgp bestpath peer-type multipath-relax" commands */ |
18851 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
18852 | install_element(BGP_NODE, | |
18853 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
18854 | ||
d62a17ae | 18855 | /* "bgp log-neighbor-changes" commands */ |
18856 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
18857 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
18858 | ||
18859 | /* "bgp bestpath med" commands */ | |
18860 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
18861 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
18862 | ||
f7e1c681 | 18863 | /* "bgp bestpath bandwidth" commands */ |
18864 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 18865 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 18866 | |
b16bcbba TA |
18867 | /* "no bgp default <afi>-<safi>" commands. */ |
18868 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 18869 | |
d62a17ae | 18870 | /* "bgp network import-check" commands. */ |
18871 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
18872 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
18873 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
18874 | ||
18875 | /* "bgp default local-preference" commands. */ | |
18876 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
18877 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
18878 | ||
18879 | /* bgp default show-hostname */ | |
18880 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
18881 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
18882 | ||
aef999a2 DA |
18883 | /* bgp default show-nexthop-hostname */ |
18884 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
18885 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
18886 | ||
d62a17ae | 18887 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
18888 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
18889 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
18890 | ||
18891 | /* bgp ibgp-allow-policy-mods command */ | |
18892 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
18893 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
18894 | ||
18895 | /* "bgp listen limit" commands. */ | |
18896 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
18897 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
18898 | ||
18899 | /* "bgp listen range" commands. */ | |
18900 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
18901 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
18902 | ||
8175f54a | 18903 | /* "bgp default shutdown" command */ |
f26845f9 | 18904 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
18905 | |
18906 | /* "bgp shutdown" commands */ | |
18907 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 18908 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 18909 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 18910 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 18911 | |
d62a17ae | 18912 | /* "neighbor remote-as" commands. */ |
18913 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
18914 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
18915 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
18916 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
18917 | install_element(BGP_NODE, | |
18918 | &neighbor_interface_v6only_config_remote_as_cmd); | |
18919 | install_element(BGP_NODE, &no_neighbor_cmd); | |
18920 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
18921 | ||
18922 | /* "neighbor peer-group" commands. */ | |
18923 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
18924 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
18925 | install_element(BGP_NODE, | |
18926 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
18927 | ||
18928 | /* "neighbor local-as" commands. */ | |
18929 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
18930 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
18931 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
18932 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
18933 | ||
18934 | /* "neighbor solo" commands. */ | |
18935 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
18936 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
18937 | ||
18938 | /* "neighbor password" commands. */ | |
18939 | install_element(BGP_NODE, &neighbor_password_cmd); | |
18940 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
18941 | ||
18942 | /* "neighbor activate" commands. */ | |
18943 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
18944 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
18945 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
18946 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
18947 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
18948 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
18949 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
18950 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
18951 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 18952 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
18953 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 18954 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
18955 | ||
18956 | /* "no neighbor activate" commands. */ | |
18957 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
18958 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
18959 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
18960 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
18961 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
18962 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
18963 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
18964 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
18965 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 18966 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
18967 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 18968 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
18969 | ||
18970 | /* "neighbor peer-group" set commands. */ | |
18971 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
18972 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18973 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18974 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18975 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18976 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18977 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18978 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18979 | install_element(BGP_FLOWSPECV4_NODE, |
18980 | &neighbor_set_peer_group_hidden_cmd); | |
18981 | install_element(BGP_FLOWSPECV6_NODE, | |
18982 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18983 | |
18984 | /* "no neighbor peer-group unset" commands. */ | |
18985 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
18986 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18987 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18988 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18989 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18990 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18991 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18992 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18993 | install_element(BGP_FLOWSPECV4_NODE, |
18994 | &no_neighbor_set_peer_group_hidden_cmd); | |
18995 | install_element(BGP_FLOWSPECV6_NODE, | |
18996 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18997 | |
18998 | /* "neighbor softreconfiguration inbound" commands.*/ | |
18999 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
19000 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
19001 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
19002 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19003 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
19004 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19005 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
19006 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19007 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
19008 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19009 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
19010 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19011 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
19012 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19013 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
19014 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19015 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
19016 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 19017 | install_element(BGP_FLOWSPECV4_NODE, |
19018 | &neighbor_soft_reconfiguration_cmd); | |
19019 | install_element(BGP_FLOWSPECV4_NODE, | |
19020 | &no_neighbor_soft_reconfiguration_cmd); | |
19021 | install_element(BGP_FLOWSPECV6_NODE, | |
19022 | &neighbor_soft_reconfiguration_cmd); | |
19023 | install_element(BGP_FLOWSPECV6_NODE, | |
19024 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
19025 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
19026 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 19027 | |
19028 | /* "neighbor attribute-unchanged" commands. */ | |
19029 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
19030 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
19031 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
19032 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19033 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
19034 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
19035 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
19036 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
19037 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
19038 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19039 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
19040 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
19041 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
19042 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
19043 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
19044 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19045 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
19046 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19047 | ||
19048 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
19049 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
19050 | ||
b8ad84d2 PG |
19051 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
19052 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19053 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
19054 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19055 | ||
d62a17ae | 19056 | /* "nexthop-local unchanged" commands */ |
19057 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
19058 | install_element(BGP_IPV6_NODE, | |
19059 | &no_neighbor_nexthop_local_unchanged_cmd); | |
19060 | ||
19061 | /* "neighbor next-hop-self" commands. */ | |
19062 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
19063 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
19064 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
19065 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19066 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
19067 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
19068 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
19069 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
19070 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
19071 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
19072 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
19073 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
19074 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
19075 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
19076 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
19077 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19078 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
19079 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
19080 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
19081 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 19082 | |
19083 | /* "neighbor next-hop-self force" commands. */ | |
19084 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
19085 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
19086 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19087 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19088 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
19089 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19090 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19091 | install_element(BGP_IPV4_NODE, | |
19092 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19093 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
19094 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19095 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19096 | install_element(BGP_IPV4M_NODE, | |
19097 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19098 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
19099 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19100 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19101 | install_element(BGP_IPV4L_NODE, | |
19102 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19103 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
19104 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19105 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19106 | install_element(BGP_IPV6_NODE, | |
19107 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19108 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
19109 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19110 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19111 | install_element(BGP_IPV6M_NODE, | |
19112 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19113 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
19114 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19115 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19116 | install_element(BGP_IPV6L_NODE, | |
19117 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19118 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
19119 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19120 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19121 | install_element(BGP_VPNV4_NODE, | |
19122 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19123 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
19124 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19125 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19126 | install_element(BGP_VPNV6_NODE, | |
19127 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
19128 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
19129 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 19130 | |
19131 | /* "neighbor as-override" commands. */ | |
19132 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
19133 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
19134 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
19135 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
19136 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
19137 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
19138 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
19139 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
19140 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
19141 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
19142 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
19143 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
19144 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
19145 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
19146 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
19147 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
19148 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
19149 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
19150 | ||
19151 | /* "neighbor remove-private-AS" commands. */ | |
19152 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
19153 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
19154 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
19155 | install_element(BGP_NODE, | |
19156 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
19157 | install_element(BGP_NODE, | |
19158 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
19159 | install_element(BGP_NODE, | |
19160 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
19161 | install_element(BGP_NODE, | |
19162 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19163 | install_element( | |
19164 | BGP_NODE, | |
19165 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19166 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
19167 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19168 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19169 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19170 | install_element(BGP_IPV4_NODE, | |
19171 | &neighbor_remove_private_as_replace_as_cmd); | |
19172 | install_element(BGP_IPV4_NODE, | |
19173 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19174 | install_element(BGP_IPV4_NODE, | |
19175 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19176 | install_element(BGP_IPV4_NODE, | |
19177 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19178 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
19179 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
19180 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
19181 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19182 | install_element(BGP_IPV4M_NODE, | |
19183 | &neighbor_remove_private_as_replace_as_cmd); | |
19184 | install_element(BGP_IPV4M_NODE, | |
19185 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19186 | install_element(BGP_IPV4M_NODE, | |
19187 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19188 | install_element(BGP_IPV4M_NODE, | |
19189 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19190 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
19191 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
19192 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
19193 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19194 | install_element(BGP_IPV4L_NODE, | |
19195 | &neighbor_remove_private_as_replace_as_cmd); | |
19196 | install_element(BGP_IPV4L_NODE, | |
19197 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19198 | install_element(BGP_IPV4L_NODE, | |
19199 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19200 | install_element(BGP_IPV4L_NODE, | |
19201 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19202 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
19203 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19204 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19205 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19206 | install_element(BGP_IPV6_NODE, | |
19207 | &neighbor_remove_private_as_replace_as_cmd); | |
19208 | install_element(BGP_IPV6_NODE, | |
19209 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19210 | install_element(BGP_IPV6_NODE, | |
19211 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19212 | install_element(BGP_IPV6_NODE, | |
19213 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19214 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
19215 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
19216 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
19217 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19218 | install_element(BGP_IPV6M_NODE, | |
19219 | &neighbor_remove_private_as_replace_as_cmd); | |
19220 | install_element(BGP_IPV6M_NODE, | |
19221 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19222 | install_element(BGP_IPV6M_NODE, | |
19223 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19224 | install_element(BGP_IPV6M_NODE, | |
19225 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19226 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
19227 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
19228 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
19229 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19230 | install_element(BGP_IPV6L_NODE, | |
19231 | &neighbor_remove_private_as_replace_as_cmd); | |
19232 | install_element(BGP_IPV6L_NODE, | |
19233 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19234 | install_element(BGP_IPV6L_NODE, | |
19235 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19236 | install_element(BGP_IPV6L_NODE, | |
19237 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19238 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
19239 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19240 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19241 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19242 | install_element(BGP_VPNV4_NODE, | |
19243 | &neighbor_remove_private_as_replace_as_cmd); | |
19244 | install_element(BGP_VPNV4_NODE, | |
19245 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19246 | install_element(BGP_VPNV4_NODE, | |
19247 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19248 | install_element(BGP_VPNV4_NODE, | |
19249 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19250 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
19251 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19252 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19253 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19254 | install_element(BGP_VPNV6_NODE, | |
19255 | &neighbor_remove_private_as_replace_as_cmd); | |
19256 | install_element(BGP_VPNV6_NODE, | |
19257 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19258 | install_element(BGP_VPNV6_NODE, | |
19259 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19260 | install_element(BGP_VPNV6_NODE, | |
19261 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19262 | ||
19263 | /* "neighbor send-community" commands.*/ | |
19264 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
19265 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
19266 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
19267 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
19268 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
19269 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
19270 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
19271 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
19272 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
19273 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
19274 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
19275 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
19276 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
19277 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
19278 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
19279 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
19280 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
19281 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
19282 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
19283 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
19284 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
19285 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
19286 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
19287 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
19288 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
19289 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
19290 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
19291 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
19292 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
19293 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
19294 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
19295 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
19296 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
19297 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
19298 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
19299 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
19300 | ||
19301 | /* "neighbor route-reflector" commands.*/ | |
19302 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
19303 | install_element(BGP_NODE, | |
19304 | &no_neighbor_route_reflector_client_hidden_cmd); | |
19305 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
19306 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
19307 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
19308 | install_element(BGP_IPV4M_NODE, | |
19309 | &no_neighbor_route_reflector_client_cmd); | |
19310 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
19311 | install_element(BGP_IPV4L_NODE, | |
19312 | &no_neighbor_route_reflector_client_cmd); | |
19313 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
19314 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
19315 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
19316 | install_element(BGP_IPV6M_NODE, | |
19317 | &no_neighbor_route_reflector_client_cmd); | |
19318 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
19319 | install_element(BGP_IPV6L_NODE, | |
19320 | &no_neighbor_route_reflector_client_cmd); | |
19321 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
19322 | install_element(BGP_VPNV4_NODE, | |
19323 | &no_neighbor_route_reflector_client_cmd); | |
19324 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
19325 | install_element(BGP_VPNV6_NODE, | |
19326 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 19327 | install_element(BGP_FLOWSPECV4_NODE, |
19328 | &neighbor_route_reflector_client_cmd); | |
19329 | install_element(BGP_FLOWSPECV4_NODE, | |
19330 | &no_neighbor_route_reflector_client_cmd); | |
19331 | install_element(BGP_FLOWSPECV6_NODE, | |
19332 | &neighbor_route_reflector_client_cmd); | |
19333 | install_element(BGP_FLOWSPECV6_NODE, | |
19334 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 19335 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
19336 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
19337 | ||
70cd87ca MK |
19338 | /* "optimal-route-reflection" commands */ |
19339 | install_element(BGP_IPV4_NODE, &optimal_route_reflection_cmd); | |
19340 | install_element(BGP_IPV4M_NODE, &optimal_route_reflection_cmd); | |
19341 | install_element(BGP_IPV4L_NODE, &optimal_route_reflection_cmd); | |
19342 | install_element(BGP_IPV6_NODE, &optimal_route_reflection_cmd); | |
19343 | install_element(BGP_IPV6M_NODE, &optimal_route_reflection_cmd); | |
19344 | install_element(BGP_IPV6L_NODE, &optimal_route_reflection_cmd); | |
19345 | install_element(BGP_VPNV4_NODE, &optimal_route_reflection_cmd); | |
19346 | install_element(BGP_VPNV6_NODE, &optimal_route_reflection_cmd); | |
19347 | install_element(BGP_FLOWSPECV4_NODE, &optimal_route_reflection_cmd); | |
19348 | install_element(BGP_FLOWSPECV6_NODE, &optimal_route_reflection_cmd); | |
19349 | install_element(BGP_EVPN_NODE, &optimal_route_reflection_cmd); | |
19350 | ||
19351 | /* "neighbor optimal-route-reflection" commands */ | |
19352 | install_element(BGP_IPV4_NODE, &neighbor_optimal_route_reflection_cmd); | |
19353 | install_element(BGP_IPV4M_NODE, &neighbor_optimal_route_reflection_cmd); | |
19354 | install_element(BGP_IPV4L_NODE, &neighbor_optimal_route_reflection_cmd); | |
19355 | install_element(BGP_IPV6_NODE, &neighbor_optimal_route_reflection_cmd); | |
19356 | install_element(BGP_IPV6M_NODE, &neighbor_optimal_route_reflection_cmd); | |
19357 | install_element(BGP_IPV6L_NODE, &neighbor_optimal_route_reflection_cmd); | |
19358 | install_element(BGP_VPNV4_NODE, &neighbor_optimal_route_reflection_cmd); | |
19359 | install_element(BGP_VPNV6_NODE, &neighbor_optimal_route_reflection_cmd); | |
19360 | install_element(BGP_FLOWSPECV4_NODE, | |
19361 | &neighbor_optimal_route_reflection_cmd); | |
19362 | install_element(BGP_FLOWSPECV6_NODE, | |
19363 | &neighbor_optimal_route_reflection_cmd); | |
19364 | install_element(BGP_EVPN_NODE, &neighbor_optimal_route_reflection_cmd); | |
19365 | ||
d62a17ae | 19366 | /* "neighbor route-server" commands.*/ |
19367 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
19368 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
19369 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
19370 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
19371 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
19372 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
19373 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
19374 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
19375 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
19376 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
19377 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
19378 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
19379 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
19380 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
19381 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
19382 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
19383 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
19384 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
19385 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
19386 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 19387 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
19388 | install_element(BGP_FLOWSPECV4_NODE, | |
19389 | &no_neighbor_route_server_client_cmd); | |
19390 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
19391 | install_element(BGP_FLOWSPECV6_NODE, | |
19392 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 19393 | |
7c0e4312 DA |
19394 | /* "neighbor disable-addpath-rx" commands. */ |
19395 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19396 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19397 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19398 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19399 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19400 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19401 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19402 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19403 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19404 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19405 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19406 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19407 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19408 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19409 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19410 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19411 | ||
d62a17ae | 19412 | /* "neighbor addpath-tx-all-paths" commands.*/ |
19413 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
19414 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
19415 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19416 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19417 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19418 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19419 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19420 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19421 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19422 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19423 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19424 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19425 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19426 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19427 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19428 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19429 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19430 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19431 | ||
19432 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
19433 | install_element(BGP_NODE, | |
19434 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19435 | install_element(BGP_NODE, | |
19436 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19437 | install_element(BGP_IPV4_NODE, | |
19438 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19439 | install_element(BGP_IPV4_NODE, | |
19440 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19441 | install_element(BGP_IPV4M_NODE, | |
19442 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19443 | install_element(BGP_IPV4M_NODE, | |
19444 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19445 | install_element(BGP_IPV4L_NODE, | |
19446 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19447 | install_element(BGP_IPV4L_NODE, | |
19448 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19449 | install_element(BGP_IPV6_NODE, | |
19450 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19451 | install_element(BGP_IPV6_NODE, | |
19452 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19453 | install_element(BGP_IPV6M_NODE, | |
19454 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19455 | install_element(BGP_IPV6M_NODE, | |
19456 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19457 | install_element(BGP_IPV6L_NODE, | |
19458 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19459 | install_element(BGP_IPV6L_NODE, | |
19460 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19461 | install_element(BGP_VPNV4_NODE, | |
19462 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19463 | install_element(BGP_VPNV4_NODE, | |
19464 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19465 | install_element(BGP_VPNV6_NODE, | |
19466 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19467 | install_element(BGP_VPNV6_NODE, | |
19468 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19469 | ||
2b31007c RZ |
19470 | /* "neighbor sender-as-path-loop-detection" commands. */ |
19471 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
19472 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
19473 | ||
d62a17ae | 19474 | /* "neighbor passive" commands. */ |
19475 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
19476 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
19477 | ||
19478 | ||
19479 | /* "neighbor shutdown" commands. */ | |
19480 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
19481 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
19482 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
19483 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
19484 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
19485 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 19486 | |
19487 | /* "neighbor capability extended-nexthop" commands.*/ | |
19488 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
19489 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
19490 | ||
19491 | /* "neighbor capability orf prefix-list" commands.*/ | |
19492 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
19493 | install_element(BGP_NODE, | |
19494 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
19495 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
19496 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19497 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19498 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19499 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19500 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19501 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
19502 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19503 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19504 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19505 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19506 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19507 | ||
19508 | /* "neighbor capability dynamic" commands.*/ | |
19509 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
19510 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
19511 | ||
19512 | /* "neighbor dont-capability-negotiate" commands. */ | |
19513 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
19514 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
19515 | ||
19516 | /* "neighbor ebgp-multihop" commands. */ | |
19517 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
19518 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
19519 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
19520 | ||
19521 | /* "neighbor disable-connected-check" commands. */ | |
19522 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
19523 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
19524 | ||
7ab294ea DA |
19525 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
19526 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
19527 | install_element(BGP_NODE, | |
19528 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 19529 | |
d08c0c80 DA |
19530 | /* "neighbor extended-optional-parameters" commands. */ |
19531 | install_element(BGP_NODE, &neighbor_extended_optional_parameters_cmd); | |
19532 | install_element(BGP_NODE, | |
19533 | &no_neighbor_extended_optional_parameters_cmd); | |
19534 | ||
47cbc09b PM |
19535 | /* "neighbor enforce-first-as" commands. */ |
19536 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
19537 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
19538 | ||
d62a17ae | 19539 | /* "neighbor description" commands. */ |
19540 | install_element(BGP_NODE, &neighbor_description_cmd); | |
19541 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 19542 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 19543 | |
19544 | /* "neighbor update-source" commands. "*/ | |
19545 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
19546 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
19547 | ||
19548 | /* "neighbor default-originate" commands. */ | |
19549 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
19550 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
19551 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
19552 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
19553 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
19554 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
19555 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
19556 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
19557 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
19558 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
19559 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
19560 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
19561 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
19562 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
19563 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
19564 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
19565 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
19566 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
19567 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
19568 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
19569 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
19570 | ||
19571 | /* "neighbor port" commands. */ | |
19572 | install_element(BGP_NODE, &neighbor_port_cmd); | |
19573 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
19574 | ||
19575 | /* "neighbor weight" commands. */ | |
19576 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
19577 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
19578 | ||
19579 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
19580 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
19581 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
19582 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
19583 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
19584 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
19585 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
19586 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
19587 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
19588 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
19589 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
19590 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
19591 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
19592 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
19593 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
19594 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
19595 | ||
19596 | /* "neighbor override-capability" commands. */ | |
19597 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
19598 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
19599 | ||
19600 | /* "neighbor strict-capability-match" commands. */ | |
19601 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
19602 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
19603 | ||
19604 | /* "neighbor timers" commands. */ | |
19605 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
19606 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
19607 | ||
19608 | /* "neighbor timers connect" commands. */ | |
19609 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
19610 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
19611 | ||
d43114f3 DS |
19612 | /* "neighbor timers delayopen" commands. */ |
19613 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
19614 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
19615 | ||
d62a17ae | 19616 | /* "neighbor advertisement-interval" commands. */ |
19617 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
19618 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
19619 | ||
19620 | /* "neighbor interface" commands. */ | |
19621 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
19622 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
19623 | ||
19624 | /* "neighbor distribute" commands. */ | |
19625 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
19626 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
19627 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
19628 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
19629 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
19630 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
19631 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
19632 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
19633 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
19634 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
19635 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
19636 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
19637 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
19638 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
19639 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
19640 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
19641 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
19642 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
19643 | ||
19644 | /* "neighbor prefix-list" commands. */ | |
19645 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 19646 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 19647 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19648 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19649 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19650 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19651 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19652 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19653 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19654 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19655 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19656 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19657 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19658 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19659 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19660 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19661 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19662 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19663 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19664 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19665 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19666 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19667 | |
19668 | /* "neighbor filter-list" commands. */ | |
19669 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
19670 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
19671 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
19672 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
19673 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
19674 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
19675 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
19676 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
19677 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
19678 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
19679 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
19680 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
19681 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
19682 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
19683 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
19684 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
19685 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
19686 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 19687 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
19688 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
19689 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
19690 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 19691 | |
19692 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
19693 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
19694 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 19695 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19696 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19697 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19698 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19699 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19700 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19701 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19702 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19703 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19704 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19705 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19706 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19707 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19708 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19709 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19710 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19711 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19712 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19713 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19714 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 19715 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19716 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19717 | |
19718 | /* "neighbor unsuppress-map" commands. */ | |
19719 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
19720 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
19721 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
19722 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19723 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
19724 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19725 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
19726 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19727 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
19728 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19729 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
19730 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19731 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
19732 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19733 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
19734 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19735 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
19736 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19737 | ||
7f7940e6 | 19738 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 19739 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 19740 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 19741 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19742 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19743 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19744 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19745 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19746 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19747 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19748 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19749 | |
fde246e8 DA |
19750 | /* neighbor maximum-prefix-out commands. */ |
19751 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
19752 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19753 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19754 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19755 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19756 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19757 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19758 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19759 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19760 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19761 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19762 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19763 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19764 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19765 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19766 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19767 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19768 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19769 | ||
d62a17ae | 19770 | /* "neighbor maximum-prefix" commands. */ |
19771 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
19772 | install_element(BGP_NODE, | |
19773 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
19774 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
19775 | install_element(BGP_NODE, | |
19776 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
19777 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
19778 | install_element(BGP_NODE, | |
19779 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
19780 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
19781 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
19782 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19783 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19784 | install_element(BGP_IPV4_NODE, | |
19785 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19786 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19787 | install_element(BGP_IPV4_NODE, | |
19788 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19789 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19790 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
19791 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19792 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19793 | install_element(BGP_IPV4M_NODE, | |
19794 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19795 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19796 | install_element(BGP_IPV4M_NODE, | |
19797 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19798 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19799 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
19800 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19801 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19802 | install_element(BGP_IPV4L_NODE, | |
19803 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19804 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19805 | install_element(BGP_IPV4L_NODE, | |
19806 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19807 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19808 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
19809 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19810 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19811 | install_element(BGP_IPV6_NODE, | |
19812 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19813 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19814 | install_element(BGP_IPV6_NODE, | |
19815 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19816 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19817 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
19818 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19819 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19820 | install_element(BGP_IPV6M_NODE, | |
19821 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19822 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19823 | install_element(BGP_IPV6M_NODE, | |
19824 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19825 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19826 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
19827 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19828 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19829 | install_element(BGP_IPV6L_NODE, | |
19830 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19831 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19832 | install_element(BGP_IPV6L_NODE, | |
19833 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19834 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19835 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
19836 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19837 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19838 | install_element(BGP_VPNV4_NODE, | |
19839 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19840 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19841 | install_element(BGP_VPNV4_NODE, | |
19842 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19843 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19844 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
19845 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19846 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19847 | install_element(BGP_VPNV6_NODE, | |
19848 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19849 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19850 | install_element(BGP_VPNV6_NODE, | |
19851 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19852 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19853 | ||
19854 | /* "neighbor allowas-in" */ | |
19855 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
19856 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
19857 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
19858 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
19859 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
19860 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
19861 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
19862 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
19863 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
19864 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
19865 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
19866 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
19867 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
19868 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
19869 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
19870 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
19871 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
19872 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
19873 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
19874 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
19875 | ||
46dbf9d0 DA |
19876 | /* neighbor accept-own */ |
19877 | install_element(BGP_VPNV4_NODE, &neighbor_accept_own_cmd); | |
19878 | install_element(BGP_VPNV6_NODE, &neighbor_accept_own_cmd); | |
19879 | ||
01da2d26 DA |
19880 | /* "neighbor soo" */ |
19881 | install_element(BGP_IPV4_NODE, &neighbor_soo_cmd); | |
19882 | install_element(BGP_IPV4_NODE, &no_neighbor_soo_cmd); | |
19883 | install_element(BGP_IPV4M_NODE, &neighbor_soo_cmd); | |
19884 | install_element(BGP_IPV4M_NODE, &no_neighbor_soo_cmd); | |
19885 | install_element(BGP_IPV4L_NODE, &neighbor_soo_cmd); | |
19886 | install_element(BGP_IPV4L_NODE, &no_neighbor_soo_cmd); | |
19887 | install_element(BGP_IPV6_NODE, &neighbor_soo_cmd); | |
19888 | install_element(BGP_IPV6_NODE, &no_neighbor_soo_cmd); | |
19889 | install_element(BGP_IPV6M_NODE, &neighbor_soo_cmd); | |
19890 | install_element(BGP_IPV6M_NODE, &no_neighbor_soo_cmd); | |
19891 | install_element(BGP_IPV6L_NODE, &neighbor_soo_cmd); | |
19892 | install_element(BGP_IPV6L_NODE, &no_neighbor_soo_cmd); | |
19893 | install_element(BGP_VPNV4_NODE, &neighbor_soo_cmd); | |
19894 | install_element(BGP_VPNV4_NODE, &no_neighbor_soo_cmd); | |
19895 | install_element(BGP_VPNV6_NODE, &neighbor_soo_cmd); | |
19896 | install_element(BGP_VPNV6_NODE, &no_neighbor_soo_cmd); | |
19897 | install_element(BGP_EVPN_NODE, &neighbor_soo_cmd); | |
19898 | install_element(BGP_EVPN_NODE, &no_neighbor_soo_cmd); | |
19899 | ||
d62a17ae | 19900 | /* address-family commands. */ |
19901 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
19902 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 19903 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 19904 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
19905 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 19906 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 19907 | |
d62a17ae | 19908 | install_element(BGP_NODE, &address_family_evpn_cmd); |
19909 | ||
19910 | /* "exit-address-family" command. */ | |
19911 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
19912 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
19913 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
19914 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
19915 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
19916 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
19917 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
19918 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 19919 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
19920 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 19921 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
19922 | ||
a486300b PG |
19923 | /* BGP retain all route-target */ |
19924 | install_element(BGP_VPNV4_NODE, &bgp_retain_route_target_cmd); | |
19925 | install_element(BGP_VPNV6_NODE, &bgp_retain_route_target_cmd); | |
19926 | ||
d62a17ae | 19927 | /* "clear ip bgp commands" */ |
19928 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
19929 | ||
19930 | /* clear ip bgp prefix */ | |
19931 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
19932 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
19933 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
19934 | ||
19935 | /* "show [ip] bgp summary" commands. */ | |
19936 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 19937 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 19938 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 19939 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 19940 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
19941 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 19942 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
19943 | ||
19944 | /* "show [ip] bgp neighbors" commands. */ | |
19945 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
19946 | ||
36235319 | 19947 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 19948 | |
d62a17ae | 19949 | /* "show [ip] bgp peer-group" commands. */ |
19950 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
19951 | ||
19952 | /* "show [ip] bgp paths" commands. */ | |
19953 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
19954 | ||
19955 | /* "show [ip] bgp community" commands. */ | |
19956 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
19957 | ||
19958 | /* "show ip bgp large-community" commands. */ | |
19959 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
19960 | /* "show [ip] bgp attribute-info" commands. */ | |
19961 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 19962 | /* "show [ip] bgp route-leak" command */ |
19963 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 19964 | |
19965 | /* "redistribute" commands. */ | |
19966 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
19967 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
19968 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
19969 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
19970 | install_element(BGP_NODE, | |
19971 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
19972 | install_element(BGP_NODE, | |
19973 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
19974 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19975 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19976 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
19977 | install_element(BGP_NODE, | |
19978 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
19979 | install_element(BGP_NODE, | |
19980 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
19981 | install_element(BGP_NODE, | |
19982 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
19983 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
19984 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
19985 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
19986 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
19987 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
19988 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
19989 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
19990 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
19991 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
19992 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
19993 | install_element(BGP_IPV4_NODE, | |
19994 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
19995 | install_element(BGP_IPV4_NODE, | |
19996 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
19997 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
19998 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
19999 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
20000 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
20001 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
20002 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
20003 | ||
70dd370f | 20004 | /* import|export vpn [route-map RMAP_NAME] */ |
b9c7bc5a PZ |
20005 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); |
20006 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 20007 | |
12a844a5 DS |
20008 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
20009 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
20010 | ||
d62a17ae | 20011 | /* ttl_security commands */ |
20012 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
20013 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
20014 | ||
d1adb448 PG |
20015 | /* "bgp tcp-keepalive" commands */ |
20016 | install_element(BGP_NODE, &bgp_tcp_keepalive_cmd); | |
20017 | install_element(BGP_NODE, &no_bgp_tcp_keepalive_cmd); | |
20018 | ||
d62a17ae | 20019 | /* "show [ip] bgp memory" commands. */ |
20020 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
20021 | ||
acf71666 MK |
20022 | /* "show bgp martian next-hop" */ |
20023 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
20024 | ||
48ecf8f5 DS |
20025 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
20026 | ||
d62a17ae | 20027 | /* "show [ip] bgp views" commands. */ |
20028 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
20029 | ||
20030 | /* "show [ip] bgp vrfs" commands. */ | |
20031 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
20032 | ||
20033 | /* Community-list. */ | |
20034 | community_list_vty(); | |
ddb5b488 | 20035 | |
ed0e57e3 DA |
20036 | community_alias_vty(); |
20037 | ||
ddb5b488 | 20038 | /* vpn-policy commands */ |
b9c7bc5a PZ |
20039 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
20040 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
20041 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
20042 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
20043 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
20044 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
20045 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
20046 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
20047 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
20048 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20049 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
20050 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 20051 | |
301ad80a PG |
20052 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
20053 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
20054 | ||
b9c7bc5a PZ |
20055 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
20056 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
20057 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
20058 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
20059 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
20060 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
20061 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
20062 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20063 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
20064 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
20065 | |
20066 | /* tcp-mss command */ | |
20067 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
20068 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
20069 | |
20070 | /* srv6 commands */ | |
ea372e81 | 20071 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 20072 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 20073 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 20074 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 20075 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
20076 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
20077 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
527588aa | 20078 | install_element(BGP_NODE, &bgp_sid_vpn_export_cmd); |
e606d8ec | 20079 | install_element(BGP_NODE, &no_bgp_sid_vpn_export_cmd); |
4cd690ae PG |
20080 | |
20081 | bgp_vty_if_init(); | |
718e3744 | 20082 | } |
6b0655a2 | 20083 | |
718e3744 | 20084 | #include "memory.h" |
20085 | #include "bgp_regex.h" | |
20086 | #include "bgp_clist.h" | |
20087 | #include "bgp_ecommunity.h" | |
20088 | ||
20089 | /* VTY functions. */ | |
20090 | ||
20091 | /* Direction value to string conversion. */ | |
d62a17ae | 20092 | static const char *community_direct_str(int direct) |
20093 | { | |
20094 | switch (direct) { | |
20095 | case COMMUNITY_DENY: | |
20096 | return "deny"; | |
20097 | case COMMUNITY_PERMIT: | |
20098 | return "permit"; | |
20099 | default: | |
20100 | return "unknown"; | |
20101 | } | |
718e3744 | 20102 | } |
20103 | ||
20104 | /* Display error string. */ | |
d62a17ae | 20105 | static void community_list_perror(struct vty *vty, int ret) |
20106 | { | |
20107 | switch (ret) { | |
20108 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
20109 | vty_out(vty, "%% Can't find community-list\n"); | |
20110 | break; | |
20111 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
20112 | vty_out(vty, "%% Malformed community-list value\n"); | |
20113 | break; | |
20114 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
20115 | vty_out(vty, | |
20116 | "%% Community name conflict, previously defined as standard community\n"); | |
20117 | break; | |
20118 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
20119 | vty_out(vty, | |
20120 | "%% Community name conflict, previously defined as expanded community\n"); | |
20121 | break; | |
20122 | } | |
718e3744 | 20123 | } |
20124 | ||
5bf15956 DW |
20125 | /* "community-list" keyword help string. */ |
20126 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
20127 | ||
7336e101 SP |
20128 | /*community-list standard */ |
20129 | DEFUN (community_list_standard, | |
20130 | bgp_community_list_standard_cmd, | |
a2099c1d | 20131 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20132 | BGP_STR |
718e3744 | 20133 | COMMUNITY_LIST_STR |
20134 | "Community list number (standard)\n" | |
5bf15956 | 20135 | "Add an standard community-list entry\n" |
718e3744 | 20136 | "Community list name\n" |
2f8cc0e5 DA |
20137 | "Sequence number of an entry\n" |
20138 | "Sequence number\n" | |
718e3744 | 20139 | "Specify community to reject\n" |
20140 | "Specify community to accept\n" | |
20141 | COMMUNITY_VAL_STR) | |
20142 | { | |
d62a17ae | 20143 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20144 | char *seq = NULL; |
d62a17ae | 20145 | int direct = 0; |
20146 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 20147 | int idx = 0; |
7336e101 | 20148 | |
e34627f9 | 20149 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20150 | seq = argv[idx]->arg; |
20151 | ||
20152 | idx = 0; | |
d62a17ae | 20153 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20154 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20155 | cl_name_or_number = argv[idx]->arg; |
20156 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20157 | : COMMUNITY_DENY; | |
20158 | argv_find(argv, argc, "AA:NN", &idx); | |
20159 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20160 | |
2f8cc0e5 DA |
20161 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20162 | direct, style); | |
42f914d4 | 20163 | |
d62a17ae | 20164 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20165 | |
d62a17ae | 20166 | if (ret < 0) { |
20167 | /* Display error string. */ | |
20168 | community_list_perror(vty, ret); | |
20169 | return CMD_WARNING_CONFIG_FAILED; | |
20170 | } | |
42f914d4 | 20171 | |
d62a17ae | 20172 | return CMD_SUCCESS; |
718e3744 | 20173 | } |
20174 | ||
7336e101 SP |
20175 | DEFUN (no_community_list_standard_all, |
20176 | no_bgp_community_list_standard_all_cmd, | |
a2099c1d | 20177 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20178 | NO_STR |
20179 | BGP_STR | |
20180 | COMMUNITY_LIST_STR | |
20181 | "Community list number (standard)\n" | |
20182 | "Add an standard community-list entry\n" | |
20183 | "Community list name\n" | |
2f8cc0e5 DA |
20184 | "Sequence number of an entry\n" |
20185 | "Sequence number\n" | |
7336e101 SP |
20186 | "Specify community to reject\n" |
20187 | "Specify community to accept\n" | |
20188 | COMMUNITY_VAL_STR) | |
718e3744 | 20189 | { |
d62a17ae | 20190 | char *cl_name_or_number = NULL; |
174b5cb9 | 20191 | char *str = NULL; |
d62a17ae | 20192 | int direct = 0; |
20193 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 20194 | char *seq = NULL; |
d62a17ae | 20195 | int idx = 0; |
7336e101 | 20196 | |
e34627f9 | 20197 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20198 | seq = argv[idx]->arg; |
20199 | ||
20200 | idx = 0; | |
174b5cb9 DA |
20201 | argv_find(argv, argc, "permit", &idx); |
20202 | argv_find(argv, argc, "deny", &idx); | |
20203 | ||
20204 | if (idx) { | |
20205 | direct = argv_find(argv, argc, "permit", &idx) | |
20206 | ? COMMUNITY_PERMIT | |
20207 | : COMMUNITY_DENY; | |
20208 | ||
20209 | idx = 0; | |
20210 | argv_find(argv, argc, "AA:NN", &idx); | |
20211 | str = argv_concat(argv, argc, idx); | |
20212 | } | |
20213 | ||
20214 | idx = 0; | |
d62a17ae | 20215 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20216 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20217 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20218 | |
2f8cc0e5 | 20219 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20220 | direct, style); |
42f914d4 | 20221 | |
d62a17ae | 20222 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20223 | |
d62a17ae | 20224 | if (ret < 0) { |
20225 | community_list_perror(vty, ret); | |
20226 | return CMD_WARNING_CONFIG_FAILED; | |
20227 | } | |
42f914d4 | 20228 | |
d62a17ae | 20229 | return CMD_SUCCESS; |
718e3744 | 20230 | } |
7336e101 | 20231 | |
174b5cb9 | 20232 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
a2099c1d | 20233 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", |
174b5cb9 DA |
20234 | NO_STR BGP_STR COMMUNITY_LIST_STR |
20235 | "Community list number (standard)\n" | |
20236 | "Add an standard community-list entry\n" | |
20237 | "Community list name\n") | |
20238 | ||
7336e101 SP |
20239 | /*community-list expanded */ |
20240 | DEFUN (community_list_expanded_all, | |
20241 | bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20242 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20243 | BGP_STR |
20244 | COMMUNITY_LIST_STR | |
718e3744 | 20245 | "Community list number (expanded)\n" |
5bf15956 | 20246 | "Add an expanded community-list entry\n" |
718e3744 | 20247 | "Community list name\n" |
2f8cc0e5 DA |
20248 | "Sequence number of an entry\n" |
20249 | "Sequence number\n" | |
718e3744 | 20250 | "Specify community to reject\n" |
20251 | "Specify community to accept\n" | |
20252 | COMMUNITY_VAL_STR) | |
20253 | { | |
d62a17ae | 20254 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20255 | char *seq = NULL; |
d62a17ae | 20256 | int direct = 0; |
20257 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20258 | int idx = 0; |
7b9a4750 | 20259 | |
e34627f9 | 20260 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20261 | seq = argv[idx]->arg; |
20262 | ||
20263 | idx = 0; | |
20264 | ||
d62a17ae | 20265 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20266 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20267 | cl_name_or_number = argv[idx]->arg; |
20268 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20269 | : COMMUNITY_DENY; | |
20270 | argv_find(argv, argc, "AA:NN", &idx); | |
20271 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20272 | |
2f8cc0e5 DA |
20273 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20274 | direct, style); | |
42f914d4 | 20275 | |
d62a17ae | 20276 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20277 | |
d62a17ae | 20278 | if (ret < 0) { |
20279 | /* Display error string. */ | |
20280 | community_list_perror(vty, ret); | |
20281 | return CMD_WARNING_CONFIG_FAILED; | |
20282 | } | |
42f914d4 | 20283 | |
d62a17ae | 20284 | return CMD_SUCCESS; |
718e3744 | 20285 | } |
20286 | ||
7336e101 SP |
20287 | DEFUN (no_community_list_expanded_all, |
20288 | no_bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20289 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20290 | NO_STR |
20291 | BGP_STR | |
20292 | COMMUNITY_LIST_STR | |
20293 | "Community list number (expanded)\n" | |
20294 | "Add an expanded community-list entry\n" | |
20295 | "Community list name\n" | |
2f8cc0e5 DA |
20296 | "Sequence number of an entry\n" |
20297 | "Sequence number\n" | |
7336e101 SP |
20298 | "Specify community to reject\n" |
20299 | "Specify community to accept\n" | |
20300 | COMMUNITY_VAL_STR) | |
718e3744 | 20301 | { |
d62a17ae | 20302 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20303 | char *seq = NULL; |
174b5cb9 | 20304 | char *str = NULL; |
d62a17ae | 20305 | int direct = 0; |
20306 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20307 | int idx = 0; |
174b5cb9 | 20308 | |
e34627f9 | 20309 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20310 | seq = argv[idx]->arg; |
20311 | ||
20312 | idx = 0; | |
174b5cb9 DA |
20313 | argv_find(argv, argc, "permit", &idx); |
20314 | argv_find(argv, argc, "deny", &idx); | |
20315 | ||
20316 | if (idx) { | |
20317 | direct = argv_find(argv, argc, "permit", &idx) | |
20318 | ? COMMUNITY_PERMIT | |
20319 | : COMMUNITY_DENY; | |
20320 | ||
20321 | idx = 0; | |
20322 | argv_find(argv, argc, "AA:NN", &idx); | |
20323 | str = argv_concat(argv, argc, idx); | |
7336e101 | 20324 | } |
174b5cb9 DA |
20325 | |
20326 | idx = 0; | |
d62a17ae | 20327 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20328 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20329 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20330 | |
2f8cc0e5 | 20331 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20332 | direct, style); |
42f914d4 | 20333 | |
d62a17ae | 20334 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20335 | |
d62a17ae | 20336 | if (ret < 0) { |
20337 | community_list_perror(vty, ret); | |
20338 | return CMD_WARNING_CONFIG_FAILED; | |
20339 | } | |
42f914d4 | 20340 | |
d62a17ae | 20341 | return CMD_SUCCESS; |
718e3744 | 20342 | } |
20343 | ||
36d4bb44 EB |
20344 | ALIAS(no_community_list_expanded_all, |
20345 | no_bgp_community_list_expanded_all_list_cmd, | |
a2099c1d | 20346 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", |
36d4bb44 | 20347 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
20348 | "Community list number (expanded)\n" |
20349 | "Add an expanded community-list entry\n" | |
20350 | "Community list name\n") | |
20351 | ||
8d9b8ed9 PM |
20352 | /* Return configuration string of community-list entry. */ |
20353 | static const char *community_list_config_str(struct community_entry *entry) | |
20354 | { | |
20355 | const char *str; | |
20356 | ||
20357 | if (entry->any) | |
20358 | str = ""; | |
20359 | else { | |
20360 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
c0945b78 | 20361 | str = community_str(entry->u.com, false, false); |
8d9b8ed9 | 20362 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) |
c0945b78 | 20363 | str = lcommunity_str(entry->u.lcom, false, false); |
8d9b8ed9 PM |
20364 | else |
20365 | str = entry->config; | |
20366 | } | |
20367 | return str; | |
20368 | } | |
20369 | ||
d62a17ae | 20370 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20371 | { |
d62a17ae | 20372 | struct community_entry *entry; |
718e3744 | 20373 | |
d62a17ae | 20374 | for (entry = list->head; entry; entry = entry->next) { |
20375 | if (entry == list->head) { | |
20376 | if (all_digit(list->name)) | |
20377 | vty_out(vty, "Community %s list %s\n", | |
20378 | entry->style == COMMUNITY_LIST_STANDARD | |
20379 | ? "standard" | |
20380 | : "(expanded) access", | |
20381 | list->name); | |
20382 | else | |
20383 | vty_out(vty, "Named Community %s list %s\n", | |
20384 | entry->style == COMMUNITY_LIST_STANDARD | |
20385 | ? "standard" | |
20386 | : "expanded", | |
20387 | list->name); | |
20388 | } | |
20389 | if (entry->any) | |
20390 | vty_out(vty, " %s\n", | |
20391 | community_direct_str(entry->direct)); | |
20392 | else | |
20393 | vty_out(vty, " %s %s\n", | |
20394 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20395 | community_list_config_str(entry)); |
d62a17ae | 20396 | } |
718e3744 | 20397 | } |
20398 | ||
7336e101 SP |
20399 | DEFUN (show_community_list, |
20400 | show_bgp_community_list_cmd, | |
20401 | "show bgp community-list", | |
718e3744 | 20402 | SHOW_STR |
7336e101 | 20403 | BGP_STR |
718e3744 | 20404 | "List community-list\n") |
20405 | { | |
d62a17ae | 20406 | struct community_list *list; |
20407 | struct community_list_master *cm; | |
718e3744 | 20408 | |
d62a17ae | 20409 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
20410 | if (!cm) | |
20411 | return CMD_SUCCESS; | |
718e3744 | 20412 | |
d62a17ae | 20413 | for (list = cm->num.head; list; list = list->next) |
20414 | community_list_show(vty, list); | |
718e3744 | 20415 | |
d62a17ae | 20416 | for (list = cm->str.head; list; list = list->next) |
20417 | community_list_show(vty, list); | |
718e3744 | 20418 | |
d62a17ae | 20419 | return CMD_SUCCESS; |
718e3744 | 20420 | } |
20421 | ||
7336e101 SP |
20422 | DEFUN (show_community_list_arg, |
20423 | show_bgp_community_list_arg_cmd, | |
a2099c1d | 20424 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20425 | SHOW_STR |
20426 | BGP_STR | |
718e3744 | 20427 | "List community-list\n" |
20428 | "Community-list number\n" | |
960b69b9 | 20429 | "Community-list name\n" |
20430 | "Detailed information on community-list\n") | |
718e3744 | 20431 | { |
d62a17ae | 20432 | int idx_comm_list = 3; |
20433 | struct community_list *list; | |
718e3744 | 20434 | |
e237b0d2 | 20435 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20436 | COMMUNITY_LIST_MASTER); |
20437 | if (!list) { | |
20438 | vty_out(vty, "%% Can't find community-list\n"); | |
20439 | return CMD_WARNING; | |
20440 | } | |
718e3744 | 20441 | |
d62a17ae | 20442 | community_list_show(vty, list); |
718e3744 | 20443 | |
d62a17ae | 20444 | return CMD_SUCCESS; |
718e3744 | 20445 | } |
6b0655a2 | 20446 | |
57d187bc JS |
20447 | /* |
20448 | * Large Community code. | |
20449 | */ | |
d62a17ae | 20450 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
20451 | struct cmd_token **argv, int style, | |
20452 | int reject_all_digit_name) | |
20453 | { | |
20454 | int ret; | |
20455 | int direct; | |
20456 | char *str; | |
20457 | int idx = 0; | |
20458 | char *cl_name; | |
2f8cc0e5 DA |
20459 | char *seq = NULL; |
20460 | ||
a08032fe | 20461 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20462 | seq = argv[idx]->arg; |
d62a17ae | 20463 | |
2f8cc0e5 | 20464 | idx = 0; |
d62a17ae | 20465 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20466 | : COMMUNITY_DENY; | |
20467 | ||
20468 | /* All digit name check. */ | |
20469 | idx = 0; | |
a2099c1d | 20470 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20471 | argv_find(argv, argc, "(1-99)", &idx); |
20472 | argv_find(argv, argc, "(100-500)", &idx); | |
20473 | cl_name = argv[idx]->arg; | |
20474 | if (reject_all_digit_name && all_digit(cl_name)) { | |
20475 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
20476 | return CMD_WARNING_CONFIG_FAILED; | |
20477 | } | |
20478 | ||
20479 | idx = 0; | |
20480 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
20481 | argv_find(argv, argc, "LINE", &idx); | |
20482 | /* Concat community string argument. */ | |
20483 | if (idx) | |
20484 | str = argv_concat(argv, argc, idx); | |
20485 | else | |
20486 | str = NULL; | |
20487 | ||
2f8cc0e5 | 20488 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 20489 | |
20490 | /* Free temporary community list string allocated by | |
20491 | argv_concat(). */ | |
0a22ddfb | 20492 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20493 | |
20494 | if (ret < 0) { | |
20495 | community_list_perror(vty, ret); | |
20496 | return CMD_WARNING_CONFIG_FAILED; | |
20497 | } | |
20498 | return CMD_SUCCESS; | |
20499 | } | |
20500 | ||
20501 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
20502 | struct cmd_token **argv, int style) | |
20503 | { | |
20504 | int ret; | |
20505 | int direct = 0; | |
20506 | char *str = NULL; | |
20507 | int idx = 0; | |
2f8cc0e5 | 20508 | char *seq = NULL; |
d62a17ae | 20509 | |
a08032fe | 20510 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20511 | seq = argv[idx]->arg; |
d62a17ae | 20512 | |
2f8cc0e5 | 20513 | idx = 0; |
d62a17ae | 20514 | argv_find(argv, argc, "permit", &idx); |
20515 | argv_find(argv, argc, "deny", &idx); | |
20516 | ||
20517 | if (idx) { | |
20518 | /* Check the list direct. */ | |
20519 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
20520 | direct = COMMUNITY_PERMIT; | |
20521 | else | |
20522 | direct = COMMUNITY_DENY; | |
20523 | ||
20524 | idx = 0; | |
20525 | argv_find(argv, argc, "LINE", &idx); | |
20526 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
20527 | /* Concat community string argument. */ | |
20528 | str = argv_concat(argv, argc, idx); | |
20529 | } | |
20530 | ||
20531 | idx = 0; | |
20532 | argv_find(argv, argc, "(1-99)", &idx); | |
20533 | argv_find(argv, argc, "(100-500)", &idx); | |
a2099c1d | 20534 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20535 | |
20536 | /* Unset community list. */ | |
2f8cc0e5 | 20537 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 20538 | style); |
20539 | ||
20540 | /* Free temporary community list string allocated by | |
20541 | argv_concat(). */ | |
0a22ddfb | 20542 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20543 | |
20544 | if (ret < 0) { | |
20545 | community_list_perror(vty, ret); | |
20546 | return CMD_WARNING_CONFIG_FAILED; | |
20547 | } | |
20548 | ||
20549 | return CMD_SUCCESS; | |
57d187bc JS |
20550 | } |
20551 | ||
20552 | /* "large-community-list" keyword help string. */ | |
20553 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
20554 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
20555 | ||
7336e101 SP |
20556 | DEFUN (lcommunity_list_standard, |
20557 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20558 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20559 | BGP_STR |
20560 | LCOMMUNITY_LIST_STR | |
20561 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20562 | "Sequence number of an entry\n" |
20563 | "Sequence number\n" | |
7336e101 SP |
20564 | "Specify large community to reject\n" |
20565 | "Specify large community to accept\n" | |
20566 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20567 | { |
d62a17ae | 20568 | return lcommunity_list_set_vty(vty, argc, argv, |
20569 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
20570 | } |
20571 | ||
7336e101 SP |
20572 | DEFUN (lcommunity_list_expanded, |
20573 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20574 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20575 | BGP_STR |
20576 | LCOMMUNITY_LIST_STR | |
20577 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20578 | "Sequence number of an entry\n" |
20579 | "Sequence number\n" | |
7336e101 SP |
20580 | "Specify large community to reject\n" |
20581 | "Specify large community to accept\n" | |
20582 | "An ordered list as a regular-expression\n") | |
57d187bc | 20583 | { |
d62a17ae | 20584 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20585 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
20586 | } |
20587 | ||
7336e101 SP |
20588 | DEFUN (lcommunity_list_name_standard, |
20589 | bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20590 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20591 | BGP_STR |
20592 | LCOMMUNITY_LIST_STR | |
20593 | "Specify standard large-community-list\n" | |
20594 | "Large Community list name\n" | |
2f8cc0e5 DA |
20595 | "Sequence number of an entry\n" |
20596 | "Sequence number\n" | |
7336e101 SP |
20597 | "Specify large community to reject\n" |
20598 | "Specify large community to accept\n" | |
20599 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20600 | { |
d62a17ae | 20601 | return lcommunity_list_set_vty(vty, argc, argv, |
20602 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
20603 | } |
20604 | ||
7336e101 SP |
20605 | DEFUN (lcommunity_list_name_expanded, |
20606 | bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20607 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20608 | BGP_STR |
20609 | LCOMMUNITY_LIST_STR | |
20610 | "Specify expanded large-community-list\n" | |
20611 | "Large Community list name\n" | |
2f8cc0e5 DA |
20612 | "Sequence number of an entry\n" |
20613 | "Sequence number\n" | |
7336e101 SP |
20614 | "Specify large community to reject\n" |
20615 | "Specify large community to accept\n" | |
20616 | "An ordered list as a regular-expression\n") | |
57d187bc | 20617 | { |
d62a17ae | 20618 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20619 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
20620 | } |
20621 | ||
4378f57c DA |
20622 | DEFUN (no_lcommunity_list_all, |
20623 | no_bgp_lcommunity_list_all_cmd, | |
a2099c1d | 20624 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", |
7336e101 SP |
20625 | NO_STR |
20626 | BGP_STR | |
20627 | LCOMMUNITY_LIST_STR | |
20628 | "Large Community list number (standard)\n" | |
20629 | "Large Community list number (expanded)\n" | |
20630 | "Large Community list name\n") | |
57d187bc | 20631 | { |
7336e101 SP |
20632 | return lcommunity_list_unset_vty(vty, argc, argv, |
20633 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
20634 | } |
20635 | ||
4378f57c DA |
20636 | DEFUN (no_lcommunity_list_name_standard_all, |
20637 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
a2099c1d | 20638 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", |
4378f57c DA |
20639 | NO_STR |
20640 | BGP_STR | |
20641 | LCOMMUNITY_LIST_STR | |
20642 | "Specify standard large-community-list\n" | |
20643 | "Large Community list name\n") | |
20644 | { | |
20645 | return lcommunity_list_unset_vty(vty, argc, argv, | |
20646 | LARGE_COMMUNITY_LIST_STANDARD); | |
20647 | } | |
20648 | ||
7336e101 SP |
20649 | DEFUN (no_lcommunity_list_name_expanded_all, |
20650 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
a2099c1d | 20651 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", |
7336e101 SP |
20652 | NO_STR |
20653 | BGP_STR | |
20654 | LCOMMUNITY_LIST_STR | |
20655 | "Specify expanded large-community-list\n" | |
20656 | "Large Community list name\n") | |
57d187bc | 20657 | { |
d62a17ae | 20658 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20659 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20660 | } |
20661 | ||
7336e101 SP |
20662 | DEFUN (no_lcommunity_list_standard, |
20663 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20664 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20665 | NO_STR |
20666 | BGP_STR | |
20667 | LCOMMUNITY_LIST_STR | |
20668 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20669 | "Sequence number of an entry\n" |
20670 | "Sequence number\n" | |
7336e101 SP |
20671 | "Specify large community to reject\n" |
20672 | "Specify large community to accept\n" | |
20673 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20674 | { |
d62a17ae | 20675 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20676 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20677 | } |
20678 | ||
7336e101 SP |
20679 | DEFUN (no_lcommunity_list_expanded, |
20680 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20681 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20682 | NO_STR |
20683 | BGP_STR | |
20684 | LCOMMUNITY_LIST_STR | |
20685 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20686 | "Sequence number of an entry\n" |
20687 | "Sequence number\n" | |
7336e101 SP |
20688 | "Specify large community to reject\n" |
20689 | "Specify large community to accept\n" | |
20690 | "An ordered list as a regular-expression\n") | |
57d187bc | 20691 | { |
d62a17ae | 20692 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20693 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20694 | } |
20695 | ||
7336e101 SP |
20696 | DEFUN (no_lcommunity_list_name_standard, |
20697 | no_bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20698 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20699 | NO_STR |
20700 | BGP_STR | |
20701 | LCOMMUNITY_LIST_STR | |
20702 | "Specify standard large-community-list\n" | |
20703 | "Large Community list name\n" | |
2f8cc0e5 DA |
20704 | "Sequence number of an entry\n" |
20705 | "Sequence number\n" | |
7336e101 SP |
20706 | "Specify large community to reject\n" |
20707 | "Specify large community to accept\n" | |
20708 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20709 | { |
d62a17ae | 20710 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20711 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20712 | } |
20713 | ||
7336e101 SP |
20714 | DEFUN (no_lcommunity_list_name_expanded, |
20715 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20716 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20717 | NO_STR |
20718 | BGP_STR | |
20719 | LCOMMUNITY_LIST_STR | |
20720 | "Specify expanded large-community-list\n" | |
20721 | "Large community list name\n" | |
2f8cc0e5 DA |
20722 | "Sequence number of an entry\n" |
20723 | "Sequence number\n" | |
7336e101 SP |
20724 | "Specify large community to reject\n" |
20725 | "Specify large community to accept\n" | |
20726 | "An ordered list as a regular-expression\n") | |
57d187bc | 20727 | { |
d62a17ae | 20728 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20729 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20730 | } |
20731 | ||
d62a17ae | 20732 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
20733 | { | |
20734 | struct community_entry *entry; | |
20735 | ||
20736 | for (entry = list->head; entry; entry = entry->next) { | |
20737 | if (entry == list->head) { | |
20738 | if (all_digit(list->name)) | |
20739 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 20740 | entry->style == |
20741 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20742 | ? "standard" |
20743 | : "(expanded) access", | |
20744 | list->name); | |
20745 | else | |
20746 | vty_out(vty, | |
20747 | "Named large community %s list %s\n", | |
169b72c8 | 20748 | entry->style == |
20749 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20750 | ? "standard" |
20751 | : "expanded", | |
20752 | list->name); | |
20753 | } | |
20754 | if (entry->any) | |
20755 | vty_out(vty, " %s\n", | |
20756 | community_direct_str(entry->direct)); | |
20757 | else | |
20758 | vty_out(vty, " %s %s\n", | |
20759 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20760 | community_list_config_str(entry)); |
d62a17ae | 20761 | } |
57d187bc JS |
20762 | } |
20763 | ||
7336e101 SP |
20764 | DEFUN (show_lcommunity_list, |
20765 | show_bgp_lcommunity_list_cmd, | |
20766 | "show bgp large-community-list", | |
57d187bc | 20767 | SHOW_STR |
7336e101 | 20768 | BGP_STR |
57d187bc JS |
20769 | "List large-community list\n") |
20770 | { | |
d62a17ae | 20771 | struct community_list *list; |
20772 | struct community_list_master *cm; | |
57d187bc | 20773 | |
d62a17ae | 20774 | cm = community_list_master_lookup(bgp_clist, |
20775 | LARGE_COMMUNITY_LIST_MASTER); | |
20776 | if (!cm) | |
20777 | return CMD_SUCCESS; | |
57d187bc | 20778 | |
d62a17ae | 20779 | for (list = cm->num.head; list; list = list->next) |
20780 | lcommunity_list_show(vty, list); | |
57d187bc | 20781 | |
d62a17ae | 20782 | for (list = cm->str.head; list; list = list->next) |
20783 | lcommunity_list_show(vty, list); | |
57d187bc | 20784 | |
d62a17ae | 20785 | return CMD_SUCCESS; |
57d187bc JS |
20786 | } |
20787 | ||
7336e101 SP |
20788 | DEFUN (show_lcommunity_list_arg, |
20789 | show_bgp_lcommunity_list_arg_cmd, | |
a2099c1d | 20790 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20791 | SHOW_STR |
20792 | BGP_STR | |
57d187bc | 20793 | "List large-community list\n" |
960b69b9 | 20794 | "Large-community-list number\n" |
20795 | "Large-community-list name\n" | |
20796 | "Detailed information on large-community-list\n") | |
57d187bc | 20797 | { |
d62a17ae | 20798 | struct community_list *list; |
57d187bc | 20799 | |
e237b0d2 | 20800 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 20801 | LARGE_COMMUNITY_LIST_MASTER); |
20802 | if (!list) { | |
960b69b9 | 20803 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 20804 | return CMD_WARNING; |
20805 | } | |
57d187bc | 20806 | |
d62a17ae | 20807 | lcommunity_list_show(vty, list); |
57d187bc | 20808 | |
d62a17ae | 20809 | return CMD_SUCCESS; |
57d187bc JS |
20810 | } |
20811 | ||
718e3744 | 20812 | /* "extcommunity-list" keyword help string. */ |
20813 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
20814 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
20815 | ||
7336e101 SP |
20816 | DEFUN (extcommunity_list_standard, |
20817 | bgp_extcommunity_list_standard_cmd, | |
a2099c1d | 20818 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20819 | BGP_STR |
718e3744 | 20820 | EXTCOMMUNITY_LIST_STR |
20821 | "Extended Community list number (standard)\n" | |
718e3744 | 20822 | "Specify standard extcommunity-list\n" |
5bf15956 | 20823 | "Community list name\n" |
2f8cc0e5 DA |
20824 | "Sequence number of an entry\n" |
20825 | "Sequence number\n" | |
718e3744 | 20826 | "Specify community to reject\n" |
20827 | "Specify community to accept\n" | |
20828 | EXTCOMMUNITY_VAL_STR) | |
20829 | { | |
d62a17ae | 20830 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20831 | int direct = 0; | |
20832 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20833 | char *seq = NULL; |
42f914d4 | 20834 | |
d62a17ae | 20835 | int idx = 0; |
7b9a4750 | 20836 | |
d62a17ae | 20837 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20838 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20839 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20840 | |
a08032fe | 20841 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20842 | seq = argv[idx]->arg; |
20843 | ||
d62a17ae | 20844 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20845 | : COMMUNITY_DENY; | |
20846 | argv_find(argv, argc, "AA:NN", &idx); | |
20847 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20848 | |
2f8cc0e5 | 20849 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20850 | direct, style); |
42f914d4 | 20851 | |
d62a17ae | 20852 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20853 | |
d62a17ae | 20854 | if (ret < 0) { |
20855 | community_list_perror(vty, ret); | |
20856 | return CMD_WARNING_CONFIG_FAILED; | |
20857 | } | |
42f914d4 | 20858 | |
d62a17ae | 20859 | return CMD_SUCCESS; |
718e3744 | 20860 | } |
20861 | ||
7336e101 SP |
20862 | DEFUN (extcommunity_list_name_expanded, |
20863 | bgp_extcommunity_list_name_expanded_cmd, | |
a2099c1d | 20864 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20865 | BGP_STR |
20866 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 20867 | "Extended Community list number (expanded)\n" |
718e3744 | 20868 | "Specify expanded extcommunity-list\n" |
20869 | "Extended Community list name\n" | |
2f8cc0e5 DA |
20870 | "Sequence number of an entry\n" |
20871 | "Sequence number\n" | |
718e3744 | 20872 | "Specify community to reject\n" |
20873 | "Specify community to accept\n" | |
20874 | "An ordered list as a regular-expression\n") | |
20875 | { | |
d62a17ae | 20876 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20877 | int direct = 0; | |
20878 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20879 | char *seq = NULL; |
d62a17ae | 20880 | int idx = 0; |
7336e101 | 20881 | |
d62a17ae | 20882 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20883 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20884 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20885 | |
a08032fe | 20886 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20887 | seq = argv[idx]->arg; |
20888 | ||
d62a17ae | 20889 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20890 | : COMMUNITY_DENY; | |
20891 | argv_find(argv, argc, "LINE", &idx); | |
20892 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20893 | |
2f8cc0e5 | 20894 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20895 | direct, style); |
42f914d4 | 20896 | |
d62a17ae | 20897 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20898 | |
d62a17ae | 20899 | if (ret < 0) { |
20900 | community_list_perror(vty, ret); | |
20901 | return CMD_WARNING_CONFIG_FAILED; | |
20902 | } | |
42f914d4 | 20903 | |
d62a17ae | 20904 | return CMD_SUCCESS; |
718e3744 | 20905 | } |
20906 | ||
7336e101 SP |
20907 | DEFUN (no_extcommunity_list_standard_all, |
20908 | no_bgp_extcommunity_list_standard_all_cmd, | |
a2099c1d | 20909 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20910 | NO_STR |
20911 | BGP_STR | |
20912 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 20913 | "Extended Community list number (standard)\n" |
718e3744 | 20914 | "Specify standard extcommunity-list\n" |
5bf15956 | 20915 | "Community list name\n" |
2f8cc0e5 DA |
20916 | "Sequence number of an entry\n" |
20917 | "Sequence number\n" | |
718e3744 | 20918 | "Specify community to reject\n" |
20919 | "Specify community to accept\n" | |
20920 | EXTCOMMUNITY_VAL_STR) | |
20921 | { | |
d62a17ae | 20922 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20923 | int direct = 0; | |
20924 | char *cl_number_or_name = NULL; | |
d4455c89 | 20925 | char *str = NULL; |
2f8cc0e5 | 20926 | char *seq = NULL; |
d62a17ae | 20927 | int idx = 0; |
d4455c89 | 20928 | |
a08032fe | 20929 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20930 | seq = argv[idx]->arg; |
20931 | ||
20932 | idx = 0; | |
d4455c89 DA |
20933 | argv_find(argv, argc, "permit", &idx); |
20934 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
20935 | if (idx) { |
20936 | direct = argv_find(argv, argc, "permit", &idx) | |
20937 | ? COMMUNITY_PERMIT | |
20938 | : COMMUNITY_DENY; | |
20939 | ||
20940 | idx = 0; | |
20941 | argv_find(argv, argc, "AA:NN", &idx); | |
20942 | str = argv_concat(argv, argc, idx); | |
20943 | } | |
20944 | ||
20945 | idx = 0; | |
d62a17ae | 20946 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20947 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20948 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 20949 | |
d62a17ae | 20950 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20951 | seq, direct, style); |
42f914d4 | 20952 | |
d62a17ae | 20953 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20954 | |
d62a17ae | 20955 | if (ret < 0) { |
20956 | community_list_perror(vty, ret); | |
20957 | return CMD_WARNING_CONFIG_FAILED; | |
20958 | } | |
42f914d4 | 20959 | |
d62a17ae | 20960 | return CMD_SUCCESS; |
718e3744 | 20961 | } |
20962 | ||
d4455c89 DA |
20963 | ALIAS(no_extcommunity_list_standard_all, |
20964 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
a2099c1d | 20965 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 20966 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20967 | "Extended Community list number (standard)\n" |
20968 | "Specify standard extcommunity-list\n" | |
20969 | "Community list name\n") | |
20970 | ||
7336e101 SP |
20971 | DEFUN (no_extcommunity_list_expanded_all, |
20972 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a2099c1d | 20973 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20974 | NO_STR |
20975 | BGP_STR | |
20976 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 20977 | "Extended Community list number (expanded)\n" |
718e3744 | 20978 | "Specify expanded extcommunity-list\n" |
5bf15956 | 20979 | "Extended Community list name\n" |
2f8cc0e5 DA |
20980 | "Sequence number of an entry\n" |
20981 | "Sequence number\n" | |
718e3744 | 20982 | "Specify community to reject\n" |
20983 | "Specify community to accept\n" | |
20984 | "An ordered list as a regular-expression\n") | |
20985 | { | |
d62a17ae | 20986 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20987 | int direct = 0; | |
20988 | char *cl_number_or_name = NULL; | |
d4455c89 | 20989 | char *str = NULL; |
2f8cc0e5 | 20990 | char *seq = NULL; |
d62a17ae | 20991 | int idx = 0; |
d4455c89 | 20992 | |
a08032fe | 20993 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20994 | seq = argv[idx]->arg; |
20995 | ||
20996 | idx = 0; | |
d4455c89 DA |
20997 | argv_find(argv, argc, "permit", &idx); |
20998 | argv_find(argv, argc, "deny", &idx); | |
20999 | ||
21000 | if (idx) { | |
21001 | direct = argv_find(argv, argc, "permit", &idx) | |
21002 | ? COMMUNITY_PERMIT | |
21003 | : COMMUNITY_DENY; | |
21004 | ||
21005 | idx = 0; | |
21006 | argv_find(argv, argc, "LINE", &idx); | |
21007 | str = argv_concat(argv, argc, idx); | |
21008 | } | |
21009 | ||
21010 | idx = 0; | |
d62a17ae | 21011 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 21012 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 21013 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 21014 | |
d62a17ae | 21015 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 21016 | seq, direct, style); |
42f914d4 | 21017 | |
d62a17ae | 21018 | XFREE(MTYPE_TMP, str); |
42f914d4 | 21019 | |
d62a17ae | 21020 | if (ret < 0) { |
21021 | community_list_perror(vty, ret); | |
21022 | return CMD_WARNING_CONFIG_FAILED; | |
21023 | } | |
42f914d4 | 21024 | |
d62a17ae | 21025 | return CMD_SUCCESS; |
718e3744 | 21026 | } |
21027 | ||
d4455c89 DA |
21028 | ALIAS(no_extcommunity_list_expanded_all, |
21029 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
a2099c1d | 21030 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 21031 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
21032 | "Extended Community list number (expanded)\n" |
21033 | "Specify expanded extcommunity-list\n" | |
21034 | "Extended Community list name\n") | |
21035 | ||
d62a17ae | 21036 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 21037 | { |
d62a17ae | 21038 | struct community_entry *entry; |
718e3744 | 21039 | |
d62a17ae | 21040 | for (entry = list->head; entry; entry = entry->next) { |
21041 | if (entry == list->head) { | |
21042 | if (all_digit(list->name)) | |
21043 | vty_out(vty, "Extended community %s list %s\n", | |
21044 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
21045 | ? "standard" | |
21046 | : "(expanded) access", | |
21047 | list->name); | |
21048 | else | |
21049 | vty_out(vty, | |
21050 | "Named extended community %s list %s\n", | |
21051 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
21052 | ? "standard" | |
21053 | : "expanded", | |
21054 | list->name); | |
21055 | } | |
21056 | if (entry->any) | |
21057 | vty_out(vty, " %s\n", | |
21058 | community_direct_str(entry->direct)); | |
21059 | else | |
21060 | vty_out(vty, " %s %s\n", | |
21061 | community_direct_str(entry->direct), | |
8d9b8ed9 | 21062 | community_list_config_str(entry)); |
d62a17ae | 21063 | } |
718e3744 | 21064 | } |
21065 | ||
7336e101 SP |
21066 | DEFUN (show_extcommunity_list, |
21067 | show_bgp_extcommunity_list_cmd, | |
21068 | "show bgp extcommunity-list", | |
718e3744 | 21069 | SHOW_STR |
7336e101 | 21070 | BGP_STR |
718e3744 | 21071 | "List extended-community list\n") |
21072 | { | |
d62a17ae | 21073 | struct community_list *list; |
21074 | struct community_list_master *cm; | |
718e3744 | 21075 | |
d62a17ae | 21076 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
21077 | if (!cm) | |
21078 | return CMD_SUCCESS; | |
718e3744 | 21079 | |
d62a17ae | 21080 | for (list = cm->num.head; list; list = list->next) |
21081 | extcommunity_list_show(vty, list); | |
718e3744 | 21082 | |
d62a17ae | 21083 | for (list = cm->str.head; list; list = list->next) |
21084 | extcommunity_list_show(vty, list); | |
718e3744 | 21085 | |
d62a17ae | 21086 | return CMD_SUCCESS; |
718e3744 | 21087 | } |
21088 | ||
7336e101 SP |
21089 | DEFUN (show_extcommunity_list_arg, |
21090 | show_bgp_extcommunity_list_arg_cmd, | |
a2099c1d | 21091 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
21092 | SHOW_STR |
21093 | BGP_STR | |
718e3744 | 21094 | "List extended-community list\n" |
21095 | "Extcommunity-list number\n" | |
960b69b9 | 21096 | "Extcommunity-list name\n" |
21097 | "Detailed information on extcommunity-list\n") | |
718e3744 | 21098 | { |
d62a17ae | 21099 | int idx_comm_list = 3; |
21100 | struct community_list *list; | |
718e3744 | 21101 | |
e237b0d2 | 21102 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 21103 | EXTCOMMUNITY_LIST_MASTER); |
21104 | if (!list) { | |
21105 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
21106 | return CMD_WARNING; | |
21107 | } | |
718e3744 | 21108 | |
d62a17ae | 21109 | extcommunity_list_show(vty, list); |
718e3744 | 21110 | |
d62a17ae | 21111 | return CMD_SUCCESS; |
718e3744 | 21112 | } |
6b0655a2 | 21113 | |
718e3744 | 21114 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 21115 | static int community_list_config_write(struct vty *vty) |
21116 | { | |
21117 | struct community_list *list; | |
21118 | struct community_entry *entry; | |
21119 | struct community_list_master *cm; | |
21120 | int write = 0; | |
21121 | ||
21122 | /* Community-list. */ | |
21123 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
21124 | ||
21125 | for (list = cm->num.head; list; list = list->next) | |
21126 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21127 | vty_out(vty, |
21128 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
21129 | list->name, entry->seq, | |
d62a17ae | 21130 | community_direct_str(entry->direct), |
21131 | community_list_config_str(entry)); | |
21132 | write++; | |
21133 | } | |
21134 | for (list = cm->str.head; list; list = list->next) | |
21135 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21136 | vty_out(vty, |
21137 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 21138 | entry->style == COMMUNITY_LIST_STANDARD |
21139 | ? "standard" | |
21140 | : "expanded", | |
2f8cc0e5 DA |
21141 | list->name, entry->seq, |
21142 | community_direct_str(entry->direct), | |
d62a17ae | 21143 | community_list_config_str(entry)); |
21144 | write++; | |
21145 | } | |
21146 | ||
21147 | /* Extcommunity-list. */ | |
21148 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
21149 | ||
21150 | for (list = cm->num.head; list; list = list->next) | |
21151 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21152 | vty_out(vty, |
21153 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
21154 | list->name, entry->seq, | |
21155 | community_direct_str(entry->direct), | |
d62a17ae | 21156 | community_list_config_str(entry)); |
21157 | write++; | |
21158 | } | |
21159 | for (list = cm->str.head; list; list = list->next) | |
21160 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21161 | vty_out(vty, |
6cde4b45 | 21162 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 21163 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
21164 | ? "standard" | |
21165 | : "expanded", | |
2f8cc0e5 DA |
21166 | list->name, entry->seq, |
21167 | community_direct_str(entry->direct), | |
d62a17ae | 21168 | community_list_config_str(entry)); |
21169 | write++; | |
21170 | } | |
21171 | ||
21172 | ||
21173 | /* lcommunity-list. */ | |
21174 | cm = community_list_master_lookup(bgp_clist, | |
21175 | LARGE_COMMUNITY_LIST_MASTER); | |
21176 | ||
21177 | for (list = cm->num.head; list; list = list->next) | |
21178 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21179 | vty_out(vty, |
6cde4b45 | 21180 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
21181 | list->name, entry->seq, |
21182 | community_direct_str(entry->direct), | |
d62a17ae | 21183 | community_list_config_str(entry)); |
21184 | write++; | |
21185 | } | |
21186 | for (list = cm->str.head; list; list = list->next) | |
21187 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21188 | vty_out(vty, |
6cde4b45 | 21189 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 21190 | |
d62a17ae | 21191 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
21192 | ? "standard" | |
21193 | : "expanded", | |
2f8cc0e5 | 21194 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 21195 | community_list_config_str(entry)); |
21196 | write++; | |
21197 | } | |
21198 | ||
21199 | return write; | |
21200 | } | |
21201 | ||
612c2c15 | 21202 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 21203 | static struct cmd_node community_list_node = { |
f4b8291f | 21204 | .name = "community list", |
62b346ee DL |
21205 | .node = COMMUNITY_LIST_NODE, |
21206 | .prompt = "", | |
612c2c15 | 21207 | .config_write = community_list_config_write, |
718e3744 | 21208 | }; |
21209 | ||
d62a17ae | 21210 | static void community_list_vty(void) |
21211 | { | |
612c2c15 | 21212 | install_node(&community_list_node); |
d62a17ae | 21213 | |
21214 | /* Community-list. */ | |
7336e101 SP |
21215 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
21216 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
21217 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 21218 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 21219 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 21220 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
21221 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
21222 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 21223 | |
21224 | /* Extcommunity-list. */ | |
7336e101 SP |
21225 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
21226 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
21227 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
21228 | install_element(CONFIG_NODE, |
21229 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 21230 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
21231 | install_element(CONFIG_NODE, |
21232 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
21233 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
21234 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 21235 | |
21236 | /* Large Community List */ | |
7336e101 | 21237 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
21238 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
21239 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 21240 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
21241 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
21242 | install_element(CONFIG_NODE, | |
21243 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
21244 | install_element(CONFIG_NODE, |
21245 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
21246 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
21247 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
21248 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
21249 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
21250 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
21251 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
21252 | |
21253 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 21254 | } |
ed0e57e3 DA |
21255 | |
21256 | static struct cmd_node community_alias_node = { | |
21257 | .name = "community alias", | |
21258 | .node = COMMUNITY_ALIAS_NODE, | |
21259 | .prompt = "", | |
21260 | .config_write = bgp_community_alias_write, | |
21261 | }; | |
21262 | ||
21263 | void community_alias_vty(void) | |
21264 | { | |
21265 | install_node(&community_alias_node); | |
21266 | ||
21267 | /* Community-list. */ | |
21268 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
21269 | |
21270 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 21271 | } |