]>
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" |
8079a413 | 42 | #include "asn.h" |
718e3744 | 43 | |
44 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 45 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 46 | #include "bgpd/bgp_advertise.h" |
718e3744 | 47 | #include "bgpd/bgp_attr.h" |
48 | #include "bgpd/bgp_aspath.h" | |
49 | #include "bgpd/bgp_community.h" | |
ed0e57e3 | 50 | #include "bgpd/bgp_community_alias.h" |
4bf6a362 | 51 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 52 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 53 | #include "bgpd/bgp_damp.h" |
718e3744 | 54 | #include "bgpd/bgp_debug.h" |
14454c9f | 55 | #include "bgpd/bgp_errors.h" |
e0701b79 | 56 | #include "bgpd/bgp_fsm.h" |
4cd690ae | 57 | #include "bgpd/bgp_nht.h" |
4bf6a362 | 58 | #include "bgpd/bgp_nexthop.h" |
4122b697 | 59 | #include "bgpd/bgp_network.h" |
718e3744 | 60 | #include "bgpd/bgp_open.h" |
4bf6a362 | 61 | #include "bgpd/bgp_regex.h" |
718e3744 | 62 | #include "bgpd/bgp_route.h" |
c016b6c7 | 63 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 64 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 65 | #include "bgpd/bgp_table.h" |
94f2b392 | 66 | #include "bgpd/bgp_vty.h" |
165b5fff | 67 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 68 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 69 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 70 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 71 | #include "bgpd/bgp_io.h" |
94c2f693 | 72 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 73 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 74 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 75 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 76 | #include "bgpd/bgp_mac.h" |
dd65f45e | 77 | #include "bgpd/bgp_flowspec.h" |
389e4f92 | 78 | #include "bgpd/bgp_conditional_adv.h" |
49e5a4a0 | 79 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
80 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
81 | #endif | |
82 | ||
5d5393b9 | 83 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
84 | { |
85 | .val_bool = false, | |
86 | .match_profile = "traditional", | |
87 | .match_version = "< 7.4", | |
88 | }, | |
89 | { .val_bool = true }, | |
67b0f40c | 90 | ); |
5d5393b9 | 91 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
92 | { .val_bool = true, .match_profile = "datacenter", }, |
93 | { .val_bool = false }, | |
67b0f40c | 94 | ); |
aef999a2 DA |
95 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
96 | { .val_bool = true, .match_profile = "datacenter", }, | |
97 | { .val_bool = false }, | |
67b0f40c | 98 | ); |
5d5393b9 | 99 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
100 | { .val_bool = true, .match_profile = "datacenter", }, |
101 | { .val_bool = false }, | |
67b0f40c | 102 | ); |
5d5393b9 | 103 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
104 | { .val_bool = true, .match_profile = "datacenter", }, |
105 | { .val_bool = false }, | |
67b0f40c | 106 | ); |
5d5393b9 DL |
107 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
108 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
109 | { .val_ulong = 120 }, | |
67b0f40c | 110 | ); |
5d5393b9 DL |
111 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
112 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
113 | { .val_ulong = 180 }, | |
67b0f40c | 114 | ); |
5d5393b9 DL |
115 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
116 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
117 | { .val_ulong = 60 }, | |
67b0f40c | 118 | ); |
1d3fdccf DA |
119 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
120 | { .val_bool = false, .match_profile = "datacenter", }, | |
121 | { .val_bool = false, .match_version = "< 7.4", }, | |
122 | { .val_bool = true }, | |
67b0f40c | 123 | ); |
2adac256 DA |
124 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
125 | { .val_bool = false, .match_version = "< 7.6", }, | |
126 | { .val_bool = true }, | |
67b0f40c | 127 | ); |
f2ca5c5b DA |
128 | FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION, |
129 | { .val_bool = false, .match_version = "< 8.3", }, | |
130 | { .val_bool = true }, | |
131 | ); | |
1ae314be DA |
132 | FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET, |
133 | { .val_bool = false, .match_version = "< 8.3", }, | |
134 | { .val_bool = true }, | |
135 | ); | |
5d5393b9 | 136 | |
dd65f45e DL |
137 | DEFINE_HOOK(bgp_inst_config_write, |
138 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
139 | (bgp, vty)); |
140 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
1ca2fd11 | 141 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); |
718e3744 | 142 | |
d62a17ae | 143 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
144 | struct prefix *range, int exact); | |
145 | ||
055679e9 | 146 | /* Show BGP peer's information. */ |
147 | enum show_type { | |
148 | show_all, | |
149 | show_peer, | |
150 | show_ipv4_all, | |
151 | show_ipv6_all, | |
152 | show_ipv4_peer, | |
153 | show_ipv6_peer | |
154 | }; | |
155 | ||
36235319 QY |
156 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
157 | struct prefix *range, int exact); | |
2986cac2 | 158 | |
36235319 | 159 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
403e64f8 | 160 | struct bgp *bgp); |
2986cac2 | 161 | |
36235319 QY |
162 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
163 | enum show_type type, | |
164 | const char *ip_str, | |
165 | afi_t afi, bool use_json); | |
2986cac2 | 166 | |
d62a17ae | 167 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
168 | { | |
169 | switch (afi) { | |
170 | case AFI_IP: | |
171 | switch (safi) { | |
172 | case SAFI_UNICAST: | |
173 | return BGP_IPV4_NODE; | |
d62a17ae | 174 | case SAFI_MULTICAST: |
175 | return BGP_IPV4M_NODE; | |
d62a17ae | 176 | case SAFI_LABELED_UNICAST: |
177 | return BGP_IPV4L_NODE; | |
d62a17ae | 178 | case SAFI_MPLS_VPN: |
179 | return BGP_VPNV4_NODE; | |
7c40bf39 | 180 | case SAFI_FLOWSPEC: |
181 | return BGP_FLOWSPECV4_NODE; | |
58cf0823 DS |
182 | case SAFI_UNSPEC: |
183 | case SAFI_ENCAP: | |
184 | case SAFI_EVPN: | |
185 | case SAFI_MAX: | |
5c525538 RW |
186 | /* not expected */ |
187 | return BGP_IPV4_NODE; | |
d62a17ae | 188 | } |
58cf0823 | 189 | break; |
d62a17ae | 190 | case AFI_IP6: |
191 | switch (safi) { | |
192 | case SAFI_UNICAST: | |
193 | return BGP_IPV6_NODE; | |
d62a17ae | 194 | case SAFI_MULTICAST: |
195 | return BGP_IPV6M_NODE; | |
d62a17ae | 196 | case SAFI_LABELED_UNICAST: |
197 | return BGP_IPV6L_NODE; | |
d62a17ae | 198 | case SAFI_MPLS_VPN: |
199 | return BGP_VPNV6_NODE; | |
7c40bf39 | 200 | case SAFI_FLOWSPEC: |
201 | return BGP_FLOWSPECV6_NODE; | |
58cf0823 DS |
202 | case SAFI_UNSPEC: |
203 | case SAFI_ENCAP: | |
204 | case SAFI_EVPN: | |
205 | case SAFI_MAX: | |
206 | /* not expected and the return value seems wrong */ | |
5c525538 | 207 | return BGP_IPV4_NODE; |
d62a17ae | 208 | } |
58cf0823 | 209 | break; |
d62a17ae | 210 | case AFI_L2VPN: |
211 | return BGP_EVPN_NODE; | |
b26f891d | 212 | case AFI_UNSPEC: |
d62a17ae | 213 | case AFI_MAX: |
214 | // We should never be here but to clarify the switch statement.. | |
215 | return BGP_IPV4_NODE; | |
d62a17ae | 216 | } |
217 | ||
218 | // Impossible to happen | |
219 | return BGP_IPV4_NODE; | |
f51bae9c | 220 | } |
20eb8864 | 221 | |
5cb5f4d0 DD |
222 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
223 | { | |
7d0d37de DS |
224 | if (afi == AFI_IP) { |
225 | if (safi == SAFI_UNICAST) | |
226 | return "IPv4 Unicast"; | |
227 | if (safi == SAFI_MULTICAST) | |
228 | return "IPv4 Multicast"; | |
229 | if (safi == SAFI_LABELED_UNICAST) | |
230 | return "IPv4 Labeled Unicast"; | |
231 | if (safi == SAFI_MPLS_VPN) | |
232 | return "IPv4 VPN"; | |
233 | if (safi == SAFI_ENCAP) | |
234 | return "IPv4 Encap"; | |
235 | if (safi == SAFI_FLOWSPEC) | |
236 | return "IPv4 Flowspec"; | |
237 | } else if (afi == AFI_IP6) { | |
238 | if (safi == SAFI_UNICAST) | |
239 | return "IPv6 Unicast"; | |
240 | if (safi == SAFI_MULTICAST) | |
241 | return "IPv6 Multicast"; | |
242 | if (safi == SAFI_LABELED_UNICAST) | |
243 | return "IPv6 Labeled Unicast"; | |
244 | if (safi == SAFI_MPLS_VPN) | |
245 | return "IPv6 VPN"; | |
246 | if (safi == SAFI_ENCAP) | |
247 | return "IPv6 Encap"; | |
248 | if (safi == SAFI_FLOWSPEC) | |
249 | return "IPv6 Flowspec"; | |
250 | } else if (afi == AFI_L2VPN) { | |
251 | if (safi == SAFI_EVPN) | |
252 | return "L2VPN EVPN"; | |
253 | } | |
254 | ||
255 | return "Unknown"; | |
5cb5f4d0 DD |
256 | } |
257 | ||
258 | /* | |
259 | * Please note that we have intentionally camelCased | |
260 | * the return strings here. So if you want | |
261 | * to use this function, please ensure you | |
262 | * are doing this within json output | |
263 | */ | |
264 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
265 | { | |
7d0d37de DS |
266 | if (afi == AFI_IP) { |
267 | if (safi == SAFI_UNICAST) | |
268 | return "ipv4Unicast"; | |
269 | if (safi == SAFI_MULTICAST) | |
270 | return "ipv4Multicast"; | |
271 | if (safi == SAFI_LABELED_UNICAST) | |
272 | return "ipv4LabeledUnicast"; | |
273 | if (safi == SAFI_MPLS_VPN) | |
274 | return "ipv4Vpn"; | |
275 | if (safi == SAFI_ENCAP) | |
276 | return "ipv4Encap"; | |
277 | if (safi == SAFI_FLOWSPEC) | |
278 | return "ipv4Flowspec"; | |
279 | } else if (afi == AFI_IP6) { | |
280 | if (safi == SAFI_UNICAST) | |
281 | return "ipv6Unicast"; | |
282 | if (safi == SAFI_MULTICAST) | |
283 | return "ipv6Multicast"; | |
284 | if (safi == SAFI_LABELED_UNICAST) | |
285 | return "ipv6LabeledUnicast"; | |
286 | if (safi == SAFI_MPLS_VPN) | |
287 | return "ipv6Vpn"; | |
288 | if (safi == SAFI_ENCAP) | |
289 | return "ipv6Encap"; | |
290 | if (safi == SAFI_FLOWSPEC) | |
291 | return "ipv6Flowspec"; | |
292 | } else if (afi == AFI_L2VPN) { | |
293 | if (safi == SAFI_EVPN) | |
294 | return "l2VpnEvpn"; | |
295 | } | |
296 | ||
297 | return "Unknown"; | |
5cb5f4d0 DD |
298 | } |
299 | ||
0249b8b6 HS |
300 | /* unset srv6 locator */ |
301 | static int bgp_srv6_locator_unset(struct bgp *bgp) | |
302 | { | |
303 | int ret; | |
304 | struct listnode *node, *nnode; | |
efae8c26 | 305 | struct srv6_locator_chunk *chunk; |
0249b8b6 HS |
306 | struct bgp_srv6_function *func; |
307 | struct bgp *bgp_vrf; | |
0249b8b6 HS |
308 | |
309 | /* release chunk notification via ZAPI */ | |
310 | ret = bgp_zebra_srv6_manager_release_locator_chunk( | |
311 | bgp->srv6_locator_name); | |
312 | if (ret < 0) | |
313 | return -1; | |
314 | ||
315 | /* refresh chunks */ | |
03852f67 | 316 | for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) { |
0249b8b6 | 317 | listnode_delete(bgp->srv6_locator_chunks, chunk); |
69467313 | 318 | srv6_locator_chunk_free(&chunk); |
03852f67 | 319 | } |
0249b8b6 HS |
320 | |
321 | /* refresh functions */ | |
bda15542 | 322 | for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) { |
0249b8b6 | 323 | listnode_delete(bgp->srv6_functions, func); |
bda15542 CS |
324 | XFREE(MTYPE_BGP_SRV6_FUNCTION, func); |
325 | } | |
0249b8b6 HS |
326 | |
327 | /* refresh tovpn_sid */ | |
328 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
329 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
330 | continue; | |
331 | ||
332 | /* refresh vpnv4 tovpn_sid */ | |
944909f4 CS |
333 | XFREE(MTYPE_BGP_SRV6_SID, |
334 | bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); | |
0249b8b6 HS |
335 | |
336 | /* refresh vpnv6 tovpn_sid */ | |
944909f4 CS |
337 | XFREE(MTYPE_BGP_SRV6_SID, |
338 | bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid); | |
527588aa CS |
339 | |
340 | /* refresh per-vrf tovpn_sid */ | |
341 | XFREE(MTYPE_BGP_SRV6_SID, bgp_vrf->tovpn_sid); | |
0249b8b6 HS |
342 | } |
343 | ||
344 | /* update vpn bgp processes */ | |
345 | vpn_leak_postchange_all(); | |
346 | ||
f8e9c702 CS |
347 | /* refresh tovpn_sid_locator */ |
348 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
349 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
350 | continue; | |
351 | ||
352 | /* refresh vpnv4 tovpn_sid_locator */ | |
efae8c26 CS |
353 | srv6_locator_chunk_free( |
354 | &bgp_vrf->vpn_policy[AFI_IP].tovpn_sid_locator); | |
f8e9c702 CS |
355 | |
356 | /* refresh vpnv6 tovpn_sid_locator */ | |
efae8c26 CS |
357 | srv6_locator_chunk_free( |
358 | &bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid_locator); | |
527588aa CS |
359 | |
360 | /* refresh per-vrf tovpn_sid_locator */ | |
69467313 | 361 | srv6_locator_chunk_free(&bgp_vrf->tovpn_sid_locator); |
f8e9c702 CS |
362 | } |
363 | ||
0249b8b6 HS |
364 | /* clear locator name */ |
365 | memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name)); | |
366 | ||
367 | return 0; | |
368 | } | |
369 | ||
718e3744 | 370 | /* Utility function to get address family from current node. */ |
d62a17ae | 371 | afi_t bgp_node_afi(struct vty *vty) |
372 | { | |
373 | afi_t afi; | |
374 | switch (vty->node) { | |
375 | case BGP_IPV6_NODE: | |
376 | case BGP_IPV6M_NODE: | |
377 | case BGP_IPV6L_NODE: | |
378 | case BGP_VPNV6_NODE: | |
7c40bf39 | 379 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 380 | afi = AFI_IP6; |
381 | break; | |
382 | case BGP_EVPN_NODE: | |
383 | afi = AFI_L2VPN; | |
384 | break; | |
385 | default: | |
386 | afi = AFI_IP; | |
387 | break; | |
388 | } | |
389 | return afi; | |
718e3744 | 390 | } |
391 | ||
392 | /* Utility function to get subsequent address family from current | |
393 | node. */ | |
d62a17ae | 394 | safi_t bgp_node_safi(struct vty *vty) |
395 | { | |
396 | safi_t safi; | |
397 | switch (vty->node) { | |
398 | case BGP_VPNV4_NODE: | |
399 | case BGP_VPNV6_NODE: | |
400 | safi = SAFI_MPLS_VPN; | |
401 | break; | |
402 | case BGP_IPV4M_NODE: | |
403 | case BGP_IPV6M_NODE: | |
404 | safi = SAFI_MULTICAST; | |
405 | break; | |
406 | case BGP_EVPN_NODE: | |
407 | safi = SAFI_EVPN; | |
408 | break; | |
409 | case BGP_IPV4L_NODE: | |
410 | case BGP_IPV6L_NODE: | |
411 | safi = SAFI_LABELED_UNICAST; | |
412 | break; | |
7c40bf39 | 413 | case BGP_FLOWSPECV4_NODE: |
414 | case BGP_FLOWSPECV6_NODE: | |
415 | safi = SAFI_FLOWSPEC; | |
416 | break; | |
d62a17ae | 417 | default: |
418 | safi = SAFI_UNICAST; | |
419 | break; | |
420 | } | |
421 | return safi; | |
718e3744 | 422 | } |
423 | ||
55f91488 QY |
424 | /** |
425 | * Converts an AFI in string form to afi_t | |
426 | * | |
427 | * @param afi string, one of | |
428 | * - "ipv4" | |
429 | * - "ipv6" | |
81cf0de5 | 430 | * - "l2vpn" |
55f91488 QY |
431 | * @return the corresponding afi_t |
432 | */ | |
d62a17ae | 433 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
434 | { | |
435 | afi_t afi = AFI_MAX; /* unknown */ | |
436 | if (strmatch(afi_str, "ipv4")) | |
437 | afi = AFI_IP; | |
438 | else if (strmatch(afi_str, "ipv6")) | |
439 | afi = AFI_IP6; | |
81cf0de5 CS |
440 | else if (strmatch(afi_str, "l2vpn")) |
441 | afi = AFI_L2VPN; | |
d62a17ae | 442 | return afi; |
443 | } | |
444 | ||
445 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
446 | afi_t *afi) | |
447 | { | |
448 | int ret = 0; | |
449 | if (argv_find(argv, argc, "ipv4", index)) { | |
450 | ret = 1; | |
451 | if (afi) | |
452 | *afi = AFI_IP; | |
453 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
454 | ret = 1; | |
455 | if (afi) | |
456 | *afi = AFI_IP6; | |
8688b3e7 DS |
457 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
458 | ret = 1; | |
459 | if (afi) | |
460 | *afi = AFI_L2VPN; | |
d62a17ae | 461 | } |
462 | return ret; | |
46f296b4 LB |
463 | } |
464 | ||
375a2e67 | 465 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 466 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
467 | { | |
468 | safi_t safi = SAFI_MAX; /* unknown */ | |
469 | if (strmatch(safi_str, "multicast")) | |
470 | safi = SAFI_MULTICAST; | |
471 | else if (strmatch(safi_str, "unicast")) | |
472 | safi = SAFI_UNICAST; | |
473 | else if (strmatch(safi_str, "vpn")) | |
474 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
475 | else if (strmatch(safi_str, "evpn")) |
476 | safi = SAFI_EVPN; | |
d62a17ae | 477 | else if (strmatch(safi_str, "labeled-unicast")) |
478 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 479 | else if (strmatch(safi_str, "flowspec")) |
480 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 481 | return safi; |
482 | } | |
483 | ||
484 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
485 | safi_t *safi) | |
486 | { | |
487 | int ret = 0; | |
488 | if (argv_find(argv, argc, "unicast", index)) { | |
489 | ret = 1; | |
490 | if (safi) | |
491 | *safi = SAFI_UNICAST; | |
492 | } else if (argv_find(argv, argc, "multicast", index)) { | |
493 | ret = 1; | |
494 | if (safi) | |
495 | *safi = SAFI_MULTICAST; | |
496 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
497 | ret = 1; | |
498 | if (safi) | |
499 | *safi = SAFI_LABELED_UNICAST; | |
500 | } else if (argv_find(argv, argc, "vpn", index)) { | |
501 | ret = 1; | |
502 | if (safi) | |
503 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
504 | } else if (argv_find(argv, argc, "evpn", index)) { |
505 | ret = 1; | |
506 | if (safi) | |
507 | *safi = SAFI_EVPN; | |
7c40bf39 | 508 | } else if (argv_find(argv, argc, "flowspec", index)) { |
509 | ret = 1; | |
510 | if (safi) | |
511 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 512 | } |
513 | return ret; | |
46f296b4 LB |
514 | } |
515 | ||
b16bcbba TA |
516 | /* |
517 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
518 | * | |
519 | * afi | |
520 | * address-family identifier | |
521 | * | |
522 | * safi | |
523 | * subsequent address-family identifier | |
524 | * | |
525 | * Returns: | |
526 | * default_af string corresponding to the supplied afi/safi pair. | |
527 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
528 | * return -1. | |
529 | */ | |
530 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
531 | { | |
532 | switch (afi) { | |
533 | case AFI_IP: | |
534 | switch (safi) { | |
535 | case SAFI_UNICAST: | |
536 | return "ipv4-unicast"; | |
537 | case SAFI_MULTICAST: | |
538 | return "ipv4-multicast"; | |
539 | case SAFI_MPLS_VPN: | |
540 | return "ipv4-vpn"; | |
541 | case SAFI_ENCAP: | |
542 | return "ipv4-encap"; | |
543 | case SAFI_LABELED_UNICAST: | |
544 | return "ipv4-labeled-unicast"; | |
545 | case SAFI_FLOWSPEC: | |
546 | return "ipv4-flowspec"; | |
58cf0823 DS |
547 | case SAFI_UNSPEC: |
548 | case SAFI_EVPN: | |
549 | case SAFI_MAX: | |
b16bcbba TA |
550 | return "unknown-afi/safi"; |
551 | } | |
552 | break; | |
553 | case AFI_IP6: | |
554 | switch (safi) { | |
555 | case SAFI_UNICAST: | |
556 | return "ipv6-unicast"; | |
557 | case SAFI_MULTICAST: | |
558 | return "ipv6-multicast"; | |
559 | case SAFI_MPLS_VPN: | |
560 | return "ipv6-vpn"; | |
561 | case SAFI_ENCAP: | |
562 | return "ipv6-encap"; | |
563 | case SAFI_LABELED_UNICAST: | |
564 | return "ipv6-labeled-unicast"; | |
565 | case SAFI_FLOWSPEC: | |
566 | return "ipv6-flowspec"; | |
58cf0823 DS |
567 | case SAFI_UNSPEC: |
568 | case SAFI_EVPN: | |
569 | case SAFI_MAX: | |
b16bcbba TA |
570 | return "unknown-afi/safi"; |
571 | } | |
572 | break; | |
573 | case AFI_L2VPN: | |
574 | switch (safi) { | |
575 | case SAFI_EVPN: | |
576 | return "l2vpn-evpn"; | |
58cf0823 DS |
577 | case SAFI_UNICAST: |
578 | case SAFI_MULTICAST: | |
579 | case SAFI_MPLS_VPN: | |
580 | case SAFI_ENCAP: | |
581 | case SAFI_LABELED_UNICAST: | |
582 | case SAFI_FLOWSPEC: | |
583 | case SAFI_UNSPEC: | |
584 | case SAFI_MAX: | |
b16bcbba TA |
585 | return "unknown-afi/safi"; |
586 | } | |
58cf0823 | 587 | break; |
b16bcbba TA |
588 | case AFI_UNSPEC: |
589 | case AFI_MAX: | |
590 | return "unknown-afi/safi"; | |
591 | } | |
592 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
58cf0823 DS |
593 | |
594 | assert(!"Reached end of function where we did not expect to"); | |
b16bcbba TA |
595 | } |
596 | ||
5d5393b9 | 597 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
e55b0883 PG |
598 | enum bgp_instance_type inst_type, const char *as_pretty, |
599 | enum asnotation_mode asnotation) | |
5d5393b9 | 600 | { |
e55b0883 | 601 | int ret = bgp_get(bgp, as, name, inst_type, as_pretty, asnotation); |
5d5393b9 DL |
602 | |
603 | if (ret == BGP_CREATED) { | |
604 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 605 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
606 | |
607 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 608 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 609 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 610 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
611 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
612 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 613 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 614 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 615 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 616 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
617 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
618 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
619 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
620 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
f2ca5c5b DA |
621 | if (DFLT_BGP_GRACEFUL_NOTIFICATION) |
622 | SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
1ae314be DA |
623 | if (DFLT_BGP_HARD_ADMIN_RESET) |
624 | SET_FLAG((*bgp)->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
5d5393b9 DL |
625 | |
626 | ret = BGP_SUCCESS; | |
627 | } | |
628 | return ret; | |
629 | } | |
630 | ||
7eeee51e | 631 | /* |
f212a857 | 632 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 633 | * |
f212a857 DS |
634 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
635 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
636 | * to appropriate values for the calling function. This is to allow the |
637 | * calling function to make decisions appropriate for the show command | |
638 | * that is being parsed. | |
639 | * | |
640 | * The show commands are generally of the form: | |
d62a17ae | 641 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
642 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
643 | * |
644 | * Since we use argv_find if the show command in particular doesn't have: | |
645 | * [ip] | |
18c57037 | 646 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 647 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
648 | * The command parsing should still be ok. |
649 | * | |
650 | * vty -> The vty for the command so we can output some useful data in | |
651 | * the event of a parse error in the vrf. | |
652 | * argv -> The command tokens | |
653 | * argc -> How many command tokens we have | |
d62a17ae | 654 | * idx -> The current place in the command, generally should be 0 for this |
655 | * function | |
7eeee51e DS |
656 | * afi -> The parsed afi if it was included in the show command, returned here |
657 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 658 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 659 | * use_json -> json is configured or not |
7eeee51e DS |
660 | * |
661 | * The function returns the correct location in the parse tree for the | |
662 | * last token found. | |
0e37c258 DS |
663 | * |
664 | * Returns 0 for failure to parse correctly, else the idx position of where | |
665 | * it found the last token. | |
7eeee51e | 666 | */ |
d62a17ae | 667 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
668 | struct cmd_token **argv, int argc, | |
669 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 670 | struct bgp **bgp, bool use_json) |
d62a17ae | 671 | { |
672 | char *vrf_name = NULL; | |
673 | ||
674 | assert(afi); | |
675 | assert(safi); | |
676 | assert(bgp); | |
677 | ||
678 | if (argv_find(argv, argc, "ip", idx)) | |
679 | *afi = AFI_IP; | |
680 | ||
9a8bdf1c | 681 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 682 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
683 | else if (argv_find(argv, argc, "vrf", idx)) { |
684 | vrf_name = argv[*idx + 1]->arg; | |
685 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
686 | vrf_name = NULL; | |
687 | } | |
688 | if (vrf_name) { | |
d62a17ae | 689 | if (strmatch(vrf_name, "all")) |
690 | *bgp = NULL; | |
691 | else { | |
692 | *bgp = bgp_lookup_by_name(vrf_name); | |
693 | if (!*bgp) { | |
52e5b8c4 SP |
694 | if (use_json) { |
695 | json_object *json = NULL; | |
696 | json = json_object_new_object(); | |
697 | json_object_string_add( | |
698 | json, "warning", | |
699 | "View/Vrf is unknown"); | |
75eeda93 | 700 | vty_json(vty, json); |
52e5b8c4 | 701 | } |
ca61fd25 DS |
702 | else |
703 | vty_out(vty, "View/Vrf %s is unknown\n", | |
704 | vrf_name); | |
d62a17ae | 705 | *idx = 0; |
706 | return 0; | |
707 | } | |
708 | } | |
709 | } else { | |
710 | *bgp = bgp_get_default(); | |
711 | if (!*bgp) { | |
52e5b8c4 SP |
712 | if (use_json) { |
713 | json_object *json = NULL; | |
714 | json = json_object_new_object(); | |
715 | json_object_string_add( | |
716 | json, "warning", | |
717 | "Default BGP instance not found"); | |
75eeda93 | 718 | vty_json(vty, json); |
52e5b8c4 | 719 | } |
ca61fd25 DS |
720 | else |
721 | vty_out(vty, | |
722 | "Default BGP instance not found\n"); | |
d62a17ae | 723 | *idx = 0; |
724 | return 0; | |
725 | } | |
726 | } | |
727 | ||
728 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
729 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
730 | ||
731 | *idx += 1; | |
732 | return *idx; | |
733 | } | |
734 | ||
28c6e247 | 735 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 736 | { |
737 | struct interface *ifp = NULL; | |
4122b697 DA |
738 | struct listnode *node; |
739 | struct bgp_listener *listener; | |
740 | union sockunion all_su; | |
d62a17ae | 741 | |
4122b697 | 742 | if (su->sa.sa_family == AF_INET) { |
3d2a2725 | 743 | (void)str2sockunion("0.0.0.0", &all_su); |
d62a17ae | 744 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); |
4122b697 | 745 | } else if (su->sa.sa_family == AF_INET6) { |
3d2a2725 | 746 | (void)str2sockunion("::", &all_su); |
d62a17ae | 747 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, |
748 | su->sin6.sin6_scope_id, | |
749 | bgp->vrf_id); | |
4122b697 | 750 | } |
d62a17ae | 751 | |
4122b697 DA |
752 | if (ifp) { |
753 | for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) { | |
754 | if (sockunion_family(su) != | |
755 | sockunion_family(&listener->su)) | |
756 | continue; | |
757 | ||
758 | /* If 0.0.0.0/:: is a listener, then treat as self and | |
759 | * reject. | |
760 | */ | |
761 | if (!sockunion_cmp(&listener->su, su) || | |
762 | !sockunion_cmp(&listener->su, &all_su)) | |
763 | return true; | |
764 | } | |
765 | } | |
d62a17ae | 766 | |
3dc339cd | 767 | return false; |
718e3744 | 768 | } |
769 | ||
28c6e247 IR |
770 | /* Utility function for looking up peer from VTY. */ |
771 | /* This is used only for configuration, so disallow if attempted on | |
772 | * a dynamic neighbor. | |
773 | */ | |
774 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
775 | { | |
776 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
777 | int ret; | |
778 | union sockunion su; | |
779 | struct peer *peer; | |
780 | ||
781 | if (!bgp) { | |
782 | return NULL; | |
783 | } | |
784 | ||
785 | ret = str2sockunion(ip_str, &su); | |
786 | if (ret < 0) { | |
787 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
788 | if (!peer) { | |
789 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
790 | == NULL) { | |
791 | vty_out(vty, | |
792 | "%% Malformed address or name: %s\n", | |
793 | ip_str); | |
794 | return NULL; | |
795 | } | |
796 | } | |
797 | } else { | |
798 | peer = peer_lookup(bgp, &su); | |
799 | if (!peer) { | |
800 | vty_out(vty, | |
801 | "%% Specify remote-as or peer-group commands first\n"); | |
802 | return NULL; | |
803 | } | |
804 | if (peer_dynamic_neighbor(peer)) { | |
805 | vty_out(vty, | |
806 | "%% Operation not allowed on a dynamic neighbor\n"); | |
807 | return NULL; | |
808 | } | |
809 | } | |
810 | return peer; | |
811 | } | |
812 | ||
718e3744 | 813 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
814 | /* This is used only for configuration, so disallow if attempted on |
815 | * a dynamic neighbor. | |
816 | */ | |
d62a17ae | 817 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
818 | { | |
819 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
820 | int ret; | |
821 | union sockunion su; | |
822 | struct peer *peer = NULL; | |
823 | struct peer_group *group = NULL; | |
824 | ||
825 | if (!bgp) { | |
826 | return NULL; | |
827 | } | |
828 | ||
829 | ret = str2sockunion(peer_str, &su); | |
830 | if (ret == 0) { | |
831 | /* IP address, locate peer. */ | |
832 | peer = peer_lookup(bgp, &su); | |
833 | } else { | |
834 | /* Not IP, could match either peer configured on interface or a | |
835 | * group. */ | |
836 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
837 | if (!peer) | |
838 | group = peer_group_lookup(bgp, peer_str); | |
839 | } | |
840 | ||
841 | if (peer) { | |
842 | if (peer_dynamic_neighbor(peer)) { | |
3b56a646 DA |
843 | zlog_warn( |
844 | "%pBP: Operation not allowed on a dynamic neighbor", | |
845 | peer); | |
d62a17ae | 846 | vty_out(vty, |
847 | "%% Operation not allowed on a dynamic neighbor\n"); | |
848 | return NULL; | |
849 | } | |
850 | ||
851 | return peer; | |
852 | } | |
853 | ||
854 | if (group) | |
855 | return group->conf; | |
856 | ||
3b56a646 DA |
857 | zlog_warn("Specify remote-as or peer-group commands first before: %s", |
858 | vty->buf); | |
d62a17ae | 859 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); |
860 | ||
861 | return NULL; | |
862 | } | |
863 | ||
4b7e23e9 | 864 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret) |
d62a17ae | 865 | { |
866 | const char *str = NULL; | |
867 | ||
868 | switch (ret) { | |
4b7e23e9 DS |
869 | case BGP_SUCCESS: |
870 | case BGP_CREATED: | |
871 | case BGP_GR_NO_OPERATION: | |
872 | break; | |
d62a17ae | 873 | case BGP_ERR_INVALID_VALUE: |
874 | str = "Invalid value"; | |
875 | break; | |
876 | case BGP_ERR_INVALID_FLAG: | |
877 | str = "Invalid flag"; | |
878 | break; | |
879 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
880 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
881 | break; | |
882 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
883 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
884 | break; | |
885 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
886 | str = "Specify remote-as or peer-group remote AS first"; | |
887 | break; | |
888 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
889 | str = "Cannot change the peer-group. Deconfigure first"; | |
890 | break; | |
891 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
892 | str = "Peer is not a member of this peer-group"; | |
893 | break; | |
894 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
895 | str = "Prefix/distribute list can not co-exist"; | |
896 | break; | |
897 | case BGP_ERR_NOT_INTERNAL_PEER: | |
898 | str = "Invalid command. Not an internal neighbor"; | |
899 | break; | |
900 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
901 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
902 | break; | |
d62a17ae | 903 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: |
904 | str = "Cannot have local-as same as BGP AS number"; | |
905 | break; | |
906 | case BGP_ERR_TCPSIG_FAILED: | |
907 | str = "Error while applying TCP-Sig to session(s)"; | |
908 | break; | |
909 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
910 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
911 | break; | |
912 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
913 | str = "ttl-security only allowed for EBGP peers"; | |
914 | break; | |
915 | case BGP_ERR_AS_OVERRIDE: | |
916 | str = "as-override cannot be configured for IBGP peers"; | |
917 | break; | |
918 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
919 | str = "Invalid limit for number of dynamic neighbors"; | |
920 | break; | |
921 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
922 | str = "Dynamic neighbor listen range already exists"; | |
923 | break; | |
924 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
925 | str = "Operation not allowed on a dynamic neighbor"; | |
926 | break; | |
927 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
928 | str = "Operation not allowed on a directly connected neighbor"; | |
929 | break; | |
930 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 931 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 932 | break; |
933 | case BGP_ERR_GR_INVALID_CMD: | |
934 | str = "The Graceful Restart command used is not valid at this moment."; | |
935 | break; | |
936 | case BGP_ERR_GR_OPERATION_FAILED: | |
937 | str = "The Graceful Restart Operation failed due to an err."; | |
938 | break; | |
6dcea6fe DS |
939 | case BGP_ERR_PEER_GROUP_MEMBER: |
940 | str = "Peer-group member cannot override remote-as of peer-group."; | |
941 | break; | |
942 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
943 | str = "Peer-group members must be all internal or all external."; | |
944 | break; | |
4b7e23e9 DS |
945 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND: |
946 | str = "Range specified cannot be deleted because it is not part of current config."; | |
947 | break; | |
948 | case BGP_ERR_INSTANCE_MISMATCH: | |
949 | str = "Instance specified does not match the current instance."; | |
950 | break; | |
951 | case BGP_ERR_NO_INTERFACE_CONFIG: | |
952 | str = "Interface specified is not being used for interface based peer."; | |
953 | break; | |
954 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
955 | str = "No configuration already specified for soft reconfiguration."; | |
956 | break; | |
957 | case BGP_ERR_AS_MISMATCH: | |
958 | str = "BGP is already running."; | |
959 | break; | |
960 | case BGP_ERR_AF_UNCONFIGURED: | |
961 | str = "AFI/SAFI specified is not currently configured."; | |
962 | break; | |
4b7e23e9 DS |
963 | case BGP_ERR_INVALID_AS: |
964 | str = "Confederation AS specified is the same AS as our AS."; | |
965 | break; | |
d864dd9e EB |
966 | case BGP_ERR_INVALID_ROLE_NAME: |
967 | str = "Invalid role name"; | |
968 | break; | |
969 | case BGP_ERR_INVALID_INTERNAL_ROLE: | |
8f2d6021 | 970 | str = "External roles can be set only on eBGP session"; |
d864dd9e | 971 | break; |
d62a17ae | 972 | } |
973 | if (str) { | |
974 | vty_out(vty, "%% %s\n", str); | |
975 | return CMD_WARNING_CONFIG_FAILED; | |
976 | } | |
977 | return CMD_SUCCESS; | |
718e3744 | 978 | } |
979 | ||
7aafcaca | 980 | /* BGP clear sort. */ |
d62a17ae | 981 | enum clear_sort { |
982 | clear_all, | |
983 | clear_peer, | |
984 | clear_group, | |
985 | clear_external, | |
986 | clear_as | |
7aafcaca DS |
987 | }; |
988 | ||
1ca2fd11 IR |
989 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
990 | safi_t safi, int error) | |
d62a17ae | 991 | { |
992 | switch (error) { | |
993 | case BGP_ERR_AF_UNCONFIGURED: | |
a486300b PG |
994 | if (vty) |
995 | vty_out(vty, | |
996 | "%% BGP: Enable %s address family for the neighbor %s\n", | |
997 | get_afi_safi_str(afi, safi, false), peer->host); | |
998 | else | |
999 | zlog_warn( | |
1af6e82b | 1000 | "%% BGP: Enable %s address family for the neighbor %s", |
a486300b | 1001 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 1002 | break; |
1003 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
a486300b PG |
1004 | if (vty) |
1005 | vty_out(vty, | |
1006 | "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
1007 | peer->host); | |
1008 | else | |
1009 | zlog_warn( | |
1af6e82b | 1010 | "%% BGP: Inbound soft reconfig for %s not possible as it has neither refresh capability, nor inbound soft reconfig", |
a486300b | 1011 | peer->host); |
d62a17ae | 1012 | break; |
1013 | default: | |
1014 | break; | |
1015 | } | |
7aafcaca DS |
1016 | } |
1017 | ||
dc912615 | 1018 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 1019 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
1020 | { |
1021 | int ret = 0; | |
2adac256 | 1022 | struct peer_af *paf; |
dc912615 DS |
1023 | |
1024 | /* if afi/.safi not specified, spin thru all of them */ | |
1025 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
1026 | afi_t tmp_afi; | |
1027 | safi_t tmp_safi; | |
0e5cdd59 DS |
1028 | enum bgp_af_index index; |
1029 | ||
1030 | for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { | |
1031 | paf = peer->peer_af_array[index]; | |
1032 | if (!paf) | |
1033 | continue; | |
dc912615 | 1034 | |
2adac256 DA |
1035 | if (paf && paf->subgroup) |
1036 | SET_FLAG(paf->subgroup->sflags, | |
1037 | SUBGRP_STATUS_FORCE_UPDATES); | |
1038 | ||
0e5cdd59 DS |
1039 | tmp_afi = paf->afi; |
1040 | tmp_safi = paf->safi; | |
dc912615 DS |
1041 | if (!peer->afc[tmp_afi][tmp_safi]) |
1042 | continue; | |
1043 | ||
1044 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 1045 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1046 | else |
1047 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
1048 | stype); | |
1049 | } | |
1050 | /* if afi specified and safi not, spin thru safis on this afi */ | |
1051 | } else if (safi == SAFI_UNSPEC) { | |
1052 | safi_t tmp_safi; | |
1053 | ||
1054 | for (tmp_safi = SAFI_UNICAST; | |
1055 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
1056 | if (!peer->afc[afi][tmp_safi]) | |
1057 | continue; | |
1058 | ||
2adac256 DA |
1059 | paf = peer_af_find(peer, afi, tmp_safi); |
1060 | if (paf && paf->subgroup) | |
1061 | SET_FLAG(paf->subgroup->sflags, | |
1062 | SUBGRP_STATUS_FORCE_UPDATES); | |
1063 | ||
dc912615 | 1064 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1065 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1066 | else |
1067 | ret = peer_clear_soft(peer, afi, | |
1068 | tmp_safi, stype); | |
1069 | } | |
1070 | /* both afi/safi specified, let the caller know if not defined */ | |
1071 | } else { | |
1072 | if (!peer->afc[afi][safi]) | |
1073 | return 1; | |
1074 | ||
2adac256 DA |
1075 | paf = peer_af_find(peer, afi, safi); |
1076 | if (paf && paf->subgroup) | |
1077 | SET_FLAG(paf->subgroup->sflags, | |
1078 | SUBGRP_STATUS_FORCE_UPDATES); | |
1079 | ||
dc912615 | 1080 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1081 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1082 | else |
1083 | ret = peer_clear_soft(peer, afi, safi, stype); | |
1084 | } | |
1085 | ||
1086 | return ret; | |
1087 | } | |
1088 | ||
7aafcaca | 1089 | /* `clear ip bgp' functions. */ |
1ca2fd11 | 1090 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 1091 | enum clear_sort sort, enum bgp_clear_type stype, |
1ca2fd11 | 1092 | const char *arg) |
d62a17ae | 1093 | { |
dc912615 | 1094 | int ret = 0; |
3ae8bfa5 | 1095 | bool found = false; |
d62a17ae | 1096 | struct peer *peer; |
dc95985f | 1097 | |
1098 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 1099 | |
1100 | /* Clear all neighbors. */ | |
1101 | /* | |
1102 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
1103 | * nodes on the BGP instance as that may get freed if it is a |
1104 | * doppelganger | |
d62a17ae | 1105 | */ |
1106 | if (sort == clear_all) { | |
1107 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 1108 | |
1109 | bgp_peer_gr_flags_update(peer); | |
1110 | ||
36235319 | 1111 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 1112 | gr_router_detected = true; |
1113 | ||
c368171c | 1114 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 1115 | stype); |
d62a17ae | 1116 | |
1117 | if (ret < 0) | |
1ca2fd11 | 1118 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
dc95985f | 1119 | } |
1120 | ||
36235319 QY |
1121 | if (gr_router_detected |
1122 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1123 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1124 | } else if (!gr_router_detected |
1125 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1126 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 1127 | } |
d62a17ae | 1128 | |
1129 | /* This is to apply read-only mode on this clear. */ | |
1130 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1131 | bgp->update_delay_over = 0; | |
1132 | ||
1133 | return CMD_SUCCESS; | |
7aafcaca DS |
1134 | } |
1135 | ||
3ae8bfa5 | 1136 | /* Clear specified neighbor. */ |
d62a17ae | 1137 | if (sort == clear_peer) { |
1138 | union sockunion su; | |
d62a17ae | 1139 | |
1140 | /* Make sockunion for lookup. */ | |
1141 | ret = str2sockunion(arg, &su); | |
1142 | if (ret < 0) { | |
1143 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1144 | if (!peer) { | |
1145 | peer = peer_lookup_by_hostname(bgp, arg); | |
1146 | if (!peer) { | |
1ca2fd11 IR |
1147 | vty_out(vty, |
1148 | "Malformed address or name: %s\n", | |
d62a17ae | 1149 | arg); |
1150 | return CMD_WARNING; | |
1151 | } | |
1152 | } | |
1153 | } else { | |
1154 | peer = peer_lookup(bgp, &su); | |
1155 | if (!peer) { | |
1ca2fd11 | 1156 | vty_out(vty, |
664b6f18 | 1157 | "%% BGP: Unknown neighbor - \"%s\"\n", |
1ca2fd11 | 1158 | arg); |
d62a17ae | 1159 | return CMD_WARNING; |
1160 | } | |
1161 | } | |
7aafcaca | 1162 | |
dc95985f | 1163 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1164 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1165 | ||
dc912615 DS |
1166 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1167 | ||
1168 | /* if afi/safi not defined for this peer, let caller know */ | |
1169 | if (ret == 1) | |
3ae8bfa5 | 1170 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1171 | |
d62a17ae | 1172 | if (ret < 0) |
1ca2fd11 | 1173 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
7aafcaca | 1174 | |
d62a17ae | 1175 | return CMD_SUCCESS; |
7aafcaca | 1176 | } |
7aafcaca | 1177 | |
3ae8bfa5 | 1178 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1179 | if (sort == clear_group) { |
1180 | struct peer_group *group; | |
7aafcaca | 1181 | |
d62a17ae | 1182 | group = peer_group_lookup(bgp, arg); |
1183 | if (!group) { | |
664b6f18 | 1184 | vty_out(vty, "%% BGP: No such peer-group %s\n", arg); |
d62a17ae | 1185 | return CMD_WARNING; |
1186 | } | |
1187 | ||
1188 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1189 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1190 | |
d62a17ae | 1191 | if (ret < 0) |
1ca2fd11 | 1192 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1193 | else |
1194 | found = true; | |
d62a17ae | 1195 | } |
3ae8bfa5 PM |
1196 | |
1197 | if (!found) | |
1ca2fd11 | 1198 | vty_out(vty, |
664b6f18 | 1199 | "%% BGP: No %s peer belonging to peer-group %s is configured\n", |
5cb5f4d0 | 1200 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1201 | |
d62a17ae | 1202 | return CMD_SUCCESS; |
7aafcaca | 1203 | } |
7aafcaca | 1204 | |
3ae8bfa5 | 1205 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1206 | if (sort == clear_external) { |
1207 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1208 | if (peer->sort == BGP_PEER_IBGP) | |
1209 | continue; | |
7aafcaca | 1210 | |
dc95985f | 1211 | bgp_peer_gr_flags_update(peer); |
1212 | ||
36235319 | 1213 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1214 | gr_router_detected = true; |
dc95985f | 1215 | |
c368171c | 1216 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1217 | |
d62a17ae | 1218 | if (ret < 0) |
1ca2fd11 | 1219 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1220 | else |
1221 | found = true; | |
d62a17ae | 1222 | } |
3ae8bfa5 | 1223 | |
36235319 QY |
1224 | if (gr_router_detected |
1225 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1226 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1227 | } else if (!gr_router_detected |
1228 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1229 | bgp_zebra_send_capabilities(bgp, true); |
1230 | } | |
1231 | ||
3ae8bfa5 | 1232 | if (!found) |
1ca2fd11 | 1233 | vty_out(vty, |
664b6f18 | 1234 | "%% BGP: No external %s peer is configured\n", |
1ca2fd11 | 1235 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 1236 | |
d62a17ae | 1237 | return CMD_SUCCESS; |
1238 | } | |
1239 | ||
3ae8bfa5 | 1240 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1241 | if (sort == clear_as) { |
8079a413 PG |
1242 | as_t as; |
1243 | ||
1244 | if (!asn_str2asn(arg, &as)) { | |
1245 | vty_out(vty, "%% BGP: No such AS %s\n", arg); | |
1246 | return CMD_WARNING; | |
1247 | } | |
d62a17ae | 1248 | |
1249 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1250 | if (peer->as != as) | |
1251 | continue; | |
1252 | ||
dc95985f | 1253 | bgp_peer_gr_flags_update(peer); |
1254 | ||
36235319 | 1255 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1256 | gr_router_detected = true; |
dc95985f | 1257 | |
c368171c | 1258 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1259 | |
1260 | if (ret < 0) | |
1ca2fd11 | 1261 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1262 | else |
1263 | found = true; | |
d62a17ae | 1264 | } |
3ae8bfa5 | 1265 | |
36235319 QY |
1266 | if (gr_router_detected |
1267 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1268 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1269 | } else if (!gr_router_detected |
1270 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1271 | bgp_zebra_send_capabilities(bgp, true); |
1272 | } | |
1273 | ||
3ae8bfa5 | 1274 | if (!found) |
1ca2fd11 | 1275 | vty_out(vty, |
664b6f18 | 1276 | "%% BGP: No %s peer is configured with AS %s\n", |
1ca2fd11 | 1277 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1278 | |
d62a17ae | 1279 | return CMD_SUCCESS; |
1280 | } | |
1281 | ||
1282 | return CMD_SUCCESS; | |
1283 | } | |
1284 | ||
1ca2fd11 IR |
1285 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, |
1286 | safi_t safi, enum clear_sort sort, | |
1287 | enum bgp_clear_type stype, const char *arg) | |
d62a17ae | 1288 | { |
1289 | struct bgp *bgp; | |
1290 | ||
1291 | /* BGP structure lookup. */ | |
1292 | if (name) { | |
1293 | bgp = bgp_lookup_by_name(name); | |
1294 | if (bgp == NULL) { | |
1ca2fd11 | 1295 | vty_out(vty, "Can't find BGP instance %s\n", name); |
d62a17ae | 1296 | return CMD_WARNING; |
1297 | } | |
1298 | } else { | |
1299 | bgp = bgp_get_default(); | |
1300 | if (bgp == NULL) { | |
1ca2fd11 | 1301 | vty_out(vty, "No BGP process is configured\n"); |
d62a17ae | 1302 | return CMD_WARNING; |
1303 | } | |
1304 | } | |
1305 | ||
1ca2fd11 | 1306 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); |
7aafcaca DS |
1307 | } |
1308 | ||
1309 | /* clear soft inbound */ | |
1ca2fd11 | 1310 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1311 | { |
99b3ebd3 NS |
1312 | afi_t afi; |
1313 | safi_t safi; | |
1314 | ||
1ca2fd11 IR |
1315 | FOREACH_AFI_SAFI (afi, safi) |
1316 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1317 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1318 | } |
1319 | ||
1320 | /* clear soft outbound */ | |
1ca2fd11 | 1321 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1322 | { |
99b3ebd3 NS |
1323 | afi_t afi; |
1324 | safi_t safi; | |
1325 | ||
1ca2fd11 IR |
1326 | FOREACH_AFI_SAFI (afi, safi) |
1327 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1328 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1329 | } |
1330 | ||
1331 | ||
a486300b PG |
1332 | void bgp_clear_soft_in(struct bgp *bgp, afi_t afi, safi_t safi) |
1333 | { | |
1334 | bgp_clear(NULL, bgp, afi, safi, clear_all, BGP_CLEAR_SOFT_IN, NULL); | |
1335 | } | |
1336 | ||
4f770cf1 DA |
1337 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
1338 | uint64_t flag, int set) | |
1339 | { | |
1340 | int ret; | |
1341 | struct peer *peer; | |
1342 | ||
1343 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
1344 | if (!peer) | |
1345 | return CMD_WARNING_CONFIG_FAILED; | |
1346 | ||
1347 | /* | |
1348 | * If 'neighbor <interface>', then this is for directly connected peers, | |
1349 | * we should not accept disable-connected-check. | |
1350 | */ | |
1351 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
1352 | vty_out(vty, | |
1353 | "%s is directly connected peer, cannot accept disable-connected-check\n", | |
1354 | ip_str); | |
1355 | return CMD_WARNING_CONFIG_FAILED; | |
1356 | } | |
1357 | ||
1358 | if (!set && flag == PEER_FLAG_SHUTDOWN) | |
1359 | peer_tx_shutdown_message_unset(peer); | |
1360 | ||
1361 | if (set) | |
1362 | ret = peer_flag_set(peer, flag); | |
1363 | else | |
1364 | ret = peer_flag_unset(peer, flag); | |
1365 | ||
1366 | return bgp_vty_return(vty, ret); | |
1367 | } | |
1368 | ||
1369 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint64_t flag) | |
1370 | { | |
1371 | return peer_flag_modify_vty(vty, ip_str, flag, 1); | |
1372 | } | |
1373 | ||
1374 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, | |
1375 | uint64_t flag) | |
1376 | { | |
1377 | return peer_flag_modify_vty(vty, ip_str, flag, 0); | |
1378 | } | |
1379 | ||
2e4c2296 | 1380 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 | 1381 | |
8029b216 AK |
1382 | DEFUN_HIDDEN (bgp_local_mac, |
1383 | bgp_local_mac_cmd, | |
093e3f23 | 1384 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1385 | BGP_STR |
1386 | "Local MAC config\n" | |
1387 | "VxLAN Network Identifier\n" | |
1388 | "VNI number\n" | |
1389 | "local mac\n" | |
1390 | "mac address\n" | |
1391 | "mac-mobility sequence\n" | |
1392 | "seq number\n") | |
1393 | { | |
1394 | int rv; | |
1395 | vni_t vni; | |
1396 | struct ethaddr mac; | |
1397 | struct ipaddr ip; | |
1398 | uint32_t seq; | |
1399 | struct bgp *bgp; | |
1400 | ||
1401 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1402 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1403 | vty_out(vty, "%% Malformed MAC address\n"); | |
1404 | return CMD_WARNING; | |
1405 | } | |
1406 | memset(&ip, 0, sizeof(ip)); | |
1407 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1408 | ||
1409 | bgp = bgp_get_default(); | |
1410 | if (!bgp) { | |
1411 | vty_out(vty, "Default BGP instance is not there\n"); | |
1412 | return CMD_WARNING; | |
1413 | } | |
1414 | ||
b5e140c8 AK |
1415 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1416 | zero_esi); | |
8029b216 AK |
1417 | if (rv < 0) { |
1418 | vty_out(vty, "Internal error\n"); | |
1419 | return CMD_WARNING; | |
1420 | } | |
1421 | ||
1422 | return CMD_SUCCESS; | |
1423 | } | |
1424 | ||
1425 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1426 | no_bgp_local_mac_cmd, | |
093e3f23 | 1427 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1428 | NO_STR |
1429 | BGP_STR | |
1430 | "Local MAC config\n" | |
1431 | "VxLAN Network Identifier\n" | |
1432 | "VNI number\n" | |
1433 | "local mac\n" | |
1434 | "mac address\n") | |
1435 | { | |
1436 | int rv; | |
1437 | vni_t vni; | |
1438 | struct ethaddr mac; | |
1439 | struct ipaddr ip; | |
1440 | struct bgp *bgp; | |
1441 | ||
1442 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1443 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1444 | vty_out(vty, "%% Malformed MAC address\n"); | |
1445 | return CMD_WARNING; | |
1446 | } | |
1447 | memset(&ip, 0, sizeof(ip)); | |
1448 | ||
1449 | bgp = bgp_get_default(); | |
1450 | if (!bgp) { | |
1451 | vty_out(vty, "Default BGP instance is not there\n"); | |
1452 | return CMD_WARNING; | |
1453 | } | |
1454 | ||
ec0ab544 | 1455 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1456 | if (rv < 0) { |
1457 | vty_out(vty, "Internal error\n"); | |
1458 | return CMD_WARNING; | |
1459 | } | |
1460 | ||
1461 | return CMD_SUCCESS; | |
1462 | } | |
1463 | ||
718e3744 | 1464 | DEFUN (no_synchronization, |
1465 | no_synchronization_cmd, | |
1466 | "no synchronization", | |
1467 | NO_STR | |
1468 | "Perform IGP synchronization\n") | |
1469 | { | |
d62a17ae | 1470 | return CMD_SUCCESS; |
718e3744 | 1471 | } |
1472 | ||
1473 | DEFUN (no_auto_summary, | |
1474 | no_auto_summary_cmd, | |
1475 | "no auto-summary", | |
1476 | NO_STR | |
1477 | "Enable automatic network number summarization\n") | |
1478 | { | |
d62a17ae | 1479 | return CMD_SUCCESS; |
718e3744 | 1480 | } |
3d515fd9 | 1481 | |
718e3744 | 1482 | /* "router bgp" commands. */ |
1ca2fd11 IR |
1483 | DEFUN_NOSH (router_bgp, |
1484 | router_bgp_cmd, | |
e55b0883 | 1485 | "router bgp [ASNUM$instasn [<view|vrf> VIEWVRFNAME] [as-notation <dot|dot+|plain>]]", |
1ca2fd11 IR |
1486 | ROUTER_STR |
1487 | BGP_STR | |
1488 | AS_STR | |
e55b0883 PG |
1489 | BGP_INSTANCE_HELP_STR |
1490 | "Force the AS notation output\n" | |
1491 | "use 'AA.BB' format for AS 4 byte values\n" | |
1492 | "use 'AA.BB' format for all AS values\n" | |
1493 | "use plain format for all AS values\n") | |
718e3744 | 1494 | { |
d62a17ae | 1495 | int idx_asn = 2; |
1496 | int idx_view_vrf = 3; | |
1497 | int idx_vrf = 4; | |
1ca2fd11 | 1498 | int is_new_bgp = 0; |
e55b0883 PG |
1499 | int idx_asnotation = 3; |
1500 | int idx_asnotation_kind = 4; | |
1501 | enum asnotation_mode asnotation = ASNOTATION_UNDEFINED; | |
1ca2fd11 | 1502 | int ret; |
d62a17ae | 1503 | as_t as; |
1504 | struct bgp *bgp; | |
1505 | const char *name = NULL; | |
1506 | enum bgp_instance_type inst_type; | |
1507 | ||
1508 | // "router bgp" without an ASN | |
1509 | if (argc == 2) { | |
1510 | // Pending: Make VRF option available for ASN less config | |
1abef40f | 1511 | bgp = bgp_get_default(); |
d62a17ae | 1512 | |
1abef40f | 1513 | if (bgp == NULL) { |
d62a17ae | 1514 | vty_out(vty, "%% No BGP process is configured\n"); |
1515 | return CMD_WARNING_CONFIG_FAILED; | |
1516 | } | |
1517 | ||
1518 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1519 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1520 | return CMD_WARNING_CONFIG_FAILED; |
1521 | } | |
1522 | } | |
1523 | ||
1524 | // "router bgp X" | |
1525 | else { | |
8079a413 PG |
1526 | if (!asn_str2asn(argv[idx_asn]->arg, &as)) { |
1527 | vty_out(vty, "%% BGP: No such AS %s\n", | |
1528 | argv[idx_asn]->arg); | |
1529 | return CMD_WARNING_CONFIG_FAILED; | |
1530 | } | |
1ca2fd11 | 1531 | |
cc413e2a DA |
1532 | if (as == BGP_PRIVATE_AS_MAX || as == BGP_AS4_MAX) |
1533 | vty_out(vty, "Reserved AS used (%u|%u); AS is %u\n", | |
1534 | BGP_PRIVATE_AS_MAX, BGP_AS4_MAX, as); | |
1535 | ||
d62a17ae | 1536 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
d62a17ae | 1537 | |
e55b0883 PG |
1538 | if (argv_find(argv, argc, "VIEWVRFNAME", &idx_vrf)) { |
1539 | idx_view_vrf = idx_vrf - 1; | |
1540 | if (argv[idx_view_vrf]->text) { | |
1541 | name = argv[idx_vrf]->arg; | |
1542 | ||
1543 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { | |
1544 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1545 | name = NULL; | |
1546 | else | |
1547 | inst_type = | |
1548 | BGP_INSTANCE_TYPE_VRF; | |
1549 | } else if (!strcmp(argv[idx_view_vrf]->text, | |
1550 | "view")) | |
1551 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
1552 | } | |
1553 | } | |
1554 | if (argv_find(argv, argc, "as-notation", &idx_asnotation)) { | |
1555 | idx_asnotation_kind = idx_asnotation + 1; | |
1556 | if (strmatch(argv[idx_asnotation_kind]->text, "dot+")) | |
1557 | asnotation = ASNOTATION_DOTPLUS; | |
1558 | else if (strmatch(argv[idx_asnotation_kind]->text, | |
1559 | "dot")) | |
1560 | asnotation = ASNOTATION_DOT; | |
1561 | else if (strmatch(argv[idx_asnotation_kind]->text, | |
1562 | "plain")) | |
1563 | asnotation = ASNOTATION_PLAIN; | |
d62a17ae | 1564 | } |
1565 | ||
1ca2fd11 IR |
1566 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1567 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
3bd70bf8 | 1568 | |
9eb11997 | 1569 | ret = bgp_get_vty(&bgp, &as, name, inst_type, |
e55b0883 | 1570 | argv[idx_asn]->arg, asnotation); |
1ca2fd11 IR |
1571 | switch (ret) { |
1572 | case BGP_ERR_AS_MISMATCH: | |
9eb11997 PG |
1573 | vty_out(vty, "BGP is already running; AS is %s\n", |
1574 | bgp->as_pretty); | |
1ca2fd11 IR |
1575 | return CMD_WARNING_CONFIG_FAILED; |
1576 | case BGP_ERR_INSTANCE_MISMATCH: | |
1577 | vty_out(vty, | |
1578 | "BGP instance name and AS number mismatch\n"); | |
1579 | vty_out(vty, | |
9eb11997 PG |
1580 | "BGP instance is already running; AS is %s\n", |
1581 | bgp->as_pretty); | |
1ca2fd11 | 1582 | return CMD_WARNING_CONFIG_FAILED; |
ff8a8a7a | 1583 | } |
1ca2fd11 IR |
1584 | |
1585 | /* | |
1586 | * If we just instantiated the default instance, complete | |
1587 | * any pending VRF-VPN leaking that was configured via | |
1588 | * earlier "router bgp X vrf FOO" blocks. | |
1589 | */ | |
1590 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1591 | vpn_leak_postchange_all(); | |
1592 | ||
1593 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1594 | bgp_vpn_leak_export(bgp); | |
1595 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1596 | */ | |
e55b0883 PG |
1597 | /* for pre-existing bgp instance, |
1598 | * - update as_pretty | |
1599 | * - update asnotation if explicitly mentioned | |
1600 | */ | |
1601 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) { | |
1602 | XFREE(MTYPE_BGP, bgp->as_pretty); | |
1603 | bgp->as_pretty = XSTRDUP(MTYPE_BGP, argv[idx_asn]->arg); | |
1604 | if (!CHECK_FLAG(bgp->config, BGP_CONFIG_ASNOTATION) && | |
1605 | asnotation != ASNOTATION_UNDEFINED) { | |
1606 | SET_FLAG(bgp->config, BGP_CONFIG_ASNOTATION); | |
1607 | bgp->asnotation = asnotation; | |
1608 | } | |
1609 | } | |
d62a17ae | 1610 | } |
1611 | ||
1ca2fd11 IR |
1612 | /* unset the auto created flag as the user config is now present */ |
1613 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1614 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1615 | ||
1616 | return CMD_SUCCESS; | |
718e3744 | 1617 | } |
1618 | ||
718e3744 | 1619 | /* "no router bgp" commands. */ |
1ca2fd11 IR |
1620 | DEFUN (no_router_bgp, |
1621 | no_router_bgp_cmd, | |
e55b0883 | 1622 | "no router bgp [ASNUM$instasn [<view|vrf> VIEWVRFNAME] [as-notation <dot|dot+|plain>]]", |
1ca2fd11 IR |
1623 | NO_STR |
1624 | ROUTER_STR | |
1625 | BGP_STR | |
1626 | AS_STR | |
e55b0883 PG |
1627 | BGP_INSTANCE_HELP_STR |
1628 | "Force the AS notation output\n" | |
1629 | "use 'AA.BB' format for AS 4 byte values\n" | |
1630 | "use 'AA.BB' format for all AS values\n" | |
1631 | "use plain format for all AS values\n") | |
718e3744 | 1632 | { |
4fd9919e | 1633 | int idx_asn = 3; |
d62a17ae | 1634 | int idx_vrf = 5; |
1ca2fd11 | 1635 | as_t as; |
4fd9919e | 1636 | struct bgp *bgp; |
d62a17ae | 1637 | const char *name = NULL; |
718e3744 | 1638 | |
d62a17ae | 1639 | // "no router bgp" without an ASN |
1640 | if (argc == 3) { | |
1641 | // Pending: Make VRF option available for ASN less config | |
8382083a | 1642 | bgp = bgp_get_default(); |
718e3744 | 1643 | |
8382083a | 1644 | if (bgp == NULL) { |
d62a17ae | 1645 | vty_out(vty, "%% No BGP process is configured\n"); |
1646 | return CMD_WARNING_CONFIG_FAILED; | |
1647 | } | |
7fb21a9f | 1648 | |
d62a17ae | 1649 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1650 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1651 | return CMD_WARNING_CONFIG_FAILED; |
1652 | } | |
4fd9919e | 1653 | |
4fd9919e | 1654 | if (bgp->l3vni) { |
be125e6f | 1655 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
4fd9919e IR |
1656 | bgp->l3vni); |
1657 | return CMD_WARNING_CONFIG_FAILED; | |
1658 | } | |
d62a17ae | 1659 | } else { |
8079a413 PG |
1660 | if (!asn_str2asn(argv[idx_asn]->arg, &as)) { |
1661 | vty_out(vty, "%% BGP: No such AS %s\n", | |
1662 | argv[idx_asn]->arg); | |
1663 | return CMD_WARNING_CONFIG_FAILED; | |
1664 | } | |
1ca42c8d | 1665 | if (argc > 4) { |
d62a17ae | 1666 | name = argv[idx_vrf]->arg; |
1ca42c8d IR |
1667 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") |
1668 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1669 | name = NULL; | |
1670 | } | |
7fb21a9f | 1671 | |
4fd9919e IR |
1672 | /* Lookup bgp structure. */ |
1673 | bgp = bgp_lookup(as, name); | |
1674 | if (!bgp) { | |
1675 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1676 | return CMD_WARNING_CONFIG_FAILED; | |
1677 | } | |
1678 | ||
1679 | if (bgp->l3vni) { | |
1680 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1681 | bgp->l3vni); | |
1682 | return CMD_WARNING_CONFIG_FAILED; | |
1683 | } | |
1684 | ||
1685 | /* Cannot delete default instance if vrf instances exist */ | |
1686 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1687 | struct listnode *node; | |
1688 | struct bgp *tmp_bgp; | |
1689 | ||
1690 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1691 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1692 | continue; | |
1693 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1694 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1695 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1696 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1697 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1698 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1699 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1700 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1701 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1702 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1703 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1704 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1705 | (bgp == bgp_get_evpn() && | |
1706 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1707 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1708 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1709 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1710 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1711 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1712 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1713 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
f33bf7c0 | 1714 | (hashcount(tmp_bgp->vnihash))) { |
4fd9919e IR |
1715 | vty_out(vty, |
1716 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1717 | return CMD_WARNING_CONFIG_FAILED; | |
1718 | } | |
1719 | } | |
1720 | } | |
d62a17ae | 1721 | } |
718e3744 | 1722 | |
1ca2fd11 | 1723 | bgp_delete(bgp); |
718e3744 | 1724 | |
1ca2fd11 | 1725 | return CMD_SUCCESS; |
718e3744 | 1726 | } |
1727 | ||
425bd64b PS |
1728 | /* bgp session-dscp */ |
1729 | ||
1730 | DEFPY (bgp_session_dscp, | |
1731 | bgp_session_dscp_cmd, | |
1732 | "bgp session-dscp (0-63)$dscp", | |
1733 | BGP_STR | |
1734 | "Override default (C6) bgp TCP session DSCP value\n" | |
1735 | "Manually configured dscp parameter\n") | |
1736 | { | |
1737 | bm->tcp_dscp = dscp << 2; | |
1738 | ||
1739 | return CMD_SUCCESS; | |
1740 | } | |
1741 | ||
1742 | DEFPY (no_bgp_session_dscp, | |
1743 | no_bgp_session_dscp_cmd, | |
1744 | "no bgp session-dscp [(0-63)]", | |
1745 | NO_STR | |
1746 | BGP_STR | |
1747 | "Override default (C6) bgp TCP session DSCP value\n" | |
1748 | "Manually configured dscp parameter\n") | |
1749 | { | |
1750 | bm->tcp_dscp = IPTOS_PREC_INTERNETCONTROL; | |
1751 | ||
1752 | return CMD_SUCCESS; | |
1753 | } | |
718e3744 | 1754 | |
ff8a8a7a CS |
1755 | /* BGP router-id. */ |
1756 | ||
1ca2fd11 IR |
1757 | DEFPY (bgp_router_id, |
1758 | bgp_router_id_cmd, | |
1759 | "bgp router-id A.B.C.D", | |
1760 | BGP_STR | |
1761 | "Override configured router identifier\n" | |
1762 | "Manually configured router identifier\n") | |
718e3744 | 1763 | { |
1ca2fd11 IR |
1764 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1765 | bgp_router_id_static_set(bgp, router_id); | |
1766 | return CMD_SUCCESS; | |
ff8a8a7a | 1767 | } |
718e3744 | 1768 | |
1ca2fd11 IR |
1769 | DEFPY (no_bgp_router_id, |
1770 | no_bgp_router_id_cmd, | |
1771 | "no bgp router-id [A.B.C.D]", | |
1772 | NO_STR | |
1773 | BGP_STR | |
1774 | "Override configured router identifier\n" | |
1775 | "Manually configured router identifier\n") | |
ff8a8a7a | 1776 | { |
1ca2fd11 | 1777 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1778 | |
1ca2fd11 IR |
1779 | if (router_id_str) { |
1780 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1781 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1782 | return CMD_WARNING_CONFIG_FAILED; | |
1783 | } | |
1784 | } | |
718e3744 | 1785 | |
1ca2fd11 IR |
1786 | router_id.s_addr = 0; |
1787 | bgp_router_id_static_set(bgp, router_id); | |
1788 | ||
1789 | return CMD_SUCCESS; | |
ff8a8a7a | 1790 | } |
6b0655a2 | 1791 | |
ed0e57e3 | 1792 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
b4ad2fae | 1793 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", |
ed0e57e3 DA |
1794 | NO_STR BGP_STR |
1795 | "Add community specific parameters\n" | |
1796 | "Create an alias for a community\n" | |
1797 | "Community (AA:BB or AA:BB:CC)\n" | |
1798 | "Alias name\n") | |
1799 | { | |
8cfa1e78 | 1800 | struct community_alias ca = {}; |
ed0e57e3 DA |
1801 | struct community_alias *lookup_community; |
1802 | struct community_alias *lookup_alias; | |
d13d137a DA |
1803 | struct community *comm; |
1804 | struct lcommunity *lcomm; | |
1805 | uint8_t invalid = 0; | |
ed0e57e3 | 1806 | |
d13d137a DA |
1807 | comm = community_str2com(community); |
1808 | if (!comm) | |
1809 | invalid++; | |
1810 | community_free(&comm); | |
1811 | ||
1812 | lcomm = lcommunity_str2com(community); | |
1813 | if (!lcomm) | |
1814 | invalid++; | |
1815 | lcommunity_free(&lcomm); | |
1816 | ||
1817 | if (invalid > 1) { | |
ed0e57e3 DA |
1818 | vty_out(vty, "Invalid community format\n"); |
1819 | return CMD_WARNING; | |
1820 | } | |
1821 | ||
8cfa1e78 DA |
1822 | strlcpy(ca.community, community, sizeof(ca.community)); |
1823 | strlcpy(ca.alias, alias_name, sizeof(ca.alias)); | |
ed0e57e3 | 1824 | |
8cfa1e78 DA |
1825 | lookup_community = bgp_ca_community_lookup(&ca); |
1826 | lookup_alias = bgp_ca_alias_lookup(&ca); | |
ed0e57e3 DA |
1827 | |
1828 | if (no) { | |
8cfa1e78 DA |
1829 | bgp_ca_alias_delete(&ca); |
1830 | bgp_ca_community_delete(&ca); | |
ed0e57e3 DA |
1831 | } else { |
1832 | if (lookup_alias) { | |
1833 | /* Lookup if community hash table has an item | |
1834 | * with the same alias name. | |
1835 | */ | |
8cfa1e78 DA |
1836 | strlcpy(ca.community, lookup_alias->community, |
1837 | sizeof(ca.community)); | |
1838 | if (bgp_ca_community_lookup(&ca)) { | |
ed0e57e3 DA |
1839 | vty_out(vty, |
1840 | "community (%s) already has this alias (%s)\n", | |
1841 | lookup_alias->community, | |
1842 | lookup_alias->alias); | |
1843 | return CMD_WARNING; | |
1844 | } | |
8cfa1e78 | 1845 | bgp_ca_alias_delete(&ca); |
ed0e57e3 DA |
1846 | } |
1847 | ||
8cfa1e78 DA |
1848 | if (lookup_community) { |
1849 | /* Lookup if alias hash table has an item | |
1850 | * with the same community. | |
1851 | */ | |
1852 | strlcpy(ca.alias, lookup_community->alias, | |
1853 | sizeof(ca.alias)); | |
1854 | if (bgp_ca_alias_lookup(&ca)) { | |
1855 | vty_out(vty, | |
1856 | "alias (%s) already has this community (%s)\n", | |
1857 | lookup_community->alias, | |
1858 | lookup_community->community); | |
1859 | return CMD_WARNING; | |
1860 | } | |
1861 | bgp_ca_community_delete(&ca); | |
1862 | } | |
ed0e57e3 | 1863 | |
8cfa1e78 DA |
1864 | bgp_ca_alias_insert(&ca); |
1865 | bgp_ca_community_insert(&ca); | |
ed0e57e3 DA |
1866 | } |
1867 | ||
1868 | return CMD_SUCCESS; | |
1869 | } | |
1870 | ||
9acb67cb DS |
1871 | DEFPY (bgp_global_suppress_fib_pending, |
1872 | bgp_global_suppress_fib_pending_cmd, | |
1873 | "[no] bgp suppress-fib-pending", | |
1874 | NO_STR | |
1875 | BGP_STR | |
1876 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1877 | { | |
1878 | bm_wait_for_fib_set(!no); | |
1879 | ||
1880 | return CMD_SUCCESS; | |
1881 | } | |
1882 | ||
c208c586 S |
1883 | DEFPY (bgp_suppress_fib_pending, |
1884 | bgp_suppress_fib_pending_cmd, | |
1885 | "[no] bgp suppress-fib-pending", | |
1886 | NO_STR | |
1887 | BGP_STR | |
1888 | "Advertise only routes that are programmed in kernel to peers\n") | |
1889 | { | |
1890 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1891 | ||
1892 | bgp_suppress_fib_pending_set(bgp, !no); | |
1893 | return CMD_SUCCESS; | |
1894 | } | |
1895 | ||
718e3744 | 1896 | /* BGP Cluster ID. */ |
1ca2fd11 IR |
1897 | DEFUN (bgp_cluster_id, |
1898 | bgp_cluster_id_cmd, | |
1899 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1900 | BGP_STR | |
1901 | "Configure Route-Reflector Cluster-id\n" | |
1902 | "Route-Reflector Cluster-id in IP address format\n" | |
1903 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1904 | { |
1ca2fd11 | 1905 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1906 | int idx_ipv4 = 2; |
1ca2fd11 IR |
1907 | int ret; |
1908 | struct in_addr cluster; | |
1909 | ||
1910 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1911 | if (!ret) { | |
1912 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1913 | return CMD_WARNING_CONFIG_FAILED; | |
1914 | } | |
718e3744 | 1915 | |
1ca2fd11 IR |
1916 | bgp_cluster_id_set(bgp, &cluster); |
1917 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1918 | |
1ca2fd11 | 1919 | return CMD_SUCCESS; |
718e3744 | 1920 | } |
1921 | ||
1ca2fd11 IR |
1922 | DEFUN (no_bgp_cluster_id, |
1923 | no_bgp_cluster_id_cmd, | |
1924 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1925 | NO_STR | |
1926 | BGP_STR | |
1927 | "Configure Route-Reflector Cluster-id\n" | |
1928 | "Route-Reflector Cluster-id in IP address format\n" | |
1929 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1930 | { |
1ca2fd11 IR |
1931 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1932 | bgp_cluster_id_unset(bgp); | |
1933 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1934 | |
1ca2fd11 | 1935 | return CMD_SUCCESS; |
718e3744 | 1936 | } |
1937 | ||
c163f297 DS |
1938 | DEFPY (bgp_norib, |
1939 | bgp_norib_cmd, | |
1940 | "bgp no-rib", | |
1941 | BGP_STR | |
1942 | "Disable BGP route installation to RIB (Zebra)\n") | |
1943 | { | |
1944 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1945 | vty_out(vty, | |
1946 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1947 | return CMD_SUCCESS; | |
1948 | } | |
1949 | ||
1950 | bgp_option_norib_set_runtime(); | |
1951 | ||
1952 | return CMD_SUCCESS; | |
1953 | } | |
1954 | ||
1955 | DEFPY (no_bgp_norib, | |
1956 | no_bgp_norib_cmd, | |
1957 | "no bgp no-rib", | |
1958 | NO_STR | |
1959 | BGP_STR | |
1960 | "Disable BGP route installation to RIB (Zebra)\n") | |
1961 | { | |
1962 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1963 | vty_out(vty, | |
1964 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1965 | return CMD_SUCCESS; | |
1966 | } | |
1967 | ||
1968 | bgp_option_norib_unset_runtime(); | |
1969 | ||
1970 | return CMD_SUCCESS; | |
1971 | } | |
1972 | ||
e46723a5 DS |
1973 | DEFPY (no_bgp_send_extra_data, |
1974 | no_bgp_send_extra_data_cmd, | |
1975 | "[no] bgp send-extra-data zebra", | |
1976 | NO_STR | |
1977 | BGP_STR | |
1978 | "Extra data to Zebra for display/use\n" | |
1979 | "To zebra\n") | |
1980 | { | |
ec0acb80 DA |
1981 | if (no) |
1982 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1983 | else | |
1984 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1985 | |
1986 | return CMD_SUCCESS; | |
1987 | } | |
1988 | ||
1ca2fd11 IR |
1989 | DEFUN (bgp_confederation_identifier, |
1990 | bgp_confederation_identifier_cmd, | |
8079a413 | 1991 | "bgp confederation identifier ASNUM", |
e9273987 | 1992 | BGP_STR |
1ca2fd11 | 1993 | "AS confederation parameters\n" |
8079a413 | 1994 | AS_STR |
1ca2fd11 | 1995 | "Set routing domain confederation AS\n") |
718e3744 | 1996 | { |
1ca2fd11 | 1997 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1998 | int idx_number = 3; |
1ca2fd11 | 1999 | as_t as; |
718e3744 | 2000 | |
8079a413 PG |
2001 | if (!asn_str2asn(argv[idx_number]->arg, &as)) { |
2002 | vty_out(vty, "%% BGP: No such AS %s\n", argv[idx_number]->arg); | |
2003 | return CMD_WARNING_CONFIG_FAILED; | |
2004 | } | |
718e3744 | 2005 | |
1ca2fd11 | 2006 | bgp_confederation_id_set(bgp, as); |
718e3744 | 2007 | |
1ca2fd11 | 2008 | return CMD_SUCCESS; |
718e3744 | 2009 | } |
2010 | ||
1ca2fd11 IR |
2011 | DEFUN (no_bgp_confederation_identifier, |
2012 | no_bgp_confederation_identifier_cmd, | |
8079a413 | 2013 | "no bgp confederation identifier [ASNUM]", |
1ca2fd11 | 2014 | NO_STR |
e9273987 | 2015 | BGP_STR |
1ca2fd11 | 2016 | "AS confederation parameters\n" |
8079a413 | 2017 | AS_STR |
1ca2fd11 | 2018 | "Set routing domain confederation AS\n") |
ff8a8a7a | 2019 | { |
1ca2fd11 IR |
2020 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2021 | bgp_confederation_id_unset(bgp); | |
2022 | ||
2023 | return CMD_SUCCESS; | |
ff8a8a7a CS |
2024 | } |
2025 | ||
1ca2fd11 IR |
2026 | DEFUN (bgp_confederation_peers, |
2027 | bgp_confederation_peers_cmd, | |
8079a413 | 2028 | "bgp confederation peers ASNUM...", |
e9273987 | 2029 | BGP_STR |
1ca2fd11 IR |
2030 | "AS confederation parameters\n" |
2031 | "Peer ASs in BGP confederation\n" | |
2032 | AS_STR) | |
718e3744 | 2033 | { |
1ca2fd11 | 2034 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2035 | int idx_asn = 3; |
1ca2fd11 | 2036 | as_t as; |
d62a17ae | 2037 | int i; |
718e3744 | 2038 | |
1ca2fd11 | 2039 | for (i = idx_asn; i < argc; i++) { |
8079a413 PG |
2040 | if (!asn_str2asn(argv[i]->arg, &as)) { |
2041 | vty_out(vty, "%% Invalid confed peer AS value: %s\n", | |
2042 | argv[i]->arg); | |
2043 | continue; | |
2044 | } | |
2045 | ||
1ca2fd11 IR |
2046 | bgp_confederation_peers_add(bgp, as); |
2047 | } | |
2048 | return CMD_SUCCESS; | |
718e3744 | 2049 | } |
2050 | ||
1ca2fd11 IR |
2051 | DEFUN (no_bgp_confederation_peers, |
2052 | no_bgp_confederation_peers_cmd, | |
8079a413 | 2053 | "no bgp confederation peers ASNUM...", |
1ca2fd11 | 2054 | NO_STR |
e9273987 | 2055 | BGP_STR |
1ca2fd11 IR |
2056 | "AS confederation parameters\n" |
2057 | "Peer ASs in BGP confederation\n" | |
2058 | AS_STR) | |
718e3744 | 2059 | { |
1ca2fd11 | 2060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2061 | int idx_asn = 4; |
1ca2fd11 | 2062 | as_t as; |
d62a17ae | 2063 | int i; |
718e3744 | 2064 | |
1ca2fd11 | 2065 | for (i = idx_asn; i < argc; i++) { |
8079a413 PG |
2066 | if (!asn_str2asn(argv[i]->arg, &as)) { |
2067 | vty_out(vty, "%% Invalid confed peer AS value: %s\n", | |
2068 | argv[i]->arg); | |
2069 | continue; | |
2070 | } | |
1ca2fd11 IR |
2071 | bgp_confederation_peers_remove(bgp, as); |
2072 | } | |
2073 | return CMD_SUCCESS; | |
718e3744 | 2074 | } |
6b0655a2 | 2075 | |
5e242b0d DS |
2076 | /** |
2077 | * Central routine for maximum-paths configuration. | |
2078 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
2079 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
2080 | */ | |
585f1adc IR |
2081 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
2082 | const char *mpaths, uint16_t options, | |
2083 | int set) | |
d62a17ae | 2084 | { |
585f1adc IR |
2085 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2086 | uint16_t maxpaths = 0; | |
d62a17ae | 2087 | int ret; |
585f1adc IR |
2088 | afi_t afi; |
2089 | safi_t safi; | |
2090 | ||
2091 | afi = bgp_node_afi(vty); | |
2092 | safi = bgp_node_safi(vty); | |
d62a17ae | 2093 | |
2094 | if (set) { | |
585f1adc | 2095 | maxpaths = strtol(mpaths, NULL, 10); |
d62a17ae | 2096 | if (maxpaths > multipath_num) { |
585f1adc | 2097 | vty_out(vty, |
d62a17ae | 2098 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
2099 | maxpaths, multipath_num); | |
2100 | return CMD_WARNING_CONFIG_FAILED; | |
2101 | } | |
2102 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
2103 | options); | |
2104 | } else | |
2105 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
2106 | ||
2107 | if (ret < 0) { | |
585f1adc | 2108 | vty_out(vty, |
d62a17ae | 2109 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
2110 | (set == 1) ? "" : "un", | |
2111 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
2112 | maxpaths, afi, safi); | |
2113 | return CMD_WARNING_CONFIG_FAILED; | |
2114 | } | |
2115 | ||
2116 | bgp_recalculate_all_bestpaths(bgp); | |
2117 | ||
2118 | return CMD_SUCCESS; | |
165b5fff JB |
2119 | } |
2120 | ||
1ca2fd11 IR |
2121 | DEFUN (bgp_maxmed_admin, |
2122 | bgp_maxmed_admin_cmd, | |
2123 | "bgp max-med administrative ", | |
2124 | BGP_STR | |
2125 | "Advertise routes with max-med\n" | |
2126 | "Administratively applied, for an indefinite period\n") | |
abc920f8 | 2127 | { |
1ca2fd11 | 2128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 2129 | |
1ca2fd11 IR |
2130 | bgp->v_maxmed_admin = 1; |
2131 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
ff8a8a7a | 2132 | |
1ca2fd11 | 2133 | bgp_maxmed_update(bgp); |
abc920f8 | 2134 | |
1ca2fd11 | 2135 | return CMD_SUCCESS; |
ff8a8a7a CS |
2136 | } |
2137 | ||
1ca2fd11 IR |
2138 | DEFUN (bgp_maxmed_admin_medv, |
2139 | bgp_maxmed_admin_medv_cmd, | |
2140 | "bgp max-med administrative (0-4294967295)", | |
2141 | BGP_STR | |
2142 | "Advertise routes with max-med\n" | |
2143 | "Administratively applied, for an indefinite period\n" | |
2144 | "Max MED value to be used\n") | |
abc920f8 | 2145 | { |
1ca2fd11 | 2146 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2147 | int idx_number = 3; |
abc920f8 | 2148 | |
1ca2fd11 IR |
2149 | bgp->v_maxmed_admin = 1; |
2150 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 2151 | |
1ca2fd11 | 2152 | bgp_maxmed_update(bgp); |
abc920f8 | 2153 | |
1ca2fd11 | 2154 | return CMD_SUCCESS; |
abc920f8 DS |
2155 | } |
2156 | ||
1ca2fd11 IR |
2157 | DEFUN (no_bgp_maxmed_admin, |
2158 | no_bgp_maxmed_admin_cmd, | |
2159 | "no bgp max-med administrative [(0-4294967295)]", | |
2160 | NO_STR | |
2161 | BGP_STR | |
2162 | "Advertise routes with max-med\n" | |
2163 | "Administratively applied, for an indefinite period\n" | |
2164 | "Max MED value to be used\n") | |
abc920f8 | 2165 | { |
1ca2fd11 IR |
2166 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2167 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
2168 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
2169 | bgp_maxmed_update(bgp); | |
ff8a8a7a | 2170 | |
1ca2fd11 | 2171 | return CMD_SUCCESS; |
abc920f8 DS |
2172 | } |
2173 | ||
1ca2fd11 IR |
2174 | DEFUN (bgp_maxmed_onstartup, |
2175 | bgp_maxmed_onstartup_cmd, | |
2176 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
2177 | BGP_STR | |
2178 | "Advertise routes with max-med\n" | |
2179 | "Effective on a startup\n" | |
2180 | "Time (seconds) period for max-med\n" | |
2181 | "Max MED value to be used\n") | |
abc920f8 | 2182 | { |
1ca2fd11 | 2183 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2184 | int idx = 0; |
4668a151 | 2185 | |
9b01d289 DA |
2186 | if (argv_find(argv, argc, "(5-86400)", &idx)) |
2187 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
d62a17ae | 2188 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
1ca2fd11 | 2189 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 2190 | else |
1ca2fd11 | 2191 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 | 2192 | |
1ca2fd11 IR |
2193 | bgp_maxmed_update(bgp); |
2194 | ||
2195 | return CMD_SUCCESS; | |
abc920f8 DS |
2196 | } |
2197 | ||
1ca2fd11 IR |
2198 | DEFUN (no_bgp_maxmed_onstartup, |
2199 | no_bgp_maxmed_onstartup_cmd, | |
2200 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
2201 | NO_STR | |
2202 | BGP_STR | |
2203 | "Advertise routes with max-med\n" | |
2204 | "Effective on a startup\n" | |
2205 | "Time (seconds) period for max-med\n" | |
2206 | "Max MED value to be used\n") | |
abc920f8 | 2207 | { |
1ca2fd11 IR |
2208 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2209 | ||
2210 | /* Cancel max-med onstartup if its on */ | |
2211 | if (bgp->t_maxmed_onstartup) { | |
c3aaa89a | 2212 | THREAD_OFF(bgp->t_maxmed_onstartup); |
1ca2fd11 IR |
2213 | bgp->maxmed_onstartup_over = 1; |
2214 | } | |
abc920f8 | 2215 | |
1ca2fd11 IR |
2216 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
2217 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 2218 | |
1ca2fd11 IR |
2219 | bgp_maxmed_update(bgp); |
2220 | ||
2221 | return CMD_SUCCESS; | |
abc920f8 DS |
2222 | } |
2223 | ||
d70583f7 D |
2224 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
2225 | uint16_t update_delay, | |
2226 | uint16_t establish_wait) | |
2227 | { | |
2228 | struct listnode *node, *nnode; | |
2229 | struct bgp *bgp; | |
2230 | bool vrf_cfg = false; | |
2231 | ||
2232 | /* | |
2233 | * See if update-delay is set per-vrf and warn user to delete it | |
2234 | * Note that we only need to check this if this is the first time | |
2235 | * setting the global config. | |
2236 | */ | |
2237 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
2238 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2239 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
2240 | vty_out(vty, | |
2241 | "%% update-delay configuration found in vrf %s\n", | |
2242 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
2243 | ? VRF_DEFAULT_NAME | |
2244 | : bgp->name); | |
2245 | vrf_cfg = true; | |
2246 | } | |
2247 | } | |
2248 | } | |
2249 | ||
2250 | if (vrf_cfg) { | |
2251 | vty_out(vty, | |
2252 | "%%Failed: global update-delay config not permitted\n"); | |
2253 | return CMD_WARNING; | |
2254 | } | |
2255 | ||
2256 | if (!establish_wait) { /* update-delay <delay> */ | |
2257 | bm->v_update_delay = update_delay; | |
2258 | bm->v_establish_wait = bm->v_update_delay; | |
2259 | } else { | |
2260 | /* update-delay <delay> <establish-wait> */ | |
2261 | if (update_delay < establish_wait) { | |
2262 | vty_out(vty, | |
2263 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2264 | return CMD_WARNING_CONFIG_FAILED; | |
2265 | } | |
2266 | ||
2267 | bm->v_update_delay = update_delay; | |
2268 | bm->v_establish_wait = establish_wait; | |
2269 | } | |
2270 | ||
2271 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2272 | bgp->v_update_delay = bm->v_update_delay; | |
2273 | bgp->v_establish_wait = bm->v_establish_wait; | |
2274 | } | |
2275 | ||
2276 | return CMD_SUCCESS; | |
2277 | } | |
2278 | ||
2279 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2280 | { | |
2281 | struct listnode *node, *nnode; | |
2282 | struct bgp *bgp; | |
2283 | ||
2284 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2285 | bm->v_establish_wait = bm->v_update_delay; | |
2286 | ||
2287 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2288 | bgp->v_update_delay = bm->v_update_delay; | |
2289 | bgp->v_establish_wait = bm->v_establish_wait; | |
2290 | } | |
2291 | ||
2292 | return CMD_SUCCESS; | |
2293 | } | |
2294 | ||
2295 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2296 | uint16_t establish_wait) | |
f188f2c4 | 2297 | { |
d62a17ae | 2298 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2299 | |
d70583f7 D |
2300 | /* if configured globally, per-instance config is not allowed */ |
2301 | if (bm->v_update_delay) { | |
2302 | vty_out(vty, | |
2303 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2304 | return CMD_WARNING_CONFIG_FAILED; | |
2305 | } | |
2306 | ||
f188f2c4 | 2307 | |
d70583f7 | 2308 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2309 | { |
2310 | bgp->v_update_delay = update_delay; | |
2311 | bgp->v_establish_wait = bgp->v_update_delay; | |
2312 | return CMD_SUCCESS; | |
2313 | } | |
f188f2c4 | 2314 | |
d62a17ae | 2315 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2316 | if (update_delay < establish_wait) { |
2317 | vty_out(vty, | |
2318 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2319 | return CMD_WARNING_CONFIG_FAILED; | |
2320 | } | |
f188f2c4 | 2321 | |
d62a17ae | 2322 | bgp->v_update_delay = update_delay; |
2323 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2324 | |
d62a17ae | 2325 | return CMD_SUCCESS; |
f188f2c4 DS |
2326 | } |
2327 | ||
d62a17ae | 2328 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2329 | { |
d62a17ae | 2330 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2331 | |
d70583f7 D |
2332 | /* If configured globally, cannot remove from one bgp instance */ |
2333 | if (bm->v_update_delay) { | |
2334 | vty_out(vty, | |
2335 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2336 | return CMD_WARNING_CONFIG_FAILED; | |
2337 | } | |
d62a17ae | 2338 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2339 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2340 | |
d62a17ae | 2341 | return CMD_SUCCESS; |
f188f2c4 DS |
2342 | } |
2343 | ||
2b791107 | 2344 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2345 | { |
d70583f7 D |
2346 | /* If configured globally, no need to display per-instance value */ |
2347 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2348 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2349 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2350 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2351 | vty_out(vty, "\n"); | |
2352 | } | |
f188f2c4 DS |
2353 | } |
2354 | ||
d70583f7 D |
2355 | /* Global update-delay configuration */ |
2356 | DEFPY (bgp_global_update_delay, | |
2357 | bgp_global_update_delay_cmd, | |
2358 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2359 | BGP_STR | |
2360 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2361 | "Max delay in seconds\n" | |
2362 | "Establish wait in seconds\n") | |
2363 | { | |
2364 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2365 | } | |
f188f2c4 | 2366 | |
d70583f7 D |
2367 | /* Global update-delay deconfiguration */ |
2368 | DEFPY (no_bgp_global_update_delay, | |
2369 | no_bgp_global_update_delay_cmd, | |
2370 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2371 | NO_STR | |
2372 | BGP_STR | |
f188f2c4 | 2373 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2374 | "Max delay in seconds\n" |
2375 | "Establish wait in seconds\n") | |
f188f2c4 | 2376 | { |
d70583f7 | 2377 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2378 | } |
2379 | ||
d70583f7 D |
2380 | /* Update-delay configuration */ |
2381 | ||
2382 | DEFPY (bgp_update_delay, | |
2383 | bgp_update_delay_cmd, | |
2384 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2385 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2386 | "Max delay in seconds\n" |
2387 | "Establish wait in seconds\n") | |
f188f2c4 | 2388 | { |
d70583f7 | 2389 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2390 | } |
2391 | ||
2392 | /* Update-delay deconfiguration */ | |
d70583f7 | 2393 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2394 | no_bgp_update_delay_cmd, |
838758ac DW |
2395 | "no update-delay [(0-3600) [(1-3600)]]", |
2396 | NO_STR | |
f188f2c4 | 2397 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2398 | "Max delay in seconds\n" |
2399 | "Establish wait in seconds\n") | |
f188f2c4 | 2400 | { |
d62a17ae | 2401 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2402 | } |
2403 | ||
5e242b0d | 2404 | |
1ca2fd11 IR |
2405 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2406 | bool set) | |
cb1faec9 | 2407 | { |
1ca2fd11 IR |
2408 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2409 | ||
8fa7732f QY |
2410 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2411 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2412 | |
2413 | return CMD_SUCCESS; | |
2414 | } | |
2415 | ||
1ca2fd11 IR |
2416 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2417 | bool set) | |
555e09d4 | 2418 | { |
1ca2fd11 IR |
2419 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2420 | ||
8fa7732f QY |
2421 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2422 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2423 | |
d62a17ae | 2424 | return CMD_SUCCESS; |
cb1faec9 DS |
2425 | } |
2426 | ||
2b791107 | 2427 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2428 | { |
555e09d4 QY |
2429 | uint32_t quanta = |
2430 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2431 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2432 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2433 | } |
2434 | ||
555e09d4 QY |
2435 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2436 | { | |
2437 | uint32_t quanta = | |
2438 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2439 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2440 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2441 | } |
cb1faec9 | 2442 | |
8fa7732f QY |
2443 | /* Packet quanta configuration |
2444 | * | |
2445 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2446 | * thread. When changing these limits be careful to prevent stack overflow. | |
2447 | * | |
2448 | * Furthermore, the maximums used here should correspond to | |
2449 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2450 | */ | |
1ca2fd11 IR |
2451 | DEFPY (bgp_wpkt_quanta, |
2452 | bgp_wpkt_quanta_cmd, | |
2453 | "[no] write-quanta (1-64)$quanta", | |
2454 | NO_STR | |
2455 | "How many packets to write to peer socket per run\n" | |
2456 | "Number of packets\n") | |
2457 | { | |
2458 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2459 | } | |
cb1faec9 | 2460 | |
1ca2fd11 IR |
2461 | DEFPY (bgp_rpkt_quanta, |
2462 | bgp_rpkt_quanta_cmd, | |
2463 | "[no] read-quanta (1-10)$quanta", | |
2464 | NO_STR | |
2465 | "How many packets to read from peer socket per I/O cycle\n" | |
2466 | "Number of packets\n") | |
2467 | { | |
2468 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
555e09d4 QY |
2469 | } |
2470 | ||
2b791107 | 2471 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2472 | { |
37a333fe | 2473 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2474 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2475 | } |
2476 | ||
d1adb448 PG |
2477 | /* BGP TCP keepalive */ |
2478 | static void bgp_config_tcp_keepalive(struct vty *vty, struct bgp *bgp) | |
2479 | { | |
2480 | if (bgp->tcp_keepalive_idle) { | |
2481 | vty_out(vty, " bgp tcp-keepalive %u %u %u\n", | |
2482 | bgp->tcp_keepalive_idle, bgp->tcp_keepalive_intvl, | |
2483 | bgp->tcp_keepalive_probes); | |
2484 | } | |
2485 | } | |
4668a151 | 2486 | |
1ca2fd11 IR |
2487 | DEFUN (bgp_coalesce_time, |
2488 | bgp_coalesce_time_cmd, | |
2489 | "coalesce-time (0-4294967295)", | |
2490 | "Subgroup coalesce timer\n" | |
2491 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2492 | { |
1ca2fd11 | 2493 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 2494 | |
1ca2fd11 | 2495 | int idx = 0; |
9b01d289 | 2496 | |
1ca2fd11 | 2497 | bgp->heuristic_coalesce = false; |
9b01d289 DA |
2498 | |
2499 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
2500 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2501 | ||
1ca2fd11 | 2502 | return CMD_SUCCESS; |
3f9c7369 DS |
2503 | } |
2504 | ||
1ca2fd11 IR |
2505 | DEFUN (no_bgp_coalesce_time, |
2506 | no_bgp_coalesce_time_cmd, | |
2507 | "no coalesce-time (0-4294967295)", | |
2508 | NO_STR | |
2509 | "Subgroup coalesce timer\n" | |
2510 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2511 | { |
1ca2fd11 | 2512 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 2513 | |
1ca2fd11 IR |
2514 | bgp->heuristic_coalesce = true; |
2515 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2516 | return CMD_SUCCESS; | |
3f9c7369 DS |
2517 | } |
2518 | ||
5e242b0d | 2519 | /* Maximum-paths configuration */ |
585f1adc IR |
2520 | DEFUN (bgp_maxpaths, |
2521 | bgp_maxpaths_cmd, | |
2522 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2523 | "Forward packets over multiple paths\n" | |
2524 | "Number of paths\n") | |
5e242b0d | 2525 | { |
d62a17ae | 2526 | int idx_number = 1; |
585f1adc IR |
2527 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, |
2528 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2529 | } |
2530 | ||
d62a17ae | 2531 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2532 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2533 | "Forward packets over multiple paths\n" | |
2534 | "Number of paths\n") | |
596c17ba | 2535 | |
585f1adc IR |
2536 | DEFUN (bgp_maxpaths_ibgp, |
2537 | bgp_maxpaths_ibgp_cmd, | |
2538 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2539 | "Forward packets over multiple paths\n" | |
2540 | "iBGP-multipath\n" | |
2541 | "Number of paths\n") | |
165b5fff | 2542 | { |
d62a17ae | 2543 | int idx_number = 2; |
585f1adc IR |
2544 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2545 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2546 | } |
165b5fff | 2547 | |
d62a17ae | 2548 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2549 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2550 | "Forward packets over multiple paths\n" | |
2551 | "iBGP-multipath\n" | |
2552 | "Number of paths\n") | |
596c17ba | 2553 | |
585f1adc IR |
2554 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2555 | bgp_maxpaths_ibgp_cluster_cmd, | |
2556 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2557 | "Forward packets over multiple paths\n" | |
2558 | "iBGP-multipath\n" | |
2559 | "Number of paths\n" | |
2560 | "Match the cluster length\n") | |
5e242b0d | 2561 | { |
d62a17ae | 2562 | int idx_number = 2; |
aa53c036 DS |
2563 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2564 | argv[idx_number]->arg, true, 1); | |
165b5fff JB |
2565 | } |
2566 | ||
d62a17ae | 2567 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2568 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2569 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2570 | "Forward packets over multiple paths\n" | |
2571 | "iBGP-multipath\n" | |
2572 | "Number of paths\n" | |
2573 | "Match the cluster length\n") | |
596c17ba | 2574 | |
585f1adc IR |
2575 | DEFUN (no_bgp_maxpaths, |
2576 | no_bgp_maxpaths_cmd, | |
2577 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2578 | NO_STR | |
2579 | "Forward packets over multiple paths\n" | |
2580 | "Number of paths\n") | |
165b5fff | 2581 | { |
585f1adc | 2582 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2583 | } |
2584 | ||
d62a17ae | 2585 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2586 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2587 | "Forward packets over multiple paths\n" |
2588 | "Number of paths\n") | |
596c17ba | 2589 | |
585f1adc IR |
2590 | DEFUN (no_bgp_maxpaths_ibgp, |
2591 | no_bgp_maxpaths_ibgp_cmd, | |
2592 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2593 | NO_STR | |
2594 | "Forward packets over multiple paths\n" | |
2595 | "iBGP-multipath\n" | |
2596 | "Number of paths\n" | |
2597 | "Match the cluster length\n") | |
165b5fff | 2598 | { |
585f1adc | 2599 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2600 | } |
2601 | ||
d62a17ae | 2602 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2603 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2604 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2605 | NO_STR | |
2606 | "Forward packets over multiple paths\n" | |
2607 | "iBGP-multipath\n" | |
2608 | "Number of paths\n" | |
2609 | "Match the cluster length\n") | |
596c17ba | 2610 | |
dd65f45e DL |
2611 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2612 | afi_t afi, safi_t safi) | |
165b5fff | 2613 | { |
00908b7a | 2614 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2615 | vty_out(vty, " maximum-paths %d\n", |
2616 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2617 | } | |
165b5fff | 2618 | |
00908b7a | 2619 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2620 | vty_out(vty, " maximum-paths ibgp %d", |
2621 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
aa53c036 | 2622 | if (bgp->maxpaths[afi][safi].same_clusterlen) |
d62a17ae | 2623 | vty_out(vty, " equal-cluster-length"); |
2624 | vty_out(vty, "\n"); | |
2625 | } | |
165b5fff | 2626 | } |
6b0655a2 | 2627 | |
718e3744 | 2628 | /* BGP timers. */ |
2629 | ||
1ca2fd11 IR |
2630 | DEFUN (bgp_timers, |
2631 | bgp_timers_cmd, | |
2632 | "timers bgp (0-65535) (0-65535)", | |
2633 | "Adjust routing timers\n" | |
2634 | "BGP timers\n" | |
2635 | "Keepalive interval\n" | |
2636 | "Holdtime\n") | |
718e3744 | 2637 | { |
1ca2fd11 | 2638 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2639 | int idx_number = 2; |
2640 | int idx_number_2 = 3; | |
1ca2fd11 IR |
2641 | unsigned long keepalive = 0; |
2642 | unsigned long holdtime = 0; | |
718e3744 | 2643 | |
1ca2fd11 IR |
2644 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
2645 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 2646 | |
1ca2fd11 IR |
2647 | /* Holdtime value check. */ |
2648 | if (holdtime < 3 && holdtime != 0) { | |
2649 | vty_out(vty, | |
2650 | "%% hold time value must be either 0 or greater than 3\n"); | |
2651 | return CMD_WARNING_CONFIG_FAILED; | |
2652 | } | |
718e3744 | 2653 | |
1ca2fd11 IR |
2654 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, |
2655 | BGP_DEFAULT_DELAYOPEN); | |
718e3744 | 2656 | |
1ca2fd11 | 2657 | return CMD_SUCCESS; |
718e3744 | 2658 | } |
2659 | ||
1ca2fd11 IR |
2660 | DEFUN (no_bgp_timers, |
2661 | no_bgp_timers_cmd, | |
2662 | "no timers bgp [(0-65535) (0-65535)]", | |
2663 | NO_STR | |
2664 | "Adjust routing timers\n" | |
2665 | "BGP timers\n" | |
2666 | "Keepalive interval\n" | |
2667 | "Holdtime\n") | |
718e3744 | 2668 | { |
1ca2fd11 IR |
2669 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2670 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2671 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
ff8a8a7a | 2672 | |
1ca2fd11 | 2673 | return CMD_SUCCESS; |
718e3744 | 2674 | } |
2675 | ||
b042667a TI |
2676 | /* BGP minimum holdtime. */ |
2677 | ||
2678 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2679 | "bgp minimum-holdtime (1-65535)", | |
2680 | "BGP specific commands\n" | |
2681 | "BGP minimum holdtime\n" | |
2682 | "Seconds\n") | |
2683 | { | |
2684 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2685 | int idx_number = 2; | |
2686 | unsigned long min_holdtime; | |
2687 | ||
2688 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2689 | ||
2690 | bgp->default_min_holdtime = min_holdtime; | |
2691 | ||
2692 | return CMD_SUCCESS; | |
2693 | } | |
2694 | ||
2695 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2696 | "no bgp minimum-holdtime [(1-65535)]", | |
2697 | NO_STR | |
2698 | "BGP specific commands\n" | |
2699 | "BGP minimum holdtime\n" | |
2700 | "Seconds\n") | |
2701 | { | |
2702 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2703 | ||
2704 | bgp->default_min_holdtime = 0; | |
2705 | ||
2706 | return CMD_SUCCESS; | |
2707 | } | |
ff8a8a7a | 2708 | |
d1adb448 PG |
2709 | DEFPY(bgp_tcp_keepalive, bgp_tcp_keepalive_cmd, |
2710 | "bgp tcp-keepalive (1-65535)$idle (1-65535)$intvl (1-30)$probes", | |
2711 | BGP_STR | |
2712 | "TCP keepalive parameters\n" | |
2713 | "TCP keepalive idle time (seconds)\n" | |
2714 | "TCP keepalive interval (seconds)\n" | |
2715 | "TCP keepalive maximum probes\n") | |
2716 | { | |
2717 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2718 | ||
2719 | bgp_tcp_keepalive_set(bgp, (uint16_t)idle, (uint16_t)intvl, | |
2720 | (uint16_t)probes); | |
2721 | ||
2722 | return CMD_SUCCESS; | |
2723 | } | |
2724 | ||
2725 | DEFPY(no_bgp_tcp_keepalive, no_bgp_tcp_keepalive_cmd, | |
2726 | "no bgp tcp-keepalive [(1-65535) (1-65535) (1-30)]", | |
2727 | NO_STR | |
2728 | BGP_STR | |
2729 | "TCP keepalive parameters\n" | |
2730 | "TCP keepalive idle time (seconds)\n" | |
2731 | "TCP keepalive interval (seconds)\n" | |
2732 | "TCP keepalive maximum probes\n") | |
2733 | { | |
2734 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2735 | ||
2736 | bgp_tcp_keepalive_unset(bgp); | |
2737 | ||
2738 | return CMD_SUCCESS; | |
2739 | } | |
2740 | ||
1ca2fd11 IR |
2741 | DEFUN (bgp_client_to_client_reflection, |
2742 | bgp_client_to_client_reflection_cmd, | |
2743 | "bgp client-to-client reflection", | |
e9273987 | 2744 | BGP_STR |
1ca2fd11 IR |
2745 | "Configure client to client route reflection\n" |
2746 | "reflection of routes allowed\n") | |
718e3744 | 2747 | { |
1ca2fd11 IR |
2748 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2749 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2750 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2751 | |
1ca2fd11 | 2752 | return CMD_SUCCESS; |
718e3744 | 2753 | } |
2754 | ||
1ca2fd11 IR |
2755 | DEFUN (no_bgp_client_to_client_reflection, |
2756 | no_bgp_client_to_client_reflection_cmd, | |
2757 | "no bgp client-to-client reflection", | |
2758 | NO_STR | |
e9273987 | 2759 | BGP_STR |
1ca2fd11 IR |
2760 | "Configure client to client route reflection\n" |
2761 | "reflection of routes allowed\n") | |
718e3744 | 2762 | { |
1ca2fd11 IR |
2763 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2764 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2765 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2766 | |
1ca2fd11 | 2767 | return CMD_SUCCESS; |
718e3744 | 2768 | } |
2769 | ||
2770 | /* "bgp always-compare-med" configuration. */ | |
1ca2fd11 IR |
2771 | DEFUN (bgp_always_compare_med, |
2772 | bgp_always_compare_med_cmd, | |
2773 | "bgp always-compare-med", | |
e9273987 | 2774 | BGP_STR |
1ca2fd11 | 2775 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2776 | { |
1ca2fd11 IR |
2777 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2778 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2779 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2780 | |
1ca2fd11 | 2781 | return CMD_SUCCESS; |
718e3744 | 2782 | } |
2783 | ||
1ca2fd11 IR |
2784 | DEFUN (no_bgp_always_compare_med, |
2785 | no_bgp_always_compare_med_cmd, | |
2786 | "no bgp always-compare-med", | |
2787 | NO_STR | |
e9273987 | 2788 | BGP_STR |
1ca2fd11 | 2789 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2790 | { |
1ca2fd11 IR |
2791 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2792 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2793 | bgp_recalculate_all_bestpaths(bgp); | |
6b0655a2 | 2794 | |
1ca2fd11 | 2795 | return CMD_SUCCESS; |
2adac256 DA |
2796 | } |
2797 | ||
2adac256 | 2798 | |
1ca2fd11 IR |
2799 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, |
2800 | "bgp ebgp-requires-policy", | |
e9273987 | 2801 | BGP_STR |
1ca2fd11 | 2802 | "Require in and out policy for eBGP peers (RFC8212)\n") |
2adac256 | 2803 | { |
1ca2fd11 IR |
2804 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2805 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2806 | return CMD_SUCCESS; | |
2adac256 DA |
2807 | } |
2808 | ||
1ca2fd11 IR |
2809 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, |
2810 | "no bgp ebgp-requires-policy", | |
2811 | NO_STR | |
e9273987 | 2812 | BGP_STR |
1ca2fd11 | 2813 | "Require in and out policy for eBGP peers (RFC8212)\n") |
ff8a8a7a | 2814 | { |
1ca2fd11 IR |
2815 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2816 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2817 | return CMD_SUCCESS; | |
ff8a8a7a | 2818 | } |
9dac9fc8 | 2819 | |
1ca2fd11 IR |
2820 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, |
2821 | "bgp suppress-duplicates", | |
e9273987 | 2822 | BGP_STR |
1ca2fd11 | 2823 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2824 | { |
1ca2fd11 IR |
2825 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2826 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2827 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2828 | } |
2829 | ||
1ca2fd11 IR |
2830 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, |
2831 | "no bgp suppress-duplicates", | |
2832 | NO_STR | |
e9273987 | 2833 | BGP_STR |
1ca2fd11 | 2834 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2835 | { |
1ca2fd11 IR |
2836 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2837 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2838 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2839 | } |
2840 | ||
fb29348a DA |
2841 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2842 | "bgp reject-as-sets", | |
e9273987 | 2843 | BGP_STR |
fb29348a DA |
2844 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2845 | { | |
2846 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2847 | struct listnode *node, *nnode; | |
2848 | struct peer *peer; | |
2849 | ||
7f972cd8 | 2850 | bgp->reject_as_sets = true; |
fb29348a DA |
2851 | |
2852 | /* Reset existing BGP sessions to reject routes | |
2853 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2854 | */ | |
2855 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2856 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2857 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2858 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2859 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2860 | } | |
2861 | } | |
2862 | ||
2863 | return CMD_SUCCESS; | |
2864 | } | |
2865 | ||
2866 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2867 | "no bgp reject-as-sets", | |
2868 | NO_STR | |
e9273987 | 2869 | BGP_STR |
fb29348a DA |
2870 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2871 | { | |
2872 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2873 | struct listnode *node, *nnode; | |
2874 | struct peer *peer; | |
2875 | ||
7f972cd8 | 2876 | bgp->reject_as_sets = false; |
fb29348a DA |
2877 | |
2878 | /* Reset existing BGP sessions to reject routes | |
2879 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2880 | */ | |
2881 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2882 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2883 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2884 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2885 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2886 | } | |
2887 | } | |
2888 | ||
2889 | return CMD_SUCCESS; | |
2890 | } | |
9dac9fc8 | 2891 | |
718e3744 | 2892 | /* "bgp deterministic-med" configuration. */ |
1ca2fd11 | 2893 | DEFUN (bgp_deterministic_med, |
718e3744 | 2894 | bgp_deterministic_med_cmd, |
2895 | "bgp deterministic-med", | |
e9273987 | 2896 | BGP_STR |
718e3744 | 2897 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2898 | { | |
1ca2fd11 IR |
2899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2900 | ||
2901 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2902 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2903 | bgp_recalculate_all_bestpaths(bgp); | |
2904 | } | |
7aafcaca | 2905 | |
1ca2fd11 | 2906 | return CMD_SUCCESS; |
718e3744 | 2907 | } |
2908 | ||
1ca2fd11 | 2909 | DEFUN (no_bgp_deterministic_med, |
718e3744 | 2910 | no_bgp_deterministic_med_cmd, |
2911 | "no bgp deterministic-med", | |
2912 | NO_STR | |
e9273987 | 2913 | BGP_STR |
718e3744 | 2914 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2915 | { | |
1ca2fd11 IR |
2916 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2917 | int bestpath_per_as_used; | |
2918 | afi_t afi; | |
2919 | safi_t safi; | |
2920 | struct peer *peer; | |
2921 | struct listnode *node, *nnode; | |
2922 | ||
2923 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2924 | bestpath_per_as_used = 0; | |
2925 | ||
2926 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2927 | FOREACH_AFI_SAFI (afi, safi) | |
2928 | if (bgp_addpath_dmed_required( | |
2929 | peer->addpath_type[afi][safi])) { | |
2930 | bestpath_per_as_used = 1; | |
2931 | break; | |
2932 | } | |
2933 | ||
2934 | if (bestpath_per_as_used) | |
2935 | break; | |
2936 | } | |
2937 | ||
2938 | if (bestpath_per_as_used) { | |
2939 | vty_out(vty, | |
2940 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2941 | return CMD_WARNING_CONFIG_FAILED; | |
2942 | } else { | |
2943 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2944 | bgp_recalculate_all_bestpaths(bgp); | |
2945 | } | |
2946 | } | |
d62a17ae | 2947 | |
1ca2fd11 | 2948 | return CMD_SUCCESS; |
718e3744 | 2949 | } |
538621f2 | 2950 | |
055679e9 | 2951 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2952 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2953 | bgp_graceful_restart_cmd, |
2954 | "bgp graceful-restart", | |
e9273987 | 2955 | BGP_STR |
2ba1fe69 | 2956 | GR_CMD |
055679e9 | 2957 | ) |
538621f2 | 2958 | { |
055679e9 | 2959 | int ret = BGP_GR_FAILURE; |
2960 | ||
2961 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2962 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2963 | |
d62a17ae | 2964 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2965 | |
2966 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2967 | ||
36235319 QY |
2968 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2969 | ret); | |
5cce3f05 | 2970 | |
055679e9 | 2971 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2972 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2973 | vty_out(vty, |
2974 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2975 | return bgp_vty_return(vty, ret); |
538621f2 | 2976 | } |
2977 | ||
2978 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2979 | no_bgp_graceful_restart_cmd, |
2980 | "no bgp graceful-restart", | |
2981 | NO_STR | |
e9273987 | 2982 | BGP_STR |
2ba1fe69 | 2983 | NO_GR_CMD |
055679e9 | 2984 | ) |
538621f2 | 2985 | { |
d62a17ae | 2986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2987 | |
2988 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2989 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2990 | |
2991 | int ret = BGP_GR_FAILURE; | |
2992 | ||
2993 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2994 | ||
36235319 QY |
2995 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2996 | ret); | |
5cce3f05 | 2997 | |
055679e9 | 2998 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2999 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 3000 | vty_out(vty, |
3001 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 3002 | |
3003 | return bgp_vty_return(vty, ret); | |
538621f2 | 3004 | } |
3005 | ||
93406d87 | 3006 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 3007 | bgp_graceful_restart_stalepath_time_cmd, |
3008 | "bgp graceful-restart stalepath-time (1-4095)", | |
e9273987 | 3009 | BGP_STR |
2ba1fe69 | 3010 | "Graceful restart capability parameters\n" |
3011 | "Set the max time to hold onto restarting peer's stale paths\n" | |
3012 | "Delay value (seconds)\n") | |
93406d87 | 3013 | { |
d62a17ae | 3014 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3015 | int idx_number = 3; | |
d7c0a89a | 3016 | uint32_t stalepath; |
93406d87 | 3017 | |
d62a17ae | 3018 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
3019 | bgp->stalepath_time = stalepath; | |
3020 | return CMD_SUCCESS; | |
93406d87 | 3021 | } |
3022 | ||
eb6f1b41 | 3023 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 3024 | bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 3025 | "bgp graceful-restart restart-time (0-4095)", |
e9273987 | 3026 | BGP_STR |
2ba1fe69 | 3027 | "Graceful restart capability parameters\n" |
3028 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
3029 | "Delay value (seconds)\n") | |
eb6f1b41 | 3030 | { |
d62a17ae | 3031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3032 | int idx_number = 3; | |
d7c0a89a | 3033 | uint32_t restart; |
eb6f1b41 | 3034 | |
d62a17ae | 3035 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
3036 | bgp->restart_time = restart; | |
3037 | return CMD_SUCCESS; | |
eb6f1b41 PG |
3038 | } |
3039 | ||
cfd47646 | 3040 | DEFUN (bgp_graceful_restart_select_defer_time, |
3041 | bgp_graceful_restart_select_defer_time_cmd, | |
3042 | "bgp graceful-restart select-defer-time (0-3600)", | |
e9273987 | 3043 | BGP_STR |
cfd47646 | 3044 | "Graceful restart capability parameters\n" |
3045 | "Set the time to defer the BGP route selection after restart\n" | |
3046 | "Delay value (seconds, 0 - disable)\n") | |
3047 | { | |
3048 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3049 | int idx_number = 3; | |
3050 | uint32_t defer_time; | |
3051 | ||
3052 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3053 | bgp->select_defer_time = defer_time; | |
3054 | if (defer_time == 0) | |
892fedb6 | 3055 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 3056 | else |
892fedb6 | 3057 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 3058 | |
3059 | return CMD_SUCCESS; | |
3060 | } | |
3061 | ||
93406d87 | 3062 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 3063 | no_bgp_graceful_restart_stalepath_time_cmd, |
3064 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
3065 | NO_STR | |
e9273987 | 3066 | BGP_STR |
2ba1fe69 | 3067 | "Graceful restart capability parameters\n" |
3068 | "Set the max time to hold onto restarting peer's stale paths\n" | |
3069 | "Delay value (seconds)\n") | |
93406d87 | 3070 | { |
d62a17ae | 3071 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 3072 | |
d62a17ae | 3073 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
3074 | return CMD_SUCCESS; | |
93406d87 | 3075 | } |
3076 | ||
eb6f1b41 | 3077 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 3078 | no_bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 3079 | "no bgp graceful-restart restart-time [(0-4095)]", |
2ba1fe69 | 3080 | NO_STR |
e9273987 | 3081 | BGP_STR |
2ba1fe69 | 3082 | "Graceful restart capability parameters\n" |
3083 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
3084 | "Delay value (seconds)\n") | |
eb6f1b41 | 3085 | { |
d62a17ae | 3086 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 3087 | |
d62a17ae | 3088 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
3089 | return CMD_SUCCESS; | |
eb6f1b41 PG |
3090 | } |
3091 | ||
cfd47646 | 3092 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
3093 | no_bgp_graceful_restart_select_defer_time_cmd, | |
3094 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
3095 | NO_STR | |
e9273987 | 3096 | BGP_STR |
cfd47646 | 3097 | "Graceful restart capability parameters\n" |
3098 | "Set the time to defer the BGP route selection after restart\n" | |
3099 | "Delay value (seconds)\n") | |
3100 | { | |
3101 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3102 | ||
3103 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 3104 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 3105 | |
3106 | return CMD_SUCCESS; | |
3107 | } | |
3108 | ||
43fc21b3 | 3109 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 3110 | bgp_graceful_restart_preserve_fw_cmd, |
3111 | "bgp graceful-restart preserve-fw-state", | |
e9273987 | 3112 | BGP_STR |
2ba1fe69 | 3113 | "Graceful restart capability parameters\n" |
3114 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 3115 | { |
d62a17ae | 3116 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3117 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 3118 | return CMD_SUCCESS; |
43fc21b3 JC |
3119 | } |
3120 | ||
3121 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 3122 | no_bgp_graceful_restart_preserve_fw_cmd, |
3123 | "no bgp graceful-restart preserve-fw-state", | |
3124 | NO_STR | |
e9273987 | 3125 | BGP_STR |
2ba1fe69 | 3126 | "Graceful restart capability parameters\n" |
3127 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 3128 | { |
d62a17ae | 3129 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3130 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 3131 | return CMD_SUCCESS; |
43fc21b3 JC |
3132 | } |
3133 | ||
f2ca5c5b DA |
3134 | DEFPY (bgp_graceful_restart_notification, |
3135 | bgp_graceful_restart_notification_cmd, | |
3136 | "[no$no] bgp graceful-restart notification", | |
3137 | NO_STR | |
3138 | BGP_STR | |
3139 | "Graceful restart capability parameters\n" | |
3140 | "Indicate Graceful Restart support for BGP NOTIFICATION messages\n") | |
3141 | { | |
3142 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3143 | ||
3144 | if (no) | |
3145 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
3146 | else | |
3147 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
3148 | ||
3149 | return CMD_SUCCESS; | |
3150 | } | |
3151 | ||
1ae314be DA |
3152 | DEFPY (bgp_administrative_reset, |
3153 | bgp_administrative_reset_cmd, | |
3154 | "[no$no] bgp hard-administrative-reset", | |
3155 | NO_STR | |
3156 | BGP_STR | |
3157 | "Send Hard Reset CEASE Notification for 'Administrative Reset'\n") | |
3158 | { | |
3159 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3160 | ||
3161 | if (no) | |
3162 | UNSET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
3163 | else | |
3164 | SET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
3165 | ||
3166 | return CMD_SUCCESS; | |
3167 | } | |
3168 | ||
055679e9 | 3169 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 3170 | bgp_graceful_restart_disable_cmd, |
3171 | "bgp graceful-restart-disable", | |
e9273987 | 3172 | BGP_STR |
2ba1fe69 | 3173 | GR_DISABLE) |
055679e9 | 3174 | { |
3175 | int ret = BGP_GR_FAILURE; | |
3176 | ||
3177 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3178 | zlog_debug( | |
2ba1fe69 | 3179 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 3180 | |
055679e9 | 3181 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3182 | ||
3183 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
3184 | ||
dc95985f | 3185 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
3186 | bgp->peer, ret); | |
5cce3f05 | 3187 | |
055679e9 | 3188 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3189 | zlog_debug( | |
2ba1fe69 | 3190 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3191 | vty_out(vty, |
3192 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
3193 | ||
055679e9 | 3194 | return bgp_vty_return(vty, ret); |
3195 | } | |
3196 | ||
3197 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 3198 | no_bgp_graceful_restart_disable_cmd, |
3199 | "no bgp graceful-restart-disable", | |
3200 | NO_STR | |
e9273987 | 3201 | BGP_STR |
2ba1fe69 | 3202 | NO_GR_DISABLE |
055679e9 | 3203 | ) |
3204 | { | |
3205 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3206 | ||
3207 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3208 | zlog_debug( | |
2ba1fe69 | 3209 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 3210 | |
3211 | int ret = BGP_GR_FAILURE; | |
3212 | ||
3213 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
3214 | ||
36235319 QY |
3215 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
3216 | ret); | |
5cce3f05 | 3217 | |
055679e9 | 3218 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3219 | zlog_debug( | |
2ba1fe69 | 3220 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3221 | vty_out(vty, |
3222 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 3223 | |
3224 | return bgp_vty_return(vty, ret); | |
3225 | } | |
3226 | ||
3227 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 3228 | bgp_neighbor_graceful_restart_set_cmd, |
3229 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3230 | NEIGHBOR_STR | |
3231 | NEIGHBOR_ADDR_STR2 | |
3232 | GR_NEIGHBOR_CMD | |
055679e9 | 3233 | ) |
3234 | { | |
3235 | int idx_peer = 1; | |
3236 | struct peer *peer; | |
3237 | int ret = BGP_GR_FAILURE; | |
3238 | ||
dc95985f | 3239 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3240 | ||
055679e9 | 3241 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3242 | zlog_debug( | |
2ba1fe69 | 3243 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 3244 | |
055679e9 | 3245 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3246 | if (!peer) | |
3247 | return CMD_WARNING_CONFIG_FAILED; | |
3248 | ||
3249 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
3250 | ||
dc95985f | 3251 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3252 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3253 | |
3254 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3255 | zlog_debug( | |
2ba1fe69 | 3256 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3257 | vty_out(vty, |
3258 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3259 | |
3260 | return bgp_vty_return(vty, ret); | |
3261 | } | |
3262 | ||
3263 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 3264 | no_bgp_neighbor_graceful_restart_set_cmd, |
3265 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3266 | NO_STR | |
3267 | NEIGHBOR_STR | |
3268 | NEIGHBOR_ADDR_STR2 | |
3269 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 3270 | ) |
3271 | { | |
3272 | int idx_peer = 2; | |
3273 | int ret = BGP_GR_FAILURE; | |
3274 | struct peer *peer; | |
3275 | ||
dc95985f | 3276 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3277 | ||
055679e9 | 3278 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3279 | if (!peer) | |
3280 | return CMD_WARNING_CONFIG_FAILED; | |
3281 | ||
3282 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3283 | zlog_debug( | |
2ba1fe69 | 3284 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 3285 | |
3286 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
3287 | ||
dc95985f | 3288 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3289 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3290 | |
3291 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3292 | zlog_debug( | |
2ba1fe69 | 3293 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3294 | vty_out(vty, |
3295 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3296 | |
3297 | return bgp_vty_return(vty, ret); | |
3298 | } | |
3299 | ||
3300 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 3301 | bgp_neighbor_graceful_restart_helper_set_cmd, |
3302 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3303 | NEIGHBOR_STR | |
3304 | NEIGHBOR_ADDR_STR2 | |
3305 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3306 | ) |
3307 | { | |
3308 | int idx_peer = 1; | |
3309 | struct peer *peer; | |
3310 | int ret = BGP_GR_FAILURE; | |
3311 | ||
dc95985f | 3312 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3313 | ||
055679e9 | 3314 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3315 | zlog_debug( | |
2ba1fe69 | 3316 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 3317 | |
055679e9 | 3318 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3319 | ||
055679e9 | 3320 | if (!peer) |
3321 | return CMD_WARNING_CONFIG_FAILED; | |
3322 | ||
3323 | ||
3324 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 3325 | |
dc95985f | 3326 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3327 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 3328 | |
055679e9 | 3329 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3330 | zlog_debug( | |
2ba1fe69 | 3331 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3332 | vty_out(vty, |
3333 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3334 | |
3335 | return bgp_vty_return(vty, ret); | |
3336 | } | |
3337 | ||
3338 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 3339 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
3340 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3341 | NO_STR | |
3342 | NEIGHBOR_STR | |
3343 | NEIGHBOR_ADDR_STR2 | |
3344 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3345 | ) |
3346 | { | |
3347 | int idx_peer = 2; | |
3348 | int ret = BGP_GR_FAILURE; | |
3349 | struct peer *peer; | |
3350 | ||
dc95985f | 3351 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3352 | ||
055679e9 | 3353 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3354 | if (!peer) | |
3355 | return CMD_WARNING_CONFIG_FAILED; | |
3356 | ||
3357 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3358 | zlog_debug( | |
2ba1fe69 | 3359 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3360 | |
36235319 | 3361 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3362 | |
dc95985f | 3363 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3364 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3365 | |
3366 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3367 | zlog_debug( | |
2ba1fe69 | 3368 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3369 | vty_out(vty, |
3370 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3371 | |
3372 | return bgp_vty_return(vty, ret); | |
3373 | } | |
3374 | ||
3375 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3376 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3377 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3378 | NEIGHBOR_STR | |
3379 | NEIGHBOR_ADDR_STR2 | |
3380 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3381 | ) |
3382 | { | |
3383 | int idx_peer = 1; | |
3384 | struct peer *peer; | |
3385 | int ret = BGP_GR_FAILURE; | |
3386 | ||
dc95985f | 3387 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3388 | ||
055679e9 | 3389 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3390 | zlog_debug( | |
2ba1fe69 | 3391 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3392 | |
3393 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3394 | if (!peer) | |
3395 | return CMD_WARNING_CONFIG_FAILED; | |
3396 | ||
36235319 | 3397 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3398 | |
3399 | if (peer->bgp->t_startup) | |
3400 | bgp_peer_gr_flags_update(peer); | |
3401 | ||
dc95985f | 3402 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3403 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3404 | ||
055679e9 | 3405 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3406 | zlog_debug( | |
2ba1fe69 | 3407 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3408 | vty_out(vty, |
3409 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3410 | |
3411 | return bgp_vty_return(vty, ret); | |
3412 | } | |
3413 | ||
3414 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3415 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3416 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3417 | NO_STR | |
3418 | NEIGHBOR_STR | |
3419 | NEIGHBOR_ADDR_STR2 | |
3420 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3421 | ) |
3422 | { | |
3423 | int idx_peer = 2; | |
3424 | int ret = BGP_GR_FAILURE; | |
3425 | struct peer *peer; | |
3426 | ||
dc95985f | 3427 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3428 | ||
055679e9 | 3429 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3430 | if (!peer) | |
3431 | return CMD_WARNING_CONFIG_FAILED; | |
3432 | ||
3433 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3434 | zlog_debug( | |
2ba1fe69 | 3435 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3436 | |
3437 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3438 | ||
dc95985f | 3439 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3440 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3441 | |
3442 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3443 | zlog_debug( | |
2ba1fe69 | 3444 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3445 | vty_out(vty, |
3446 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3447 | |
3448 | return bgp_vty_return(vty, ret); | |
3449 | } | |
3450 | ||
4f770cf1 DA |
3451 | DEFPY (neighbor_graceful_shutdown, |
3452 | neighbor_graceful_shutdown_cmd, | |
3453 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor graceful-shutdown", | |
3454 | NO_STR | |
3455 | NEIGHBOR_STR | |
3456 | NEIGHBOR_ADDR_STR2 | |
3457 | "Graceful shutdown\n") | |
3458 | { | |
3459 | afi_t afi; | |
3460 | safi_t safi; | |
3461 | struct peer *peer; | |
3462 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3463 | int ret; | |
3464 | ||
3465 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
3466 | if (!peer) | |
3467 | return CMD_WARNING_CONFIG_FAILED; | |
3468 | ||
3469 | if (no) | |
3470 | ret = peer_flag_unset_vty(vty, neighbor, | |
3471 | PEER_FLAG_GRACEFUL_SHUTDOWN); | |
3472 | else | |
3473 | ret = peer_flag_set_vty(vty, neighbor, | |
3474 | PEER_FLAG_GRACEFUL_SHUTDOWN); | |
3475 | ||
3476 | FOREACH_AFI_SAFI (afi, safi) { | |
3477 | if (!peer->afc[afi][safi]) | |
3478 | continue; | |
3479 | ||
3480 | bgp_clear(vty, bgp, afi, safi, clear_peer, BGP_CLEAR_SOFT_IN, | |
3481 | neighbor); | |
3482 | } | |
3483 | ||
3484 | return ret; | |
3485 | } | |
3486 | ||
d6e3c15b | 3487 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3488 | bgp_graceful_restart_disable_eor_cmd, | |
3489 | "bgp graceful-restart disable-eor", | |
e9273987 | 3490 | BGP_STR |
d6e3c15b | 3491 | "Graceful restart configuration parameters\n" |
3492 | "Disable EOR Check\n") | |
3493 | { | |
3494 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3495 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3496 | |
d6e3c15b | 3497 | return CMD_SUCCESS; |
3498 | } | |
3499 | ||
3500 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3501 | no_bgp_graceful_restart_disable_eor_cmd, | |
3502 | "no bgp graceful-restart disable-eor", | |
3503 | NO_STR | |
e9273987 | 3504 | BGP_STR |
d6e3c15b | 3505 | "Graceful restart configuration parameters\n" |
3506 | "Disable EOR Check\n") | |
3507 | { | |
3508 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3509 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3510 | |
3511 | return CMD_SUCCESS; | |
3512 | } | |
3513 | ||
3514 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3515 | bgp_graceful_restart_rib_stale_time_cmd, | |
3516 | "bgp graceful-restart rib-stale-time (1-3600)", | |
e9273987 | 3517 | BGP_STR |
dc95985f | 3518 | "Graceful restart configuration parameters\n" |
3519 | "Specify the stale route removal timer in rib\n" | |
3520 | "Delay value (seconds)\n") | |
3521 | { | |
3522 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3523 | int idx_number = 3; | |
3524 | uint32_t stale_time; | |
3525 | ||
3526 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3527 | bgp->rib_stale_time = stale_time; | |
3528 | /* Send the stale timer update message to RIB */ | |
3529 | if (bgp_zebra_stale_timer_update(bgp)) | |
3530 | return CMD_WARNING; | |
3531 | ||
3532 | return CMD_SUCCESS; | |
3533 | } | |
3534 | ||
3535 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3536 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3537 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3538 | NO_STR | |
e9273987 | 3539 | BGP_STR |
dc95985f | 3540 | "Graceful restart configuration parameters\n" |
3541 | "Specify the stale route removal timer in rib\n" | |
3542 | "Delay value (seconds)\n") | |
3543 | { | |
3544 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3545 | ||
3546 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3547 | /* Send the stale timer update message to RIB */ | |
3548 | if (bgp_zebra_stale_timer_update(bgp)) | |
3549 | return CMD_WARNING; | |
3550 | ||
d6e3c15b | 3551 | return CMD_SUCCESS; |
3552 | } | |
3553 | ||
8606be87 | 3554 | DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd, |
5970204c | 3555 | "bgp long-lived-graceful-restart stale-time (1-16777215)", |
7f8a9a24 | 3556 | BGP_STR |
8606be87 DA |
3557 | "Enable Long-lived Graceful Restart\n" |
3558 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3559 | "Stale time value (seconds)\n") | |
3560 | { | |
3561 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3562 | ||
3563 | uint32_t llgr_stale_time; | |
3564 | ||
3565 | llgr_stale_time = strtoul(argv[3]->arg, NULL, 10); | |
3566 | bgp->llgr_stale_time = llgr_stale_time; | |
3567 | ||
3568 | return CMD_SUCCESS; | |
3569 | } | |
3570 | ||
3571 | DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd, | |
5970204c | 3572 | "no bgp long-lived-graceful-restart stale-time [(1-16777215)]", |
8606be87 DA |
3573 | NO_STR BGP_STR |
3574 | "Enable Long-lived Graceful Restart\n" | |
3575 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3576 | "Stale time value (seconds)\n") | |
3577 | { | |
3578 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3579 | ||
3580 | bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; | |
3581 | ||
3582 | return CMD_SUCCESS; | |
3583 | } | |
3584 | ||
1ca2fd11 IR |
3585 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3586 | struct bgp *bgp) | |
05bd726c | 3587 | { |
3588 | bgp_static_redo_import_check(bgp); | |
3589 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3590 | bgp_clear_star_soft_out(vty, bgp->name); |
3591 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3592 | } |
3593 | ||
3594 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3595 | { | |
3596 | struct listnode *node, *nnode; | |
3597 | struct bgp *bgp; | |
3598 | bool vrf_cfg = false; | |
3599 | ||
3600 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3601 | return CMD_SUCCESS; | |
3602 | ||
3603 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3604 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3605 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3606 | vty_out(vty, | |
3607 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3608 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3609 | VRF_DEFAULT_NAME : bgp->name); | |
3610 | vrf_cfg = true; | |
3611 | } | |
3612 | } | |
3613 | ||
3614 | if (vrf_cfg) { | |
3615 | vty_out(vty, | |
3616 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3617 | return CMD_WARNING; | |
3618 | } | |
3619 | ||
3620 | /* Set flag globally */ | |
3621 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3622 | ||
3623 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3624 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3625 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3626 | |
3627 | return CMD_SUCCESS; | |
3628 | } | |
3629 | ||
3630 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3631 | { | |
3632 | struct listnode *node, *nnode; | |
3633 | struct bgp *bgp; | |
3634 | ||
3635 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3636 | return CMD_SUCCESS; | |
3637 | ||
3638 | /* Unset flag globally */ | |
3639 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3640 | ||
3641 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3642 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3643 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3644 | |
3645 | return CMD_SUCCESS; | |
3646 | } | |
3647 | ||
7f323236 DW |
3648 | /* "bgp graceful-shutdown" configuration */ |
3649 | DEFUN (bgp_graceful_shutdown, | |
3650 | bgp_graceful_shutdown_cmd, | |
3651 | "bgp graceful-shutdown", | |
3652 | BGP_STR | |
3653 | "Graceful shutdown parameters\n") | |
3654 | { | |
05bd726c | 3655 | if (vty->node == CONFIG_NODE) |
3656 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3657 | ||
1ca2fd11 | 3658 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3659 | |
1ca2fd11 IR |
3660 | /* if configured globally, per-instance config is not allowed */ |
3661 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3662 | vty_out(vty, | |
3663 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3664 | return CMD_WARNING_CONFIG_FAILED; | |
3665 | } | |
3666 | ||
3667 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3668 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3669 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3670 | } | |
3671 | ||
3672 | return CMD_SUCCESS; | |
7f323236 DW |
3673 | } |
3674 | ||
1ca2fd11 | 3675 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3676 | no_bgp_graceful_shutdown_cmd, |
3677 | "no bgp graceful-shutdown", | |
3678 | NO_STR | |
3679 | BGP_STR | |
3680 | "Graceful shutdown parameters\n") | |
3681 | { | |
05bd726c | 3682 | if (vty->node == CONFIG_NODE) |
3683 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3684 | ||
1ca2fd11 | 3685 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3686 | |
1ca2fd11 IR |
3687 | /* If configured globally, cannot remove from one bgp instance */ |
3688 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3689 | vty_out(vty, | |
3690 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3691 | return CMD_WARNING_CONFIG_FAILED; | |
3692 | } | |
7f323236 | 3693 | |
1ca2fd11 IR |
3694 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3695 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3696 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3697 | } | |
3698 | ||
3699 | return CMD_SUCCESS; | |
7f323236 DW |
3700 | } |
3701 | ||
718e3744 | 3702 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3703 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3704 | bgp_fast_external_failover_cmd, |
3705 | "bgp fast-external-failover", | |
3706 | BGP_STR | |
3707 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3708 | { | |
1ca2fd11 IR |
3709 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3710 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3711 | return CMD_SUCCESS; | |
718e3744 | 3712 | } |
3713 | ||
1ca2fd11 | 3714 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3715 | no_bgp_fast_external_failover_cmd, |
3716 | "no bgp fast-external-failover", | |
3717 | NO_STR | |
3718 | BGP_STR | |
3719 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3720 | { | |
1ca2fd11 IR |
3721 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3722 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3723 | return CMD_SUCCESS; | |
718e3744 | 3724 | } |
6b0655a2 | 3725 | |
97a52c82 DA |
3726 | DEFPY (bgp_bestpath_aigp, |
3727 | bgp_bestpath_aigp_cmd, | |
3728 | "[no$no] bgp bestpath aigp", | |
3729 | NO_STR | |
3730 | BGP_STR | |
3731 | "Change the default bestpath selection\n" | |
3732 | "Evaluate the AIGP attribute during the best path selection process\n") | |
3733 | { | |
3734 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3735 | ||
3736 | if (no) | |
3737 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP); | |
3738 | else | |
3739 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP); | |
3740 | ||
3741 | bgp_recalculate_all_bestpaths(bgp); | |
3742 | ||
3743 | return CMD_SUCCESS; | |
3744 | } | |
3745 | ||
718e3744 | 3746 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3747 | DEFUN (bgp_bestpath_compare_router_id, |
3748 | bgp_bestpath_compare_router_id_cmd, | |
3749 | "bgp bestpath compare-routerid", | |
e9273987 | 3750 | BGP_STR |
1ca2fd11 IR |
3751 | "Change the default bestpath selection\n" |
3752 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3753 | { |
1ca2fd11 IR |
3754 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3755 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3756 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3757 | |
1ca2fd11 | 3758 | return CMD_SUCCESS; |
718e3744 | 3759 | } |
3760 | ||
1ca2fd11 IR |
3761 | DEFUN (no_bgp_bestpath_compare_router_id, |
3762 | no_bgp_bestpath_compare_router_id_cmd, | |
3763 | "no bgp bestpath compare-routerid", | |
3764 | NO_STR | |
e9273987 | 3765 | BGP_STR |
1ca2fd11 IR |
3766 | "Change the default bestpath selection\n" |
3767 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3768 | { |
1ca2fd11 IR |
3769 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3770 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3771 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3772 | |
1ca2fd11 | 3773 | return CMD_SUCCESS; |
718e3744 | 3774 | } |
6b0655a2 | 3775 | |
718e3744 | 3776 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3777 | DEFUN (bgp_bestpath_aspath_ignore, |
3778 | bgp_bestpath_aspath_ignore_cmd, | |
3779 | "bgp bestpath as-path ignore", | |
e9273987 | 3780 | BGP_STR |
1ca2fd11 IR |
3781 | "Change the default bestpath selection\n" |
3782 | "AS-path attribute\n" | |
3783 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3784 | { |
1ca2fd11 IR |
3785 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3786 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3787 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3788 | |
1ca2fd11 | 3789 | return CMD_SUCCESS; |
718e3744 | 3790 | } |
3791 | ||
1ca2fd11 IR |
3792 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3793 | no_bgp_bestpath_aspath_ignore_cmd, | |
3794 | "no bgp bestpath as-path ignore", | |
3795 | NO_STR | |
e9273987 | 3796 | BGP_STR |
1ca2fd11 IR |
3797 | "Change the default bestpath selection\n" |
3798 | "AS-path attribute\n" | |
3799 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3800 | { |
1ca2fd11 IR |
3801 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3802 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3803 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3804 | |
1ca2fd11 | 3805 | return CMD_SUCCESS; |
718e3744 | 3806 | } |
6b0655a2 | 3807 | |
6811845b | 3808 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3809 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3810 | bgp_bestpath_aspath_confed_cmd, |
3811 | "bgp bestpath as-path confed", | |
e9273987 | 3812 | BGP_STR |
6811845b | 3813 | "Change the default bestpath selection\n" |
3814 | "AS-path attribute\n" | |
3815 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3816 | { | |
1ca2fd11 IR |
3817 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3818 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3819 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3820 | |
1ca2fd11 | 3821 | return CMD_SUCCESS; |
6811845b | 3822 | } |
3823 | ||
1ca2fd11 | 3824 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3825 | no_bgp_bestpath_aspath_confed_cmd, |
3826 | "no bgp bestpath as-path confed", | |
3827 | NO_STR | |
e9273987 | 3828 | BGP_STR |
6811845b | 3829 | "Change the default bestpath selection\n" |
3830 | "AS-path attribute\n" | |
3831 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3832 | { | |
1ca2fd11 IR |
3833 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3834 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3835 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3836 | |
1ca2fd11 | 3837 | return CMD_SUCCESS; |
6811845b | 3838 | } |
6b0655a2 | 3839 | |
2fdd455c | 3840 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3841 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3842 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3843 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3844 | BGP_STR |
16fc1eec DS |
3845 | "Change the default bestpath selection\n" |
3846 | "AS-path attribute\n" | |
3847 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3848 | "Generate an AS_SET\n" |
16fc1eec DS |
3849 | "Do not generate an AS_SET\n") |
3850 | { | |
1ca2fd11 | 3851 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3852 | int idx = 0; |
1ca2fd11 | 3853 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3854 | |
1ca2fd11 IR |
3855 | /* no-as-set is now the default behavior so we can silently |
3856 | * ignore it */ | |
d62a17ae | 3857 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3858 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3859 | else |
1ca2fd11 | 3860 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3861 | |
1ca2fd11 IR |
3862 | bgp_recalculate_all_bestpaths(bgp); |
3863 | ||
3864 | return CMD_SUCCESS; | |
16fc1eec DS |
3865 | } |
3866 | ||
1ca2fd11 | 3867 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3868 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3869 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3870 | NO_STR |
e9273987 | 3871 | BGP_STR |
16fc1eec DS |
3872 | "Change the default bestpath selection\n" |
3873 | "AS-path attribute\n" | |
3874 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3875 | "Generate an AS_SET\n" |
16fc1eec DS |
3876 | "Do not generate an AS_SET\n") |
3877 | { | |
1ca2fd11 IR |
3878 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3879 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3880 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3881 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3882 | |
1ca2fd11 | 3883 | return CMD_SUCCESS; |
2fdd455c | 3884 | } |
6b0655a2 | 3885 | |
ee88563a JM |
3886 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3887 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3888 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3889 | "bgp bestpath peer-type multipath-relax", | |
3890 | BGP_STR | |
3891 | "Change the default bestpath selection\n" | |
3892 | "Peer type\n" | |
3893 | "Allow load sharing across routes learned from different peer types\n") | |
3894 | { | |
3895 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3896 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3897 | bgp_recalculate_all_bestpaths(bgp); | |
3898 | ||
3899 | return CMD_SUCCESS; | |
3900 | } | |
3901 | ||
3902 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3903 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3904 | "no bgp bestpath peer-type multipath-relax", | |
3905 | NO_STR BGP_STR | |
3906 | "Change the default bestpath selection\n" | |
3907 | "Peer type\n" | |
3908 | "Allow load sharing across routes learned from different peer types\n") | |
3909 | { | |
3910 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3911 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3912 | bgp_recalculate_all_bestpaths(bgp); | |
3913 | ||
3914 | return CMD_SUCCESS; | |
3915 | } | |
3916 | ||
848973c7 | 3917 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3918 | DEFUN (bgp_log_neighbor_changes, |
3919 | bgp_log_neighbor_changes_cmd, | |
3920 | "bgp log-neighbor-changes", | |
e9273987 | 3921 | BGP_STR |
1ca2fd11 | 3922 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3923 | { |
1ca2fd11 IR |
3924 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3925 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3926 | return CMD_SUCCESS; | |
848973c7 | 3927 | } |
3928 | ||
1ca2fd11 IR |
3929 | DEFUN (no_bgp_log_neighbor_changes, |
3930 | no_bgp_log_neighbor_changes_cmd, | |
3931 | "no bgp log-neighbor-changes", | |
3932 | NO_STR | |
e9273987 | 3933 | BGP_STR |
1ca2fd11 | 3934 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3935 | { |
1ca2fd11 IR |
3936 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3937 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3938 | return CMD_SUCCESS; | |
848973c7 | 3939 | } |
6b0655a2 | 3940 | |
718e3744 | 3941 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3942 | DEFUN (bgp_bestpath_med, |
718e3744 | 3943 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3944 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3945 | BGP_STR |
718e3744 | 3946 | "Change the default bestpath selection\n" |
3947 | "MED attribute\n" | |
3948 | "Compare MED among confederation paths\n" | |
838758ac DW |
3949 | "Treat missing MED as the least preferred one\n" |
3950 | "Treat missing MED as the least preferred one\n" | |
3951 | "Compare MED among confederation paths\n") | |
718e3744 | 3952 | { |
1ca2fd11 | 3953 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3954 | |
1ca2fd11 | 3955 | int idx = 0; |
d62a17ae | 3956 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3957 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3958 | idx = 0; |
3959 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3960 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3961 | |
1ca2fd11 | 3962 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3963 | |
1ca2fd11 | 3964 | return CMD_SUCCESS; |
718e3744 | 3965 | } |
3966 | ||
1ca2fd11 | 3967 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3968 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3969 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3970 | NO_STR |
e9273987 | 3971 | BGP_STR |
718e3744 | 3972 | "Change the default bestpath selection\n" |
3973 | "MED attribute\n" | |
3974 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3975 | "Treat missing MED as the least preferred one\n" |
3976 | "Treat missing MED as the least preferred one\n" | |
3977 | "Compare MED among confederation paths\n") | |
718e3744 | 3978 | { |
1ca2fd11 | 3979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3980 | |
1ca2fd11 | 3981 | int idx = 0; |
d62a17ae | 3982 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3983 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3984 | idx = 0; |
3985 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3986 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3987 | ||
3988 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3989 | |
1ca2fd11 | 3990 | return CMD_SUCCESS; |
718e3744 | 3991 | } |
3992 | ||
f7e1c681 | 3993 | /* "bgp bestpath bandwidth" configuration. */ |
3994 | DEFPY (bgp_bestpath_bw, | |
3995 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3996 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3997 | BGP_STR |
f7e1c681 | 3998 | "Change the default bestpath selection\n" |
3999 | "Link Bandwidth attribute\n" | |
4000 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
4001 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
4002 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
4003 | { | |
4004 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4005 | afi_t afi; | |
4006 | safi_t safi; | |
4007 | ||
ad36d216 DS |
4008 | if (!bw_cfg) { |
4009 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
4010 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 4011 | } |
ad36d216 DS |
4012 | if (!strcmp(bw_cfg, "ignore")) |
4013 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
4014 | else if (!strcmp(bw_cfg, "skip-missing")) | |
4015 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
4016 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
4017 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
4018 | else | |
4019 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 4020 | |
4021 | /* This config is used in route install, so redo that. */ | |
4022 | FOREACH_AFI_SAFI (afi, safi) { | |
4023 | if (!bgp_fibupd_safi(safi)) | |
4024 | continue; | |
4025 | bgp_zebra_announce_table(bgp, afi, safi); | |
4026 | } | |
4027 | ||
4028 | return CMD_SUCCESS; | |
4029 | } | |
4030 | ||
ad36d216 DS |
4031 | DEFPY (no_bgp_bestpath_bw, |
4032 | no_bgp_bestpath_bw_cmd, | |
4033 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
4034 | NO_STR | |
e9273987 | 4035 | BGP_STR |
ad36d216 DS |
4036 | "Change the default bestpath selection\n" |
4037 | "Link Bandwidth attribute\n" | |
4038 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
4039 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
4040 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
4041 | { | |
4042 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4043 | afi_t afi; | |
4044 | safi_t safi; | |
4045 | ||
4046 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
4047 | ||
4048 | /* This config is used in route install, so redo that. */ | |
4049 | FOREACH_AFI_SAFI (afi, safi) { | |
4050 | if (!bgp_fibupd_safi(safi)) | |
4051 | continue; | |
4052 | bgp_zebra_announce_table(bgp, afi, safi); | |
4053 | } | |
4054 | return CMD_SUCCESS; | |
4055 | } | |
4056 | ||
b16bcbba | 4057 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
4058 | "[no] bgp default <ipv4-unicast|" |
4059 | "ipv4-multicast|" | |
4060 | "ipv4-vpn|" | |
4061 | "ipv4-labeled-unicast|" | |
4062 | "ipv4-flowspec|" | |
4063 | "ipv6-unicast|" | |
4064 | "ipv6-multicast|" | |
4065 | "ipv6-vpn|" | |
4066 | "ipv6-labeled-unicast|" | |
4067 | "ipv6-flowspec|" | |
4068 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 4069 | NO_STR |
e9273987 | 4070 | BGP_STR |
e84c59af | 4071 | "Configure BGP defaults\n" |
b16bcbba | 4072 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
4073 | "Activate ipv4-multicast for a peer by default\n" |
4074 | "Activate ipv4-vpn for a peer by default\n" | |
4075 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
4076 | "Activate ipv4-flowspec for a peer by default\n" | |
4077 | "Activate ipv6-unicast for a peer by default\n" | |
4078 | "Activate ipv6-multicast for a peer by default\n" | |
4079 | "Activate ipv6-vpn for a peer by default\n" | |
4080 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
4081 | "Activate ipv6-flowspec for a peer by default\n" | |
4082 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
4083 | { |
4084 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
4085 | char afi_safi_str[strlen(afi_safi) + 1]; |
4086 | char *afi_safi_str_tok; | |
e84c59af | 4087 | |
b16bcbba TA |
4088 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
4089 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
4090 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
4091 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 4092 | safi_t safi; |
e84c59af | 4093 | |
d880a643 DS |
4094 | /* |
4095 | * Impossible situation but making coverity happy | |
4096 | */ | |
4097 | assert(afi != AFI_MAX); | |
4098 | ||
38d11af5 TA |
4099 | if (strmatch(safi_str, "labeled")) |
4100 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
4101 | else | |
4102 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba | 4103 | |
f609bcd6 | 4104 | assert(safi != SAFI_MAX); |
b16bcbba TA |
4105 | if (no) |
4106 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
4107 | else { |
4108 | if ((safi == SAFI_LABELED_UNICAST | |
4109 | && bgp->default_af[afi][SAFI_UNICAST]) | |
4110 | || (safi == SAFI_UNICAST | |
4111 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
4112 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
4113 | else | |
4114 | bgp->default_af[afi][safi] = true; | |
4115 | } | |
718e3744 | 4116 | |
d62a17ae | 4117 | return CMD_SUCCESS; |
718e3744 | 4118 | } |
6b0655a2 | 4119 | |
04b6bdc0 | 4120 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 4121 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
4122 | bgp_default_show_hostname_cmd, |
4123 | "bgp default show-hostname", | |
e9273987 | 4124 | BGP_STR |
04b6bdc0 | 4125 | "Configure BGP defaults\n" |
0437e105 | 4126 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 4127 | { |
1ca2fd11 IR |
4128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4129 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
4130 | return CMD_SUCCESS; | |
ff8a8a7a CS |
4131 | } |
4132 | ||
1ca2fd11 IR |
4133 | DEFUN (no_bgp_default_show_hostname, |
4134 | no_bgp_default_show_hostname_cmd, | |
4135 | "no bgp default show-hostname", | |
4136 | NO_STR | |
e9273987 | 4137 | BGP_STR |
1ca2fd11 IR |
4138 | "Configure BGP defaults\n" |
4139 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 4140 | { |
1ca2fd11 IR |
4141 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4142 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
4143 | return CMD_SUCCESS; | |
04b6bdc0 DW |
4144 | } |
4145 | ||
aef999a2 | 4146 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
4147 | DEFUN (bgp_default_show_nexthop_hostname, |
4148 | bgp_default_show_nexthop_hostname_cmd, | |
4149 | "bgp default show-nexthop-hostname", | |
e9273987 | 4150 | BGP_STR |
1d80f243 IR |
4151 | "Configure BGP defaults\n" |
4152 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 4153 | { |
1ca2fd11 IR |
4154 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4155 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
4156 | return CMD_SUCCESS; | |
aef999a2 DA |
4157 | } |
4158 | ||
4159 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
4160 | no_bgp_default_show_nexthop_hostname_cmd, | |
4161 | "no bgp default show-nexthop-hostname", | |
4162 | NO_STR | |
e9273987 | 4163 | BGP_STR |
aef999a2 DA |
4164 | "Configure BGP defaults\n" |
4165 | "Show hostname for nexthop in certain command outputs\n") | |
4166 | { | |
1ca2fd11 IR |
4167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4168 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
4169 | return CMD_SUCCESS; | |
aef999a2 DA |
4170 | } |
4171 | ||
8233ef81 | 4172 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
4173 | DEFUN (bgp_network_import_check, |
4174 | bgp_network_import_check_cmd, | |
4175 | "bgp network import-check", | |
e9273987 | 4176 | BGP_STR |
1ca2fd11 IR |
4177 | "BGP network command\n" |
4178 | "Check BGP network route exists in IGP\n") | |
718e3744 | 4179 | { |
1ca2fd11 IR |
4180 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4181 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
4182 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
4183 | bgp_static_redo_import_check(bgp); | |
4184 | } | |
078430f6 | 4185 | |
1ca2fd11 | 4186 | return CMD_SUCCESS; |
718e3744 | 4187 | } |
4188 | ||
d62a17ae | 4189 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
4190 | "bgp network import-check exact", | |
e9273987 | 4191 | BGP_STR |
d62a17ae | 4192 | "BGP network command\n" |
4193 | "Check BGP network route exists in IGP\n" | |
4194 | "Match route precisely\n") | |
8233ef81 | 4195 | |
1ca2fd11 IR |
4196 | DEFUN (no_bgp_network_import_check, |
4197 | no_bgp_network_import_check_cmd, | |
4198 | "no bgp network import-check", | |
4199 | NO_STR | |
e9273987 | 4200 | BGP_STR |
1ca2fd11 IR |
4201 | "BGP network command\n" |
4202 | "Check BGP network route exists in IGP\n") | |
718e3744 | 4203 | { |
1ca2fd11 IR |
4204 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4205 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
4206 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
4207 | bgp_static_redo_import_check(bgp); | |
4208 | } | |
6b0655a2 | 4209 | |
1ca2fd11 | 4210 | return CMD_SUCCESS; |
ff8a8a7a | 4211 | } |
718e3744 | 4212 | |
1ca2fd11 IR |
4213 | DEFUN (bgp_default_local_preference, |
4214 | bgp_default_local_preference_cmd, | |
4215 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 4216 | BGP_STR |
1ca2fd11 IR |
4217 | "Configure BGP defaults\n" |
4218 | "local preference (higher=more preferred)\n" | |
4219 | "Configure default local preference value\n") | |
ff8a8a7a | 4220 | { |
1ca2fd11 | 4221 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 4222 | int idx_number = 3; |
1ca2fd11 | 4223 | uint32_t local_pref; |
718e3744 | 4224 | |
1ca2fd11 | 4225 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 4226 | |
1ca2fd11 IR |
4227 | bgp_default_local_preference_set(bgp, local_pref); |
4228 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 4229 | |
1ca2fd11 | 4230 | return CMD_SUCCESS; |
718e3744 | 4231 | } |
4232 | ||
1ca2fd11 IR |
4233 | DEFUN (no_bgp_default_local_preference, |
4234 | no_bgp_default_local_preference_cmd, | |
4235 | "no bgp default local-preference [(0-4294967295)]", | |
4236 | NO_STR | |
e9273987 | 4237 | BGP_STR |
1ca2fd11 IR |
4238 | "Configure BGP defaults\n" |
4239 | "local preference (higher=more preferred)\n" | |
4240 | "Configure default local preference value\n") | |
ff8a8a7a | 4241 | { |
1ca2fd11 IR |
4242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4243 | bgp_default_local_preference_unset(bgp); | |
4244 | bgp_clear_star_soft_in(vty, bgp->name); | |
4245 | ||
4246 | return CMD_SUCCESS; | |
ff8a8a7a | 4247 | } |
6b0655a2 | 4248 | |
ff8a8a7a | 4249 | |
1ca2fd11 IR |
4250 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
4251 | bgp_default_subgroup_pkt_queue_max_cmd, | |
4252 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 4253 | BGP_STR |
1ca2fd11 IR |
4254 | "Configure BGP defaults\n" |
4255 | "subgroup-pkt-queue-max\n" | |
4256 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 4257 | { |
1ca2fd11 | 4258 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4259 | int idx_number = 3; |
1ca2fd11 | 4260 | uint32_t max_size; |
3f9c7369 | 4261 | |
1ca2fd11 | 4262 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 4263 | |
1ca2fd11 | 4264 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 4265 | |
1ca2fd11 | 4266 | return CMD_SUCCESS; |
8bd9d948 DS |
4267 | } |
4268 | ||
1ca2fd11 IR |
4269 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
4270 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
4271 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
4272 | NO_STR | |
e9273987 | 4273 | BGP_STR |
1ca2fd11 IR |
4274 | "Configure BGP defaults\n" |
4275 | "subgroup-pkt-queue-max\n" | |
4276 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 4277 | { |
1ca2fd11 IR |
4278 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4279 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
4280 | return CMD_SUCCESS; | |
ff8a8a7a | 4281 | } |
813d4307 | 4282 | |
8bd9d948 | 4283 | |
1ca2fd11 IR |
4284 | DEFUN (bgp_rr_allow_outbound_policy, |
4285 | bgp_rr_allow_outbound_policy_cmd, | |
4286 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 4287 | BGP_STR |
1ca2fd11 IR |
4288 | "Allow modifications made by out route-map\n" |
4289 | "on ibgp neighbors\n") | |
ff8a8a7a | 4290 | { |
1ca2fd11 | 4291 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 4292 | |
1ca2fd11 IR |
4293 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4294 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4295 | update_group_announce_rrclients(bgp); | |
4296 | bgp_clear_star_soft_out(vty, bgp->name); | |
4297 | } | |
8bd9d948 | 4298 | |
1ca2fd11 IR |
4299 | return CMD_SUCCESS; |
4300 | } | |
ff8a8a7a | 4301 | |
1ca2fd11 IR |
4302 | DEFUN (no_bgp_rr_allow_outbound_policy, |
4303 | no_bgp_rr_allow_outbound_policy_cmd, | |
4304 | "no bgp route-reflector allow-outbound-policy", | |
4305 | NO_STR | |
e9273987 | 4306 | BGP_STR |
1ca2fd11 IR |
4307 | "Allow modifications made by out route-map\n" |
4308 | "on ibgp neighbors\n") | |
8bd9d948 | 4309 | { |
1ca2fd11 | 4310 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 4311 | |
1ca2fd11 IR |
4312 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4313 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4314 | update_group_announce_rrclients(bgp); | |
4315 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 4316 | } |
8bd9d948 | 4317 | |
1ca2fd11 | 4318 | return CMD_SUCCESS; |
8bd9d948 DS |
4319 | } |
4320 | ||
1ca2fd11 IR |
4321 | DEFUN (bgp_listen_limit, |
4322 | bgp_listen_limit_cmd, | |
4323 | "bgp listen limit (1-65535)", | |
e9273987 | 4324 | BGP_STR |
1ca2fd11 IR |
4325 | "BGP Dynamic Neighbors listen commands\n" |
4326 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4327 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4328 | { |
1ca2fd11 | 4329 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4330 | int idx_number = 3; |
1ca2fd11 IR |
4331 | int listen_limit; |
4332 | ||
4333 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 4334 | |
1ca2fd11 | 4335 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 4336 | |
1ca2fd11 | 4337 | return CMD_SUCCESS; |
f14e6fdb DS |
4338 | } |
4339 | ||
1ca2fd11 IR |
4340 | DEFUN (no_bgp_listen_limit, |
4341 | no_bgp_listen_limit_cmd, | |
4342 | "no bgp listen limit [(1-65535)]", | |
4343 | NO_STR | |
e9273987 | 4344 | BGP_STR |
1ca2fd11 IR |
4345 | "BGP Dynamic Neighbors listen commands\n" |
4346 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4347 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4348 | { |
1ca2fd11 IR |
4349 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4350 | bgp_listen_limit_unset(bgp); | |
4351 | return CMD_SUCCESS; | |
f14e6fdb DS |
4352 | } |
4353 | ||
4354 | ||
20eb8864 | 4355 | /* |
4356 | * Check if this listen range is already configured. Check for exact | |
4357 | * match or overlap based on input. | |
4358 | */ | |
d62a17ae | 4359 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
4360 | struct prefix *range, int exact) | |
4361 | { | |
4362 | struct listnode *node, *nnode; | |
4363 | struct listnode *node1, *nnode1; | |
4364 | struct peer_group *group; | |
4365 | struct prefix *lr; | |
4366 | afi_t afi; | |
4367 | int match; | |
4368 | ||
4369 | afi = family2afi(range->family); | |
4370 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4371 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
4372 | lr)) { | |
4373 | if (exact) | |
4374 | match = prefix_same(range, lr); | |
4375 | else | |
4376 | match = (prefix_match(range, lr) | |
4377 | || prefix_match(lr, range)); | |
4378 | if (match) | |
4379 | return group; | |
4380 | } | |
4381 | } | |
4382 | ||
4383 | return NULL; | |
20eb8864 | 4384 | } |
4385 | ||
f14e6fdb DS |
4386 | DEFUN (bgp_listen_range, |
4387 | bgp_listen_range_cmd, | |
d7b9898c | 4388 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 4389 | BGP_STR |
d7fa34c1 QY |
4390 | "Configure BGP dynamic neighbors listen range\n" |
4391 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
4392 | NEIGHBOR_ADDR_STR |
4393 | "Member of the peer-group\n" | |
4394 | "Peer-group name\n") | |
f14e6fdb | 4395 | { |
d62a17ae | 4396 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4397 | struct prefix range; | |
4398 | struct peer_group *group, *existing_group; | |
4399 | afi_t afi; | |
4400 | int ret; | |
4401 | int idx = 0; | |
4402 | ||
4403 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4404 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4405 | char *prefix = argv[idx]->arg; | |
d7b9898c | 4406 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4407 | char *peergroup = argv[idx]->arg; |
4408 | ||
4409 | /* Convert IP prefix string to struct prefix. */ | |
4410 | ret = str2prefix(prefix, &range); | |
4411 | if (!ret) { | |
4412 | vty_out(vty, "%% Malformed listen range\n"); | |
4413 | return CMD_WARNING_CONFIG_FAILED; | |
4414 | } | |
4415 | ||
4416 | afi = family2afi(range.family); | |
4417 | ||
4418 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4419 | vty_out(vty, | |
4420 | "%% Malformed listen range (link-local address)\n"); | |
4421 | return CMD_WARNING_CONFIG_FAILED; | |
4422 | } | |
4423 | ||
4424 | apply_mask(&range); | |
4425 | ||
4426 | /* Check if same listen range is already configured. */ | |
4427 | existing_group = listen_range_exists(bgp, &range, 1); | |
4428 | if (existing_group) { | |
4429 | if (strcmp(existing_group->name, peergroup) == 0) | |
4430 | return CMD_SUCCESS; | |
4431 | else { | |
4432 | vty_out(vty, | |
4433 | "%% Same listen range is attached to peer-group %s\n", | |
4434 | existing_group->name); | |
4435 | return CMD_WARNING_CONFIG_FAILED; | |
4436 | } | |
4437 | } | |
4438 | ||
4439 | /* Check if an overlapping listen range exists. */ | |
4440 | if (listen_range_exists(bgp, &range, 0)) { | |
4441 | vty_out(vty, | |
4442 | "%% Listen range overlaps with existing listen range\n"); | |
4443 | return CMD_WARNING_CONFIG_FAILED; | |
4444 | } | |
4445 | ||
4446 | group = peer_group_lookup(bgp, peergroup); | |
4447 | if (!group) { | |
4448 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4449 | return CMD_WARNING_CONFIG_FAILED; | |
4450 | } | |
4451 | ||
4452 | ret = peer_group_listen_range_add(group, &range); | |
4453 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4454 | } |
4455 | ||
4456 | DEFUN (no_bgp_listen_range, | |
4457 | no_bgp_listen_range_cmd, | |
d7b9898c | 4458 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4459 | NO_STR |
e9273987 | 4460 | BGP_STR |
d7fa34c1 QY |
4461 | "Unconfigure BGP dynamic neighbors listen range\n" |
4462 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4463 | NEIGHBOR_ADDR_STR | |
4464 | "Member of the peer-group\n" | |
4465 | "Peer-group name\n") | |
f14e6fdb | 4466 | { |
d62a17ae | 4467 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4468 | struct prefix range; | |
4469 | struct peer_group *group; | |
4470 | afi_t afi; | |
4471 | int ret; | |
4472 | int idx = 0; | |
4473 | ||
4474 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4475 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4476 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4477 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4478 | char *peergroup = argv[idx]->arg; |
4479 | ||
4480 | /* Convert IP prefix string to struct prefix. */ | |
4481 | ret = str2prefix(prefix, &range); | |
4482 | if (!ret) { | |
4483 | vty_out(vty, "%% Malformed listen range\n"); | |
4484 | return CMD_WARNING_CONFIG_FAILED; | |
4485 | } | |
4486 | ||
4487 | afi = family2afi(range.family); | |
4488 | ||
4489 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4490 | vty_out(vty, | |
4491 | "%% Malformed listen range (link-local address)\n"); | |
4492 | return CMD_WARNING_CONFIG_FAILED; | |
4493 | } | |
4494 | ||
4495 | apply_mask(&range); | |
4496 | ||
4497 | group = peer_group_lookup(bgp, peergroup); | |
4498 | if (!group) { | |
4499 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4500 | return CMD_WARNING_CONFIG_FAILED; | |
4501 | } | |
4502 | ||
4503 | ret = peer_group_listen_range_del(group, &range); | |
4504 | return bgp_vty_return(vty, ret); | |
4505 | } | |
4506 | ||
2b791107 | 4507 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4508 | { |
4509 | struct peer_group *group; | |
4510 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4511 | struct prefix *range; | |
4512 | afi_t afi; | |
d62a17ae | 4513 | |
4514 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4515 | vty_out(vty, " bgp listen limit %d\n", | |
4516 | bgp->dynamic_neighbors_limit); | |
4517 | ||
4518 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4519 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4520 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4521 | nrnode, range)) { | |
d62a17ae | 4522 | vty_out(vty, |
2dbe669b DA |
4523 | " bgp listen range %pFX peer-group %s\n", |
4524 | range, group->name); | |
d62a17ae | 4525 | } |
4526 | } | |
4527 | } | |
f14e6fdb DS |
4528 | } |
4529 | ||
4530 | ||
1ca2fd11 IR |
4531 | DEFUN (bgp_disable_connected_route_check, |
4532 | bgp_disable_connected_route_check_cmd, | |
4533 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4534 | BGP_STR |
1ca2fd11 | 4535 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4536 | { |
1ca2fd11 IR |
4537 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4538 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4539 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4540 | |
1ca2fd11 | 4541 | return CMD_SUCCESS; |
907f92c8 DS |
4542 | } |
4543 | ||
1ca2fd11 IR |
4544 | DEFUN (no_bgp_disable_connected_route_check, |
4545 | no_bgp_disable_connected_route_check_cmd, | |
4546 | "no bgp disable-ebgp-connected-route-check", | |
4547 | NO_STR | |
e9273987 | 4548 | BGP_STR |
1ca2fd11 | 4549 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4550 | { |
1ca2fd11 IR |
4551 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4552 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4553 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4554 | |
1ca2fd11 | 4555 | return CMD_SUCCESS; |
d62a17ae | 4556 | } |
4557 | ||
4558 | ||
28c6e247 IR |
4559 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4560 | const char *as_str) | |
4561 | { | |
4562 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4563 | int ret; | |
4564 | as_t as; | |
4565 | int as_type = AS_SPECIFIED; | |
4566 | union sockunion su; | |
4567 | ||
4568 | if (as_str[0] == 'i') { | |
4569 | as = 0; | |
4570 | as_type = AS_INTERNAL; | |
4571 | } else if (as_str[0] == 'e') { | |
4572 | as = 0; | |
4573 | as_type = AS_EXTERNAL; | |
8079a413 PG |
4574 | } else if (!asn_str2asn(as_str, &as)) |
4575 | as_type = AS_UNSPECIFIED; | |
28c6e247 | 4576 | |
8079a413 PG |
4577 | if (as_type == AS_UNSPECIFIED) { |
4578 | vty_out(vty, "%% Invalid peer AS: %s\n", as_str); | |
4579 | return CMD_WARNING_CONFIG_FAILED; | |
4580 | } | |
28c6e247 IR |
4581 | /* If peer is peer group or interface peer, call proper function. */ |
4582 | ret = str2sockunion(peer_str, &su); | |
4583 | if (ret < 0) { | |
4584 | struct peer *peer; | |
4585 | ||
4586 | /* Check if existing interface peer */ | |
4587 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4588 | ||
de76ed8a | 4589 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, as_str); |
28c6e247 IR |
4590 | |
4591 | /* if not interface peer, check peer-group settings */ | |
4592 | if (ret < 0 && !peer) { | |
de76ed8a PG |
4593 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type, |
4594 | as_str); | |
28c6e247 IR |
4595 | if (ret < 0) { |
4596 | vty_out(vty, | |
4597 | "%% Create the peer-group or interface first\n"); | |
4598 | return CMD_WARNING_CONFIG_FAILED; | |
4599 | } | |
4600 | return CMD_SUCCESS; | |
4601 | } | |
4602 | } else { | |
4603 | if (peer_address_self_check(bgp, &su)) { | |
4604 | vty_out(vty, | |
4605 | "%% Can not configure the local system as neighbor\n"); | |
4606 | return CMD_WARNING_CONFIG_FAILED; | |
4607 | } | |
de76ed8a | 4608 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, as_str); |
28c6e247 IR |
4609 | } |
4610 | ||
28c6e247 IR |
4611 | return bgp_vty_return(vty, ret); |
4612 | } | |
4613 | ||
1ca2fd11 IR |
4614 | DEFUN (bgp_default_shutdown, |
4615 | bgp_default_shutdown_cmd, | |
4616 | "[no] bgp default shutdown", | |
4617 | NO_STR | |
4618 | BGP_STR | |
4619 | "Configure BGP defaults\n" | |
4620 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4621 | { |
1ca2fd11 IR |
4622 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4623 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4624 | return CMD_SUCCESS; | |
f26845f9 QY |
4625 | } |
4626 | ||
736b68f3 DS |
4627 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4628 | BGP_STR | |
9ddf4b81 | 4629 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4630 | "Add a shutdown message (RFC 8203)\n" |
4631 | "Shutdown message\n") | |
9cf59432 | 4632 | { |
736b68f3 | 4633 | char *msgstr = NULL; |
8389c83a | 4634 | |
9cf59432 DS |
4635 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4636 | ||
8389c83a | 4637 | if (argc > 3) |
f80e35b6 | 4638 | msgstr = argv_concat(argv, argc, 3); |
8389c83a | 4639 | |
b776f48c DA |
4640 | if (msgstr && strlen(msgstr) > BGP_ADMIN_SHUTDOWN_MSG_LEN) { |
4641 | vty_out(vty, "%% Shutdown message size exceeded %d\n", | |
4642 | BGP_ADMIN_SHUTDOWN_MSG_LEN); | |
4643 | return CMD_WARNING_CONFIG_FAILED; | |
4644 | } | |
4645 | ||
8389c83a DS |
4646 | bgp_shutdown_enable(bgp, msgstr); |
4647 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4648 | |
4649 | return CMD_SUCCESS; | |
4650 | } | |
4651 | ||
736b68f3 | 4652 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4653 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4654 | { |
4655 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4656 | ||
4657 | bgp_shutdown_enable(bgp, NULL); | |
4658 | ||
4659 | return CMD_SUCCESS; | |
4660 | } | |
8389c83a | 4661 | |
736b68f3 | 4662 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4663 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4664 | { |
4665 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4666 | ||
4667 | bgp_shutdown_disable(bgp); | |
4668 | ||
4669 | return CMD_SUCCESS; | |
4670 | } | |
4671 | ||
9ddf4b81 | 4672 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4673 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4674 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4675 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4676 | |
28c6e247 IR |
4677 | DEFUN (neighbor_remote_as, |
4678 | neighbor_remote_as_cmd, | |
8079a413 | 4679 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <ASNUM|internal|external>", |
28c6e247 IR |
4680 | NEIGHBOR_STR |
4681 | NEIGHBOR_ADDR_STR2 | |
4682 | "Specify a BGP neighbor\n" | |
4683 | AS_STR | |
4684 | "Internal BGP peer\n" | |
4685 | "External BGP peer\n") | |
718e3744 | 4686 | { |
d62a17ae | 4687 | int idx_peer = 1; |
4688 | int idx_remote_as = 3; | |
28c6e247 IR |
4689 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4690 | argv[idx_remote_as]->arg); | |
d62a17ae | 4691 | } |
8666265e DS |
4692 | |
4693 | DEFPY (bgp_allow_martian, | |
4694 | bgp_allow_martian_cmd, | |
4695 | "[no]$no bgp allow-martian-nexthop", | |
4696 | NO_STR | |
4697 | BGP_STR | |
4698 | "Allow Martian nexthops to be received in the NLRI from a peer\n") | |
4699 | { | |
4700 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4701 | ||
4702 | if (no) | |
4703 | bgp->allow_martian = false; | |
4704 | else | |
4705 | bgp->allow_martian = true; | |
4706 | ||
4707 | return CMD_SUCCESS; | |
4708 | } | |
4709 | ||
f852eb98 PG |
4710 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4711 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4712 | * when nexthop becomes unreachable | |
4713 | */ | |
4714 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4715 | BGP_STR "Fast convergence for bgp sessions\n") | |
4716 | { | |
4717 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4718 | bgp->fast_convergence = true; | |
4719 | ||
4720 | return CMD_SUCCESS; | |
4721 | } | |
4722 | ||
4723 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4724 | "no bgp fast-convergence", | |
4725 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4726 | { | |
4727 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4728 | bgp->fast_convergence = false; | |
4729 | ||
4730 | return CMD_SUCCESS; | |
4731 | } | |
d62a17ae | 4732 | |
28c6e247 IR |
4733 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4734 | int v6only, | |
4735 | const char *peer_group_name, | |
4736 | const char *as_str) | |
d62a17ae | 4737 | { |
28c6e247 IR |
4738 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4739 | as_t as = 0; | |
4740 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4741 | struct peer *peer; |
4742 | struct peer_group *group; | |
4743 | int ret = 0; | |
d62a17ae | 4744 | |
4745 | group = peer_group_lookup(bgp, conf_if); | |
4746 | ||
4747 | if (group) { | |
28c6e247 IR |
4748 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4749 | return CMD_WARNING_CONFIG_FAILED; | |
4750 | } | |
4751 | ||
4752 | if (as_str) { | |
4753 | if (as_str[0] == 'i') { | |
4754 | as_type = AS_INTERNAL; | |
4755 | } else if (as_str[0] == 'e') { | |
4756 | as_type = AS_EXTERNAL; | |
4757 | } else { | |
4758 | /* Get AS number. */ | |
8079a413 PG |
4759 | if (asn_str2asn(as_str, &as)) |
4760 | as_type = AS_SPECIFIED; | |
28c6e247 | 4761 | } |
d62a17ae | 4762 | } |
4763 | ||
4764 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4765 | if (peer) { | |
28c6e247 | 4766 | if (as_str) |
de76ed8a PG |
4767 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
4768 | as_str); | |
d62a17ae | 4769 | } else { |
e84c59af | 4770 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
de76ed8a | 4771 | NULL, true, as_str); |
d62a17ae | 4772 | |
4773 | if (!peer) { | |
28c6e247 IR |
4774 | vty_out(vty, "%% BGP failed to create peer\n"); |
4775 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4776 | } |
4777 | ||
4778 | if (v6only) | |
527de3dc | 4779 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4780 | |
4781 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4782 | * this | |
4783 | * any unnumbered peer in order to not worry about run-time | |
4784 | * transitions | |
4785 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4786 | * address | |
4787 | * gets deleted later etc.) | |
4788 | */ | |
4789 | if (peer->ifp) | |
4790 | bgp_zebra_initiate_radv(bgp, peer); | |
4791 | } | |
4792 | ||
4793 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4794 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4795 | if (v6only) | |
527de3dc | 4796 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4797 | else |
527de3dc | 4798 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4799 | |
4800 | /* v6only flag changed. Reset bgp seesion */ | |
4801 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4802 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4803 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4804 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4805 | } else | |
4806 | bgp_session_reset(peer); | |
4807 | } | |
4808 | ||
9fb964de PM |
4809 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4810 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4811 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4812 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4813 | } |
d62a17ae | 4814 | |
4815 | if (peer_group_name) { | |
4816 | group = peer_group_lookup(bgp, peer_group_name); | |
4817 | if (!group) { | |
28c6e247 IR |
4818 | vty_out(vty, "%% Configure the peer-group first\n"); |
4819 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4820 | } |
4821 | ||
8395c1f8 | 4822 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4823 | } |
4824 | ||
28c6e247 | 4825 | return bgp_vty_return(vty, ret); |
a80beece DS |
4826 | } |
4827 | ||
28c6e247 IR |
4828 | DEFUN (neighbor_interface_config, |
4829 | neighbor_interface_config_cmd, | |
4830 | "neighbor WORD interface [peer-group PGNAME]", | |
4831 | NEIGHBOR_STR | |
4832 | "Interface name or neighbor tag\n" | |
4833 | "Enable BGP on interface\n" | |
4834 | "Member of the peer-group\n" | |
4835 | "Peer-group name\n") | |
4c48cf63 | 4836 | { |
d62a17ae | 4837 | int idx_word = 1; |
4838 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4839 | |
d62a17ae | 4840 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4841 | return peer_conf_interface_get( |
4842 | vty, argv[idx_word]->arg, 0, | |
4843 | argv[idx_peer_group_word]->arg, NULL); | |
4844 | else | |
4845 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4846 | NULL, NULL); | |
4c48cf63 DW |
4847 | } |
4848 | ||
28c6e247 IR |
4849 | DEFUN (neighbor_interface_config_v6only, |
4850 | neighbor_interface_config_v6only_cmd, | |
4851 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4852 | NEIGHBOR_STR | |
4853 | "Interface name or neighbor tag\n" | |
4854 | "Enable BGP on interface\n" | |
4855 | "Enable BGP with v6 link-local only\n" | |
4856 | "Member of the peer-group\n" | |
4857 | "Peer-group name\n") | |
4c48cf63 | 4858 | { |
d62a17ae | 4859 | int idx_word = 1; |
4860 | int idx_peer_group_word = 5; | |
31500417 | 4861 | |
d62a17ae | 4862 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4863 | return peer_conf_interface_get( |
4864 | vty, argv[idx_word]->arg, 1, | |
4865 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4866 | |
28c6e247 | 4867 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4868 | } |
4869 | ||
a80beece | 4870 | |
28c6e247 IR |
4871 | DEFUN (neighbor_interface_config_remote_as, |
4872 | neighbor_interface_config_remote_as_cmd, | |
8079a413 | 4873 | "neighbor WORD interface remote-as <ASNUM|internal|external>", |
28c6e247 IR |
4874 | NEIGHBOR_STR |
4875 | "Interface name or neighbor tag\n" | |
4876 | "Enable BGP on interface\n" | |
4877 | "Specify a BGP neighbor\n" | |
4878 | AS_STR | |
4879 | "Internal BGP peer\n" | |
4880 | "External BGP peer\n") | |
b3a39dc5 | 4881 | { |
d62a17ae | 4882 | int idx_word = 1; |
4883 | int idx_remote_as = 4; | |
28c6e247 IR |
4884 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4885 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4886 | } |
4887 | ||
28c6e247 IR |
4888 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4889 | neighbor_interface_v6only_config_remote_as_cmd, | |
8079a413 | 4890 | "neighbor WORD interface v6only remote-as <ASNUM|internal|external>", |
28c6e247 IR |
4891 | NEIGHBOR_STR |
4892 | "Interface name or neighbor tag\n" | |
4893 | "Enable BGP with v6 link-local only\n" | |
4894 | "Enable BGP on interface\n" | |
4895 | "Specify a BGP neighbor\n" | |
4896 | AS_STR | |
4897 | "Internal BGP peer\n" | |
4898 | "External BGP peer\n") | |
b3a39dc5 | 4899 | { |
d62a17ae | 4900 | int idx_word = 1; |
4901 | int idx_remote_as = 5; | |
28c6e247 IR |
4902 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4903 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4904 | } |
4905 | ||
28c6e247 IR |
4906 | DEFUN (neighbor_peer_group, |
4907 | neighbor_peer_group_cmd, | |
4908 | "neighbor WORD peer-group", | |
4909 | NEIGHBOR_STR | |
4910 | "Interface name or neighbor tag\n" | |
4911 | "Configure peer-group\n") | |
718e3744 | 4912 | { |
28c6e247 | 4913 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4914 | int idx_word = 1; |
28c6e247 IR |
4915 | struct peer *peer; |
4916 | struct peer_group *group; | |
718e3744 | 4917 | |
28c6e247 IR |
4918 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4919 | if (peer) { | |
4920 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4921 | return CMD_WARNING_CONFIG_FAILED; | |
4922 | } | |
718e3744 | 4923 | |
28c6e247 IR |
4924 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4925 | if (!group) { | |
4926 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4927 | return CMD_WARNING_CONFIG_FAILED; | |
4928 | } | |
718e3744 | 4929 | |
28c6e247 | 4930 | return CMD_SUCCESS; |
718e3744 | 4931 | } |
4932 | ||
1d80f243 IR |
4933 | DEFUN (no_neighbor, |
4934 | no_neighbor_cmd, | |
4935 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4936 | NO_STR | |
4937 | NEIGHBOR_STR | |
4938 | NEIGHBOR_ADDR_STR2 | |
4939 | "Specify a BGP neighbor\n" | |
4940 | AS_STR | |
4941 | "Internal BGP peer\n" | |
4942 | "External BGP peer\n") | |
718e3744 | 4943 | { |
28c6e247 | 4944 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4945 | int idx_peer = 2; |
28c6e247 | 4946 | int ret; |
d62a17ae | 4947 | union sockunion su; |
28c6e247 IR |
4948 | struct peer_group *group; |
4949 | struct peer *peer; | |
4950 | struct peer *other; | |
d62a17ae | 4951 | |
28c6e247 IR |
4952 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4953 | if (ret < 0) { | |
4954 | /* look up for neighbor by interface name config. */ | |
4955 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4956 | if (peer) { | |
4957 | /* Request zebra to terminate IPv6 RAs on this | |
4958 | * interface. */ | |
4959 | if (peer->ifp) | |
4960 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4961 | peer_notify_unconfig(peer); | |
4962 | peer_delete(peer); | |
4963 | return CMD_SUCCESS; | |
d62a17ae | 4964 | } |
28c6e247 IR |
4965 | |
4966 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4967 | if (group) { | |
4968 | peer_group_notify_unconfig(group); | |
4969 | peer_group_delete(group); | |
4e2786df | 4970 | } else { |
28c6e247 | 4971 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4972 | return CMD_WARNING_CONFIG_FAILED; |
4973 | } | |
28c6e247 IR |
4974 | } else { |
4975 | peer = peer_lookup(bgp, &su); | |
4976 | if (peer) { | |
4977 | if (peer_dynamic_neighbor(peer)) { | |
4978 | vty_out(vty, | |
4979 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4980 | return CMD_WARNING_CONFIG_FAILED; | |
4981 | } | |
d62a17ae | 4982 | |
28c6e247 | 4983 | other = peer->doppelganger; |
f4b8ec07 | 4984 | |
28c6e247 IR |
4985 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4986 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4987 | |
28c6e247 IR |
4988 | peer_notify_unconfig(peer); |
4989 | peer_delete(peer); | |
4990 | if (other && other->status != Deleted) { | |
4991 | peer_notify_unconfig(other); | |
4992 | peer_delete(other); | |
4993 | } | |
4994 | } | |
4995 | } | |
4996 | ||
4997 | return CMD_SUCCESS; | |
a80beece DS |
4998 | } |
4999 | ||
28c6e247 IR |
5000 | DEFUN (no_neighbor_interface_config, |
5001 | no_neighbor_interface_config_cmd, | |
5002 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
5003 | NO_STR | |
5004 | NEIGHBOR_STR | |
5005 | "Interface name\n" | |
5006 | "Configure BGP on interface\n" | |
5007 | "Enable BGP with v6 link-local only\n" | |
5008 | "Member of the peer-group\n" | |
5009 | "Peer-group name\n" | |
5010 | "Specify a BGP neighbor\n" | |
5011 | AS_STR | |
5012 | "Internal BGP peer\n" | |
5013 | "External BGP peer\n") | |
718e3744 | 5014 | { |
28c6e247 | 5015 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5016 | int idx_word = 2; |
28c6e247 | 5017 | struct peer *peer; |
718e3744 | 5018 | |
28c6e247 IR |
5019 | /* look up for neighbor by interface name config. */ |
5020 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
5021 | if (peer) { | |
5022 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
5023 | if (peer->ifp) | |
5024 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
5025 | peer_notify_unconfig(peer); | |
5026 | peer_delete(peer); | |
5027 | } else { | |
5028 | vty_out(vty, "%% Create the bgp interface first\n"); | |
5029 | return CMD_WARNING_CONFIG_FAILED; | |
5030 | } | |
5031 | return CMD_SUCCESS; | |
718e3744 | 5032 | } |
5033 | ||
28c6e247 IR |
5034 | DEFUN (no_neighbor_peer_group, |
5035 | no_neighbor_peer_group_cmd, | |
5036 | "no neighbor WORD peer-group", | |
5037 | NO_STR | |
5038 | NEIGHBOR_STR | |
5039 | "Neighbor tag\n" | |
5040 | "Configure peer-group\n") | |
718e3744 | 5041 | { |
28c6e247 IR |
5042 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5043 | int idx_word = 2; | |
5044 | struct peer_group *group; | |
f4b8ec07 | 5045 | |
28c6e247 IR |
5046 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
5047 | if (group) { | |
5048 | peer_group_notify_unconfig(group); | |
5049 | peer_group_delete(group); | |
f4b8ec07 | 5050 | } else { |
28c6e247 | 5051 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 5052 | return CMD_WARNING_CONFIG_FAILED; |
5053 | } | |
28c6e247 IR |
5054 | return CMD_SUCCESS; |
5055 | } | |
f4b8ec07 | 5056 | |
28c6e247 IR |
5057 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
5058 | no_neighbor_interface_peer_group_remote_as_cmd, | |
8079a413 | 5059 | "no neighbor WORD remote-as <ASNUM|internal|external>", |
28c6e247 IR |
5060 | NO_STR |
5061 | NEIGHBOR_STR | |
5062 | "Interface name or neighbor tag\n" | |
5063 | "Specify a BGP neighbor\n" | |
5064 | AS_STR | |
5065 | "Internal BGP peer\n" | |
5066 | "External BGP peer\n") | |
5067 | { | |
5068 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
5069 | int idx_word = 2; | |
5070 | struct peer_group *group; | |
5071 | struct peer *peer; | |
f4b8ec07 | 5072 | |
28c6e247 IR |
5073 | /* look up for neighbor by interface name config. */ |
5074 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
5075 | if (peer) { | |
de76ed8a | 5076 | peer_as_change(peer, 0, AS_UNSPECIFIED, NULL); |
28c6e247 IR |
5077 | return CMD_SUCCESS; |
5078 | } | |
f4b8ec07 | 5079 | |
28c6e247 IR |
5080 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
5081 | if (group) | |
5082 | peer_group_remote_as_delete(group); | |
5083 | else { | |
5084 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
5085 | return CMD_WARNING_CONFIG_FAILED; | |
5086 | } | |
5087 | return CMD_SUCCESS; | |
718e3744 | 5088 | } |
6b0655a2 | 5089 | |
28c6e247 IR |
5090 | DEFUN (neighbor_local_as, |
5091 | neighbor_local_as_cmd, | |
8079a413 | 5092 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM", |
28c6e247 IR |
5093 | NEIGHBOR_STR |
5094 | NEIGHBOR_ADDR_STR2 | |
5095 | "Specify a local-as number\n" | |
8079a413 | 5096 | "AS number expressed in dotted or plain format used as local AS\n") |
718e3744 | 5097 | { |
d62a17ae | 5098 | int idx_peer = 1; |
5099 | int idx_number = 3; | |
28c6e247 IR |
5100 | struct peer *peer; |
5101 | int ret; | |
5102 | as_t as; | |
718e3744 | 5103 | |
28c6e247 IR |
5104 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5105 | if (!peer) | |
d62a17ae | 5106 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5107 | |
8079a413 PG |
5108 | if (!asn_str2asn(argv[idx_number]->arg, &as)) { |
5109 | vty_out(vty, "%% Invalid neighbor local-as value: %s\n", | |
5110 | argv[idx_number]->arg); | |
5111 | return CMD_WARNING_CONFIG_FAILED; | |
5112 | } | |
5113 | ||
de76ed8a | 5114 | ret = peer_local_as_set(peer, as, 0, 0, argv[idx_number]->arg); |
28c6e247 | 5115 | return bgp_vty_return(vty, ret); |
718e3744 | 5116 | } |
5117 | ||
28c6e247 IR |
5118 | DEFUN (neighbor_local_as_no_prepend, |
5119 | neighbor_local_as_no_prepend_cmd, | |
8079a413 | 5120 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM no-prepend", |
28c6e247 IR |
5121 | NEIGHBOR_STR |
5122 | NEIGHBOR_ADDR_STR2 | |
5123 | "Specify a local-as number\n" | |
8079a413 | 5124 | "AS number expressed in dotted or plain format used as local AS\n" |
28c6e247 | 5125 | "Do not prepend local-as to updates from ebgp peers\n") |
718e3744 | 5126 | { |
d62a17ae | 5127 | int idx_peer = 1; |
5128 | int idx_number = 3; | |
28c6e247 IR |
5129 | struct peer *peer; |
5130 | int ret; | |
5131 | as_t as; | |
718e3744 | 5132 | |
28c6e247 IR |
5133 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5134 | if (!peer) | |
d62a17ae | 5135 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5136 | |
8079a413 PG |
5137 | if (!asn_str2asn(argv[idx_number]->arg, &as)) { |
5138 | vty_out(vty, "%% Invalid neighbor local-as value: %s\n", | |
5139 | argv[idx_number]->arg); | |
5140 | return CMD_WARNING_CONFIG_FAILED; | |
5141 | } | |
5142 | ||
de76ed8a | 5143 | ret = peer_local_as_set(peer, as, 1, 0, argv[idx_number]->arg); |
28c6e247 | 5144 | return bgp_vty_return(vty, ret); |
718e3744 | 5145 | } |
5146 | ||
28c6e247 IR |
5147 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
5148 | neighbor_local_as_no_prepend_replace_as_cmd, | |
8079a413 | 5149 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as ASNUM no-prepend replace-as", |
28c6e247 IR |
5150 | NEIGHBOR_STR |
5151 | NEIGHBOR_ADDR_STR2 | |
5152 | "Specify a local-as number\n" | |
8079a413 | 5153 | "AS number expressed in dotted or plain format used as local AS\n" |
28c6e247 IR |
5154 | "Do not prepend local-as to updates from ebgp peers\n" |
5155 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 5156 | { |
d62a17ae | 5157 | int idx_peer = 1; |
5158 | int idx_number = 3; | |
28c6e247 IR |
5159 | struct peer *peer; |
5160 | int ret; | |
5161 | as_t as; | |
9d3f9705 | 5162 | |
28c6e247 IR |
5163 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5164 | if (!peer) | |
d62a17ae | 5165 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 5166 | |
8079a413 PG |
5167 | if (!asn_str2asn(argv[idx_number]->arg, &as)) { |
5168 | vty_out(vty, "%% Invalid neighbor local-as value: %s\n", | |
5169 | argv[idx_number]->arg); | |
5170 | return CMD_WARNING_CONFIG_FAILED; | |
5171 | } | |
5172 | ||
de76ed8a | 5173 | ret = peer_local_as_set(peer, as, 1, 1, argv[idx_number]->arg); |
28c6e247 | 5174 | return bgp_vty_return(vty, ret); |
9d3f9705 AC |
5175 | } |
5176 | ||
28c6e247 IR |
5177 | DEFUN (no_neighbor_local_as, |
5178 | no_neighbor_local_as_cmd, | |
8079a413 | 5179 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [ASNUM [no-prepend [replace-as]]]", |
28c6e247 IR |
5180 | NO_STR |
5181 | NEIGHBOR_STR | |
5182 | NEIGHBOR_ADDR_STR2 | |
5183 | "Specify a local-as number\n" | |
8079a413 | 5184 | "AS number expressed in dotted or plain format used as local AS\n" |
28c6e247 IR |
5185 | "Do not prepend local-as to updates from ebgp peers\n" |
5186 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 5187 | { |
d62a17ae | 5188 | int idx_peer = 2; |
28c6e247 IR |
5189 | struct peer *peer; |
5190 | int ret; | |
718e3744 | 5191 | |
28c6e247 IR |
5192 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5193 | if (!peer) | |
d62a17ae | 5194 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5195 | |
28c6e247 IR |
5196 | ret = peer_local_as_unset(peer); |
5197 | return bgp_vty_return(vty, ret); | |
718e3744 | 5198 | } |
5199 | ||
718e3744 | 5200 | |
3f9c7369 DS |
5201 | DEFUN (neighbor_solo, |
5202 | neighbor_solo_cmd, | |
9ccf14f7 | 5203 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
5204 | NEIGHBOR_STR |
5205 | NEIGHBOR_ADDR_STR2 | |
5206 | "Solo peer - part of its own update group\n") | |
5207 | { | |
d62a17ae | 5208 | int idx_peer = 1; |
5209 | struct peer *peer; | |
5210 | int ret; | |
3f9c7369 | 5211 | |
d62a17ae | 5212 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5213 | if (!peer) | |
5214 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 5215 | |
d62a17ae | 5216 | ret = update_group_adjust_soloness(peer, 1); |
5217 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
5218 | } |
5219 | ||
5220 | DEFUN (no_neighbor_solo, | |
5221 | no_neighbor_solo_cmd, | |
9ccf14f7 | 5222 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
5223 | NO_STR |
5224 | NEIGHBOR_STR | |
5225 | NEIGHBOR_ADDR_STR2 | |
5226 | "Solo peer - part of its own update group\n") | |
5227 | { | |
d62a17ae | 5228 | int idx_peer = 2; |
5229 | struct peer *peer; | |
5230 | int ret; | |
3f9c7369 | 5231 | |
d62a17ae | 5232 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5233 | if (!peer) | |
5234 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 5235 | |
d62a17ae | 5236 | ret = update_group_adjust_soloness(peer, 0); |
5237 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
5238 | } |
5239 | ||
28c6e247 IR |
5240 | DEFUN (neighbor_password, |
5241 | neighbor_password_cmd, | |
5242 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
5243 | NEIGHBOR_STR | |
5244 | NEIGHBOR_ADDR_STR2 | |
5245 | "Set a password\n" | |
5246 | "The password\n") | |
0df7c91f | 5247 | { |
d62a17ae | 5248 | int idx_peer = 1; |
5249 | int idx_line = 3; | |
28c6e247 IR |
5250 | struct peer *peer; |
5251 | int ret; | |
0df7c91f | 5252 | |
28c6e247 IR |
5253 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5254 | if (!peer) | |
d62a17ae | 5255 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5256 | |
28c6e247 IR |
5257 | ret = peer_password_set(peer, argv[idx_line]->arg); |
5258 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
5259 | } |
5260 | ||
28c6e247 IR |
5261 | DEFUN (no_neighbor_password, |
5262 | no_neighbor_password_cmd, | |
5263 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
5264 | NO_STR | |
5265 | NEIGHBOR_STR | |
5266 | NEIGHBOR_ADDR_STR2 | |
5267 | "Set a password\n" | |
5268 | "The password\n") | |
0df7c91f | 5269 | { |
d62a17ae | 5270 | int idx_peer = 2; |
28c6e247 IR |
5271 | struct peer *peer; |
5272 | int ret; | |
0df7c91f | 5273 | |
28c6e247 IR |
5274 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5275 | if (!peer) | |
d62a17ae | 5276 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 5277 | |
28c6e247 IR |
5278 | ret = peer_password_unset(peer); |
5279 | return bgp_vty_return(vty, ret); | |
0df7c91f | 5280 | } |
6b0655a2 | 5281 | |
28c6e247 IR |
5282 | DEFUN (neighbor_activate, |
5283 | neighbor_activate_cmd, | |
5284 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5285 | NEIGHBOR_STR | |
5286 | NEIGHBOR_ADDR_STR2 | |
5287 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5288 | { |
d62a17ae | 5289 | int idx_peer = 1; |
28c6e247 IR |
5290 | int ret; |
5291 | struct peer *peer; | |
56ceae84 | 5292 | |
28c6e247 IR |
5293 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5294 | if (!peer) | |
d62a17ae | 5295 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5296 | |
28c6e247 IR |
5297 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
5298 | return bgp_vty_return(vty, ret); | |
718e3744 | 5299 | } |
5300 | ||
d62a17ae | 5301 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
5302 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5303 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5304 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5305 | |
28c6e247 IR |
5306 | DEFUN (no_neighbor_activate, |
5307 | no_neighbor_activate_cmd, | |
5308 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5309 | NO_STR | |
5310 | NEIGHBOR_STR | |
5311 | NEIGHBOR_ADDR_STR2 | |
5312 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5313 | { |
d62a17ae | 5314 | int idx_peer = 2; |
28c6e247 IR |
5315 | int ret; |
5316 | struct peer *peer; | |
f4b8ec07 | 5317 | |
28c6e247 IR |
5318 | /* Lookup peer. */ |
5319 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5320 | if (!peer) | |
d62a17ae | 5321 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5322 | |
28c6e247 IR |
5323 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
5324 | return bgp_vty_return(vty, ret); | |
718e3744 | 5325 | } |
6b0655a2 | 5326 | |
d62a17ae | 5327 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
5328 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5329 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5330 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5331 | |
28c6e247 IR |
5332 | DEFUN (neighbor_set_peer_group, |
5333 | neighbor_set_peer_group_cmd, | |
5334 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5335 | NEIGHBOR_STR | |
5336 | NEIGHBOR_ADDR_STR2 | |
5337 | "Member of the peer-group\n" | |
5338 | "Peer-group name\n") | |
718e3744 | 5339 | { |
28c6e247 | 5340 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5341 | int idx_peer = 1; |
5342 | int idx_word = 3; | |
28c6e247 IR |
5343 | int ret; |
5344 | as_t as; | |
5345 | union sockunion su; | |
5346 | struct peer *peer; | |
5347 | struct peer_group *group; | |
5348 | ||
5349 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
5350 | if (ret < 0) { | |
5351 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
5352 | if (!peer) { | |
5353 | vty_out(vty, "%% Malformed address or name: %s\n", | |
5354 | argv[idx_peer]->arg); | |
5355 | return CMD_WARNING_CONFIG_FAILED; | |
5356 | } | |
5357 | } else { | |
5358 | if (peer_address_self_check(bgp, &su)) { | |
5359 | vty_out(vty, | |
5360 | "%% Can not configure the local system as neighbor\n"); | |
5361 | return CMD_WARNING_CONFIG_FAILED; | |
5362 | } | |
2a059a54 | 5363 | |
28c6e247 IR |
5364 | /* Disallow for dynamic neighbor. */ |
5365 | peer = peer_lookup(bgp, &su); | |
5366 | if (peer && peer_dynamic_neighbor(peer)) { | |
5367 | vty_out(vty, | |
5368 | "%% Operation not allowed on a dynamic neighbor\n"); | |
5369 | return CMD_WARNING_CONFIG_FAILED; | |
5370 | } | |
5371 | } | |
5372 | ||
5373 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
5374 | if (!group) { | |
5375 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 5376 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 5377 | } |
d62a17ae | 5378 | |
28c6e247 | 5379 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 5380 | |
28c6e247 | 5381 | return bgp_vty_return(vty, ret); |
d62a17ae | 5382 | } |
5383 | ||
5384 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 5385 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5386 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5387 | "Member of the peer-group\n" | |
5388 | "Peer-group name\n") | |
596c17ba | 5389 | |
28c6e247 IR |
5390 | DEFUN (no_neighbor_set_peer_group, |
5391 | no_neighbor_set_peer_group_cmd, | |
5392 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5393 | NO_STR | |
5394 | NEIGHBOR_STR | |
5395 | NEIGHBOR_ADDR_STR2 | |
5396 | "Member of the peer-group\n" | |
5397 | "Peer-group name\n") | |
718e3744 | 5398 | { |
28c6e247 | 5399 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5400 | int idx_peer = 2; |
28c6e247 IR |
5401 | int idx_word = 4; |
5402 | int ret; | |
5403 | struct peer *peer; | |
5404 | struct peer_group *group; | |
d62a17ae | 5405 | |
28c6e247 IR |
5406 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
5407 | if (!peer) | |
d62a17ae | 5408 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 5409 | |
28c6e247 IR |
5410 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
5411 | if (!group) { | |
5412 | vty_out(vty, "%% Configure the peer-group first\n"); | |
5413 | return CMD_WARNING_CONFIG_FAILED; | |
5414 | } | |
718e3744 | 5415 | |
28c6e247 IR |
5416 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
5417 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
5418 | ||
5419 | peer_notify_unconfig(peer); | |
5420 | ret = peer_delete(peer); | |
5421 | ||
5422 | return bgp_vty_return(vty, ret); | |
718e3744 | 5423 | } |
6b0655a2 | 5424 | |
d62a17ae | 5425 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 5426 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5427 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5428 | "Member of the peer-group\n" | |
5429 | "Peer-group name\n") | |
596c17ba | 5430 | |
718e3744 | 5431 | /* neighbor passive. */ |
28c6e247 IR |
5432 | DEFUN (neighbor_passive, |
5433 | neighbor_passive_cmd, | |
5434 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5435 | NEIGHBOR_STR | |
5436 | NEIGHBOR_ADDR_STR2 | |
5437 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5438 | { |
d62a17ae | 5439 | int idx_peer = 1; |
28c6e247 | 5440 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5441 | } |
5442 | ||
28c6e247 IR |
5443 | DEFUN (no_neighbor_passive, |
5444 | no_neighbor_passive_cmd, | |
5445 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5446 | NO_STR | |
5447 | NEIGHBOR_STR | |
5448 | NEIGHBOR_ADDR_STR2 | |
5449 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5450 | { |
d62a17ae | 5451 | int idx_peer = 2; |
28c6e247 | 5452 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5453 | } |
6b0655a2 | 5454 | |
718e3744 | 5455 | /* neighbor shutdown. */ |
28c6e247 IR |
5456 | DEFUN (neighbor_shutdown_msg, |
5457 | neighbor_shutdown_msg_cmd, | |
5458 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5459 | NEIGHBOR_STR | |
5460 | NEIGHBOR_ADDR_STR2 | |
5461 | "Administratively shut down this neighbor\n" | |
5462 | "Add a shutdown message (RFC 8203)\n" | |
5463 | "Shutdown message\n") | |
718e3744 | 5464 | { |
d62a17ae | 5465 | int idx_peer = 1; |
73d70fa6 | 5466 | |
d62a17ae | 5467 | if (argc >= 5) { |
28c6e247 IR |
5468 | struct peer *peer = |
5469 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 5470 | char *message; |
73d70fa6 | 5471 | |
28c6e247 IR |
5472 | if (!peer) |
5473 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5474 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
5475 | peer_tx_shutdown_message_set(peer, message); |
5476 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 5477 | } |
73d70fa6 | 5478 | |
28c6e247 | 5479 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5480 | } |
5481 | ||
1d80f243 | 5482 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5483 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5484 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5485 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5486 | |
28c6e247 IR |
5487 | DEFUN (no_neighbor_shutdown_msg, |
5488 | no_neighbor_shutdown_msg_cmd, | |
5489 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5490 | NO_STR | |
5491 | NEIGHBOR_STR | |
5492 | NEIGHBOR_ADDR_STR2 | |
5493 | "Administratively shut down this neighbor\n" | |
5494 | "Remove a shutdown message (RFC 8203)\n" | |
5495 | "Shutdown message\n") | |
718e3744 | 5496 | { |
d62a17ae | 5497 | int idx_peer = 2; |
73d70fa6 | 5498 | |
28c6e247 IR |
5499 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5500 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5501 | } |
6b0655a2 | 5502 | |
1d80f243 | 5503 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5504 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5505 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5506 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5507 | |
8336c896 DA |
5508 | DEFUN(neighbor_shutdown_rtt, |
5509 | neighbor_shutdown_rtt_cmd, | |
5510 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5511 | NEIGHBOR_STR | |
5512 | NEIGHBOR_ADDR_STR2 | |
5513 | "Administratively shut down this neighbor\n" | |
5514 | "Shutdown if round-trip-time is higher than expected\n" | |
5515 | "Round-trip-time in milliseconds\n" | |
5516 | "Specify the number of keepalives before shutdown\n" | |
5517 | "The number of keepalives with higher RTT to shutdown\n") | |
5518 | { | |
5519 | int idx_peer = 1; | |
5520 | int idx_rtt = 4; | |
5521 | int idx_count = 0; | |
5522 | struct peer *peer; | |
5523 | ||
5524 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5525 | ||
5526 | if (!peer) | |
5527 | return CMD_WARNING_CONFIG_FAILED; | |
5528 | ||
5529 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5530 | ||
5531 | if (argv_find(argv, argc, "count", &idx_count)) | |
5532 | peer->rtt_keepalive_conf = | |
5533 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5534 | ||
5535 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5536 | PEER_FLAG_RTT_SHUTDOWN); | |
5537 | } | |
5538 | ||
5539 | DEFUN(no_neighbor_shutdown_rtt, | |
5540 | no_neighbor_shutdown_rtt_cmd, | |
5541 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5542 | NO_STR | |
5543 | NEIGHBOR_STR | |
5544 | NEIGHBOR_ADDR_STR2 | |
5545 | "Administratively shut down this neighbor\n" | |
5546 | "Shutdown if round-trip-time is higher than expected\n" | |
5547 | "Round-trip-time in milliseconds\n" | |
5548 | "Specify the number of keepalives before shutdown\n" | |
5549 | "The number of keepalives with higher RTT to shutdown\n") | |
5550 | { | |
5551 | int idx_peer = 2; | |
5552 | struct peer *peer; | |
5553 | ||
5554 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5555 | ||
5556 | if (!peer) | |
5557 | return CMD_WARNING_CONFIG_FAILED; | |
5558 | ||
5559 | peer->rtt_expected = 0; | |
5560 | peer->rtt_keepalive_conf = 1; | |
5561 | ||
5562 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5563 | PEER_FLAG_RTT_SHUTDOWN); | |
5564 | } | |
5565 | ||
718e3744 | 5566 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5567 | DEFUN (neighbor_capability_dynamic, |
5568 | neighbor_capability_dynamic_cmd, | |
5569 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5570 | NEIGHBOR_STR | |
5571 | NEIGHBOR_ADDR_STR2 | |
5572 | "Advertise capability to the peer\n" | |
5573 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5574 | { |
d62a17ae | 5575 | int idx_peer = 1; |
28c6e247 IR |
5576 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5577 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5578 | } |
5579 | ||
28c6e247 IR |
5580 | DEFUN (no_neighbor_capability_dynamic, |
5581 | no_neighbor_capability_dynamic_cmd, | |
5582 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5583 | NO_STR | |
5584 | NEIGHBOR_STR | |
5585 | NEIGHBOR_ADDR_STR2 | |
5586 | "Advertise capability to the peer\n" | |
5587 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5588 | { |
d62a17ae | 5589 | int idx_peer = 2; |
28c6e247 IR |
5590 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5591 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5592 | } |
6b0655a2 | 5593 | |
718e3744 | 5594 | /* neighbor dont-capability-negotiate */ |
5595 | DEFUN (neighbor_dont_capability_negotiate, | |
5596 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5597 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5598 | NEIGHBOR_STR |
5599 | NEIGHBOR_ADDR_STR2 | |
5600 | "Do not perform capability negotiation\n") | |
5601 | { | |
d62a17ae | 5602 | int idx_peer = 1; |
5603 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5604 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5605 | } |
5606 | ||
5607 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5608 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5609 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5610 | NO_STR |
5611 | NEIGHBOR_STR | |
5612 | NEIGHBOR_ADDR_STR2 | |
5613 | "Do not perform capability negotiation\n") | |
5614 | { | |
28c6e247 IR |
5615 | int idx_peer = 2; |
5616 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5617 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5618 | } |
5619 | ||
28c6e247 IR |
5620 | /* neighbor capability extended next hop encoding */ |
5621 | DEFUN (neighbor_capability_enhe, | |
5622 | neighbor_capability_enhe_cmd, | |
5623 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5624 | NEIGHBOR_STR | |
5625 | NEIGHBOR_ADDR_STR2 | |
5626 | "Advertise capability to the peer\n" | |
5627 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5628 | { |
28c6e247 | 5629 | int idx_peer = 1; |
c4786405 DS |
5630 | struct peer *peer; |
5631 | ||
5632 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5633 | if (peer && peer->conf_if) | |
5634 | return CMD_SUCCESS; | |
5635 | ||
28c6e247 IR |
5636 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5637 | PEER_FLAG_CAPABILITY_ENHE); | |
5638 | } | |
f4b8ec07 | 5639 | |
28c6e247 IR |
5640 | DEFUN (no_neighbor_capability_enhe, |
5641 | no_neighbor_capability_enhe_cmd, | |
5642 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5643 | NO_STR | |
5644 | NEIGHBOR_STR | |
5645 | NEIGHBOR_ADDR_STR2 | |
5646 | "Advertise capability to the peer\n" | |
5647 | "Advertise extended next-hop capability to the peer\n") | |
5648 | { | |
5649 | int idx_peer = 2; | |
c4786405 DS |
5650 | struct peer *peer; |
5651 | ||
5652 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5653 | if (peer && peer->conf_if) { | |
5654 | vty_out(vty, | |
5655 | "Peer %s cannot have capability extended-nexthop turned off\n", | |
5656 | argv[idx_peer]->arg); | |
5657 | return CMD_WARNING_CONFIG_FAILED; | |
5658 | } | |
5659 | ||
28c6e247 IR |
5660 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5661 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5662 | } |
5663 | ||
d62a17ae | 5664 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5665 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5666 | int set) |
718e3744 | 5667 | { |
d62a17ae | 5668 | int ret; |
5669 | struct peer *peer; | |
718e3744 | 5670 | |
d62a17ae | 5671 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5672 | if (!peer) | |
5673 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5674 | |
d62a17ae | 5675 | if (set) |
5676 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5677 | else | |
5678 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5679 | |
d62a17ae | 5680 | return bgp_vty_return(vty, ret); |
718e3744 | 5681 | } |
5682 | ||
d62a17ae | 5683 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5684 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5685 | { |
d62a17ae | 5686 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5687 | } |
5688 | ||
d62a17ae | 5689 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5690 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5691 | { |
d62a17ae | 5692 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5693 | } |
6b0655a2 | 5694 | |
718e3744 | 5695 | /* neighbor capability orf prefix-list. */ |
5696 | DEFUN (neighbor_capability_orf_prefix, | |
5697 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5698 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5699 | NEIGHBOR_STR |
5700 | NEIGHBOR_ADDR_STR2 | |
5701 | "Advertise capability to the peer\n" | |
5702 | "Advertise ORF capability to the peer\n" | |
5703 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5704 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5705 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5706 | "Capability to SEND the ORF to this neighbor\n") | |
5707 | { | |
d62a17ae | 5708 | int idx_send_recv = 5; |
db45f64d DS |
5709 | char *peer_str = argv[1]->arg; |
5710 | struct peer *peer; | |
5711 | afi_t afi = bgp_node_afi(vty); | |
5712 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5713 | |
db45f64d DS |
5714 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5715 | if (!peer) | |
d62a17ae | 5716 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5717 | |
db45f64d DS |
5718 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5719 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5720 | PEER_FLAG_ORF_PREFIX_SM); | |
5721 | ||
5722 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5723 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5724 | PEER_FLAG_ORF_PREFIX_RM); | |
5725 | ||
5726 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5727 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5728 | PEER_FLAG_ORF_PREFIX_SM) | |
5729 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5730 | PEER_FLAG_ORF_PREFIX_RM); | |
5731 | ||
5732 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5733 | } |
5734 | ||
5735 | ALIAS_HIDDEN( | |
5736 | neighbor_capability_orf_prefix, | |
5737 | neighbor_capability_orf_prefix_hidden_cmd, | |
5738 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5739 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5740 | "Advertise capability to the peer\n" | |
5741 | "Advertise ORF capability to the peer\n" | |
5742 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5743 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5744 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5745 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5746 | |
718e3744 | 5747 | DEFUN (no_neighbor_capability_orf_prefix, |
5748 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5749 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5750 | NO_STR |
5751 | NEIGHBOR_STR | |
5752 | NEIGHBOR_ADDR_STR2 | |
5753 | "Advertise capability to the peer\n" | |
5754 | "Advertise ORF capability to the peer\n" | |
5755 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5756 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5757 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5758 | "Capability to SEND the ORF to this neighbor\n") | |
5759 | { | |
d62a17ae | 5760 | int idx_send_recv = 6; |
db45f64d DS |
5761 | char *peer_str = argv[2]->arg; |
5762 | struct peer *peer; | |
5763 | afi_t afi = bgp_node_afi(vty); | |
5764 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5765 | |
db45f64d DS |
5766 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5767 | if (!peer) | |
d62a17ae | 5768 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5769 | |
db45f64d DS |
5770 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5771 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5772 | PEER_FLAG_ORF_PREFIX_SM); | |
5773 | ||
5774 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5775 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5776 | PEER_FLAG_ORF_PREFIX_RM); | |
5777 | ||
5778 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5779 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5780 | PEER_FLAG_ORF_PREFIX_SM) | |
5781 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5782 | PEER_FLAG_ORF_PREFIX_RM); | |
5783 | ||
5784 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5785 | } |
5786 | ||
5787 | ALIAS_HIDDEN( | |
5788 | no_neighbor_capability_orf_prefix, | |
5789 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5790 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5791 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5792 | "Advertise capability to the peer\n" | |
5793 | "Advertise ORF capability to the peer\n" | |
5794 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5795 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5796 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5797 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5798 | |
718e3744 | 5799 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5800 | DEFUN (neighbor_nexthop_self, |
5801 | neighbor_nexthop_self_cmd, | |
5802 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5803 | NEIGHBOR_STR | |
5804 | NEIGHBOR_ADDR_STR2 | |
5805 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5806 | { |
d62a17ae | 5807 | int idx_peer = 1; |
28c6e247 IR |
5808 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5809 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5810 | } |
9e7a53c1 | 5811 | |
d62a17ae | 5812 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5813 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5814 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5815 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5816 | |
f4b8ec07 | 5817 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5818 | DEFUN (neighbor_nexthop_self_force, |
5819 | neighbor_nexthop_self_force_cmd, | |
5820 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5821 | NEIGHBOR_STR | |
5822 | NEIGHBOR_ADDR_STR2 | |
5823 | "Disable the next hop calculation for this neighbor\n" | |
5824 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5825 | { |
5826 | int idx_peer = 1; | |
28c6e247 IR |
5827 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5828 | bgp_node_safi(vty), | |
5829 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5830 | } |
5831 | ||
d62a17ae | 5832 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5833 | neighbor_nexthop_self_force_hidden_cmd, | |
5834 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5835 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5836 | "Disable the next hop calculation for this neighbor\n" | |
5837 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5838 | |
1bc4e531 DA |
5839 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5840 | neighbor_nexthop_self_all_hidden_cmd, | |
5841 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5842 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5843 | "Disable the next hop calculation for this neighbor\n" | |
5844 | "Set the next hop to self for reflected routes\n") | |
5845 | ||
28c6e247 IR |
5846 | DEFUN (no_neighbor_nexthop_self, |
5847 | no_neighbor_nexthop_self_cmd, | |
5848 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5849 | NO_STR | |
5850 | NEIGHBOR_STR | |
5851 | NEIGHBOR_ADDR_STR2 | |
5852 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5853 | { |
d62a17ae | 5854 | int idx_peer = 2; |
28c6e247 IR |
5855 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5856 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5857 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5858 | } |
6b0655a2 | 5859 | |
d62a17ae | 5860 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5861 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5862 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5863 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5864 | |
28c6e247 IR |
5865 | DEFUN (no_neighbor_nexthop_self_force, |
5866 | no_neighbor_nexthop_self_force_cmd, | |
5867 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5868 | NO_STR | |
5869 | NEIGHBOR_STR | |
5870 | NEIGHBOR_ADDR_STR2 | |
5871 | "Disable the next hop calculation for this neighbor\n" | |
5872 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5873 | { |
d62a17ae | 5874 | int idx_peer = 2; |
28c6e247 IR |
5875 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5876 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5877 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5878 | } |
a538debe | 5879 | |
d62a17ae | 5880 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5881 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5882 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5883 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5884 | "Disable the next hop calculation for this neighbor\n" | |
5885 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5886 | |
1bc4e531 DA |
5887 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5888 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5889 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5890 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5891 | "Disable the next hop calculation for this neighbor\n" | |
5892 | "Set the next hop to self for reflected routes\n") | |
5893 | ||
c7122e14 | 5894 | /* neighbor as-override */ |
28c6e247 IR |
5895 | DEFUN (neighbor_as_override, |
5896 | neighbor_as_override_cmd, | |
5897 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5898 | NEIGHBOR_STR | |
5899 | NEIGHBOR_ADDR_STR2 | |
5900 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5901 | { |
d62a17ae | 5902 | int idx_peer = 1; |
28c6e247 IR |
5903 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5904 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5905 | } |
5906 | ||
d62a17ae | 5907 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5908 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5909 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5910 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5911 | |
28c6e247 IR |
5912 | DEFUN (no_neighbor_as_override, |
5913 | no_neighbor_as_override_cmd, | |
5914 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5915 | NO_STR | |
5916 | NEIGHBOR_STR | |
5917 | NEIGHBOR_ADDR_STR2 | |
5918 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5919 | { |
d62a17ae | 5920 | int idx_peer = 2; |
28c6e247 IR |
5921 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5922 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5923 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5924 | } |
5925 | ||
d62a17ae | 5926 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5927 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5928 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5929 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5930 | |
718e3744 | 5931 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5932 | DEFUN (neighbor_remove_private_as, |
5933 | neighbor_remove_private_as_cmd, | |
5934 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5935 | NEIGHBOR_STR | |
5936 | NEIGHBOR_ADDR_STR2 | |
5937 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5938 | { |
d62a17ae | 5939 | int idx_peer = 1; |
28c6e247 IR |
5940 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5941 | bgp_node_safi(vty), | |
5942 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5943 | } |
5944 | ||
d62a17ae | 5945 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5946 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5947 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5948 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5949 | |
28c6e247 IR |
5950 | DEFUN (neighbor_remove_private_as_all, |
5951 | neighbor_remove_private_as_all_cmd, | |
5952 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5953 | NEIGHBOR_STR | |
5954 | NEIGHBOR_ADDR_STR2 | |
5955 | "Remove private ASNs in outbound updates\n" | |
5956 | "Apply to all AS numbers\n") | |
5000f21c | 5957 | { |
d62a17ae | 5958 | int idx_peer = 1; |
28c6e247 IR |
5959 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5960 | bgp_node_safi(vty), | |
5961 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5962 | } |
5963 | ||
d62a17ae | 5964 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5965 | neighbor_remove_private_as_all_hidden_cmd, | |
5966 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5967 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5968 | "Remove private ASNs in outbound updates\n" | |
a0dfca37 | 5969 | "Apply to all AS numbers\n") |
596c17ba | 5970 | |
28c6e247 IR |
5971 | DEFUN (neighbor_remove_private_as_replace_as, |
5972 | neighbor_remove_private_as_replace_as_cmd, | |
5973 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5974 | NEIGHBOR_STR | |
5975 | NEIGHBOR_ADDR_STR2 | |
5976 | "Remove private ASNs in outbound updates\n" | |
5977 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5978 | { |
d62a17ae | 5979 | int idx_peer = 1; |
28c6e247 IR |
5980 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5981 | bgp_node_safi(vty), | |
5982 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5983 | } |
5984 | ||
d62a17ae | 5985 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5986 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5987 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5988 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5989 | "Remove private ASNs in outbound updates\n" | |
5990 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5991 | |
28c6e247 IR |
5992 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5993 | neighbor_remove_private_as_all_replace_as_cmd, | |
5994 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5995 | NEIGHBOR_STR | |
5996 | NEIGHBOR_ADDR_STR2 | |
5997 | "Remove private ASNs in outbound updates\n" | |
5998 | "Apply to all AS numbers\n" | |
5999 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 6000 | { |
d62a17ae | 6001 | int idx_peer = 1; |
28c6e247 IR |
6002 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6003 | bgp_node_safi(vty), | |
6004 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
6005 | } |
6006 | ||
d62a17ae | 6007 | ALIAS_HIDDEN( |
6008 | neighbor_remove_private_as_all_replace_as, | |
6009 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
6010 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6011 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6012 | "Remove private ASNs in outbound updates\n" | |
6013 | "Apply to all AS numbers\n" | |
6014 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6015 | |
28c6e247 IR |
6016 | DEFUN (no_neighbor_remove_private_as, |
6017 | no_neighbor_remove_private_as_cmd, | |
6018 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
6019 | NO_STR | |
6020 | NEIGHBOR_STR | |
6021 | NEIGHBOR_ADDR_STR2 | |
6022 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 6023 | { |
d62a17ae | 6024 | int idx_peer = 2; |
28c6e247 IR |
6025 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6026 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6027 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 6028 | } |
6b0655a2 | 6029 | |
d62a17ae | 6030 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
6031 | no_neighbor_remove_private_as_hidden_cmd, | |
6032 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
6033 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6034 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 6035 | |
28c6e247 IR |
6036 | DEFUN (no_neighbor_remove_private_as_all, |
6037 | no_neighbor_remove_private_as_all_cmd, | |
6038 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
6039 | NO_STR | |
6040 | NEIGHBOR_STR | |
6041 | NEIGHBOR_ADDR_STR2 | |
6042 | "Remove private ASNs in outbound updates\n" | |
6043 | "Apply to all AS numbers\n") | |
88b8ed8d | 6044 | { |
d62a17ae | 6045 | int idx_peer = 2; |
28c6e247 IR |
6046 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6047 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6048 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 6049 | } |
5000f21c | 6050 | |
d62a17ae | 6051 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
6052 | no_neighbor_remove_private_as_all_hidden_cmd, | |
6053 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
6054 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6055 | "Remove private ASNs in outbound updates\n" | |
6056 | "Apply to all AS numbers\n") | |
596c17ba | 6057 | |
28c6e247 IR |
6058 | DEFUN (no_neighbor_remove_private_as_replace_as, |
6059 | no_neighbor_remove_private_as_replace_as_cmd, | |
6060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6061 | NO_STR | |
6062 | NEIGHBOR_STR | |
6063 | NEIGHBOR_ADDR_STR2 | |
6064 | "Remove private ASNs in outbound updates\n" | |
6065 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 6066 | { |
d62a17ae | 6067 | int idx_peer = 2; |
28c6e247 IR |
6068 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6069 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6070 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 6071 | } |
5000f21c | 6072 | |
d62a17ae | 6073 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
6074 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
6075 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
6076 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6077 | "Remove private ASNs in outbound updates\n" | |
6078 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6079 | |
28c6e247 IR |
6080 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
6081 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
6082 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6083 | NO_STR | |
6084 | NEIGHBOR_STR | |
6085 | NEIGHBOR_ADDR_STR2 | |
6086 | "Remove private ASNs in outbound updates\n" | |
6087 | "Apply to all AS numbers\n" | |
6088 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 6089 | { |
d62a17ae | 6090 | int idx_peer = 2; |
28c6e247 IR |
6091 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6092 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6093 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 6094 | } |
5000f21c | 6095 | |
d62a17ae | 6096 | ALIAS_HIDDEN( |
6097 | no_neighbor_remove_private_as_all_replace_as, | |
6098 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
6099 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
6100 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6101 | "Remove private ASNs in outbound updates\n" | |
6102 | "Apply to all AS numbers\n" | |
6103 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 6104 | |
5000f21c | 6105 | |
718e3744 | 6106 | /* neighbor send-community. */ |
28c6e247 IR |
6107 | DEFUN (neighbor_send_community, |
6108 | neighbor_send_community_cmd, | |
6109 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6110 | NEIGHBOR_STR | |
6111 | NEIGHBOR_ADDR_STR2 | |
6112 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6113 | { |
d62a17ae | 6114 | int idx_peer = 1; |
27c05d4d | 6115 | |
f63d4054 IR |
6116 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6117 | bgp_node_safi(vty), | |
6118 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6119 | } |
6120 | ||
d62a17ae | 6121 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
6122 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6123 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6124 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6125 | |
28c6e247 IR |
6126 | DEFUN (no_neighbor_send_community, |
6127 | no_neighbor_send_community_cmd, | |
6128 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6129 | NO_STR | |
6130 | NEIGHBOR_STR | |
6131 | NEIGHBOR_ADDR_STR2 | |
6132 | "Send Community attribute to this neighbor\n") | |
718e3744 | 6133 | { |
d62a17ae | 6134 | int idx_peer = 2; |
27c05d4d | 6135 | |
f63d4054 IR |
6136 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6137 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6138 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 6139 | } |
6b0655a2 | 6140 | |
d62a17ae | 6141 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
6142 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
6143 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6144 | "Send Community attribute to this neighbor\n") | |
596c17ba | 6145 | |
718e3744 | 6146 | /* neighbor send-community extended. */ |
28c6e247 IR |
6147 | DEFUN (neighbor_send_community_type, |
6148 | neighbor_send_community_type_cmd, | |
6149 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6150 | NEIGHBOR_STR | |
6151 | NEIGHBOR_ADDR_STR2 | |
6152 | "Send Community attribute to this neighbor\n" | |
6153 | "Send Standard and Extended Community attributes\n" | |
6154 | "Send Standard, Large and Extended Community attributes\n" | |
6155 | "Send Extended Community attributes\n" | |
6156 | "Send Standard Community attributes\n" | |
6157 | "Send Large Community attributes\n") | |
718e3744 | 6158 | { |
27c05d4d | 6159 | const char *type = argv[argc - 1]->text; |
db45f64d | 6160 | char *peer_str = argv[1]->arg; |
28c6e247 | 6161 | struct peer *peer; |
db45f64d | 6162 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 6163 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 6164 | |
28c6e247 IR |
6165 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6166 | if (!peer) | |
6167 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 6168 | |
28c6e247 IR |
6169 | if (strmatch(type, "standard")) |
6170 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6171 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 6172 | |
28c6e247 IR |
6173 | if (strmatch(type, "extended")) |
6174 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6175 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6176 | |
28c6e247 IR |
6177 | if (strmatch(type, "large")) |
6178 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6179 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 6180 | |
28c6e247 IR |
6181 | if (strmatch(type, "both")) { |
6182 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6183 | PEER_FLAG_SEND_COMMUNITY) | |
6184 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6185 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6186 | } |
28c6e247 IR |
6187 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6188 | PEER_FLAG_SEND_COMMUNITY) | |
6189 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6190 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
6191 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6192 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 6193 | } |
6194 | ||
6195 | ALIAS_HIDDEN( | |
6196 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
6197 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6198 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6199 | "Send Community attribute to this neighbor\n" | |
6200 | "Send Standard and Extended Community attributes\n" | |
6201 | "Send Standard, Large and Extended Community attributes\n" | |
6202 | "Send Extended Community attributes\n" | |
6203 | "Send Standard Community attributes\n" | |
6204 | "Send Large Community attributes\n") | |
596c17ba | 6205 | |
28c6e247 IR |
6206 | DEFUN (no_neighbor_send_community_type, |
6207 | no_neighbor_send_community_type_cmd, | |
6208 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6209 | NO_STR | |
6210 | NEIGHBOR_STR | |
6211 | NEIGHBOR_ADDR_STR2 | |
6212 | "Send Community attribute to this neighbor\n" | |
6213 | "Send Standard and Extended Community attributes\n" | |
6214 | "Send Standard, Large and Extended Community attributes\n" | |
6215 | "Send Extended Community attributes\n" | |
6216 | "Send Standard Community attributes\n" | |
6217 | "Send Large Community attributes\n") | |
718e3744 | 6218 | { |
d62a17ae | 6219 | const char *type = argv[argc - 1]->text; |
db45f64d | 6220 | char *peer_str = argv[2]->arg; |
28c6e247 | 6221 | struct peer *peer; |
db45f64d DS |
6222 | afi_t afi = bgp_node_afi(vty); |
6223 | safi_t safi = bgp_node_safi(vty); | |
6224 | ||
28c6e247 IR |
6225 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6226 | if (!peer) | |
f4b8ec07 CS |
6227 | return CMD_WARNING_CONFIG_FAILED; |
6228 | ||
28c6e247 IR |
6229 | if (strmatch(type, "standard")) |
6230 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6231 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 6232 | |
28c6e247 IR |
6233 | if (strmatch(type, "extended")) |
6234 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6235 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 6236 | |
28c6e247 IR |
6237 | if (strmatch(type, "large")) |
6238 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6239 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
6240 | |
6241 | if (strmatch(type, "both")) { | |
db45f64d | 6242 | |
28c6e247 IR |
6243 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6244 | PEER_FLAG_SEND_COMMUNITY) | |
6245 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6246 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
6247 | } |
6248 | ||
28c6e247 IR |
6249 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6250 | PEER_FLAG_SEND_COMMUNITY) | |
6251 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6252 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
6253 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6254 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 6255 | } |
6256 | ||
6257 | ALIAS_HIDDEN( | |
6258 | no_neighbor_send_community_type, | |
6259 | no_neighbor_send_community_type_hidden_cmd, | |
6260 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6261 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6262 | "Send Community attribute to this neighbor\n" | |
6263 | "Send Standard and Extended Community attributes\n" | |
6264 | "Send Standard, Large and Extended Community attributes\n" | |
6265 | "Send Extended Community attributes\n" | |
6266 | "Send Standard Community attributes\n" | |
6267 | "Send Large Community attributes\n") | |
596c17ba | 6268 | |
718e3744 | 6269 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
6270 | DEFUN (neighbor_soft_reconfiguration, |
6271 | neighbor_soft_reconfiguration_cmd, | |
6272 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6273 | NEIGHBOR_STR | |
6274 | NEIGHBOR_ADDR_STR2 | |
6275 | "Per neighbor soft reconfiguration\n" | |
6276 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6277 | { |
d62a17ae | 6278 | int idx_peer = 1; |
28c6e247 IR |
6279 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6280 | bgp_node_safi(vty), | |
6281 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6282 | } |
6283 | ||
d62a17ae | 6284 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6285 | neighbor_soft_reconfiguration_hidden_cmd, | |
6286 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6287 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6288 | "Per neighbor soft reconfiguration\n" | |
6289 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6290 | |
28c6e247 IR |
6291 | DEFUN (no_neighbor_soft_reconfiguration, |
6292 | no_neighbor_soft_reconfiguration_cmd, | |
6293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6294 | NO_STR | |
6295 | NEIGHBOR_STR | |
6296 | NEIGHBOR_ADDR_STR2 | |
6297 | "Per neighbor soft reconfiguration\n" | |
6298 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6299 | { |
d62a17ae | 6300 | int idx_peer = 2; |
28c6e247 IR |
6301 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6302 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6303 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6304 | } |
6b0655a2 | 6305 | |
d62a17ae | 6306 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6307 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6308 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6309 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6310 | "Per neighbor soft reconfiguration\n" | |
6311 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6312 | |
28c6e247 IR |
6313 | DEFUN (neighbor_route_reflector_client, |
6314 | neighbor_route_reflector_client_cmd, | |
6315 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6316 | NEIGHBOR_STR | |
6317 | NEIGHBOR_ADDR_STR2 | |
6318 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6319 | { |
d62a17ae | 6320 | int idx_peer = 1; |
28c6e247 | 6321 | struct peer *peer; |
718e3744 | 6322 | |
6323 | ||
28c6e247 IR |
6324 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6325 | if (!peer) | |
d62a17ae | 6326 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6327 | |
28c6e247 IR |
6328 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6329 | bgp_node_safi(vty), | |
6330 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 6331 | } |
6332 | ||
d62a17ae | 6333 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6334 | neighbor_route_reflector_client_hidden_cmd, | |
6335 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6336 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6337 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6338 | |
28c6e247 IR |
6339 | DEFUN (no_neighbor_route_reflector_client, |
6340 | no_neighbor_route_reflector_client_cmd, | |
6341 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6342 | NO_STR | |
6343 | NEIGHBOR_STR | |
6344 | NEIGHBOR_ADDR_STR2 | |
6345 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6346 | { |
d62a17ae | 6347 | int idx_peer = 2; |
28c6e247 IR |
6348 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6349 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6350 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 6351 | } |
6b0655a2 | 6352 | |
d62a17ae | 6353 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6354 | no_neighbor_route_reflector_client_hidden_cmd, | |
6355 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6356 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6357 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6358 | |
718e3744 | 6359 | /* neighbor route-server-client. */ |
28c6e247 IR |
6360 | DEFUN (neighbor_route_server_client, |
6361 | neighbor_route_server_client_cmd, | |
6362 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6363 | NEIGHBOR_STR | |
6364 | NEIGHBOR_ADDR_STR2 | |
6365 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6366 | { |
d62a17ae | 6367 | int idx_peer = 1; |
28c6e247 | 6368 | struct peer *peer; |
f4b8ec07 | 6369 | |
28c6e247 IR |
6370 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6371 | if (!peer) | |
d62a17ae | 6372 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 IR |
6373 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6374 | bgp_node_safi(vty), | |
6375 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 6376 | } |
6377 | ||
d62a17ae | 6378 | ALIAS_HIDDEN(neighbor_route_server_client, |
6379 | neighbor_route_server_client_hidden_cmd, | |
6380 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6381 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6382 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6383 | |
28c6e247 IR |
6384 | DEFUN (no_neighbor_route_server_client, |
6385 | no_neighbor_route_server_client_cmd, | |
6386 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6387 | NO_STR | |
6388 | NEIGHBOR_STR | |
6389 | NEIGHBOR_ADDR_STR2 | |
6390 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6391 | { |
d62a17ae | 6392 | int idx_peer = 2; |
28c6e247 IR |
6393 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6394 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6395 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 6396 | } |
6b0655a2 | 6397 | |
d62a17ae | 6398 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6399 | no_neighbor_route_server_client_hidden_cmd, | |
6400 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6401 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6402 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6403 | |
fee0f4c6 | 6404 | DEFUN (neighbor_nexthop_local_unchanged, |
6405 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6406 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6407 | NEIGHBOR_STR |
6408 | NEIGHBOR_ADDR_STR2 | |
6409 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6410 | "Leave link-local nexthop unchanged for this peer\n") | |
6411 | { | |
d62a17ae | 6412 | int idx_peer = 1; |
6413 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6414 | bgp_node_safi(vty), | |
6415 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6416 | } |
6b0655a2 | 6417 | |
fee0f4c6 | 6418 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6419 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6420 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6421 | NO_STR |
6422 | NEIGHBOR_STR | |
6423 | NEIGHBOR_ADDR_STR2 | |
6424 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6425 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6426 | { |
d62a17ae | 6427 | int idx_peer = 2; |
6428 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6429 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6430 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6431 | } |
6b0655a2 | 6432 | |
28c6e247 IR |
6433 | DEFUN (neighbor_attr_unchanged, |
6434 | neighbor_attr_unchanged_cmd, | |
6435 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6436 | NEIGHBOR_STR | |
6437 | NEIGHBOR_ADDR_STR2 | |
6438 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6439 | "As-path attribute\n" | |
6440 | "Nexthop attribute\n" | |
6441 | "Med attribute\n") | |
718e3744 | 6442 | { |
d62a17ae | 6443 | int idx = 0; |
8eeb0335 | 6444 | char *peer_str = argv[1]->arg; |
28c6e247 | 6445 | struct peer *peer; |
db45f64d DS |
6446 | bool aspath = false; |
6447 | bool nexthop = false; | |
6448 | bool med = false; | |
8eeb0335 DW |
6449 | afi_t afi = bgp_node_afi(vty); |
6450 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6451 | int ret = 0; |
f4b8ec07 | 6452 | |
28c6e247 IR |
6453 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6454 | if (!peer) | |
8eeb0335 | 6455 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6456 | |
6457 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6458 | aspath = true; |
6459 | ||
d62a17ae | 6460 | idx = 0; |
6461 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6462 | nexthop = true; |
6463 | ||
d62a17ae | 6464 | idx = 0; |
6465 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6466 | med = true; |
d62a17ae | 6467 | |
8eeb0335 | 6468 | /* no flags means all of them! */ |
db45f64d | 6469 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6470 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6471 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6472 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6473 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6474 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6475 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6476 | } else { |
28c6e247 IR |
6477 | if (!aspath) { |
6478 | if (peer_af_flag_check(peer, afi, safi, | |
6479 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6480 | ret |= peer_af_flag_unset_vty( | |
6481 | vty, peer_str, afi, safi, | |
6482 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6483 | } | |
6484 | } else | |
6485 | ret |= peer_af_flag_set_vty( | |
6486 | vty, peer_str, afi, safi, | |
6487 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6488 | ||
6489 | if (!nexthop) { | |
6490 | if (peer_af_flag_check(peer, afi, safi, | |
6491 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6492 | ret |= peer_af_flag_unset_vty( | |
6493 | vty, peer_str, afi, safi, | |
6494 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6495 | } | |
6496 | } else | |
6497 | ret |= peer_af_flag_set_vty( | |
6498 | vty, peer_str, afi, safi, | |
6499 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6500 | ||
6501 | if (!med) { | |
6502 | if (peer_af_flag_check(peer, afi, safi, | |
6503 | PEER_FLAG_MED_UNCHANGED)) { | |
6504 | ret |= peer_af_flag_unset_vty( | |
6505 | vty, peer_str, afi, safi, | |
6506 | PEER_FLAG_MED_UNCHANGED); | |
6507 | } | |
6508 | } else | |
6509 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6510 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6511 | } |
6512 | ||
28c6e247 | 6513 | return ret; |
d62a17ae | 6514 | } |
6515 | ||
6516 | ALIAS_HIDDEN( | |
6517 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6518 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6519 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6520 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6521 | "As-path attribute\n" | |
6522 | "Nexthop attribute\n" | |
6523 | "Med attribute\n") | |
596c17ba | 6524 | |
28c6e247 IR |
6525 | DEFUN (no_neighbor_attr_unchanged, |
6526 | no_neighbor_attr_unchanged_cmd, | |
6527 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6528 | NO_STR | |
6529 | NEIGHBOR_STR | |
6530 | NEIGHBOR_ADDR_STR2 | |
6531 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6532 | "As-path attribute\n" | |
6533 | "Nexthop attribute\n" | |
6534 | "Med attribute\n") | |
718e3744 | 6535 | { |
d62a17ae | 6536 | int idx = 0; |
db45f64d | 6537 | char *peer_str = argv[2]->arg; |
28c6e247 | 6538 | struct peer *peer; |
db45f64d DS |
6539 | bool aspath = false; |
6540 | bool nexthop = false; | |
6541 | bool med = false; | |
6542 | afi_t afi = bgp_node_afi(vty); | |
6543 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6544 | int ret = 0; |
f4b8ec07 | 6545 | |
28c6e247 IR |
6546 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6547 | if (!peer) | |
db45f64d | 6548 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6549 | |
6550 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6551 | aspath = true; |
6552 | ||
d62a17ae | 6553 | idx = 0; |
6554 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6555 | nexthop = true; |
6556 | ||
d62a17ae | 6557 | idx = 0; |
6558 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6559 | med = true; |
d62a17ae | 6560 | |
28c6e247 IR |
6561 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6562 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6563 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6564 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6565 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6566 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6567 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6568 | |
6569 | if (aspath) | |
28c6e247 IR |
6570 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6571 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6572 | |
6573 | if (nexthop) | |
28c6e247 IR |
6574 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6575 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6576 | |
db45f64d | 6577 | if (med) |
28c6e247 IR |
6578 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6579 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6580 | |
28c6e247 | 6581 | return ret; |
d62a17ae | 6582 | } |
6583 | ||
6584 | ALIAS_HIDDEN( | |
6585 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6586 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6587 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6588 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6589 | "As-path attribute\n" | |
6590 | "Nexthop attribute\n" | |
6591 | "Med attribute\n") | |
718e3744 | 6592 | |
28c6e247 IR |
6593 | /* EBGP multihop configuration. */ |
6594 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6595 | const char *ttl_str) | |
718e3744 | 6596 | { |
28c6e247 IR |
6597 | struct peer *peer; |
6598 | unsigned int ttl; | |
718e3744 | 6599 | |
28c6e247 IR |
6600 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6601 | if (!peer) | |
d62a17ae | 6602 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6603 | |
28c6e247 IR |
6604 | if (peer->conf_if) |
6605 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6606 | ||
6607 | if (!ttl_str) | |
6608 | ttl = MAXTTL; | |
6609 | else | |
6610 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6611 | |
28c6e247 | 6612 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6613 | } |
6614 | ||
28c6e247 | 6615 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6616 | { |
28c6e247 | 6617 | struct peer *peer; |
718e3744 | 6618 | |
28c6e247 IR |
6619 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6620 | if (!peer) | |
d62a17ae | 6621 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6622 | |
28c6e247 | 6623 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6624 | } |
6625 | ||
28c6e247 IR |
6626 | /* neighbor ebgp-multihop. */ |
6627 | DEFUN (neighbor_ebgp_multihop, | |
6628 | neighbor_ebgp_multihop_cmd, | |
6629 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6630 | NEIGHBOR_STR | |
6631 | NEIGHBOR_ADDR_STR2 | |
6632 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6633 | { |
28c6e247 IR |
6634 | int idx_peer = 1; |
6635 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6636 | } | |
f4b8ec07 | 6637 | |
28c6e247 IR |
6638 | DEFUN (neighbor_ebgp_multihop_ttl, |
6639 | neighbor_ebgp_multihop_ttl_cmd, | |
6640 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6641 | NEIGHBOR_STR | |
6642 | NEIGHBOR_ADDR_STR2 | |
6643 | "Allow EBGP neighbors not on directly connected networks\n" | |
6644 | "maximum hop count\n") | |
6645 | { | |
6646 | int idx_peer = 1; | |
6647 | int idx_number = 3; | |
6648 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6649 | argv[idx_number]->arg); | |
6650 | } | |
f4b8ec07 | 6651 | |
28c6e247 IR |
6652 | DEFUN (no_neighbor_ebgp_multihop, |
6653 | no_neighbor_ebgp_multihop_cmd, | |
6654 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6655 | NO_STR | |
6656 | NEIGHBOR_STR | |
6657 | NEIGHBOR_ADDR_STR2 | |
6658 | "Allow EBGP neighbors not on directly connected networks\n" | |
6659 | "maximum hop count\n") | |
6660 | { | |
6661 | int idx_peer = 2; | |
6662 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6663 | } |
6664 | ||
97a52c82 DA |
6665 | DEFPY (neighbor_aigp, |
6666 | neighbor_aigp_cmd, | |
6667 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor aigp", | |
6668 | NO_STR | |
6669 | NEIGHBOR_STR | |
6670 | NEIGHBOR_ADDR_STR2 | |
6671 | "Enable send and receive of the AIGP attribute per neighbor\n") | |
6672 | { | |
6673 | struct peer *peer; | |
6674 | ||
6675 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
6676 | if (!peer) | |
6677 | return CMD_WARNING_CONFIG_FAILED; | |
6678 | ||
6679 | if (no) | |
6680 | return peer_flag_unset_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6681 | else | |
6682 | return peer_flag_set_vty(vty, neighbor, PEER_FLAG_AIGP); | |
6683 | } | |
6684 | ||
d864dd9e EB |
6685 | static uint8_t get_role_by_name(const char *role_str) |
6686 | { | |
6687 | if (strncmp(role_str, "peer", 2) == 0) | |
6688 | return ROLE_PEER; | |
6689 | if (strncmp(role_str, "provider", 2) == 0) | |
6690 | return ROLE_PROVIDER; | |
6691 | if (strncmp(role_str, "customer", 2) == 0) | |
6692 | return ROLE_CUSTOMER; | |
6693 | if (strncmp(role_str, "rs-server", 4) == 0) | |
6694 | return ROLE_RS_SERVER; | |
6695 | if (strncmp(role_str, "rs-client", 4) == 0) | |
6696 | return ROLE_RS_CLIENT; | |
8f2d6021 | 6697 | return ROLE_UNDEFINED; |
d864dd9e EB |
6698 | } |
6699 | ||
6700 | static int peer_role_set_vty(struct vty *vty, const char *ip_str, | |
8f2d6021 | 6701 | const char *role_str, bool strict_mode) |
d864dd9e EB |
6702 | { |
6703 | struct peer *peer; | |
6704 | ||
7dddd1f7 | 6705 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6706 | if (!peer) |
6707 | return CMD_WARNING_CONFIG_FAILED; | |
6708 | uint8_t role = get_role_by_name(role_str); | |
6709 | ||
8f2d6021 | 6710 | if (role == ROLE_UNDEFINED) |
d864dd9e EB |
6711 | return bgp_vty_return(vty, BGP_ERR_INVALID_ROLE_NAME); |
6712 | return bgp_vty_return(vty, peer_role_set(peer, role, strict_mode)); | |
6713 | } | |
6714 | ||
6715 | static int peer_role_unset_vty(struct vty *vty, const char *ip_str) | |
6716 | { | |
6717 | struct peer *peer; | |
6718 | ||
7dddd1f7 | 6719 | peer = peer_and_group_lookup_vty(vty, ip_str); |
d864dd9e EB |
6720 | if (!peer) |
6721 | return CMD_WARNING_CONFIG_FAILED; | |
6722 | return bgp_vty_return(vty, peer_role_unset(peer)); | |
6723 | } | |
6724 | ||
8f2d6021 | 6725 | DEFPY(neighbor_role, |
d864dd9e EB |
6726 | neighbor_role_cmd, |
6727 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer>", | |
6728 | NEIGHBOR_STR | |
6729 | NEIGHBOR_ADDR_STR2 | |
6730 | "Set session role\n" | |
6731 | ROLE_STR) | |
6732 | { | |
6733 | int idx_peer = 1; | |
6734 | int idx_role = 3; | |
6735 | ||
6736 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6737 | false); |
d864dd9e EB |
6738 | } |
6739 | ||
8f2d6021 | 6740 | DEFPY(neighbor_role_strict, |
d864dd9e EB |
6741 | neighbor_role_strict_cmd, |
6742 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> strict-mode", | |
6743 | NEIGHBOR_STR | |
6744 | NEIGHBOR_ADDR_STR2 | |
6745 | "Set session role\n" | |
6746 | ROLE_STR | |
6747 | "Use additional restriction on peer\n") | |
6748 | { | |
6749 | int idx_peer = 1; | |
6750 | int idx_role = 3; | |
6751 | ||
6752 | return peer_role_set_vty(vty, argv[idx_peer]->arg, argv[idx_role]->arg, | |
8f2d6021 | 6753 | true); |
d864dd9e EB |
6754 | } |
6755 | ||
8f2d6021 | 6756 | DEFPY(no_neighbor_role, |
d864dd9e EB |
6757 | no_neighbor_role_cmd, |
6758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-role <provider|rs-server|rs-client|customer|peer> [strict-mode]", | |
6759 | NO_STR | |
6760 | NEIGHBOR_STR | |
6761 | NEIGHBOR_ADDR_STR2 | |
8f2d6021 | 6762 | "Set session role\n" |
d864dd9e | 6763 | ROLE_STR |
8f2d6021 | 6764 | "Use additional restriction on peer\n") |
d864dd9e EB |
6765 | { |
6766 | int idx_peer = 2; | |
6767 | ||
6768 | return peer_role_unset_vty(vty, argv[idx_peer]->arg); | |
6769 | } | |
6b0655a2 | 6770 | |
6ffd2079 | 6771 | /* disable-connected-check */ |
28c6e247 IR |
6772 | DEFUN (neighbor_disable_connected_check, |
6773 | neighbor_disable_connected_check_cmd, | |
6774 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6775 | NEIGHBOR_STR | |
6776 | NEIGHBOR_ADDR_STR2 | |
6777 | "one-hop away EBGP peer using loopback address\n" | |
6778 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6779 | { |
d62a17ae | 6780 | int idx_peer = 1; |
28c6e247 IR |
6781 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6782 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6783 | } |
6784 | ||
28c6e247 IR |
6785 | DEFUN (no_neighbor_disable_connected_check, |
6786 | no_neighbor_disable_connected_check_cmd, | |
6787 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6788 | NO_STR | |
6789 | NEIGHBOR_STR | |
6790 | NEIGHBOR_ADDR_STR2 | |
6791 | "one-hop away EBGP peer using loopback address\n" | |
6792 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6793 | { |
d62a17ae | 6794 | int idx_peer = 2; |
28c6e247 IR |
6795 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6796 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6797 | } |
6798 | ||
7ab294ea DA |
6799 | /* disable-link-bw-encoding-ieee */ |
6800 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6801 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6802 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6803 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6804 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6805 | { |
6806 | int idx_peer = 1; | |
6807 | ||
6808 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6809 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6810 | } | |
6811 | ||
7ab294ea DA |
6812 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6813 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6815 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6816 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6817 | { |
6818 | int idx_peer = 2; | |
6819 | ||
6820 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6821 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6822 | } | |
6823 | ||
d08c0c80 DA |
6824 | /* extended-optional-parameters */ |
6825 | DEFUN(neighbor_extended_optional_parameters, | |
6826 | neighbor_extended_optional_parameters_cmd, | |
6827 | "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6828 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6829 | "Force the extended optional parameters format for OPEN messages\n") | |
6830 | { | |
6831 | int idx_peer = 1; | |
6832 | ||
6833 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6834 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6835 | } | |
6836 | ||
6837 | DEFUN(no_neighbor_extended_optional_parameters, | |
6838 | no_neighbor_extended_optional_parameters_cmd, | |
6839 | "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6840 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6841 | "Force the extended optional parameters format for OPEN messages\n") | |
6842 | { | |
6843 | int idx_peer = 2; | |
6844 | ||
6845 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6846 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6847 | } | |
47cbc09b PM |
6848 | |
6849 | /* enforce-first-as */ | |
28c6e247 IR |
6850 | DEFUN (neighbor_enforce_first_as, |
6851 | neighbor_enforce_first_as_cmd, | |
6852 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6853 | NEIGHBOR_STR | |
6854 | NEIGHBOR_ADDR_STR2 | |
6855 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6856 | { |
6857 | int idx_peer = 1; | |
f4b8ec07 | 6858 | |
28c6e247 IR |
6859 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6860 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6861 | } |
6862 | ||
28c6e247 IR |
6863 | DEFUN (no_neighbor_enforce_first_as, |
6864 | no_neighbor_enforce_first_as_cmd, | |
6865 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6866 | NO_STR | |
6867 | NEIGHBOR_STR | |
6868 | NEIGHBOR_ADDR_STR2 | |
6869 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6870 | { |
6871 | int idx_peer = 2; | |
f4b8ec07 | 6872 | |
28c6e247 IR |
6873 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6874 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6875 | } |
6876 | ||
6877 | ||
28c6e247 IR |
6878 | DEFUN (neighbor_description, |
6879 | neighbor_description_cmd, | |
6880 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6881 | NEIGHBOR_STR | |
6882 | NEIGHBOR_ADDR_STR2 | |
6883 | "Neighbor specific description\n" | |
6884 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6885 | { |
d62a17ae | 6886 | int idx_peer = 1; |
6887 | int idx_line = 3; | |
28c6e247 | 6888 | struct peer *peer; |
d62a17ae | 6889 | char *str; |
718e3744 | 6890 | |
28c6e247 IR |
6891 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6892 | if (!peer) | |
d62a17ae | 6893 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6894 | |
d62a17ae | 6895 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6896 | |
28c6e247 | 6897 | peer_description_set(peer, str); |
718e3744 | 6898 | |
d62a17ae | 6899 | XFREE(MTYPE_TMP, str); |
718e3744 | 6900 | |
28c6e247 | 6901 | return CMD_SUCCESS; |
718e3744 | 6902 | } |
6903 | ||
28c6e247 IR |
6904 | DEFUN (no_neighbor_description, |
6905 | no_neighbor_description_cmd, | |
6906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6907 | NO_STR | |
6908 | NEIGHBOR_STR | |
6909 | NEIGHBOR_ADDR_STR2 | |
6910 | "Neighbor specific description\n") | |
718e3744 | 6911 | { |
d62a17ae | 6912 | int idx_peer = 2; |
28c6e247 | 6913 | struct peer *peer; |
f4b8ec07 | 6914 | |
28c6e247 IR |
6915 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6916 | if (!peer) | |
d62a17ae | 6917 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6918 | |
28c6e247 | 6919 | peer_description_unset(peer); |
718e3744 | 6920 | |
28c6e247 | 6921 | return CMD_SUCCESS; |
718e3744 | 6922 | } |
6923 | ||
1d80f243 | 6924 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6926 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6927 | "Neighbor specific description\n" | |
6928 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6929 | |
28c6e247 IR |
6930 | /* Neighbor update-source. */ |
6931 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6932 | const char *source_str) | |
6933 | { | |
6934 | struct peer *peer; | |
6935 | struct prefix p; | |
6936 | union sockunion su; | |
6937 | ||
6938 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6939 | if (!peer) | |
6940 | return CMD_WARNING_CONFIG_FAILED; | |
6941 | ||
6942 | if (peer->conf_if) | |
6943 | return CMD_WARNING; | |
6944 | ||
6945 | if (source_str) { | |
6946 | if (str2sockunion(source_str, &su) == 0) | |
6947 | peer_update_source_addr_set(peer, &su); | |
6948 | else { | |
6949 | if (str2prefix(source_str, &p)) { | |
6950 | vty_out(vty, | |
6951 | "%% Invalid update-source, remove prefix length \n"); | |
6952 | return CMD_WARNING_CONFIG_FAILED; | |
6953 | } else | |
6954 | peer_update_source_if_set(peer, source_str); | |
6955 | } | |
6956 | } else | |
6957 | peer_update_source_unset(peer); | |
6958 | ||
6959 | return CMD_SUCCESS; | |
6960 | } | |
6961 | ||
d62a17ae | 6962 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6963 | "IPv4 address\n" \ | |
6964 | "IPv6 address\n" \ | |
6965 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6966 | |
28c6e247 IR |
6967 | DEFUN (neighbor_update_source, |
6968 | neighbor_update_source_cmd, | |
6969 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6970 | NEIGHBOR_STR | |
6971 | NEIGHBOR_ADDR_STR2 | |
6972 | "Source of routing updates\n" | |
6973 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6974 | { |
d62a17ae | 6975 | int idx_peer = 1; |
6976 | int idx_peer_2 = 3; | |
28c6e247 | 6977 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6978 | argv[idx_peer_2]->arg); |
718e3744 | 6979 | } |
6980 | ||
28c6e247 IR |
6981 | DEFUN (no_neighbor_update_source, |
6982 | no_neighbor_update_source_cmd, | |
6983 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6984 | NO_STR | |
6985 | NEIGHBOR_STR | |
6986 | NEIGHBOR_ADDR_STR2 | |
6987 | "Source of routing updates\n" | |
6988 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6989 | { |
d62a17ae | 6990 | int idx_peer = 2; |
28c6e247 | 6991 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6992 | } |
6b0655a2 | 6993 | |
d62a17ae | 6994 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6995 | afi_t afi, safi_t safi, | |
6996 | const char *rmap, int set) | |
718e3744 | 6997 | { |
d62a17ae | 6998 | int ret; |
6999 | struct peer *peer; | |
80912664 | 7000 | struct route_map *route_map = NULL; |
718e3744 | 7001 | |
d62a17ae | 7002 | peer = peer_and_group_lookup_vty(vty, peer_str); |
7003 | if (!peer) | |
7004 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7005 | |
1de27621 | 7006 | if (set) { |
80912664 DS |
7007 | if (rmap) |
7008 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
7009 | ret = peer_default_originate_set(peer, afi, safi, |
7010 | rmap, route_map); | |
7011 | } else | |
d62a17ae | 7012 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 7013 | |
d62a17ae | 7014 | return bgp_vty_return(vty, ret); |
718e3744 | 7015 | } |
7016 | ||
7017 | /* neighbor default-originate. */ | |
7018 | DEFUN (neighbor_default_originate, | |
7019 | neighbor_default_originate_cmd, | |
9ccf14f7 | 7020 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 7021 | NEIGHBOR_STR |
7022 | NEIGHBOR_ADDR_STR2 | |
7023 | "Originate default route to this neighbor\n") | |
7024 | { | |
d62a17ae | 7025 | int idx_peer = 1; |
7026 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7027 | bgp_node_afi(vty), | |
7028 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 7029 | } |
7030 | ||
d62a17ae | 7031 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
7032 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
7033 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7034 | "Originate default route to this neighbor\n") | |
596c17ba | 7035 | |
718e3744 | 7036 | DEFUN (neighbor_default_originate_rmap, |
7037 | neighbor_default_originate_rmap_cmd, | |
70dd370f | 7038 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
718e3744 | 7039 | NEIGHBOR_STR |
7040 | NEIGHBOR_ADDR_STR2 | |
7041 | "Originate default route to this neighbor\n" | |
7042 | "Route-map to specify criteria to originate default\n" | |
7043 | "route-map name\n") | |
7044 | { | |
d62a17ae | 7045 | int idx_peer = 1; |
7046 | int idx_word = 4; | |
7047 | return peer_default_originate_set_vty( | |
7048 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7049 | argv[idx_word]->arg, 1); | |
718e3744 | 7050 | } |
7051 | ||
d62a17ae | 7052 | ALIAS_HIDDEN( |
7053 | neighbor_default_originate_rmap, | |
7054 | neighbor_default_originate_rmap_hidden_cmd, | |
70dd370f | 7055 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
d62a17ae | 7056 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7057 | "Originate default route to this neighbor\n" | |
7058 | "Route-map to specify criteria to originate default\n" | |
7059 | "route-map name\n") | |
596c17ba | 7060 | |
718e3744 | 7061 | DEFUN (no_neighbor_default_originate, |
7062 | no_neighbor_default_originate_cmd, | |
70dd370f | 7063 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
718e3744 | 7064 | NO_STR |
7065 | NEIGHBOR_STR | |
7066 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
7067 | "Originate default route to this neighbor\n" |
7068 | "Route-map to specify criteria to originate default\n" | |
7069 | "route-map name\n") | |
718e3744 | 7070 | { |
d62a17ae | 7071 | int idx_peer = 2; |
7072 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
7073 | bgp_node_afi(vty), | |
7074 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 7075 | } |
7076 | ||
d62a17ae | 7077 | ALIAS_HIDDEN( |
7078 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
70dd370f | 7079 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
d62a17ae | 7080 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7081 | "Originate default route to this neighbor\n" | |
7082 | "Route-map to specify criteria to originate default\n" | |
7083 | "route-map name\n") | |
596c17ba | 7084 | |
6b0655a2 | 7085 | |
28c6e247 IR |
7086 | /* Set neighbor's BGP port. */ |
7087 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
7088 | const char *port_str) | |
718e3744 | 7089 | { |
28c6e247 IR |
7090 | struct peer *peer; |
7091 | uint16_t port; | |
7092 | struct servent *sp; | |
7093 | ||
a3aecc99 | 7094 | peer = peer_and_group_lookup_vty(vty, ip_str); |
28c6e247 IR |
7095 | if (!peer) |
7096 | return CMD_WARNING_CONFIG_FAILED; | |
7097 | ||
7098 | if (!port_str) { | |
7099 | sp = getservbyname("bgp", "tcp"); | |
7100 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
7101 | } else { | |
7102 | port = strtoul(port_str, NULL, 10); | |
7103 | } | |
718e3744 | 7104 | |
28c6e247 | 7105 | peer_port_set(peer, port); |
718e3744 | 7106 | |
28c6e247 IR |
7107 | return CMD_SUCCESS; |
7108 | } | |
f4b8ec07 | 7109 | |
28c6e247 IR |
7110 | /* Set specified peer's BGP port. */ |
7111 | DEFUN (neighbor_port, | |
7112 | neighbor_port_cmd, | |
a3aecc99 | 7113 | "neighbor <A.B.C.D|X:X::X:X|WORD> port (0-65535)", |
28c6e247 | 7114 | NEIGHBOR_STR |
a3aecc99 | 7115 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7116 | "Neighbor's BGP port\n" |
7117 | "TCP port number\n") | |
7118 | { | |
7119 | int idx_ip = 1; | |
7120 | int idx_number = 3; | |
7121 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
7122 | argv[idx_number]->arg); | |
f4b8ec07 | 7123 | } |
6b0655a2 | 7124 | |
28c6e247 IR |
7125 | DEFUN (no_neighbor_port, |
7126 | no_neighbor_port_cmd, | |
a3aecc99 | 7127 | "no neighbor <A.B.C.D|X:X::X:X|WORD> port [(0-65535)]", |
28c6e247 IR |
7128 | NO_STR |
7129 | NEIGHBOR_STR | |
a3aecc99 | 7130 | NEIGHBOR_ADDR_STR2 |
28c6e247 IR |
7131 | "Neighbor's BGP port\n" |
7132 | "TCP port number\n") | |
718e3744 | 7133 | { |
f4b8ec07 | 7134 | int idx_ip = 2; |
28c6e247 IR |
7135 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
7136 | } | |
7137 | ||
7138 | ||
7139 | /* neighbor weight. */ | |
7140 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
7141 | safi_t safi, const char *weight_str) | |
7142 | { | |
7143 | int ret; | |
7144 | struct peer *peer; | |
7145 | unsigned long weight; | |
718e3744 | 7146 | |
28c6e247 IR |
7147 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7148 | if (!peer) | |
7149 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7150 | |
28c6e247 | 7151 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 7152 | |
28c6e247 IR |
7153 | ret = peer_weight_set(peer, afi, safi, weight); |
7154 | return bgp_vty_return(vty, ret); | |
718e3744 | 7155 | } |
7156 | ||
28c6e247 IR |
7157 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7158 | safi_t safi) | |
718e3744 | 7159 | { |
28c6e247 IR |
7160 | int ret; |
7161 | struct peer *peer; | |
f4b8ec07 | 7162 | |
28c6e247 IR |
7163 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7164 | if (!peer) | |
d62a17ae | 7165 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7166 | |
28c6e247 IR |
7167 | ret = peer_weight_unset(peer, afi, safi); |
7168 | return bgp_vty_return(vty, ret); | |
7169 | } | |
f4b8ec07 | 7170 | |
28c6e247 IR |
7171 | DEFUN (neighbor_weight, |
7172 | neighbor_weight_cmd, | |
7173 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7174 | NEIGHBOR_STR | |
7175 | NEIGHBOR_ADDR_STR2 | |
7176 | "Set default weight for routes from this neighbor\n" | |
7177 | "default weight\n") | |
7178 | { | |
7179 | int idx_peer = 1; | |
7180 | int idx_number = 3; | |
7181 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7182 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 7183 | } |
7184 | ||
d62a17ae | 7185 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
7186 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
7187 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7188 | "Set default weight for routes from this neighbor\n" | |
7189 | "default weight\n") | |
596c17ba | 7190 | |
28c6e247 IR |
7191 | DEFUN (no_neighbor_weight, |
7192 | no_neighbor_weight_cmd, | |
7193 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7194 | NO_STR | |
7195 | NEIGHBOR_STR | |
7196 | NEIGHBOR_ADDR_STR2 | |
7197 | "Set default weight for routes from this neighbor\n" | |
7198 | "default weight\n") | |
718e3744 | 7199 | { |
d62a17ae | 7200 | int idx_peer = 2; |
28c6e247 IR |
7201 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
7202 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 7203 | } |
7204 | ||
d62a17ae | 7205 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
7206 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
7207 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7208 | "Set default weight for routes from this neighbor\n" | |
7209 | "default weight\n") | |
596c17ba | 7210 | |
6b0655a2 | 7211 | |
718e3744 | 7212 | /* Override capability negotiation. */ |
c36bc05f IR |
7213 | DEFUN (neighbor_override_capability, |
7214 | neighbor_override_capability_cmd, | |
7215 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7216 | NEIGHBOR_STR | |
7217 | NEIGHBOR_ADDR_STR2 | |
7218 | "Override capability negotiation result\n") | |
718e3744 | 7219 | { |
d62a17ae | 7220 | int idx_peer = 1; |
c36bc05f IR |
7221 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7222 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7223 | } |
7224 | ||
c36bc05f IR |
7225 | DEFUN (no_neighbor_override_capability, |
7226 | no_neighbor_override_capability_cmd, | |
7227 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
7228 | NO_STR | |
7229 | NEIGHBOR_STR | |
7230 | NEIGHBOR_ADDR_STR2 | |
7231 | "Override capability negotiation result\n") | |
718e3744 | 7232 | { |
d62a17ae | 7233 | int idx_peer = 2; |
c36bc05f IR |
7234 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7235 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 7236 | } |
6b0655a2 | 7237 | |
c36bc05f IR |
7238 | DEFUN (neighbor_strict_capability, |
7239 | neighbor_strict_capability_cmd, | |
7240 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7241 | NEIGHBOR_STR | |
7242 | NEIGHBOR_ADDR_STR2 | |
7243 | "Strict capability negotiation match\n") | |
718e3744 | 7244 | { |
9fb964de PM |
7245 | int idx_peer = 1; |
7246 | ||
c36bc05f IR |
7247 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
7248 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7249 | } |
7250 | ||
c36bc05f IR |
7251 | DEFUN (no_neighbor_strict_capability, |
7252 | no_neighbor_strict_capability_cmd, | |
7253 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
7254 | NO_STR | |
7255 | NEIGHBOR_STR | |
7256 | NEIGHBOR_ADDR_STR2 | |
7257 | "Strict capability negotiation match\n") | |
718e3744 | 7258 | { |
9fb964de | 7259 | int idx_peer = 2; |
8611c7f3 | 7260 | |
c36bc05f IR |
7261 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
7262 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 7263 | } |
6b0655a2 | 7264 | |
28c6e247 IR |
7265 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
7266 | const char *keep_str, const char *hold_str) | |
718e3744 | 7267 | { |
28c6e247 IR |
7268 | int ret; |
7269 | struct peer *peer; | |
7270 | uint32_t keepalive; | |
7271 | uint32_t holdtime; | |
718e3744 | 7272 | |
28c6e247 IR |
7273 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7274 | if (!peer) | |
d62a17ae | 7275 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7276 | |
28c6e247 IR |
7277 | keepalive = strtoul(keep_str, NULL, 10); |
7278 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 7279 | |
28c6e247 | 7280 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 7281 | |
28c6e247 | 7282 | return bgp_vty_return(vty, ret); |
718e3744 | 7283 | } |
6b0655a2 | 7284 | |
28c6e247 | 7285 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7286 | { |
28c6e247 IR |
7287 | int ret; |
7288 | struct peer *peer; | |
718e3744 | 7289 | |
28c6e247 IR |
7290 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7291 | if (!peer) | |
d62a17ae | 7292 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7293 | |
28c6e247 | 7294 | ret = peer_timers_unset(peer); |
718e3744 | 7295 | |
28c6e247 | 7296 | return bgp_vty_return(vty, ret); |
718e3744 | 7297 | } |
6b0655a2 | 7298 | |
28c6e247 IR |
7299 | DEFUN (neighbor_timers, |
7300 | neighbor_timers_cmd, | |
7301 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
7302 | NEIGHBOR_STR | |
7303 | NEIGHBOR_ADDR_STR2 | |
7304 | "BGP per neighbor timers\n" | |
7305 | "Keepalive interval\n" | |
7306 | "Holdtime\n") | |
718e3744 | 7307 | { |
f4b8ec07 | 7308 | int idx_peer = 1; |
28c6e247 IR |
7309 | int idx_number = 3; |
7310 | int idx_number_2 = 4; | |
7311 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
7312 | argv[idx_number]->arg, | |
7313 | argv[idx_number_2]->arg); | |
7314 | } | |
7315 | ||
7316 | DEFUN (no_neighbor_timers, | |
7317 | no_neighbor_timers_cmd, | |
7318 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
7319 | NO_STR | |
7320 | NEIGHBOR_STR | |
7321 | NEIGHBOR_ADDR_STR2 | |
7322 | "BGP per neighbor timers\n" | |
7323 | "Keepalive interval\n" | |
7324 | "Holdtime\n") | |
7325 | { | |
7326 | int idx_peer = 2; | |
7327 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
7328 | } | |
7329 | ||
7330 | ||
7331 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
7332 | const char *time_str) | |
7333 | { | |
7334 | int ret; | |
7335 | struct peer *peer; | |
7336 | uint32_t connect; | |
718e3744 | 7337 | |
28c6e247 IR |
7338 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7339 | if (!peer) | |
d62a17ae | 7340 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7341 | |
28c6e247 IR |
7342 | connect = strtoul(time_str, NULL, 10); |
7343 | ||
7344 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 7345 | |
28c6e247 | 7346 | return bgp_vty_return(vty, ret); |
718e3744 | 7347 | } |
7348 | ||
28c6e247 | 7349 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 7350 | { |
28c6e247 IR |
7351 | int ret; |
7352 | struct peer *peer; | |
718e3744 | 7353 | |
28c6e247 IR |
7354 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7355 | if (!peer) | |
d62a17ae | 7356 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7357 | |
28c6e247 IR |
7358 | ret = peer_timers_connect_unset(peer); |
7359 | ||
7360 | return bgp_vty_return(vty, ret); | |
7361 | } | |
7362 | ||
7363 | DEFUN (neighbor_timers_connect, | |
7364 | neighbor_timers_connect_cmd, | |
7365 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7366 | NEIGHBOR_STR | |
7367 | NEIGHBOR_ADDR_STR2 | |
7368 | "BGP per neighbor timers\n" | |
7369 | "BGP connect timer\n" | |
7370 | "Connect timer\n") | |
7371 | { | |
7372 | int idx_peer = 1; | |
7373 | int idx_number = 4; | |
7374 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
7375 | argv[idx_number]->arg); | |
7376 | } | |
718e3744 | 7377 | |
28c6e247 IR |
7378 | DEFUN (no_neighbor_timers_connect, |
7379 | no_neighbor_timers_connect_cmd, | |
7380 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7381 | NO_STR | |
7382 | NEIGHBOR_STR | |
7383 | NEIGHBOR_ADDR_STR2 | |
7384 | "BGP per neighbor timers\n" | |
7385 | "BGP connect timer\n" | |
7386 | "Connect timer\n") | |
7387 | { | |
7388 | int idx_peer = 2; | |
7389 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 7390 | } |
7391 | ||
d43114f3 DS |
7392 | DEFPY (neighbor_timers_delayopen, |
7393 | neighbor_timers_delayopen_cmd, | |
7394 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
7395 | NEIGHBOR_STR | |
7396 | NEIGHBOR_ADDR_STR2 | |
7397 | "BGP per neighbor timers\n" | |
7398 | "RFC 4271 DelayOpenTimer\n" | |
7399 | "DelayOpenTime timer interval\n") | |
7400 | { | |
7401 | struct peer *peer; | |
7402 | ||
7403 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7404 | if (!peer) | |
7405 | return CMD_WARNING_CONFIG_FAILED; | |
7406 | ||
7407 | if (!interval) { | |
7408 | if (peer_timers_delayopen_unset(peer)) | |
7409 | return CMD_WARNING_CONFIG_FAILED; | |
7410 | } else { | |
7411 | if (peer_timers_delayopen_set(peer, interval)) | |
7412 | return CMD_WARNING_CONFIG_FAILED; | |
7413 | } | |
7414 | ||
7415 | return CMD_SUCCESS; | |
7416 | } | |
7417 | ||
7418 | DEFPY (no_neighbor_timers_delayopen, | |
7419 | no_neighbor_timers_delayopen_cmd, | |
7420 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
7421 | NO_STR | |
7422 | NEIGHBOR_STR | |
7423 | NEIGHBOR_ADDR_STR2 | |
7424 | "BGP per neighbor timers\n" | |
7425 | "RFC 4271 DelayOpenTimer\n" | |
7426 | "DelayOpenTime timer interval\n") | |
7427 | { | |
7428 | struct peer *peer; | |
7429 | ||
7430 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7431 | if (!peer) | |
7432 | return CMD_WARNING_CONFIG_FAILED; | |
7433 | ||
7434 | if (peer_timers_delayopen_unset(peer)) | |
7435 | return CMD_WARNING_CONFIG_FAILED; | |
7436 | ||
7437 | return CMD_SUCCESS; | |
7438 | } | |
7439 | ||
28c6e247 IR |
7440 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
7441 | const char *time_str, int set) | |
718e3744 | 7442 | { |
28c6e247 IR |
7443 | int ret; |
7444 | struct peer *peer; | |
7445 | uint32_t routeadv = 0; | |
718e3744 | 7446 | |
28c6e247 IR |
7447 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7448 | if (!peer) | |
d62a17ae | 7449 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7450 | |
28c6e247 IR |
7451 | if (time_str) |
7452 | routeadv = strtoul(time_str, NULL, 10); | |
7453 | ||
7454 | if (set) | |
7455 | ret = peer_advertise_interval_set(peer, routeadv); | |
7456 | else | |
7457 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 7458 | |
28c6e247 | 7459 | return bgp_vty_return(vty, ret); |
718e3744 | 7460 | } |
7461 | ||
28c6e247 IR |
7462 | DEFUN (neighbor_advertise_interval, |
7463 | neighbor_advertise_interval_cmd, | |
7464 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7465 | NEIGHBOR_STR | |
7466 | NEIGHBOR_ADDR_STR2 | |
7467 | "Minimum interval between sending BGP routing updates\n" | |
7468 | "time in seconds\n") | |
718e3744 | 7469 | { |
28c6e247 IR |
7470 | int idx_peer = 1; |
7471 | int idx_number = 3; | |
7472 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
7473 | argv[idx_number]->arg, 1); | |
7474 | } | |
f4b8ec07 | 7475 | |
28c6e247 IR |
7476 | DEFUN (no_neighbor_advertise_interval, |
7477 | no_neighbor_advertise_interval_cmd, | |
7478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7479 | NO_STR | |
7480 | NEIGHBOR_STR | |
7481 | NEIGHBOR_ADDR_STR2 | |
7482 | "Minimum interval between sending BGP routing updates\n" | |
7483 | "time in seconds\n") | |
7484 | { | |
7485 | int idx_peer = 2; | |
7486 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 7487 | } |
7488 | ||
6b0655a2 | 7489 | |
518f0eb1 DS |
7490 | /* Time to wait before processing route-map updates */ |
7491 | DEFUN (bgp_set_route_map_delay_timer, | |
7492 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7493 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7494 | SET_STR |
7495 | "BGP route-map delay timer\n" | |
7496 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7497 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7498 | { |
d62a17ae | 7499 | int idx_number = 3; |
d7c0a89a | 7500 | uint32_t rmap_delay_timer; |
d62a17ae | 7501 | |
7502 | if (argv[idx_number]->arg) { | |
7503 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7504 | bm->rmap_update_timer = rmap_delay_timer; | |
7505 | ||
7506 | /* if the dynamic update handling is being disabled, and a timer | |
7507 | * is | |
7508 | * running, stop the timer and act as if the timer has already | |
7509 | * fired. | |
7510 | */ | |
7511 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
fa5806c3 | 7512 | THREAD_OFF(bm->t_rmap_update); |
d62a17ae | 7513 | thread_execute(bm->master, bgp_route_map_update_timer, |
7514 | NULL, 0); | |
7515 | } | |
7516 | return CMD_SUCCESS; | |
7517 | } else { | |
7518 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7519 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7520 | } |
518f0eb1 DS |
7521 | } |
7522 | ||
7523 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7524 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7525 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7526 | NO_STR |
3a2d747c | 7527 | BGP_STR |
518f0eb1 | 7528 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7529 | "Reset to default time to wait for processing route-map changes\n" |
7530 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7531 | { |
518f0eb1 | 7532 | |
d62a17ae | 7533 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7534 | |
d62a17ae | 7535 | return CMD_SUCCESS; |
518f0eb1 DS |
7536 | } |
7537 | ||
28c6e247 IR |
7538 | /* neighbor interface */ |
7539 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7540 | const char *str) | |
718e3744 | 7541 | { |
28c6e247 | 7542 | struct peer *peer; |
718e3744 | 7543 | |
28c6e247 IR |
7544 | peer = peer_lookup_vty(vty, ip_str); |
7545 | if (!peer || peer->conf_if) { | |
7546 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7547 | return CMD_WARNING_CONFIG_FAILED; | |
7548 | } | |
718e3744 | 7549 | |
28c6e247 IR |
7550 | if (str) |
7551 | peer_interface_set(peer, str); | |
7552 | else | |
7553 | peer_interface_unset(peer); | |
718e3744 | 7554 | |
28c6e247 | 7555 | return CMD_SUCCESS; |
718e3744 | 7556 | } |
7557 | ||
28c6e247 IR |
7558 | DEFUN (neighbor_interface, |
7559 | neighbor_interface_cmd, | |
7560 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7561 | NEIGHBOR_STR | |
7562 | NEIGHBOR_ADDR_STR | |
7563 | "Interface\n" | |
7564 | "Interface name\n") | |
718e3744 | 7565 | { |
28c6e247 IR |
7566 | int idx_ip = 1; |
7567 | int idx_word = 3; | |
294d8425 | 7568 | |
28c6e247 IR |
7569 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7570 | } | |
f4b8ec07 | 7571 | |
28c6e247 IR |
7572 | DEFUN (no_neighbor_interface, |
7573 | no_neighbor_interface_cmd, | |
294d8425 | 7574 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7575 | NO_STR |
7576 | NEIGHBOR_STR | |
294d8425 | 7577 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7578 | "Interface\n" |
7579 | "Interface name\n") | |
7580 | { | |
7581 | int idx_peer = 2; | |
294d8425 | 7582 | |
28c6e247 | 7583 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7584 | } |
6b0655a2 | 7585 | |
718e3744 | 7586 | DEFUN (neighbor_distribute_list, |
7587 | neighbor_distribute_list_cmd, | |
c60dec36 | 7588 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7589 | NEIGHBOR_STR |
7590 | NEIGHBOR_ADDR_STR2 | |
7591 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7592 | "IP Access-list name\n" |
7593 | "Filter incoming updates\n" | |
7594 | "Filter outgoing updates\n") | |
7595 | { | |
d62a17ae | 7596 | int idx_peer = 1; |
7597 | int idx_acl = 3; | |
7598 | int direct, ret; | |
7599 | struct peer *peer; | |
a8206004 | 7600 | |
d62a17ae | 7601 | const char *pstr = argv[idx_peer]->arg; |
7602 | const char *acl = argv[idx_acl]->arg; | |
7603 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7604 | |
d62a17ae | 7605 | peer = peer_and_group_lookup_vty(vty, pstr); |
7606 | if (!peer) | |
7607 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7608 | |
d62a17ae | 7609 | /* Check filter direction. */ |
7610 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7611 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7612 | direct, acl); | |
a8206004 | 7613 | |
d62a17ae | 7614 | return bgp_vty_return(vty, ret); |
718e3744 | 7615 | } |
7616 | ||
d62a17ae | 7617 | ALIAS_HIDDEN( |
7618 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7619 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7620 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7621 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7622 | "IP Access-list name\n" |
7623 | "Filter incoming updates\n" | |
7624 | "Filter outgoing updates\n") | |
596c17ba | 7625 | |
718e3744 | 7626 | DEFUN (no_neighbor_distribute_list, |
7627 | no_neighbor_distribute_list_cmd, | |
c60dec36 | 7628 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7629 | NO_STR |
7630 | NEIGHBOR_STR | |
7631 | NEIGHBOR_ADDR_STR2 | |
7632 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7633 | "IP Access-list name\n" |
7634 | "Filter incoming updates\n" | |
7635 | "Filter outgoing updates\n") | |
7636 | { | |
d62a17ae | 7637 | int idx_peer = 2; |
7638 | int direct, ret; | |
7639 | struct peer *peer; | |
a8206004 | 7640 | |
d62a17ae | 7641 | const char *pstr = argv[idx_peer]->arg; |
7642 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7643 | |
d62a17ae | 7644 | peer = peer_and_group_lookup_vty(vty, pstr); |
7645 | if (!peer) | |
7646 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7647 | |
d62a17ae | 7648 | /* Check filter direction. */ |
7649 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7650 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7651 | direct); | |
a8206004 | 7652 | |
d62a17ae | 7653 | return bgp_vty_return(vty, ret); |
718e3744 | 7654 | } |
6b0655a2 | 7655 | |
d62a17ae | 7656 | ALIAS_HIDDEN( |
7657 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7658 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7659 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7660 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7661 | "IP Access-list name\n" |
7662 | "Filter incoming updates\n" | |
7663 | "Filter outgoing updates\n") | |
596c17ba | 7664 | |
718e3744 | 7665 | /* Set prefix list to the peer. */ |
642ef664 IR |
7666 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7667 | afi_t afi, safi_t safi, | |
7668 | const char *name_str, | |
7669 | const char *direct_str) | |
718e3744 | 7670 | { |
642ef664 IR |
7671 | int ret; |
7672 | int direct = FILTER_IN; | |
7673 | struct peer *peer; | |
718e3744 | 7674 | |
642ef664 IR |
7675 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7676 | if (!peer) | |
d62a17ae | 7677 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7678 | |
642ef664 IR |
7679 | /* Check filter direction. */ |
7680 | if (strncmp(direct_str, "i", 1) == 0) | |
7681 | direct = FILTER_IN; | |
7682 | else if (strncmp(direct_str, "o", 1) == 0) | |
7683 | direct = FILTER_OUT; | |
718e3744 | 7684 | |
642ef664 | 7685 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7686 | |
642ef664 IR |
7687 | return bgp_vty_return(vty, ret); |
7688 | } | |
7689 | ||
7690 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7691 | afi_t afi, safi_t safi, | |
7692 | const char *direct_str) | |
7693 | { | |
7694 | int ret; | |
7695 | struct peer *peer; | |
7696 | int direct = FILTER_IN; | |
7697 | ||
7698 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7699 | if (!peer) | |
7700 | return CMD_WARNING_CONFIG_FAILED; | |
7701 | ||
7702 | /* Check filter direction. */ | |
7703 | if (strncmp(direct_str, "i", 1) == 0) | |
7704 | direct = FILTER_IN; | |
7705 | else if (strncmp(direct_str, "o", 1) == 0) | |
7706 | direct = FILTER_OUT; | |
7707 | ||
7708 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7709 | ||
7710 | return bgp_vty_return(vty, ret); | |
7711 | } | |
7712 | ||
7713 | DEFUN (neighbor_prefix_list, | |
7714 | neighbor_prefix_list_cmd, | |
7715 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7716 | NEIGHBOR_STR | |
7717 | NEIGHBOR_ADDR_STR2 | |
7718 | "Filter updates to/from this neighbor\n" | |
7719 | "Name of a prefix list\n" | |
7720 | "Filter incoming updates\n" | |
7721 | "Filter outgoing updates\n") | |
7722 | { | |
7723 | int idx_peer = 1; | |
7724 | int idx_word = 3; | |
7725 | int idx_in_out = 4; | |
7726 | return peer_prefix_list_set_vty( | |
7727 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7728 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7729 | } |
7730 | ||
d62a17ae | 7731 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7732 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7733 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7734 | "Filter updates to/from this neighbor\n" | |
7735 | "Name of a prefix list\n" | |
7736 | "Filter incoming updates\n" | |
7737 | "Filter outgoing updates\n") | |
596c17ba | 7738 | |
642ef664 IR |
7739 | DEFUN (no_neighbor_prefix_list, |
7740 | no_neighbor_prefix_list_cmd, | |
7741 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7742 | NO_STR | |
7743 | NEIGHBOR_STR | |
7744 | NEIGHBOR_ADDR_STR2 | |
7745 | "Filter updates to/from this neighbor\n" | |
7746 | "Name of a prefix list\n" | |
7747 | "Filter incoming updates\n" | |
7748 | "Filter outgoing updates\n") | |
7749 | { | |
7750 | int idx_peer = 2; | |
7751 | int idx_in_out = 5; | |
7752 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7753 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7754 | argv[idx_in_out]->arg); | |
7755 | } | |
7756 | ||
7757 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7759 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7760 | "Filter updates to/from this neighbor\n" | |
7761 | "Name of a prefix list\n" | |
7762 | "Filter incoming updates\n" | |
7763 | "Filter outgoing updates\n") | |
7764 | ||
d62a17ae | 7765 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7766 | safi_t safi, const char *name_str, | |
7767 | const char *direct_str) | |
718e3744 | 7768 | { |
d62a17ae | 7769 | int ret; |
7770 | struct peer *peer; | |
7771 | int direct = FILTER_IN; | |
718e3744 | 7772 | |
d62a17ae | 7773 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7774 | if (!peer) | |
7775 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7776 | |
d62a17ae | 7777 | /* Check filter direction. */ |
7778 | if (strncmp(direct_str, "i", 1) == 0) | |
7779 | direct = FILTER_IN; | |
7780 | else if (strncmp(direct_str, "o", 1) == 0) | |
7781 | direct = FILTER_OUT; | |
718e3744 | 7782 | |
d62a17ae | 7783 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7784 | |
d62a17ae | 7785 | return bgp_vty_return(vty, ret); |
718e3744 | 7786 | } |
7787 | ||
d62a17ae | 7788 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7789 | safi_t safi, const char *direct_str) | |
718e3744 | 7790 | { |
d62a17ae | 7791 | int ret; |
7792 | struct peer *peer; | |
7793 | int direct = FILTER_IN; | |
718e3744 | 7794 | |
d62a17ae | 7795 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7796 | if (!peer) | |
7797 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7798 | |
d62a17ae | 7799 | /* Check filter direction. */ |
7800 | if (strncmp(direct_str, "i", 1) == 0) | |
7801 | direct = FILTER_IN; | |
7802 | else if (strncmp(direct_str, "o", 1) == 0) | |
7803 | direct = FILTER_OUT; | |
718e3744 | 7804 | |
d62a17ae | 7805 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7806 | |
d62a17ae | 7807 | return bgp_vty_return(vty, ret); |
718e3744 | 7808 | } |
7809 | ||
7810 | DEFUN (neighbor_filter_list, | |
7811 | neighbor_filter_list_cmd, | |
de71d43e | 7812 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7813 | NEIGHBOR_STR |
7814 | NEIGHBOR_ADDR_STR2 | |
7815 | "Establish BGP filters\n" | |
7816 | "AS path access-list name\n" | |
7817 | "Filter incoming routes\n" | |
7818 | "Filter outgoing routes\n") | |
7819 | { | |
d62a17ae | 7820 | int idx_peer = 1; |
7821 | int idx_word = 3; | |
7822 | int idx_in_out = 4; | |
7823 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7824 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7825 | argv[idx_in_out]->arg); | |
718e3744 | 7826 | } |
7827 | ||
d62a17ae | 7828 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
de71d43e | 7829 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7830 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7831 | "Establish BGP filters\n" | |
7832 | "AS path access-list name\n" | |
7833 | "Filter incoming routes\n" | |
7834 | "Filter outgoing routes\n") | |
596c17ba | 7835 | |
718e3744 | 7836 | DEFUN (no_neighbor_filter_list, |
7837 | no_neighbor_filter_list_cmd, | |
de71d43e | 7838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7839 | NO_STR |
7840 | NEIGHBOR_STR | |
7841 | NEIGHBOR_ADDR_STR2 | |
7842 | "Establish BGP filters\n" | |
7843 | "AS path access-list name\n" | |
7844 | "Filter incoming routes\n" | |
7845 | "Filter outgoing routes\n") | |
7846 | { | |
d62a17ae | 7847 | int idx_peer = 2; |
7848 | int idx_in_out = 5; | |
7849 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7850 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7851 | argv[idx_in_out]->arg); | |
718e3744 | 7852 | } |
6b0655a2 | 7853 | |
d62a17ae | 7854 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
de71d43e | 7855 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7856 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7857 | "Establish BGP filters\n" | |
7858 | "AS path access-list name\n" | |
7859 | "Filter incoming routes\n" | |
7860 | "Filter outgoing routes\n") | |
596c17ba | 7861 | |
7f7940e6 MK |
7862 | /* Set advertise-map to the peer. */ |
7863 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7864 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7865 | const char *advertise_str, |
7866 | const char *condition_str, bool condition, | |
7867 | bool set) | |
7f7940e6 MK |
7868 | { |
7869 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7870 | struct peer *peer; | |
7871 | struct route_map *advertise_map; | |
7872 | struct route_map *condition_map; | |
7873 | ||
7874 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7875 | if (!peer) | |
7876 | return ret; | |
7877 | ||
7878 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7879 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7880 | ||
cf2ad4d8 MK |
7881 | if (set) |
7882 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7883 | advertise_map, condition_str, | |
7884 | condition_map, condition); | |
7885 | else | |
7886 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7887 | advertise_map, condition_str, | |
7888 | condition_map, condition); | |
7f7940e6 MK |
7889 | |
7890 | return bgp_vty_return(vty, ret); | |
7891 | } | |
7892 | ||
389e4f92 QY |
7893 | DEFPY (bgp_condadv_period, |
7894 | bgp_condadv_period_cmd, | |
7895 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7896 | NO_STR | |
7897 | BGP_STR | |
7898 | "Conditional advertisement settings\n" | |
7899 | "Set period to rescan BGP table to check if condition is met\n" | |
7900 | "Period between BGP table scans, in seconds; default 60\n") | |
7901 | { | |
7902 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7903 | ||
7904 | bgp->condition_check_period = | |
7905 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7906 | ||
7907 | return CMD_SUCCESS; | |
7908 | } | |
7909 | ||
cf2ad4d8 | 7910 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7911 | neighbor_advertise_map_cmd, |
3ccddc25 | 7912 | "[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 | 7913 | NO_STR |
7f7940e6 MK |
7914 | NEIGHBOR_STR |
7915 | NEIGHBOR_ADDR_STR2 | |
7916 | "Route-map to conditionally advertise routes\n" | |
7917 | "Name of advertise map\n" | |
7918 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7919 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7920 | "Name of the exist or non exist map\n") |
7f7940e6 | 7921 | { |
7f7940e6 MK |
7922 | bool condition = CONDITION_EXIST; |
7923 | ||
52b84062 | 7924 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7925 | condition = CONDITION_NON_EXIST; |
7926 | ||
52b84062 MK |
7927 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7928 | bgp_node_safi(vty), advertise_str, | |
7929 | condition_str, condition, !no); | |
7f7940e6 MK |
7930 | } |
7931 | ||
7932 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
3ccddc25 | 7933 | "[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 |
7934 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7935 | "Route-map to conditionally advertise routes\n" | |
7936 | "Name of advertise map\n" | |
7937 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7938 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7939 | "Name of the exist or non exist map\n") |
7f7940e6 | 7940 | |
718e3744 | 7941 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7942 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7943 | afi_t afi, safi_t safi, const char *name_str, | |
7944 | const char *direct_str) | |
718e3744 | 7945 | { |
0ea8d871 IR |
7946 | int ret; |
7947 | struct peer *peer; | |
7948 | int direct = RMAP_IN; | |
7949 | struct route_map *route_map; | |
718e3744 | 7950 | |
0ea8d871 IR |
7951 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7952 | if (!peer) | |
d62a17ae | 7953 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7954 | |
0ea8d871 IR |
7955 | /* Check filter direction. */ |
7956 | if (strncmp(direct_str, "in", 2) == 0) | |
7957 | direct = RMAP_IN; | |
7958 | else if (strncmp(direct_str, "o", 1) == 0) | |
7959 | direct = RMAP_OUT; | |
718e3744 | 7960 | |
0ea8d871 IR |
7961 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7962 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7963 | |
0ea8d871 IR |
7964 | return bgp_vty_return(vty, ret); |
7965 | } | |
7966 | ||
7967 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7968 | afi_t afi, safi_t safi, | |
7969 | const char *direct_str) | |
7970 | { | |
7971 | int ret; | |
7972 | struct peer *peer; | |
7973 | int direct = RMAP_IN; | |
7974 | ||
7975 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7976 | if (!peer) | |
7977 | return CMD_WARNING_CONFIG_FAILED; | |
7978 | ||
7979 | /* Check filter direction. */ | |
7980 | if (strncmp(direct_str, "in", 2) == 0) | |
7981 | direct = RMAP_IN; | |
7982 | else if (strncmp(direct_str, "o", 1) == 0) | |
7983 | direct = RMAP_OUT; | |
7984 | ||
7985 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7986 | ||
7987 | return bgp_vty_return(vty, ret); | |
7988 | } | |
7989 | ||
7990 | DEFUN (neighbor_route_map, | |
7991 | neighbor_route_map_cmd, | |
70dd370f | 7992 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7993 | NEIGHBOR_STR |
7994 | NEIGHBOR_ADDR_STR2 | |
7995 | "Apply route map to neighbor\n" | |
7996 | "Name of route map\n" | |
7997 | "Apply map to incoming routes\n" | |
7998 | "Apply map to outbound routes\n") | |
7999 | { | |
8000 | int idx_peer = 1; | |
8001 | int idx_word = 3; | |
8002 | int idx_in_out = 4; | |
8003 | return peer_route_map_set_vty( | |
8004 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8005 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 8006 | } |
8007 | ||
d6d7ed37 | 8008 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
70dd370f | 8009 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
8010 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8011 | "Apply route map to neighbor\n" | |
8012 | "Name of route map\n" | |
8013 | "Apply map to incoming routes\n" | |
8014 | "Apply map to outbound routes\n") | |
8015 | ||
0ea8d871 IR |
8016 | DEFUN (no_neighbor_route_map, |
8017 | no_neighbor_route_map_cmd, | |
70dd370f | 8018 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
8019 | NO_STR |
8020 | NEIGHBOR_STR | |
8021 | NEIGHBOR_ADDR_STR2 | |
8022 | "Apply route map to neighbor\n" | |
8023 | "Name of route map\n" | |
8024 | "Apply map to incoming routes\n" | |
8025 | "Apply map to outbound routes\n") | |
8026 | { | |
8027 | int idx_peer = 2; | |
8028 | int idx_in_out = 5; | |
8029 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
8030 | bgp_node_afi(vty), bgp_node_safi(vty), | |
8031 | argv[idx_in_out]->arg); | |
8032 | } | |
8033 | ||
8034 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
70dd370f | 8035 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
8036 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8037 | "Apply route map to neighbor\n" | |
8038 | "Name of route map\n" | |
8039 | "Apply map to incoming routes\n" | |
8040 | "Apply map to outbound routes\n") | |
8041 | ||
718e3744 | 8042 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 8043 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
8044 | afi_t afi, safi_t safi, | |
8045 | const char *name_str) | |
718e3744 | 8046 | { |
d62a17ae | 8047 | int ret; |
8048 | struct peer *peer; | |
1de27621 | 8049 | struct route_map *route_map; |
718e3744 | 8050 | |
d62a17ae | 8051 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8052 | if (!peer) | |
8053 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8054 | |
1de27621 DA |
8055 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
8056 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 8057 | |
d62a17ae | 8058 | return bgp_vty_return(vty, ret); |
718e3744 | 8059 | } |
8060 | ||
8061 | /* Unset route-map from the peer. */ | |
d62a17ae | 8062 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
8063 | afi_t afi, safi_t safi) | |
718e3744 | 8064 | { |
d62a17ae | 8065 | int ret; |
8066 | struct peer *peer; | |
718e3744 | 8067 | |
d62a17ae | 8068 | peer = peer_and_group_lookup_vty(vty, ip_str); |
8069 | if (!peer) | |
8070 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8071 | |
d62a17ae | 8072 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 8073 | |
d62a17ae | 8074 | return bgp_vty_return(vty, ret); |
718e3744 | 8075 | } |
8076 | ||
8077 | DEFUN (neighbor_unsuppress_map, | |
8078 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8079 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8080 | NEIGHBOR_STR |
8081 | NEIGHBOR_ADDR_STR2 | |
8082 | "Route-map to selectively unsuppress suppressed routes\n" | |
8083 | "Name of route map\n") | |
8084 | { | |
d62a17ae | 8085 | int idx_peer = 1; |
8086 | int idx_word = 3; | |
8087 | return peer_unsuppress_map_set_vty( | |
8088 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8089 | argv[idx_word]->arg); | |
718e3744 | 8090 | } |
8091 | ||
d62a17ae | 8092 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
8093 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8094 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8095 | "Route-map to selectively unsuppress suppressed routes\n" | |
8096 | "Name of route map\n") | |
596c17ba | 8097 | |
718e3744 | 8098 | DEFUN (no_neighbor_unsuppress_map, |
8099 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 8100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 8101 | NO_STR |
8102 | NEIGHBOR_STR | |
8103 | NEIGHBOR_ADDR_STR2 | |
8104 | "Route-map to selectively unsuppress suppressed routes\n" | |
8105 | "Name of route map\n") | |
8106 | { | |
d62a17ae | 8107 | int idx_peer = 2; |
8108 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
8109 | bgp_node_afi(vty), | |
8110 | bgp_node_safi(vty)); | |
718e3744 | 8111 | } |
6b0655a2 | 8112 | |
d62a17ae | 8113 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
8114 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
8115 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8116 | "Route-map to selectively unsuppress suppressed routes\n" | |
8117 | "Name of route map\n") | |
596c17ba | 8118 | |
7e62b792 IR |
8119 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
8120 | afi_t afi, safi_t safi, | |
8121 | const char *num_str, | |
8122 | const char *threshold_str, int warning, | |
8123 | const char *restart_str, | |
8124 | const char *force_str) | |
8125 | { | |
8126 | int ret; | |
8127 | struct peer *peer; | |
8128 | uint32_t max; | |
8129 | uint8_t threshold; | |
8130 | uint16_t restart; | |
8131 | ||
8132 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8133 | if (!peer) | |
8134 | return CMD_WARNING_CONFIG_FAILED; | |
8135 | ||
8136 | max = strtoul(num_str, NULL, 10); | |
8137 | if (threshold_str) | |
8138 | threshold = atoi(threshold_str); | |
8139 | else | |
8140 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
8141 | ||
8142 | if (restart_str) | |
8143 | restart = atoi(restart_str); | |
8144 | else | |
8145 | restart = 0; | |
8146 | ||
8147 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
8148 | restart, force_str ? true : false); | |
8149 | ||
8150 | return bgp_vty_return(vty, ret); | |
8151 | } | |
8152 | ||
8153 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
8154 | afi_t afi, safi_t safi) | |
8155 | { | |
8156 | int ret; | |
8157 | struct peer *peer; | |
8158 | ||
8159 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
8160 | if (!peer) | |
8161 | return CMD_WARNING_CONFIG_FAILED; | |
8162 | ||
8163 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
8164 | ||
8165 | return bgp_vty_return(vty, ret); | |
8166 | } | |
8167 | ||
fde246e8 | 8168 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
8169 | DEFUN(neighbor_maximum_prefix_out, |
8170 | neighbor_maximum_prefix_out_cmd, | |
8171 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
8172 | NEIGHBOR_STR | |
8173 | NEIGHBOR_ADDR_STR2 | |
8174 | "Maximum number of prefixes to be sent to this peer\n" | |
8175 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8176 | { |
80444d30 | 8177 | int ret; |
fde246e8 DA |
8178 | int idx_peer = 1; |
8179 | int idx_number = 3; | |
7e62b792 IR |
8180 | struct peer *peer; |
8181 | uint32_t max; | |
fde246e8 DA |
8182 | afi_t afi = bgp_node_afi(vty); |
8183 | safi_t safi = bgp_node_safi(vty); | |
8184 | ||
7e62b792 IR |
8185 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8186 | if (!peer) | |
fde246e8 DA |
8187 | return CMD_WARNING_CONFIG_FAILED; |
8188 | ||
7e62b792 | 8189 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 8190 | |
80444d30 | 8191 | ret = peer_maximum_prefix_out_set(peer, afi, safi, max); |
fde246e8 | 8192 | |
80444d30 | 8193 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8194 | } |
8195 | ||
1d80f243 IR |
8196 | DEFUN(no_neighbor_maximum_prefix_out, |
8197 | no_neighbor_maximum_prefix_out_cmd, | |
bc03c622 | 8198 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]", |
1d80f243 IR |
8199 | NO_STR |
8200 | NEIGHBOR_STR | |
8201 | NEIGHBOR_ADDR_STR2 | |
bc03c622 LS |
8202 | "Maximum number of prefixes to be sent to this peer\n" |
8203 | "Maximum no. of prefix limit\n") | |
fde246e8 | 8204 | { |
80444d30 | 8205 | int ret; |
fde246e8 | 8206 | int idx_peer = 2; |
7e62b792 | 8207 | struct peer *peer; |
fde246e8 DA |
8208 | afi_t afi = bgp_node_afi(vty); |
8209 | safi_t safi = bgp_node_safi(vty); | |
8210 | ||
7e62b792 IR |
8211 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8212 | if (!peer) | |
fde246e8 DA |
8213 | return CMD_WARNING_CONFIG_FAILED; |
8214 | ||
80444d30 | 8215 | ret = peer_maximum_prefix_out_unset(peer, afi, safi); |
fde246e8 | 8216 | |
80444d30 | 8217 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
8218 | } |
8219 | ||
9cbd06e0 DA |
8220 | /* Maximum number of prefix configuration. Prefix count is different |
8221 | for each peer configuration. So this configuration can be set for | |
718e3744 | 8222 | each peer configuration. */ |
1d80f243 IR |
8223 | DEFUN (neighbor_maximum_prefix, |
8224 | neighbor_maximum_prefix_cmd, | |
8225 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
8226 | NEIGHBOR_STR | |
8227 | NEIGHBOR_ADDR_STR2 | |
8228 | "Maximum number of prefix accept from this peer\n" | |
8229 | "maximum no. of prefix limit\n" | |
8230 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8231 | { |
d62a17ae | 8232 | int idx_peer = 1; |
8233 | int idx_number = 3; | |
9cbd06e0 | 8234 | int idx_force = 0; |
7e62b792 | 8235 | char *force = NULL; |
9cbd06e0 DA |
8236 | |
8237 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8238 | force = argv[idx_force]->arg; |
9cbd06e0 | 8239 | |
7e62b792 IR |
8240 | return peer_maximum_prefix_set_vty( |
8241 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8242 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 8243 | } |
8244 | ||
d62a17ae | 8245 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 8246 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 8247 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8248 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
8249 | "maximum no. of prefix limit\n" |
8250 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8251 | |
1d80f243 IR |
8252 | DEFUN (neighbor_maximum_prefix_threshold, |
8253 | neighbor_maximum_prefix_threshold_cmd, | |
8254 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
8255 | NEIGHBOR_STR | |
8256 | NEIGHBOR_ADDR_STR2 | |
8257 | "Maximum number of prefix accept from this peer\n" | |
8258 | "maximum no. of prefix limit\n" | |
8259 | "Threshold value (%) at which to generate a warning msg\n" | |
8260 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8261 | { |
d62a17ae | 8262 | int idx_peer = 1; |
8263 | int idx_number = 3; | |
8264 | int idx_number_2 = 4; | |
9cbd06e0 | 8265 | int idx_force = 0; |
7e62b792 | 8266 | char *force = NULL; |
9cbd06e0 DA |
8267 | |
8268 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8269 | force = argv[idx_force]->arg; |
9cbd06e0 | 8270 | |
7e62b792 IR |
8271 | return peer_maximum_prefix_set_vty( |
8272 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8273 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 8274 | } |
e0701b79 | 8275 | |
d62a17ae | 8276 | ALIAS_HIDDEN( |
8277 | neighbor_maximum_prefix_threshold, | |
8278 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 8279 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 8280 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8281 | "Maximum number of prefix accept from this peer\n" | |
8282 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8283 | "Threshold value (%) at which to generate a warning msg\n" |
8284 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8285 | |
1d80f243 IR |
8286 | DEFUN (neighbor_maximum_prefix_warning, |
8287 | neighbor_maximum_prefix_warning_cmd, | |
8288 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
8289 | NEIGHBOR_STR | |
8290 | NEIGHBOR_ADDR_STR2 | |
8291 | "Maximum number of prefix accept from this peer\n" | |
8292 | "maximum no. of prefix limit\n" | |
8293 | "Only give warning message when limit is exceeded\n" | |
8294 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8295 | { |
d62a17ae | 8296 | int idx_peer = 1; |
8297 | int idx_number = 3; | |
9cbd06e0 | 8298 | int idx_force = 0; |
7e62b792 | 8299 | char *force = NULL; |
9cbd06e0 DA |
8300 | |
8301 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8302 | force = argv[idx_force]->arg; |
9cbd06e0 | 8303 | |
7e62b792 IR |
8304 | return peer_maximum_prefix_set_vty( |
8305 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8306 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 8307 | } |
8308 | ||
d62a17ae | 8309 | ALIAS_HIDDEN( |
8310 | neighbor_maximum_prefix_warning, | |
8311 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 8312 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 8313 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8314 | "Maximum number of prefix accept from this peer\n" | |
8315 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
8316 | "Only give warning message when limit is exceeded\n" |
8317 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8318 | |
1d80f243 IR |
8319 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
8320 | neighbor_maximum_prefix_threshold_warning_cmd, | |
8321 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
8322 | NEIGHBOR_STR | |
8323 | NEIGHBOR_ADDR_STR2 | |
8324 | "Maximum number of prefix accept from this peer\n" | |
8325 | "maximum no. of prefix limit\n" | |
8326 | "Threshold value (%) at which to generate a warning msg\n" | |
8327 | "Only give warning message when limit is exceeded\n" | |
8328 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 8329 | { |
d62a17ae | 8330 | int idx_peer = 1; |
8331 | int idx_number = 3; | |
8332 | int idx_number_2 = 4; | |
9cbd06e0 | 8333 | int idx_force = 0; |
7e62b792 | 8334 | char *force = NULL; |
9cbd06e0 DA |
8335 | |
8336 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8337 | force = argv[idx_force]->arg; |
9cbd06e0 | 8338 | |
7e62b792 IR |
8339 | return peer_maximum_prefix_set_vty( |
8340 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8341 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 8342 | } |
8343 | ||
d62a17ae | 8344 | ALIAS_HIDDEN( |
8345 | neighbor_maximum_prefix_threshold_warning, | |
8346 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 8347 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 8348 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8349 | "Maximum number of prefix accept from this peer\n" | |
8350 | "maximum no. of prefix limit\n" | |
8351 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
8352 | "Only give warning message when limit is exceeded\n" |
8353 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8354 | |
1d80f243 IR |
8355 | DEFUN (neighbor_maximum_prefix_restart, |
8356 | neighbor_maximum_prefix_restart_cmd, | |
8357 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
8358 | NEIGHBOR_STR | |
8359 | NEIGHBOR_ADDR_STR2 | |
8360 | "Maximum number of prefix accept from this peer\n" | |
8361 | "maximum no. of prefix limit\n" | |
8362 | "Restart bgp connection after limit is exceeded\n" | |
8363 | "Restart interval in minutes\n" | |
8364 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8365 | { |
d62a17ae | 8366 | int idx_peer = 1; |
8367 | int idx_number = 3; | |
8368 | int idx_number_2 = 5; | |
9cbd06e0 | 8369 | int idx_force = 0; |
7e62b792 | 8370 | char *force = NULL; |
9cbd06e0 DA |
8371 | |
8372 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8373 | force = argv[idx_force]->arg; |
9cbd06e0 | 8374 | |
7e62b792 IR |
8375 | return peer_maximum_prefix_set_vty( |
8376 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8377 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 8378 | } |
8379 | ||
d62a17ae | 8380 | ALIAS_HIDDEN( |
8381 | neighbor_maximum_prefix_restart, | |
8382 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8383 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8384 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8385 | "Maximum number of prefix accept from this peer\n" | |
8386 | "maximum no. of prefix limit\n" | |
8387 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8388 | "Restart interval in minutes\n" |
8389 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8390 | |
1d80f243 IR |
8391 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
8392 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8393 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8394 | NEIGHBOR_STR | |
8395 | NEIGHBOR_ADDR_STR2 | |
8396 | "Maximum number of prefixes to accept from this peer\n" | |
8397 | "maximum no. of prefix limit\n" | |
8398 | "Threshold value (%) at which to generate a warning msg\n" | |
8399 | "Restart bgp connection after limit is exceeded\n" | |
8400 | "Restart interval in minutes\n" | |
8401 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8402 | { |
d62a17ae | 8403 | int idx_peer = 1; |
8404 | int idx_number = 3; | |
8405 | int idx_number_2 = 4; | |
8406 | int idx_number_3 = 6; | |
9cbd06e0 | 8407 | int idx_force = 0; |
7e62b792 | 8408 | char *force = NULL; |
9cbd06e0 DA |
8409 | |
8410 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8411 | force = argv[idx_force]->arg; |
9cbd06e0 | 8412 | |
7e62b792 IR |
8413 | return peer_maximum_prefix_set_vty( |
8414 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8415 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
8416 | argv[idx_number_3]->arg, force); | |
d62a17ae | 8417 | } |
8418 | ||
8419 | ALIAS_HIDDEN( | |
8420 | neighbor_maximum_prefix_threshold_restart, | |
8421 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8422 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8423 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8424 | "Maximum number of prefixes to accept from this peer\n" | |
8425 | "maximum no. of prefix limit\n" | |
8426 | "Threshold value (%) at which to generate a warning msg\n" | |
8427 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8428 | "Restart interval in minutes\n" |
8429 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8430 | |
1d80f243 IR |
8431 | DEFUN (no_neighbor_maximum_prefix, |
8432 | no_neighbor_maximum_prefix_cmd, | |
8433 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8434 | NO_STR | |
8435 | NEIGHBOR_STR | |
8436 | NEIGHBOR_ADDR_STR2 | |
8437 | "Maximum number of prefixes to accept from this peer\n" | |
8438 | "maximum no. of prefix limit\n" | |
8439 | "Threshold value (%) at which to generate a warning msg\n" | |
8440 | "Restart bgp connection after limit is exceeded\n" | |
8441 | "Restart interval in minutes\n" | |
8442 | "Only give warning message when limit is exceeded\n" | |
8443 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8444 | { |
d62a17ae | 8445 | int idx_peer = 2; |
7e62b792 IR |
8446 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
8447 | bgp_node_afi(vty), | |
8448 | bgp_node_safi(vty)); | |
718e3744 | 8449 | } |
e52702f2 | 8450 | |
d62a17ae | 8451 | ALIAS_HIDDEN( |
8452 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8453 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8454 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8455 | "Maximum number of prefixes to accept from this peer\n" | |
8456 | "maximum no. of prefix limit\n" | |
8457 | "Threshold value (%) at which to generate a warning msg\n" | |
8458 | "Restart bgp connection after limit is exceeded\n" | |
8459 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8460 | "Only give warning message when limit is exceeded\n" |
8461 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8462 | |
46dbf9d0 DA |
8463 | /* "neighbor accept-own" */ |
8464 | DEFPY (neighbor_accept_own, | |
8465 | neighbor_accept_own_cmd, | |
8466 | "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor accept-own", | |
8467 | NO_STR | |
8468 | NEIGHBOR_STR | |
8469 | NEIGHBOR_ADDR_STR2 | |
8470 | "Enable handling of self-originated VPN routes containing ACCEPT_OWN community\n") | |
8471 | { | |
8472 | struct peer *peer; | |
8473 | afi_t afi = bgp_node_afi(vty); | |
8474 | safi_t safi = bgp_node_safi(vty); | |
8475 | int ret; | |
8476 | ||
8477 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8478 | if (!peer) | |
8479 | return CMD_WARNING_CONFIG_FAILED; | |
8480 | ||
8481 | if (no) | |
8482 | ret = peer_af_flag_unset(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8483 | else | |
8484 | ret = peer_af_flag_set(peer, afi, safi, PEER_FLAG_ACCEPT_OWN); | |
8485 | ||
8486 | return bgp_vty_return(vty, ret); | |
8487 | } | |
8488 | ||
01da2d26 DA |
8489 | /* "neighbor soo" */ |
8490 | DEFPY (neighbor_soo, | |
8491 | neighbor_soo_cmd, | |
8492 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo ASN:NN_OR_IP-ADDRESS:NN$soo", | |
8493 | NEIGHBOR_STR | |
8494 | NEIGHBOR_ADDR_STR2 | |
8495 | "Set the Site-of-Origin (SoO) extended community\n" | |
8496 | "VPN extended community\n") | |
8497 | { | |
8498 | struct peer *peer; | |
8499 | afi_t afi = bgp_node_afi(vty); | |
8500 | safi_t safi = bgp_node_safi(vty); | |
8501 | struct ecommunity *ecomm_soo; | |
8502 | ||
8503 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8504 | if (!peer) | |
8505 | return CMD_WARNING_CONFIG_FAILED; | |
8506 | ||
8507 | ecomm_soo = ecommunity_str2com(soo, ECOMMUNITY_SITE_ORIGIN, 0); | |
8508 | if (!ecomm_soo) { | |
8509 | vty_out(vty, "%% Malformed SoO extended community\n"); | |
8510 | return CMD_WARNING; | |
8511 | } | |
8512 | ecommunity_str(ecomm_soo); | |
8513 | ||
8514 | if (!ecommunity_match(peer->soo[afi][safi], ecomm_soo)) { | |
8515 | ecommunity_free(&peer->soo[afi][safi]); | |
8516 | peer->soo[afi][safi] = ecomm_soo; | |
8517 | peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO); | |
8518 | } | |
8519 | ||
8520 | return bgp_vty_return(vty, | |
8521 | peer_af_flag_set(peer, afi, safi, PEER_FLAG_SOO)); | |
8522 | } | |
8523 | ||
8524 | DEFPY (no_neighbor_soo, | |
8525 | no_neighbor_soo_cmd, | |
8526 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor soo [ASN:NN_OR_IP-ADDRESS:NN$soo]", | |
8527 | NO_STR | |
8528 | NEIGHBOR_STR | |
8529 | NEIGHBOR_ADDR_STR2 | |
8530 | "Set the Site-of-Origin (SoO) extended community\n" | |
8531 | "VPN extended community\n") | |
8532 | { | |
8533 | struct peer *peer; | |
8534 | afi_t afi = bgp_node_afi(vty); | |
8535 | safi_t safi = bgp_node_safi(vty); | |
8536 | ||
8537 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8538 | if (!peer) | |
8539 | return CMD_WARNING_CONFIG_FAILED; | |
8540 | ||
8541 | ecommunity_free(&peer->soo[afi][safi]); | |
8542 | ||
8543 | return bgp_vty_return( | |
8544 | vty, peer_af_flag_unset(peer, afi, safi, PEER_FLAG_SOO)); | |
8545 | } | |
718e3744 | 8546 | |
718e3744 | 8547 | /* "neighbor allowas-in" */ |
8548 | DEFUN (neighbor_allowas_in, | |
8549 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8550 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8551 | NEIGHBOR_STR |
8552 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8553 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8554 | "Number of occurrences of AS number\n" |
fd8503f5 | 8555 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8556 | { |
d62a17ae | 8557 | int idx_peer = 1; |
8558 | int idx_number_origin = 3; | |
8559 | int ret; | |
8560 | int origin = 0; | |
8561 | struct peer *peer; | |
8562 | int allow_num = 0; | |
8563 | ||
8564 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8565 | if (!peer) | |
8566 | return CMD_WARNING_CONFIG_FAILED; | |
8567 | ||
8568 | if (argc <= idx_number_origin) | |
8569 | allow_num = 3; | |
8570 | else { | |
8571 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8572 | origin = 1; | |
8573 | else | |
8574 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8575 | } | |
8576 | ||
8577 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8578 | allow_num, origin); | |
8579 | ||
8580 | return bgp_vty_return(vty, ret); | |
8581 | } | |
8582 | ||
8583 | ALIAS_HIDDEN( | |
8584 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8585 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8586 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8587 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8588 | "Number of occurrences of AS number\n" |
d62a17ae | 8589 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8590 | |
718e3744 | 8591 | DEFUN (no_neighbor_allowas_in, |
8592 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8593 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8594 | NO_STR |
8595 | NEIGHBOR_STR | |
8596 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8597 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8598 | "Number of occurrences of AS number\n" |
fd8503f5 | 8599 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8600 | { |
d62a17ae | 8601 | int idx_peer = 2; |
8602 | int ret; | |
8603 | struct peer *peer; | |
718e3744 | 8604 | |
d62a17ae | 8605 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8606 | if (!peer) | |
8607 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8608 | |
d62a17ae | 8609 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8610 | bgp_node_safi(vty)); | |
718e3744 | 8611 | |
d62a17ae | 8612 | return bgp_vty_return(vty, ret); |
718e3744 | 8613 | } |
6b0655a2 | 8614 | |
d62a17ae | 8615 | ALIAS_HIDDEN( |
8616 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8617 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8618 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8619 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8620 | "Number of occurrences of AS number\n" |
d62a17ae | 8621 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8622 | |
28c6e247 IR |
8623 | DEFUN (neighbor_ttl_security, |
8624 | neighbor_ttl_security_cmd, | |
8625 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8626 | NEIGHBOR_STR | |
8627 | NEIGHBOR_ADDR_STR2 | |
8628 | "BGP ttl-security parameters\n" | |
8629 | "Specify the maximum number of hops to the BGP peer\n" | |
8630 | "Number of hops to BGP peer\n") | |
fa411a21 | 8631 | { |
d62a17ae | 8632 | int idx_peer = 1; |
8633 | int idx_number = 4; | |
28c6e247 IR |
8634 | struct peer *peer; |
8635 | int gtsm_hops; | |
d62a17ae | 8636 | |
28c6e247 IR |
8637 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8638 | if (!peer) | |
d62a17ae | 8639 | return CMD_WARNING_CONFIG_FAILED; |
8640 | ||
28c6e247 IR |
8641 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
8642 | ||
8643 | /* | |
8644 | * If 'neighbor swpX', then this is for directly connected peers, | |
8645 | * we should not accept a ttl-security hops value greater than 1. | |
8646 | */ | |
8647 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8648 | vty_out(vty, | |
8649 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8650 | argv[idx_peer]->arg); | |
8651 | return CMD_WARNING_CONFIG_FAILED; | |
8652 | } | |
7ebe625c | 8653 | |
28c6e247 | 8654 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8655 | } |
8656 | ||
1d80f243 IR |
8657 | DEFUN (no_neighbor_ttl_security, |
8658 | no_neighbor_ttl_security_cmd, | |
8659 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8660 | NO_STR | |
8661 | NEIGHBOR_STR | |
8662 | NEIGHBOR_ADDR_STR2 | |
8663 | "BGP ttl-security parameters\n" | |
8664 | "Specify the maximum number of hops to the BGP peer\n" | |
8665 | "Number of hops to BGP peer\n") | |
fa411a21 | 8666 | { |
d62a17ae | 8667 | int idx_peer = 2; |
28c6e247 | 8668 | struct peer *peer; |
fa411a21 | 8669 | |
28c6e247 IR |
8670 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8671 | if (!peer) | |
d62a17ae | 8672 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8673 | |
28c6e247 | 8674 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8675 | } |
6b0655a2 | 8676 | |
7c0e4312 DA |
8677 | /* disable-addpath-rx */ |
8678 | DEFUN(neighbor_disable_addpath_rx, | |
8679 | neighbor_disable_addpath_rx_cmd, | |
8680 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8681 | NEIGHBOR_STR | |
8682 | NEIGHBOR_ADDR_STR2 | |
8683 | "Do not accept additional paths\n") | |
8684 | { | |
8685 | char *peer_str = argv[1]->arg; | |
8686 | struct peer *peer; | |
8687 | afi_t afi = bgp_node_afi(vty); | |
8688 | safi_t safi = bgp_node_safi(vty); | |
8689 | ||
8690 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8691 | if (!peer) | |
8692 | return CMD_WARNING_CONFIG_FAILED; | |
8693 | ||
8694 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8695 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8696 | } | |
8697 | ||
8698 | DEFUN(no_neighbor_disable_addpath_rx, | |
8699 | no_neighbor_disable_addpath_rx_cmd, | |
8700 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8701 | NO_STR | |
8702 | NEIGHBOR_STR | |
8703 | NEIGHBOR_ADDR_STR2 | |
8704 | "Do not accept additional paths\n") | |
8705 | { | |
8706 | char *peer_str = argv[2]->arg; | |
8707 | struct peer *peer; | |
8708 | afi_t afi = bgp_node_afi(vty); | |
8709 | safi_t safi = bgp_node_safi(vty); | |
8710 | ||
8711 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8712 | if (!peer) | |
8713 | return CMD_WARNING_CONFIG_FAILED; | |
8714 | ||
8715 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8716 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8717 | } | |
8718 | ||
adbac85e DW |
8719 | DEFUN (neighbor_addpath_tx_all_paths, |
8720 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8721 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8722 | NEIGHBOR_STR |
8723 | NEIGHBOR_ADDR_STR2 | |
8724 | "Use addpath to advertise all paths to a neighbor\n") | |
8725 | { | |
d62a17ae | 8726 | int idx_peer = 1; |
8727 | struct peer *peer; | |
adbac85e | 8728 | |
d62a17ae | 8729 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8730 | if (!peer) | |
8731 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8732 | |
dcc68b5e MS |
8733 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8734 | BGP_ADDPATH_ALL); | |
8735 | return CMD_SUCCESS; | |
adbac85e DW |
8736 | } |
8737 | ||
d62a17ae | 8738 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8739 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8740 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8741 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8742 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8743 | |
adbac85e DW |
8744 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8745 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8746 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8747 | NO_STR |
8748 | NEIGHBOR_STR | |
8749 | NEIGHBOR_ADDR_STR2 | |
8750 | "Use addpath to advertise all paths to a neighbor\n") | |
8751 | { | |
d62a17ae | 8752 | int idx_peer = 2; |
dcc68b5e MS |
8753 | struct peer *peer; |
8754 | ||
8755 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8756 | if (!peer) | |
8757 | return CMD_WARNING_CONFIG_FAILED; | |
8758 | ||
8759 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8760 | != BGP_ADDPATH_ALL) { | |
8761 | vty_out(vty, | |
8762 | "%% Peer not currently configured to transmit all paths."); | |
8763 | return CMD_WARNING_CONFIG_FAILED; | |
8764 | } | |
8765 | ||
8766 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8767 | BGP_ADDPATH_NONE); | |
8768 | ||
8769 | return CMD_SUCCESS; | |
adbac85e DW |
8770 | } |
8771 | ||
d62a17ae | 8772 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8773 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8774 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8775 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8776 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8777 | |
06370dac DW |
8778 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8779 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8780 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8781 | NEIGHBOR_STR |
8782 | NEIGHBOR_ADDR_STR2 | |
8783 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8784 | { | |
d62a17ae | 8785 | int idx_peer = 1; |
8786 | struct peer *peer; | |
06370dac | 8787 | |
d62a17ae | 8788 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8789 | if (!peer) | |
8790 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8791 | |
dcc68b5e MS |
8792 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8793 | BGP_ADDPATH_BEST_PER_AS); | |
8794 | ||
8795 | return CMD_SUCCESS; | |
06370dac DW |
8796 | } |
8797 | ||
d62a17ae | 8798 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8799 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8800 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8801 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8802 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8803 | |
06370dac DW |
8804 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8805 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8806 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8807 | NO_STR |
8808 | NEIGHBOR_STR | |
8809 | NEIGHBOR_ADDR_STR2 | |
8810 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8811 | { | |
d62a17ae | 8812 | int idx_peer = 2; |
dcc68b5e MS |
8813 | struct peer *peer; |
8814 | ||
8815 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8816 | if (!peer) | |
8817 | return CMD_WARNING_CONFIG_FAILED; | |
8818 | ||
8819 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8820 | != BGP_ADDPATH_BEST_PER_AS) { | |
8821 | vty_out(vty, | |
8822 | "%% Peer not currently configured to transmit all best path per as."); | |
8823 | return CMD_WARNING_CONFIG_FAILED; | |
8824 | } | |
8825 | ||
8826 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8827 | BGP_ADDPATH_NONE); | |
8828 | ||
8829 | return CMD_SUCCESS; | |
06370dac DW |
8830 | } |
8831 | ||
d62a17ae | 8832 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8833 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8834 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8835 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8836 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8837 | |
2b31007c RZ |
8838 | DEFPY( |
8839 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8840 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8841 | NEIGHBOR_STR | |
8842 | NEIGHBOR_ADDR_STR2 | |
8843 | "Detect AS loops before sending to neighbor\n") | |
8844 | { | |
8845 | struct peer *peer; | |
8846 | ||
8847 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8848 | if (!peer) | |
8849 | return CMD_WARNING_CONFIG_FAILED; | |
8850 | ||
8851 | peer->as_path_loop_detection = true; | |
8852 | ||
8853 | return CMD_SUCCESS; | |
8854 | } | |
8855 | ||
8856 | DEFPY( | |
8857 | no_neighbor_aspath_loop_detection, | |
8858 | no_neighbor_aspath_loop_detection_cmd, | |
8859 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8860 | NO_STR | |
8861 | NEIGHBOR_STR | |
8862 | NEIGHBOR_ADDR_STR2 | |
8863 | "Detect AS loops before sending to neighbor\n") | |
8864 | { | |
8865 | struct peer *peer; | |
8866 | ||
8867 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8868 | if (!peer) | |
8869 | return CMD_WARNING_CONFIG_FAILED; | |
8870 | ||
8871 | peer->as_path_loop_detection = false; | |
8872 | ||
8873 | return CMD_SUCCESS; | |
8874 | } | |
8875 | ||
a5c6a9b1 DA |
8876 | DEFPY(neighbor_path_attribute_discard, |
8877 | neighbor_path_attribute_discard_cmd, | |
8878 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard (1-255)...", | |
8879 | NEIGHBOR_STR | |
8880 | NEIGHBOR_ADDR_STR2 | |
8881 | "Manipulate path attributes from incoming UPDATE messages\n" | |
8882 | "Drop specified attributes from incoming UPDATE messages\n" | |
8883 | "Attribute number\n") | |
8884 | { | |
8885 | struct peer *peer; | |
8886 | int idx = 0; | |
8887 | const char *discard_attrs = NULL; | |
8888 | ||
8889 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8890 | if (!peer) | |
8891 | return CMD_WARNING_CONFIG_FAILED; | |
8892 | ||
8893 | argv_find(argv, argc, "(1-255)", &idx); | |
8894 | if (idx) | |
8895 | discard_attrs = argv_concat(argv, argc, idx); | |
8896 | ||
b986d7f4 DA |
8897 | bgp_path_attribute_discard_vty(vty, peer, discard_attrs, true); |
8898 | ||
8899 | return CMD_SUCCESS; | |
8900 | } | |
8901 | ||
8902 | DEFPY(no_neighbor_path_attribute_discard, | |
8903 | no_neighbor_path_attribute_discard_cmd, | |
8904 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute discard [(1-255)]", | |
8905 | NO_STR | |
8906 | NEIGHBOR_STR | |
8907 | NEIGHBOR_ADDR_STR2 | |
8908 | "Manipulate path attributes from incoming UPDATE messages\n" | |
8909 | "Drop specified attributes from incoming UPDATE messages\n" | |
8910 | "Attribute number\n") | |
8911 | { | |
8912 | struct peer *peer; | |
8913 | int idx = 0; | |
8914 | const char *discard_attrs = NULL; | |
8915 | ||
8916 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8917 | if (!peer) | |
8918 | return CMD_WARNING_CONFIG_FAILED; | |
8919 | ||
8920 | argv_find(argv, argc, "(1-255)", &idx); | |
8921 | if (idx) | |
8922 | discard_attrs = argv[idx]->arg; | |
8923 | ||
8924 | bgp_path_attribute_discard_vty(vty, peer, discard_attrs, false); | |
a5c6a9b1 DA |
8925 | |
8926 | return CMD_SUCCESS; | |
8927 | } | |
8928 | ||
b9c7bc5a | 8929 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8930 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8931 | { |
b9c7bc5a PZ |
8932 | struct ecommunity *ecom = NULL; |
8933 | struct ecommunity *ecomadd; | |
ddb5b488 | 8934 | |
b9c7bc5a | 8935 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8936 | if (is_rt6) |
8937 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8938 | ECOMMUNITY_ROUTE_TARGET, | |
8939 | 0); | |
8940 | else | |
8941 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8942 | ECOMMUNITY_ROUTE_TARGET, | |
8943 | 0); | |
b9c7bc5a PZ |
8944 | if (!ecomadd) { |
8945 | vty_out(vty, "Malformed community-list value\n"); | |
8946 | if (ecom) | |
8947 | ecommunity_free(&ecom); | |
8948 | return CMD_WARNING_CONFIG_FAILED; | |
8949 | } | |
ddb5b488 | 8950 | |
b9c7bc5a PZ |
8951 | if (ecom) { |
8952 | ecommunity_merge(ecom, ecomadd); | |
8953 | ecommunity_free(&ecomadd); | |
8954 | } else { | |
8955 | ecom = ecomadd; | |
8956 | } | |
8957 | } | |
8958 | ||
8959 | if (*list) { | |
8960 | ecommunity_free(&*list); | |
ddb5b488 | 8961 | } |
b9c7bc5a PZ |
8962 | *list = ecom; |
8963 | ||
8964 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8965 | } |
8966 | ||
0ca70ba5 DS |
8967 | /* |
8968 | * v2vimport is true if we are handling a `import vrf ...` command | |
8969 | */ | |
8970 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8971 | { |
0ca70ba5 DS |
8972 | afi_t afi; |
8973 | ||
ddb5b488 | 8974 | switch (vty->node) { |
b9c7bc5a | 8975 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8976 | afi = AFI_IP; |
8977 | break; | |
b9c7bc5a | 8978 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8979 | afi = AFI_IP6; |
8980 | break; | |
ddb5b488 PZ |
8981 | default: |
8982 | vty_out(vty, | |
b9c7bc5a | 8983 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8984 | return AFI_MAX; |
ddb5b488 | 8985 | } |
69b07479 | 8986 | |
0ca70ba5 DS |
8987 | if (!v2vimport) { |
8988 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8989 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8990 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8991 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8992 | vty_out(vty, | |
8993 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8994 | return AFI_MAX; | |
8995 | } | |
8996 | } else { | |
8997 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8998 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8999 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9000 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
9001 | vty_out(vty, | |
9002 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
9003 | return AFI_MAX; | |
9004 | } | |
9005 | } | |
9006 | return afi; | |
ddb5b488 PZ |
9007 | } |
9008 | ||
585f1adc IR |
9009 | DEFPY (af_rd_vpn_export, |
9010 | af_rd_vpn_export_cmd, | |
9011 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
9012 | NO_STR | |
9013 | "Specify route distinguisher\n" | |
9014 | "Between current address-family and vpn\n" | |
9015 | "For routes leaked from current address-family to vpn\n" | |
9016 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 9017 | { |
585f1adc IR |
9018 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9019 | struct prefix_rd prd; | |
9020 | int ret; | |
ddb5b488 | 9021 | afi_t afi; |
b9c7bc5a | 9022 | int idx = 0; |
585f1adc | 9023 | bool yes = true; |
b9c7bc5a | 9024 | |
585f1adc IR |
9025 | if (argv_find(argv, argc, "no", &idx)) |
9026 | yes = false; | |
ddb5b488 | 9027 | |
585f1adc IR |
9028 | if (yes) { |
9029 | ret = str2prefix_rd(rd_str, &prd); | |
9030 | if (!ret) { | |
9031 | vty_out(vty, "%% Malformed rd\n"); | |
9032 | return CMD_WARNING_CONFIG_FAILED; | |
9033 | } | |
9034 | } | |
ddb5b488 | 9035 | |
585f1adc IR |
9036 | afi = vpn_policy_getafi(vty, bgp, false); |
9037 | if (afi == AFI_MAX) | |
9038 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9039 | |
585f1adc IR |
9040 | /* |
9041 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9042 | */ | |
9043 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9044 | bgp_get_default(), bgp); | |
ddb5b488 | 9045 | |
585f1adc IR |
9046 | if (yes) { |
9047 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
9048 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9049 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
9050 | } else { | |
9051 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
9052 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
9053 | } | |
69b07479 | 9054 | |
585f1adc IR |
9055 | /* post-change: re-export vpn routes */ |
9056 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9057 | bgp_get_default(), bgp); | |
9058 | ||
9059 | return CMD_SUCCESS; | |
ddb5b488 PZ |
9060 | } |
9061 | ||
b9c7bc5a PZ |
9062 | ALIAS (af_rd_vpn_export, |
9063 | af_no_rd_vpn_export_cmd, | |
9064 | "no rd vpn export", | |
ddb5b488 | 9065 | NO_STR |
b9c7bc5a PZ |
9066 | "Specify route distinguisher\n" |
9067 | "Between current address-family and vpn\n" | |
9068 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9069 | |
b9c7bc5a PZ |
9070 | DEFPY (af_label_vpn_export, |
9071 | af_label_vpn_export_cmd, | |
e70e9f8e | 9072 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 9073 | NO_STR |
ddb5b488 | 9074 | "label value for VRF\n" |
b9c7bc5a PZ |
9075 | "Between current address-family and vpn\n" |
9076 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
9077 | "Label Value <0-1048575>\n" |
9078 | "Automatically assign a label\n") | |
ddb5b488 PZ |
9079 | { |
9080 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 9081 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 9082 | afi_t afi; |
b9c7bc5a | 9083 | int idx = 0; |
c6423c31 | 9084 | bool yes = true; |
b9c7bc5a PZ |
9085 | |
9086 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9087 | yes = false; |
ddb5b488 | 9088 | |
21a16cc2 PZ |
9089 | /* If "no ...", squash trailing parameter */ |
9090 | if (!yes) | |
9091 | label_auto = NULL; | |
9092 | ||
e70e9f8e PZ |
9093 | if (yes) { |
9094 | if (!label_auto) | |
9095 | label = label_val; /* parser should force unsigned */ | |
9096 | } | |
ddb5b488 | 9097 | |
0ca70ba5 | 9098 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9099 | if (afi == AFI_MAX) |
9100 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 9101 | |
e70e9f8e | 9102 | |
69b07479 DS |
9103 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
9104 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
9105 | /* no change */ | |
9106 | return CMD_SUCCESS; | |
e70e9f8e | 9107 | |
69b07479 DS |
9108 | /* |
9109 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9110 | */ | |
9111 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9112 | bgp_get_default(), bgp); | |
9113 | ||
9114 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9115 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
9116 | ||
9117 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
9118 | ||
9119 | /* | |
9120 | * label has previously been automatically | |
9121 | * assigned by labelpool: release it | |
9122 | * | |
9123 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
9124 | * means the automatic assignment is in flight | |
9125 | * and therefore the labelpool callback must | |
9126 | * detect that the auto label is not needed. | |
9127 | */ | |
9128 | ||
9129 | bgp_lp_release(LP_TYPE_VRF, | |
9130 | &bgp->vpn_policy[afi], | |
9131 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 9132 | } |
69b07479 DS |
9133 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
9134 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9135 | } | |
ddb5b488 | 9136 | |
69b07479 DS |
9137 | bgp->vpn_policy[afi].tovpn_label = label; |
9138 | if (label_auto) { | |
9139 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9140 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
9141 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
9142 | vpn_leak_label_callback); | |
ddb5b488 PZ |
9143 | } |
9144 | ||
69b07479 DS |
9145 | /* post-change: re-export vpn routes */ |
9146 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9147 | bgp_get_default(), bgp); | |
9148 | ||
0d020cd6 | 9149 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
9150 | return CMD_SUCCESS; |
9151 | } | |
9152 | ||
b72c9e14 HS |
9153 | DEFPY (af_sid_vpn_export, |
9154 | af_sid_vpn_export_cmd, | |
46279a11 | 9155 | "[no] sid vpn export <(1-1048575)$sid_idx|auto$sid_auto>", |
b72c9e14 HS |
9156 | NO_STR |
9157 | "sid value for VRF\n" | |
9158 | "Between current address-family and vpn\n" | |
9159 | "For routes leaked from current address-family to vpn\n" | |
9160 | "Sid allocation index\n" | |
9161 | "Automatically assign a label\n") | |
9162 | { | |
9163 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9164 | afi_t afi; | |
9165 | int debug = 0; | |
9166 | int idx = 0; | |
9167 | bool yes = true; | |
9168 | ||
9169 | if (argv_find(argv, argc, "no", &idx)) | |
9170 | yes = false; | |
9171 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9172 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9173 | ||
9174 | afi = vpn_policy_getafi(vty, bgp, false); | |
9175 | if (afi == AFI_MAX) | |
9176 | return CMD_WARNING_CONFIG_FAILED; | |
9177 | ||
9178 | if (!yes) { | |
9179 | /* implement me */ | |
4d4c404b | 9180 | vty_out(vty, "It's not implemented\n"); |
b72c9e14 HS |
9181 | return CMD_WARNING_CONFIG_FAILED; |
9182 | } | |
9183 | ||
527588aa CS |
9184 | if (bgp->tovpn_sid_index != 0 || |
9185 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
9186 | vty_out(vty, | |
9187 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9188 | "Failed: per-vrf sid is configured. Remove per-vrf sid before configuring per-af sid\n"); | |
9189 | return CMD_WARNING_CONFIG_FAILED; | |
9190 | } | |
9191 | ||
b72c9e14 HS |
9192 | /* skip when it's already configured */ |
9193 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
9194 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9195 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
9196 | return CMD_SUCCESS; | |
9197 | ||
7de4c885 HS |
9198 | /* |
9199 | * mode change between sid_idx and sid_auto isn't supported. | |
9200 | * user must negate sid vpn export when they want to change the mode | |
9201 | */ | |
b72c9e14 HS |
9202 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
9203 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
9204 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
9205 | vty_out(vty, "it's already configured as %s.\n", | |
9206 | sid_auto ? "auto-mode" : "idx-mode"); | |
9207 | return CMD_WARNING_CONFIG_FAILED; | |
9208 | } | |
9209 | ||
9210 | /* pre-change */ | |
9211 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9212 | bgp_get_default(), bgp); | |
9213 | ||
9214 | if (sid_auto) { | |
9215 | /* SID allocation auto-mode */ | |
9216 | if (debug) | |
9217 | zlog_debug("%s: auto sid alloc.", __func__); | |
9218 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9219 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
9220 | } else { | |
9221 | /* SID allocation index-mode */ | |
9222 | if (debug) | |
9223 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
9224 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
9225 | } | |
9226 | ||
9227 | /* post-change */ | |
9228 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9229 | bgp_get_default(), bgp); | |
9230 | return CMD_SUCCESS; | |
9231 | } | |
9232 | ||
527588aa CS |
9233 | DEFPY (bgp_sid_vpn_export, |
9234 | bgp_sid_vpn_export_cmd, | |
346bbb39 | 9235 | "[no] sid vpn per-vrf export <(1-1048575)$sid_idx|auto$sid_auto>", |
527588aa CS |
9236 | NO_STR |
9237 | "sid value for VRF\n" | |
9238 | "Between current vrf and vpn\n" | |
9239 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9240 | "For routes leaked from current vrf to vpn\n" | |
9241 | "Sid allocation index\n" | |
9242 | "Automatically assign a label\n") | |
9243 | { | |
9244 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9245 | int debug; | |
9246 | ||
9247 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
9248 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
9249 | ||
9250 | if (no) { | |
e606d8ec CS |
9251 | /* when per-VRF SID is not set, do nothing */ |
9252 | if (bgp->tovpn_sid_index == 0 && | |
9253 | !CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) | |
9254 | return CMD_SUCCESS; | |
9255 | ||
9256 | sid_idx = 0; | |
9257 | sid_auto = false; | |
9258 | bgp->tovpn_sid_index = 0; | |
9259 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
527588aa CS |
9260 | } |
9261 | ||
9262 | if (bgp->vpn_policy[AFI_IP].tovpn_sid_index != 0 || | |
9263 | CHECK_FLAG(bgp->vpn_policy[AFI_IP].flags, | |
9264 | BGP_VPN_POLICY_TOVPN_SID_AUTO) || | |
9265 | bgp->vpn_policy[AFI_IP6].tovpn_sid_index != 0 || | |
9266 | CHECK_FLAG(bgp->vpn_policy[AFI_IP6].flags, | |
9267 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
9268 | vty_out(vty, | |
9269 | "per-vrf sid and per-af sid are mutually exclusive\n" | |
9270 | "Failed: per-af sid is configured. Remove per-af sid before configuring per-vrf sid\n"); | |
9271 | return CMD_WARNING_CONFIG_FAILED; | |
9272 | } | |
9273 | ||
9274 | /* skip when it's already configured */ | |
9275 | if ((sid_idx != 0 && bgp->tovpn_sid_index != 0) || | |
9276 | (sid_auto && CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) | |
9277 | return CMD_SUCCESS; | |
9278 | ||
9279 | /* | |
9280 | * mode change between sid_idx and sid_auto isn't supported. | |
9281 | * user must negate sid vpn export when they want to change the mode | |
9282 | */ | |
9283 | if ((sid_auto && bgp->tovpn_sid_index != 0) || | |
9284 | (sid_idx != 0 && | |
9285 | CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO))) { | |
9286 | vty_out(vty, "it's already configured as %s.\n", | |
9287 | sid_auto ? "auto-mode" : "idx-mode"); | |
9288 | return CMD_WARNING_CONFIG_FAILED; | |
9289 | } | |
9290 | ||
9291 | /* pre-change */ | |
9292 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9293 | bgp); | |
9294 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp_get_default(), | |
9295 | bgp); | |
9296 | ||
9297 | if (sid_auto) { | |
9298 | /* SID allocation auto-mode */ | |
9299 | if (debug) | |
9300 | zlog_debug("%s: auto per-vrf sid alloc.", __func__); | |
9301 | SET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); | |
e606d8ec | 9302 | } else if (sid_idx != 0) { |
527588aa CS |
9303 | /* SID allocation index-mode */ |
9304 | if (debug) | |
9305 | zlog_debug("%s: idx %ld per-vrf sid alloc.", __func__, | |
9306 | sid_idx); | |
9307 | bgp->tovpn_sid_index = sid_idx; | |
9308 | } | |
9309 | ||
9310 | /* post-change */ | |
9311 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), | |
9312 | bgp); | |
9313 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, | |
9314 | bgp_get_default(), bgp); | |
9315 | ||
9316 | return CMD_SUCCESS; | |
9317 | } | |
9318 | ||
b9c7bc5a PZ |
9319 | ALIAS (af_label_vpn_export, |
9320 | af_no_label_vpn_export_cmd, | |
9321 | "no label vpn export", | |
9322 | NO_STR | |
9323 | "label value for VRF\n" | |
9324 | "Between current address-family and vpn\n" | |
9325 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 9326 | |
e606d8ec CS |
9327 | ALIAS (bgp_sid_vpn_export, |
9328 | no_bgp_sid_vpn_export_cmd, | |
9329 | "no$no sid vpn per-vrf export", | |
9330 | NO_STR | |
9331 | "sid value for VRF\n" | |
9332 | "Between current vrf and vpn\n" | |
9333 | "sid per-VRF (both IPv4 and IPv6 address families)\n" | |
9334 | "For routes leaked from current vrf to vpn\n") | |
9335 | ||
585f1adc | 9336 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 9337 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 9338 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 9339 | NO_STR |
ddb5b488 | 9340 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
9341 | "Between current address-family and vpn\n" |
9342 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9343 | "IPv4 prefix\n" |
9344 | "IPv6 prefix\n") | |
9345 | { | |
585f1adc | 9346 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 9347 | afi_t afi; |
ddb5b488 PZ |
9348 | struct prefix p; |
9349 | ||
8c85ca28 QY |
9350 | if (!no) { |
9351 | if (!nexthop_su) { | |
9352 | vty_out(vty, "%% Nexthop required\n"); | |
9353 | return CMD_WARNING_CONFIG_FAILED; | |
9354 | } | |
8c85ca28 | 9355 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
9356 | return CMD_WARNING_CONFIG_FAILED; |
9357 | } | |
ddb5b488 | 9358 | |
585f1adc IR |
9359 | afi = vpn_policy_getafi(vty, bgp, false); |
9360 | if (afi == AFI_MAX) | |
9361 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9362 | |
585f1adc IR |
9363 | /* |
9364 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
9365 | */ | |
9366 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9367 | bgp_get_default(), bgp); | |
ddb5b488 | 9368 | |
585f1adc IR |
9369 | if (!no) { |
9370 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
9371 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
9372 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9373 | } else { | |
9374 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
9375 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
9376 | } | |
69b07479 | 9377 | |
585f1adc IR |
9378 | /* post-change: re-export vpn routes */ |
9379 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
9380 | bgp_get_default(), bgp); | |
37a87b8f | 9381 | |
585f1adc | 9382 | return CMD_SUCCESS; |
ddb5b488 PZ |
9383 | } |
9384 | ||
b9c7bc5a | 9385 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 9386 | { |
b9c7bc5a PZ |
9387 | if (!strcmp(dstr, "import")) { |
9388 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9389 | } else if (!strcmp(dstr, "export")) { | |
9390 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9391 | } else if (!strcmp(dstr, "both")) { | |
9392 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
9393 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
9394 | } else { | |
9395 | vty_out(vty, "%% direction parse error\n"); | |
9396 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9397 | } |
ddb5b488 PZ |
9398 | return CMD_SUCCESS; |
9399 | } | |
9400 | ||
b9c7bc5a PZ |
9401 | DEFPY (af_rt_vpn_imexport, |
9402 | af_rt_vpn_imexport_cmd, | |
9403 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
9404 | NO_STR | |
9405 | "Specify route target list\n" | |
ddb5b488 | 9406 | "Specify route target list\n" |
b9c7bc5a PZ |
9407 | "Between current address-family and vpn\n" |
9408 | "For routes leaked from vpn to current address-family: match any\n" | |
9409 | "For routes leaked from current address-family to vpn: set\n" | |
9410 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
9411 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
9412 | { | |
9413 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9414 | int ret; | |
9415 | struct ecommunity *ecom = NULL; | |
9416 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9417 | enum vpn_policy_direction dir; |
ddb5b488 PZ |
9418 | afi_t afi; |
9419 | int idx = 0; | |
c6423c31 | 9420 | bool yes = true; |
ddb5b488 | 9421 | |
b9c7bc5a | 9422 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 9423 | yes = false; |
b9c7bc5a | 9424 | |
0ca70ba5 | 9425 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9426 | if (afi == AFI_MAX) |
9427 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9428 | |
b9c7bc5a | 9429 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
9430 | if (ret != CMD_SUCCESS) |
9431 | return ret; | |
9432 | ||
b9c7bc5a PZ |
9433 | if (yes) { |
9434 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9435 | vty_out(vty, "%% Missing RTLIST\n"); | |
9436 | return CMD_WARNING_CONFIG_FAILED; | |
9437 | } | |
c6423c31 | 9438 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
9439 | if (ret != CMD_SUCCESS) { |
9440 | return ret; | |
9441 | } | |
ddb5b488 PZ |
9442 | } |
9443 | ||
69b07479 DS |
9444 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9445 | if (!dodir[dir]) | |
ddb5b488 | 9446 | continue; |
ddb5b488 | 9447 | |
69b07479 | 9448 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 9449 | |
69b07479 DS |
9450 | if (yes) { |
9451 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9452 | ecommunity_free( | |
9453 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9454 | bgp->vpn_policy[afi].rtlist[dir] = | |
9455 | ecommunity_dup(ecom); | |
9456 | } else { | |
9457 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
9458 | ecommunity_free( | |
9459 | &bgp->vpn_policy[afi].rtlist[dir]); | |
9460 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 9461 | } |
69b07479 DS |
9462 | |
9463 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 9464 | } |
69b07479 | 9465 | |
d555f3e9 PZ |
9466 | if (ecom) |
9467 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
9468 | |
9469 | return CMD_SUCCESS; | |
9470 | } | |
9471 | ||
b9c7bc5a PZ |
9472 | ALIAS (af_rt_vpn_imexport, |
9473 | af_no_rt_vpn_imexport_cmd, | |
9474 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
9475 | NO_STR |
9476 | "Specify route target list\n" | |
b9c7bc5a PZ |
9477 | "Specify route target list\n" |
9478 | "Between current address-family and vpn\n" | |
9479 | "For routes leaked from vpn to current address-family\n" | |
9480 | "For routes leaked from current address-family to vpn\n" | |
9481 | "both import and export\n") | |
9482 | ||
585f1adc | 9483 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
9484 | af_route_map_vpn_imexport_cmd, |
9485 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
9486 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
9487 | NO_STR | |
ddb5b488 | 9488 | "Specify route map\n" |
b9c7bc5a PZ |
9489 | "Between current address-family and vpn\n" |
9490 | "For routes leaked from vpn to current address-family\n" | |
9491 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
9492 | "name of route-map\n") |
9493 | { | |
585f1adc IR |
9494 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9495 | int ret; | |
9496 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 9497 | enum vpn_policy_direction dir; |
ddb5b488 | 9498 | afi_t afi; |
ddb5b488 | 9499 | int idx = 0; |
585f1adc | 9500 | bool yes = true; |
ddb5b488 | 9501 | |
585f1adc IR |
9502 | if (argv_find(argv, argc, "no", &idx)) |
9503 | yes = false; | |
ddb5b488 | 9504 | |
585f1adc IR |
9505 | afi = vpn_policy_getafi(vty, bgp, false); |
9506 | if (afi == AFI_MAX) | |
9507 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 9508 | |
585f1adc IR |
9509 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
9510 | if (ret != CMD_SUCCESS) | |
9511 | return ret; | |
ddb5b488 | 9512 | |
585f1adc IR |
9513 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
9514 | if (!dodir[dir]) | |
9515 | continue; | |
69b07479 | 9516 | |
585f1adc IR |
9517 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
9518 | ||
9519 | if (yes) { | |
9520 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9521 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9522 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9523 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
9524 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9525 | bgp->vpn_policy[afi].rmap[dir] = | |
9526 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9527 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9528 | return CMD_SUCCESS; | |
9529 | } else { | |
9530 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9531 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9532 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9533 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9534 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9535 | } | |
9536 | ||
9537 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9538 | } | |
ddb5b488 | 9539 | |
585f1adc | 9540 | return CMD_SUCCESS; |
ddb5b488 PZ |
9541 | } |
9542 | ||
b9c7bc5a PZ |
9543 | ALIAS (af_route_map_vpn_imexport, |
9544 | af_no_route_map_vpn_imexport_cmd, | |
9545 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
9546 | NO_STR |
9547 | "Specify route map\n" | |
b9c7bc5a PZ |
9548 | "Between current address-family and vpn\n" |
9549 | "For routes leaked from vpn to current address-family\n" | |
9550 | "For routes leaked from current address-family to vpn\n") | |
9551 | ||
bb4f6190 | 9552 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 9553 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
9554 | "Import routes from another VRF\n" |
9555 | "Vrf routes being filtered\n" | |
9556 | "Specify route map\n" | |
9557 | "name of route-map\n") | |
9558 | { | |
9559 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9560 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
bb4f6190 | 9561 | afi_t afi; |
bb4f6190 DS |
9562 | struct bgp *bgp_default; |
9563 | ||
0ca70ba5 | 9564 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
9565 | if (afi == AFI_MAX) |
9566 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
9567 | |
9568 | bgp_default = bgp_get_default(); | |
9569 | if (!bgp_default) { | |
9570 | int32_t ret; | |
9571 | as_t as = bgp->as; | |
9572 | ||
9573 | /* Auto-create assuming the same AS */ | |
5d5393b9 | 9574 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
e55b0883 PG |
9575 | BGP_INSTANCE_TYPE_DEFAULT, NULL, |
9576 | ASNOTATION_UNDEFINED); | |
bb4f6190 DS |
9577 | |
9578 | if (ret) { | |
9579 | vty_out(vty, | |
9580 | "VRF default is not configured as a bgp instance\n"); | |
9581 | return CMD_WARNING; | |
9582 | } | |
9583 | } | |
9584 | ||
69b07479 | 9585 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 9586 | |
ae6a6fb4 DS |
9587 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
9588 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9589 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9590 | bgp->vpn_policy[afi].rmap_name[dir] = | |
9591 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
9592 | bgp->vpn_policy[afi].rmap[dir] = | |
9593 | route_map_lookup_warn_noexist(vty, rmap_str); | |
9594 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
9595 | return CMD_SUCCESS; | |
9596 | ||
9597 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9598 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 9599 | |
69b07479 DS |
9600 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
9601 | ||
bb4f6190 DS |
9602 | return CMD_SUCCESS; |
9603 | } | |
9604 | ||
ae6a6fb4 DS |
9605 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9606 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9607 | NO_STR |
9608 | "Import routes from another VRF\n" | |
9609 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9610 | "Specify route map\n" |
9611 | "name of route-map\n") | |
9612 | { | |
9613 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9614 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
ae6a6fb4 DS |
9615 | afi_t afi; |
9616 | ||
9617 | afi = vpn_policy_getafi(vty, bgp, true); | |
9618 | if (afi == AFI_MAX) | |
9619 | return CMD_WARNING_CONFIG_FAILED; | |
9620 | ||
9621 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9622 | ||
9623 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9624 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9625 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9626 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9627 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9628 | ||
9629 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9630 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9631 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9632 | ||
9633 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9634 | ||
9635 | return CMD_SUCCESS; | |
9636 | } | |
bb4f6190 | 9637 | |
585f1adc IR |
9638 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
9639 | "[no] import vrf VIEWVRFNAME$import_name", | |
9640 | NO_STR | |
9641 | "Import routes from another VRF\n" | |
9642 | "VRF to import from\n" | |
9643 | "The name of the VRF\n") | |
12a844a5 | 9644 | { |
585f1adc IR |
9645 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9646 | struct listnode *node; | |
9647 | struct bgp *vrf_bgp, *bgp_default; | |
9648 | int32_t ret = 0; | |
9649 | as_t as = bgp->as; | |
9650 | bool remove = false; | |
9651 | int32_t idx = 0; | |
9652 | char *vname; | |
9653 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
9654 | safi_t safi; |
9655 | afi_t afi; | |
9656 | ||
867f0cca | 9657 | if (import_name == NULL) { |
9658 | vty_out(vty, "%% Missing import name\n"); | |
9659 | return CMD_WARNING; | |
9660 | } | |
9661 | ||
ae6a6fb4 DS |
9662 | if (strcmp(import_name, "route-map") == 0) { |
9663 | vty_out(vty, "%% Must include route-map name\n"); | |
9664 | return CMD_WARNING; | |
9665 | } | |
9666 | ||
585f1adc IR |
9667 | if (argv_find(argv, argc, "no", &idx)) |
9668 | remove = true; | |
9669 | ||
9670 | afi = vpn_policy_getafi(vty, bgp, true); | |
9671 | if (afi == AFI_MAX) | |
9672 | return CMD_WARNING_CONFIG_FAILED; | |
9673 | ||
12a844a5 DS |
9674 | safi = bgp_node_safi(vty); |
9675 | ||
585f1adc IR |
9676 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
9677 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
9678 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
9679 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
9680 | remove ? "unimport" : "import", import_name); | |
9681 | return CMD_WARNING; | |
9682 | } | |
25679caa | 9683 | |
585f1adc IR |
9684 | bgp_default = bgp_get_default(); |
9685 | if (!bgp_default) { | |
9686 | /* Auto-create assuming the same AS */ | |
9687 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
e55b0883 PG |
9688 | BGP_INSTANCE_TYPE_DEFAULT, NULL, |
9689 | ASNOTATION_UNDEFINED); | |
12a844a5 | 9690 | |
585f1adc IR |
9691 | if (ret) { |
9692 | vty_out(vty, | |
9693 | "VRF default is not configured as a bgp instance\n"); | |
9694 | return CMD_WARNING; | |
9695 | } | |
9696 | } | |
12a844a5 | 9697 | |
585f1adc IR |
9698 | vrf_bgp = bgp_lookup_by_name(import_name); |
9699 | if (!vrf_bgp) { | |
9700 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
9701 | vrf_bgp = bgp_default; | |
9702 | else | |
9703 | /* Auto-create assuming the same AS */ | |
e55b0883 PG |
9704 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type, |
9705 | NULL, ASNOTATION_UNDEFINED); | |
585f1adc IR |
9706 | if (ret) { |
9707 | vty_out(vty, | |
9708 | "VRF %s is not configured as a bgp instance\n", | |
9709 | import_name); | |
9710 | return CMD_WARNING; | |
9711 | } | |
9712 | } | |
9713 | ||
9714 | if (remove) { | |
9715 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
9716 | } else { | |
9717 | /* Already importing from "import_vrf"? */ | |
9718 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
9719 | vname)) { | |
9720 | if (strcmp(vname, import_name) == 0) | |
9721 | return CMD_WARNING; | |
9722 | } | |
9723 | ||
9724 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
9725 | } | |
9726 | ||
9727 | return CMD_SUCCESS; | |
12a844a5 DS |
9728 | } |
9729 | ||
b9c7bc5a | 9730 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 9731 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
9732 | bgp_imexport_vpn_cmd, |
9733 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9734 | NO_STR |
9735 | "Import routes to this address-family\n" | |
9736 | "Export routes from this address-family\n" | |
9737 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9738 | { |
585f1adc IR |
9739 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9740 | int previous_state; | |
37a87b8f | 9741 | afi_t afi; |
585f1adc IR |
9742 | safi_t safi; |
9743 | int idx = 0; | |
9744 | bool yes = true; | |
9745 | int flag; | |
9c2fd3fe | 9746 | enum vpn_policy_direction dir; |
585f1adc IR |
9747 | |
9748 | if (argv_find(argv, argc, "no", &idx)) | |
9749 | yes = false; | |
9750 | ||
9751 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
9752 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
9753 | ||
9754 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
9755 | return CMD_WARNING_CONFIG_FAILED; | |
9756 | } | |
ddb5b488 | 9757 | |
b9c7bc5a PZ |
9758 | afi = bgp_node_afi(vty); |
9759 | safi = bgp_node_safi(vty); | |
585f1adc IR |
9760 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
9761 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
9762 | return CMD_WARNING_CONFIG_FAILED; | |
9763 | } | |
ddb5b488 | 9764 | |
b9c7bc5a | 9765 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
9766 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
9767 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 9768 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
9769 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
9770 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
9771 | } else { |
9772 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9773 | return CMD_WARNING_CONFIG_FAILED; | |
9774 | } | |
9775 | ||
585f1adc | 9776 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 9777 | |
585f1adc IR |
9778 | if (yes) { |
9779 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9780 | if (!previous_state) { | |
9781 | /* trigger export current vrf */ | |
9782 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9783 | } | |
9784 | } else { | |
9785 | if (previous_state) { | |
9786 | /* trigger un-export current vrf */ | |
9787 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9788 | } | |
9789 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9790 | } | |
37a87b8f | 9791 | |
1ca2fd11 IR |
9792 | hook_call(bgp_snmp_init_stats, bgp); |
9793 | ||
585f1adc | 9794 | return CMD_SUCCESS; |
ddb5b488 PZ |
9795 | } |
9796 | ||
301ad80a PG |
9797 | DEFPY (af_routetarget_import, |
9798 | af_routetarget_import_cmd, | |
9a659715 | 9799 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9800 | NO_STR |
9801 | "Specify route target list\n" | |
9802 | "Specify route target list\n" | |
9a659715 PG |
9803 | "Specify route target list\n" |
9804 | "Specify route target list\n" | |
301ad80a PG |
9805 | "Flow-spec redirect type route target\n" |
9806 | "Import routes to this address-family\n" | |
9a659715 | 9807 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9808 | { |
9809 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9810 | int ret; | |
9811 | struct ecommunity *ecom = NULL; | |
301ad80a | 9812 | afi_t afi; |
9a659715 | 9813 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9814 | bool yes = true; |
9815 | bool rt6 = false; | |
301ad80a PG |
9816 | |
9817 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9818 | yes = false; |
301ad80a | 9819 | |
9a659715 PG |
9820 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9821 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9822 | rt6 = true; |
301ad80a | 9823 | |
0ca70ba5 | 9824 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9825 | if (afi == AFI_MAX) |
9826 | return CMD_WARNING_CONFIG_FAILED; | |
9827 | ||
9a659715 PG |
9828 | if (rt6 && afi != AFI_IP6) |
9829 | return CMD_WARNING_CONFIG_FAILED; | |
9830 | ||
301ad80a PG |
9831 | if (yes) { |
9832 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9833 | vty_out(vty, "%% Missing RTLIST\n"); | |
9834 | return CMD_WARNING_CONFIG_FAILED; | |
9835 | } | |
9a659715 | 9836 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9837 | if (ret != CMD_SUCCESS) |
9838 | return ret; | |
9839 | } | |
69b07479 DS |
9840 | |
9841 | if (yes) { | |
9842 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9843 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9844 | .import_redirect_rtlist); |
69b07479 DS |
9845 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9846 | ecommunity_dup(ecom); | |
9847 | } else { | |
9848 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9849 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9850 | .import_redirect_rtlist); |
69b07479 | 9851 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9852 | } |
69b07479 | 9853 | |
301ad80a PG |
9854 | if (ecom) |
9855 | ecommunity_free(&ecom); | |
9856 | ||
9857 | return CMD_SUCCESS; | |
9858 | } | |
9859 | ||
505e5056 | 9860 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9861 | address_family_ipv4_safi_cmd, |
9862 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9863 | "Enter Address Family command mode\n" | |
00e6edb9 | 9864 | BGP_AF_STR |
7c40bf39 | 9865 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 9866 | { |
f51bae9c | 9867 | |
d62a17ae | 9868 | if (argc == 3) { |
585f1adc IR |
9869 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9870 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9871 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9872 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9873 | && safi != SAFI_EVPN) { |
31947174 MK |
9874 | vty_out(vty, |
9875 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9876 | return CMD_WARNING_CONFIG_FAILED; |
9877 | } | |
585f1adc IR |
9878 | vty->node = bgp_node_type(AFI_IP, safi); |
9879 | } else | |
9880 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9881 | |
d62a17ae | 9882 | return CMD_SUCCESS; |
718e3744 | 9883 | } |
9884 | ||
505e5056 | 9885 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9886 | address_family_ipv6_safi_cmd, |
9887 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9888 | "Enter Address Family command mode\n" | |
00e6edb9 | 9889 | BGP_AF_STR |
7c40bf39 | 9890 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 9891 | { |
d62a17ae | 9892 | if (argc == 3) { |
585f1adc IR |
9893 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9894 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9895 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9896 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9897 | && safi != SAFI_EVPN) { |
31947174 MK |
9898 | vty_out(vty, |
9899 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9900 | return CMD_WARNING_CONFIG_FAILED; |
9901 | } | |
585f1adc IR |
9902 | vty->node = bgp_node_type(AFI_IP6, safi); |
9903 | } else | |
9904 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9905 | |
d62a17ae | 9906 | return CMD_SUCCESS; |
25ffbdc1 | 9907 | } |
718e3744 | 9908 | |
d6902373 | 9909 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9910 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9911 | address_family_vpnv4_cmd, |
8334fd5a | 9912 | "address-family vpnv4 [unicast]", |
718e3744 | 9913 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9914 | BGP_AF_STR |
9915 | BGP_AF_MODIFIER_STR) | |
718e3744 | 9916 | { |
d62a17ae | 9917 | vty->node = BGP_VPNV4_NODE; |
9918 | return CMD_SUCCESS; | |
718e3744 | 9919 | } |
9920 | ||
505e5056 | 9921 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9922 | address_family_vpnv6_cmd, |
8334fd5a | 9923 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9924 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9925 | BGP_AF_STR |
9926 | BGP_AF_MODIFIER_STR) | |
8ecd3266 | 9927 | { |
d62a17ae | 9928 | vty->node = BGP_VPNV6_NODE; |
9929 | return CMD_SUCCESS; | |
8ecd3266 | 9930 | } |
64e4a6c5 | 9931 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9932 | |
505e5056 | 9933 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9934 | address_family_evpn_cmd, |
7111c1a0 | 9935 | "address-family l2vpn evpn", |
4e0b7b6d | 9936 | "Enter Address Family command mode\n" |
00e6edb9 DA |
9937 | BGP_AF_STR |
9938 | BGP_AF_MODIFIER_STR) | |
4e0b7b6d | 9939 | { |
2131d5cf | 9940 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9941 | vty->node = BGP_EVPN_NODE; |
9942 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9943 | } |
9944 | ||
bfaab44d HS |
9945 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9946 | bgp_segment_routing_srv6_cmd, | |
9947 | "segment-routing srv6", | |
9948 | "Segment-Routing configuration\n" | |
9949 | "Segment-Routing SRv6 configuration\n") | |
9950 | { | |
9951 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9952 | bgp->srv6_enabled = true; |
bfaab44d HS |
9953 | vty->node = BGP_SRV6_NODE; |
9954 | return CMD_SUCCESS; | |
9955 | } | |
9956 | ||
0249b8b6 HS |
9957 | DEFUN (no_bgp_segment_routing_srv6, |
9958 | no_bgp_segment_routing_srv6_cmd, | |
9959 | "no segment-routing srv6", | |
9960 | NO_STR | |
9961 | "Segment-Routing configuration\n" | |
9962 | "Segment-Routing SRv6 configuration\n") | |
9963 | { | |
9964 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9965 | ||
9966 | if (strlen(bgp->srv6_locator_name) > 0) | |
9967 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9968 | return CMD_WARNING_CONFIG_FAILED; | |
9969 | ||
9970 | bgp->srv6_enabled = false; | |
9971 | return CMD_SUCCESS; | |
9972 | } | |
9973 | ||
a0281b2e HS |
9974 | DEFPY (bgp_srv6_locator, |
9975 | bgp_srv6_locator_cmd, | |
9976 | "locator NAME$name", | |
9977 | "Specify SRv6 locator\n" | |
9978 | "Specify SRv6 locator\n") | |
9979 | { | |
9980 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9981 | int ret; |
a0281b2e HS |
9982 | |
9983 | if (strlen(bgp->srv6_locator_name) > 0 | |
9984 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9985 | vty_out(vty, "srv6 locator is already configured\n"); | |
9986 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9987 | } |
9988 | ||
9989 | snprintf(bgp->srv6_locator_name, | |
9990 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9991 | |
7de4c885 | 9992 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9993 | if (ret < 0) |
9994 | return CMD_WARNING_CONFIG_FAILED; | |
9995 | ||
9996 | return CMD_SUCCESS; | |
9997 | } | |
9998 | ||
0249b8b6 HS |
9999 | DEFPY (no_bgp_srv6_locator, |
10000 | no_bgp_srv6_locator_cmd, | |
10001 | "no locator NAME$name", | |
10002 | NO_STR | |
10003 | "Specify SRv6 locator\n" | |
10004 | "Specify SRv6 locator\n") | |
10005 | { | |
10006 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
10007 | ||
10008 | /* when locator isn't configured, do nothing */ | |
10009 | if (strlen(bgp->srv6_locator_name) < 1) | |
10010 | return CMD_SUCCESS; | |
10011 | ||
10012 | /* name validation */ | |
10013 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
10014 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
10015 | return CMD_WARNING_CONFIG_FAILED; | |
10016 | } | |
10017 | ||
10018 | /* unset locator */ | |
10019 | if (bgp_srv6_locator_unset(bgp) < 0) | |
10020 | return CMD_WARNING_CONFIG_FAILED; | |
10021 | ||
10022 | return CMD_SUCCESS; | |
10023 | } | |
10024 | ||
ea372e81 HS |
10025 | DEFPY (show_bgp_srv6, |
10026 | show_bgp_srv6_cmd, | |
10027 | "show bgp segment-routing srv6", | |
10028 | SHOW_STR | |
10029 | BGP_STR | |
10030 | "BGP Segment Routing\n" | |
10031 | "BGP Segment Routing SRv6\n") | |
10032 | { | |
10033 | struct bgp *bgp; | |
10034 | struct listnode *node; | |
1c21a234 | 10035 | struct srv6_locator_chunk *chunk; |
ea372e81 | 10036 | struct bgp_srv6_function *func; |
ea372e81 HS |
10037 | |
10038 | bgp = bgp_get_default(); | |
96db4340 | 10039 | if (!bgp) |
ea372e81 HS |
10040 | return CMD_SUCCESS; |
10041 | ||
10042 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
10043 | vty_out(vty, "locator_chunks:\n"); | |
dccef127 | 10044 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { |
511211bf | 10045 | vty_out(vty, "- %pFX\n", &chunk->prefix); |
dccef127 CS |
10046 | vty_out(vty, " block-length: %d\n", chunk->block_bits_length); |
10047 | vty_out(vty, " node-length: %d\n", chunk->node_bits_length); | |
10048 | vty_out(vty, " func-length: %d\n", | |
10049 | chunk->function_bits_length); | |
10050 | vty_out(vty, " arg-length: %d\n", chunk->argument_bits_length); | |
10051 | } | |
ea372e81 HS |
10052 | |
10053 | vty_out(vty, "functions:\n"); | |
10054 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
07380148 | 10055 | vty_out(vty, "- sid: %pI6\n", &func->sid); |
ea372e81 HS |
10056 | vty_out(vty, " locator: %s\n", func->locator_name); |
10057 | } | |
10058 | ||
10059 | vty_out(vty, "bgps:\n"); | |
10060 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
10061 | vty_out(vty, "- name: %s\n", | |
10062 | bgp->name ? bgp->name : "default"); | |
10063 | ||
1830895a CS |
10064 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %pI6\n", |
10065 | bgp->vpn_policy[AFI_IP].tovpn_sid); | |
10066 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %pI6\n", | |
10067 | bgp->vpn_policy[AFI_IP6].tovpn_sid); | |
9f5d4430 | 10068 | vty_out(vty, " per-vrf tovpn_sid: %pI6\n", bgp->tovpn_sid); |
ea372e81 HS |
10069 | } |
10070 | ||
10071 | return CMD_SUCCESS; | |
10072 | } | |
10073 | ||
505e5056 | 10074 | DEFUN_NOSH (exit_address_family, |
718e3744 | 10075 | exit_address_family_cmd, |
10076 | "exit-address-family", | |
10077 | "Exit from Address Family configuration mode\n") | |
10078 | { | |
d62a17ae | 10079 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
10080 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
10081 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
10082 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
10083 | || vty->node == BGP_EVPN_NODE |
10084 | || vty->node == BGP_FLOWSPECV4_NODE | |
10085 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 10086 | vty->node = BGP_NODE; |
10087 | return CMD_SUCCESS; | |
718e3744 | 10088 | } |
6b0655a2 | 10089 | |
8ad7271d | 10090 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 10091 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
10092 | const char *ip_str, afi_t afi, safi_t safi, | |
10093 | struct prefix_rd *prd) | |
10094 | { | |
10095 | int ret; | |
10096 | struct prefix match; | |
9bcb3eef DS |
10097 | struct bgp_dest *dest; |
10098 | struct bgp_dest *rm; | |
d62a17ae | 10099 | struct bgp *bgp; |
10100 | struct bgp_table *table; | |
10101 | struct bgp_table *rib; | |
10102 | ||
10103 | /* BGP structure lookup. */ | |
10104 | if (view_name) { | |
10105 | bgp = bgp_lookup_by_name(view_name); | |
10106 | if (bgp == NULL) { | |
10107 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
10108 | view_name); | |
10109 | return CMD_WARNING; | |
10110 | } | |
10111 | } else { | |
10112 | bgp = bgp_get_default(); | |
10113 | if (bgp == NULL) { | |
10114 | vty_out(vty, "%% No BGP process is configured\n"); | |
10115 | return CMD_WARNING; | |
10116 | } | |
10117 | } | |
10118 | ||
10119 | /* Check IP address argument. */ | |
10120 | ret = str2prefix(ip_str, &match); | |
10121 | if (!ret) { | |
10122 | vty_out(vty, "%% address is malformed\n"); | |
10123 | return CMD_WARNING; | |
10124 | } | |
10125 | ||
10126 | match.family = afi2family(afi); | |
10127 | rib = bgp->rib[afi][safi]; | |
10128 | ||
10129 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
10130 | for (dest = bgp_table_top(rib); dest; |
10131 | dest = bgp_route_next(dest)) { | |
10132 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 10133 | |
9bcb3eef | 10134 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 10135 | continue; |
10136 | ||
9bcb3eef | 10137 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
10138 | if (table == NULL) |
10139 | continue; | |
10140 | ||
4953391b DA |
10141 | rm = bgp_node_match(table, &match); |
10142 | if (rm != NULL) { | |
b54892e0 | 10143 | const struct prefix *rm_p = |
9bcb3eef | 10144 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
10145 | |
10146 | if (rm_p->prefixlen == match.prefixlen) { | |
10147 | SET_FLAG(rm->flags, | |
10148 | BGP_NODE_USER_CLEAR); | |
10149 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 10150 | } |
9bcb3eef | 10151 | bgp_dest_unlock_node(rm); |
d62a17ae | 10152 | } |
10153 | } | |
10154 | } else { | |
4953391b DA |
10155 | dest = bgp_node_match(rib, &match); |
10156 | if (dest != NULL) { | |
9bcb3eef | 10157 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 10158 | |
9bcb3eef DS |
10159 | if (dest_p->prefixlen == match.prefixlen) { |
10160 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
10161 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 10162 | } |
9bcb3eef | 10163 | bgp_dest_unlock_node(dest); |
d62a17ae | 10164 | } |
10165 | } | |
10166 | ||
10167 | return CMD_SUCCESS; | |
8ad7271d DS |
10168 | } |
10169 | ||
b09b5ae0 | 10170 | /* one clear bgp command to rule them all */ |
718e3744 | 10171 | DEFUN (clear_ip_bgp_all, |
10172 | clear_ip_bgp_all_cmd, | |
8079a413 | 10173 | "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|ASNUM|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]", |
718e3744 | 10174 | CLEAR_STR |
10175 | IP_STR | |
10176 | BGP_STR | |
838758ac | 10177 | BGP_INSTANCE_HELP_STR |
510afcd6 | 10178 | BGP_AFI_HELP_STR |
00e6edb9 | 10179 | BGP_AF_STR |
510afcd6 | 10180 | BGP_SAFI_WITH_LABEL_HELP_STR |
00e6edb9 | 10181 | BGP_AF_MODIFIER_STR |
b09b5ae0 | 10182 | "Clear all peers\n" |
453c92f6 | 10183 | "BGP IPv4 neighbor to clear\n" |
a80beece | 10184 | "BGP IPv6 neighbor to clear\n" |
838758ac | 10185 | "BGP neighbor on interface to clear\n" |
8079a413 | 10186 | "Clear peers with the AS number in plain or dotted format\n" |
b09b5ae0 | 10187 | "Clear all external peers\n" |
718e3744 | 10188 | "Clear all members of peer-group\n" |
b09b5ae0 | 10189 | "BGP peer-group name\n" |
b09b5ae0 DW |
10190 | BGP_SOFT_STR |
10191 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
10192 | BGP_SOFT_OUT_STR |
10193 | BGP_SOFT_IN_STR | |
10194 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
3cb14f26 DS |
10195 | BGP_SOFT_OUT_STR |
10196 | "Reset message statistics\n") | |
718e3744 | 10197 | { |
d62a17ae | 10198 | char *vrf = NULL; |
10199 | ||
dc912615 DS |
10200 | afi_t afi = AFI_UNSPEC; |
10201 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 10202 | enum clear_sort clr_sort = clear_peer; |
10203 | enum bgp_clear_type clr_type; | |
10204 | char *clr_arg = NULL; | |
10205 | ||
10206 | int idx = 0; | |
10207 | ||
10208 | /* clear [ip] bgp */ | |
10209 | if (argv_find(argv, argc, "ip", &idx)) | |
10210 | afi = AFI_IP; | |
10211 | ||
9a8bdf1c PG |
10212 | /* [<vrf> VIEWVRFNAME] */ |
10213 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10214 | vrf = argv[idx + 1]->arg; | |
10215 | idx += 2; | |
10216 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10217 | vrf = NULL; | |
10218 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10219 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 10220 | vrf = argv[idx + 1]->arg; |
10221 | idx += 2; | |
10222 | } | |
d62a17ae | 10223 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10224 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
10225 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10226 | ||
8079a413 | 10227 | /* <*|A.B.C.D|X:X::X:X|WORD|ASNUM|external|peer-group PGNAME> */ |
d62a17ae | 10228 | if (argv_find(argv, argc, "*", &idx)) { |
10229 | clr_sort = clear_all; | |
10230 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
10231 | clr_sort = clear_peer; | |
10232 | clr_arg = argv[idx]->arg; | |
10233 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
10234 | clr_sort = clear_peer; | |
10235 | clr_arg = argv[idx]->arg; | |
10236 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
10237 | clr_sort = clear_group; | |
10238 | idx++; | |
10239 | clr_arg = argv[idx]->arg; | |
d7b9898c | 10240 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 10241 | clr_sort = clear_peer; |
10242 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
10243 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
10244 | clr_sort = clear_peer; | |
10245 | clr_arg = argv[idx]->arg; | |
8079a413 | 10246 | } else if (argv_find(argv, argc, "ASNUM", &idx)) { |
d62a17ae | 10247 | clr_sort = clear_as; |
10248 | clr_arg = argv[idx]->arg; | |
10249 | } else if (argv_find(argv, argc, "external", &idx)) { | |
10250 | clr_sort = clear_external; | |
10251 | } | |
10252 | ||
3cb14f26 | 10253 | /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */ |
d62a17ae | 10254 | if (argv_find(argv, argc, "soft", &idx)) { |
10255 | if (argv_find(argv, argc, "in", &idx) | |
10256 | || argv_find(argv, argc, "out", &idx)) | |
10257 | clr_type = strmatch(argv[idx]->text, "in") | |
10258 | ? BGP_CLEAR_SOFT_IN | |
10259 | : BGP_CLEAR_SOFT_OUT; | |
10260 | else | |
10261 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
10262 | } else if (argv_find(argv, argc, "in", &idx)) { | |
10263 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
10264 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
10265 | : BGP_CLEAR_SOFT_IN; | |
10266 | } else if (argv_find(argv, argc, "out", &idx)) { | |
10267 | clr_type = BGP_CLEAR_SOFT_OUT; | |
3cb14f26 DS |
10268 | } else if (argv_find(argv, argc, "message-stats", &idx)) { |
10269 | clr_type = BGP_CLEAR_MESSAGE_STATS; | |
d62a17ae | 10270 | } else |
10271 | clr_type = BGP_CLEAR_SOFT_NONE; | |
10272 | ||
1ca2fd11 | 10273 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 10274 | } |
01080f7c | 10275 | |
8ad7271d DS |
10276 | DEFUN (clear_ip_bgp_prefix, |
10277 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 10278 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
10279 | CLEAR_STR |
10280 | IP_STR | |
10281 | BGP_STR | |
838758ac | 10282 | BGP_INSTANCE_HELP_STR |
8ad7271d | 10283 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10284 | "IPv4 prefix\n") |
8ad7271d | 10285 | { |
d62a17ae | 10286 | char *vrf = NULL; |
10287 | char *prefix = NULL; | |
8ad7271d | 10288 | |
d62a17ae | 10289 | int idx = 0; |
01080f7c | 10290 | |
d62a17ae | 10291 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
10292 | if (argv_find(argv, argc, "vrf", &idx)) { |
10293 | vrf = argv[idx + 1]->arg; | |
10294 | idx += 2; | |
10295 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10296 | vrf = NULL; | |
10297 | } else if (argv_find(argv, argc, "view", &idx)) { | |
10298 | /* [<view> VIEWVRFNAME] */ | |
10299 | vrf = argv[idx + 1]->arg; | |
10300 | idx += 2; | |
10301 | } | |
0c7b1b01 | 10302 | |
d62a17ae | 10303 | prefix = argv[argc - 1]->arg; |
8ad7271d | 10304 | |
d62a17ae | 10305 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 10306 | } |
8ad7271d | 10307 | |
b09b5ae0 DW |
10308 | DEFUN (clear_bgp_ipv6_safi_prefix, |
10309 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 10310 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10311 | CLEAR_STR |
3a2d747c | 10312 | IP_STR |
718e3744 | 10313 | BGP_STR |
00e6edb9 | 10314 | BGP_AF_STR |
46f296b4 | 10315 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10316 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10317 | "IPv6 prefix\n") |
718e3744 | 10318 | { |
9b475e76 PG |
10319 | int idx_safi = 0; |
10320 | int idx_ipv6_prefix = 0; | |
10321 | safi_t safi = SAFI_UNICAST; | |
10322 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10323 | argv[idx_ipv6_prefix]->arg : NULL; | |
10324 | ||
10325 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 10326 | return bgp_clear_prefix( |
9b475e76 PG |
10327 | vty, NULL, prefix, AFI_IP6, |
10328 | safi, NULL); | |
838758ac | 10329 | } |
01080f7c | 10330 | |
b09b5ae0 DW |
10331 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
10332 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 10333 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 10334 | CLEAR_STR |
3a2d747c | 10335 | IP_STR |
718e3744 | 10336 | BGP_STR |
838758ac | 10337 | BGP_INSTANCE_HELP_STR |
00e6edb9 | 10338 | BGP_AF_STR |
46f296b4 | 10339 | BGP_SAFI_HELP_STR |
b09b5ae0 | 10340 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 10341 | "IPv6 prefix\n") |
718e3744 | 10342 | { |
9b475e76 | 10343 | int idx_safi = 0; |
9a8bdf1c | 10344 | int idx_vrfview = 0; |
9b475e76 PG |
10345 | int idx_ipv6_prefix = 0; |
10346 | safi_t safi = SAFI_UNICAST; | |
10347 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
10348 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 10349 | char *vrfview = NULL; |
9b475e76 | 10350 | |
9a8bdf1c PG |
10351 | /* [<view|vrf> VIEWVRFNAME] */ |
10352 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
10353 | vrfview = argv[idx_vrfview + 1]->arg; | |
10354 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
10355 | vrfview = NULL; | |
10356 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
10357 | /* [<view> VIEWVRFNAME] */ | |
10358 | vrfview = argv[idx_vrfview + 1]->arg; | |
10359 | } | |
9b475e76 PG |
10360 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
10361 | ||
d62a17ae | 10362 | return bgp_clear_prefix( |
9b475e76 PG |
10363 | vty, vrfview, prefix, |
10364 | AFI_IP6, safi, NULL); | |
718e3744 | 10365 | } |
10366 | ||
b09b5ae0 DW |
10367 | DEFUN (show_bgp_views, |
10368 | show_bgp_views_cmd, | |
d6e3c605 | 10369 | "show [ip] bgp views", |
b09b5ae0 | 10370 | SHOW_STR |
d6e3c605 | 10371 | IP_STR |
01080f7c | 10372 | BGP_STR |
b09b5ae0 | 10373 | "Show the defined BGP views\n") |
01080f7c | 10374 | { |
d62a17ae | 10375 | struct list *inst = bm->bgp; |
10376 | struct listnode *node; | |
10377 | struct bgp *bgp; | |
01080f7c | 10378 | |
d62a17ae | 10379 | vty_out(vty, "Defined BGP views:\n"); |
10380 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
10381 | /* Skip VRFs. */ | |
10382 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
10383 | continue; | |
9eb11997 PG |
10384 | vty_out(vty, "\t%s (AS%s)\n", bgp->name ? bgp->name : "(null)", |
10385 | bgp->as_pretty); | |
d62a17ae | 10386 | } |
e52702f2 | 10387 | |
d62a17ae | 10388 | return CMD_SUCCESS; |
e0081f70 ML |
10389 | } |
10390 | ||
4acd6bc9 SPG |
10391 | static inline void calc_peers_cfgd_estbd(struct bgp *bgp, int *peers_cfgd, |
10392 | int *peers_estbd) | |
10393 | { | |
10394 | struct peer *peer; | |
10395 | struct listnode *node; | |
10396 | ||
10397 | *peers_cfgd = *peers_estbd = 0; | |
10398 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { | |
10399 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10400 | continue; | |
10401 | (*peers_cfgd)++; | |
10402 | if (peer_established(peer)) | |
10403 | (*peers_estbd)++; | |
10404 | } | |
10405 | } | |
10406 | ||
10407 | static void print_bgp_vrfs(struct bgp *bgp, struct vty *vty, json_object *json, | |
10408 | const char *type) | |
10409 | { | |
10410 | int peers_cfg, peers_estb; | |
10411 | ||
10412 | calc_peers_cfgd_estbd(bgp, &peers_cfg, &peers_estb); | |
10413 | ||
10414 | if (json) { | |
10415 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) | |
10416 | ? -1 | |
10417 | : (int64_t)bgp->vrf_id; | |
10418 | json_object_string_add(json, "type", type); | |
10419 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
10420 | json_object_string_addf(json, "routerId", "%pI4", | |
10421 | &bgp->router_id); | |
10422 | json_object_int_add(json, "numConfiguredPeers", peers_cfg); | |
10423 | json_object_int_add(json, "numEstablishedPeers", peers_estb); | |
10424 | json_object_int_add(json, "l3vni", bgp->l3vni); | |
10425 | json_object_string_addf(json, "rmac", "%pEA", &bgp->rmac); | |
10426 | json_object_string_add( | |
10427 | json, "interface", | |
10428 | ifindex2ifname(bgp->l3vni_svi_ifindex, bgp->vrf_id)); | |
10429 | } | |
10430 | } | |
10431 | ||
10432 | static int show_bgp_vrfs_detail_common(struct vty *vty, struct bgp *bgp, | |
10433 | json_object *json, const char *name, | |
10434 | const char *type, bool use_vrf) | |
10435 | { | |
10436 | int peers_cfg, peers_estb; | |
10437 | ||
10438 | calc_peers_cfgd_estbd(bgp, &peers_cfg, &peers_estb); | |
10439 | ||
10440 | if (use_vrf) { | |
10441 | if (json) { | |
10442 | print_bgp_vrfs(bgp, vty, json, type); | |
10443 | } else { | |
10444 | vty_out(vty, "BGP instance %s VRF id %d\n", | |
10445 | bgp->name_pretty, | |
10446 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10447 | : (int)bgp->vrf_id); | |
10448 | vty_out(vty, "Router Id %pI4\n", &bgp->router_id); | |
10449 | vty_out(vty, | |
10450 | "Num Configured Peers %d, Established %d\n", | |
10451 | peers_cfg, peers_estb); | |
10452 | if (bgp->l3vni) { | |
10453 | vty_out(vty, | |
10454 | "L3VNI %u, L3VNI-SVI %s, Router MAC %pEA\n", | |
10455 | bgp->l3vni, | |
10456 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10457 | bgp->vrf_id), | |
10458 | &bgp->rmac); | |
10459 | } | |
10460 | } | |
10461 | } else { | |
10462 | if (json) { | |
10463 | print_bgp_vrfs(bgp, vty, json, type); | |
10464 | } else { | |
10465 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", | |
10466 | type, | |
10467 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
10468 | : (int)bgp->vrf_id, | |
10469 | &bgp->router_id, peers_cfg, peers_estb, name); | |
10470 | vty_out(vty, "%11s %-16u %-21pEA %-20s\n", " ", | |
10471 | bgp->l3vni, &bgp->rmac, | |
10472 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
10473 | bgp->vrf_id)); | |
10474 | } | |
10475 | } | |
10476 | ||
10477 | return CMD_SUCCESS; | |
10478 | } | |
10479 | ||
10480 | DEFPY (show_bgp_vrfs, | |
8386ac43 | 10481 | show_bgp_vrfs_cmd, |
4acd6bc9 | 10482 | "show [ip] bgp vrfs [<VRFNAME$vrf_name>] [json]", |
8386ac43 | 10483 | SHOW_STR |
d6e3c605 | 10484 | IP_STR |
8386ac43 | 10485 | BGP_STR |
10486 | "Show BGP VRFs\n" | |
4acd6bc9 | 10487 | "Specific VRF name\n" |
9973d184 | 10488 | JSON_STR) |
8386ac43 | 10489 | { |
d62a17ae | 10490 | struct list *inst = bm->bgp; |
10491 | struct listnode *node; | |
10492 | struct bgp *bgp; | |
9f049418 | 10493 | bool uj = use_json(argc, argv); |
d62a17ae | 10494 | json_object *json = NULL; |
10495 | json_object *json_vrfs = NULL; | |
4acd6bc9 | 10496 | json_object *json_vrf = NULL; |
d62a17ae | 10497 | int count = 0; |
4acd6bc9 SPG |
10498 | const char *name = vrf_name; |
10499 | const char *type; | |
d62a17ae | 10500 | |
4acd6bc9 | 10501 | if (uj) |
d62a17ae | 10502 | json = json_object_new_object(); |
4acd6bc9 SPG |
10503 | |
10504 | if (name) { | |
10505 | if (strmatch(name, VRF_DEFAULT_NAME)) { | |
10506 | bgp = bgp_get_default(); | |
10507 | type = "DFLT"; | |
10508 | } else { | |
10509 | bgp = bgp_lookup_by_name(name); | |
10510 | type = "VRF"; | |
10511 | } | |
10512 | if (!bgp) { | |
10513 | if (uj) | |
10514 | vty_json(vty, json); | |
10515 | else | |
10516 | vty_out(vty, | |
10517 | "%% Specified BGP instance not found\n"); | |
10518 | ||
10519 | return CMD_WARNING; | |
10520 | } | |
10521 | } | |
10522 | ||
10523 | if (vrf_name) { | |
10524 | if (uj) | |
10525 | json_vrf = json_object_new_object(); | |
10526 | ||
10527 | show_bgp_vrfs_detail_common(vty, bgp, json_vrf, name, type, | |
10528 | true); | |
10529 | ||
10530 | if (uj) { | |
10531 | json_object_object_add(json, name, json_vrf); | |
10532 | vty_json(vty, json); | |
10533 | } | |
10534 | ||
10535 | return CMD_SUCCESS; | |
d62a17ae | 10536 | } |
10537 | ||
4acd6bc9 SPG |
10538 | if (uj) |
10539 | json_vrfs = json_object_new_object(); | |
10540 | ||
d62a17ae | 10541 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { |
4acd6bc9 | 10542 | const char *name; |
d62a17ae | 10543 | |
10544 | /* Skip Views. */ | |
10545 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
10546 | continue; | |
10547 | ||
10548 | count++; | |
efb4077a | 10549 | if (!uj && count == 1) { |
fe1dc5a3 | 10550 | vty_out(vty, |
efb4077a | 10551 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 10552 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
10553 | "#PeersEstb", "Name"); |
10554 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
10555 | "L3-VNI", "RouterMAC", "Interface"); | |
10556 | } | |
d62a17ae | 10557 | if (uj) |
10558 | json_vrf = json_object_new_object(); | |
10559 | ||
d62a17ae | 10560 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { |
5742e42b | 10561 | name = VRF_DEFAULT_NAME; |
d62a17ae | 10562 | type = "DFLT"; |
10563 | } else { | |
10564 | name = bgp->name; | |
10565 | type = "VRF"; | |
10566 | } | |
10567 | ||
4acd6bc9 SPG |
10568 | show_bgp_vrfs_detail_common(vty, bgp, json_vrf, name, type, |
10569 | false); | |
a8bf7d9c | 10570 | |
4acd6bc9 | 10571 | if (uj) |
d62a17ae | 10572 | json_object_object_add(json_vrfs, name, json_vrf); |
d62a17ae | 10573 | } |
10574 | ||
10575 | if (uj) { | |
10576 | json_object_object_add(json, "vrfs", json_vrfs); | |
d62a17ae | 10577 | json_object_int_add(json, "totalVrfs", count); |
75eeda93 | 10578 | vty_json(vty, json); |
d62a17ae | 10579 | } else { |
10580 | if (count) | |
10581 | vty_out(vty, | |
10582 | "\nTotal number of VRFs (including default): %d\n", | |
10583 | count); | |
10584 | } | |
10585 | ||
10586 | return CMD_SUCCESS; | |
8386ac43 | 10587 | } |
10588 | ||
48ecf8f5 DS |
10589 | DEFUN (show_bgp_mac_hash, |
10590 | show_bgp_mac_hash_cmd, | |
10591 | "show bgp mac hash", | |
10592 | SHOW_STR | |
10593 | BGP_STR | |
10594 | "Mac Address\n" | |
10595 | "Mac Address database\n") | |
10596 | { | |
10597 | bgp_mac_dump_table(vty); | |
10598 | ||
10599 | return CMD_SUCCESS; | |
10600 | } | |
acf71666 | 10601 | |
e3b78da8 | 10602 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 10603 | { |
0291c246 | 10604 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 10605 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 10606 | |
23d0a753 | 10607 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
10608 | } |
10609 | ||
10610 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
10611 | { | |
10612 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 10613 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
10614 | |
10615 | vty_out(vty, "Tunnel-ip database:\n"); | |
10616 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 10617 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
10618 | vty); |
10619 | } | |
10620 | ||
15c81ca4 DS |
10621 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
10622 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
10623 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
10624 | "martian next-hops\n" |
10625 | "martian next-hop database\n") | |
acf71666 | 10626 | { |
0291c246 | 10627 | struct bgp *bgp = NULL; |
15c81ca4 | 10628 | int idx = 0; |
9a8bdf1c PG |
10629 | char *name = NULL; |
10630 | ||
10631 | /* [<vrf> VIEWVRFNAME] */ | |
10632 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10633 | name = argv[idx + 1]->arg; | |
10634 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
10635 | name = NULL; | |
10636 | } else if (argv_find(argv, argc, "view", &idx)) | |
10637 | /* [<view> VIEWVRFNAME] */ | |
10638 | name = argv[idx + 1]->arg; | |
10639 | if (name) | |
10640 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
10641 | else |
10642 | bgp = bgp_get_default(); | |
acf71666 | 10643 | |
acf71666 MK |
10644 | if (!bgp) { |
10645 | vty_out(vty, "%% No BGP process is configured\n"); | |
10646 | return CMD_WARNING; | |
10647 | } | |
10648 | bgp_show_martian_nexthops(vty, bgp); | |
10649 | ||
10650 | return CMD_SUCCESS; | |
10651 | } | |
10652 | ||
f412b39a | 10653 | DEFUN (show_bgp_memory, |
4bf6a362 | 10654 | show_bgp_memory_cmd, |
7fa12b13 | 10655 | "show [ip] bgp memory", |
4bf6a362 | 10656 | SHOW_STR |
3a2d747c | 10657 | IP_STR |
4bf6a362 PJ |
10658 | BGP_STR |
10659 | "Global BGP memory statistics\n") | |
10660 | { | |
d62a17ae | 10661 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
10662 | unsigned long count; | |
10663 | ||
10664 | /* RIB related usage stats */ | |
10665 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
10666 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
10667 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 10668 | count * sizeof(struct bgp_dest))); |
d62a17ae | 10669 | |
10670 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
10671 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10672 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10673 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10674 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10675 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10676 | count, | |
4b7e6066 DS |
10677 | mtype_memstr( |
10678 | memstrbuf, sizeof(memstrbuf), | |
10679 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10680 | |
10681 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10682 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10683 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10684 | count * sizeof(struct bgp_static))); | |
10685 | ||
10686 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10687 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10688 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10689 | count * sizeof(struct bpacket))); | |
10690 | ||
10691 | /* Adj-In/Out */ | |
10692 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10693 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10694 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10695 | count * sizeof(struct bgp_adj_in))); | |
10696 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10697 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10698 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10699 | count * sizeof(struct bgp_adj_out))); | |
10700 | ||
10701 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10702 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10703 | count, | |
10704 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10705 | count * sizeof(struct bgp_nexthop_cache))); | |
10706 | ||
10707 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10708 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10709 | count, | |
10710 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10711 | count * sizeof(struct bgp_damp_info))); | |
10712 | ||
10713 | /* Attributes */ | |
10714 | count = attr_count(); | |
10715 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10716 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10717 | count * sizeof(struct attr))); | |
10718 | ||
10719 | if ((count = attr_unknown_count())) | |
10720 | vty_out(vty, "%ld unknown attributes\n", count); | |
10721 | ||
10722 | /* AS_PATH attributes */ | |
10723 | count = aspath_count(); | |
10724 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10725 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10726 | count * sizeof(struct aspath))); | |
10727 | ||
10728 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10729 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10730 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10731 | count * sizeof(struct assegment))); | |
10732 | ||
10733 | /* Other attributes */ | |
10734 | if ((count = community_count())) | |
10735 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10736 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10737 | count * sizeof(struct community))); | |
d62a17ae | 10738 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
145f7619 DA |
10739 | vty_out(vty, |
10740 | "%ld BGP ext-community entries, using %s of memory\n", | |
10741 | count, | |
10742 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10743 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10744 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10745 | vty_out(vty, | |
10746 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10747 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10748 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10749 | |
10750 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10751 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10752 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10753 | count * sizeof(struct cluster_list))); | |
10754 | ||
10755 | /* Peer related usage */ | |
10756 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10757 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10758 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10759 | count * sizeof(struct peer))); | |
10760 | ||
10761 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10762 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10763 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10764 | count * sizeof(struct peer_group))); | |
10765 | ||
10766 | /* Other */ | |
d62a17ae | 10767 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10768 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10769 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10770 | count * sizeof(regex_t))); | |
d62a17ae | 10771 | return CMD_SUCCESS; |
4bf6a362 | 10772 | } |
fee0f4c6 | 10773 | |
57a9c8a8 DS |
10774 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10775 | { | |
10776 | json_object *bestpath = json_object_new_object(); | |
10777 | ||
892fedb6 | 10778 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10779 | json_object_string_add(bestpath, "asPath", "ignore"); |
10780 | ||
892fedb6 | 10781 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10782 | json_object_string_add(bestpath, "asPath", "confed"); |
10783 | ||
892fedb6 DA |
10784 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10785 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10786 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10787 | "as-set"); |
10788 | else | |
a4d82a8a | 10789 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10790 | "true"); |
10791 | } else | |
a4d82a8a | 10792 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10793 | |
ee88563a JM |
10794 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
10795 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
10796 | ||
892fedb6 | 10797 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10798 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10799 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10800 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10801 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10802 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10803 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10804 | json_object_string_add(bestpath, "med", |
10805 | "missing-as-worst"); | |
10806 | else | |
10807 | json_object_string_add(bestpath, "med", "true"); | |
10808 | } | |
10809 | ||
10810 | json_object_object_add(json, "bestPath", bestpath); | |
10811 | } | |
10812 | ||
3577f1c5 DD |
10813 | /* Print the error code/subcode for why the peer is down */ |
10814 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10815 | json_object *json_peer, bool use_json) | |
10816 | { | |
10817 | const char *code_str; | |
10818 | const char *subcode_str; | |
10819 | ||
10820 | if (use_json) { | |
10821 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10822 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10823 | char errorcodesubcode_hexstr[5]; | |
10824 | char errorcodesubcode_str[256]; | |
10825 | ||
10826 | code_str = bgp_notify_code_str(peer->notify.code); | |
10827 | subcode_str = bgp_notify_subcode_str( | |
10828 | peer->notify.code, | |
10829 | peer->notify.subcode); | |
10830 | ||
772270f3 QY |
10831 | snprintf(errorcodesubcode_hexstr, |
10832 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10833 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10834 | json_object_string_add(json_peer, |
10835 | "lastErrorCodeSubcode", | |
10836 | errorcodesubcode_hexstr); | |
10837 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10838 | code_str, subcode_str); | |
10839 | json_object_string_add(json_peer, | |
10840 | "lastNotificationReason", | |
10841 | errorcodesubcode_str); | |
eea685b6 DA |
10842 | json_object_boolean_add(json_peer, |
10843 | "lastNotificationHardReset", | |
10844 | peer->notify.hard_reset); | |
3577f1c5 DD |
10845 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
10846 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10847 | && (peer->notify.subcode | |
10848 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10849 | || peer->notify.subcode | |
10850 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10851 | && peer->notify.length) { | |
10852 | char msgbuf[1024]; | |
10853 | const char *msg_str; | |
10854 | ||
10855 | msg_str = bgp_notify_admin_message( | |
10856 | msgbuf, sizeof(msgbuf), | |
10857 | (uint8_t *)peer->notify.data, | |
10858 | peer->notify.length); | |
10859 | if (msg_str) | |
10860 | json_object_string_add( | |
10861 | json_peer, | |
10862 | "lastShutdownDescription", | |
10863 | msg_str); | |
10864 | } | |
10865 | ||
c258527b | 10866 | } |
3577f1c5 DD |
10867 | json_object_string_add(json_peer, "lastResetDueTo", |
10868 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10869 | json_object_int_add(json_peer, "lastResetCode", |
10870 | peer->last_reset); | |
3577f1c5 DD |
10871 | } else { |
10872 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10873 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10874 | code_str = bgp_notify_code_str(peer->notify.code); | |
10875 | subcode_str = | |
10876 | bgp_notify_subcode_str(peer->notify.code, | |
10877 | peer->notify.subcode); | |
eea685b6 | 10878 | vty_out(vty, " Notification %s (%s%s%s)\n", |
3577f1c5 | 10879 | peer->last_reset == PEER_DOWN_NOTIFY_SEND |
eea685b6 DA |
10880 | ? "sent" |
10881 | : "received", | |
10882 | code_str, subcode_str, | |
10883 | peer->notify.hard_reset | |
10884 | ? bgp_notify_subcode_str( | |
10885 | BGP_NOTIFY_CEASE, | |
10886 | BGP_NOTIFY_CEASE_HARD_RESET) | |
10887 | : ""); | |
3577f1c5 | 10888 | } else { |
e91c24c8 | 10889 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10890 | peer_down_str[(int)peer->last_reset]); |
10891 | } | |
10892 | } | |
10893 | } | |
10894 | ||
10895 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10896 | safi_t safi) | |
10897 | { | |
feb17238 | 10898 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10899 | } |
10900 | ||
10901 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10902 | struct peer *peer, json_object *json_peer, | |
10903 | int max_neighbor_width, bool use_json) | |
10904 | { | |
10905 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10906 | int len; | |
10907 | ||
10908 | if (use_json) { | |
10909 | if (peer_dynamic_neighbor(peer)) | |
10910 | json_object_boolean_true_add(json_peer, | |
10911 | "dynamicPeer"); | |
10912 | if (peer->hostname) | |
10913 | json_object_string_add(json_peer, "hostname", | |
10914 | peer->hostname); | |
10915 | ||
10916 | if (peer->domainname) | |
10917 | json_object_string_add(json_peer, "domainname", | |
10918 | peer->domainname); | |
10919 | json_object_int_add(json_peer, "connectionsEstablished", | |
10920 | peer->established); | |
10921 | json_object_int_add(json_peer, "connectionsDropped", | |
10922 | peer->dropped); | |
10923 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10924 | use_json, json_peer); | |
feb17238 | 10925 | if (peer_established(peer)) |
3577f1c5 DD |
10926 | json_object_string_add(json_peer, "lastResetDueTo", |
10927 | "AFI/SAFI Not Negotiated"); | |
10928 | else | |
10929 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10930 | } else { | |
10931 | dn_flag[1] = '\0'; | |
10932 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10933 | if (peer->hostname | |
892fedb6 | 10934 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10935 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10936 | peer->hostname, peer->host); | |
10937 | else | |
10938 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10939 | ||
10940 | /* pad the neighbor column with spaces */ | |
10941 | if (len < max_neighbor_width) | |
10942 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10943 | " "); | |
e91c24c8 | 10944 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10945 | peer->dropped, |
10946 | peer_uptime(peer->uptime, timebuf, | |
10947 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10948 | if (peer_established(peer)) |
3577f1c5 DD |
10949 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10950 | else | |
10951 | bgp_show_peer_reset(vty, peer, NULL, | |
10952 | false); | |
10953 | } | |
10954 | } | |
c258527b | 10955 | |
565e9ddd | 10956 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10957 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10958 | { | |
10959 | static char stripped[BUFSIZ]; | |
64541ffa FD |
10960 | uint32_t i = 0; |
10961 | uint32_t last_space = 0; | |
cb75bb31 | 10962 | |
64541ffa FD |
10963 | while (i < size) { |
10964 | if (*(desc + i) == 0) { | |
10965 | stripped[i] = '\0'; | |
10966 | return stripped; | |
10967 | } | |
10968 | if (i != 0 && *(desc + i) == ' ' && last_space != i - 1) | |
10969 | last_space = i; | |
10970 | stripped[i] = *(desc + i); | |
10971 | i++; | |
10972 | } | |
10973 | ||
10974 | if (last_space > size) | |
10975 | stripped[size + 1] = '\0'; | |
10976 | else | |
10977 | stripped[last_space] = '\0'; | |
cb75bb31 DA |
10978 | |
10979 | return stripped; | |
10980 | } | |
3577f1c5 | 10981 | |
8c1d4cd5 LS |
10982 | /* Determine whether var peer should be filtered out of the summary. */ |
10983 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10984 | struct peer *fpeer, int as_type, | |
10985 | as_t as) | |
10986 | { | |
10987 | ||
10988 | /* filter neighbor XXXX */ | |
10989 | if (fpeer && fpeer != peer) | |
10990 | return true; | |
10991 | ||
10992 | /* filter remote-as (internal|external) */ | |
10993 | if (as_type != AS_UNSPECIFIED) { | |
10994 | if (peer->as_type == AS_SPECIFIED) { | |
10995 | if (as_type == AS_INTERNAL) { | |
10996 | if (peer->as != peer->local_as) | |
10997 | return true; | |
10998 | } else if (peer->as == peer->local_as) | |
10999 | return true; | |
11000 | } else if (as_type != peer->as_type) | |
11001 | return true; | |
11002 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
11003 | return true; | |
11004 | ||
11005 | return false; | |
11006 | } | |
11007 | ||
565e9ddd DA |
11008 | /* Show BGP peer's summary information. |
11009 | * | |
11010 | * Peer's description is stripped according to if `wide` option is given | |
11011 | * or not. | |
11012 | * | |
11013 | * When adding new columns to `show bgp summary` output, please make | |
11014 | * sure `Desc` is the lastest column to show because it can contain | |
11015 | * whitespaces and the whole output will be tricky. | |
11016 | */ | |
d62a17ae | 11017 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 11018 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 11019 | uint16_t show_flags) |
d62a17ae | 11020 | { |
11021 | struct peer *peer; | |
11022 | struct listnode *node, *nnode; | |
11023 | unsigned int count = 0, dn_count = 0; | |
11024 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
11025 | char neighbor_buf[VTY_BUFSIZ]; | |
11026 | int neighbor_col_default_width = 16; | |
3577f1c5 | 11027 | int len, failed_count = 0; |
ce1944f0 | 11028 | unsigned int filtered_count = 0; |
d62a17ae | 11029 | int max_neighbor_width = 0; |
11030 | int pfx_rcd_safi; | |
3c13337d | 11031 | json_object *json = NULL; |
d62a17ae | 11032 | json_object *json_peer = NULL; |
11033 | json_object *json_peers = NULL; | |
50e05855 | 11034 | struct peer_af *paf; |
d3ada366 | 11035 | struct bgp_filter *filter; |
85eeb029 DA |
11036 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
11037 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
11038 | bool show_established = | |
11039 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
11040 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 11041 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 11042 | |
11043 | /* labeled-unicast routes are installed in the unicast table so in order | |
11044 | * to | |
11045 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
11046 | */ | |
3577f1c5 | 11047 | |
d62a17ae | 11048 | if (safi == SAFI_LABELED_UNICAST) |
11049 | pfx_rcd_safi = SAFI_UNICAST; | |
11050 | else | |
11051 | pfx_rcd_safi = safi; | |
11052 | ||
11053 | if (use_json) { | |
3c13337d | 11054 | json = json_object_new_object(); |
d62a17ae | 11055 | json_peers = json_object_new_object(); |
3577f1c5 | 11056 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
11057 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
11058 | as_type, as)) { | |
ce1944f0 | 11059 | filtered_count++; |
8c1d4cd5 LS |
11060 | count++; |
11061 | continue; | |
11062 | } | |
11063 | ||
3577f1c5 DD |
11064 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
11065 | continue; | |
11066 | ||
11067 | if (peer->afc[afi][safi]) { | |
11068 | /* See if we have at least a single failed peer */ | |
11069 | if (bgp_has_peer_failed(peer, afi, safi)) | |
11070 | failed_count++; | |
11071 | count++; | |
11072 | } | |
11073 | if (peer_dynamic_neighbor(peer)) | |
11074 | dn_count++; | |
11075 | } | |
c258527b | 11076 | |
d62a17ae | 11077 | } else { |
11078 | /* Loop over all neighbors that will be displayed to determine | |
11079 | * how many | |
11080 | * characters are needed for the Neighbor column | |
11081 | */ | |
11082 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
11083 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
11084 | as_type, as)) { | |
ce1944f0 | 11085 | filtered_count++; |
8c1d4cd5 LS |
11086 | count++; |
11087 | continue; | |
11088 | } | |
11089 | ||
d62a17ae | 11090 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
11091 | continue; | |
11092 | ||
11093 | if (peer->afc[afi][safi]) { | |
11094 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
11095 | if (peer_dynamic_neighbor(peer)) | |
11096 | dn_flag[0] = '*'; | |
11097 | ||
11098 | if (peer->hostname | |
892fedb6 DA |
11099 | && CHECK_FLAG(bgp->flags, |
11100 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
11101 | snprintf(neighbor_buf, |
11102 | sizeof(neighbor_buf), | |
11103 | "%s%s(%s) ", dn_flag, | |
11104 | peer->hostname, peer->host); | |
d62a17ae | 11105 | else |
772270f3 QY |
11106 | snprintf(neighbor_buf, |
11107 | sizeof(neighbor_buf), "%s%s ", | |
11108 | dn_flag, peer->host); | |
d62a17ae | 11109 | |
11110 | len = strlen(neighbor_buf); | |
11111 | ||
11112 | if (len > max_neighbor_width) | |
11113 | max_neighbor_width = len; | |
c258527b | 11114 | |
3577f1c5 DD |
11115 | /* See if we have at least a single failed peer */ |
11116 | if (bgp_has_peer_failed(peer, afi, safi)) | |
11117 | failed_count++; | |
11118 | count++; | |
d62a17ae | 11119 | } |
11120 | } | |
f933309e | 11121 | |
d62a17ae | 11122 | /* Originally we displayed the Neighbor column as 16 |
11123 | * characters wide so make that the default | |
11124 | */ | |
11125 | if (max_neighbor_width < neighbor_col_default_width) | |
11126 | max_neighbor_width = neighbor_col_default_width; | |
11127 | } | |
f933309e | 11128 | |
3577f1c5 DD |
11129 | if (show_failed && !failed_count) { |
11130 | if (use_json) { | |
11131 | json_object_int_add(json, "failedPeersCount", 0); | |
11132 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 11133 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 | 11134 | |
75eeda93 | 11135 | vty_json(vty, json); |
3577f1c5 DD |
11136 | } else { |
11137 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
11138 | } |
11139 | return CMD_SUCCESS; | |
11140 | } | |
c258527b | 11141 | |
3577f1c5 | 11142 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 11143 | filtered_count = 0; |
800867d8 | 11144 | dn_count = 0; |
d62a17ae | 11145 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
11146 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
11147 | continue; | |
11148 | ||
ea47320b DL |
11149 | if (!peer->afc[afi][safi]) |
11150 | continue; | |
d62a17ae | 11151 | |
ea47320b DL |
11152 | if (!count) { |
11153 | unsigned long ents; | |
11154 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 11155 | int64_t vrf_id_ui; |
d62a17ae | 11156 | |
a4d82a8a PZ |
11157 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
11158 | ? -1 | |
11159 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
11160 | |
11161 | /* Usage summary and header */ | |
11162 | if (use_json) { | |
c949c771 DA |
11163 | json_object_string_addf(json, "routerId", |
11164 | "%pI4", | |
11165 | &bgp->router_id); | |
e84c7c12 PG |
11166 | asn_asn2json(json, "as", bgp->as, |
11167 | bgp->asnotation); | |
60466a63 | 11168 | json_object_int_add(json, "vrfId", vrf_id_ui); |
ea47320b DL |
11169 | json_object_string_add( |
11170 | json, "vrfName", | |
11171 | (bgp->inst_type | |
11172 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11173 | ? VRF_DEFAULT_NAME |
ea47320b DL |
11174 | : bgp->name); |
11175 | } else { | |
11176 | vty_out(vty, | |
9eb11997 PG |
11177 | "BGP router identifier %pI4, local AS number %s vrf-id %d", |
11178 | &bgp->router_id, bgp->as_pretty, | |
a4d82a8a PZ |
11179 | bgp->vrf_id == VRF_UNKNOWN |
11180 | ? -1 | |
11181 | : (int)bgp->vrf_id); | |
ea47320b DL |
11182 | vty_out(vty, "\n"); |
11183 | } | |
d62a17ae | 11184 | |
ea47320b | 11185 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 11186 | if (use_json) { |
ea47320b | 11187 | json_object_int_add( |
60466a63 | 11188 | json, "updateDelayLimit", |
ea47320b | 11189 | bgp->v_update_delay); |
d62a17ae | 11190 | |
ea47320b DL |
11191 | if (bgp->v_update_delay |
11192 | != bgp->v_establish_wait) | |
d62a17ae | 11193 | json_object_int_add( |
11194 | json, | |
ea47320b DL |
11195 | "updateDelayEstablishWait", |
11196 | bgp->v_establish_wait); | |
d62a17ae | 11197 | |
60466a63 | 11198 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11199 | json_object_string_add( |
11200 | json, | |
11201 | "updateDelayFirstNeighbor", | |
11202 | bgp->update_delay_begin_time); | |
11203 | json_object_boolean_true_add( | |
11204 | json, | |
11205 | "updateDelayInProgress"); | |
11206 | } else { | |
11207 | if (bgp->update_delay_over) { | |
d62a17ae | 11208 | json_object_string_add( |
11209 | json, | |
11210 | "updateDelayFirstNeighbor", | |
11211 | bgp->update_delay_begin_time); | |
ea47320b | 11212 | json_object_string_add( |
d62a17ae | 11213 | json, |
ea47320b DL |
11214 | "updateDelayBestpathResumed", |
11215 | bgp->update_delay_end_time); | |
11216 | json_object_string_add( | |
d62a17ae | 11217 | json, |
ea47320b DL |
11218 | "updateDelayZebraUpdateResume", |
11219 | bgp->update_delay_zebra_resume_time); | |
11220 | json_object_string_add( | |
11221 | json, | |
11222 | "updateDelayPeerUpdateResume", | |
11223 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11224 | } |
ea47320b DL |
11225 | } |
11226 | } else { | |
11227 | vty_out(vty, | |
11228 | "Read-only mode update-delay limit: %d seconds\n", | |
11229 | bgp->v_update_delay); | |
11230 | if (bgp->v_update_delay | |
11231 | != bgp->v_establish_wait) | |
d62a17ae | 11232 | vty_out(vty, |
ea47320b DL |
11233 | " Establish wait: %d seconds\n", |
11234 | bgp->v_establish_wait); | |
d62a17ae | 11235 | |
60466a63 | 11236 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
11237 | vty_out(vty, |
11238 | " First neighbor established: %s\n", | |
11239 | bgp->update_delay_begin_time); | |
11240 | vty_out(vty, | |
11241 | " Delay in progress\n"); | |
11242 | } else { | |
11243 | if (bgp->update_delay_over) { | |
d62a17ae | 11244 | vty_out(vty, |
11245 | " First neighbor established: %s\n", | |
11246 | bgp->update_delay_begin_time); | |
11247 | vty_out(vty, | |
ea47320b DL |
11248 | " Best-paths resumed: %s\n", |
11249 | bgp->update_delay_end_time); | |
11250 | vty_out(vty, | |
11251 | " zebra update resumed: %s\n", | |
11252 | bgp->update_delay_zebra_resume_time); | |
11253 | vty_out(vty, | |
11254 | " peers update resumed: %s\n", | |
11255 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 11256 | } |
11257 | } | |
11258 | } | |
ea47320b | 11259 | } |
d62a17ae | 11260 | |
ea47320b DL |
11261 | if (use_json) { |
11262 | if (bgp_maxmed_onstartup_configured(bgp) | |
11263 | && bgp->maxmed_active) | |
11264 | json_object_boolean_true_add( | |
60466a63 | 11265 | json, "maxMedOnStartup"); |
ea47320b DL |
11266 | if (bgp->v_maxmed_admin) |
11267 | json_object_boolean_true_add( | |
60466a63 | 11268 | json, "maxMedAdministrative"); |
d62a17ae | 11269 | |
ea47320b DL |
11270 | json_object_int_add( |
11271 | json, "tableVersion", | |
60466a63 | 11272 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 11273 | |
60466a63 QY |
11274 | ents = bgp_table_count(bgp->rib[afi][safi]); |
11275 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
11276 | json_object_int_add( |
11277 | json, "ribMemory", | |
9bcb3eef | 11278 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 11279 | |
210ec2a0 | 11280 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
11281 | json_object_int_add(json, "peerCount", ents); |
11282 | json_object_int_add(json, "peerMemory", | |
11283 | ents * sizeof(struct peer)); | |
d62a17ae | 11284 | |
ea47320b DL |
11285 | if ((ents = listcount(bgp->group))) { |
11286 | json_object_int_add( | |
60466a63 | 11287 | json, "peerGroupCount", ents); |
ea47320b DL |
11288 | json_object_int_add( |
11289 | json, "peerGroupMemory", | |
996c9314 LB |
11290 | ents * sizeof(struct |
11291 | peer_group)); | |
ea47320b | 11292 | } |
d62a17ae | 11293 | |
ea47320b DL |
11294 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
11295 | BGP_CONFIG_DAMPENING)) | |
11296 | json_object_boolean_true_add( | |
60466a63 | 11297 | json, "dampeningEnabled"); |
ea47320b | 11298 | } else { |
96c81f66 LS |
11299 | if (!show_terse) { |
11300 | if (bgp_maxmed_onstartup_configured(bgp) | |
11301 | && bgp->maxmed_active) | |
11302 | vty_out(vty, | |
11303 | "Max-med on-startup active\n"); | |
11304 | if (bgp->v_maxmed_admin) | |
11305 | vty_out(vty, | |
11306 | "Max-med administrative active\n"); | |
d62a17ae | 11307 | |
96c81f66 LS |
11308 | vty_out(vty, |
11309 | "BGP table version %" PRIu64 | |
11310 | "\n", | |
11311 | bgp_table_version( | |
11312 | bgp->rib[afi][safi])); | |
ea47320b | 11313 | |
96c81f66 LS |
11314 | ents = bgp_table_count( |
11315 | bgp->rib[afi][safi]); | |
d62a17ae | 11316 | vty_out(vty, |
96c81f66 | 11317 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 11318 | ents, |
11319 | mtype_memstr( | |
11320 | memstrbuf, | |
11321 | sizeof(memstrbuf), | |
96c81f66 LS |
11322 | ents |
11323 | * sizeof( | |
11324 | struct | |
11325 | bgp_dest))); | |
d62a17ae | 11326 | |
96c81f66 LS |
11327 | /* Peer related usage */ |
11328 | ents = bgp->af_peer_count[afi][safi]; | |
11329 | vty_out(vty, | |
11330 | "Peers %ld, using %s of memory\n", | |
11331 | ents, | |
11332 | mtype_memstr( | |
11333 | memstrbuf, | |
11334 | sizeof(memstrbuf), | |
11335 | ents | |
11336 | * sizeof( | |
11337 | struct | |
11338 | peer))); | |
d62a17ae | 11339 | |
96c81f66 LS |
11340 | if ((ents = listcount(bgp->group))) |
11341 | vty_out(vty, | |
11342 | "Peer groups %ld, using %s of memory\n", | |
11343 | ents, | |
11344 | mtype_memstr( | |
11345 | memstrbuf, | |
11346 | sizeof(memstrbuf), | |
11347 | ents | |
11348 | * sizeof( | |
11349 | struct | |
11350 | peer_group))); | |
11351 | ||
11352 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
11353 | BGP_CONFIG_DAMPENING)) | |
11354 | vty_out(vty, | |
11355 | "Dampening enabled.\n"); | |
11356 | } | |
11357 | if (show_failed) { | |
11358 | vty_out(vty, "\n"); | |
11359 | ||
11360 | /* Subtract 8 here because 'Neighbor' is | |
11361 | * 8 characters */ | |
11362 | vty_out(vty, "Neighbor"); | |
11363 | vty_out(vty, "%*s", | |
11364 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
11365 | vty_out(vty, |
11366 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 11367 | } |
d62a17ae | 11368 | } |
ea47320b | 11369 | } |
d62a17ae | 11370 | |
d55811cc | 11371 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 11372 | filter = &peer->filter[afi][safi]; |
db92d226 | 11373 | |
ea47320b | 11374 | count++; |
3577f1c5 DD |
11375 | /* Works for both failed & successful cases */ |
11376 | if (peer_dynamic_neighbor(peer)) | |
11377 | dn_count++; | |
d62a17ae | 11378 | |
ea47320b | 11379 | if (use_json) { |
3577f1c5 | 11380 | json_peer = NULL; |
8c1d4cd5 | 11381 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11382 | as_type, as)) { |
11383 | filtered_count++; | |
8c1d4cd5 | 11384 | continue; |
ce1944f0 | 11385 | } |
3577f1c5 DD |
11386 | if (show_failed && |
11387 | bgp_has_peer_failed(peer, afi, safi)) { | |
11388 | json_peer = json_object_new_object(); | |
11389 | bgp_show_failed_summary(vty, bgp, peer, | |
11390 | json_peer, 0, use_json); | |
11391 | } else if (!show_failed) { | |
10b49f14 | 11392 | if (show_established |
ce1944f0 LS |
11393 | && bgp_has_peer_failed(peer, afi, safi)) { |
11394 | filtered_count++; | |
10b49f14 | 11395 | continue; |
ce1944f0 | 11396 | } |
10b49f14 | 11397 | |
3577f1c5 DD |
11398 | json_peer = json_object_new_object(); |
11399 | if (peer_dynamic_neighbor(peer)) { | |
11400 | json_object_boolean_true_add(json_peer, | |
11401 | "dynamicPeer"); | |
11402 | } | |
d62a17ae | 11403 | |
3577f1c5 DD |
11404 | if (peer->hostname) |
11405 | json_object_string_add(json_peer, "hostname", | |
11406 | peer->hostname); | |
11407 | ||
11408 | if (peer->domainname) | |
11409 | json_object_string_add(json_peer, "domainname", | |
11410 | peer->domainname); | |
11411 | ||
11412 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
11413 | json_object_int_add( |
11414 | json_peer, "localAs", | |
11415 | peer->change_local_as | |
11416 | ? peer->change_local_as | |
11417 | : peer->local_as); | |
3577f1c5 DD |
11418 | json_object_int_add(json_peer, "version", 4); |
11419 | json_object_int_add(json_peer, "msgRcvd", | |
11420 | PEER_TOTAL_RX(peer)); | |
11421 | json_object_int_add(json_peer, "msgSent", | |
11422 | PEER_TOTAL_TX(peer)); | |
11423 | ||
43aa5965 QY |
11424 | atomic_size_t outq_count, inq_count; |
11425 | outq_count = atomic_load_explicit( | |
11426 | &peer->obuf->count, | |
11427 | memory_order_relaxed); | |
11428 | inq_count = atomic_load_explicit( | |
11429 | &peer->ibuf->count, | |
11430 | memory_order_relaxed); | |
11431 | ||
3577f1c5 DD |
11432 | json_object_int_add(json_peer, "tableVersion", |
11433 | peer->version[afi][safi]); | |
11434 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
11435 | outq_count); |
11436 | json_object_int_add(json_peer, "inq", | |
11437 | inq_count); | |
3577f1c5 DD |
11438 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
11439 | use_json, json_peer); | |
11440 | ||
3577f1c5 DD |
11441 | json_object_int_add(json_peer, "pfxRcd", |
11442 | peer->pcount[afi][pfx_rcd_safi]); | |
11443 | ||
3577f1c5 | 11444 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
11445 | json_object_int_add( |
11446 | json_peer, "pfxSnt", | |
11447 | (PAF_SUBGRP(paf))->scount); | |
11448 | else | |
11449 | json_object_int_add(json_peer, "pfxSnt", | |
11450 | 0); | |
0e1f8ab5 DA |
11451 | |
11452 | /* BGP FSM state */ | |
cb9196e7 | 11453 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
11454 | || CHECK_FLAG(peer->bgp->flags, |
11455 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
11456 | json_object_string_add(json_peer, |
11457 | "state", | |
3577f1c5 DD |
11458 | "Idle (Admin)"); |
11459 | else if (peer->afc_recv[afi][safi]) | |
11460 | json_object_string_add( | |
0e1f8ab5 DA |
11461 | json_peer, "state", |
11462 | lookup_msg(bgp_status_msg, | |
11463 | peer->status, NULL)); | |
11464 | else if (CHECK_FLAG( | |
11465 | peer->sflags, | |
11466 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11467 | json_object_string_add(json_peer, | |
11468 | "state", | |
3577f1c5 DD |
11469 | "Idle (PfxCt)"); |
11470 | else | |
11471 | json_object_string_add( | |
0e1f8ab5 DA |
11472 | json_peer, "state", |
11473 | lookup_msg(bgp_status_msg, | |
11474 | peer->status, NULL)); | |
11475 | ||
11476 | /* BGP peer state */ | |
11477 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
11478 | || CHECK_FLAG(peer->bgp->flags, | |
11479 | BGP_FLAG_SHUTDOWN)) | |
11480 | json_object_string_add(json_peer, | |
11481 | "peerState", | |
11482 | "Admin"); | |
11483 | else if (CHECK_FLAG( | |
11484 | peer->sflags, | |
11485 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11486 | json_object_string_add(json_peer, | |
11487 | "peerState", | |
11488 | "PfxCt"); | |
11489 | else if (CHECK_FLAG(peer->flags, | |
11490 | PEER_FLAG_PASSIVE)) | |
11491 | json_object_string_add(json_peer, | |
11492 | "peerState", | |
11493 | "Passive"); | |
11494 | else if (CHECK_FLAG(peer->sflags, | |
11495 | PEER_STATUS_NSF_WAIT)) | |
11496 | json_object_string_add(json_peer, | |
11497 | "peerState", | |
11498 | "NSF passive"); | |
11499 | else if (CHECK_FLAG( | |
11500 | peer->bgp->flags, | |
11501 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11502 | && (!bgp_inbound_policy_exists(peer, | |
11503 | filter) | |
11504 | || !bgp_outbound_policy_exists( | |
11505 | peer, filter))) | |
11506 | json_object_string_add(json_peer, | |
11507 | "peerState", | |
11508 | "Policy"); | |
11509 | else | |
11510 | json_object_string_add( | |
11511 | json_peer, "peerState", "OK"); | |
11512 | ||
200116db DD |
11513 | json_object_int_add(json_peer, "connectionsEstablished", |
11514 | peer->established); | |
11515 | json_object_int_add(json_peer, "connectionsDropped", | |
11516 | peer->dropped); | |
aa72bd7e PG |
11517 | if (peer->desc) |
11518 | json_object_string_add( | |
11519 | json_peer, "desc", peer->desc); | |
b4e9dcba | 11520 | } |
3577f1c5 DD |
11521 | /* Avoid creating empty peer dicts in JSON */ |
11522 | if (json_peer == NULL) | |
11523 | continue; | |
ea47320b DL |
11524 | |
11525 | if (peer->conf_if) | |
60466a63 | 11526 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
11527 | "interface"); |
11528 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
11529 | json_object_string_add(json_peer, "idType", |
11530 | "ipv4"); | |
ea47320b | 11531 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
11532 | json_object_string_add(json_peer, "idType", |
11533 | "ipv6"); | |
ea47320b DL |
11534 | json_object_object_add(json_peers, peer->host, |
11535 | json_peer); | |
11536 | } else { | |
8c1d4cd5 | 11537 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
11538 | as_type, as)) { |
11539 | filtered_count++; | |
8c1d4cd5 | 11540 | continue; |
ce1944f0 | 11541 | } |
3577f1c5 DD |
11542 | if (show_failed && |
11543 | bgp_has_peer_failed(peer, afi, safi)) { | |
11544 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
11545 | max_neighbor_width, | |
11546 | use_json); | |
11547 | } else if (!show_failed) { | |
10b49f14 | 11548 | if (show_established |
ce1944f0 LS |
11549 | && bgp_has_peer_failed(peer, afi, safi)) { |
11550 | filtered_count++; | |
10b49f14 | 11551 | continue; |
ce1944f0 | 11552 | } |
96c81f66 LS |
11553 | |
11554 | if ((count - filtered_count) == 1) { | |
11555 | /* display headline before the first | |
11556 | * neighbor line */ | |
11557 | vty_out(vty, "\n"); | |
11558 | ||
11559 | /* Subtract 8 here because 'Neighbor' is | |
11560 | * 8 characters */ | |
11561 | vty_out(vty, "Neighbor"); | |
11562 | vty_out(vty, "%*s", | |
11563 | max_neighbor_width - 8, " "); | |
11564 | vty_out(vty, | |
11565 | show_wide | |
11566 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
11567 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
11568 | } | |
11569 | ||
3577f1c5 DD |
11570 | memset(dn_flag, '\0', sizeof(dn_flag)); |
11571 | if (peer_dynamic_neighbor(peer)) { | |
11572 | dn_flag[0] = '*'; | |
11573 | } | |
d62a17ae | 11574 | |
3577f1c5 | 11575 | if (peer->hostname |
892fedb6 DA |
11576 | && CHECK_FLAG(bgp->flags, |
11577 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 11578 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
11579 | peer->hostname, |
11580 | peer->host); | |
d62a17ae | 11581 | else |
3577f1c5 DD |
11582 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
11583 | ||
11584 | /* pad the neighbor column with spaces */ | |
11585 | if (len < max_neighbor_width) | |
11586 | vty_out(vty, "%*s", max_neighbor_width - len, | |
11587 | " "); | |
11588 | ||
43aa5965 QY |
11589 | atomic_size_t outq_count, inq_count; |
11590 | outq_count = atomic_load_explicit( | |
11591 | &peer->obuf->count, | |
11592 | memory_order_relaxed); | |
11593 | inq_count = atomic_load_explicit( | |
11594 | &peer->ibuf->count, | |
11595 | memory_order_relaxed); | |
11596 | ||
85eeb029 DA |
11597 | if (show_wide) |
11598 | vty_out(vty, | |
11599 | "4 %10u %10u %9u %9u %8" PRIu64 | |
11600 | " %4zu %4zu %8s", | |
11601 | peer->as, | |
11602 | peer->change_local_as | |
11603 | ? peer->change_local_as | |
11604 | : peer->local_as, | |
11605 | PEER_TOTAL_RX(peer), | |
11606 | PEER_TOTAL_TX(peer), | |
11607 | peer->version[afi][safi], | |
11608 | inq_count, outq_count, | |
11609 | peer_uptime(peer->uptime, | |
11610 | timebuf, | |
11611 | BGP_UPTIME_LEN, 0, | |
11612 | NULL)); | |
11613 | else | |
11614 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
11615 | " %4zu %4zu %8s", | |
11616 | peer->as, PEER_TOTAL_RX(peer), | |
11617 | PEER_TOTAL_TX(peer), | |
11618 | peer->version[afi][safi], | |
11619 | inq_count, outq_count, | |
11620 | peer_uptime(peer->uptime, | |
11621 | timebuf, | |
11622 | BGP_UPTIME_LEN, 0, | |
11623 | NULL)); | |
3577f1c5 | 11624 | |
feb17238 | 11625 | if (peer_established(peer)) { |
d3ada366 DA |
11626 | if (peer->afc_recv[afi][safi]) { |
11627 | if (CHECK_FLAG( | |
11628 | bgp->flags, | |
11629 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11630 | && !bgp_inbound_policy_exists( | |
11631 | peer, filter)) | |
11632 | vty_out(vty, " %12s", | |
11633 | "(Policy)"); | |
11634 | else | |
11635 | vty_out(vty, | |
6cde4b45 | 11636 | " %12u", |
d3ada366 DA |
11637 | peer->pcount |
11638 | [afi] | |
11639 | [pfx_rcd_safi]); | |
11640 | } else { | |
749d0f27 | 11641 | vty_out(vty, " NoNeg"); |
d3ada366 | 11642 | } |
db92d226 | 11643 | |
d3ada366 DA |
11644 | if (paf && PAF_SUBGRP(paf)) { |
11645 | if (CHECK_FLAG( | |
11646 | bgp->flags, | |
11647 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
11648 | && !bgp_outbound_policy_exists( | |
11649 | peer, filter)) | |
11650 | vty_out(vty, " %8s", | |
11651 | "(Policy)"); | |
11652 | else | |
11653 | vty_out(vty, | |
6cde4b45 | 11654 | " %8u", |
d3ada366 DA |
11655 | (PAF_SUBGRP( |
11656 | paf)) | |
11657 | ->scount); | |
749d0f27 DA |
11658 | } else { |
11659 | vty_out(vty, " NoNeg"); | |
d3ada366 | 11660 | } |
db92d226 | 11661 | } else { |
736b68f3 DS |
11662 | if (CHECK_FLAG(peer->flags, |
11663 | PEER_FLAG_SHUTDOWN) | |
11664 | || CHECK_FLAG(peer->bgp->flags, | |
11665 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
11666 | vty_out(vty, " Idle (Admin)"); |
11667 | else if (CHECK_FLAG( | |
11668 | peer->sflags, | |
11669 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11670 | vty_out(vty, " Idle (PfxCt)"); | |
11671 | else | |
11672 | vty_out(vty, " %12s", | |
11673 | lookup_msg(bgp_status_msg, | |
11674 | peer->status, NULL)); | |
db92d226 | 11675 | |
6cde4b45 | 11676 | vty_out(vty, " %8u", 0); |
3577f1c5 | 11677 | } |
565e9ddd DA |
11678 | /* Make sure `Desc` column is the lastest in |
11679 | * the output. | |
11680 | */ | |
aa72bd7e | 11681 | if (peer->desc) |
cb75bb31 DA |
11682 | vty_out(vty, " %s", |
11683 | bgp_peer_description_stripped( | |
85eeb029 DA |
11684 | peer->desc, |
11685 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
11686 | else |
11687 | vty_out(vty, " N/A"); | |
3577f1c5 | 11688 | vty_out(vty, "\n"); |
d62a17ae | 11689 | } |
3577f1c5 | 11690 | |
d62a17ae | 11691 | } |
11692 | } | |
f933309e | 11693 | |
d62a17ae | 11694 | if (use_json) { |
11695 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11696 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
11697 | json_object_int_add(json, "displayedPeers", |
11698 | count - filtered_count); | |
d62a17ae | 11699 | json_object_int_add(json, "totalPeers", count); |
11700 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11701 | ||
3577f1c5 DD |
11702 | if (!show_failed) |
11703 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11704 | |
75eeda93 | 11705 | vty_json(vty, json); |
d62a17ae | 11706 | } else { |
ce1944f0 | 11707 | if (count) { |
96c81f66 LS |
11708 | if (filtered_count == count) |
11709 | vty_out(vty, "\n%% No matching neighbor\n"); | |
11710 | else { | |
11711 | if (show_failed) | |
11712 | vty_out(vty, "\nDisplayed neighbors %d", | |
11713 | failed_count); | |
11714 | else if (as_type != AS_UNSPECIFIED || as | |
11715 | || fpeer || show_established) | |
ce1944f0 LS |
11716 | vty_out(vty, "\nDisplayed neighbors %d", |
11717 | count - filtered_count); | |
96c81f66 LS |
11718 | |
11719 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
11720 | count); | |
ce1944f0 | 11721 | } |
ce1944f0 | 11722 | } else { |
d6ceaca3 | 11723 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11724 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11725 | } |
b05a1c8b | 11726 | |
d6ceaca3 | 11727 | if (dn_count) { |
d62a17ae | 11728 | vty_out(vty, "* - dynamic neighbor\n"); |
11729 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11730 | dn_count, bgp->dynamic_neighbors_limit); | |
11731 | } | |
11732 | } | |
1ff9a340 | 11733 | |
d62a17ae | 11734 | return CMD_SUCCESS; |
718e3744 | 11735 | } |
11736 | ||
d62a17ae | 11737 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 11738 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 11739 | as_t as, uint16_t show_flags) |
d62a17ae | 11740 | { |
11741 | int is_first = 1; | |
11742 | int afi_wildcard = (afi == AFI_MAX); | |
11743 | int safi_wildcard = (safi == SAFI_MAX); | |
11744 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11745 | bool nbr_output = false; |
85eeb029 | 11746 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11747 | |
11748 | if (use_json && is_wildcard) | |
11749 | vty_out(vty, "{\n"); | |
11750 | if (afi_wildcard) | |
11751 | afi = 1; /* AFI_IP */ | |
11752 | while (afi < AFI_MAX) { | |
11753 | if (safi_wildcard) | |
11754 | safi = 1; /* SAFI_UNICAST */ | |
11755 | while (safi < SAFI_MAX) { | |
318cac96 | 11756 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11757 | nbr_output = true; |
f86897b9 | 11758 | |
d62a17ae | 11759 | if (is_wildcard) { |
11760 | /* | |
11761 | * So limit output to those afi/safi | |
11762 | * pairs that | |
11763 | * actualy have something interesting in | |
11764 | * them | |
11765 | */ | |
11766 | if (use_json) { | |
d62a17ae | 11767 | if (!is_first) |
11768 | vty_out(vty, ",\n"); | |
11769 | else | |
11770 | is_first = 0; | |
11771 | ||
11772 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11773 | get_afi_safi_str(afi, |
11774 | safi, | |
11775 | true)); | |
d62a17ae | 11776 | } else { |
6cac2fcc LS |
11777 | vty_out(vty, |
11778 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
11779 | get_afi_safi_str(afi, |
11780 | safi, | |
6cac2fcc LS |
11781 | false), |
11782 | bgp->name_pretty); | |
d62a17ae | 11783 | } |
11784 | } | |
8c1d4cd5 LS |
11785 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
11786 | as_type, as, show_flags); | |
d62a17ae | 11787 | } |
11788 | safi++; | |
d62a17ae | 11789 | if (!safi_wildcard) |
11790 | safi = SAFI_MAX; | |
11791 | } | |
11792 | afi++; | |
ee851c8c | 11793 | if (!afi_wildcard) |
d62a17ae | 11794 | afi = AFI_MAX; |
11795 | } | |
11796 | ||
11797 | if (use_json && is_wildcard) | |
11798 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11799 | else if (!nbr_output) { |
11800 | if (use_json) | |
11801 | vty_out(vty, "{}\n"); | |
11802 | else | |
6cac2fcc LS |
11803 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
11804 | bgp->name_pretty); | |
ca61fd25 | 11805 | } |
d62a17ae | 11806 | } |
11807 | ||
11808 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
11809 | safi_t safi, |
11810 | const char *neighbor, | |
11811 | int as_type, as_t as, | |
96c81f66 | 11812 | uint16_t show_flags) |
d62a17ae | 11813 | { |
11814 | struct listnode *node, *nnode; | |
11815 | struct bgp *bgp; | |
8c1d4cd5 | 11816 | struct peer *fpeer = NULL; |
d62a17ae | 11817 | int is_first = 1; |
9f049418 | 11818 | bool nbr_output = false; |
85eeb029 | 11819 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11820 | |
11821 | if (use_json) | |
11822 | vty_out(vty, "{\n"); | |
11823 | ||
11824 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11825 | nbr_output = true; |
d62a17ae | 11826 | if (use_json) { |
d62a17ae | 11827 | if (!is_first) |
11828 | vty_out(vty, ",\n"); | |
11829 | else | |
11830 | is_first = 0; | |
11831 | ||
11832 | vty_out(vty, "\"%s\":", | |
11833 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11834 | ? VRF_DEFAULT_NAME |
d62a17ae | 11835 | : bgp->name); |
d62a17ae | 11836 | } |
8c1d4cd5 LS |
11837 | if (neighbor) { |
11838 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11839 | use_json); | |
11840 | if (!fpeer) | |
11841 | continue; | |
11842 | } | |
11843 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11844 | as, show_flags); | |
d62a17ae | 11845 | } |
11846 | ||
11847 | if (use_json) | |
11848 | vty_out(vty, "}\n"); | |
9f049418 DS |
11849 | else if (!nbr_output) |
11850 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11851 | } |
11852 | ||
11853 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 11854 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 11855 | as_t as, uint16_t show_flags) |
d62a17ae | 11856 | { |
11857 | struct bgp *bgp; | |
85eeb029 | 11858 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 11859 | struct peer *fpeer = NULL; |
d62a17ae | 11860 | |
11861 | if (name) { | |
11862 | if (strmatch(name, "all")) { | |
85eeb029 | 11863 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
11864 | neighbor, as_type, |
11865 | as, show_flags); | |
d62a17ae | 11866 | return CMD_SUCCESS; |
11867 | } else { | |
11868 | bgp = bgp_lookup_by_name(name); | |
11869 | ||
11870 | if (!bgp) { | |
11871 | if (use_json) | |
11872 | vty_out(vty, "{}\n"); | |
11873 | else | |
11874 | vty_out(vty, | |
ca61fd25 | 11875 | "%% BGP instance not found\n"); |
d62a17ae | 11876 | return CMD_WARNING; |
11877 | } | |
11878 | ||
8c1d4cd5 LS |
11879 | if (neighbor) { |
11880 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11881 | use_json); | |
11882 | if (!fpeer) | |
11883 | return CMD_WARNING; | |
11884 | } | |
11885 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11886 | as_type, as, show_flags); | |
d62a17ae | 11887 | return CMD_SUCCESS; |
11888 | } | |
11889 | } | |
11890 | ||
11891 | bgp = bgp_get_default(); | |
11892 | ||
8c1d4cd5 LS |
11893 | if (bgp) { |
11894 | if (neighbor) { | |
11895 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11896 | use_json); | |
11897 | if (!fpeer) | |
11898 | return CMD_WARNING; | |
11899 | } | |
11900 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11901 | as, show_flags); | |
11902 | } else { | |
ca61fd25 DS |
11903 | if (use_json) |
11904 | vty_out(vty, "{}\n"); | |
11905 | else | |
11906 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11907 | return CMD_WARNING; |
11908 | } | |
d62a17ae | 11909 | |
11910 | return CMD_SUCCESS; | |
4fb25c53 DW |
11911 | } |
11912 | ||
716b2d8a | 11913 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11914 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11915 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11916 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
8079a413 | 11917 | "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <ASNUM|internal|external>>] [terse] [wide] [json$uj]", |
8c1d4cd5 LS |
11918 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11919 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11920 | "Display the entries for all address families\n" | |
11921 | "Summary of BGP neighbor status\n" | |
11922 | "Show only sessions in Established state\n" | |
11923 | "Show only sessions not in Established state\n" | |
11924 | "Show only the specified neighbor session\n" | |
11925 | "Neighbor to display information about\n" | |
11926 | "Neighbor to display information about\n" | |
11927 | "Neighbor on BGP configured interface\n" | |
8079a413 | 11928 | "Show only the specified remote AS sessions\n" AS_STR |
8c1d4cd5 LS |
11929 | "Internal (iBGP) AS sessions\n" |
11930 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11931 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11932 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11933 | { |
d62a17ae | 11934 | char *vrf = NULL; |
11935 | afi_t afi = AFI_MAX; | |
11936 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11937 | as_t as = 0; /* 0 means AS filter not set */ |
11938 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11939 | uint16_t show_flags = 0; |
d62a17ae | 11940 | |
11941 | int idx = 0; | |
11942 | ||
11943 | /* show [ip] bgp */ | |
96f3485c | 11944 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11945 | afi = AFI_IP; |
9a8bdf1c PG |
11946 | /* [<vrf> VIEWVRFNAME] */ |
11947 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11948 | vrf = argv[idx + 1]->arg; | |
11949 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11950 | vrf = NULL; | |
11951 | } else if (argv_find(argv, argc, "view", &idx)) | |
11952 | /* [<view> VIEWVRFNAME] */ | |
11953 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11954 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11955 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11956 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11957 | } | |
11958 | ||
3577f1c5 | 11959 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11960 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11961 | ||
10b49f14 | 11962 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11963 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11964 | ||
8c1d4cd5 LS |
11965 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11966 | if (argv[idx + 1]->arg[0] == 'i') | |
11967 | as_type = AS_INTERNAL; | |
11968 | else if (argv[idx + 1]->arg[0] == 'e') | |
11969 | as_type = AS_EXTERNAL; | |
8079a413 PG |
11970 | else if (!asn_str2asn(argv[idx + 1]->arg, &as)) { |
11971 | vty_out(vty, | |
11972 | "%% Invalid neighbor remote-as value: %s\n", | |
11973 | argv[idx + 1]->arg); | |
11974 | return CMD_SUCCESS; | |
11975 | } | |
8c1d4cd5 LS |
11976 | } |
11977 | ||
96c81f66 LS |
11978 | if (argv_find(argv, argc, "terse", &idx)) |
11979 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11980 | ||
85eeb029 DA |
11981 | if (argv_find(argv, argc, "wide", &idx)) |
11982 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11983 | ||
11984 | if (argv_find(argv, argc, "json", &idx)) | |
11985 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11986 | |
8c1d4cd5 LS |
11987 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11988 | show_flags); | |
d62a17ae | 11989 | } |
11990 | ||
5cb5f4d0 | 11991 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11992 | { |
5cb5f4d0 DD |
11993 | if (for_json) |
11994 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11995 | else |
5cb5f4d0 | 11996 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11997 | } |
11998 | ||
d62a17ae | 11999 | |
12000 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
12001 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
12002 | uint16_t adv_smcap, uint16_t adv_rmcap, |
12003 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 12004 | bool use_json, json_object *json_pref) |
d62a17ae | 12005 | { |
12006 | /* Send-Mode */ | |
12007 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
12008 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
12009 | if (use_json) { | |
12010 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
12011 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
12012 | json_object_string_add(json_pref, "sendMode", | |
12013 | "advertisedAndReceived"); | |
12014 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
12015 | json_object_string_add(json_pref, "sendMode", | |
12016 | "advertised"); | |
12017 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
12018 | json_object_string_add(json_pref, "sendMode", | |
12019 | "received"); | |
12020 | } else { | |
12021 | vty_out(vty, " Send-mode: "); | |
12022 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
12023 | vty_out(vty, "advertised"); | |
12024 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
12025 | vty_out(vty, "%sreceived", | |
12026 | CHECK_FLAG(p->af_cap[afi][safi], | |
12027 | adv_smcap) | |
12028 | ? ", " | |
12029 | : ""); | |
12030 | vty_out(vty, "\n"); | |
12031 | } | |
12032 | } | |
12033 | ||
12034 | /* Receive-Mode */ | |
12035 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
12036 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
12037 | if (use_json) { | |
12038 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
12039 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
12040 | json_object_string_add(json_pref, "recvMode", | |
12041 | "advertisedAndReceived"); | |
12042 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
12043 | json_object_string_add(json_pref, "recvMode", | |
12044 | "advertised"); | |
12045 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
12046 | json_object_string_add(json_pref, "recvMode", | |
12047 | "received"); | |
12048 | } else { | |
12049 | vty_out(vty, " Receive-mode: "); | |
12050 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
12051 | vty_out(vty, "advertised"); | |
12052 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
12053 | vty_out(vty, "%sreceived", | |
12054 | CHECK_FLAG(p->af_cap[afi][safi], | |
12055 | adv_rmcap) | |
12056 | ? ", " | |
12057 | : ""); | |
12058 | vty_out(vty, "\n"); | |
12059 | } | |
12060 | } | |
12061 | } | |
12062 | ||
eea685b6 DA |
12063 | static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty, |
12064 | struct peer *p, | |
eea685b6 | 12065 | json_object *json) |
2986cac2 | 12066 | { |
eea685b6 DA |
12067 | bool rbit = false; |
12068 | bool nbit = false; | |
2986cac2 | 12069 | |
13909c4f DS |
12070 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
12071 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 12072 | && (peer_established(p))) { |
eea685b6 DA |
12073 | rbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV); |
12074 | nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV); | |
2986cac2 | 12075 | } |
12076 | ||
403e64f8 | 12077 | if (json) { |
eea685b6 DA |
12078 | json_object_boolean_add(json, "rBit", rbit); |
12079 | json_object_boolean_add(json, "nBit", nbit); | |
2986cac2 | 12080 | } else { |
eea685b6 DA |
12081 | vty_out(vty, "\n R bit: %s", rbit ? "True" : "False"); |
12082 | vty_out(vty, "\n N bit: %s\n", nbit ? "True" : "False"); | |
2986cac2 | 12083 | } |
12084 | } | |
12085 | ||
13909c4f DS |
12086 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
12087 | struct peer *peer, | |
13909c4f | 12088 | json_object *json) |
2986cac2 | 12089 | { |
2bb5d39b | 12090 | const char *mode = "NotApplicable"; |
2986cac2 | 12091 | |
403e64f8 | 12092 | if (!json) |
a53ca37b | 12093 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 12094 | |
13909c4f | 12095 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 12096 | && (peer_established(peer))) { |
2986cac2 | 12097 | |
13909c4f DS |
12098 | if ((peer->nsf_af_count == 0) |
12099 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12100 | |
2986cac2 | 12101 | mode = "Disable"; |
12102 | ||
13909c4f DS |
12103 | } else if (peer->nsf_af_count == 0 |
12104 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12105 | |
2986cac2 | 12106 | mode = "Helper"; |
12107 | ||
13909c4f DS |
12108 | } else if (peer->nsf_af_count != 0 |
12109 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12110 | |
2986cac2 | 12111 | mode = "Restart"; |
2986cac2 | 12112 | } |
12113 | } | |
12114 | ||
403e64f8 | 12115 | if (json) |
13909c4f | 12116 | json_object_string_add(json, "remoteGrMode", mode); |
403e64f8 | 12117 | else |
0e4e879b | 12118 | vty_out(vty, "%s\n", mode); |
2986cac2 | 12119 | } |
12120 | ||
13909c4f DS |
12121 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
12122 | struct peer *p, | |
13909c4f | 12123 | json_object *json) |
2986cac2 | 12124 | { |
12125 | const char *mode = "Invalid"; | |
12126 | ||
403e64f8 | 12127 | if (!json) |
a53ca37b | 12128 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 12129 | |
12130 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
12131 | mode = "Helper"; | |
12132 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
12133 | mode = "Restart"; | |
12134 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
12135 | mode = "Disable"; | |
2ba1fe69 | 12136 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 12137 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
12138 | mode = "Helper*"; | |
12139 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
12140 | mode = "Restart*"; | |
12141 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
12142 | mode = "Disable*"; | |
12143 | else | |
12144 | mode = "Invalid*"; | |
2ba1fe69 | 12145 | } |
2986cac2 | 12146 | |
403e64f8 | 12147 | if (json) |
13909c4f | 12148 | json_object_string_add(json, "localGrMode", mode); |
403e64f8 | 12149 | else |
0e4e879b | 12150 | vty_out(vty, "%s\n", mode); |
2986cac2 | 12151 | } |
12152 | ||
13909c4f | 12153 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
403e64f8 | 12154 | struct vty *vty, struct peer *peer, json_object *json) |
2986cac2 | 12155 | { |
2ba1fe69 | 12156 | afi_t afi; |
12157 | safi_t safi; | |
2986cac2 | 12158 | json_object *json_afi_safi = NULL; |
12159 | json_object *json_timer = NULL; | |
12160 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 12161 | bool eor_flag = false; |
2986cac2 | 12162 | |
df8d723c DA |
12163 | FOREACH_AFI_SAFI_NSF (afi, safi) { |
12164 | if (!peer->afc[afi][safi]) | |
12165 | continue; | |
2986cac2 | 12166 | |
df8d723c DA |
12167 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) || |
12168 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
12169 | continue; | |
9e3b51a7 | 12170 | |
403e64f8 | 12171 | if (json) { |
df8d723c DA |
12172 | json_afi_safi = json_object_new_object(); |
12173 | json_endofrib_status = json_object_new_object(); | |
12174 | json_timer = json_object_new_object(); | |
12175 | } | |
2986cac2 | 12176 | |
df8d723c DA |
12177 | if (peer->eor_stime[afi][safi] >= peer->pkt_stime[afi][safi]) |
12178 | eor_flag = true; | |
12179 | else | |
12180 | eor_flag = false; | |
2986cac2 | 12181 | |
403e64f8 | 12182 | if (!json) { |
df8d723c DA |
12183 | vty_out(vty, " %s:\n", |
12184 | get_afi_safi_str(afi, safi, false)); | |
2986cac2 | 12185 | |
df8d723c DA |
12186 | vty_out(vty, " F bit: "); |
12187 | } | |
2986cac2 | 12188 | |
df8d723c DA |
12189 | if (peer->nsf[afi][safi] && |
12190 | CHECK_FLAG(peer->af_cap[afi][safi], | |
12191 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 12192 | |
403e64f8 | 12193 | if (json) { |
df8d723c DA |
12194 | json_object_boolean_true_add(json_afi_safi, |
12195 | "fBit"); | |
12196 | } else | |
12197 | vty_out(vty, "True\n"); | |
12198 | } else { | |
403e64f8 | 12199 | if (json) |
df8d723c DA |
12200 | json_object_boolean_false_add(json_afi_safi, |
12201 | "fBit"); | |
12202 | else | |
12203 | vty_out(vty, "False\n"); | |
12204 | } | |
2986cac2 | 12205 | |
403e64f8 | 12206 | if (!json) |
df8d723c | 12207 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 12208 | |
df8d723c DA |
12209 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12210 | PEER_STATUS_EOR_SEND)) { | |
403e64f8 | 12211 | if (json) { |
df8d723c DA |
12212 | json_object_boolean_true_add( |
12213 | json_endofrib_status, "endOfRibSend"); | |
9e3b51a7 | 12214 | |
df8d723c DA |
12215 | PRINT_EOR_JSON(eor_flag); |
12216 | } else { | |
12217 | vty_out(vty, "Yes\n"); | |
12218 | vty_out(vty, | |
12219 | " End-of-RIB sent after update: "); | |
2986cac2 | 12220 | |
df8d723c DA |
12221 | PRINT_EOR(eor_flag); |
12222 | } | |
12223 | } else { | |
403e64f8 | 12224 | if (json) { |
df8d723c DA |
12225 | json_object_boolean_false_add( |
12226 | json_endofrib_status, "endOfRibSend"); | |
12227 | json_object_boolean_false_add( | |
12228 | json_endofrib_status, | |
12229 | "endOfRibSentAfterUpdate"); | |
13909c4f | 12230 | } else { |
df8d723c DA |
12231 | vty_out(vty, "No\n"); |
12232 | vty_out(vty, | |
12233 | " End-of-RIB sent after update: "); | |
12234 | vty_out(vty, "No\n"); | |
13909c4f | 12235 | } |
df8d723c | 12236 | } |
2986cac2 | 12237 | |
403e64f8 | 12238 | if (!json) |
df8d723c | 12239 | vty_out(vty, " End-of-RIB received: "); |
a53ca37b | 12240 | |
df8d723c DA |
12241 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
12242 | PEER_STATUS_EOR_RECEIVED)) { | |
403e64f8 | 12243 | if (json) |
df8d723c DA |
12244 | json_object_boolean_true_add( |
12245 | json_endofrib_status, "endOfRibRecv"); | |
12246 | else | |
12247 | vty_out(vty, "Yes\n"); | |
12248 | } else { | |
403e64f8 | 12249 | if (json) |
df8d723c DA |
12250 | json_object_boolean_false_add( |
12251 | json_endofrib_status, "endOfRibRecv"); | |
12252 | else | |
12253 | vty_out(vty, "No\n"); | |
12254 | } | |
12255 | ||
403e64f8 | 12256 | if (json) { |
df8d723c DA |
12257 | json_object_int_add(json_timer, "stalePathTimer", |
12258 | peer->bgp->stalepath_time); | |
12259 | ||
12260 | if (peer->t_gr_stale != NULL) { | |
12261 | json_object_int_add(json_timer, | |
12262 | "stalePathTimerRemaining", | |
12263 | thread_timer_remain_second( | |
12264 | peer->t_gr_stale)); | |
a53ca37b DA |
12265 | } |
12266 | ||
df8d723c DA |
12267 | /* Display Configured Selection |
12268 | * Deferral only when when | |
12269 | * Gr mode is enabled. | |
12270 | */ | |
12271 | if (CHECK_FLAG(peer->flags, | |
12272 | PEER_FLAG_GRACEFUL_RESTART)) { | |
13909c4f | 12273 | json_object_int_add(json_timer, |
df8d723c | 12274 | "selectionDeferralTimer", |
13909c4f | 12275 | peer->bgp->stalepath_time); |
df8d723c | 12276 | } |
2986cac2 | 12277 | |
df8d723c DA |
12278 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12279 | NULL) { | |
2986cac2 | 12280 | |
df8d723c DA |
12281 | json_object_int_add( |
12282 | json_timer, | |
12283 | "selectionDeferralTimerRemaining", | |
12284 | thread_timer_remain_second( | |
12285 | peer->bgp->gr_info[afi][safi] | |
12286 | .t_select_deferral)); | |
12287 | } | |
12288 | } else { | |
12289 | vty_out(vty, " Timers:\n"); | |
12290 | vty_out(vty, | |
12291 | " Configured Stale Path Time(sec): %u\n", | |
12292 | peer->bgp->stalepath_time); | |
2986cac2 | 12293 | |
df8d723c | 12294 | if (peer->t_gr_stale != NULL) |
13909c4f | 12295 | vty_out(vty, |
df8d723c DA |
12296 | " Stale Path Remaining(sec): %ld\n", |
12297 | thread_timer_remain_second( | |
12298 | peer->t_gr_stale)); | |
12299 | /* Display Configured Selection | |
12300 | * Deferral only when when | |
12301 | * Gr mode is enabled. | |
12302 | */ | |
12303 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
12304 | vty_out(vty, | |
12305 | " Configured Selection Deferral Time(sec): %u\n", | |
12306 | peer->bgp->select_defer_time); | |
2986cac2 | 12307 | |
df8d723c DA |
12308 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
12309 | NULL) | |
12310 | vty_out(vty, | |
12311 | " Selection Deferral Time Remaining(sec): %ld\n", | |
12312 | thread_timer_remain_second( | |
12313 | peer->bgp->gr_info[afi][safi] | |
12314 | .t_select_deferral)); | |
12315 | } | |
403e64f8 | 12316 | if (json) { |
df8d723c DA |
12317 | json_object_object_add(json_afi_safi, "endOfRibStatus", |
12318 | json_endofrib_status); | |
12319 | json_object_object_add(json_afi_safi, "timers", | |
12320 | json_timer); | |
12321 | json_object_object_add( | |
12322 | json, get_afi_safi_str(afi, safi, true), | |
12323 | json_afi_safi); | |
2986cac2 | 12324 | } |
12325 | } | |
12326 | } | |
12327 | ||
36235319 QY |
12328 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
12329 | struct peer *p, | |
36235319 | 12330 | json_object *json) |
2986cac2 | 12331 | { |
403e64f8 | 12332 | if (json) { |
2986cac2 | 12333 | json_object *json_timer = NULL; |
12334 | ||
12335 | json_timer = json_object_new_object(); | |
12336 | ||
13909c4f DS |
12337 | json_object_int_add(json_timer, "configuredRestartTimer", |
12338 | p->bgp->restart_time); | |
2986cac2 | 12339 | |
13909c4f DS |
12340 | json_object_int_add(json_timer, "receivedRestartTimer", |
12341 | p->v_gr_restart); | |
2986cac2 | 12342 | |
13909c4f DS |
12343 | if (p->t_gr_restart != NULL) |
12344 | json_object_int_add( | |
12345 | json_timer, "restartTimerRemaining", | |
12346 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 12347 | |
12348 | json_object_object_add(json, "timers", json_timer); | |
12349 | } else { | |
12350 | ||
a53ca37b DA |
12351 | vty_out(vty, " Timers:\n"); |
12352 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 12353 | p->bgp->restart_time); |
2986cac2 | 12354 | |
a53ca37b | 12355 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
12356 | p->v_gr_restart); |
12357 | if (p->t_gr_restart != NULL) | |
a53ca37b | 12358 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 12359 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 12360 | if (p->t_gr_restart != NULL) { |
a53ca37b | 12361 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
12362 | thread_timer_remain_second(p->t_gr_restart)); |
12363 | } | |
2986cac2 | 12364 | } |
12365 | } | |
12366 | ||
12367 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
403e64f8 | 12368 | json_object *json) |
2986cac2 | 12369 | { |
2986cac2 | 12370 | char dn_flag[2] = {0}; |
2b7165e7 QY |
12371 | /* '*' + v6 address of neighbor */ |
12372 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 12373 | |
2986cac2 | 12374 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
12375 | dn_flag[0] = '*'; | |
12376 | ||
12377 | if (p->conf_if) { | |
403e64f8 | 12378 | if (json) |
47e12884 DA |
12379 | json_object_string_addf(json, "neighborAddr", "%pSU", |
12380 | &p->su); | |
2986cac2 | 12381 | else |
47e12884 DA |
12382 | vty_out(vty, "BGP neighbor on %s: %pSU\n", p->conf_if, |
12383 | &p->su); | |
2986cac2 | 12384 | } else { |
772270f3 QY |
12385 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
12386 | p->host); | |
2986cac2 | 12387 | |
403e64f8 | 12388 | if (json) |
36235319 QY |
12389 | json_object_string_add(json, "neighborAddr", |
12390 | neighborAddr); | |
2986cac2 | 12391 | else |
36235319 | 12392 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 12393 | } |
12394 | ||
12395 | /* more gr info in new format */ | |
403e64f8 | 12396 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json); |
2986cac2 | 12397 | } |
12398 | ||
d62a17ae | 12399 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 12400 | safi_t safi, bool use_json, |
d62a17ae | 12401 | json_object *json_neigh) |
12402 | { | |
0291c246 MK |
12403 | struct bgp_filter *filter; |
12404 | struct peer_af *paf; | |
12405 | char orf_pfx_name[BUFSIZ]; | |
12406 | int orf_pfx_count; | |
12407 | json_object *json_af = NULL; | |
12408 | json_object *json_prefA = NULL; | |
12409 | json_object *json_prefB = NULL; | |
12410 | json_object *json_addr = NULL; | |
fa36596c | 12411 | json_object *json_advmap = NULL; |
d62a17ae | 12412 | |
12413 | if (use_json) { | |
12414 | json_addr = json_object_new_object(); | |
12415 | json_af = json_object_new_object(); | |
12416 | filter = &p->filter[afi][safi]; | |
12417 | ||
12418 | if (peer_group_active(p)) | |
12419 | json_object_string_add(json_addr, "peerGroupMember", | |
12420 | p->group->name); | |
12421 | ||
12422 | paf = peer_af_find(p, afi, safi); | |
12423 | if (paf && PAF_SUBGRP(paf)) { | |
12424 | json_object_int_add(json_addr, "updateGroupId", | |
12425 | PAF_UPDGRP(paf)->id); | |
12426 | json_object_int_add(json_addr, "subGroupId", | |
12427 | PAF_SUBGRP(paf)->id); | |
12428 | json_object_int_add(json_addr, "packetQueueLength", | |
12429 | bpacket_queue_virtual_length(paf)); | |
12430 | } | |
12431 | ||
12432 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12433 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12434 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12435 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12436 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12437 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12438 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12439 | json_object_int_add(json_af, "orfType", | |
12440 | ORF_TYPE_PREFIX); | |
12441 | json_prefA = json_object_new_object(); | |
12442 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
12443 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
12444 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12445 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12446 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
12447 | use_json, json_prefA); | |
12448 | json_object_object_add(json_af, "orfPrefixList", | |
12449 | json_prefA); | |
12450 | } | |
12451 | ||
12452 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12453 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12454 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12455 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12456 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12457 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12458 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12459 | json_object_int_add(json_af, "orfOldType", | |
12460 | ORF_TYPE_PREFIX_OLD); | |
12461 | json_prefB = json_object_new_object(); | |
12462 | bgp_show_peer_afi_orf_cap( | |
12463 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12464 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12465 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12466 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
12467 | json_prefB); | |
12468 | json_object_object_add(json_af, "orfOldPrefixList", | |
12469 | json_prefB); | |
12470 | } | |
12471 | ||
12472 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12473 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12474 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12475 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12476 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12477 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12478 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12479 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12480 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12481 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12482 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12483 | json_object_object_add(json_addr, "afDependentCap", | |
12484 | json_af); | |
12485 | else | |
12486 | json_object_free(json_af); | |
12487 | ||
772270f3 QY |
12488 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12489 | p->host, afi, safi); | |
d62a17ae | 12490 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12491 | NULL, afi, orf_pfx_name, use_json); | |
12492 | ||
12493 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12494 | PEER_STATUS_ORF_PREFIX_SEND) | |
12495 | || orf_pfx_count) { | |
12496 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12497 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12498 | json_object_boolean_true_add(json_neigh, | |
12499 | "orfSent"); | |
12500 | if (orf_pfx_count) | |
12501 | json_object_int_add(json_addr, "orfRecvCounter", | |
12502 | orf_pfx_count); | |
12503 | } | |
12504 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12505 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12506 | json_object_string_add( | |
12507 | json_addr, "orfFirstUpdate", | |
12508 | "deferredUntilORFOrRouteRefreshRecvd"); | |
12509 | ||
12510 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12511 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12512 | json_object_boolean_true_add(json_addr, | |
12513 | "routeReflectorClient"); | |
12514 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12515 | PEER_FLAG_RSERVER_CLIENT)) | |
12516 | json_object_boolean_true_add(json_addr, | |
12517 | "routeServerClient"); | |
12518 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12519 | json_object_boolean_true_add(json_addr, | |
12520 | "inboundSoftConfigPermit"); | |
12521 | ||
12522 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12523 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12524 | json_object_boolean_true_add( | |
12525 | json_addr, | |
12526 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
12527 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12528 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12529 | json_object_boolean_true_add( | |
12530 | json_addr, | |
12531 | "privateAsNumsReplacedInUpdatesToNbr"); | |
12532 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12533 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12534 | json_object_boolean_true_add( | |
12535 | json_addr, | |
12536 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
12537 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12538 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12539 | json_object_boolean_true_add( | |
12540 | json_addr, | |
12541 | "privateAsNumsRemovedInUpdatesToNbr"); | |
12542 | ||
b2ac1d0d MS |
12543 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12544 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12545 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12546 | json_object_boolean_true_add(json_addr, | |
12547 | "allowAsInOrigin"); | |
12548 | else | |
12549 | json_object_int_add(json_addr, "allowAsInCount", | |
12550 | p->allowas_in[afi][safi]); | |
12551 | } | |
12552 | ||
dcc68b5e MS |
12553 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12554 | json_object_boolean_true_add( | |
12555 | json_addr, | |
12556 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12557 | ->type_json_name); | |
d62a17ae | 12558 | |
12559 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12560 | json_object_string_add(json_addr, | |
12561 | "overrideASNsInOutboundUpdates", | |
12562 | "ifAspathEqualRemoteAs"); | |
12563 | ||
12564 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12565 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12566 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12567 | json_object_boolean_true_add(json_addr, | |
12568 | "routerAlwaysNextHop"); | |
12569 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12570 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12571 | json_object_boolean_true_add( | |
12572 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
12573 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12574 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12575 | json_object_boolean_true_add( | |
12576 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
12577 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12578 | json_object_boolean_true_add( | |
12579 | json_addr, "unchangedMedPropogatedToNbr"); | |
12580 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12581 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12582 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
12583 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12584 | PEER_FLAG_SEND_COMMUNITY) | |
12585 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12586 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12587 | json_object_string_add(json_addr, | |
12588 | "commAttriSentToNbr", | |
12589 | "extendedAndStandard"); | |
12590 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12591 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12592 | json_object_string_add(json_addr, | |
12593 | "commAttriSentToNbr", | |
12594 | "extended"); | |
12595 | else | |
12596 | json_object_string_add(json_addr, | |
12597 | "commAttriSentToNbr", | |
12598 | "standard"); | |
12599 | } | |
12600 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12601 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12602 | if (p->default_rmap[afi][safi].name) | |
12603 | json_object_string_add( | |
12604 | json_addr, "defaultRouteMap", | |
12605 | p->default_rmap[afi][safi].name); | |
12606 | ||
12607 | if (paf && PAF_SUBGRP(paf) | |
12608 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12609 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12610 | json_object_boolean_true_add(json_addr, | |
12611 | "defaultSent"); | |
12612 | else | |
12613 | json_object_boolean_true_add(json_addr, | |
12614 | "defaultNotSent"); | |
12615 | } | |
12616 | ||
dff8f48d | 12617 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 12618 | if (is_evpn_enabled()) |
60466a63 QY |
12619 | json_object_boolean_true_add( |
12620 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
12621 | } |
12622 | ||
d62a17ae | 12623 | if (filter->plist[FILTER_IN].name |
12624 | || filter->dlist[FILTER_IN].name | |
12625 | || filter->aslist[FILTER_IN].name | |
12626 | || filter->map[RMAP_IN].name) | |
12627 | json_object_boolean_true_add(json_addr, | |
12628 | "inboundPathPolicyConfig"); | |
12629 | if (filter->plist[FILTER_OUT].name | |
12630 | || filter->dlist[FILTER_OUT].name | |
12631 | || filter->aslist[FILTER_OUT].name | |
12632 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12633 | json_object_boolean_true_add( | |
12634 | json_addr, "outboundPathPolicyConfig"); | |
12635 | ||
12636 | /* prefix-list */ | |
12637 | if (filter->plist[FILTER_IN].name) | |
12638 | json_object_string_add(json_addr, | |
12639 | "incomingUpdatePrefixFilterList", | |
12640 | filter->plist[FILTER_IN].name); | |
12641 | if (filter->plist[FILTER_OUT].name) | |
12642 | json_object_string_add(json_addr, | |
12643 | "outgoingUpdatePrefixFilterList", | |
12644 | filter->plist[FILTER_OUT].name); | |
12645 | ||
12646 | /* distribute-list */ | |
12647 | if (filter->dlist[FILTER_IN].name) | |
12648 | json_object_string_add( | |
12649 | json_addr, "incomingUpdateNetworkFilterList", | |
12650 | filter->dlist[FILTER_IN].name); | |
12651 | if (filter->dlist[FILTER_OUT].name) | |
12652 | json_object_string_add( | |
12653 | json_addr, "outgoingUpdateNetworkFilterList", | |
12654 | filter->dlist[FILTER_OUT].name); | |
12655 | ||
12656 | /* filter-list. */ | |
12657 | if (filter->aslist[FILTER_IN].name) | |
12658 | json_object_string_add(json_addr, | |
12659 | "incomingUpdateAsPathFilterList", | |
12660 | filter->aslist[FILTER_IN].name); | |
12661 | if (filter->aslist[FILTER_OUT].name) | |
12662 | json_object_string_add(json_addr, | |
12663 | "outgoingUpdateAsPathFilterList", | |
12664 | filter->aslist[FILTER_OUT].name); | |
12665 | ||
12666 | /* route-map. */ | |
12667 | if (filter->map[RMAP_IN].name) | |
12668 | json_object_string_add( | |
12669 | json_addr, "routeMapForIncomingAdvertisements", | |
12670 | filter->map[RMAP_IN].name); | |
12671 | if (filter->map[RMAP_OUT].name) | |
12672 | json_object_string_add( | |
12673 | json_addr, "routeMapForOutgoingAdvertisements", | |
12674 | filter->map[RMAP_OUT].name); | |
12675 | ||
9dac9fc8 | 12676 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12677 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12678 | && !bgp_inbound_policy_exists(p, filter)) |
12679 | json_object_string_add( | |
12680 | json_addr, "inboundEbgpRequiresPolicy", | |
12681 | "Inbound updates discarded due to missing policy"); | |
12682 | ||
12683 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12684 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12685 | && (!bgp_outbound_policy_exists(p, filter))) |
12686 | json_object_string_add( | |
12687 | json_addr, "outboundEbgpRequiresPolicy", | |
12688 | "Outbound updates discarded due to missing policy"); | |
12689 | ||
d62a17ae | 12690 | /* unsuppress-map */ |
12691 | if (filter->usmap.name) | |
12692 | json_object_string_add(json_addr, | |
12693 | "selectiveUnsuppressRouteMap", | |
12694 | filter->usmap.name); | |
12695 | ||
fa36596c MK |
12696 | /* advertise-map */ |
12697 | if (filter->advmap.aname) { | |
12698 | json_advmap = json_object_new_object(); | |
12699 | json_object_string_add(json_advmap, "condition", | |
12700 | filter->advmap.condition | |
12701 | ? "EXIST" | |
12702 | : "NON_EXIST"); | |
12703 | json_object_string_add(json_advmap, "conditionMap", | |
12704 | filter->advmap.cname); | |
12705 | json_object_string_add(json_advmap, "advertiseMap", | |
12706 | filter->advmap.aname); | |
ecf2b628 QY |
12707 | json_object_string_add( |
12708 | json_advmap, "advertiseStatus", | |
12709 | filter->advmap.update_type == | |
12710 | UPDATE_TYPE_ADVERTISE | |
12711 | ? "Advertise" | |
12712 | : "Withdraw"); | |
fa36596c MK |
12713 | json_object_object_add(json_addr, "advertiseMap", |
12714 | json_advmap); | |
12715 | } | |
12716 | ||
d62a17ae | 12717 | /* Receive prefix count */ |
12718 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
12719 | p->pcount[afi][safi]); | |
50e05855 AD |
12720 | if (paf && PAF_SUBGRP(paf)) |
12721 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12722 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12723 | |
fde246e8 DA |
12724 | /* Maximum prefix */ |
12725 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12726 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12727 | p->pmax_out[afi][safi]); | |
12728 | ||
d62a17ae | 12729 | /* Maximum prefix */ |
12730 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12731 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12732 | p->pmax[afi][safi]); | |
12733 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12734 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12735 | json_object_boolean_true_add( | |
12736 | json_addr, "prefixAllowedMaxWarning"); | |
12737 | json_object_int_add(json_addr, | |
12738 | "prefixAllowedWarningThresh", | |
12739 | p->pmax_threshold[afi][safi]); | |
12740 | if (p->pmax_restart[afi][safi]) | |
12741 | json_object_int_add( | |
12742 | json_addr, | |
12743 | "prefixAllowedRestartIntervalMsecs", | |
12744 | p->pmax_restart[afi][safi] * 60000); | |
12745 | } | |
2986cac2 | 12746 | json_object_object_add(json_neigh, |
36235319 | 12747 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12748 | json_addr); |
12749 | ||
12750 | } else { | |
12751 | filter = &p->filter[afi][safi]; | |
12752 | ||
12753 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12754 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12755 | |
12756 | if (peer_group_active(p)) | |
12757 | vty_out(vty, " %s peer-group member\n", | |
12758 | p->group->name); | |
12759 | ||
12760 | paf = peer_af_find(p, afi, safi); | |
12761 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12762 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12763 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12764 | vty_out(vty, " Packet Queue length %d\n", | |
12765 | bpacket_queue_virtual_length(paf)); | |
12766 | } else { | |
12767 | vty_out(vty, " Not part of any update group\n"); | |
12768 | } | |
12769 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12770 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12771 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12772 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12773 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12774 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12775 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12776 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12777 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12778 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12779 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12780 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12781 | ||
12782 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12783 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12784 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12785 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12786 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12787 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12788 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12789 | vty_out(vty, | |
12790 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12791 | ORF_TYPE_PREFIX); | |
12792 | bgp_show_peer_afi_orf_cap( | |
12793 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12794 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12795 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12796 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12797 | } | |
12798 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12799 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12800 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12801 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12802 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12803 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12804 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12805 | vty_out(vty, | |
12806 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12807 | ORF_TYPE_PREFIX_OLD); | |
12808 | bgp_show_peer_afi_orf_cap( | |
12809 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12810 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12811 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12812 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12813 | } | |
12814 | ||
772270f3 QY |
12815 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12816 | p->host, afi, safi); | |
d62a17ae | 12817 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12818 | NULL, afi, orf_pfx_name, use_json); | |
12819 | ||
12820 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12821 | PEER_STATUS_ORF_PREFIX_SEND) | |
12822 | || orf_pfx_count) { | |
12823 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12824 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12825 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12826 | vty_out(vty, " sent;"); | |
12827 | if (orf_pfx_count) | |
12828 | vty_out(vty, " received (%d entries)", | |
12829 | orf_pfx_count); | |
12830 | vty_out(vty, "\n"); | |
12831 | } | |
12832 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12833 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12834 | vty_out(vty, | |
12835 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12836 | ||
12837 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12838 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12839 | vty_out(vty, " Route-Reflector Client\n"); | |
12840 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12841 | PEER_FLAG_RSERVER_CLIENT)) | |
12842 | vty_out(vty, " Route-Server Client\n"); | |
12843 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12844 | vty_out(vty, | |
12845 | " Inbound soft reconfiguration allowed\n"); | |
12846 | ||
12847 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12848 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12849 | vty_out(vty, | |
12850 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12851 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12852 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12853 | vty_out(vty, | |
12854 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12855 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12856 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12857 | vty_out(vty, | |
12858 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12859 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12860 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12861 | vty_out(vty, | |
12862 | " Private AS numbers removed in updates to this neighbor\n"); | |
12863 | ||
b2ac1d0d MS |
12864 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN)) { |
12865 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12866 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) | |
12867 | vty_out(vty, | |
12868 | " Local AS allowed as path origin\n"); | |
12869 | else | |
12870 | vty_out(vty, | |
12871 | " Local AS allowed in path, %d occurrences\n", | |
12872 | p->allowas_in[afi][safi]); | |
12873 | } | |
12874 | ||
dcc68b5e MS |
12875 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12876 | vty_out(vty, " %s\n", | |
12877 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12878 | ->human_description); | |
d62a17ae | 12879 | |
12880 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12881 | vty_out(vty, | |
12882 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12883 | ||
12884 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12885 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12886 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12887 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12888 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12889 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12890 | vty_out(vty, | |
12891 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12892 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12893 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12894 | vty_out(vty, | |
12895 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12896 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12897 | vty_out(vty, | |
12898 | " MED is propagated unchanged to this neighbor\n"); | |
12899 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12900 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12901 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12902 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12903 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12904 | vty_out(vty, | |
12905 | " Community attribute sent to this neighbor"); | |
12906 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12907 | PEER_FLAG_SEND_COMMUNITY) | |
12908 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12909 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12910 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12911 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12912 | vty_out(vty, "(all)\n"); | |
12913 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12914 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12915 | vty_out(vty, "(large)\n"); | |
12916 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12917 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12918 | vty_out(vty, "(extended)\n"); | |
12919 | else | |
12920 | vty_out(vty, "(standard)\n"); | |
12921 | } | |
12922 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12923 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12924 | vty_out(vty, " Default information originate,"); | |
12925 | ||
12926 | if (p->default_rmap[afi][safi].name) | |
12927 | vty_out(vty, " default route-map %s%s,", | |
12928 | p->default_rmap[afi][safi].map ? "*" | |
12929 | : "", | |
12930 | p->default_rmap[afi][safi].name); | |
12931 | if (paf && PAF_SUBGRP(paf) | |
12932 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12933 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12934 | vty_out(vty, " default sent\n"); | |
12935 | else | |
12936 | vty_out(vty, " default not sent\n"); | |
12937 | } | |
12938 | ||
dff8f48d MK |
12939 | /* advertise-vni-all */ |
12940 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12941 | if (is_evpn_enabled()) |
dff8f48d MK |
12942 | vty_out(vty, " advertise-all-vni\n"); |
12943 | } | |
12944 | ||
d62a17ae | 12945 | if (filter->plist[FILTER_IN].name |
12946 | || filter->dlist[FILTER_IN].name | |
12947 | || filter->aslist[FILTER_IN].name | |
12948 | || filter->map[RMAP_IN].name) | |
12949 | vty_out(vty, " Inbound path policy configured\n"); | |
12950 | if (filter->plist[FILTER_OUT].name | |
12951 | || filter->dlist[FILTER_OUT].name | |
12952 | || filter->aslist[FILTER_OUT].name | |
12953 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12954 | vty_out(vty, " Outbound path policy configured\n"); | |
12955 | ||
12956 | /* prefix-list */ | |
12957 | if (filter->plist[FILTER_IN].name) | |
12958 | vty_out(vty, | |
12959 | " Incoming update prefix filter list is %s%s\n", | |
12960 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12961 | filter->plist[FILTER_IN].name); | |
12962 | if (filter->plist[FILTER_OUT].name) | |
12963 | vty_out(vty, | |
12964 | " Outgoing update prefix filter list is %s%s\n", | |
12965 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12966 | filter->plist[FILTER_OUT].name); | |
12967 | ||
12968 | /* distribute-list */ | |
12969 | if (filter->dlist[FILTER_IN].name) | |
12970 | vty_out(vty, | |
12971 | " Incoming update network filter list is %s%s\n", | |
12972 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12973 | filter->dlist[FILTER_IN].name); | |
12974 | if (filter->dlist[FILTER_OUT].name) | |
12975 | vty_out(vty, | |
12976 | " Outgoing update network filter list is %s%s\n", | |
12977 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12978 | filter->dlist[FILTER_OUT].name); | |
12979 | ||
12980 | /* filter-list. */ | |
12981 | if (filter->aslist[FILTER_IN].name) | |
12982 | vty_out(vty, | |
12983 | " Incoming update AS path filter list is %s%s\n", | |
12984 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12985 | filter->aslist[FILTER_IN].name); | |
12986 | if (filter->aslist[FILTER_OUT].name) | |
12987 | vty_out(vty, | |
12988 | " Outgoing update AS path filter list is %s%s\n", | |
12989 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12990 | filter->aslist[FILTER_OUT].name); | |
12991 | ||
12992 | /* route-map. */ | |
12993 | if (filter->map[RMAP_IN].name) | |
12994 | vty_out(vty, | |
12995 | " Route map for incoming advertisements is %s%s\n", | |
12996 | filter->map[RMAP_IN].map ? "*" : "", | |
12997 | filter->map[RMAP_IN].name); | |
12998 | if (filter->map[RMAP_OUT].name) | |
12999 | vty_out(vty, | |
13000 | " Route map for outgoing advertisements is %s%s\n", | |
13001 | filter->map[RMAP_OUT].map ? "*" : "", | |
13002 | filter->map[RMAP_OUT].name); | |
13003 | ||
9dac9fc8 | 13004 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 13005 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
13006 | && !bgp_inbound_policy_exists(p, filter)) |
13007 | vty_out(vty, | |
13008 | " Inbound updates discarded due to missing policy\n"); | |
13009 | ||
13010 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 13011 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
13012 | && !bgp_outbound_policy_exists(p, filter)) |
13013 | vty_out(vty, | |
13014 | " Outbound updates discarded due to missing policy\n"); | |
13015 | ||
d62a17ae | 13016 | /* unsuppress-map */ |
13017 | if (filter->usmap.name) | |
13018 | vty_out(vty, | |
13019 | " Route map for selective unsuppress is %s%s\n", | |
13020 | filter->usmap.map ? "*" : "", | |
13021 | filter->usmap.name); | |
13022 | ||
7f7940e6 MK |
13023 | /* advertise-map */ |
13024 | if (filter->advmap.aname && filter->advmap.cname) | |
13025 | vty_out(vty, | |
13026 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
13027 | filter->advmap.condition ? "EXIST" | |
13028 | : "NON_EXIST", | |
13029 | filter->advmap.cmap ? "*" : "", | |
13030 | filter->advmap.cname, | |
13031 | filter->advmap.amap ? "*" : "", | |
13032 | filter->advmap.aname, | |
ecf2b628 QY |
13033 | filter->advmap.update_type == |
13034 | UPDATE_TYPE_ADVERTISE | |
c385f82a MK |
13035 | ? "Advertise" |
13036 | : "Withdraw"); | |
7f7940e6 | 13037 | |
d62a17ae | 13038 | /* Receive prefix count */ |
6cde4b45 | 13039 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 13040 | p->pcount[afi][safi]); |
d62a17ae | 13041 | |
fde246e8 DA |
13042 | /* maximum-prefix-out */ |
13043 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
13044 | PEER_FLAG_MAX_PREFIX_OUT)) | |
13045 | vty_out(vty, | |
6cde4b45 | 13046 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
13047 | p->pmax_out[afi][safi]); |
13048 | ||
d62a17ae | 13049 | /* Maximum prefix */ |
13050 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 13051 | vty_out(vty, |
6cde4b45 | 13052 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 13053 | p->pmax[afi][safi], |
13054 | CHECK_FLAG(p->af_flags[afi][safi], | |
13055 | PEER_FLAG_MAX_PREFIX_WARNING) | |
13056 | ? " (warning-only)" | |
13057 | : ""); | |
13058 | vty_out(vty, " Threshold for warning message %d%%", | |
13059 | p->pmax_threshold[afi][safi]); | |
13060 | if (p->pmax_restart[afi][safi]) | |
13061 | vty_out(vty, ", restart interval %d min", | |
13062 | p->pmax_restart[afi][safi]); | |
13063 | vty_out(vty, "\n"); | |
13064 | } | |
13065 | ||
13066 | vty_out(vty, "\n"); | |
13067 | } | |
13068 | } | |
13069 | ||
9f049418 | 13070 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 13071 | json_object *json) |
718e3744 | 13072 | { |
d62a17ae | 13073 | struct bgp *bgp; |
d62a17ae | 13074 | char timebuf[BGP_UPTIME_LEN]; |
13075 | char dn_flag[2]; | |
d62a17ae | 13076 | afi_t afi; |
13077 | safi_t safi; | |
d7c0a89a QY |
13078 | uint16_t i; |
13079 | uint8_t *msg; | |
d62a17ae | 13080 | json_object *json_neigh = NULL; |
13081 | time_t epoch_tbuf; | |
4ab46701 | 13082 | uint32_t sync_tcp_mss; |
718e3744 | 13083 | |
d62a17ae | 13084 | bgp = p->bgp; |
13085 | ||
13086 | if (use_json) | |
13087 | json_neigh = json_object_new_object(); | |
13088 | ||
13089 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
13090 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
13091 | dn_flag[0] = '*'; | |
13092 | ||
13093 | if (!use_json) { | |
13094 | if (p->conf_if) /* Configured interface name. */ | |
47e12884 DA |
13095 | vty_out(vty, "BGP neighbor on %s: %pSU, ", p->conf_if, |
13096 | &p->su); | |
d62a17ae | 13097 | else /* Configured IP address. */ |
13098 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
13099 | p->host); | |
13100 | } | |
13101 | ||
13102 | if (use_json) { | |
13103 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
13104 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
13105 | "none"); | |
13106 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
47e12884 DA |
13107 | json_object_string_addf(json_neigh, "bgpNeighborAddr", |
13108 | "%pSU", &p->su); | |
d62a17ae | 13109 | |
13110 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
13111 | ||
13112 | if (p->change_local_as) | |
13113 | json_object_int_add(json_neigh, "localAs", | |
13114 | p->change_local_as); | |
13115 | else | |
13116 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
13117 | ||
13118 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
13119 | json_object_boolean_true_add(json_neigh, | |
13120 | "localAsNoPrepend"); | |
13121 | ||
13122 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
13123 | json_object_boolean_true_add(json_neigh, | |
13124 | "localAsReplaceAs"); | |
13125 | } else { | |
13126 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
13127 | || (p->as_type == AS_INTERNAL)) | |
13128 | vty_out(vty, "remote AS %u, ", p->as); | |
13129 | else | |
13130 | vty_out(vty, "remote AS Unspecified, "); | |
13131 | vty_out(vty, "local AS %u%s%s, ", | |
13132 | p->change_local_as ? p->change_local_as : p->local_as, | |
13133 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
13134 | ? " no-prepend" | |
13135 | : "", | |
13136 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
13137 | ? " replace-as" | |
13138 | : ""); | |
13139 | } | |
faa16034 DS |
13140 | /* peer type internal or confed-internal */ |
13141 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 13142 | if (use_json) { |
13143 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13144 | json_object_boolean_true_add( | |
13145 | json_neigh, "nbrConfedInternalLink"); | |
13146 | else | |
13147 | json_object_boolean_true_add(json_neigh, | |
13148 | "nbrInternalLink"); | |
13149 | } else { | |
13150 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13151 | vty_out(vty, "confed-internal link\n"); | |
13152 | else | |
13153 | vty_out(vty, "internal link\n"); | |
13154 | } | |
faa16034 DS |
13155 | /* peer type external or confed-external */ |
13156 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 13157 | if (use_json) { |
13158 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
13159 | json_object_boolean_true_add( | |
13160 | json_neigh, "nbrConfedExternalLink"); | |
13161 | else | |
13162 | json_object_boolean_true_add(json_neigh, | |
13163 | "nbrExternalLink"); | |
13164 | } else { | |
13165 | if (bgp_confederation_peers_check(bgp, p->as)) | |
13166 | vty_out(vty, "confed-external link\n"); | |
13167 | else | |
13168 | vty_out(vty, "external link\n"); | |
13169 | } | |
faa16034 DS |
13170 | } else { |
13171 | if (use_json) | |
13172 | json_object_boolean_true_add(json_neigh, | |
13173 | "nbrUnspecifiedLink"); | |
13174 | else | |
13175 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 13176 | } |
13177 | ||
d864dd9e EB |
13178 | /* Roles */ |
13179 | if (use_json) { | |
13180 | json_object_string_add(json_neigh, "localRole", | |
8f2d6021 EB |
13181 | bgp_get_name_by_role(p->local_role)); |
13182 | json_object_string_add(json_neigh, "remoteRole", | |
13183 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
13184 | } else { |
13185 | vty_out(vty, " Local Role: %s\n", | |
8f2d6021 EB |
13186 | bgp_get_name_by_role(p->local_role)); |
13187 | vty_out(vty, " Remote Role: %s\n", | |
13188 | bgp_get_name_by_role(p->remote_role)); | |
d864dd9e EB |
13189 | } |
13190 | ||
13191 | ||
d62a17ae | 13192 | /* Description. */ |
13193 | if (p->desc) { | |
13194 | if (use_json) | |
13195 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
13196 | else | |
13197 | vty_out(vty, " Description: %s\n", p->desc); | |
13198 | } | |
13199 | ||
13200 | if (p->hostname) { | |
13201 | if (use_json) { | |
432e7e46 KQ |
13202 | json_object_string_add(json_neigh, "hostname", |
13203 | p->hostname); | |
d62a17ae | 13204 | |
13205 | if (p->domainname) | |
13206 | json_object_string_add(json_neigh, "domainname", | |
13207 | p->domainname); | |
13208 | } else { | |
13209 | if (p->domainname && (p->domainname[0] != '\0')) | |
13210 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
13211 | p->domainname); | |
13212 | else | |
13213 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
13214 | } | |
432e7e46 KQ |
13215 | } else { |
13216 | if (use_json) | |
13217 | json_object_string_add(json_neigh, "hostname", | |
13218 | "Unknown"); | |
d62a17ae | 13219 | } |
13220 | ||
13221 | /* Peer-group */ | |
13222 | if (p->group) { | |
13223 | if (use_json) { | |
13224 | json_object_string_add(json_neigh, "peerGroup", | |
13225 | p->group->name); | |
13226 | ||
13227 | if (dn_flag[0]) { | |
13228 | struct prefix prefix, *range = NULL; | |
13229 | ||
0154d8ce DS |
13230 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13231 | range = peer_group_lookup_dynamic_neighbor_range( | |
13232 | p->group, &prefix); | |
d62a17ae | 13233 | |
13234 | if (range) { | |
67d7e256 | 13235 | json_object_string_addf( |
d62a17ae | 13236 | json_neigh, |
67d7e256 DA |
13237 | "peerSubnetRangeGroup", "%pFX", |
13238 | range); | |
d62a17ae | 13239 | } |
13240 | } | |
13241 | } else { | |
13242 | vty_out(vty, | |
13243 | " Member of peer-group %s for session parameters\n", | |
13244 | p->group->name); | |
13245 | ||
13246 | if (dn_flag[0]) { | |
13247 | struct prefix prefix, *range = NULL; | |
13248 | ||
0154d8ce DS |
13249 | if (sockunion2hostprefix(&(p->su), &prefix)) |
13250 | range = peer_group_lookup_dynamic_neighbor_range( | |
13251 | p->group, &prefix); | |
d62a17ae | 13252 | |
13253 | if (range) { | |
d62a17ae | 13254 | vty_out(vty, |
1b78780b DL |
13255 | " Belongs to the subnet range group: %pFX\n", |
13256 | range); | |
d62a17ae | 13257 | } |
13258 | } | |
13259 | } | |
13260 | } | |
13261 | ||
13262 | if (use_json) { | |
13263 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13264 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13265 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13266 | json_object_boolean_true_add(json_neigh, |
13267 | "adminShutDown"); | |
13268 | ||
13269 | /* BGP Version. */ | |
13270 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
c949c771 DA |
13271 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", |
13272 | &p->remote_id); | |
13273 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
13274 | &bgp->router_id); | |
d62a17ae | 13275 | |
13276 | /* Confederation */ | |
13277 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13278 | && bgp_confederation_peers_check(bgp, p->as)) | |
13279 | json_object_boolean_true_add(json_neigh, | |
13280 | "nbrCommonAdmin"); | |
13281 | ||
13282 | /* Status. */ | |
13283 | json_object_string_add( | |
13284 | json_neigh, "bgpState", | |
13285 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13286 | ||
feb17238 | 13287 | if (peer_established(p)) { |
d62a17ae | 13288 | time_t uptime; |
d62a17ae | 13289 | |
083ec940 | 13290 | uptime = monotime(NULL); |
d62a17ae | 13291 | uptime -= p->uptime; |
d62a17ae | 13292 | epoch_tbuf = time(NULL) - uptime; |
13293 | ||
d3c7efed DS |
13294 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
13295 | uptime * 1000); | |
d62a17ae | 13296 | json_object_string_add(json_neigh, "bgpTimerUpString", |
13297 | peer_uptime(p->uptime, timebuf, | |
13298 | BGP_UPTIME_LEN, 0, | |
13299 | NULL)); | |
13300 | json_object_int_add(json_neigh, | |
13301 | "bgpTimerUpEstablishedEpoch", | |
13302 | epoch_tbuf); | |
13303 | } | |
13304 | ||
13305 | else if (p->status == Active) { | |
13306 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13307 | json_object_string_add(json_neigh, "bgpStateIs", | |
13308 | "passive"); | |
13309 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13310 | json_object_string_add(json_neigh, "bgpStateIs", | |
13311 | "passiveNSF"); | |
13312 | } | |
13313 | ||
13314 | /* read timer */ | |
13315 | time_t uptime; | |
a2700b50 | 13316 | struct tm tm; |
d62a17ae | 13317 | |
083ec940 | 13318 | uptime = monotime(NULL); |
d62a17ae | 13319 | uptime -= p->readtime; |
a2700b50 MS |
13320 | gmtime_r(&uptime, &tm); |
13321 | ||
d62a17ae | 13322 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
13323 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13324 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13325 | |
083ec940 | 13326 | uptime = monotime(NULL); |
d62a17ae | 13327 | uptime -= p->last_write; |
a2700b50 MS |
13328 | gmtime_r(&uptime, &tm); |
13329 | ||
d62a17ae | 13330 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
13331 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13332 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13333 | |
083ec940 | 13334 | uptime = monotime(NULL); |
d62a17ae | 13335 | uptime -= p->update_time; |
a2700b50 MS |
13336 | gmtime_r(&uptime, &tm); |
13337 | ||
d62a17ae | 13338 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
13339 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
13340 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 13341 | |
13342 | /* Configured timer values. */ | |
9b1b9623 TA |
13343 | json_object_int_add(json_neigh, |
13344 | "bgpTimerConfiguredHoldTimeMsecs", | |
e93d5c29 TA |
13345 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13346 | ? p->holdtime * 1000 | |
13347 | : bgp->default_holdtime * 1000); | |
13348 | json_object_int_add(json_neigh, | |
13349 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
13350 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13351 | ? p->keepalive * 1000 | |
13352 | : bgp->default_keepalive * 1000); | |
d62a17ae | 13353 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", |
13354 | p->v_holdtime * 1000); | |
13355 | json_object_int_add(json_neigh, | |
13356 | "bgpTimerKeepAliveIntervalMsecs", | |
13357 | p->v_keepalive * 1000); | |
d43114f3 DS |
13358 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
13359 | json_object_int_add(json_neigh, | |
13360 | "bgpTimerDelayOpenTimeMsecs", | |
13361 | p->v_delayopen * 1000); | |
13362 | } | |
13363 | ||
4ab46701 AR |
13364 | /* Configured and Synced tcp-mss value for peer */ |
13365 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13366 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13367 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
13368 | p->tcp_mss); | |
13369 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
13370 | sync_tcp_mss); | |
13371 | } | |
13372 | ||
d08c0c80 DA |
13373 | /* Extended Optional Parameters Length for BGP OPEN Message */ |
13374 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13375 | json_object_boolean_true_add( | |
13376 | json_neigh, "extendedOptionalParametersLength"); | |
13377 | else | |
13378 | json_object_boolean_false_add( | |
13379 | json_neigh, "extendedOptionalParametersLength"); | |
6e37924b DA |
13380 | |
13381 | /* Conditional advertisements */ | |
13382 | json_object_int_add( | |
13383 | json_neigh, | |
13384 | "bgpTimerConfiguredConditionalAdvertisementsSec", | |
13385 | bgp->condition_check_period); | |
13386 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13387 | json_object_int_add( | |
13388 | json_neigh, | |
13389 | "bgpTimerUntilConditionalAdvertisementsSec", | |
13390 | thread_timer_remain_second( | |
13391 | bgp->t_condition_check)); | |
d62a17ae | 13392 | } else { |
13393 | /* Administrative shutdown. */ | |
cb9196e7 DS |
13394 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
13395 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 13396 | vty_out(vty, " Administratively shut down\n"); |
13397 | ||
13398 | /* BGP Version. */ | |
13399 | vty_out(vty, " BGP version 4"); | |
07380148 DA |
13400 | vty_out(vty, ", remote router ID %pI4", &p->remote_id); |
13401 | vty_out(vty, ", local router ID %pI4\n", &bgp->router_id); | |
d62a17ae | 13402 | |
13403 | /* Confederation */ | |
13404 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
13405 | && bgp_confederation_peers_check(bgp, p->as)) | |
13406 | vty_out(vty, | |
13407 | " Neighbor under common administration\n"); | |
13408 | ||
13409 | /* Status. */ | |
13410 | vty_out(vty, " BGP state = %s", | |
13411 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
13412 | ||
feb17238 | 13413 | if (peer_established(p)) |
d62a17ae | 13414 | vty_out(vty, ", up for %8s", |
13415 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
13416 | 0, NULL)); | |
13417 | ||
13418 | else if (p->status == Active) { | |
13419 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
13420 | vty_out(vty, " (passive)"); | |
13421 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
13422 | vty_out(vty, " (NSF passive)"); | |
13423 | } | |
13424 | vty_out(vty, "\n"); | |
13425 | ||
13426 | /* read timer */ | |
13427 | vty_out(vty, " Last read %s", | |
13428 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
13429 | NULL)); | |
13430 | vty_out(vty, ", Last write %s\n", | |
13431 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
13432 | NULL)); | |
13433 | ||
13434 | /* Configured timer values. */ | |
13435 | vty_out(vty, | |
e93d5c29 | 13436 | " Hold time is %d seconds, keepalive interval is %d seconds\n", |
d62a17ae | 13437 | p->v_holdtime, p->v_keepalive); |
e93d5c29 TA |
13438 | vty_out(vty, " Configured hold time is %d seconds", |
13439 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) | |
13440 | ? p->holdtime | |
13441 | : bgp->default_holdtime); | |
9b1b9623 | 13442 | vty_out(vty, ", keepalive interval is %d seconds\n", |
e93d5c29 TA |
13443 | CHECK_FLAG(p->flags, PEER_FLAG_TIMER) |
13444 | ? p->keepalive | |
13445 | : bgp->default_keepalive); | |
d43114f3 DS |
13446 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
13447 | vty_out(vty, | |
13448 | " Configured DelayOpenTime is %d seconds\n", | |
13449 | p->delayopen); | |
4ab46701 AR |
13450 | |
13451 | /* Configured and synced tcp-mss value for peer */ | |
13452 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
13453 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
13454 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
13455 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
13456 | } | |
d08c0c80 DA |
13457 | |
13458 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
13459 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
13460 | vty_out(vty, | |
13461 | " Extended Optional Parameters Length is enabled\n"); | |
6e37924b DA |
13462 | |
13463 | /* Conditional advertisements */ | |
13464 | vty_out(vty, | |
13465 | " Configured conditional advertisements interval is %d seconds\n", | |
13466 | bgp->condition_check_period); | |
13467 | if (thread_is_scheduled(bgp->t_condition_check)) | |
13468 | vty_out(vty, | |
13469 | " Time until conditional advertisements begin is %lu seconds\n", | |
13470 | thread_timer_remain_second( | |
13471 | bgp->t_condition_check)); | |
d62a17ae | 13472 | } |
13473 | /* Capability. */ | |
10711563 DA |
13474 | if (peer_established(p) && |
13475 | (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) { | |
13476 | if (use_json) { | |
13477 | json_object *json_cap = NULL; | |
d62a17ae | 13478 | |
10711563 | 13479 | json_cap = json_object_new_object(); |
d62a17ae | 13480 | |
10711563 DA |
13481 | /* AS4 */ |
13482 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13483 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13484 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) && | |
13485 | CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
ef56aee4 | 13486 | json_object_string_add( |
10711563 | 13487 | json_cap, "4byteAs", |
ef56aee4 | 13488 | "advertisedAndReceived"); |
10711563 DA |
13489 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) |
13490 | json_object_string_add(json_cap, | |
13491 | "4byteAs", | |
13492 | "advertised"); | |
13493 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13494 | json_object_string_add(json_cap, | |
13495 | "4byteAs", | |
13496 | "received"); | |
13497 | } | |
ef56aee4 | 13498 | |
10711563 DA |
13499 | /* Extended Message Support */ |
13500 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV) && | |
13501 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13502 | json_object_string_add(json_cap, | |
13503 | "extendedMessage", | |
13504 | "advertisedAndReceived"); | |
13505 | else if (CHECK_FLAG(p->cap, | |
13506 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
13507 | json_object_string_add(json_cap, | |
13508 | "extendedMessage", | |
13509 | "advertised"); | |
13510 | else if (CHECK_FLAG(p->cap, | |
13511 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13512 | json_object_string_add(json_cap, | |
13513 | "extendedMessage", | |
13514 | "received"); | |
ef56aee4 | 13515 | |
10711563 DA |
13516 | /* AddPath */ |
13517 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13518 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13519 | json_object *json_add = NULL; | |
13520 | const char *print_store; | |
d62a17ae | 13521 | |
10711563 | 13522 | json_add = json_object_new_object(); |
d62a17ae | 13523 | |
10711563 DA |
13524 | FOREACH_AFI_SAFI (afi, safi) { |
13525 | json_object *json_sub = NULL; | |
13526 | json_sub = json_object_new_object(); | |
13527 | print_store = get_afi_safi_str( | |
13528 | afi, safi, true); | |
d62a17ae | 13529 | |
10711563 DA |
13530 | if (CHECK_FLAG( |
13531 | p->af_cap[afi][safi], | |
13532 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13533 | CHECK_FLAG( | |
13534 | p->af_cap[afi][safi], | |
13535 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
05c7a1cc QY |
13536 | if (CHECK_FLAG( |
13537 | p->af_cap[afi] | |
13538 | [safi], | |
10711563 DA |
13539 | PEER_CAP_ADDPATH_AF_TX_ADV) && |
13540 | CHECK_FLAG( | |
05c7a1cc QY |
13541 | p->af_cap[afi] |
13542 | [safi], | |
10711563 DA |
13543 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
13544 | json_object_boolean_true_add( | |
13545 | json_sub, | |
13546 | "txAdvertisedAndReceived"); | |
13547 | else if ( | |
13548 | CHECK_FLAG( | |
13549 | p->af_cap[afi] | |
13550 | [safi], | |
13551 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13552 | json_object_boolean_true_add( | |
13553 | json_sub, | |
13554 | "txAdvertised"); | |
13555 | else if ( | |
13556 | CHECK_FLAG( | |
13557 | p->af_cap[afi] | |
13558 | [safi], | |
13559 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
13560 | json_object_boolean_true_add( | |
13561 | json_sub, | |
13562 | "txReceived"); | |
13563 | } | |
d62a17ae | 13564 | |
10711563 DA |
13565 | if (CHECK_FLAG( |
13566 | p->af_cap[afi][safi], | |
13567 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13568 | CHECK_FLAG( | |
13569 | p->af_cap[afi][safi], | |
13570 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
05c7a1cc QY |
13571 | if (CHECK_FLAG( |
13572 | p->af_cap[afi] | |
13573 | [safi], | |
10711563 DA |
13574 | PEER_CAP_ADDPATH_AF_RX_ADV) && |
13575 | CHECK_FLAG( | |
13576 | p->af_cap[afi] | |
13577 | [safi], | |
13578 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13579 | json_object_boolean_true_add( | |
13580 | json_sub, | |
13581 | "rxAdvertisedAndReceived"); | |
13582 | else if ( | |
13583 | CHECK_FLAG( | |
13584 | p->af_cap[afi] | |
13585 | [safi], | |
13586 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
13587 | json_object_boolean_true_add( | |
13588 | json_sub, | |
13589 | "rxAdvertised"); | |
13590 | else if ( | |
13591 | CHECK_FLAG( | |
13592 | p->af_cap[afi] | |
13593 | [safi], | |
13594 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13595 | json_object_boolean_true_add( | |
13596 | json_sub, | |
13597 | "rxReceived"); | |
05c7a1cc QY |
13598 | } |
13599 | ||
10711563 DA |
13600 | if (CHECK_FLAG( |
13601 | p->af_cap[afi][safi], | |
13602 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13603 | CHECK_FLAG( | |
13604 | p->af_cap[afi][safi], | |
13605 | PEER_CAP_ADDPATH_AF_TX_RCV) || | |
13606 | CHECK_FLAG( | |
13607 | p->af_cap[afi][safi], | |
13608 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13609 | CHECK_FLAG( | |
13610 | p->af_cap[afi][safi], | |
13611 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
13612 | json_object_object_add( | |
13613 | json_add, print_store, | |
13614 | json_sub); | |
13615 | else | |
13616 | json_object_free(json_sub); | |
d62a17ae | 13617 | } |
13618 | ||
10711563 DA |
13619 | json_object_object_add(json_cap, "addPath", |
13620 | json_add); | |
13621 | } | |
d62a17ae | 13622 | |
10711563 DA |
13623 | /* Dynamic */ |
13624 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13625 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13626 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV) && | |
13627 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13628 | json_object_string_add( | |
13629 | json_cap, "dynamic", | |
13630 | "advertisedAndReceived"); | |
13631 | else if (CHECK_FLAG(p->cap, | |
13632 | PEER_CAP_DYNAMIC_ADV)) | |
13633 | json_object_string_add(json_cap, | |
13634 | "dynamic", | |
13635 | "advertised"); | |
13636 | else if (CHECK_FLAG(p->cap, | |
13637 | PEER_CAP_DYNAMIC_RCV)) | |
13638 | json_object_string_add(json_cap, | |
13639 | "dynamic", | |
13640 | "received"); | |
13641 | } | |
d62a17ae | 13642 | |
d864dd9e EB |
13643 | /* Role */ |
13644 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
13645 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
13646 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV) && | |
13647 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13648 | json_object_string_add( | |
13649 | json_cap, "role", | |
13650 | "advertisedAndReceived"); | |
13651 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
13652 | json_object_string_add(json_cap, "role", | |
13653 | "advertised"); | |
13654 | else if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
13655 | json_object_string_add(json_cap, "role", | |
13656 | "received"); | |
13657 | } | |
13658 | ||
10711563 DA |
13659 | /* Extended nexthop */ |
13660 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13661 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13662 | json_object *json_nxt = NULL; | |
13663 | const char *print_store; | |
d62a17ae | 13664 | |
d62a17ae | 13665 | |
10711563 DA |
13666 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV) && |
13667 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13668 | json_object_string_add( | |
13669 | json_cap, "extendedNexthop", | |
13670 | "advertisedAndReceived"); | |
13671 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13672 | json_object_string_add( | |
13673 | json_cap, "extendedNexthop", | |
13674 | "advertised"); | |
13675 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13676 | json_object_string_add( | |
13677 | json_cap, "extendedNexthop", | |
13678 | "received"); | |
d62a17ae | 13679 | |
10711563 DA |
13680 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
13681 | json_nxt = json_object_new_object(); | |
d62a17ae | 13682 | |
10711563 DA |
13683 | for (safi = SAFI_UNICAST; |
13684 | safi < SAFI_MAX; safi++) { | |
13685 | if (CHECK_FLAG( | |
13686 | p->af_cap[AFI_IP] | |
13687 | [safi], | |
13688 | PEER_CAP_ENHE_AF_RCV)) { | |
13689 | print_store = | |
13690 | get_afi_safi_str( | |
d62a17ae | 13691 | AFI_IP, |
10711563 DA |
13692 | safi, |
13693 | true); | |
13694 | json_object_string_add( | |
13695 | json_nxt, | |
13696 | print_store, | |
13697 | "recieved"); /* misspelled for compatibility */ | |
d62a17ae | 13698 | } |
d62a17ae | 13699 | } |
10711563 DA |
13700 | json_object_object_add( |
13701 | json_cap, | |
13702 | "extendedNexthopFamililesByPeer", | |
13703 | json_nxt); | |
d62a17ae | 13704 | } |
10711563 | 13705 | } |
d62a17ae | 13706 | |
10711563 DA |
13707 | /* Long-lived Graceful Restart */ |
13708 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13709 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13710 | json_object *json_llgr = NULL; | |
13711 | const char *afi_safi_str; | |
8606be87 | 13712 | |
10711563 DA |
13713 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV) && |
13714 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13715 | json_object_string_add( | |
13716 | json_cap, | |
13717 | "longLivedGracefulRestart", | |
13718 | "advertisedAndReceived"); | |
13719 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13720 | json_object_string_add( | |
13721 | json_cap, | |
13722 | "longLivedGracefulRestart", | |
13723 | "advertised"); | |
13724 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13725 | json_object_string_add( | |
13726 | json_cap, | |
13727 | "longLivedGracefulRestart", | |
13728 | "received"); | |
8606be87 | 13729 | |
10711563 DA |
13730 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
13731 | json_llgr = json_object_new_object(); | |
8606be87 | 13732 | |
10711563 DA |
13733 | FOREACH_AFI_SAFI (afi, safi) { |
13734 | if (CHECK_FLAG( | |
13735 | p->af_cap[afi] | |
13736 | [safi], | |
13737 | PEER_CAP_ENHE_AF_RCV)) { | |
13738 | afi_safi_str = | |
13739 | get_afi_safi_str( | |
8606be87 DA |
13740 | afi, |
13741 | safi, | |
13742 | true); | |
10711563 DA |
13743 | json_object_string_add( |
13744 | json_llgr, | |
13745 | afi_safi_str, | |
13746 | "received"); | |
8606be87 | 13747 | } |
8606be87 | 13748 | } |
10711563 DA |
13749 | json_object_object_add( |
13750 | json_cap, | |
13751 | "longLivedGracefulRestartByPeer", | |
13752 | json_llgr); | |
8606be87 | 13753 | } |
10711563 | 13754 | } |
8606be87 | 13755 | |
10711563 DA |
13756 | /* Route Refresh */ |
13757 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13758 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13759 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13760 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && | |
13761 | (CHECK_FLAG(p->cap, | |
13762 | PEER_CAP_REFRESH_NEW_RCV) || | |
13763 | CHECK_FLAG(p->cap, | |
13764 | PEER_CAP_REFRESH_OLD_RCV))) { | |
13765 | if (CHECK_FLAG( | |
13766 | p->cap, | |
13767 | PEER_CAP_REFRESH_OLD_RCV) && | |
13768 | CHECK_FLAG( | |
13769 | p->cap, | |
13770 | PEER_CAP_REFRESH_NEW_RCV)) | |
13771 | json_object_string_add( | |
13772 | json_cap, | |
13773 | "routeRefresh", | |
13774 | "advertisedAndReceivedOldNew"); | |
13775 | else { | |
d62a17ae | 13776 | if (CHECK_FLAG( |
13777 | p->cap, | |
10711563 | 13778 | PEER_CAP_REFRESH_OLD_RCV)) |
d62a17ae | 13779 | json_object_string_add( |
13780 | json_cap, | |
13781 | "routeRefresh", | |
10711563 DA |
13782 | "advertisedAndReceivedOld"); |
13783 | else | |
13784 | json_object_string_add( | |
13785 | json_cap, | |
13786 | "routeRefresh", | |
13787 | "advertisedAndReceivedNew"); | |
d62a17ae | 13788 | } |
10711563 DA |
13789 | } else if (CHECK_FLAG(p->cap, |
13790 | PEER_CAP_REFRESH_ADV)) | |
13791 | json_object_string_add(json_cap, | |
13792 | "routeRefresh", | |
13793 | "advertised"); | |
13794 | else if (CHECK_FLAG(p->cap, | |
13795 | PEER_CAP_REFRESH_NEW_RCV) || | |
13796 | CHECK_FLAG(p->cap, | |
13797 | PEER_CAP_REFRESH_OLD_RCV)) | |
13798 | json_object_string_add(json_cap, | |
13799 | "routeRefresh", | |
13800 | "received"); | |
13801 | } | |
d62a17ae | 13802 | |
10711563 DA |
13803 | /* Enhanced Route Refresh */ |
13804 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13805 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13806 | if (CHECK_FLAG(p->cap, | |
13807 | PEER_CAP_ENHANCED_RR_ADV) && | |
13808 | CHECK_FLAG(p->cap, | |
13809 | PEER_CAP_ENHANCED_RR_RCV)) | |
d77114b7 | 13810 | json_object_string_add( |
10711563 DA |
13811 | json_cap, |
13812 | "enhancedRouteRefresh", | |
13813 | "advertisedAndReceived"); | |
13814 | else if (CHECK_FLAG(p->cap, | |
13815 | PEER_CAP_ENHANCED_RR_ADV)) | |
d77114b7 | 13816 | json_object_string_add( |
10711563 DA |
13817 | json_cap, |
13818 | "enhancedRouteRefresh", | |
13819 | "advertised"); | |
13820 | else if (CHECK_FLAG(p->cap, | |
9af52ccf | 13821 | PEER_CAP_ENHANCED_RR_RCV)) |
10711563 DA |
13822 | json_object_string_add( |
13823 | json_cap, | |
13824 | "enhancedRouteRefresh", | |
13825 | "received"); | |
13826 | } | |
d77114b7 | 13827 | |
10711563 DA |
13828 | /* Multiprotocol Extensions */ |
13829 | json_object *json_multi = NULL; | |
d77114b7 | 13830 | |
10711563 | 13831 | json_multi = json_object_new_object(); |
d77114b7 | 13832 | |
10711563 DA |
13833 | FOREACH_AFI_SAFI (afi, safi) { |
13834 | if (p->afc_adv[afi][safi] || | |
13835 | p->afc_recv[afi][safi]) { | |
13836 | json_object *json_exten = NULL; | |
13837 | json_exten = json_object_new_object(); | |
13838 | ||
13839 | if (p->afc_adv[afi][safi] && | |
13840 | p->afc_recv[afi][safi]) | |
13841 | json_object_boolean_true_add( | |
13842 | json_exten, | |
9af52ccf | 13843 | "advertisedAndReceived"); |
10711563 DA |
13844 | else if (p->afc_adv[afi][safi]) |
13845 | json_object_boolean_true_add( | |
13846 | json_exten, | |
9af52ccf | 13847 | "advertised"); |
10711563 DA |
13848 | else if (p->afc_recv[afi][safi]) |
13849 | json_object_boolean_true_add( | |
13850 | json_exten, "received"); | |
9af52ccf | 13851 | |
10711563 DA |
13852 | json_object_object_add( |
13853 | json_multi, | |
13854 | get_afi_safi_str(afi, safi, | |
13855 | true), | |
13856 | json_exten); | |
13857 | } | |
13858 | } | |
13859 | json_object_object_add(json_cap, | |
13860 | "multiprotocolExtensions", | |
13861 | json_multi); | |
d62a17ae | 13862 | |
10711563 DA |
13863 | /* Hostname capabilities */ |
13864 | json_object *json_hname = NULL; | |
d62a17ae | 13865 | |
10711563 | 13866 | json_hname = json_object_new_object(); |
d62a17ae | 13867 | |
10711563 DA |
13868 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
13869 | json_object_string_add( | |
13870 | json_hname, "advHostName", | |
13871 | bgp->peer_self->hostname | |
13872 | ? bgp->peer_self->hostname | |
13873 | : "n/a"); | |
13874 | json_object_string_add( | |
13875 | json_hname, "advDomainName", | |
13876 | bgp->peer_self->domainname | |
13877 | ? bgp->peer_self->domainname | |
13878 | : "n/a"); | |
13879 | } | |
d77114b7 | 13880 | |
d77114b7 | 13881 | |
10711563 DA |
13882 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13883 | json_object_string_add( | |
13884 | json_hname, "rcvHostName", | |
13885 | p->hostname ? p->hostname : "n/a"); | |
13886 | json_object_string_add( | |
13887 | json_hname, "rcvDomainName", | |
13888 | p->domainname ? p->domainname : "n/a"); | |
13889 | } | |
d77114b7 | 13890 | |
10711563 DA |
13891 | json_object_object_add(json_cap, "hostName", |
13892 | json_hname); | |
d77114b7 | 13893 | |
17be83bf | 13894 | /* Graceful Restart */ |
10711563 DA |
13895 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || |
13896 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13897 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
13898 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
d77114b7 | 13899 | json_object_string_add( |
10711563 DA |
13900 | json_cap, "gracefulRestart", |
13901 | "advertisedAndReceived"); | |
13902 | else if (CHECK_FLAG(p->cap, | |
13903 | PEER_CAP_RESTART_ADV)) | |
d77114b7 | 13904 | json_object_string_add( |
10711563 DA |
13905 | json_cap, |
13906 | "gracefulRestartCapability", | |
13907 | "advertised"); | |
13908 | else if (CHECK_FLAG(p->cap, | |
13909 | PEER_CAP_RESTART_RCV)) | |
13910 | json_object_string_add( | |
13911 | json_cap, | |
13912 | "gracefulRestartCapability", | |
13913 | "received"); | |
d77114b7 | 13914 | |
10711563 DA |
13915 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13916 | int restart_af_count = 0; | |
13917 | json_object *json_restart = NULL; | |
13918 | json_restart = json_object_new_object(); | |
d62a17ae | 13919 | |
10711563 DA |
13920 | json_object_int_add( |
13921 | json_cap, | |
13922 | "gracefulRestartRemoteTimerMsecs", | |
13923 | p->v_gr_restart * 1000); | |
d62a17ae | 13924 | |
10711563 | 13925 | FOREACH_AFI_SAFI (afi, safi) { |
05c7a1cc QY |
13926 | if (CHECK_FLAG( |
13927 | p->af_cap[afi] | |
13928 | [safi], | |
10711563 DA |
13929 | PEER_CAP_RESTART_AF_RCV)) { |
13930 | json_object *json_sub = | |
13931 | NULL; | |
13932 | json_sub = | |
13933 | json_object_new_object(); | |
d62a17ae | 13934 | |
05c7a1cc QY |
13935 | if (CHECK_FLAG( |
13936 | p->af_cap | |
13937 | [afi] | |
13938 | [safi], | |
10711563 DA |
13939 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13940 | json_object_boolean_true_add( | |
13941 | json_sub, | |
13942 | "preserved"); | |
13943 | restart_af_count++; | |
d62a17ae | 13944 | json_object_object_add( |
10711563 DA |
13945 | json_restart, |
13946 | get_afi_safi_str( | |
13947 | afi, | |
13948 | safi, | |
13949 | true), | |
13950 | json_sub); | |
d62a17ae | 13951 | } |
d62a17ae | 13952 | } |
10711563 DA |
13953 | if (!restart_af_count) { |
13954 | json_object_string_add( | |
13955 | json_cap, | |
13956 | "addressFamiliesByPeer", | |
13957 | "none"); | |
13958 | json_object_free(json_restart); | |
13959 | } else | |
13960 | json_object_object_add( | |
13961 | json_cap, | |
13962 | "addressFamiliesByPeer", | |
13963 | json_restart); | |
d62a17ae | 13964 | } |
10711563 DA |
13965 | } |
13966 | json_object_object_add( | |
13967 | json_neigh, "neighborCapabilities", json_cap); | |
13968 | } else { | |
13969 | vty_out(vty, " Neighbor capabilities:\n"); | |
13970 | ||
13971 | /* AS4 */ | |
13972 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13973 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13974 | vty_out(vty, " 4 Byte AS:"); | |
13975 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
13976 | vty_out(vty, " advertised"); | |
13977 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13978 | vty_out(vty, " %sreceived", | |
13979 | CHECK_FLAG(p->cap, | |
13980 | PEER_CAP_AS4_ADV) | |
13981 | ? "and " | |
13982 | : ""); | |
13983 | vty_out(vty, "\n"); | |
13984 | } | |
d62a17ae | 13985 | |
10711563 DA |
13986 | /* Extended Message Support */ |
13987 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) || | |
13988 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13989 | vty_out(vty, " Extended Message:"); | |
ef56aee4 | 13990 | if (CHECK_FLAG(p->cap, |
10711563 DA |
13991 | PEER_CAP_EXTENDED_MESSAGE_ADV)) |
13992 | vty_out(vty, " advertised"); | |
13993 | if (CHECK_FLAG(p->cap, | |
13994 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13995 | vty_out(vty, " %sreceived", | |
13996 | CHECK_FLAG( | |
13997 | p->cap, | |
13998 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13999 | ? "and " | |
14000 | : ""); | |
14001 | vty_out(vty, "\n"); | |
14002 | } | |
d62a17ae | 14003 | |
10711563 DA |
14004 | /* AddPath */ |
14005 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
14006 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
14007 | vty_out(vty, " AddPath:\n"); | |
d62a17ae | 14008 | |
10711563 | 14009 | FOREACH_AFI_SAFI (afi, safi) { |
ef56aee4 | 14010 | if (CHECK_FLAG( |
10711563 DA |
14011 | p->af_cap[afi][safi], |
14012 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
14013 | CHECK_FLAG( | |
14014 | p->af_cap[afi][safi], | |
14015 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
14016 | vty_out(vty, " %s: TX ", | |
14017 | get_afi_safi_str( | |
14018 | afi, safi, | |
14019 | false)); | |
ef56aee4 | 14020 | |
10711563 DA |
14021 | if (CHECK_FLAG( |
14022 | p->af_cap[afi] | |
14023 | [safi], | |
14024 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
14025 | vty_out(vty, | |
14026 | "advertised"); | |
d62a17ae | 14027 | |
05c7a1cc QY |
14028 | if (CHECK_FLAG( |
14029 | p->af_cap[afi] | |
14030 | [safi], | |
10711563 | 14031 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
05c7a1cc | 14032 | vty_out(vty, |
10711563 DA |
14033 | "%sreceived", |
14034 | CHECK_FLAG( | |
14035 | p->af_cap | |
14036 | [afi] | |
14037 | [safi], | |
14038 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
14039 | ? " and " | |
14040 | : ""); | |
05c7a1cc | 14041 | |
10711563 DA |
14042 | vty_out(vty, "\n"); |
14043 | } | |
d62a17ae | 14044 | |
9af52ccf | 14045 | if (CHECK_FLAG( |
10711563 DA |
14046 | p->af_cap[afi][safi], |
14047 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
14048 | CHECK_FLAG( | |
14049 | p->af_cap[afi][safi], | |
14050 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
14051 | vty_out(vty, " %s: RX ", | |
5cb5f4d0 | 14052 | get_afi_safi_str( |
10711563 DA |
14053 | afi, safi, |
14054 | false)); | |
d62a17ae | 14055 | |
05c7a1cc QY |
14056 | if (CHECK_FLAG( |
14057 | p->af_cap[afi] | |
14058 | [safi], | |
10711563 | 14059 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
05c7a1cc | 14060 | vty_out(vty, |
10711563 | 14061 | "advertised"); |
d62a17ae | 14062 | |
10711563 DA |
14063 | if (CHECK_FLAG( |
14064 | p->af_cap[afi] | |
14065 | [safi], | |
14066 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc | 14067 | vty_out(vty, |
10711563 DA |
14068 | "%sreceived", |
14069 | CHECK_FLAG( | |
14070 | p->af_cap | |
14071 | [afi] | |
14072 | [safi], | |
14073 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
14074 | ? " and " | |
05c7a1cc | 14075 | : ""); |
d62a17ae | 14076 | |
05c7a1cc | 14077 | vty_out(vty, "\n"); |
05c7a1cc | 14078 | } |
d62a17ae | 14079 | } |
10711563 | 14080 | } |
d62a17ae | 14081 | |
10711563 DA |
14082 | /* Dynamic */ |
14083 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
14084 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
14085 | vty_out(vty, " Dynamic:"); | |
14086 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) | |
14087 | vty_out(vty, " advertised"); | |
14088 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
14089 | vty_out(vty, " %sreceived", | |
14090 | CHECK_FLAG(p->cap, | |
14091 | PEER_CAP_DYNAMIC_ADV) | |
14092 | ? "and " | |
14093 | : ""); | |
14094 | vty_out(vty, "\n"); | |
14095 | } | |
d62a17ae | 14096 | |
d864dd9e EB |
14097 | /* Role */ |
14098 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV) || | |
14099 | CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) { | |
14100 | vty_out(vty, " Role:"); | |
14101 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_ADV)) | |
14102 | vty_out(vty, " advertised"); | |
14103 | if (CHECK_FLAG(p->cap, PEER_CAP_ROLE_RCV)) | |
14104 | vty_out(vty, " %sreceived", | |
14105 | CHECK_FLAG(p->cap, | |
14106 | PEER_CAP_ROLE_ADV) | |
14107 | ? "and " | |
14108 | : ""); | |
14109 | vty_out(vty, "\n"); | |
14110 | } | |
14111 | ||
10711563 DA |
14112 | /* Extended nexthop */ |
14113 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
14114 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
14115 | vty_out(vty, " Extended nexthop:"); | |
14116 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
14117 | vty_out(vty, " advertised"); | |
14118 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
14119 | vty_out(vty, " %sreceived", | |
14120 | CHECK_FLAG(p->cap, | |
14121 | PEER_CAP_ENHE_ADV) | |
14122 | ? "and " | |
14123 | : ""); | |
14124 | vty_out(vty, "\n"); | |
d62a17ae | 14125 | |
10711563 | 14126 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
57f7feb6 | 14127 | vty_out(vty, |
10711563 DA |
14128 | " Address families by peer:\n "); |
14129 | for (safi = SAFI_UNICAST; | |
14130 | safi < SAFI_MAX; safi++) | |
14131 | if (CHECK_FLAG( | |
14132 | p->af_cap[AFI_IP] | |
14133 | [safi], | |
14134 | PEER_CAP_ENHE_AF_RCV)) | |
14135 | vty_out(vty, | |
14136 | " %s\n", | |
14137 | get_afi_safi_str( | |
14138 | AFI_IP, | |
14139 | safi, | |
14140 | false)); | |
d62a17ae | 14141 | } |
10711563 | 14142 | } |
d62a17ae | 14143 | |
10711563 DA |
14144 | /* Long-lived Graceful Restart */ |
14145 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
14146 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
14147 | vty_out(vty, | |
14148 | " Long-lived Graceful Restart:"); | |
14149 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
14150 | vty_out(vty, " advertised"); | |
14151 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
14152 | vty_out(vty, " %sreceived", | |
14153 | CHECK_FLAG(p->cap, | |
14154 | PEER_CAP_LLGR_ADV) | |
14155 | ? "and " | |
14156 | : ""); | |
14157 | vty_out(vty, "\n"); | |
8606be87 | 14158 | |
10711563 | 14159 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
57f7feb6 | 14160 | vty_out(vty, |
10711563 DA |
14161 | " Address families by peer:\n"); |
14162 | FOREACH_AFI_SAFI (afi, safi) | |
14163 | if (CHECK_FLAG( | |
14164 | p->af_cap[afi] | |
14165 | [safi], | |
14166 | PEER_CAP_LLGR_AF_RCV)) | |
14167 | vty_out(vty, | |
14168 | " %s\n", | |
14169 | get_afi_safi_str( | |
14170 | afi, | |
14171 | safi, | |
14172 | false)); | |
8606be87 | 14173 | } |
10711563 | 14174 | } |
8606be87 | 14175 | |
10711563 DA |
14176 | /* Route Refresh */ |
14177 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
14178 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
14179 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
14180 | vty_out(vty, " Route refresh:"); | |
14181 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV)) | |
14182 | vty_out(vty, " advertised"); | |
14183 | if (CHECK_FLAG(p->cap, | |
14184 | PEER_CAP_REFRESH_NEW_RCV) || | |
14185 | CHECK_FLAG(p->cap, | |
14186 | PEER_CAP_REFRESH_OLD_RCV)) | |
14187 | vty_out(vty, " %sreceived(%s)", | |
14188 | CHECK_FLAG(p->cap, | |
14189 | PEER_CAP_REFRESH_ADV) | |
14190 | ? "and " | |
14191 | : "", | |
14192 | (CHECK_FLAG( | |
14193 | p->cap, | |
14194 | PEER_CAP_REFRESH_OLD_RCV) && | |
14195 | CHECK_FLAG( | |
14196 | p->cap, | |
14197 | PEER_CAP_REFRESH_NEW_RCV)) | |
14198 | ? "old & new" | |
14199 | : CHECK_FLAG( | |
14200 | p->cap, | |
14201 | PEER_CAP_REFRESH_OLD_RCV) | |
14202 | ? "old" | |
14203 | : "new"); | |
d62a17ae | 14204 | |
d77114b7 | 14205 | vty_out(vty, "\n"); |
10711563 | 14206 | } |
d62a17ae | 14207 | |
10711563 DA |
14208 | /* Enhanced Route Refresh */ |
14209 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
14210 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
14211 | vty_out(vty, " Enhanced Route Refresh:"); | |
14212 | if (CHECK_FLAG(p->cap, | |
14213 | PEER_CAP_ENHANCED_RR_ADV)) | |
14214 | vty_out(vty, " advertised"); | |
14215 | if (CHECK_FLAG(p->cap, | |
14216 | PEER_CAP_ENHANCED_RR_RCV)) | |
14217 | vty_out(vty, " %sreceived", | |
14218 | CHECK_FLAG(p->cap, | |
14219 | PEER_CAP_REFRESH_ADV) | |
14220 | ? "and " | |
14221 | : ""); | |
14222 | vty_out(vty, "\n"); | |
14223 | } | |
14224 | ||
14225 | /* Multiprotocol Extensions */ | |
14226 | FOREACH_AFI_SAFI (afi, safi) | |
14227 | if (p->afc_adv[afi][safi] || | |
14228 | p->afc_recv[afi][safi]) { | |
14229 | vty_out(vty, " Address Family %s:", | |
14230 | get_afi_safi_str(afi, safi, | |
14231 | false)); | |
14232 | if (p->afc_adv[afi][safi]) | |
9af52ccf | 14233 | vty_out(vty, " advertised"); |
10711563 | 14234 | if (p->afc_recv[afi][safi]) |
9af52ccf | 14235 | vty_out(vty, " %sreceived", |
10711563 | 14236 | p->afc_adv[afi][safi] |
9af52ccf DA |
14237 | ? "and " |
14238 | : ""); | |
14239 | vty_out(vty, "\n"); | |
14240 | } | |
14241 | ||
10711563 DA |
14242 | /* Hostname capability */ |
14243 | vty_out(vty, " Hostname Capability:"); | |
d62a17ae | 14244 | |
10711563 DA |
14245 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
14246 | vty_out(vty, | |
14247 | " advertised (name: %s,domain name: %s)", | |
14248 | bgp->peer_self->hostname | |
14249 | ? bgp->peer_self->hostname | |
14250 | : "n/a", | |
14251 | bgp->peer_self->domainname | |
14252 | ? bgp->peer_self->domainname | |
14253 | : "n/a"); | |
14254 | } else { | |
14255 | vty_out(vty, " not advertised"); | |
14256 | } | |
d77114b7 | 14257 | |
10711563 DA |
14258 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
14259 | vty_out(vty, | |
14260 | " received (name: %s,domain name: %s)", | |
14261 | p->hostname ? p->hostname : "n/a", | |
14262 | p->domainname ? p->domainname : "n/a"); | |
14263 | } else { | |
14264 | vty_out(vty, " not received"); | |
d62a17ae | 14265 | } |
d62a17ae | 14266 | |
10711563 | 14267 | vty_out(vty, "\n"); |
d77114b7 | 14268 | |
10711563 DA |
14269 | /* Graceful Restart */ |
14270 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
14271 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
14272 | vty_out(vty, | |
14273 | " Graceful Restart Capability:"); | |
14274 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) | |
14275 | vty_out(vty, " advertised"); | |
14276 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
14277 | vty_out(vty, " %sreceived", | |
14278 | CHECK_FLAG(p->cap, | |
14279 | PEER_CAP_RESTART_ADV) | |
14280 | ? "and " | |
14281 | : ""); | |
d77114b7 MK |
14282 | vty_out(vty, "\n"); |
14283 | ||
10711563 DA |
14284 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
14285 | int restart_af_count = 0; | |
d62a17ae | 14286 | |
10711563 DA |
14287 | vty_out(vty, |
14288 | " Remote Restart timer is %d seconds\n", | |
14289 | p->v_gr_restart); | |
14290 | vty_out(vty, | |
14291 | " Address families by peer:\n "); | |
d62a17ae | 14292 | |
10711563 DA |
14293 | FOREACH_AFI_SAFI (afi, safi) |
14294 | if (CHECK_FLAG( | |
14295 | p->af_cap[afi] | |
14296 | [safi], | |
14297 | PEER_CAP_RESTART_AF_RCV)) { | |
14298 | vty_out(vty, "%s%s(%s)", | |
14299 | restart_af_count | |
14300 | ? ", " | |
14301 | : "", | |
14302 | get_afi_safi_str( | |
14303 | afi, | |
14304 | safi, | |
14305 | false), | |
14306 | CHECK_FLAG( | |
14307 | p->af_cap | |
14308 | [afi] | |
14309 | [safi], | |
14310 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
14311 | ? "preserved" | |
14312 | : "not preserved"); | |
14313 | restart_af_count++; | |
14314 | } | |
14315 | if (!restart_af_count) | |
14316 | vty_out(vty, "none"); | |
14317 | vty_out(vty, "\n"); | |
14318 | } | |
17be83bf | 14319 | } /* Graceful Restart */ |
d62a17ae | 14320 | } |
14321 | } | |
14322 | ||
14323 | /* graceful restart information */ | |
10711563 DA |
14324 | json_object *json_grace = NULL; |
14325 | json_object *json_grace_send = NULL; | |
14326 | json_object *json_grace_recv = NULL; | |
14327 | int eor_send_af_count = 0; | |
14328 | int eor_receive_af_count = 0; | |
d62a17ae | 14329 | |
10711563 DA |
14330 | if (use_json) { |
14331 | json_grace = json_object_new_object(); | |
14332 | json_grace_send = json_object_new_object(); | |
14333 | json_grace_recv = json_object_new_object(); | |
14334 | ||
14335 | if ((peer_established(p)) && | |
14336 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14337 | FOREACH_AFI_SAFI (afi, safi) { | |
14338 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14339 | PEER_STATUS_EOR_SEND)) { | |
14340 | json_object_boolean_true_add( | |
14341 | json_grace_send, | |
14342 | get_afi_safi_str(afi, safi, | |
14343 | true)); | |
14344 | eor_send_af_count++; | |
d62a17ae | 14345 | } |
10711563 DA |
14346 | } |
14347 | FOREACH_AFI_SAFI (afi, safi) { | |
14348 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14349 | PEER_STATUS_EOR_RECEIVED)) { | |
14350 | json_object_boolean_true_add( | |
14351 | json_grace_recv, | |
14352 | get_afi_safi_str(afi, safi, | |
14353 | true)); | |
14354 | eor_receive_af_count++; | |
d62a17ae | 14355 | } |
14356 | } | |
10711563 DA |
14357 | } |
14358 | json_object_object_add(json_grace, "endOfRibSend", | |
14359 | json_grace_send); | |
14360 | json_object_object_add(json_grace, "endOfRibRecv", | |
14361 | json_grace_recv); | |
d62a17ae | 14362 | |
d62a17ae | 14363 | |
10711563 DA |
14364 | if (p->t_gr_restart) |
14365 | json_object_int_add( | |
14366 | json_grace, "gracefulRestartTimerMsecs", | |
14367 | thread_timer_remain_second(p->t_gr_restart) * | |
14368 | 1000); | |
2986cac2 | 14369 | |
10711563 DA |
14370 | if (p->t_gr_stale) |
14371 | json_object_int_add( | |
14372 | json_grace, "gracefulStalepathTimerMsecs", | |
14373 | thread_timer_remain_second(p->t_gr_stale) * | |
14374 | 1000); | |
14375 | /* more gr info in new format */ | |
403e64f8 | 14376 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, json_grace); |
10711563 DA |
14377 | json_object_object_add(json_neigh, "gracefulRestartInfo", |
14378 | json_grace); | |
14379 | } else { | |
14380 | vty_out(vty, " Graceful restart information:\n"); | |
14381 | if ((peer_established(p)) && | |
14382 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
14383 | ||
14384 | vty_out(vty, " End-of-RIB send: "); | |
14385 | FOREACH_AFI_SAFI (afi, safi) { | |
14386 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14387 | PEER_STATUS_EOR_SEND)) { | |
14388 | vty_out(vty, "%s%s", | |
14389 | eor_send_af_count ? ", " : "", | |
14390 | get_afi_safi_str(afi, safi, | |
14391 | false)); | |
14392 | eor_send_af_count++; | |
d62a17ae | 14393 | } |
10711563 DA |
14394 | } |
14395 | vty_out(vty, "\n"); | |
14396 | vty_out(vty, " End-of-RIB received: "); | |
14397 | FOREACH_AFI_SAFI (afi, safi) { | |
14398 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
14399 | PEER_STATUS_EOR_RECEIVED)) { | |
14400 | vty_out(vty, "%s%s", | |
14401 | eor_receive_af_count ? ", " | |
14402 | : "", | |
14403 | get_afi_safi_str(afi, safi, | |
14404 | false)); | |
14405 | eor_receive_af_count++; | |
d62a17ae | 14406 | } |
d62a17ae | 14407 | } |
10711563 DA |
14408 | vty_out(vty, "\n"); |
14409 | } | |
d62a17ae | 14410 | |
10711563 DA |
14411 | if (p->t_gr_restart) |
14412 | vty_out(vty, | |
14413 | " The remaining time of restart timer is %ld\n", | |
14414 | thread_timer_remain_second(p->t_gr_restart)); | |
d62a17ae | 14415 | |
10711563 DA |
14416 | if (p->t_gr_stale) |
14417 | vty_out(vty, | |
14418 | " The remaining time of stalepath timer is %ld\n", | |
14419 | thread_timer_remain_second(p->t_gr_stale)); | |
2986cac2 | 14420 | |
10711563 | 14421 | /* more gr info in new format */ |
403e64f8 | 14422 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, NULL); |
10711563 | 14423 | } |
2986cac2 | 14424 | |
d62a17ae | 14425 | if (use_json) { |
14426 | json_object *json_stat = NULL; | |
14427 | json_stat = json_object_new_object(); | |
14428 | /* Packet counts. */ | |
43aa5965 QY |
14429 | |
14430 | atomic_size_t outq_count, inq_count; | |
14431 | outq_count = atomic_load_explicit(&p->obuf->count, | |
14432 | memory_order_relaxed); | |
14433 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14434 | memory_order_relaxed); | |
14435 | ||
14436 | json_object_int_add(json_stat, "depthInq", | |
14437 | (unsigned long)inq_count); | |
d62a17ae | 14438 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 14439 | (unsigned long)outq_count); |
0112e9e0 QY |
14440 | json_object_int_add(json_stat, "opensSent", |
14441 | atomic_load_explicit(&p->open_out, | |
14442 | memory_order_relaxed)); | |
14443 | json_object_int_add(json_stat, "opensRecv", | |
14444 | atomic_load_explicit(&p->open_in, | |
14445 | memory_order_relaxed)); | |
d62a17ae | 14446 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
14447 | atomic_load_explicit(&p->notify_out, |
14448 | memory_order_relaxed)); | |
d62a17ae | 14449 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
14450 | atomic_load_explicit(&p->notify_in, |
14451 | memory_order_relaxed)); | |
14452 | json_object_int_add(json_stat, "updatesSent", | |
14453 | atomic_load_explicit(&p->update_out, | |
14454 | memory_order_relaxed)); | |
14455 | json_object_int_add(json_stat, "updatesRecv", | |
14456 | atomic_load_explicit(&p->update_in, | |
14457 | memory_order_relaxed)); | |
d62a17ae | 14458 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
14459 | atomic_load_explicit(&p->keepalive_out, |
14460 | memory_order_relaxed)); | |
d62a17ae | 14461 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
14462 | atomic_load_explicit(&p->keepalive_in, |
14463 | memory_order_relaxed)); | |
d62a17ae | 14464 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
14465 | atomic_load_explicit(&p->refresh_out, |
14466 | memory_order_relaxed)); | |
d62a17ae | 14467 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
14468 | atomic_load_explicit(&p->refresh_in, |
14469 | memory_order_relaxed)); | |
d62a17ae | 14470 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
14471 | atomic_load_explicit(&p->dynamic_cap_out, |
14472 | memory_order_relaxed)); | |
d62a17ae | 14473 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
14474 | atomic_load_explicit(&p->dynamic_cap_in, |
14475 | memory_order_relaxed)); | |
14476 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
14477 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 14478 | json_object_object_add(json_neigh, "messageStats", json_stat); |
14479 | } else { | |
cb93e0a2 IS |
14480 | atomic_size_t outq_count, inq_count, open_out, open_in, |
14481 | notify_out, notify_in, update_out, update_in, | |
14482 | keepalive_out, keepalive_in, refresh_out, refresh_in, | |
14483 | dynamic_cap_out, dynamic_cap_in; | |
43aa5965 QY |
14484 | outq_count = atomic_load_explicit(&p->obuf->count, |
14485 | memory_order_relaxed); | |
14486 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
14487 | memory_order_relaxed); | |
cb93e0a2 IS |
14488 | open_out = atomic_load_explicit(&p->open_out, |
14489 | memory_order_relaxed); | |
14490 | open_in = | |
14491 | atomic_load_explicit(&p->open_in, memory_order_relaxed); | |
14492 | notify_out = atomic_load_explicit(&p->notify_out, | |
14493 | memory_order_relaxed); | |
14494 | notify_in = atomic_load_explicit(&p->notify_in, | |
14495 | memory_order_relaxed); | |
14496 | update_out = atomic_load_explicit(&p->update_out, | |
14497 | memory_order_relaxed); | |
14498 | update_in = atomic_load_explicit(&p->update_in, | |
14499 | memory_order_relaxed); | |
14500 | keepalive_out = atomic_load_explicit(&p->keepalive_out, | |
14501 | memory_order_relaxed); | |
14502 | keepalive_in = atomic_load_explicit(&p->keepalive_in, | |
14503 | memory_order_relaxed); | |
14504 | refresh_out = atomic_load_explicit(&p->refresh_out, | |
14505 | memory_order_relaxed); | |
14506 | refresh_in = atomic_load_explicit(&p->refresh_in, | |
14507 | memory_order_relaxed); | |
14508 | dynamic_cap_out = atomic_load_explicit(&p->dynamic_cap_out, | |
14509 | memory_order_relaxed); | |
14510 | dynamic_cap_in = atomic_load_explicit(&p->dynamic_cap_in, | |
14511 | memory_order_relaxed); | |
43aa5965 | 14512 | |
d62a17ae | 14513 | /* Packet counts. */ |
14514 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
14515 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
14516 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 14517 | vty_out(vty, " Sent Rcvd\n"); |
cb93e0a2 IS |
14518 | vty_out(vty, " Opens: %10zu %10zu\n", open_out, |
14519 | open_in); | |
14520 | vty_out(vty, " Notifications: %10zu %10zu\n", notify_out, | |
14521 | notify_in); | |
14522 | vty_out(vty, " Updates: %10zu %10zu\n", update_out, | |
14523 | update_in); | |
14524 | vty_out(vty, " Keepalives: %10zu %10zu\n", keepalive_out, | |
14525 | keepalive_in); | |
14526 | vty_out(vty, " Route Refresh: %10zu %10zu\n", refresh_out, | |
14527 | refresh_in); | |
14528 | vty_out(vty, " Capability: %10zu %10zu\n", | |
14529 | dynamic_cap_out, dynamic_cap_in); | |
14530 | vty_out(vty, " Total: %10u %10u\n", | |
14531 | (uint32_t)PEER_TOTAL_TX(p), (uint32_t)PEER_TOTAL_RX(p)); | |
d62a17ae | 14532 | } |
14533 | ||
14534 | if (use_json) { | |
14535 | /* advertisement-interval */ | |
14536 | json_object_int_add(json_neigh, | |
14537 | "minBtwnAdvertisementRunsTimerMsecs", | |
14538 | p->v_routeadv * 1000); | |
14539 | ||
14540 | /* Update-source. */ | |
14541 | if (p->update_if || p->update_source) { | |
14542 | if (p->update_if) | |
14543 | json_object_string_add(json_neigh, | |
14544 | "updateSource", | |
14545 | p->update_if); | |
14546 | else if (p->update_source) | |
47e12884 DA |
14547 | json_object_string_addf(json_neigh, |
14548 | "updateSource", "%pSU", | |
14549 | p->update_source); | |
d62a17ae | 14550 | } |
14551 | } else { | |
14552 | /* advertisement-interval */ | |
14553 | vty_out(vty, | |
14554 | " Minimum time between advertisement runs is %d seconds\n", | |
14555 | p->v_routeadv); | |
14556 | ||
14557 | /* Update-source. */ | |
14558 | if (p->update_if || p->update_source) { | |
14559 | vty_out(vty, " Update source is "); | |
14560 | if (p->update_if) | |
14561 | vty_out(vty, "%s", p->update_if); | |
14562 | else if (p->update_source) | |
47e12884 | 14563 | vty_out(vty, "%pSU", p->update_source); |
d62a17ae | 14564 | vty_out(vty, "\n"); |
14565 | } | |
14566 | ||
14567 | vty_out(vty, "\n"); | |
14568 | } | |
14569 | ||
14570 | /* Address Family Information */ | |
14571 | json_object *json_hold = NULL; | |
14572 | ||
14573 | if (use_json) | |
14574 | json_hold = json_object_new_object(); | |
14575 | ||
05c7a1cc QY |
14576 | FOREACH_AFI_SAFI (afi, safi) |
14577 | if (p->afc[afi][safi]) | |
14578 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
14579 | json_hold); | |
d62a17ae | 14580 | |
14581 | if (use_json) { | |
14582 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
14583 | json_hold); | |
14584 | json_object_int_add(json_neigh, "connectionsEstablished", | |
14585 | p->established); | |
14586 | json_object_int_add(json_neigh, "connectionsDropped", | |
14587 | p->dropped); | |
14588 | } else | |
14589 | vty_out(vty, " Connections established %d; dropped %d\n", | |
14590 | p->established, p->dropped); | |
14591 | ||
14592 | if (!p->last_reset) { | |
14593 | if (use_json) | |
14594 | json_object_string_add(json_neigh, "lastReset", | |
14595 | "never"); | |
14596 | else | |
14597 | vty_out(vty, " Last reset never\n"); | |
14598 | } else { | |
14599 | if (use_json) { | |
14600 | time_t uptime; | |
a2700b50 | 14601 | struct tm tm; |
d62a17ae | 14602 | |
083ec940 | 14603 | uptime = monotime(NULL); |
d62a17ae | 14604 | uptime -= p->resettime; |
a2700b50 MS |
14605 | gmtime_r(&uptime, &tm); |
14606 | ||
d62a17ae | 14607 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
14608 | (tm.tm_sec * 1000) |
14609 | + (tm.tm_min * 60000) | |
14610 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 14611 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 14612 | } else { |
14613 | vty_out(vty, " Last reset %s, ", | |
14614 | peer_uptime(p->resettime, timebuf, | |
14615 | BGP_UPTIME_LEN, 0, NULL)); | |
14616 | ||
3577f1c5 | 14617 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 14618 | if (p->last_reset_cause_size) { |
14619 | msg = p->last_reset_cause; | |
14620 | vty_out(vty, | |
14621 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
14622 | for (i = 1; i <= p->last_reset_cause_size; | |
14623 | i++) { | |
14624 | vty_out(vty, "%02X", *msg++); | |
14625 | ||
14626 | if (i != p->last_reset_cause_size) { | |
14627 | if (i % 16 == 0) { | |
14628 | vty_out(vty, "\n "); | |
14629 | } else if (i % 4 == 0) { | |
14630 | vty_out(vty, " "); | |
14631 | } | |
14632 | } | |
14633 | } | |
14634 | vty_out(vty, "\n"); | |
14635 | } | |
14636 | } | |
14637 | } | |
14638 | ||
14639 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
14640 | if (use_json) | |
14641 | json_object_boolean_true_add(json_neigh, | |
14642 | "prefixesConfigExceedMax"); | |
14643 | else | |
14644 | vty_out(vty, | |
14645 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
14646 | ||
14647 | if (p->t_pmax_restart) { | |
14648 | if (use_json) { | |
14649 | json_object_boolean_true_add( | |
14650 | json_neigh, "reducePrefixNumFrom"); | |
14651 | json_object_int_add(json_neigh, | |
14652 | "restartInTimerMsec", | |
14653 | thread_timer_remain_second( | |
14654 | p->t_pmax_restart) | |
14655 | * 1000); | |
14656 | } else | |
14657 | vty_out(vty, | |
14658 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
14659 | p->host, thread_timer_remain_second( |
14660 | p->t_pmax_restart)); | |
d62a17ae | 14661 | } else { |
14662 | if (use_json) | |
14663 | json_object_boolean_true_add( | |
14664 | json_neigh, | |
14665 | "reducePrefixNumAndClearIpBgp"); | |
14666 | else | |
14667 | vty_out(vty, | |
14668 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
14669 | p->host); | |
14670 | } | |
14671 | } | |
14672 | ||
14673 | /* EBGP Multihop and GTSM */ | |
14674 | if (p->sort != BGP_PEER_IBGP) { | |
14675 | if (use_json) { | |
e2521429 | 14676 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14677 | json_object_int_add(json_neigh, |
14678 | "externalBgpNbrMaxHopsAway", | |
14679 | p->gtsm_hops); | |
be8d1733 | 14680 | else |
d62a17ae | 14681 | json_object_int_add(json_neigh, |
14682 | "externalBgpNbrMaxHopsAway", | |
14683 | p->ttl); | |
14684 | } else { | |
e2521429 | 14685 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 14686 | vty_out(vty, |
14687 | " External BGP neighbor may be up to %d hops away.\n", | |
14688 | p->gtsm_hops); | |
be8d1733 | 14689 | else |
d62a17ae | 14690 | vty_out(vty, |
14691 | " External BGP neighbor may be up to %d hops away.\n", | |
14692 | p->ttl); | |
14693 | } | |
14694 | } else { | |
be8d1733 DA |
14695 | if (use_json) { |
14696 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14697 | json_object_int_add(json_neigh, |
14698 | "internalBgpNbrMaxHopsAway", | |
14699 | p->gtsm_hops); | |
14700 | else | |
be8d1733 DA |
14701 | json_object_int_add(json_neigh, |
14702 | "internalBgpNbrMaxHopsAway", | |
14703 | p->ttl); | |
14704 | } else { | |
14705 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 14706 | vty_out(vty, |
14707 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14708 | p->gtsm_hops); | |
be8d1733 DA |
14709 | else |
14710 | vty_out(vty, | |
14711 | " Internal BGP neighbor may be up to %d hops away.\n", | |
14712 | p->ttl); | |
d62a17ae | 14713 | } |
14714 | } | |
14715 | ||
14716 | /* Local address. */ | |
14717 | if (p->su_local) { | |
14718 | if (use_json) { | |
47e12884 DA |
14719 | json_object_string_addf(json_neigh, "hostLocal", "%pSU", |
14720 | p->su_local); | |
d62a17ae | 14721 | json_object_int_add(json_neigh, "portLocal", |
14722 | ntohs(p->su_local->sin.sin_port)); | |
14723 | } else | |
47e12884 DA |
14724 | vty_out(vty, "Local host: %pSU, Local port: %d\n", |
14725 | p->su_local, ntohs(p->su_local->sin.sin_port)); | |
1e592331 DS |
14726 | } else { |
14727 | if (use_json) { | |
14728 | json_object_string_add(json_neigh, "hostLocal", | |
14729 | "Unknown"); | |
14730 | json_object_int_add(json_neigh, "portLocal", -1); | |
14731 | } | |
d62a17ae | 14732 | } |
14733 | ||
14734 | /* Remote address. */ | |
14735 | if (p->su_remote) { | |
14736 | if (use_json) { | |
47e12884 DA |
14737 | json_object_string_addf(json_neigh, "hostForeign", |
14738 | "%pSU", p->su_remote); | |
d62a17ae | 14739 | json_object_int_add(json_neigh, "portForeign", |
14740 | ntohs(p->su_remote->sin.sin_port)); | |
14741 | } else | |
47e12884 DA |
14742 | vty_out(vty, "Foreign host: %pSU, Foreign port: %d\n", |
14743 | p->su_remote, | |
d62a17ae | 14744 | ntohs(p->su_remote->sin.sin_port)); |
1e592331 DS |
14745 | } else { |
14746 | if (use_json) { | |
14747 | json_object_string_add(json_neigh, "hostForeign", | |
14748 | "Unknown"); | |
14749 | json_object_int_add(json_neigh, "portForeign", -1); | |
14750 | } | |
d62a17ae | 14751 | } |
14752 | ||
14753 | /* Nexthop display. */ | |
14754 | if (p->su_local) { | |
14755 | if (use_json) { | |
c949c771 DA |
14756 | json_object_string_addf(json_neigh, "nexthop", "%pI4", |
14757 | &p->nexthop.v4); | |
14758 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
14759 | "%pI6", &p->nexthop.v6_global); | |
14760 | json_object_string_addf(json_neigh, "nexthopLocal", | |
14761 | "%pI6", &p->nexthop.v6_local); | |
d62a17ae | 14762 | if (p->shared_network) |
14763 | json_object_string_add(json_neigh, | |
14764 | "bgpConnection", | |
14765 | "sharedNetwork"); | |
14766 | else | |
14767 | json_object_string_add(json_neigh, | |
14768 | "bgpConnection", | |
14769 | "nonSharedNetwork"); | |
14770 | } else { | |
07380148 DA |
14771 | vty_out(vty, "Nexthop: %pI4\n", &p->nexthop.v4); |
14772 | vty_out(vty, "Nexthop global: %pI6\n", | |
14773 | &p->nexthop.v6_global); | |
14774 | vty_out(vty, "Nexthop local: %pI6\n", | |
14775 | &p->nexthop.v6_local); | |
d62a17ae | 14776 | vty_out(vty, "BGP connection: %s\n", |
14777 | p->shared_network ? "shared network" | |
14778 | : "non shared network"); | |
14779 | } | |
432e7e46 KQ |
14780 | } else { |
14781 | if (use_json) { | |
14782 | json_object_string_add(json_neigh, "nexthop", | |
14783 | "Unknown"); | |
14784 | json_object_string_add(json_neigh, "nexthopGlobal", | |
14785 | "Unknown"); | |
14786 | json_object_string_add(json_neigh, "nexthopLocal", | |
14787 | "Unknown"); | |
14788 | json_object_string_add(json_neigh, "bgpConnection", | |
14789 | "Unknown"); | |
14790 | } | |
d62a17ae | 14791 | } |
14792 | ||
14793 | /* Timer information. */ | |
14794 | if (use_json) { | |
14795 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14796 | p->v_connect); | |
f41255a0 | 14797 | if (peer_established(p)) { |
d62a17ae | 14798 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
14799 | p->rtt); | |
f41255a0 DA |
14800 | if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) { |
14801 | json_object_int_add(json_neigh, | |
14802 | "shutdownRttInMsecs", | |
14803 | p->rtt_expected); | |
14804 | json_object_int_add(json_neigh, | |
14805 | "shutdownRttAfterCount", | |
14806 | p->rtt_keepalive_rcv); | |
14807 | } | |
14808 | } | |
d62a17ae | 14809 | if (p->t_start) |
14810 | json_object_int_add( | |
14811 | json_neigh, "nextStartTimerDueInMsecs", | |
14812 | thread_timer_remain_second(p->t_start) * 1000); | |
14813 | if (p->t_connect) | |
14814 | json_object_int_add( | |
14815 | json_neigh, "nextConnectTimerDueInMsecs", | |
14816 | thread_timer_remain_second(p->t_connect) | |
14817 | * 1000); | |
14818 | if (p->t_routeadv) { | |
14819 | json_object_int_add(json_neigh, "mraiInterval", | |
14820 | p->v_routeadv); | |
14821 | json_object_int_add( | |
14822 | json_neigh, "mraiTimerExpireInMsecs", | |
14823 | thread_timer_remain_second(p->t_routeadv) | |
14824 | * 1000); | |
14825 | } | |
14826 | if (p->password) | |
14827 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14828 | 1); | |
14829 | ||
14830 | if (p->t_read) | |
14831 | json_object_string_add(json_neigh, "readThread", "on"); | |
14832 | else | |
14833 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14834 | |
14835 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14836 | json_object_string_add(json_neigh, "writeThread", "on"); |
14837 | else | |
14838 | json_object_string_add(json_neigh, "writeThread", | |
14839 | "off"); | |
14840 | } else { | |
14841 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14842 | p->v_connect); | |
f41255a0 | 14843 | if (peer_established(p)) { |
d62a17ae | 14844 | vty_out(vty, "Estimated round trip time: %d ms\n", |
14845 | p->rtt); | |
f41255a0 DA |
14846 | if (CHECK_FLAG(p->flags, PEER_FLAG_RTT_SHUTDOWN)) |
14847 | vty_out(vty, | |
14848 | "Shutdown when RTT > %dms, count > %u\n", | |
14849 | p->rtt_expected, p->rtt_keepalive_rcv); | |
14850 | } | |
d62a17ae | 14851 | if (p->t_start) |
14852 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14853 | thread_timer_remain_second(p->t_start)); | |
14854 | if (p->t_connect) | |
14855 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14856 | thread_timer_remain_second(p->t_connect)); | |
14857 | if (p->t_routeadv) | |
14858 | vty_out(vty, | |
14859 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14860 | p->v_routeadv, | |
14861 | thread_timer_remain_second(p->t_routeadv)); | |
14862 | if (p->password) | |
14863 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14864 | ||
cac9e917 | 14865 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14866 | p->t_read ? "on" : "off", |
14867 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14868 | ? "on" | |
cac9e917 | 14869 | : "off", p->fd); |
d62a17ae | 14870 | } |
14871 | ||
14872 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14873 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14874 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14875 | ||
14876 | if (!use_json) | |
14877 | vty_out(vty, "\n"); | |
14878 | ||
14879 | /* BFD information. */ | |
21bfce98 RZ |
14880 | if (p->bfd_config) |
14881 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 14882 | |
14883 | if (use_json) { | |
14884 | if (p->conf_if) /* Configured interface name. */ | |
14885 | json_object_object_add(json, p->conf_if, json_neigh); | |
14886 | else /* Configured IP address. */ | |
14887 | json_object_object_add(json, p->host, json_neigh); | |
14888 | } | |
14889 | } | |
14890 | ||
36235319 QY |
14891 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14892 | enum show_type type, | |
14893 | union sockunion *su, | |
14894 | const char *conf_if, afi_t afi, | |
403e64f8 | 14895 | json_object *json) |
2986cac2 | 14896 | { |
14897 | struct listnode *node, *nnode; | |
14898 | struct peer *peer; | |
5a59e9b2 | 14899 | bool found = false; |
2986cac2 | 14900 | safi_t safi = SAFI_UNICAST; |
14901 | json_object *json_neighbor = NULL; | |
14902 | ||
14903 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14904 | ||
14905 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14906 | continue; | |
14907 | ||
14908 | if ((peer->afc[afi][safi]) == 0) | |
14909 | continue; | |
14910 | ||
403e64f8 DA |
14911 | if (json) |
14912 | json_neighbor = json_object_new_object(); | |
14913 | ||
2ba1fe69 | 14914 | if (type == show_all) { |
403e64f8 | 14915 | bgp_show_peer_gr_status(vty, peer, json_neighbor); |
2986cac2 | 14916 | |
403e64f8 | 14917 | if (json) |
13909c4f DS |
14918 | json_object_object_add(json, peer->host, |
14919 | json_neighbor); | |
2986cac2 | 14920 | |
2ba1fe69 | 14921 | } else if (type == show_peer) { |
2986cac2 | 14922 | if (conf_if) { |
14923 | if ((peer->conf_if | |
13909c4f DS |
14924 | && !strcmp(peer->conf_if, conf_if)) |
14925 | || (peer->hostname | |
2986cac2 | 14926 | && !strcmp(peer->hostname, conf_if))) { |
5a59e9b2 | 14927 | found = true; |
13909c4f | 14928 | bgp_show_peer_gr_status(vty, peer, |
13909c4f | 14929 | json_neighbor); |
2986cac2 | 14930 | } |
14931 | } else { | |
14932 | if (sockunion_same(&peer->su, su)) { | |
5a59e9b2 | 14933 | found = true; |
13909c4f | 14934 | bgp_show_peer_gr_status(vty, peer, |
13909c4f | 14935 | json_neighbor); |
2986cac2 | 14936 | } |
14937 | } | |
5a59e9b2 DS |
14938 | if (json) { |
14939 | if (found) | |
14940 | json_object_object_add(json, peer->host, | |
14941 | json_neighbor); | |
14942 | else | |
14943 | json_object_free(json_neighbor); | |
14944 | } | |
2986cac2 | 14945 | } |
14946 | ||
5a59e9b2 | 14947 | if (found) |
2986cac2 | 14948 | break; |
14949 | } | |
14950 | ||
5a59e9b2 | 14951 | if (type == show_peer && !found) { |
403e64f8 | 14952 | if (json) |
13909c4f | 14953 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14954 | else |
14955 | vty_out(vty, "%% No such neighbor\n"); | |
14956 | } | |
403e64f8 DA |
14957 | |
14958 | if (!json) | |
2986cac2 | 14959 | vty_out(vty, "\n"); |
2986cac2 | 14960 | |
14961 | return CMD_SUCCESS; | |
14962 | } | |
14963 | ||
d62a17ae | 14964 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14965 | enum show_type type, union sockunion *su, | |
9f049418 | 14966 | const char *conf_if, bool use_json, |
d62a17ae | 14967 | json_object *json) |
14968 | { | |
14969 | struct listnode *node, *nnode; | |
14970 | struct peer *peer; | |
14971 | int find = 0; | |
9f049418 | 14972 | bool nbr_output = false; |
d1927ebe AS |
14973 | afi_t afi = AFI_MAX; |
14974 | safi_t safi = SAFI_MAX; | |
14975 | ||
14976 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14977 | afi = AFI_IP; | |
14978 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14979 | afi = AFI_IP6; | |
14980 | } | |
d62a17ae | 14981 | |
14982 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14983 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14984 | continue; | |
14985 | ||
14986 | switch (type) { | |
14987 | case show_all: | |
14988 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14989 | nbr_output = true; |
d62a17ae | 14990 | break; |
14991 | case show_peer: | |
14992 | if (conf_if) { | |
14993 | if ((peer->conf_if | |
14994 | && !strcmp(peer->conf_if, conf_if)) | |
14995 | || (peer->hostname | |
14996 | && !strcmp(peer->hostname, conf_if))) { | |
14997 | find = 1; | |
14998 | bgp_show_peer(vty, peer, use_json, | |
14999 | json); | |
15000 | } | |
15001 | } else { | |
15002 | if (sockunion_same(&peer->su, su)) { | |
15003 | find = 1; | |
15004 | bgp_show_peer(vty, peer, use_json, | |
15005 | json); | |
15006 | } | |
15007 | } | |
15008 | break; | |
d1927ebe AS |
15009 | case show_ipv4_peer: |
15010 | case show_ipv6_peer: | |
15011 | FOREACH_SAFI (safi) { | |
15012 | if (peer->afc[afi][safi]) { | |
15013 | if (conf_if) { | |
15014 | if ((peer->conf_if | |
15015 | && !strcmp(peer->conf_if, conf_if)) | |
15016 | || (peer->hostname | |
15017 | && !strcmp(peer->hostname, conf_if))) { | |
15018 | find = 1; | |
15019 | bgp_show_peer(vty, peer, use_json, | |
15020 | json); | |
15021 | break; | |
15022 | } | |
15023 | } else { | |
15024 | if (sockunion_same(&peer->su, su)) { | |
15025 | find = 1; | |
15026 | bgp_show_peer(vty, peer, use_json, | |
15027 | json); | |
15028 | break; | |
15029 | } | |
15030 | } | |
15031 | } | |
15032 | } | |
15033 | break; | |
15034 | case show_ipv4_all: | |
15035 | case show_ipv6_all: | |
15036 | FOREACH_SAFI (safi) { | |
15037 | if (peer->afc[afi][safi]) { | |
15038 | bgp_show_peer(vty, peer, use_json, json); | |
15039 | nbr_output = true; | |
15040 | break; | |
15041 | } | |
15042 | } | |
15043 | break; | |
d62a17ae | 15044 | } |
15045 | } | |
15046 | ||
d1927ebe AS |
15047 | if ((type == show_peer || type == show_ipv4_peer || |
15048 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 15049 | if (use_json) |
15050 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
15051 | else | |
88b7d255 | 15052 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 15053 | } |
15054 | ||
d1927ebe AS |
15055 | if (type != show_peer && type != show_ipv4_peer && |
15056 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 15057 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 15058 | |
d62a17ae | 15059 | if (use_json) { |
996c9314 LB |
15060 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
15061 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 15062 | } else { |
15063 | vty_out(vty, "\n"); | |
15064 | } | |
15065 | ||
15066 | return CMD_SUCCESS; | |
15067 | } | |
15068 | ||
36235319 QY |
15069 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
15070 | enum show_type type, | |
15071 | const char *ip_str, | |
403e64f8 | 15072 | afi_t afi, json_object *json) |
2986cac2 | 15073 | { |
15074 | ||
15075 | int ret; | |
15076 | struct bgp *bgp; | |
15077 | union sockunion su; | |
2986cac2 | 15078 | |
15079 | bgp = bgp_get_default(); | |
15080 | ||
13909c4f DS |
15081 | if (!bgp) |
15082 | return; | |
2986cac2 | 15083 | |
403e64f8 DA |
15084 | if (!json) |
15085 | bgp_show_global_graceful_restart_mode_vty(vty, bgp); | |
2986cac2 | 15086 | |
13909c4f DS |
15087 | if (ip_str) { |
15088 | ret = str2sockunion(ip_str, &su); | |
15089 | if (ret < 0) | |
403e64f8 DA |
15090 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, |
15091 | ip_str, afi, json); | |
74a630b6 NT |
15092 | else |
15093 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
403e64f8 | 15094 | NULL, afi, json); |
13909c4f DS |
15095 | } else |
15096 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
403e64f8 | 15097 | afi, json); |
2986cac2 | 15098 | } |
15099 | ||
d62a17ae | 15100 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
15101 | enum show_type type, |
15102 | const char *ip_str, | |
9f049418 | 15103 | bool use_json) |
d62a17ae | 15104 | { |
0291c246 MK |
15105 | struct listnode *node, *nnode; |
15106 | struct bgp *bgp; | |
71aedaa3 | 15107 | union sockunion su; |
0291c246 | 15108 | json_object *json = NULL; |
71aedaa3 | 15109 | int ret, is_first = 1; |
9f049418 | 15110 | bool nbr_output = false; |
d62a17ae | 15111 | |
15112 | if (use_json) | |
15113 | vty_out(vty, "{\n"); | |
15114 | ||
15115 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 15116 | nbr_output = true; |
d62a17ae | 15117 | if (use_json) { |
15118 | if (!(json = json_object_new_object())) { | |
af4c2728 | 15119 | flog_err( |
e50f7cfd | 15120 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 15121 | "Unable to allocate memory for JSON object"); |
15122 | vty_out(vty, | |
15123 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
15124 | return; | |
15125 | } | |
15126 | ||
15127 | json_object_int_add(json, "vrfId", | |
15128 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
15129 | ? -1 |
15130 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 15131 | json_object_string_add( |
15132 | json, "vrfName", | |
15133 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15134 | ? VRF_DEFAULT_NAME |
d62a17ae | 15135 | : bgp->name); |
15136 | ||
15137 | if (!is_first) | |
15138 | vty_out(vty, ",\n"); | |
15139 | else | |
15140 | is_first = 0; | |
15141 | ||
15142 | vty_out(vty, "\"%s\":", | |
15143 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15144 | ? VRF_DEFAULT_NAME |
d62a17ae | 15145 | : bgp->name); |
15146 | } else { | |
15147 | vty_out(vty, "\nInstance %s:\n", | |
15148 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15149 | ? VRF_DEFAULT_NAME |
d62a17ae | 15150 | : bgp->name); |
15151 | } | |
71aedaa3 | 15152 | |
d1927ebe AS |
15153 | if (type == show_peer || type == show_ipv4_peer || |
15154 | type == show_ipv6_peer) { | |
71aedaa3 DS |
15155 | ret = str2sockunion(ip_str, &su); |
15156 | if (ret < 0) | |
15157 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
15158 | use_json, json); | |
15159 | else | |
15160 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
15161 | use_json, json); | |
15162 | } else { | |
d1927ebe | 15163 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
15164 | use_json, json); |
15165 | } | |
b77004d6 | 15166 | json_object_free(json); |
121067e9 | 15167 | json = NULL; |
d62a17ae | 15168 | } |
15169 | ||
3e78a6ce | 15170 | if (use_json) |
d62a17ae | 15171 | vty_out(vty, "}\n"); |
9f049418 DS |
15172 | else if (!nbr_output) |
15173 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 15174 | } |
15175 | ||
15176 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
15177 | enum show_type type, const char *ip_str, | |
9f049418 | 15178 | bool use_json) |
d62a17ae | 15179 | { |
15180 | int ret; | |
15181 | struct bgp *bgp; | |
15182 | union sockunion su; | |
15183 | json_object *json = NULL; | |
15184 | ||
15185 | if (name) { | |
15186 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
15187 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
15188 | use_json); | |
d62a17ae | 15189 | return CMD_SUCCESS; |
15190 | } else { | |
15191 | bgp = bgp_lookup_by_name(name); | |
15192 | if (!bgp) { | |
15193 | if (use_json) { | |
15194 | json = json_object_new_object(); | |
75eeda93 | 15195 | vty_json(vty, json); |
d62a17ae | 15196 | } else |
15197 | vty_out(vty, | |
9f049418 | 15198 | "%% BGP instance not found\n"); |
d62a17ae | 15199 | |
15200 | return CMD_WARNING; | |
15201 | } | |
15202 | } | |
15203 | } else { | |
15204 | bgp = bgp_get_default(); | |
15205 | } | |
15206 | ||
15207 | if (bgp) { | |
15208 | json = json_object_new_object(); | |
15209 | if (ip_str) { | |
15210 | ret = str2sockunion(ip_str, &su); | |
15211 | if (ret < 0) | |
15212 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
15213 | use_json, json); | |
15214 | else | |
15215 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
15216 | use_json, json); | |
15217 | } else { | |
15218 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
15219 | json); | |
15220 | } | |
15221 | json_object_free(json); | |
ca61fd25 DS |
15222 | } else { |
15223 | if (use_json) | |
15224 | vty_out(vty, "{}\n"); | |
15225 | else | |
15226 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 15227 | } |
15228 | ||
15229 | return CMD_SUCCESS; | |
4fb25c53 DW |
15230 | } |
15231 | ||
2986cac2 | 15232 | |
15233 | ||
15234 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
dcab9012 | 15235 | DEFUN (show_ip_bgp_neighbors_graceful_restart, |
2986cac2 | 15236 | show_ip_bgp_neighbors_graceful_restart_cmd, |
15237 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
15238 | SHOW_STR | |
15239 | BGP_STR | |
15240 | IP_STR | |
15241 | IPV6_STR | |
15242 | NEIGHBOR_STR | |
15243 | "Neighbor to display information about\n" | |
15244 | "Neighbor to display information about\n" | |
15245 | "Neighbor on BGP configured interface\n" | |
15246 | GR_SHOW | |
15247 | JSON_STR) | |
15248 | { | |
15249 | char *sh_arg = NULL; | |
15250 | enum show_type sh_type; | |
15251 | int idx = 0; | |
15252 | afi_t afi = AFI_MAX; | |
2986cac2 | 15253 | bool uj = use_json(argc, argv); |
15254 | ||
36235319 | 15255 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 15256 | afi = AFI_MAX; |
15257 | ||
15258 | idx++; | |
15259 | ||
15260 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
15261 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15262 | || argv_find(argv, argc, "WORD", &idx)) { | |
15263 | sh_type = show_peer; | |
15264 | sh_arg = argv[idx]->arg; | |
15265 | } else | |
15266 | sh_type = show_all; | |
15267 | ||
15268 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
15269 | return CMD_SUCCESS; | |
15270 | ||
15271 | ||
36235319 QY |
15272 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
15273 | afi, uj); | |
2986cac2 | 15274 | } |
15275 | ||
716b2d8a | 15276 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 15277 | DEFUN (show_ip_bgp_neighbors, |
15278 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 15279 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 15280 | SHOW_STR |
15281 | IP_STR | |
15282 | BGP_STR | |
f2a8972b | 15283 | BGP_INSTANCE_HELP_STR |
00e6edb9 DA |
15284 | BGP_AF_STR |
15285 | BGP_AF_STR | |
718e3744 | 15286 | "Detailed information on TCP and BGP neighbor connections\n" |
15287 | "Neighbor to display information about\n" | |
a80beece | 15288 | "Neighbor to display information about\n" |
91d37724 | 15289 | "Neighbor on BGP configured interface\n" |
9973d184 | 15290 | JSON_STR) |
718e3744 | 15291 | { |
d62a17ae | 15292 | char *vrf = NULL; |
15293 | char *sh_arg = NULL; | |
15294 | enum show_type sh_type; | |
d1927ebe | 15295 | afi_t afi = AFI_MAX; |
718e3744 | 15296 | |
9f049418 | 15297 | bool uj = use_json(argc, argv); |
718e3744 | 15298 | |
d62a17ae | 15299 | int idx = 0; |
718e3744 | 15300 | |
9a8bdf1c PG |
15301 | /* [<vrf> VIEWVRFNAME] */ |
15302 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15303 | vrf = argv[idx + 1]->arg; | |
15304 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15305 | vrf = NULL; | |
15306 | } else if (argv_find(argv, argc, "view", &idx)) | |
15307 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 15308 | vrf = argv[idx + 1]->arg; |
718e3744 | 15309 | |
d62a17ae | 15310 | idx++; |
d1927ebe AS |
15311 | |
15312 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
15313 | sh_type = show_ipv4_all; | |
15314 | afi = AFI_IP; | |
15315 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
15316 | sh_type = show_ipv6_all; | |
15317 | afi = AFI_IP6; | |
15318 | } else { | |
15319 | sh_type = show_all; | |
15320 | } | |
15321 | ||
d62a17ae | 15322 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
15323 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
15324 | || argv_find(argv, argc, "WORD", &idx)) { | |
15325 | sh_type = show_peer; | |
15326 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
15327 | } |
15328 | ||
15329 | if (sh_type == show_peer && afi == AFI_IP) { | |
15330 | sh_type = show_ipv4_peer; | |
15331 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
15332 | sh_type = show_ipv6_peer; | |
15333 | } | |
856ca177 | 15334 | |
d62a17ae | 15335 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 15336 | } |
15337 | ||
716b2d8a | 15338 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 15339 | paths' and `show ip mbgp paths'. Those functions results are the |
15340 | same.*/ | |
f412b39a | 15341 | DEFUN (show_ip_bgp_paths, |
718e3744 | 15342 | show_ip_bgp_paths_cmd, |
46f296b4 | 15343 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 15344 | SHOW_STR |
15345 | IP_STR | |
15346 | BGP_STR | |
46f296b4 | 15347 | BGP_SAFI_HELP_STR |
718e3744 | 15348 | "Path information\n") |
15349 | { | |
d62a17ae | 15350 | vty_out(vty, "Address Refcnt Path\n"); |
15351 | aspath_print_all_vty(vty); | |
15352 | return CMD_SUCCESS; | |
718e3744 | 15353 | } |
15354 | ||
718e3744 | 15355 | #include "hash.h" |
15356 | ||
e3b78da8 | 15357 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15358 | struct vty *vty) |
718e3744 | 15359 | { |
d62a17ae | 15360 | struct community *com; |
718e3744 | 15361 | |
e3b78da8 | 15362 | com = (struct community *)bucket->data; |
3f65c5b1 | 15363 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
c0945b78 | 15364 | community_str(com, false, false)); |
718e3744 | 15365 | } |
15366 | ||
15367 | /* Show BGP's community internal data. */ | |
f412b39a | 15368 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 15369 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 15370 | "show [ip] bgp community-info", |
718e3744 | 15371 | SHOW_STR |
15372 | IP_STR | |
15373 | BGP_STR | |
15374 | "List all bgp community information\n") | |
15375 | { | |
d62a17ae | 15376 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 15377 | |
d62a17ae | 15378 | hash_iterate(community_hash(), |
e3b78da8 | 15379 | (void (*)(struct hash_bucket *, |
d62a17ae | 15380 | void *))community_show_all_iterator, |
15381 | vty); | |
718e3744 | 15382 | |
d62a17ae | 15383 | return CMD_SUCCESS; |
718e3744 | 15384 | } |
15385 | ||
e3b78da8 | 15386 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 15387 | struct vty *vty) |
57d187bc | 15388 | { |
d62a17ae | 15389 | struct lcommunity *lcom; |
57d187bc | 15390 | |
e3b78da8 | 15391 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 15392 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
c0945b78 | 15393 | lcommunity_str(lcom, false, false)); |
57d187bc JS |
15394 | } |
15395 | ||
15396 | /* Show BGP's community internal data. */ | |
15397 | DEFUN (show_ip_bgp_lcommunity_info, | |
15398 | show_ip_bgp_lcommunity_info_cmd, | |
15399 | "show ip bgp large-community-info", | |
15400 | SHOW_STR | |
15401 | IP_STR | |
15402 | BGP_STR | |
15403 | "List all bgp large-community information\n") | |
15404 | { | |
d62a17ae | 15405 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 15406 | |
d62a17ae | 15407 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 15408 | (void (*)(struct hash_bucket *, |
d62a17ae | 15409 | void *))lcommunity_show_all_iterator, |
15410 | vty); | |
57d187bc | 15411 | |
d62a17ae | 15412 | return CMD_SUCCESS; |
57d187bc | 15413 | } |
2986cac2 | 15414 | /* Graceful Restart */ |
15415 | ||
15416 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
403e64f8 | 15417 | struct bgp *bgp) |
2986cac2 | 15418 | { |
57d187bc JS |
15419 | |
15420 | ||
2986cac2 | 15421 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
15422 | ||
7318ae88 | 15423 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 15424 | |
15425 | switch (bgp_global_gr_mode) { | |
15426 | ||
15427 | case GLOBAL_HELPER: | |
13909c4f | 15428 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 15429 | break; |
15430 | ||
15431 | case GLOBAL_GR: | |
13909c4f | 15432 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 15433 | break; |
15434 | ||
15435 | case GLOBAL_DISABLE: | |
13909c4f | 15436 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 15437 | break; |
15438 | ||
15439 | case GLOBAL_INVALID: | |
2986cac2 | 15440 | vty_out(vty, |
2ba1fe69 | 15441 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 15442 | break; |
15443 | } | |
15444 | vty_out(vty, "\n"); | |
15445 | } | |
15446 | ||
36235319 QY |
15447 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
15448 | enum show_type type, | |
15449 | const char *ip_str, | |
15450 | afi_t afi, bool use_json) | |
2986cac2 | 15451 | { |
403e64f8 DA |
15452 | json_object *json = NULL; |
15453 | ||
15454 | if (use_json) | |
15455 | json = json_object_new_object(); | |
15456 | ||
2986cac2 | 15457 | if ((afi == AFI_MAX) && (ip_str == NULL)) { |
15458 | afi = AFI_IP; | |
15459 | ||
15460 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
15461 | ||
36235319 | 15462 | bgp_show_neighbor_graceful_restart_vty( |
403e64f8 | 15463 | vty, type, ip_str, afi, json); |
2986cac2 | 15464 | afi++; |
15465 | } | |
15466 | } else if (afi != AFI_MAX) { | |
36235319 | 15467 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
403e64f8 | 15468 | json); |
2986cac2 | 15469 | } else { |
403e64f8 DA |
15470 | if (json) |
15471 | json_object_free(json); | |
2986cac2 | 15472 | return CMD_ERR_INCOMPLETE; |
15473 | } | |
15474 | ||
403e64f8 DA |
15475 | if (json) |
15476 | vty_json(vty, json); | |
15477 | ||
2986cac2 | 15478 | return CMD_SUCCESS; |
15479 | } | |
15480 | /* Graceful Restart */ | |
15481 | ||
f412b39a | 15482 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 15483 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 15484 | "show [ip] bgp attribute-info", |
718e3744 | 15485 | SHOW_STR |
15486 | IP_STR | |
15487 | BGP_STR | |
15488 | "List all bgp attribute information\n") | |
15489 | { | |
d62a17ae | 15490 | attr_show_all(vty); |
15491 | return CMD_SUCCESS; | |
718e3744 | 15492 | } |
6b0655a2 | 15493 | |
03915806 CS |
15494 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
15495 | afi_t afi, safi_t safi, | |
15496 | bool use_json, json_object *json) | |
53089bec | 15497 | { |
15498 | struct bgp *bgp; | |
15499 | struct listnode *node; | |
15500 | char *vname; | |
53089bec | 15501 | char *ecom_str; |
9c2fd3fe | 15502 | enum vpn_policy_direction dir; |
53089bec | 15503 | |
03915806 | 15504 | if (json) { |
b46dfd20 DS |
15505 | json_object *json_import_vrfs = NULL; |
15506 | json_object *json_export_vrfs = NULL; | |
15507 | ||
b46dfd20 DS |
15508 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15509 | ||
53089bec | 15510 | if (!bgp) { |
75eeda93 | 15511 | vty_json(vty, json); |
b46dfd20 | 15512 | |
53089bec | 15513 | return CMD_WARNING; |
15514 | } | |
b46dfd20 | 15515 | |
94d4c685 DS |
15516 | /* Provide context for the block */ |
15517 | json_object_string_add(json, "vrf", name ? name : "default"); | |
15518 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 15519 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 15520 | |
b46dfd20 DS |
15521 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15522 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15523 | json_object_string_add(json, "importFromVrfs", "none"); | |
15524 | json_object_string_add(json, "importRts", "none"); | |
15525 | } else { | |
6ce24e52 DS |
15526 | json_import_vrfs = json_object_new_array(); |
15527 | ||
b46dfd20 DS |
15528 | for (ALL_LIST_ELEMENTS_RO( |
15529 | bgp->vpn_policy[afi].import_vrf, | |
15530 | node, vname)) | |
15531 | json_object_array_add(json_import_vrfs, | |
15532 | json_object_new_string(vname)); | |
15533 | ||
b20875ea CS |
15534 | json_object_object_add(json, "importFromVrfs", |
15535 | json_import_vrfs); | |
b46dfd20 | 15536 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
15537 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15538 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15539 | bgp->vpn_policy[afi].rtlist[dir], |
15540 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15541 | json_object_string_add(json, "importRts", |
15542 | ecom_str); | |
15543 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15544 | } else | |
15545 | json_object_string_add(json, "importRts", | |
15546 | "none"); | |
b46dfd20 DS |
15547 | } |
15548 | ||
15549 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
15550 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
15551 | json_object_string_add(json, "exportToVrfs", "none"); | |
15552 | json_object_string_add(json, "routeDistinguisher", | |
15553 | "none"); | |
15554 | json_object_string_add(json, "exportRts", "none"); | |
15555 | } else { | |
6ce24e52 DS |
15556 | json_export_vrfs = json_object_new_array(); |
15557 | ||
b46dfd20 DS |
15558 | for (ALL_LIST_ELEMENTS_RO( |
15559 | bgp->vpn_policy[afi].export_vrf, | |
15560 | node, vname)) | |
15561 | json_object_array_add(json_export_vrfs, | |
15562 | json_object_new_string(vname)); | |
15563 | json_object_object_add(json, "exportToVrfs", | |
15564 | json_export_vrfs); | |
c4f64ea9 DA |
15565 | json_object_string_addf(json, "routeDistinguisher", |
15566 | "%pRD", | |
15567 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15568 | |
15569 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15570 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15571 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15572 | bgp->vpn_policy[afi].rtlist[dir], |
15573 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15574 | json_object_string_add(json, "exportRts", |
15575 | ecom_str); | |
15576 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15577 | } else | |
15578 | json_object_string_add(json, "exportRts", | |
15579 | "none"); | |
b46dfd20 DS |
15580 | } |
15581 | ||
03915806 | 15582 | if (use_json) { |
75eeda93 | 15583 | vty_json(vty, json); |
03915806 | 15584 | } |
53089bec | 15585 | } else { |
b46dfd20 DS |
15586 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
15587 | ||
53089bec | 15588 | if (!bgp) { |
b46dfd20 | 15589 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 15590 | return CMD_WARNING; |
15591 | } | |
53089bec | 15592 | |
b46dfd20 DS |
15593 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15594 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
15595 | vty_out(vty, | |
15596 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 15597 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15598 | else { |
15599 | vty_out(vty, | |
15600 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 15601 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15602 | |
15603 | for (ALL_LIST_ELEMENTS_RO( | |
15604 | bgp->vpn_policy[afi].import_vrf, | |
15605 | node, vname)) | |
15606 | vty_out(vty, " %s\n", vname); | |
15607 | ||
15608 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
15609 | ecom_str = NULL; |
15610 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
15611 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15612 | bgp->vpn_policy[afi].rtlist[dir], |
15613 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 15614 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 15615 | |
b20875ea CS |
15616 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
15617 | } else | |
15618 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15619 | } |
53089bec | 15620 | |
b46dfd20 DS |
15621 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
15622 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15623 | vty_out(vty, | |
15624 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 15625 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15626 | else { |
15627 | vty_out(vty, | |
04c9077f | 15628 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 15629 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
15630 | |
15631 | for (ALL_LIST_ELEMENTS_RO( | |
15632 | bgp->vpn_policy[afi].export_vrf, | |
15633 | node, vname)) | |
15634 | vty_out(vty, " %s\n", vname); | |
15635 | ||
c4f64ea9 DA |
15636 | vty_out(vty, "RD: %pRD\n", |
15637 | &bgp->vpn_policy[afi].tovpn_rd); | |
b46dfd20 DS |
15638 | |
15639 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
15640 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
15641 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
15642 | bgp->vpn_policy[afi].rtlist[dir], |
15643 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
15644 | vty_out(vty, "Export RT: %s\n", ecom_str); |
15645 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
15646 | } else | |
15647 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 15648 | } |
53089bec | 15649 | } |
15650 | ||
15651 | return CMD_SUCCESS; | |
15652 | } | |
15653 | ||
03915806 CS |
15654 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
15655 | safi_t safi, bool use_json) | |
15656 | { | |
15657 | struct listnode *node, *nnode; | |
15658 | struct bgp *bgp; | |
15659 | char *vrf_name = NULL; | |
15660 | json_object *json = NULL; | |
15661 | json_object *json_vrf = NULL; | |
15662 | json_object *json_vrfs = NULL; | |
15663 | ||
15664 | if (use_json) { | |
15665 | json = json_object_new_object(); | |
15666 | json_vrfs = json_object_new_object(); | |
15667 | } | |
15668 | ||
15669 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
15670 | ||
15671 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
15672 | vrf_name = bgp->name; | |
15673 | ||
15674 | if (use_json) { | |
15675 | json_vrf = json_object_new_object(); | |
15676 | } else { | |
15677 | vty_out(vty, "\nInstance %s:\n", | |
15678 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15679 | ? VRF_DEFAULT_NAME : bgp->name); | |
15680 | } | |
15681 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
15682 | if (use_json) { | |
15683 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15684 | json_object_object_add(json_vrfs, | |
15685 | VRF_DEFAULT_NAME, json_vrf); | |
15686 | else | |
15687 | json_object_object_add(json_vrfs, vrf_name, | |
15688 | json_vrf); | |
15689 | } | |
15690 | } | |
15691 | ||
15692 | if (use_json) { | |
15693 | json_object_object_add(json, "vrfs", json_vrfs); | |
75eeda93 | 15694 | vty_json(vty, json); |
03915806 CS |
15695 | } |
15696 | ||
15697 | return CMD_SUCCESS; | |
15698 | } | |
15699 | ||
53089bec | 15700 | /* "show [ip] bgp route-leak" command. */ |
15701 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
15702 | show_ip_bgp_route_leak_cmd, |
15703 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
15704 | SHOW_STR |
15705 | IP_STR | |
15706 | BGP_STR | |
15707 | BGP_INSTANCE_HELP_STR | |
15708 | BGP_AFI_HELP_STR | |
15709 | BGP_SAFI_HELP_STR | |
15710 | "Route leaking information\n" | |
15711 | JSON_STR) | |
53089bec | 15712 | { |
15713 | char *vrf = NULL; | |
15714 | afi_t afi = AFI_MAX; | |
15715 | safi_t safi = SAFI_MAX; | |
15716 | ||
9f049418 | 15717 | bool uj = use_json(argc, argv); |
53089bec | 15718 | int idx = 0; |
03915806 | 15719 | json_object *json = NULL; |
53089bec | 15720 | |
15721 | /* show [ip] bgp */ | |
15722 | if (argv_find(argv, argc, "ip", &idx)) { | |
15723 | afi = AFI_IP; | |
15724 | safi = SAFI_UNICAST; | |
15725 | } | |
15726 | /* [vrf VIEWVRFNAME] */ | |
15727 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
15728 | vty_out(vty, |
15729 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 15730 | return CMD_WARNING; |
15731 | } | |
15732 | ||
9a8bdf1c PG |
15733 | if (argv_find(argv, argc, "vrf", &idx)) { |
15734 | vrf = argv[idx + 1]->arg; | |
15735 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15736 | vrf = NULL; | |
15737 | } | |
53089bec | 15738 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
c48349e3 | 15739 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
53089bec | 15740 | argv_find_and_parse_safi(argv, argc, &idx, &safi); |
53089bec | 15741 | |
15742 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
15743 | vty_out(vty, |
15744 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 15745 | return CMD_WARNING; |
15746 | } | |
15747 | ||
03915806 CS |
15748 | if (vrf && strmatch(vrf, "all")) |
15749 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
15750 | ||
15751 | if (uj) | |
15752 | json = json_object_new_object(); | |
15753 | ||
15754 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 15755 | } |
15756 | ||
d62a17ae | 15757 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
fa5a9276 | 15758 | safi_t safi, bool uj) |
f186de26 | 15759 | { |
d62a17ae | 15760 | struct listnode *node, *nnode; |
15761 | struct bgp *bgp; | |
f186de26 | 15762 | |
d62a17ae | 15763 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
fa5a9276 AR |
15764 | if (!uj) |
15765 | vty_out(vty, "\nInstance %s:\n", | |
15766 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
15767 | ? VRF_DEFAULT_NAME | |
15768 | : bgp->name); | |
15769 | ||
15770 | update_group_show(bgp, afi, safi, vty, 0, uj); | |
d62a17ae | 15771 | } |
f186de26 | 15772 | } |
15773 | ||
d62a17ae | 15774 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
fa5a9276 | 15775 | int safi, uint64_t subgrp_id, bool uj) |
4fb25c53 | 15776 | { |
d62a17ae | 15777 | struct bgp *bgp; |
4fb25c53 | 15778 | |
d62a17ae | 15779 | if (name) { |
15780 | if (strmatch(name, "all")) { | |
fa5a9276 | 15781 | bgp_show_all_instances_updgrps_vty(vty, afi, safi, uj); |
d62a17ae | 15782 | return CMD_SUCCESS; |
15783 | } else { | |
15784 | bgp = bgp_lookup_by_name(name); | |
15785 | } | |
15786 | } else { | |
15787 | bgp = bgp_get_default(); | |
15788 | } | |
4fb25c53 | 15789 | |
d62a17ae | 15790 | if (bgp) |
fa5a9276 | 15791 | update_group_show(bgp, afi, safi, vty, subgrp_id, uj); |
d62a17ae | 15792 | return CMD_SUCCESS; |
4fb25c53 DW |
15793 | } |
15794 | ||
8fe8a7f6 DS |
15795 | DEFUN (show_ip_bgp_updgrps, |
15796 | show_ip_bgp_updgrps_cmd, | |
fa5a9276 | 15797 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID] [json]", |
8386ac43 | 15798 | SHOW_STR |
15799 | IP_STR | |
15800 | BGP_STR | |
15801 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15802 | BGP_AFI_HELP_STR |
9bedbb1e | 15803 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 | 15804 | "Detailed info about dynamic update groups\n" |
fa5a9276 AR |
15805 | "Specific subgroup to display detailed info for\n" |
15806 | JSON_STR) | |
8386ac43 | 15807 | { |
d62a17ae | 15808 | char *vrf = NULL; |
15809 | afi_t afi = AFI_IP6; | |
15810 | safi_t safi = SAFI_UNICAST; | |
15811 | uint64_t subgrp_id = 0; | |
15812 | ||
15813 | int idx = 0; | |
15814 | ||
fa5a9276 AR |
15815 | bool uj = use_json(argc, argv); |
15816 | ||
d62a17ae | 15817 | /* show [ip] bgp */ |
15818 | if (argv_find(argv, argc, "ip", &idx)) | |
15819 | afi = AFI_IP; | |
9a8bdf1c PG |
15820 | /* [<vrf> VIEWVRFNAME] */ |
15821 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15822 | vrf = argv[idx + 1]->arg; | |
15823 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15824 | vrf = NULL; | |
15825 | } else if (argv_find(argv, argc, "view", &idx)) | |
15826 | /* [<view> VIEWVRFNAME] */ | |
15827 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15828 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15829 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15830 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15831 | } | |
5bf15956 | 15832 | |
d62a17ae | 15833 | /* get subgroup id, if provided */ |
15834 | idx = argc - 1; | |
15835 | if (argv[idx]->type == VARIABLE_TKN) | |
15836 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15837 | |
fa5a9276 | 15838 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id, uj)); |
8fe8a7f6 DS |
15839 | } |
15840 | ||
f186de26 | 15841 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15842 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
fa5a9276 | 15843 | "show [ip] bgp <view|vrf> all update-groups [json]", |
f186de26 | 15844 | SHOW_STR |
716b2d8a | 15845 | IP_STR |
f186de26 | 15846 | BGP_STR |
15847 | BGP_INSTANCE_ALL_HELP_STR | |
fa5a9276 AR |
15848 | "Detailed info about dynamic update groups\n" |
15849 | JSON_STR) | |
f186de26 | 15850 | { |
fa5a9276 AR |
15851 | bool uj = use_json(argc, argv); |
15852 | ||
15853 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST, uj); | |
d62a17ae | 15854 | return CMD_SUCCESS; |
f186de26 | 15855 | } |
15856 | ||
43d3f4fc DS |
15857 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15858 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15859 | "show [ip] bgp l2vpn evpn update-groups", | |
15860 | SHOW_STR | |
15861 | IP_STR | |
15862 | BGP_STR | |
15863 | "l2vpn address family\n" | |
15864 | "evpn sub-address family\n" | |
15865 | "Detailed info about dynamic update groups\n") | |
15866 | { | |
15867 | char *vrf = NULL; | |
15868 | uint64_t subgrp_id = 0; | |
15869 | ||
fa5a9276 | 15870 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id, 0); |
43d3f4fc DS |
15871 | return CMD_SUCCESS; |
15872 | } | |
15873 | ||
5bf15956 DW |
15874 | DEFUN (show_bgp_updgrps_stats, |
15875 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15876 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15877 | SHOW_STR |
716b2d8a | 15878 | IP_STR |
3f9c7369 | 15879 | BGP_STR |
0c7b1b01 | 15880 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15881 | "Statistics\n") |
15882 | { | |
d62a17ae | 15883 | struct bgp *bgp; |
3f9c7369 | 15884 | |
d62a17ae | 15885 | bgp = bgp_get_default(); |
15886 | if (bgp) | |
15887 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15888 | |
d62a17ae | 15889 | return CMD_SUCCESS; |
3f9c7369 DS |
15890 | } |
15891 | ||
8386ac43 | 15892 | DEFUN (show_bgp_instance_updgrps_stats, |
15893 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15894 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15895 | SHOW_STR |
716b2d8a | 15896 | IP_STR |
8386ac43 | 15897 | BGP_STR |
15898 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15899 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15900 | "Statistics\n") |
15901 | { | |
d62a17ae | 15902 | int idx_word = 3; |
15903 | struct bgp *bgp; | |
8386ac43 | 15904 | |
d62a17ae | 15905 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15906 | if (bgp) | |
15907 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15908 | |
d62a17ae | 15909 | return CMD_SUCCESS; |
8386ac43 | 15910 | } |
15911 | ||
d62a17ae | 15912 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15913 | afi_t afi, safi_t safi, | |
15914 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15915 | { |
d62a17ae | 15916 | struct bgp *bgp; |
8386ac43 | 15917 | |
d62a17ae | 15918 | if (name) |
15919 | bgp = bgp_lookup_by_name(name); | |
15920 | else | |
15921 | bgp = bgp_get_default(); | |
8386ac43 | 15922 | |
d62a17ae | 15923 | if (bgp) { |
15924 | if (!strcmp(what, "advertise-queue")) | |
15925 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15926 | subgrp_id); | |
15927 | else if (!strcmp(what, "advertised-routes")) | |
15928 | update_group_show_advertised(bgp, afi, safi, vty, | |
15929 | subgrp_id); | |
15930 | else if (!strcmp(what, "packet-queue")) | |
15931 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15932 | subgrp_id); | |
15933 | } | |
3f9c7369 DS |
15934 | } |
15935 | ||
dc64bdec QY |
15936 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15937 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15938 | "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", | |
15939 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15940 | BGP_SAFI_HELP_STR | |
15941 | "Detailed info about dynamic update groups\n" | |
15942 | "Specific subgroup to display info for\n" | |
15943 | "Advertisement queue\n" | |
15944 | "Announced routes\n" | |
15945 | "Packet queue\n") | |
3f9c7369 | 15946 | { |
dc64bdec QY |
15947 | uint64_t subgrp_id = 0; |
15948 | afi_t afiz; | |
15949 | safi_t safiz; | |
15950 | if (sgid) | |
15951 | subgrp_id = strtoull(sgid, NULL, 10); | |
15952 | ||
15953 | if (!ip && !afi) | |
15954 | afiz = AFI_IP6; | |
15955 | if (!ip && afi) | |
15956 | afiz = bgp_vty_afi_from_str(afi); | |
15957 | if (ip && !afi) | |
15958 | afiz = AFI_IP; | |
15959 | if (ip && afi) { | |
15960 | afiz = bgp_vty_afi_from_str(afi); | |
15961 | if (afiz != AFI_IP) | |
15962 | vty_out(vty, | |
15963 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15964 | return CMD_WARNING; | |
15965 | } | |
d62a17ae | 15966 | |
dc64bdec | 15967 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15968 | |
dc64bdec | 15969 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15970 | return CMD_SUCCESS; |
15971 | } | |
15972 | ||
6f4eacf3 DA |
15973 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15974 | json_object *json) | |
d62a17ae | 15975 | { |
15976 | struct listnode *node, *nnode; | |
15977 | struct prefix *range; | |
15978 | struct peer *conf; | |
15979 | struct peer *peer; | |
d62a17ae | 15980 | afi_t afi; |
15981 | safi_t safi; | |
15982 | const char *peer_status; | |
d62a17ae | 15983 | int lr_count; |
15984 | int dynamic; | |
6f4eacf3 DA |
15985 | bool af_cfgd; |
15986 | json_object *json_peer_group = NULL; | |
15987 | json_object *json_peer_group_afc = NULL; | |
15988 | json_object *json_peer_group_members = NULL; | |
15989 | json_object *json_peer_group_dynamic = NULL; | |
15990 | json_object *json_peer_group_dynamic_af = NULL; | |
15991 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15992 | |
15993 | conf = group->conf; | |
15994 | ||
6f4eacf3 DA |
15995 | if (json) { |
15996 | json_peer_group = json_object_new_object(); | |
15997 | json_peer_group_afc = json_object_new_array(); | |
15998 | } | |
15999 | ||
d62a17ae | 16000 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
16001 | if (json) |
16002 | json_object_int_add(json_peer_group, "remoteAs", | |
16003 | conf->as); | |
16004 | else | |
16005 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
16006 | group->name, conf->as); | |
d62a17ae | 16007 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 | 16008 | if (json) |
e84c7c12 PG |
16009 | asn_asn2json(json, "remoteAs", group->bgp->as, |
16010 | group->bgp->asnotation); | |
6f4eacf3 | 16011 | else |
9eb11997 PG |
16012 | vty_out(vty, "\nBGP peer-group %s, remote AS %s\n", |
16013 | group->name, group->bgp->as_pretty); | |
d62a17ae | 16014 | } else { |
6f4eacf3 DA |
16015 | if (!json) |
16016 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 16017 | } |
f14e6fdb | 16018 | |
6f4eacf3 DA |
16019 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
16020 | if (json) | |
16021 | json_object_string_add(json_peer_group, "type", | |
16022 | "internal"); | |
16023 | else | |
16024 | vty_out(vty, " Peer-group type is internal\n"); | |
16025 | } else { | |
16026 | if (json) | |
16027 | json_object_string_add(json_peer_group, "type", | |
16028 | "external"); | |
16029 | else | |
16030 | vty_out(vty, " Peer-group type is external\n"); | |
16031 | } | |
d62a17ae | 16032 | |
16033 | /* Display AFs configured. */ | |
6f4eacf3 DA |
16034 | if (!json) |
16035 | vty_out(vty, " Configured address-families:"); | |
16036 | ||
05c7a1cc QY |
16037 | FOREACH_AFI_SAFI (afi, safi) { |
16038 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
16039 | af_cfgd = true; |
16040 | if (json) | |
16041 | json_object_array_add( | |
16042 | json_peer_group_afc, | |
16043 | json_object_new_string(get_afi_safi_str( | |
16044 | afi, safi, false))); | |
16045 | else | |
16046 | vty_out(vty, " %s;", | |
16047 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 16048 | } |
05c7a1cc | 16049 | } |
6f4eacf3 DA |
16050 | |
16051 | if (json) { | |
16052 | json_object_object_add(json_peer_group, | |
16053 | "addressFamiliesConfigured", | |
16054 | json_peer_group_afc); | |
16055 | } else { | |
16056 | if (!af_cfgd) | |
16057 | vty_out(vty, " none\n"); | |
16058 | else | |
16059 | vty_out(vty, "\n"); | |
16060 | } | |
d62a17ae | 16061 | |
16062 | /* Display listen ranges (for dynamic neighbors), if any */ | |
16063 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 16064 | lr_count = listcount(group->listen_range[afi]); |
16065 | if (lr_count) { | |
6f4eacf3 DA |
16066 | if (json) { |
16067 | if (!json_peer_group_dynamic) | |
16068 | json_peer_group_dynamic = | |
16069 | json_object_new_object(); | |
16070 | ||
16071 | json_peer_group_dynamic_af = | |
16072 | json_object_new_object(); | |
16073 | json_peer_group_ranges = | |
16074 | json_object_new_array(); | |
16075 | json_object_int_add(json_peer_group_dynamic_af, | |
16076 | "count", lr_count); | |
16077 | } else { | |
16078 | vty_out(vty, " %d %s listen range(s)\n", | |
16079 | lr_count, afi2str(afi)); | |
16080 | } | |
d62a17ae | 16081 | |
16082 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
16083 | nnode, range)) { |
16084 | if (json) { | |
16085 | char buf[BUFSIZ]; | |
16086 | ||
16087 | snprintfrr(buf, sizeof(buf), "%pFX", | |
16088 | range); | |
16089 | ||
16090 | json_object_array_add( | |
16091 | json_peer_group_ranges, | |
16092 | json_object_new_string(buf)); | |
16093 | } else { | |
16094 | vty_out(vty, " %pFX\n", range); | |
16095 | } | |
16096 | } | |
16097 | ||
16098 | if (json) { | |
16099 | json_object_object_add( | |
16100 | json_peer_group_dynamic_af, "ranges", | |
16101 | json_peer_group_ranges); | |
16102 | ||
16103 | json_object_object_add( | |
16104 | json_peer_group_dynamic, afi2str(afi), | |
16105 | json_peer_group_dynamic_af); | |
16106 | } | |
d62a17ae | 16107 | } |
16108 | } | |
f14e6fdb | 16109 | |
6f4eacf3 DA |
16110 | if (json_peer_group_dynamic) |
16111 | json_object_object_add(json_peer_group, "dynamicRanges", | |
16112 | json_peer_group_dynamic); | |
16113 | ||
d62a17ae | 16114 | /* Display group members and their status */ |
16115 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
16116 | if (json) |
16117 | json_peer_group_members = json_object_new_object(); | |
16118 | else | |
16119 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 16120 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
16121 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
16122 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 16123 | peer_status = "Idle (Admin)"; |
16124 | else if (CHECK_FLAG(peer->sflags, | |
16125 | PEER_STATUS_PREFIX_OVERFLOW)) | |
16126 | peer_status = "Idle (PfxCt)"; | |
16127 | else | |
16128 | peer_status = lookup_msg(bgp_status_msg, | |
16129 | peer->status, NULL); | |
16130 | ||
16131 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
16132 | |
16133 | if (json) { | |
16134 | json_object *json_peer_group_member = | |
16135 | json_object_new_object(); | |
16136 | ||
16137 | json_object_string_add(json_peer_group_member, | |
16138 | "status", peer_status); | |
16139 | ||
16140 | if (dynamic) | |
16141 | json_object_boolean_true_add( | |
16142 | json_peer_group_member, | |
16143 | "dynamic"); | |
16144 | ||
16145 | json_object_object_add(json_peer_group_members, | |
16146 | peer->host, | |
16147 | json_peer_group_member); | |
16148 | } else { | |
16149 | vty_out(vty, " %s %s %s \n", peer->host, | |
16150 | dynamic ? "(dynamic)" : "", | |
16151 | peer_status); | |
16152 | } | |
d62a17ae | 16153 | } |
6f4eacf3 DA |
16154 | if (json) |
16155 | json_object_object_add(json_peer_group, "members", | |
16156 | json_peer_group_members); | |
d62a17ae | 16157 | } |
f14e6fdb | 16158 | |
6f4eacf3 DA |
16159 | if (json) |
16160 | json_object_object_add(json, group->name, json_peer_group); | |
16161 | ||
d62a17ae | 16162 | return CMD_SUCCESS; |
16163 | } | |
16164 | ||
ff9959b0 | 16165 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 16166 | const char *group_name, bool uj) |
d62a17ae | 16167 | { |
ff9959b0 | 16168 | struct bgp *bgp; |
d62a17ae | 16169 | struct listnode *node, *nnode; |
16170 | struct peer_group *group; | |
ff9959b0 | 16171 | bool found = false; |
6f4eacf3 DA |
16172 | json_object *json = NULL; |
16173 | ||
16174 | if (uj) | |
16175 | json = json_object_new_object(); | |
ff9959b0 QY |
16176 | |
16177 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
16178 | ||
16179 | if (!bgp) { | |
c48349e3 | 16180 | if (uj) |
75eeda93 | 16181 | vty_json(vty, json); |
c48349e3 | 16182 | else |
6f4eacf3 | 16183 | vty_out(vty, "%% BGP instance not found\n"); |
6f4eacf3 | 16184 | |
ff9959b0 QY |
16185 | return CMD_WARNING; |
16186 | } | |
d62a17ae | 16187 | |
16188 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
16189 | if (group_name) { |
16190 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 16191 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
16192 | found = true; |
16193 | break; | |
d62a17ae | 16194 | } |
ff9959b0 | 16195 | } else { |
6f4eacf3 | 16196 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 16197 | } |
f14e6fdb | 16198 | } |
f14e6fdb | 16199 | |
6f4eacf3 | 16200 | if (group_name && !found && !uj) |
d62a17ae | 16201 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 16202 | |
c48349e3 | 16203 | if (uj) |
75eeda93 | 16204 | vty_json(vty, json); |
6f4eacf3 | 16205 | |
d62a17ae | 16206 | return CMD_SUCCESS; |
f14e6fdb DS |
16207 | } |
16208 | ||
6f4eacf3 DA |
16209 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
16210 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
16211 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
16212 | "Detailed information on BGP peer groups\n" | |
16213 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 16214 | { |
d62a17ae | 16215 | char *vrf, *pg; |
d62a17ae | 16216 | int idx = 0; |
6f4eacf3 | 16217 | bool uj = use_json(argc, argv); |
f14e6fdb | 16218 | |
a4d82a8a PZ |
16219 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
16220 | : NULL; | |
d62a17ae | 16221 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 16222 | |
6f4eacf3 | 16223 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 16224 | } |
3f9c7369 | 16225 | |
d6e3c605 | 16226 | |
718e3744 | 16227 | /* Redistribute VTY commands. */ |
16228 | ||
585f1adc IR |
16229 | DEFUN (bgp_redistribute_ipv4, |
16230 | bgp_redistribute_ipv4_cmd, | |
16231 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16232 | "Redistribute information from another routing protocol\n" | |
16233 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 16234 | { |
585f1adc | 16235 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16236 | int idx_protocol = 1; |
585f1adc | 16237 | int type; |
37a87b8f | 16238 | |
585f1adc IR |
16239 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
16240 | if (type < 0) { | |
16241 | vty_out(vty, "%% Invalid route type\n"); | |
16242 | return CMD_WARNING_CONFIG_FAILED; | |
16243 | } | |
7f323236 | 16244 | |
585f1adc IR |
16245 | bgp_redist_add(bgp, AFI_IP, type, 0); |
16246 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 16247 | } |
16248 | ||
d62a17ae | 16249 | ALIAS_HIDDEN( |
16250 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
16251 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
16252 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 16253 | |
585f1adc IR |
16254 | DEFUN (bgp_redistribute_ipv4_rmap, |
16255 | bgp_redistribute_ipv4_rmap_cmd, | |
70dd370f | 16256 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16257 | "Redistribute information from another routing protocol\n" |
16258 | FRR_IP_REDIST_HELP_STR_BGPD | |
16259 | "Route map reference\n" | |
16260 | "Pointer to route-map entries\n") | |
718e3744 | 16261 | { |
585f1adc | 16262 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16263 | int idx_protocol = 1; |
16264 | int idx_word = 3; | |
585f1adc IR |
16265 | int type; |
16266 | struct bgp_redist *red; | |
16267 | bool changed; | |
16268 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
16269 | vty, argv[idx_word]->arg); | |
16270 | ||
16271 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16272 | if (type < 0) { | |
16273 | vty_out(vty, "%% Invalid route type\n"); | |
16274 | return CMD_WARNING_CONFIG_FAILED; | |
16275 | } | |
37a87b8f | 16276 | |
585f1adc IR |
16277 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16278 | changed = | |
16279 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16280 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 16281 | } |
16282 | ||
d62a17ae | 16283 | ALIAS_HIDDEN( |
16284 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
70dd370f | 16285 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
d62a17ae | 16286 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16287 | "Route map reference\n" | |
16288 | "Pointer to route-map entries\n") | |
596c17ba | 16289 | |
585f1adc IR |
16290 | DEFUN (bgp_redistribute_ipv4_metric, |
16291 | bgp_redistribute_ipv4_metric_cmd, | |
16292 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16293 | "Redistribute information from another routing protocol\n" | |
16294 | FRR_IP_REDIST_HELP_STR_BGPD | |
16295 | "Metric for redistributed routes\n" | |
16296 | "Default metric\n") | |
718e3744 | 16297 | { |
585f1adc | 16298 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16299 | int idx_protocol = 1; |
16300 | int idx_number = 3; | |
585f1adc IR |
16301 | int type; |
16302 | uint32_t metric; | |
16303 | struct bgp_redist *red; | |
16304 | bool changed; | |
16305 | ||
16306 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16307 | if (type < 0) { | |
16308 | vty_out(vty, "%% Invalid route type\n"); | |
16309 | return CMD_WARNING_CONFIG_FAILED; | |
16310 | } | |
16311 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16312 | |
585f1adc IR |
16313 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16314 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16315 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16316 | } |
16317 | ||
16318 | ALIAS_HIDDEN( | |
16319 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
16320 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
16321 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16322 | "Metric for redistributed routes\n" | |
16323 | "Default metric\n") | |
596c17ba | 16324 | |
585f1adc IR |
16325 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
16326 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
70dd370f | 16327 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16328 | "Redistribute information from another routing protocol\n" |
16329 | FRR_IP_REDIST_HELP_STR_BGPD | |
16330 | "Route map reference\n" | |
16331 | "Pointer to route-map entries\n" | |
16332 | "Metric for redistributed routes\n" | |
16333 | "Default metric\n") | |
718e3744 | 16334 | { |
585f1adc | 16335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16336 | int idx_protocol = 1; |
16337 | int idx_word = 3; | |
16338 | int idx_number = 5; | |
585f1adc IR |
16339 | int type; |
16340 | uint32_t metric; | |
16341 | struct bgp_redist *red; | |
16342 | bool changed; | |
16343 | struct route_map *route_map = | |
16344 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16345 | ||
16346 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16347 | if (type < 0) { | |
16348 | vty_out(vty, "%% Invalid route type\n"); | |
16349 | return CMD_WARNING_CONFIG_FAILED; | |
16350 | } | |
16351 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16352 | |
585f1adc IR |
16353 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16354 | changed = | |
16355 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16356 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16357 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16358 | } |
16359 | ||
16360 | ALIAS_HIDDEN( | |
16361 | bgp_redistribute_ipv4_rmap_metric, | |
16362 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
16363 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16364 | " route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16365 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16366 | "Route map reference\n" | |
16367 | "Pointer to route-map entries\n" | |
16368 | "Metric for redistributed routes\n" | |
16369 | "Default metric\n") | |
596c17ba | 16370 | |
585f1adc IR |
16371 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
16372 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
70dd370f | 16373 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16374 | "Redistribute information from another routing protocol\n" |
16375 | FRR_IP_REDIST_HELP_STR_BGPD | |
16376 | "Metric for redistributed routes\n" | |
16377 | "Default metric\n" | |
16378 | "Route map reference\n" | |
16379 | "Pointer to route-map entries\n") | |
718e3744 | 16380 | { |
585f1adc | 16381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16382 | int idx_protocol = 1; |
37a87b8f | 16383 | int idx_number = 3; |
585f1adc IR |
16384 | int idx_word = 5; |
16385 | int type; | |
16386 | uint32_t metric; | |
16387 | struct bgp_redist *red; | |
16388 | bool changed; | |
16389 | struct route_map *route_map = | |
16390 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16391 | ||
16392 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
16393 | if (type < 0) { | |
16394 | vty_out(vty, "%% Invalid route type\n"); | |
16395 | return CMD_WARNING_CONFIG_FAILED; | |
16396 | } | |
16397 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 16398 | |
585f1adc IR |
16399 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
16400 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
16401 | changed |= | |
16402 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16403 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 16404 | } |
16405 | ||
16406 | ALIAS_HIDDEN( | |
16407 | bgp_redistribute_ipv4_metric_rmap, | |
16408 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
16409 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16410 | " metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16411 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
16412 | "Metric for redistributed routes\n" | |
16413 | "Default metric\n" | |
16414 | "Route map reference\n" | |
16415 | "Pointer to route-map entries\n") | |
596c17ba | 16416 | |
585f1adc IR |
16417 | DEFUN (bgp_redistribute_ipv4_ospf, |
16418 | bgp_redistribute_ipv4_ospf_cmd, | |
16419 | "redistribute <ospf|table> (1-65535)", | |
16420 | "Redistribute information from another routing protocol\n" | |
16421 | "Open Shortest Path First (OSPFv2)\n" | |
16422 | "Non-main Kernel Routing Table\n" | |
16423 | "Instance ID/Table ID\n") | |
7c8ff89e | 16424 | { |
585f1adc IR |
16425 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16426 | int idx_ospf_table = 1; | |
d62a17ae | 16427 | int idx_number = 2; |
585f1adc IR |
16428 | unsigned short instance; |
16429 | unsigned short protocol; | |
7c8ff89e | 16430 | |
585f1adc | 16431 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 16432 | |
585f1adc IR |
16433 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16434 | protocol = ZEBRA_ROUTE_OSPF; | |
16435 | else | |
16436 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 16437 | |
585f1adc IR |
16438 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16439 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
16440 | } |
16441 | ||
d62a17ae | 16442 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
16443 | "redistribute <ospf|table> (1-65535)", | |
16444 | "Redistribute information from another routing protocol\n" | |
16445 | "Open Shortest Path First (OSPFv2)\n" | |
16446 | "Non-main Kernel Routing Table\n" | |
16447 | "Instance ID/Table ID\n") | |
596c17ba | 16448 | |
585f1adc IR |
16449 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
16450 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
70dd370f | 16451 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
585f1adc IR |
16452 | "Redistribute information from another routing protocol\n" |
16453 | "Open Shortest Path First (OSPFv2)\n" | |
16454 | "Non-main Kernel Routing Table\n" | |
16455 | "Instance ID/Table ID\n" | |
16456 | "Route map reference\n" | |
16457 | "Pointer to route-map entries\n") | |
7c8ff89e | 16458 | { |
585f1adc IR |
16459 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16460 | int idx_ospf_table = 1; | |
d62a17ae | 16461 | int idx_number = 2; |
16462 | int idx_word = 4; | |
585f1adc IR |
16463 | struct bgp_redist *red; |
16464 | unsigned short instance; | |
16465 | int protocol; | |
16466 | bool changed; | |
16467 | struct route_map *route_map = | |
16468 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16469 | ||
16470 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16471 | protocol = ZEBRA_ROUTE_OSPF; | |
16472 | else | |
16473 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16474 | |
585f1adc IR |
16475 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16476 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
16477 | changed = | |
16478 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16479 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16480 | } |
16481 | ||
16482 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
16483 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
70dd370f | 16484 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
d62a17ae | 16485 | "Redistribute information from another routing protocol\n" |
16486 | "Open Shortest Path First (OSPFv2)\n" | |
16487 | "Non-main Kernel Routing Table\n" | |
16488 | "Instance ID/Table ID\n" | |
16489 | "Route map reference\n" | |
16490 | "Pointer to route-map entries\n") | |
596c17ba | 16491 | |
585f1adc IR |
16492 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
16493 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
16494 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16495 | "Redistribute information from another routing protocol\n" | |
16496 | "Open Shortest Path First (OSPFv2)\n" | |
16497 | "Non-main Kernel Routing Table\n" | |
16498 | "Instance ID/Table ID\n" | |
16499 | "Metric for redistributed routes\n" | |
16500 | "Default metric\n") | |
7c8ff89e | 16501 | { |
585f1adc IR |
16502 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16503 | int idx_ospf_table = 1; | |
d62a17ae | 16504 | int idx_number = 2; |
16505 | int idx_number_2 = 4; | |
585f1adc IR |
16506 | uint32_t metric; |
16507 | struct bgp_redist *red; | |
16508 | unsigned short instance; | |
16509 | int protocol; | |
16510 | bool changed; | |
16511 | ||
16512 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16513 | protocol = ZEBRA_ROUTE_OSPF; | |
16514 | else | |
16515 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16516 | |
585f1adc IR |
16517 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16518 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16519 | |
585f1adc IR |
16520 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16521 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16522 | metric); | |
16523 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16524 | } |
16525 | ||
16526 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
16527 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
16528 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
16529 | "Redistribute information from another routing protocol\n" | |
16530 | "Open Shortest Path First (OSPFv2)\n" | |
16531 | "Non-main Kernel Routing Table\n" | |
16532 | "Instance ID/Table ID\n" | |
16533 | "Metric for redistributed routes\n" | |
16534 | "Default metric\n") | |
596c17ba | 16535 | |
585f1adc IR |
16536 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
16537 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
70dd370f | 16538 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16539 | "Redistribute information from another routing protocol\n" |
16540 | "Open Shortest Path First (OSPFv2)\n" | |
16541 | "Non-main Kernel Routing Table\n" | |
16542 | "Instance ID/Table ID\n" | |
16543 | "Route map reference\n" | |
16544 | "Pointer to route-map entries\n" | |
16545 | "Metric for redistributed routes\n" | |
16546 | "Default metric\n") | |
7c8ff89e | 16547 | { |
585f1adc IR |
16548 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16549 | int idx_ospf_table = 1; | |
d62a17ae | 16550 | int idx_number = 2; |
16551 | int idx_word = 4; | |
16552 | int idx_number_2 = 6; | |
585f1adc IR |
16553 | uint32_t metric; |
16554 | struct bgp_redist *red; | |
16555 | unsigned short instance; | |
16556 | int protocol; | |
16557 | bool changed; | |
16558 | struct route_map *route_map = | |
16559 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16560 | ||
16561 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16562 | protocol = ZEBRA_ROUTE_OSPF; | |
16563 | else | |
16564 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16565 | |
585f1adc IR |
16566 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16567 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16568 | |
585f1adc IR |
16569 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16570 | changed = | |
16571 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16572 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16573 | metric); | |
16574 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16575 | } |
16576 | ||
16577 | ALIAS_HIDDEN( | |
16578 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
16579 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
70dd370f | 16580 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 16581 | "Redistribute information from another routing protocol\n" |
16582 | "Open Shortest Path First (OSPFv2)\n" | |
16583 | "Non-main Kernel Routing Table\n" | |
16584 | "Instance ID/Table ID\n" | |
16585 | "Route map reference\n" | |
16586 | "Pointer to route-map entries\n" | |
16587 | "Metric for redistributed routes\n" | |
16588 | "Default metric\n") | |
596c17ba | 16589 | |
585f1adc IR |
16590 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
16591 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
70dd370f | 16592 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16593 | "Redistribute information from another routing protocol\n" |
16594 | "Open Shortest Path First (OSPFv2)\n" | |
16595 | "Non-main Kernel Routing Table\n" | |
16596 | "Instance ID/Table ID\n" | |
16597 | "Metric for redistributed routes\n" | |
16598 | "Default metric\n" | |
16599 | "Route map reference\n" | |
16600 | "Pointer to route-map entries\n") | |
7c8ff89e | 16601 | { |
585f1adc IR |
16602 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16603 | int idx_ospf_table = 1; | |
d62a17ae | 16604 | int idx_number = 2; |
16605 | int idx_number_2 = 4; | |
16606 | int idx_word = 6; | |
585f1adc IR |
16607 | uint32_t metric; |
16608 | struct bgp_redist *red; | |
16609 | unsigned short instance; | |
16610 | int protocol; | |
16611 | bool changed; | |
16612 | struct route_map *route_map = | |
16613 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16614 | ||
16615 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
16616 | protocol = ZEBRA_ROUTE_OSPF; | |
16617 | else | |
16618 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16619 | |
585f1adc IR |
16620 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16621 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 16622 | |
585f1adc IR |
16623 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
16624 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
16625 | metric); | |
16626 | changed |= | |
16627 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16628 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 16629 | } |
16630 | ||
16631 | ALIAS_HIDDEN( | |
16632 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
16633 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
70dd370f | 16634 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 16635 | "Redistribute information from another routing protocol\n" |
16636 | "Open Shortest Path First (OSPFv2)\n" | |
16637 | "Non-main Kernel Routing Table\n" | |
16638 | "Instance ID/Table ID\n" | |
16639 | "Metric for redistributed routes\n" | |
16640 | "Default metric\n" | |
16641 | "Route map reference\n" | |
16642 | "Pointer to route-map entries\n") | |
596c17ba | 16643 | |
585f1adc IR |
16644 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
16645 | no_bgp_redistribute_ipv4_ospf_cmd, | |
70dd370f | 16646 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16647 | NO_STR |
16648 | "Redistribute information from another routing protocol\n" | |
16649 | "Open Shortest Path First (OSPFv2)\n" | |
16650 | "Non-main Kernel Routing Table\n" | |
16651 | "Instance ID/Table ID\n" | |
16652 | "Metric for redistributed routes\n" | |
16653 | "Default metric\n" | |
16654 | "Route map reference\n" | |
16655 | "Pointer to route-map entries\n") | |
7c8ff89e | 16656 | { |
585f1adc IR |
16657 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16658 | int idx_ospf_table = 2; | |
d62a17ae | 16659 | int idx_number = 3; |
585f1adc IR |
16660 | unsigned short instance; |
16661 | int protocol; | |
37a87b8f | 16662 | |
585f1adc IR |
16663 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
16664 | protocol = ZEBRA_ROUTE_OSPF; | |
16665 | else | |
16666 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 16667 | |
585f1adc IR |
16668 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
16669 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 16670 | } |
16671 | ||
16672 | ALIAS_HIDDEN( | |
16673 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
70dd370f | 16674 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16675 | NO_STR |
16676 | "Redistribute information from another routing protocol\n" | |
16677 | "Open Shortest Path First (OSPFv2)\n" | |
16678 | "Non-main Kernel Routing Table\n" | |
16679 | "Instance ID/Table ID\n" | |
16680 | "Metric for redistributed routes\n" | |
16681 | "Default metric\n" | |
16682 | "Route map reference\n" | |
16683 | "Pointer to route-map entries\n") | |
596c17ba | 16684 | |
585f1adc IR |
16685 | DEFUN (no_bgp_redistribute_ipv4, |
16686 | no_bgp_redistribute_ipv4_cmd, | |
70dd370f | 16687 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16688 | NO_STR |
16689 | "Redistribute information from another routing protocol\n" | |
16690 | FRR_IP_REDIST_HELP_STR_BGPD | |
16691 | "Metric for redistributed routes\n" | |
16692 | "Default metric\n" | |
16693 | "Route map reference\n" | |
16694 | "Pointer to route-map entries\n") | |
718e3744 | 16695 | { |
585f1adc | 16696 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16697 | int idx_protocol = 2; |
585f1adc | 16698 | int type; |
d62a17ae | 16699 | |
585f1adc IR |
16700 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
16701 | if (type < 0) { | |
16702 | vty_out(vty, "%% Invalid route type\n"); | |
16703 | return CMD_WARNING_CONFIG_FAILED; | |
16704 | } | |
16705 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 16706 | } |
16707 | ||
16708 | ALIAS_HIDDEN( | |
16709 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
16710 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 16711 | " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 16712 | NO_STR |
16713 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
16714 | "Metric for redistributed routes\n" | |
16715 | "Default metric\n" | |
16716 | "Route map reference\n" | |
16717 | "Pointer to route-map entries\n") | |
596c17ba | 16718 | |
585f1adc IR |
16719 | DEFUN (bgp_redistribute_ipv6, |
16720 | bgp_redistribute_ipv6_cmd, | |
16721 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
16722 | "Redistribute information from another routing protocol\n" | |
16723 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 16724 | { |
585f1adc | 16725 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16726 | int idx_protocol = 1; |
585f1adc | 16727 | int type; |
718e3744 | 16728 | |
585f1adc IR |
16729 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16730 | if (type < 0) { | |
16731 | vty_out(vty, "%% Invalid route type\n"); | |
16732 | return CMD_WARNING_CONFIG_FAILED; | |
16733 | } | |
718e3744 | 16734 | |
585f1adc IR |
16735 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
16736 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 16737 | } |
16738 | ||
585f1adc IR |
16739 | DEFUN (bgp_redistribute_ipv6_rmap, |
16740 | bgp_redistribute_ipv6_rmap_cmd, | |
70dd370f | 16741 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
16742 | "Redistribute information from another routing protocol\n" |
16743 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16744 | "Route map reference\n" | |
16745 | "Pointer to route-map entries\n") | |
718e3744 | 16746 | { |
585f1adc | 16747 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16748 | int idx_protocol = 1; |
16749 | int idx_word = 3; | |
585f1adc IR |
16750 | int type; |
16751 | struct bgp_redist *red; | |
16752 | bool changed; | |
16753 | struct route_map *route_map = | |
16754 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16755 | ||
16756 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16757 | if (type < 0) { | |
16758 | vty_out(vty, "%% Invalid route type\n"); | |
16759 | return CMD_WARNING_CONFIG_FAILED; | |
16760 | } | |
37a87b8f | 16761 | |
585f1adc IR |
16762 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16763 | changed = | |
16764 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16765 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16766 | } |
16767 | ||
585f1adc | 16768 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 16769 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16770 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16771 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16772 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16773 | "Metric for redistributed routes\n" |
16774 | "Default metric\n") | |
16775 | { | |
585f1adc | 16776 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16777 | int idx_protocol = 1; |
16778 | int idx_number = 3; | |
585f1adc IR |
16779 | int type; |
16780 | uint32_t metric; | |
16781 | struct bgp_redist *red; | |
16782 | bool changed; | |
16783 | ||
16784 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16785 | if (type < 0) { | |
16786 | vty_out(vty, "%% Invalid route type\n"); | |
16787 | return CMD_WARNING_CONFIG_FAILED; | |
16788 | } | |
16789 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16790 | |
585f1adc IR |
16791 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16792 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
16793 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16794 | } |
16795 | ||
585f1adc IR |
16796 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
16797 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
70dd370f | 16798 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16799 | "Redistribute information from another routing protocol\n" |
16800 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16801 | "Route map reference\n" | |
16802 | "Pointer to route-map entries\n" | |
16803 | "Metric for redistributed routes\n" | |
16804 | "Default metric\n") | |
718e3744 | 16805 | { |
585f1adc | 16806 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16807 | int idx_protocol = 1; |
16808 | int idx_word = 3; | |
16809 | int idx_number = 5; | |
585f1adc IR |
16810 | int type; |
16811 | uint32_t metric; | |
16812 | struct bgp_redist *red; | |
16813 | bool changed; | |
16814 | struct route_map *route_map = | |
16815 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16816 | ||
16817 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16818 | if (type < 0) { | |
16819 | vty_out(vty, "%% Invalid route type\n"); | |
16820 | return CMD_WARNING_CONFIG_FAILED; | |
16821 | } | |
16822 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16823 | |
585f1adc IR |
16824 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16825 | changed = | |
16826 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16827 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
16828 | metric); | |
16829 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16830 | } |
16831 | ||
585f1adc IR |
16832 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
16833 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
70dd370f | 16834 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16835 | "Redistribute information from another routing protocol\n" |
16836 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16837 | "Metric for redistributed routes\n" | |
16838 | "Default metric\n" | |
16839 | "Route map reference\n" | |
16840 | "Pointer to route-map entries\n") | |
718e3744 | 16841 | { |
585f1adc | 16842 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16843 | int idx_protocol = 1; |
37a87b8f | 16844 | int idx_number = 3; |
585f1adc IR |
16845 | int idx_word = 5; |
16846 | int type; | |
16847 | uint32_t metric; | |
16848 | struct bgp_redist *red; | |
16849 | bool changed; | |
16850 | struct route_map *route_map = | |
16851 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16852 | ||
16853 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16854 | if (type < 0) { | |
16855 | vty_out(vty, "%% Invalid route type\n"); | |
16856 | return CMD_WARNING_CONFIG_FAILED; | |
16857 | } | |
16858 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16859 | |
585f1adc IR |
16860 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16861 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
16862 | metric); | |
16863 | changed |= | |
16864 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16865 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16866 | } |
16867 | ||
585f1adc IR |
16868 | DEFUN (no_bgp_redistribute_ipv6, |
16869 | no_bgp_redistribute_ipv6_cmd, | |
70dd370f | 16870 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16871 | NO_STR |
16872 | "Redistribute information from another routing protocol\n" | |
16873 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16874 | "Metric for redistributed routes\n" | |
16875 | "Default metric\n" | |
16876 | "Route map reference\n" | |
16877 | "Pointer to route-map entries\n") | |
718e3744 | 16878 | { |
585f1adc | 16879 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16880 | int idx_protocol = 2; |
585f1adc | 16881 | int type; |
37a87b8f | 16882 | |
585f1adc IR |
16883 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16884 | if (type < 0) { | |
16885 | vty_out(vty, "%% Invalid route type\n"); | |
16886 | return CMD_WARNING_CONFIG_FAILED; | |
16887 | } | |
718e3744 | 16888 | |
585f1adc | 16889 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 16890 | } |
16891 | ||
4ab46701 AR |
16892 | /* Neighbor update tcp-mss. */ |
16893 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16894 | const char *tcp_mss_str) | |
16895 | { | |
16896 | struct peer *peer; | |
16897 | uint32_t tcp_mss_val = 0; | |
16898 | ||
16899 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16900 | if (!peer) | |
16901 | return CMD_WARNING_CONFIG_FAILED; | |
16902 | ||
16903 | if (tcp_mss_str) { | |
16904 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16905 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16906 | } else { | |
16907 | peer_tcp_mss_unset(peer); | |
16908 | } | |
16909 | ||
16910 | return CMD_SUCCESS; | |
16911 | } | |
16912 | ||
16913 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16914 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16915 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16916 | "TCP max segment size\n" | |
16917 | "TCP MSS value\n") | |
16918 | { | |
16919 | int peer_index = 1; | |
16920 | int mss_index = 3; | |
16921 | ||
16922 | vty_out(vty, | |
16923 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16924 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16925 | argv[mss_index]->arg); | |
16926 | } | |
16927 | ||
16928 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16929 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16930 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16931 | "TCP max segment size\n" | |
16932 | "TCP MSS value\n") | |
16933 | { | |
16934 | int peer_index = 2; | |
16935 | ||
16936 | vty_out(vty, | |
16937 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16938 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16939 | } | |
16940 | ||
a486300b PG |
16941 | DEFPY(bgp_retain_route_target, bgp_retain_route_target_cmd, |
16942 | "[no$no] bgp retain route-target all", | |
16943 | NO_STR BGP_STR | |
16944 | "Retain BGP updates\n" | |
16945 | "Retain BGP updates based on route-target values\n" | |
16946 | "Retain all BGP updates\n") | |
16947 | { | |
16948 | bool check; | |
16949 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
16950 | ||
16951 | check = CHECK_FLAG(bgp->af_flags[bgp_node_afi(vty)][bgp_node_safi(vty)], | |
16952 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16953 | if (check != !no) { | |
16954 | if (!no) | |
16955 | SET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16956 | [bgp_node_safi(vty)], | |
16957 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16958 | else | |
16959 | UNSET_FLAG(bgp->af_flags[bgp_node_afi(vty)] | |
16960 | [bgp_node_safi(vty)], | |
16961 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL); | |
16962 | /* trigger a flush to re-sync with ADJ-RIB-in */ | |
16963 | bgp_clear(vty, bgp, bgp_node_afi(vty), bgp_node_safi(vty), | |
16964 | clear_all, BGP_CLEAR_SOFT_IN, NULL); | |
16965 | } | |
16966 | return CMD_SUCCESS; | |
16967 | } | |
16968 | ||
dd65f45e DL |
16969 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16970 | afi_t afi, safi_t safi) | |
d62a17ae | 16971 | { |
16972 | int i; | |
16973 | ||
16974 | /* Unicast redistribution only. */ | |
16975 | if (safi != SAFI_UNICAST) | |
2b791107 | 16976 | return; |
d62a17ae | 16977 | |
16978 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16979 | /* Redistribute BGP does not make sense. */ | |
16980 | if (i != ZEBRA_ROUTE_BGP) { | |
16981 | struct list *red_list; | |
16982 | struct listnode *node; | |
16983 | struct bgp_redist *red; | |
16984 | ||
16985 | red_list = bgp->redist[afi][i]; | |
16986 | if (!red_list) | |
16987 | continue; | |
16988 | ||
16989 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16990 | /* "redistribute" configuration. */ |
16991 | vty_out(vty, " redistribute %s", | |
16992 | zebra_route_string(i)); | |
16993 | if (red->instance) | |
16994 | vty_out(vty, " %d", red->instance); | |
16995 | if (red->redist_metric_flag) | |
16996 | vty_out(vty, " metric %u", | |
16997 | red->redist_metric); | |
16998 | if (red->rmap.name) | |
16999 | vty_out(vty, " route-map %s", | |
17000 | red->rmap.name); | |
17001 | vty_out(vty, "\n"); | |
17002 | } | |
17003 | } | |
17004 | } | |
718e3744 | 17005 | } |
6b0655a2 | 17006 | |
dd65f45e DL |
17007 | /* peer-group helpers for config-write */ |
17008 | ||
83194f39 | 17009 | static bool peergroup_flag_check(struct peer *peer, uint64_t flag) |
dd65f45e DL |
17010 | { |
17011 | if (!peer_group_active(peer)) { | |
17012 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
17013 | return !CHECK_FLAG(peer->flags, flag); | |
17014 | else | |
17015 | return !!CHECK_FLAG(peer->flags, flag); | |
17016 | } | |
17017 | ||
17018 | return !!CHECK_FLAG(peer->flags_override, flag); | |
17019 | } | |
17020 | ||
17021 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
da5e1a58 | 17022 | uint64_t flag) |
dd65f45e DL |
17023 | { |
17024 | if (!peer_group_active(peer)) { | |
17025 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
17026 | return !peer_af_flag_check(peer, afi, safi, flag); | |
17027 | else | |
17028 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
17029 | } | |
17030 | ||
17031 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
17032 | } | |
17033 | ||
17034 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
17035 | uint8_t type, int direct) | |
17036 | { | |
17037 | struct bgp_filter *filter; | |
17038 | ||
17039 | if (peer_group_active(peer)) | |
17040 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
17041 | type); | |
17042 | ||
17043 | filter = &peer->filter[afi][safi]; | |
17044 | switch (type) { | |
17045 | case PEER_FT_DISTRIBUTE_LIST: | |
17046 | return !!(filter->dlist[direct].name); | |
17047 | case PEER_FT_FILTER_LIST: | |
17048 | return !!(filter->aslist[direct].name); | |
17049 | case PEER_FT_PREFIX_LIST: | |
17050 | return !!(filter->plist[direct].name); | |
17051 | case PEER_FT_ROUTE_MAP: | |
17052 | return !!(filter->map[direct].name); | |
17053 | case PEER_FT_UNSUPPRESS_MAP: | |
17054 | return !!(filter->usmap.name); | |
7f7940e6 MK |
17055 | case PEER_FT_ADVERTISE_MAP: |
17056 | return !!(filter->advmap.aname | |
17057 | && ((filter->advmap.condition == direct) | |
17058 | && filter->advmap.cname)); | |
dd65f45e DL |
17059 | default: |
17060 | return false; | |
17061 | } | |
17062 | } | |
17063 | ||
17064 | /* Return true if the addpath type is set for peer and different from | |
17065 | * peer-group. | |
17066 | */ | |
3dc339cd DA |
17067 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
17068 | safi_t safi) | |
dd65f45e DL |
17069 | { |
17070 | enum bgp_addpath_strat type, g_type; | |
17071 | ||
17072 | type = peer->addpath_type[afi][safi]; | |
17073 | ||
17074 | if (type != BGP_ADDPATH_NONE) { | |
17075 | if (peer_group_active(peer)) { | |
17076 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
17077 | ||
17078 | if (type != g_type) | |
3dc339cd | 17079 | return true; |
dd65f45e | 17080 | else |
3dc339cd | 17081 | return false; |
dd65f45e DL |
17082 | } |
17083 | ||
3dc339cd | 17084 | return true; |
dd65f45e DL |
17085 | } |
17086 | ||
3dc339cd | 17087 | return false; |
dd65f45e DL |
17088 | } |
17089 | ||
b9c7bc5a | 17090 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 17091 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
17092 | afi_t afi) |
17093 | { | |
b9c7bc5a | 17094 | int indent = 2; |
53970de3 | 17095 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 17096 | |
8a066a70 | 17097 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
17098 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
17099 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
17100 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
17101 | bgp->vpn_policy[afi] | |
bb4f6190 | 17102 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
17103 | else |
17104 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
17105 | bgp->vpn_policy[afi] | |
17106 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
17107 | } | |
12a844a5 DS |
17108 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
17109 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
17110 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
17111 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
17112 | return; | |
17113 | ||
e70e9f8e PZ |
17114 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
17115 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
17116 | ||
17117 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
17118 | ||
17119 | } else { | |
17120 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
17121 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
17122 | bgp->vpn_policy[afi].tovpn_label); | |
17123 | } | |
ddb5b488 | 17124 | } |
53970de3 RS |
17125 | |
17126 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
17127 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
17128 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
17129 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
17130 | } else if (tovpn_sid_index != 0) { | |
17131 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
17132 | tovpn_sid_index); | |
17133 | } | |
17134 | ||
c4f64ea9 DA |
17135 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_RD_SET)) |
17136 | vty_out(vty, "%*srd vpn export %pRD\n", indent, "", | |
17137 | &bgp->vpn_policy[afi].tovpn_rd); | |
17138 | ||
ddb5b488 PZ |
17139 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
17140 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
17141 | ||
17142 | char buf[PREFIX_STRLEN]; | |
17143 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
17144 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
17145 | sizeof(buf))) { | |
17146 | ||
b9c7bc5a PZ |
17147 | vty_out(vty, "%*snexthop vpn export %s\n", |
17148 | indent, "", buf); | |
ddb5b488 PZ |
17149 | } |
17150 | } | |
17151 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
17152 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
17153 | && ecommunity_cmp( | |
17154 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
17155 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
17156 | ||
17157 | char *b = ecommunity_ecom2str( | |
17158 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
17159 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17160 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
17161 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17162 | } else { | |
17163 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
17164 | char *b = ecommunity_ecom2str( | |
17165 | bgp->vpn_policy[afi] | |
17166 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
17167 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17168 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17169 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
17170 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17171 | } | |
17172 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
17173 | char *b = ecommunity_ecom2str( | |
17174 | bgp->vpn_policy[afi] | |
17175 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
17176 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17177 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 17178 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
17179 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17180 | } | |
17181 | } | |
bb4f6190 DS |
17182 | |
17183 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 17184 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
17185 | bgp->vpn_policy[afi] |
17186 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 17187 | |
301ad80a PG |
17188 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
17189 | char *b = ecommunity_ecom2str( | |
17190 | bgp->vpn_policy[afi] | |
17191 | .import_redirect_rtlist, | |
17192 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
17193 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 17194 | |
9a659715 PG |
17195 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
17196 | != ECOMMUNITY_SIZE) | |
c6423c31 | 17197 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
17198 | indent, "", b); |
17199 | else | |
17200 | vty_out(vty, "%*srt redirect import %s\n", | |
17201 | indent, "", b); | |
301ad80a PG |
17202 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
17203 | } | |
ddb5b488 PZ |
17204 | } |
17205 | ||
dd65f45e DL |
17206 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
17207 | afi_t afi, safi_t safi) | |
17208 | { | |
17209 | struct bgp_filter *filter; | |
17210 | char *addr; | |
17211 | ||
17212 | addr = peer->host; | |
17213 | filter = &peer->filter[afi][safi]; | |
17214 | ||
17215 | /* distribute-list. */ | |
17216 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17217 | FILTER_IN)) | |
17218 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
17219 | filter->dlist[FILTER_IN].name); | |
17220 | ||
17221 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
17222 | FILTER_OUT)) | |
17223 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
17224 | filter->dlist[FILTER_OUT].name); | |
17225 | ||
17226 | /* prefix-list. */ | |
17227 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17228 | FILTER_IN)) | |
17229 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
17230 | filter->plist[FILTER_IN].name); | |
17231 | ||
17232 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
17233 | FILTER_OUT)) | |
17234 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
17235 | filter->plist[FILTER_OUT].name); | |
17236 | ||
17237 | /* route-map. */ | |
17238 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
17239 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
17240 | filter->map[RMAP_IN].name); | |
17241 | ||
17242 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
17243 | RMAP_OUT)) | |
17244 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
17245 | filter->map[RMAP_OUT].name); | |
17246 | ||
17247 | /* unsuppress-map */ | |
17248 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
17249 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
17250 | filter->usmap.name); | |
17251 | ||
7f7940e6 MK |
17252 | /* advertise-map : always applied in OUT direction*/ |
17253 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17254 | CONDITION_NON_EXIST)) | |
17255 | vty_out(vty, | |
17256 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
17257 | addr, filter->advmap.aname, filter->advmap.cname); | |
17258 | ||
17259 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
17260 | CONDITION_EXIST)) | |
17261 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
17262 | addr, filter->advmap.aname, filter->advmap.cname); | |
17263 | ||
dd65f45e DL |
17264 | /* filter-list. */ |
17265 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17266 | FILTER_IN)) | |
17267 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
17268 | filter->aslist[FILTER_IN].name); | |
17269 | ||
17270 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
17271 | FILTER_OUT)) | |
17272 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
17273 | filter->aslist[FILTER_OUT].name); | |
17274 | } | |
17275 | ||
17276 | /* BGP peer configuration display function. */ | |
17277 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
17278 | struct peer *peer) | |
17279 | { | |
17280 | struct peer *g_peer = NULL; | |
dd65f45e DL |
17281 | char *addr; |
17282 | int if_pg_printed = false; | |
17283 | int if_ras_printed = false; | |
17284 | ||
17285 | /* Skip dynamic neighbors. */ | |
17286 | if (peer_dynamic_neighbor(peer)) | |
17287 | return; | |
17288 | ||
17289 | if (peer->conf_if) | |
17290 | addr = peer->conf_if; | |
17291 | else | |
17292 | addr = peer->host; | |
17293 | ||
17294 | /************************************ | |
17295 | ****** Global to the neighbor ****** | |
17296 | ************************************/ | |
17297 | if (peer->conf_if) { | |
17298 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
17299 | vty_out(vty, " neighbor %s interface v6only", addr); | |
17300 | else | |
17301 | vty_out(vty, " neighbor %s interface", addr); | |
17302 | ||
17303 | if (peer_group_active(peer)) { | |
17304 | vty_out(vty, " peer-group %s", peer->group->name); | |
17305 | if_pg_printed = true; | |
17306 | } else if (peer->as_type == AS_SPECIFIED) { | |
de76ed8a | 17307 | vty_out(vty, " remote-as %s", peer->as_pretty); |
dd65f45e DL |
17308 | if_ras_printed = true; |
17309 | } else if (peer->as_type == AS_INTERNAL) { | |
17310 | vty_out(vty, " remote-as internal"); | |
17311 | if_ras_printed = true; | |
17312 | } else if (peer->as_type == AS_EXTERNAL) { | |
17313 | vty_out(vty, " remote-as external"); | |
17314 | if_ras_printed = true; | |
17315 | } | |
17316 | ||
17317 | vty_out(vty, "\n"); | |
17318 | } | |
17319 | ||
17320 | /* remote-as and peer-group */ | |
17321 | /* peer is a member of a peer-group */ | |
17322 | if (peer_group_active(peer)) { | |
17323 | g_peer = peer->group->conf; | |
17324 | ||
17325 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
17326 | if (peer->as_type == AS_SPECIFIED) { | |
de76ed8a PG |
17327 | vty_out(vty, " neighbor %s remote-as %s\n", |
17328 | addr, peer->as_pretty); | |
dd65f45e DL |
17329 | } else if (peer->as_type == AS_INTERNAL) { |
17330 | vty_out(vty, | |
17331 | " neighbor %s remote-as internal\n", | |
17332 | addr); | |
17333 | } else if (peer->as_type == AS_EXTERNAL) { | |
17334 | vty_out(vty, | |
17335 | " neighbor %s remote-as external\n", | |
17336 | addr); | |
17337 | } | |
17338 | } | |
17339 | ||
17340 | /* For swpX peers we displayed the peer-group | |
17341 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
17342 | if (!if_pg_printed) | |
17343 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
17344 | peer->group->name); | |
17345 | } | |
17346 | ||
17347 | /* peer is NOT a member of a peer-group */ | |
17348 | else { | |
17349 | /* peer is a peer-group, declare the peer-group */ | |
17350 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
17351 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
17352 | } | |
17353 | ||
17354 | if (!if_ras_printed) { | |
17355 | if (peer->as_type == AS_SPECIFIED) { | |
de76ed8a PG |
17356 | vty_out(vty, " neighbor %s remote-as %s\n", |
17357 | addr, peer->as_pretty); | |
dd65f45e DL |
17358 | } else if (peer->as_type == AS_INTERNAL) { |
17359 | vty_out(vty, | |
17360 | " neighbor %s remote-as internal\n", | |
17361 | addr); | |
17362 | } else if (peer->as_type == AS_EXTERNAL) { | |
17363 | vty_out(vty, | |
17364 | " neighbor %s remote-as external\n", | |
17365 | addr); | |
17366 | } | |
17367 | } | |
17368 | } | |
17369 | ||
17370 | /* local-as */ | |
17371 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
de76ed8a PG |
17372 | vty_out(vty, " neighbor %s local-as %s", addr, |
17373 | peer->change_local_as_pretty); | |
dd65f45e DL |
17374 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) |
17375 | vty_out(vty, " no-prepend"); | |
17376 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
17377 | vty_out(vty, " replace-as"); | |
17378 | vty_out(vty, "\n"); | |
17379 | } | |
17380 | ||
17381 | /* description */ | |
17382 | if (peer->desc) { | |
17383 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
17384 | } | |
17385 | ||
17386 | /* shutdown */ | |
17387 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
17388 | if (peer->tx_shutdown_message) | |
17389 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
17390 | peer->tx_shutdown_message); | |
17391 | else | |
17392 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
17393 | } | |
17394 | ||
8336c896 DA |
17395 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
17396 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
17397 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
17398 | ||
dd65f45e | 17399 | /* bfd */ |
21bfce98 RZ |
17400 | if (peer->bfd_config) |
17401 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
17402 | |
17403 | /* password */ | |
17404 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
17405 | vty_out(vty, " neighbor %s password %s\n", addr, | |
17406 | peer->password); | |
17407 | ||
17408 | /* neighbor solo */ | |
17409 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
17410 | if (!peer_group_active(peer)) { | |
17411 | vty_out(vty, " neighbor %s solo\n", addr); | |
17412 | } | |
17413 | } | |
17414 | ||
17415 | /* BGP port */ | |
17416 | if (peer->port != BGP_PORT_DEFAULT) { | |
17417 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
17418 | } | |
17419 | ||
17420 | /* Local interface name */ | |
17421 | if (peer->ifname) { | |
17422 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
17423 | } | |
17424 | ||
4ab46701 AR |
17425 | /* TCP max segment size */ |
17426 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
17427 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
17428 | ||
dd65f45e DL |
17429 | /* passive */ |
17430 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
17431 | vty_out(vty, " neighbor %s passive\n", addr); | |
17432 | ||
17433 | /* ebgp-multihop */ | |
17434 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
17435 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
17436 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
17437 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
17438 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
17439 | peer->ttl); | |
17440 | } | |
17441 | } | |
17442 | ||
97a52c82 DA |
17443 | /* aigp */ |
17444 | if (peergroup_flag_check(peer, PEER_FLAG_AIGP)) | |
17445 | vty_out(vty, " neighbor %s aigp\n", addr); | |
17446 | ||
4f770cf1 DA |
17447 | /* graceful-shutdown */ |
17448 | if (peergroup_flag_check(peer, PEER_FLAG_GRACEFUL_SHUTDOWN)) | |
17449 | vty_out(vty, " neighbor %s graceful-shutdown\n", addr); | |
17450 | ||
d864dd9e | 17451 | /* role */ |
7dddd1f7 DA |
17452 | if (peergroup_flag_check(peer, PEER_FLAG_ROLE) && |
17453 | peer->local_role != ROLE_UNDEFINED) | |
d864dd9e | 17454 | vty_out(vty, " neighbor %s local-role %s%s\n", addr, |
8f2d6021 | 17455 | bgp_get_name_by_role(peer->local_role), |
7dddd1f7 | 17456 | CHECK_FLAG(peer->flags, PEER_FLAG_ROLE_STRICT_MODE) |
d864dd9e EB |
17457 | ? " strict-mode" |
17458 | : ""); | |
d864dd9e | 17459 | |
dd65f45e | 17460 | /* ttl-security hops */ |
e2521429 | 17461 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
17462 | if (!peer_group_active(peer) |
17463 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
17464 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
17465 | addr, peer->gtsm_hops); | |
17466 | } | |
17467 | } | |
17468 | ||
17469 | /* disable-connected-check */ | |
17470 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
17471 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
17472 | ||
27aa23a4 DA |
17473 | /* link-bw-encoding-ieee */ |
17474 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
17475 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
17476 | addr); | |
17477 | ||
d08c0c80 DA |
17478 | /* extended-optional-parameters */ |
17479 | if (peergroup_flag_check(peer, PEER_FLAG_EXTENDED_OPT_PARAMS)) | |
17480 | vty_out(vty, " neighbor %s extended-optional-parameters\n", | |
17481 | addr); | |
17482 | ||
dd65f45e DL |
17483 | /* enforce-first-as */ |
17484 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
17485 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
17486 | ||
17487 | /* update-source */ | |
17488 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
17489 | if (peer->update_source) | |
47e12884 DA |
17490 | vty_out(vty, " neighbor %s update-source %pSU\n", addr, |
17491 | peer->update_source); | |
dd65f45e DL |
17492 | else if (peer->update_if) |
17493 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
17494 | peer->update_if); | |
17495 | } | |
17496 | ||
17497 | /* advertisement-interval */ | |
17498 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
17499 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
17500 | peer->routeadv); | |
17501 | ||
17502 | /* timers */ | |
17503 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
17504 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
17505 | peer->keepalive, peer->holdtime); | |
17506 | ||
17507 | /* timers connect */ | |
17508 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
17509 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17510 | peer->connect); | |
5d5393b9 DL |
17511 | /* need special-case handling for changed default values due to |
17512 | * config profile / version (because there is no "timers bgp connect" | |
17513 | * command, we need to save this per-peer :/) | |
17514 | */ | |
17515 | else if (!peer_group_active(peer) && !peer->connect && | |
17516 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
17517 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
17518 | peer->bgp->default_connect_retry); | |
dd65f45e | 17519 | |
d43114f3 DS |
17520 | /* timers delayopen */ |
17521 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
17522 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17523 | peer->delayopen); | |
17524 | /* Save config even though flag is not set if default values have been | |
17525 | * changed | |
17526 | */ | |
17527 | else if (!peer_group_active(peer) && !peer->delayopen | |
17528 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
17529 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
17530 | peer->bgp->default_delayopen); | |
17531 | ||
dd65f45e DL |
17532 | /* capability dynamic */ |
17533 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
17534 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
17535 | ||
17536 | /* capability extended-nexthop */ | |
17537 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
8e89adc1 DS |
17538 | if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE) && |
17539 | !peer->conf_if) | |
843770f6 DA |
17540 | vty_out(vty, |
17541 | " no neighbor %s capability extended-nexthop\n", | |
17542 | addr); | |
17543 | else if (!peer->conf_if) | |
17544 | vty_out(vty, | |
17545 | " neighbor %s capability extended-nexthop\n", | |
17546 | addr); | |
dd65f45e DL |
17547 | } |
17548 | ||
17549 | /* dont-capability-negotiation */ | |
17550 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
17551 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
17552 | ||
17553 | /* override-capability */ | |
17554 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
17555 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
17556 | ||
17557 | /* strict-capability-match */ | |
17558 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
17559 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
17560 | ||
17561 | /* Sender side AS path loop detection. */ | |
17562 | if (peer->as_path_loop_detection) | |
17563 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
17564 | addr); | |
cfd47646 | 17565 | |
a5c6a9b1 DA |
17566 | /* path-attribute discard */ |
17567 | char discard_attrs_str[BUFSIZ] = {0}; | |
17568 | bool discard_attrs = bgp_path_attribute_discard( | |
17569 | peer, discard_attrs_str, sizeof(discard_attrs_str)); | |
17570 | ||
17571 | if (discard_attrs) | |
17572 | vty_out(vty, " neighbor %s path-attribute discard %s\n", addr, | |
17573 | discard_attrs_str); | |
17574 | ||
cfd47646 | 17575 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, |
13909c4f | 17576 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 17577 | |
17578 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 17579 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 17580 | vty_out(vty, |
17581 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
17582 | } else if (CHECK_FLAG( |
17583 | peer->peer_gr_new_status_flag, | |
17584 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 17585 | vty_out(vty, |
17586 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
17587 | } else if ( |
17588 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
17589 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
17590 | && !(CHECK_FLAG( | |
17591 | peer->peer_gr_new_status_flag, | |
17592 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
17593 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
17594 | addr); | |
cfd47646 | 17595 | } |
17596 | } | |
dd65f45e DL |
17597 | } |
17598 | ||
17599 | /* BGP peer configuration display function. */ | |
17600 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
17601 | struct peer *peer, afi_t afi, safi_t safi) | |
17602 | { | |
17603 | struct peer *g_peer = NULL; | |
17604 | char *addr; | |
17605 | bool flag_scomm, flag_secomm, flag_slcomm; | |
17606 | ||
17607 | /* Skip dynamic neighbors. */ | |
17608 | if (peer_dynamic_neighbor(peer)) | |
17609 | return; | |
17610 | ||
17611 | if (peer->conf_if) | |
17612 | addr = peer->conf_if; | |
17613 | else | |
17614 | addr = peer->host; | |
17615 | ||
17616 | /************************************ | |
17617 | ****** Per AF to the neighbor ****** | |
17618 | ************************************/ | |
17619 | if (peer_group_active(peer)) { | |
17620 | g_peer = peer->group->conf; | |
17621 | ||
17622 | /* If the peer-group is active but peer is not, print a 'no | |
17623 | * activate' */ | |
17624 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
17625 | vty_out(vty, " no neighbor %s activate\n", addr); | |
17626 | } | |
17627 | ||
17628 | /* If the peer-group is not active but peer is, print an | |
17629 | 'activate' */ | |
17630 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
17631 | vty_out(vty, " neighbor %s activate\n", addr); | |
17632 | } | |
17633 | } else { | |
17634 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
17635 | if (safi == SAFI_ENCAP) |
17636 | vty_out(vty, " neighbor %s activate\n", addr); | |
17637 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
17638 | vty_out(vty, " neighbor %s activate\n", addr); |
17639 | } else { | |
38d11af5 TA |
17640 | if (bgp->default_af[afi][safi]) |
17641 | vty_out(vty, " no neighbor %s activate\n", | |
17642 | addr); | |
dd65f45e DL |
17643 | } |
17644 | } | |
17645 | ||
17646 | /* addpath TX knobs */ | |
17647 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
17648 | switch (peer->addpath_type[afi][safi]) { | |
17649 | case BGP_ADDPATH_ALL: | |
17650 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
17651 | addr); | |
17652 | break; | |
17653 | case BGP_ADDPATH_BEST_PER_AS: | |
17654 | vty_out(vty, | |
17655 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
17656 | addr); | |
17657 | break; | |
17658 | case BGP_ADDPATH_MAX: | |
17659 | case BGP_ADDPATH_NONE: | |
17660 | break; | |
17661 | } | |
17662 | } | |
17663 | ||
7c0e4312 DA |
17664 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
17665 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
17666 | ||
dd65f45e DL |
17667 | /* ORF capability. */ |
17668 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
17669 | || peergroup_af_flag_check(peer, afi, safi, | |
17670 | PEER_FLAG_ORF_PREFIX_RM)) { | |
17671 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
17672 | ||
17673 | if (peergroup_af_flag_check(peer, afi, safi, | |
17674 | PEER_FLAG_ORF_PREFIX_SM) | |
17675 | && peergroup_af_flag_check(peer, afi, safi, | |
17676 | PEER_FLAG_ORF_PREFIX_RM)) | |
17677 | vty_out(vty, " both"); | |
17678 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17679 | PEER_FLAG_ORF_PREFIX_SM)) | |
17680 | vty_out(vty, " send"); | |
17681 | else | |
17682 | vty_out(vty, " receive"); | |
17683 | vty_out(vty, "\n"); | |
17684 | } | |
17685 | ||
dd65f45e DL |
17686 | /* Route reflector client. */ |
17687 | if (peergroup_af_flag_check(peer, afi, safi, | |
17688 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
17689 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
17690 | } | |
17691 | ||
17692 | /* next-hop-self force */ | |
17693 | if (peergroup_af_flag_check(peer, afi, safi, | |
17694 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
17695 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
17696 | } | |
17697 | ||
17698 | /* next-hop-self */ | |
17699 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
17700 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
17701 | } | |
17702 | ||
17703 | /* remove-private-AS */ | |
17704 | if (peergroup_af_flag_check(peer, afi, safi, | |
17705 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
17706 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
17707 | addr); | |
17708 | } | |
17709 | ||
17710 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17711 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
17712 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
17713 | addr); | |
17714 | } | |
17715 | ||
17716 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17717 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
17718 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
17719 | } | |
17720 | ||
17721 | else if (peergroup_af_flag_check(peer, afi, safi, | |
17722 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
17723 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
17724 | } | |
17725 | ||
17726 | /* as-override */ | |
17727 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
17728 | vty_out(vty, " neighbor %s as-override\n", addr); | |
17729 | } | |
17730 | ||
17731 | /* send-community print. */ | |
17732 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
17733 | PEER_FLAG_SEND_COMMUNITY); | |
17734 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
17735 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
17736 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
17737 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
17738 | ||
17739 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
17740 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
17741 | } else { | |
17742 | if (flag_scomm) | |
17743 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
17744 | if (flag_secomm) | |
17745 | vty_out(vty, | |
17746 | " no neighbor %s send-community extended\n", | |
17747 | addr); | |
17748 | ||
17749 | if (flag_slcomm) | |
17750 | vty_out(vty, " no neighbor %s send-community large\n", | |
17751 | addr); | |
17752 | } | |
17753 | ||
17754 | /* Default information */ | |
17755 | if (peergroup_af_flag_check(peer, afi, safi, | |
17756 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
17757 | vty_out(vty, " neighbor %s default-originate", addr); | |
17758 | ||
17759 | if (peer->default_rmap[afi][safi].name) | |
17760 | vty_out(vty, " route-map %s", | |
17761 | peer->default_rmap[afi][safi].name); | |
17762 | ||
17763 | vty_out(vty, "\n"); | |
17764 | } | |
17765 | ||
17766 | /* Soft reconfiguration inbound. */ | |
17767 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
17768 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
17769 | addr); | |
17770 | } | |
17771 | ||
17772 | /* maximum-prefix. */ | |
17773 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 17774 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
17775 | peer->pmax[afi][safi]); |
17776 | ||
17777 | if (peer->pmax_threshold[afi][safi] | |
17778 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
17779 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
17780 | if (peer_af_flag_check(peer, afi, safi, | |
17781 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
17782 | vty_out(vty, " warning-only"); | |
17783 | if (peer->pmax_restart[afi][safi]) | |
17784 | vty_out(vty, " restart %u", | |
17785 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
17786 | if (peer_af_flag_check(peer, afi, safi, |
17787 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
17788 | vty_out(vty, " force"); | |
dd65f45e DL |
17789 | |
17790 | vty_out(vty, "\n"); | |
17791 | } | |
17792 | ||
fde246e8 DA |
17793 | /* maximum-prefix-out */ |
17794 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 17795 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
17796 | addr, peer->pmax_out[afi][safi]); |
17797 | ||
dd65f45e DL |
17798 | /* Route server client. */ |
17799 | if (peergroup_af_flag_check(peer, afi, safi, | |
17800 | PEER_FLAG_RSERVER_CLIENT)) { | |
17801 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
17802 | } | |
17803 | ||
17804 | /* Nexthop-local unchanged. */ | |
17805 | if (peergroup_af_flag_check(peer, afi, safi, | |
17806 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
17807 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
17808 | } | |
17809 | ||
17810 | /* allowas-in <1-10> */ | |
17811 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17812 | if (peer_af_flag_check(peer, afi, safi, | |
17813 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17814 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17815 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17816 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17817 | } else { | |
17818 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17819 | peer->allowas_in[afi][safi]); | |
17820 | } | |
17821 | } | |
17822 | ||
46dbf9d0 DA |
17823 | /* accept-own */ |
17824 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ACCEPT_OWN)) | |
17825 | vty_out(vty, " neighbor %s accept-own\n", addr); | |
17826 | ||
01da2d26 DA |
17827 | /* soo */ |
17828 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOO)) { | |
17829 | char *soo_str = ecommunity_ecom2str( | |
17830 | peer->soo[afi][safi], ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
17831 | ||
17832 | vty_out(vty, " neighbor %s soo %s\n", addr, soo_str); | |
17833 | XFREE(MTYPE_ECOMMUNITY_STR, soo_str); | |
17834 | } | |
17835 | ||
dd65f45e DL |
17836 | /* weight */ |
17837 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17838 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17839 | peer->weight[afi][safi]); | |
17840 | ||
17841 | /* Filter. */ | |
17842 | bgp_config_write_filter(vty, peer, afi, safi); | |
17843 | ||
17844 | /* atribute-unchanged. */ | |
17845 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17846 | || (safi != SAFI_EVPN | |
17847 | && peer_af_flag_check(peer, afi, safi, | |
17848 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17849 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17850 | ||
17851 | if (!peer_group_active(peer) | |
17852 | || peergroup_af_flag_check(peer, afi, safi, | |
17853 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17854 | || peergroup_af_flag_check(peer, afi, safi, | |
17855 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17856 | || peergroup_af_flag_check(peer, afi, safi, | |
17857 | PEER_FLAG_MED_UNCHANGED)) { | |
17858 | ||
17859 | vty_out(vty, | |
17860 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17861 | addr, | |
17862 | peer_af_flag_check(peer, afi, safi, | |
17863 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17864 | ? " as-path" | |
17865 | : "", | |
17866 | peer_af_flag_check(peer, afi, safi, | |
17867 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17868 | ? " next-hop" | |
17869 | : "", | |
17870 | peer_af_flag_check(peer, afi, safi, | |
17871 | PEER_FLAG_MED_UNCHANGED) | |
17872 | ? " med" | |
17873 | : ""); | |
17874 | } | |
17875 | } | |
17876 | } | |
17877 | ||
a486300b PG |
17878 | static void bgp_vpn_config_write(struct vty *vty, struct bgp *bgp, afi_t afi, |
17879 | safi_t safi) | |
17880 | { | |
17881 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
17882 | BGP_VPNVX_RETAIN_ROUTE_TARGET_ALL)) | |
17883 | vty_out(vty, " no bgp retain route-target all\n"); | |
17884 | } | |
17885 | ||
dd65f45e DL |
17886 | /* Address family based peer configuration display. */ |
17887 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17888 | safi_t safi) | |
17889 | { | |
17890 | struct peer *peer; | |
17891 | struct peer_group *group; | |
17892 | struct listnode *node, *nnode; | |
17893 | ||
17894 | ||
17895 | vty_frame(vty, " !\n address-family "); | |
17896 | if (afi == AFI_IP) { | |
17897 | if (safi == SAFI_UNICAST) | |
17898 | vty_frame(vty, "ipv4 unicast"); | |
17899 | else if (safi == SAFI_LABELED_UNICAST) | |
17900 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17901 | else if (safi == SAFI_MULTICAST) | |
17902 | vty_frame(vty, "ipv4 multicast"); | |
17903 | else if (safi == SAFI_MPLS_VPN) | |
17904 | vty_frame(vty, "ipv4 vpn"); | |
17905 | else if (safi == SAFI_ENCAP) | |
17906 | vty_frame(vty, "ipv4 encap"); | |
17907 | else if (safi == SAFI_FLOWSPEC) | |
17908 | vty_frame(vty, "ipv4 flowspec"); | |
17909 | } else if (afi == AFI_IP6) { | |
17910 | if (safi == SAFI_UNICAST) | |
17911 | vty_frame(vty, "ipv6 unicast"); | |
17912 | else if (safi == SAFI_LABELED_UNICAST) | |
17913 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17914 | else if (safi == SAFI_MULTICAST) | |
17915 | vty_frame(vty, "ipv6 multicast"); | |
17916 | else if (safi == SAFI_MPLS_VPN) | |
17917 | vty_frame(vty, "ipv6 vpn"); | |
17918 | else if (safi == SAFI_ENCAP) | |
17919 | vty_frame(vty, "ipv6 encap"); | |
17920 | else if (safi == SAFI_FLOWSPEC) | |
17921 | vty_frame(vty, "ipv6 flowspec"); | |
17922 | } else if (afi == AFI_L2VPN) { | |
17923 | if (safi == SAFI_EVPN) | |
17924 | vty_frame(vty, "l2vpn evpn"); | |
17925 | } | |
17926 | vty_frame(vty, "\n"); | |
17927 | ||
17928 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17929 | ||
17930 | bgp_config_write_network(vty, bgp, afi, safi); | |
17931 | ||
17932 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17933 | ||
8a4e7fe6 DA |
17934 | /* BGP flag dampening. */ |
17935 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 17936 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 17937 | |
dd65f45e DL |
17938 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17939 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17940 | ||
17941 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17942 | /* Do not display doppelganger peers */ |
17943 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17944 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17945 | } | |
17946 | ||
17947 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17948 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17949 | ||
17950 | if (safi == SAFI_EVPN) | |
17951 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17952 | ||
17953 | if (safi == SAFI_FLOWSPEC) | |
17954 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17955 | ||
a486300b PG |
17956 | if (safi == SAFI_MPLS_VPN) |
17957 | bgp_vpn_config_write(vty, bgp, afi, safi); | |
17958 | ||
dd65f45e DL |
17959 | if (safi == SAFI_UNICAST) { |
17960 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17961 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17962 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17963 | ||
17964 | vty_out(vty, " export vpn\n"); | |
17965 | } | |
17966 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17967 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17968 | ||
17969 | vty_out(vty, " import vpn\n"); | |
17970 | } | |
17971 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17972 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17973 | char *name; | |
17974 | ||
17975 | for (ALL_LIST_ELEMENTS_RO( | |
17976 | bgp->vpn_policy[afi].import_vrf, node, | |
17977 | name)) | |
17978 | vty_out(vty, " import vrf %s\n", name); | |
17979 | } | |
17980 | } | |
17981 | ||
17982 | vty_endframe(vty, " exit-address-family\n"); | |
17983 | } | |
17984 | ||
17985 | int bgp_config_write(struct vty *vty) | |
17986 | { | |
17987 | struct bgp *bgp; | |
17988 | struct peer_group *group; | |
17989 | struct peer *peer; | |
17990 | struct listnode *node, *nnode; | |
17991 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17992 | afi_t afi; |
17993 | safi_t safi; | |
efc9b57d | 17994 | uint32_t tovpn_sid_index = 0; |
dd65f45e DL |
17995 | |
17996 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17997 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17998 | bm->rmap_update_timer); | |
17999 | ||
d70583f7 D |
18000 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
18001 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
18002 | if (bm->v_update_delay != bm->v_establish_wait) | |
18003 | vty_out(vty, " %d", bm->v_establish_wait); | |
18004 | vty_out(vty, "\n"); | |
18005 | } | |
18006 | ||
9acb67cb DS |
18007 | if (bm->wait_for_fib) |
18008 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
18009 | ||
05bd726c | 18010 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
18011 | vty_out(vty, "bgp graceful-shutdown\n"); | |
18012 | ||
c163f297 DS |
18013 | /* No-RIB (Zebra) option flag configuration */ |
18014 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
18015 | vty_out(vty, "bgp no-rib\n"); | |
18016 | ||
870791a3 IR |
18017 | if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
18018 | vty_out(vty, "bgp send-extra-data zebra\n"); | |
e46723a5 | 18019 | |
425bd64b PS |
18020 | /* BGP session DSCP value */ |
18021 | if (bm->tcp_dscp != IPTOS_PREC_INTERNETCONTROL) | |
18022 | vty_out(vty, "bgp session-dscp %u\n", bm->tcp_dscp >> 2); | |
18023 | ||
a0b937de | 18024 | /* BGP InQ limit */ |
963b7ee4 | 18025 | if (bm->inq_limit != BM_DEFAULT_Q_LIMIT) |
a0b937de SW |
18026 | vty_out(vty, "bgp input-queue-limit %u\n", bm->inq_limit); |
18027 | ||
963b7ee4 DS |
18028 | if (bm->outq_limit != BM_DEFAULT_Q_LIMIT) |
18029 | vty_out(vty, "bgp output-queue-limit %u\n", bm->outq_limit); | |
18030 | ||
dd65f45e DL |
18031 | /* BGP configuration. */ |
18032 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
18033 | ||
18034 | /* skip all auto created vrf as they dont have user config */ | |
18035 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
18036 | continue; | |
18037 | ||
18038 | /* Router bgp ASN */ | |
9eb11997 | 18039 | vty_out(vty, "router bgp %s", bgp->as_pretty); |
dd65f45e DL |
18040 | |
18041 | if (bgp->name) | |
18042 | vty_out(vty, " %s %s", | |
18043 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
18044 | ? "view" : "vrf", bgp->name); | |
e55b0883 PG |
18045 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_ASNOTATION)) |
18046 | vty_out(vty, " as-notation %s", | |
18047 | asn_mode2str(bgp->asnotation)); | |
18048 | ||
dd65f45e DL |
18049 | vty_out(vty, "\n"); |
18050 | ||
18051 | /* BGP fast-external-failover. */ | |
18052 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
18053 | vty_out(vty, " no bgp fast-external-failover\n"); | |
18054 | ||
18055 | /* BGP router ID. */ | |
3a6290bd | 18056 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
18057 | vty_out(vty, " bgp router-id %pI4\n", |
18058 | &bgp->router_id_static); | |
dd65f45e | 18059 | |
c208c586 S |
18060 | /* Suppress fib pending */ |
18061 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
18062 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
18063 | ||
dd65f45e | 18064 | /* BGP log-neighbor-changes. */ |
892fedb6 | 18065 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 18066 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 18067 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
18068 | CHECK_FLAG(bgp->flags, |
18069 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
18070 | ? "" |
18071 | : "no "); | |
18072 | ||
18073 | /* BGP configuration. */ | |
892fedb6 | 18074 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
18075 | vty_out(vty, " bgp always-compare-med\n"); |
18076 | ||
18077 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
18078 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
18079 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
18080 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
18081 | CHECK_FLAG(bgp->flags, | |
18082 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
18083 | ? "" | |
18084 | : "no "); | |
dd65f45e DL |
18085 | |
18086 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 18087 | if (bgp->reject_as_sets) |
dd65f45e DL |
18088 | vty_out(vty, " bgp reject-as-sets\n"); |
18089 | ||
2adac256 DA |
18090 | /* Suppress duplicate updates if the route actually not changed |
18091 | */ | |
18092 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
18093 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
18094 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
18095 | CHECK_FLAG(bgp->flags, | |
18096 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
18097 | ? "" | |
18098 | : "no "); | |
18099 | ||
1ae314be DA |
18100 | /* Send Hard Reset CEASE Notification for 'Administrative Reset' |
18101 | */ | |
18102 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET) != | |
18103 | SAVE_BGP_HARD_ADMIN_RESET) | |
18104 | vty_out(vty, " %sbgp hard-administrative-reset\n", | |
18105 | CHECK_FLAG(bgp->flags, | |
18106 | BGP_FLAG_HARD_ADMIN_RESET) | |
18107 | ? "" | |
18108 | : "no "); | |
18109 | ||
b16bcbba TA |
18110 | /* BGP default <afi>-<safi> */ |
18111 | FOREACH_AFI_SAFI (afi, safi) { | |
18112 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
18113 | if (!bgp->default_af[afi][safi]) | |
18114 | vty_out(vty, " no bgp default %s\n", | |
18115 | get_bgp_default_af_flag(afi, | |
18116 | safi)); | |
18117 | } else if (bgp->default_af[afi][safi]) | |
18118 | vty_out(vty, " bgp default %s\n", | |
18119 | get_bgp_default_af_flag(afi, safi)); | |
18120 | } | |
e84c59af | 18121 | |
dd65f45e DL |
18122 | /* BGP default local-preference. */ |
18123 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
18124 | vty_out(vty, " bgp default local-preference %u\n", | |
18125 | bgp->default_local_pref); | |
18126 | ||
18127 | /* BGP default show-hostname */ | |
892fedb6 | 18128 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 18129 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 18130 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 18131 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
18132 | ? "" |
18133 | : "no "); | |
18134 | ||
aef999a2 DA |
18135 | /* BGP default show-nexthop-hostname */ |
18136 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
18137 | != SAVE_BGP_SHOW_HOSTNAME) | |
18138 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
18139 | CHECK_FLAG(bgp->flags, | |
18140 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
18141 | ? "" | |
18142 | : "no "); | |
18143 | ||
dd65f45e DL |
18144 | /* BGP default subgroup-pkt-queue-max. */ |
18145 | if (bgp->default_subgroup_pkt_queue_max | |
18146 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
18147 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
18148 | bgp->default_subgroup_pkt_queue_max); | |
18149 | ||
18150 | /* BGP client-to-client reflection. */ | |
892fedb6 | 18151 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
18152 | vty_out(vty, " no bgp client-to-client reflection\n"); |
18153 | ||
18154 | /* BGP cluster ID. */ | |
18155 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
18156 | vty_out(vty, " bgp cluster-id %pI4\n", |
18157 | &bgp->cluster_id); | |
dd65f45e DL |
18158 | |
18159 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 18160 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
18161 | vty_out(vty, |
18162 | " bgp disable-ebgp-connected-route-check\n"); | |
18163 | ||
18164 | /* Confederation identifier*/ | |
18165 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
18166 | vty_out(vty, " bgp confederation identifier %u\n", | |
18167 | bgp->confed_id); | |
18168 | ||
18169 | /* Confederation peer */ | |
18170 | if (bgp->confed_peers_cnt > 0) { | |
18171 | int i; | |
18172 | ||
18173 | vty_out(vty, " bgp confederation peers"); | |
18174 | ||
18175 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
18176 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
18177 | ||
18178 | vty_out(vty, "\n"); | |
18179 | } | |
18180 | ||
18181 | /* BGP deterministic-med. */ | |
892fedb6 | 18182 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 18183 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 18184 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
18185 | CHECK_FLAG(bgp->flags, |
18186 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
18187 | ? "" |
18188 | : "no "); | |
18189 | ||
18190 | /* BGP update-delay. */ | |
18191 | bgp_config_write_update_delay(vty, bgp); | |
18192 | ||
18193 | if (bgp->v_maxmed_onstartup | |
18194 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
18195 | vty_out(vty, " bgp max-med on-startup %u", | |
18196 | bgp->v_maxmed_onstartup); | |
18197 | if (bgp->maxmed_onstartup_value | |
18198 | != BGP_MAXMED_VALUE_DEFAULT) | |
18199 | vty_out(vty, " %u", | |
18200 | bgp->maxmed_onstartup_value); | |
18201 | vty_out(vty, "\n"); | |
18202 | } | |
18203 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
18204 | vty_out(vty, " bgp max-med administrative"); | |
18205 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
18206 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
18207 | vty_out(vty, "\n"); | |
18208 | } | |
18209 | ||
18210 | /* write quanta */ | |
18211 | bgp_config_write_wpkt_quanta(vty, bgp); | |
18212 | /* read quanta */ | |
18213 | bgp_config_write_rpkt_quanta(vty, bgp); | |
18214 | ||
18215 | /* coalesce time */ | |
18216 | bgp_config_write_coalesce_time(vty, bgp); | |
18217 | ||
05bd726c | 18218 | /* BGP per-instance graceful-shutdown */ |
18219 | /* BGP-wide settings and per-instance settings are mutually | |
18220 | * exclusive. | |
18221 | */ | |
18222 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
18223 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
18224 | vty_out(vty, " bgp graceful-shutdown\n"); | |
18225 | ||
8606be87 DA |
18226 | /* Long-lived Graceful Restart */ |
18227 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
18228 | vty_out(vty, | |
18229 | " bgp long-lived-graceful-restart stale-time %u\n", | |
18230 | bgp->llgr_stale_time); | |
18231 | ||
dd65f45e DL |
18232 | /* BGP graceful-restart. */ |
18233 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
18234 | vty_out(vty, | |
18235 | " bgp graceful-restart stalepath-time %u\n", | |
18236 | bgp->stalepath_time); | |
cfd47646 | 18237 | |
dd65f45e DL |
18238 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
18239 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
18240 | bgp->restart_time); | |
cfd47646 | 18241 | |
f2ca5c5b DA |
18242 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION) != |
18243 | SAVE_BGP_GRACEFUL_NOTIFICATION) | |
18244 | vty_out(vty, " %sbgp graceful-restart notification\n", | |
18245 | CHECK_FLAG(bgp->flags, | |
18246 | BGP_FLAG_GRACEFUL_NOTIFICATION) | |
18247 | ? "" | |
18248 | : "no "); | |
18249 | ||
cfd47646 | 18250 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) |
18251 | vty_out(vty, | |
18252 | " bgp graceful-restart select-defer-time %u\n", | |
18253 | bgp->select_defer_time); | |
18254 | ||
18255 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
18256 | vty_out(vty, " bgp graceful-restart\n"); |
18257 | ||
cfd47646 | 18258 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
18259 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
18260 | ||
dd65f45e | 18261 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 18262 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
18263 | vty_out(vty, |
18264 | " bgp graceful-restart preserve-fw-state\n"); | |
18265 | ||
d1adb448 PG |
18266 | /* BGP TCP keepalive */ |
18267 | bgp_config_tcp_keepalive(vty, bgp); | |
18268 | ||
dc95985f | 18269 | /* Stale timer for RIB */ |
18270 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
18271 | vty_out(vty, | |
18272 | " bgp graceful-restart rib-stale-time %u\n", | |
18273 | bgp->rib_stale_time); | |
18274 | ||
dd65f45e | 18275 | /* BGP bestpath method. */ |
892fedb6 | 18276 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 18277 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 18278 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
18279 | vty_out(vty, " bgp bestpath as-path confed\n"); |
18280 | ||
892fedb6 DA |
18281 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
18282 | if (CHECK_FLAG(bgp->flags, | |
18283 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
18284 | vty_out(vty, |
18285 | " bgp bestpath as-path multipath-relax as-set\n"); | |
18286 | } else { | |
18287 | vty_out(vty, | |
18288 | " bgp bestpath as-path multipath-relax\n"); | |
18289 | } | |
18290 | } | |
18291 | ||
892fedb6 | 18292 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
18293 | vty_out(vty, |
18294 | " bgp route-reflector allow-outbound-policy\n"); | |
18295 | } | |
892fedb6 | 18296 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 18297 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
97a52c82 DA |
18298 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_AIGP)) |
18299 | vty_out(vty, " bgp bestpath aigp\n"); | |
892fedb6 DA |
18300 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
18301 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 18302 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 18303 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 18304 | vty_out(vty, " confed"); |
892fedb6 DA |
18305 | if (CHECK_FLAG(bgp->flags, |
18306 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
18307 | vty_out(vty, " missing-as-worst"); |
18308 | vty_out(vty, "\n"); | |
18309 | } | |
18310 | ||
ee88563a JM |
18311 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
18312 | vty_out(vty, | |
18313 | " bgp bestpath peer-type multipath-relax\n"); | |
18314 | ||
f7e1c681 | 18315 | /* Link bandwidth handling. */ |
18316 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
18317 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
18318 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
18319 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
18320 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
18321 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
18322 | ||
dd65f45e | 18323 | /* BGP network import check. */ |
892fedb6 | 18324 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 18325 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 18326 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 18327 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
18328 | ? "" |
18329 | : "no "); | |
18330 | ||
18331 | /* BGP timers configuration. */ | |
5d5393b9 | 18332 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 18333 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
18334 | vty_out(vty, " timers bgp %u %u\n", |
18335 | bgp->default_keepalive, bgp->default_holdtime); | |
18336 | ||
b042667a TI |
18337 | /* BGP minimum holdtime configuration. */ |
18338 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
18339 | && bgp->default_min_holdtime != 0) | |
18340 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
18341 | bgp->default_min_holdtime); | |
18342 | ||
389e4f92 QY |
18343 | /* Conditional advertisement timer configuration */ |
18344 | if (bgp->condition_check_period | |
18345 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
18346 | vty_out(vty, | |
18347 | " bgp conditional-advertisement timer %u\n", | |
18348 | bgp->condition_check_period); | |
18349 | ||
dd65f45e DL |
18350 | /* peer-group */ |
18351 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
18352 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
18353 | } | |
18354 | ||
18355 | /* Normal neighbor configuration. */ | |
18356 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
18357 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
18358 | bgp_config_write_peer_global(vty, bgp, peer); | |
18359 | } | |
18360 | ||
18361 | /* listen range and limit for dynamic BGP neighbors */ | |
18362 | bgp_config_write_listen(vty, bgp); | |
18363 | ||
18364 | /* | |
18365 | * BGP default autoshutdown neighbors | |
18366 | * | |
18367 | * This must be placed after any peer and peer-group | |
18368 | * configuration, to avoid setting all peers to shutdown after | |
18369 | * a daemon restart, which is undesired behavior. (see #2286) | |
18370 | */ | |
18371 | if (bgp->autoshutdown) | |
18372 | vty_out(vty, " bgp default shutdown\n"); | |
18373 | ||
9cf59432 DS |
18374 | /* BGP instance administrative shutdown */ |
18375 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
18376 | vty_out(vty, " bgp shutdown\n"); | |
18377 | ||
8666265e DS |
18378 | if (bgp->allow_martian) |
18379 | vty_out(vty, " bgp allow-martian-nexthop\n"); | |
18380 | ||
f852eb98 PG |
18381 | if (bgp->fast_convergence) |
18382 | vty_out(vty, " bgp fast-convergence\n"); | |
18383 | ||
a0281b2e HS |
18384 | if (bgp->srv6_enabled) { |
18385 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 18386 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
18387 | vty_out(vty, " locator %s\n", |
18388 | bgp->srv6_locator_name); | |
ff7c3ee1 | 18389 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
18390 | } |
18391 | ||
efc9b57d CS |
18392 | tovpn_sid_index = bgp->tovpn_sid_index; |
18393 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) { | |
18394 | vty_out(vty, " sid vpn per-vrf export auto\n"); | |
18395 | } else if (tovpn_sid_index != 0) { | |
18396 | vty_out(vty, " sid vpn per-vrf export %d\n", | |
18397 | tovpn_sid_index); | |
18398 | } | |
a0281b2e | 18399 | |
dd65f45e DL |
18400 | /* IPv4 unicast configuration. */ |
18401 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
18402 | ||
18403 | /* IPv4 multicast configuration. */ | |
18404 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
18405 | ||
18406 | /* IPv4 labeled-unicast configuration. */ | |
18407 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
18408 | ||
18409 | /* IPv4 VPN configuration. */ | |
18410 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
18411 | ||
18412 | /* ENCAPv4 configuration. */ | |
18413 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
18414 | ||
18415 | /* FLOWSPEC v4 configuration. */ | |
18416 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
18417 | ||
18418 | /* IPv6 unicast configuration. */ | |
18419 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
18420 | ||
18421 | /* IPv6 multicast configuration. */ | |
18422 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
18423 | ||
18424 | /* IPv6 labeled-unicast configuration. */ | |
18425 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
18426 | SAFI_LABELED_UNICAST); | |
18427 | ||
18428 | /* IPv6 VPN configuration. */ | |
18429 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
18430 | ||
18431 | /* ENCAPv6 configuration. */ | |
18432 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
18433 | ||
18434 | /* FLOWSPEC v6 configuration. */ | |
18435 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
18436 | ||
18437 | /* EVPN configuration. */ | |
18438 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
18439 | ||
18440 | hook_call(bgp_inst_config_write, bgp, vty); | |
18441 | ||
49e5a4a0 | 18442 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
18443 | bgp_rfapi_cfg_write(vty, bgp); |
18444 | #endif | |
18445 | ||
07679ad9 | 18446 | vty_out(vty, "exit\n"); |
dd65f45e DL |
18447 | vty_out(vty, "!\n"); |
18448 | } | |
18449 | return 0; | |
18450 | } | |
18451 | ||
ddb5b488 | 18452 | |
718e3744 | 18453 | /* BGP node structure. */ |
d62a17ae | 18454 | static struct cmd_node bgp_node = { |
f4b8291f | 18455 | .name = "bgp", |
62b346ee | 18456 | .node = BGP_NODE, |
24389580 | 18457 | .parent_node = CONFIG_NODE, |
62b346ee | 18458 | .prompt = "%s(config-router)# ", |
612c2c15 | 18459 | .config_write = bgp_config_write, |
718e3744 | 18460 | }; |
18461 | ||
d62a17ae | 18462 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 18463 | .name = "bgp ipv4 unicast", |
62b346ee | 18464 | .node = BGP_IPV4_NODE, |
24389580 | 18465 | .parent_node = BGP_NODE, |
62b346ee | 18466 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18467 | .no_xpath = true, |
718e3744 | 18468 | }; |
18469 | ||
d62a17ae | 18470 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 18471 | .name = "bgp ipv4 multicast", |
62b346ee | 18472 | .node = BGP_IPV4M_NODE, |
24389580 | 18473 | .parent_node = BGP_NODE, |
62b346ee | 18474 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18475 | .no_xpath = true, |
718e3744 | 18476 | }; |
18477 | ||
d62a17ae | 18478 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 18479 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 18480 | .node = BGP_IPV4L_NODE, |
24389580 | 18481 | .parent_node = BGP_NODE, |
62b346ee | 18482 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18483 | .no_xpath = true, |
f51bae9c DS |
18484 | }; |
18485 | ||
d62a17ae | 18486 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 18487 | .name = "bgp ipv6 unicast", |
62b346ee | 18488 | .node = BGP_IPV6_NODE, |
24389580 | 18489 | .parent_node = BGP_NODE, |
62b346ee | 18490 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18491 | .no_xpath = true, |
718e3744 | 18492 | }; |
18493 | ||
d62a17ae | 18494 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 18495 | .name = "bgp ipv6 multicast", |
62b346ee | 18496 | .node = BGP_IPV6M_NODE, |
24389580 | 18497 | .parent_node = BGP_NODE, |
62b346ee | 18498 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18499 | .no_xpath = true, |
25ffbdc1 | 18500 | }; |
18501 | ||
d62a17ae | 18502 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 18503 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 18504 | .node = BGP_IPV6L_NODE, |
24389580 | 18505 | .parent_node = BGP_NODE, |
62b346ee | 18506 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18507 | .no_xpath = true, |
f51bae9c DS |
18508 | }; |
18509 | ||
62b346ee | 18510 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 18511 | .name = "bgp vpnv4", |
62b346ee | 18512 | .node = BGP_VPNV4_NODE, |
24389580 | 18513 | .parent_node = BGP_NODE, |
62b346ee | 18514 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18515 | .no_xpath = true, |
62b346ee | 18516 | }; |
6b0655a2 | 18517 | |
62b346ee | 18518 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 18519 | .name = "bgp vpnv6", |
62b346ee | 18520 | .node = BGP_VPNV6_NODE, |
24389580 | 18521 | .parent_node = BGP_NODE, |
62b346ee | 18522 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18523 | .no_xpath = true, |
62b346ee | 18524 | }; |
8ecd3266 | 18525 | |
62b346ee | 18526 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 18527 | .name = "bgp evpn", |
62b346ee | 18528 | .node = BGP_EVPN_NODE, |
24389580 | 18529 | .parent_node = BGP_NODE, |
62b346ee | 18530 | .prompt = "%s(config-router-evpn)# ", |
dd2c81b8 | 18531 | .no_xpath = true, |
62b346ee | 18532 | }; |
4e0b7b6d | 18533 | |
62b346ee | 18534 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 18535 | .name = "bgp evpn vni", |
62b346ee | 18536 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 18537 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 18538 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 18539 | }; |
90e60aa7 | 18540 | |
62b346ee | 18541 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 18542 | .name = "bgp ipv4 flowspec", |
62b346ee | 18543 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 18544 | .parent_node = BGP_NODE, |
62b346ee | 18545 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 18546 | .no_xpath = true, |
62b346ee | 18547 | }; |
7c40bf39 | 18548 | |
62b346ee | 18549 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 18550 | .name = "bgp ipv6 flowspec", |
62b346ee | 18551 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 18552 | .parent_node = BGP_NODE, |
62b346ee | 18553 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 18554 | .no_xpath = true, |
62b346ee | 18555 | }; |
7c40bf39 | 18556 | |
bfaab44d HS |
18557 | static struct cmd_node bgp_srv6_node = { |
18558 | .name = "bgp srv6", | |
18559 | .node = BGP_SRV6_NODE, | |
18560 | .parent_node = BGP_NODE, | |
18561 | .prompt = "%s(config-router-srv6)# ", | |
18562 | }; | |
18563 | ||
d62a17ae | 18564 | static void community_list_vty(void); |
1f8ae70b | 18565 | |
8c20061f DA |
18566 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
18567 | { | |
18568 | struct bgp *bgp; | |
18569 | struct peer_group *group; | |
18570 | struct listnode *lnbgp, *lnpeer; | |
18571 | ||
18572 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
18573 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
18574 | vector_set(comps, | |
18575 | XSTRDUP(MTYPE_COMPLETION, group->name)); | |
18576 | } | |
18577 | } | |
18578 | ||
18579 | static void bgp_ac_peer(vector comps, struct cmd_token *token) | |
b8a815e5 | 18580 | { |
d62a17ae | 18581 | struct bgp *bgp; |
18582 | struct peer *peer; | |
d62a17ae | 18583 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 18584 | |
d62a17ae | 18585 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
18586 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
18587 | /* only provide suggestions on the appropriate input | |
18588 | * token type, | |
18589 | * they'll otherwise show up multiple times */ | |
18590 | enum cmd_token_type match_type; | |
18591 | char *name = peer->host; | |
d48ed3e0 | 18592 | |
d62a17ae | 18593 | if (peer->conf_if) { |
18594 | match_type = VARIABLE_TKN; | |
18595 | name = peer->conf_if; | |
18596 | } else if (strchr(peer->host, ':')) | |
18597 | match_type = IPV6_TKN; | |
18598 | else | |
18599 | match_type = IPV4_TKN; | |
d48ed3e0 | 18600 | |
d62a17ae | 18601 | if (token->type != match_type) |
18602 | continue; | |
d48ed3e0 | 18603 | |
d62a17ae | 18604 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
18605 | } | |
d62a17ae | 18606 | } |
b8a815e5 DL |
18607 | } |
18608 | ||
8c20061f DA |
18609 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
18610 | { | |
18611 | bgp_ac_peer(comps, token); | |
84de1483 DA |
18612 | |
18613 | if (token->type == VARIABLE_TKN) | |
18614 | bgp_ac_peergroup(comps, token); | |
8c20061f DA |
18615 | } |
18616 | ||
b8a815e5 | 18617 | static const struct cmd_variable_handler bgp_var_neighbor[] = { |
d62a17ae | 18618 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
18619 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 18620 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 18621 | {.completions = NULL}}; |
18622 | ||
47a306a0 DS |
18623 | static const struct cmd_variable_handler bgp_var_peergroup[] = { |
18624 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
18625 | {.completions = NULL} }; | |
18626 | ||
aa24a36a DA |
18627 | DEFINE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp)); |
18628 | ||
18629 | static struct thread *t_bgp_cfg; | |
18630 | ||
18631 | bool bgp_config_inprocess(void) | |
18632 | { | |
18633 | return thread_is_scheduled(t_bgp_cfg); | |
18634 | } | |
18635 | ||
18636 | static void bgp_config_finish(struct thread *t) | |
18637 | { | |
18638 | struct listnode *node; | |
18639 | struct bgp *bgp; | |
18640 | ||
18641 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) | |
18642 | hook_call(bgp_config_end, bgp); | |
18643 | } | |
18644 | ||
18645 | static void bgp_config_start(void) | |
18646 | { | |
18647 | #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600 | |
18648 | THREAD_OFF(t_bgp_cfg); | |
18649 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18650 | BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg); | |
18651 | } | |
18652 | ||
18653 | /* When we receive a hook the configuration is read, | |
18654 | * we start a timer to make sure we postpone sending | |
18655 | * EoR before route-maps are processed. | |
18656 | * This is especially valid if using `bgp route-map delay-timer`. | |
18657 | */ | |
18658 | static void bgp_config_end(void) | |
18659 | { | |
18660 | #define BGP_POST_CONFIG_DELAY_SECONDS 1 | |
18661 | uint32_t bgp_post_config_delay = | |
18662 | thread_is_scheduled(bm->t_rmap_update) | |
18663 | ? thread_timer_remain_second(bm->t_rmap_update) | |
18664 | : BGP_POST_CONFIG_DELAY_SECONDS; | |
18665 | ||
18666 | /* If BGP config processing thread isn't running, then | |
18667 | * we can return and rely it's properly handled. | |
18668 | */ | |
18669 | if (!bgp_config_inprocess()) | |
18670 | return; | |
18671 | ||
18672 | THREAD_OFF(t_bgp_cfg); | |
18673 | ||
18674 | /* Start a new timer to make sure we don't send EoR | |
18675 | * before route-maps are processed. | |
18676 | */ | |
18677 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
18678 | bgp_post_config_delay, &t_bgp_cfg); | |
18679 | } | |
18680 | ||
4cd690ae PG |
18681 | static int config_write_interface_one(struct vty *vty, struct vrf *vrf) |
18682 | { | |
18683 | int write = 0; | |
18684 | struct interface *ifp; | |
18685 | struct bgp_interface *iifp; | |
18686 | ||
18687 | FOR_ALL_INTERFACES (vrf, ifp) { | |
18688 | iifp = ifp->info; | |
18689 | if (!iifp) | |
18690 | continue; | |
18691 | ||
18692 | if_vty_config_start(vty, ifp); | |
18693 | ||
18694 | if (CHECK_FLAG(iifp->flags, | |
18695 | BGP_INTERFACE_MPLS_BGP_FORWARDING)) { | |
18696 | vty_out(vty, " mpls bgp forwarding\n"); | |
18697 | write++; | |
18698 | } | |
18699 | ||
18700 | if_vty_config_end(vty); | |
18701 | } | |
18702 | ||
18703 | return write; | |
18704 | } | |
18705 | ||
18706 | /* Configuration write function for bgpd. */ | |
18707 | static int config_write_interface(struct vty *vty) | |
18708 | { | |
18709 | int write = 0; | |
18710 | struct vrf *vrf = NULL; | |
18711 | ||
18712 | /* Display all VRF aware OSPF interface configuration */ | |
18713 | RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { | |
18714 | write += config_write_interface_one(vty, vrf); | |
18715 | } | |
18716 | ||
18717 | return write; | |
18718 | } | |
18719 | ||
18720 | DEFPY(mpls_bgp_forwarding, mpls_bgp_forwarding_cmd, | |
18721 | "[no$no] mpls bgp forwarding", | |
18722 | NO_STR MPLS_STR BGP_STR | |
18723 | "Enable MPLS forwarding for eBGP directly connected peers\n") | |
18724 | { | |
18725 | bool check; | |
18726 | struct bgp_interface *iifp; | |
18727 | ||
18728 | VTY_DECLVAR_CONTEXT(interface, ifp); | |
18729 | iifp = ifp->info; | |
18730 | if (!iifp) { | |
18731 | vty_out(vty, "Interface %s not available\n", ifp->name); | |
18732 | return CMD_WARNING_CONFIG_FAILED; | |
18733 | } | |
18734 | check = CHECK_FLAG(iifp->flags, BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18735 | if (check != !no) { | |
18736 | if (no) | |
18737 | UNSET_FLAG(iifp->flags, | |
18738 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18739 | else | |
18740 | SET_FLAG(iifp->flags, | |
18741 | BGP_INTERFACE_MPLS_BGP_FORWARDING); | |
18742 | /* trigger a nht update on eBGP sessions */ | |
18743 | if (if_is_operative(ifp)) | |
18744 | bgp_nht_ifp_up(ifp); | |
18745 | } | |
18746 | return CMD_SUCCESS; | |
18747 | } | |
18748 | ||
a0b937de SW |
18749 | DEFPY (bgp_inq_limit, |
18750 | bgp_inq_limit_cmd, | |
18751 | "bgp input-queue-limit (1-4294967295)$limit", | |
18752 | BGP_STR | |
18753 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18754 | "Input-Queue limit\n") | |
18755 | { | |
18756 | bm->inq_limit = limit; | |
18757 | ||
18758 | return CMD_SUCCESS; | |
18759 | } | |
18760 | ||
18761 | DEFPY (no_bgp_inq_limit, | |
18762 | no_bgp_inq_limit_cmd, | |
18763 | "no bgp input-queue-limit [(1-4294967295)$limit]", | |
18764 | NO_STR | |
18765 | BGP_STR | |
18766 | "Set the BGP Input Queue limit for all peers when message parsing\n" | |
18767 | "Input-Queue limit\n") | |
18768 | { | |
963b7ee4 DS |
18769 | bm->inq_limit = BM_DEFAULT_Q_LIMIT; |
18770 | ||
18771 | return CMD_SUCCESS; | |
18772 | } | |
18773 | ||
18774 | DEFPY (bgp_outq_limit, | |
18775 | bgp_outq_limit_cmd, | |
18776 | "bgp output-queue-limit (1-4294967295)$limit", | |
18777 | BGP_STR | |
18778 | "Set the BGP Output Queue limit for all peers when message parsing\n" | |
18779 | "Output-Queue limit\n") | |
18780 | { | |
18781 | bm->outq_limit = limit; | |
a0b937de SW |
18782 | |
18783 | return CMD_SUCCESS; | |
18784 | } | |
18785 | ||
963b7ee4 DS |
18786 | DEFPY (no_bgp_outq_limit, |
18787 | no_bgp_outq_limit_cmd, | |
18788 | "no bgp output-queue-limit [(1-4294967295)$limit]", | |
18789 | NO_STR | |
18790 | BGP_STR | |
18791 | "Set the BGP Output Queue limit for all peers when message parsing\n" | |
18792 | "Output-Queue limit\n") | |
18793 | { | |
18794 | bm->outq_limit = BM_DEFAULT_Q_LIMIT; | |
a0b937de SW |
18795 | |
18796 | return CMD_SUCCESS; | |
18797 | } | |
18798 | ||
963b7ee4 | 18799 | |
4cd690ae PG |
18800 | /* Initialization of BGP interface. */ |
18801 | static void bgp_vty_if_init(void) | |
18802 | { | |
18803 | /* Install interface node. */ | |
18804 | if_cmd_init(config_write_interface); | |
18805 | ||
18806 | /* "mpls bgp forwarding" commands. */ | |
18807 | install_element(INTERFACE_NODE, &mpls_bgp_forwarding_cmd); | |
18808 | } | |
18809 | ||
d62a17ae | 18810 | void bgp_vty_init(void) |
18811 | { | |
18812 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 18813 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 18814 | |
aa24a36a DA |
18815 | cmd_init_config_callbacks(bgp_config_start, bgp_config_end); |
18816 | ||
d62a17ae | 18817 | /* Install bgp top node. */ |
612c2c15 DL |
18818 | install_node(&bgp_node); |
18819 | install_node(&bgp_ipv4_unicast_node); | |
18820 | install_node(&bgp_ipv4_multicast_node); | |
18821 | install_node(&bgp_ipv4_labeled_unicast_node); | |
18822 | install_node(&bgp_ipv6_unicast_node); | |
18823 | install_node(&bgp_ipv6_multicast_node); | |
18824 | install_node(&bgp_ipv6_labeled_unicast_node); | |
18825 | install_node(&bgp_vpnv4_node); | |
18826 | install_node(&bgp_vpnv6_node); | |
18827 | install_node(&bgp_evpn_node); | |
18828 | install_node(&bgp_evpn_vni_node); | |
18829 | install_node(&bgp_flowspecv4_node); | |
18830 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 18831 | install_node(&bgp_srv6_node); |
d62a17ae | 18832 | |
18833 | /* Install default VTY commands to new nodes. */ | |
18834 | install_default(BGP_NODE); | |
18835 | install_default(BGP_IPV4_NODE); | |
18836 | install_default(BGP_IPV4M_NODE); | |
18837 | install_default(BGP_IPV4L_NODE); | |
18838 | install_default(BGP_IPV6_NODE); | |
18839 | install_default(BGP_IPV6M_NODE); | |
18840 | install_default(BGP_IPV6L_NODE); | |
18841 | install_default(BGP_VPNV4_NODE); | |
18842 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 18843 | install_default(BGP_FLOWSPECV4_NODE); |
18844 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 18845 | install_default(BGP_EVPN_NODE); |
18846 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 18847 | install_default(BGP_SRV6_NODE); |
d62a17ae | 18848 | |
a0b937de SW |
18849 | /* "global bgp inq-limit command */ |
18850 | install_element(CONFIG_NODE, &bgp_inq_limit_cmd); | |
18851 | install_element(CONFIG_NODE, &no_bgp_inq_limit_cmd); | |
963b7ee4 DS |
18852 | install_element(CONFIG_NODE, &bgp_outq_limit_cmd); |
18853 | install_element(CONFIG_NODE, &no_bgp_outq_limit_cmd); | |
a0b937de | 18854 | |
8029b216 AK |
18855 | /* "bgp local-mac" hidden commands. */ |
18856 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
18857 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
18858 | ||
9acb67cb DS |
18859 | /* "bgp suppress-fib-pending" global */ |
18860 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
18861 | ||
d62a17ae | 18862 | /* bgp route-map delay-timer commands. */ |
18863 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18864 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18865 | ||
8666265e DS |
18866 | install_element(BGP_NODE, &bgp_allow_martian_cmd); |
18867 | ||
f852eb98 PG |
18868 | /* bgp fast-convergence command */ |
18869 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
18870 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
18871 | ||
d70583f7 D |
18872 | /* global bgp update-delay command */ |
18873 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
18874 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
18875 | ||
05bd726c | 18876 | /* global bgp graceful-shutdown command */ |
18877 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
18878 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
18879 | ||
d62a17ae | 18880 | /* Dummy commands (Currently not supported) */ |
18881 | install_element(BGP_NODE, &no_synchronization_cmd); | |
18882 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
18883 | ||
18884 | /* "router bgp" commands. */ | |
18885 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
18886 | ||
18887 | /* "no router bgp" commands. */ | |
18888 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
18889 | ||
425bd64b PS |
18890 | /* "bgp session-dscp command */ |
18891 | install_element(CONFIG_NODE, &bgp_session_dscp_cmd); | |
18892 | install_element(CONFIG_NODE, &no_bgp_session_dscp_cmd); | |
18893 | ||
d62a17ae | 18894 | /* "bgp router-id" commands. */ |
18895 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
18896 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
18897 | ||
c208c586 S |
18898 | /* "bgp suppress-fib-pending" command */ |
18899 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
18900 | ||
d62a17ae | 18901 | /* "bgp cluster-id" commands. */ |
18902 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
18903 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
18904 | ||
c163f297 DS |
18905 | /* "bgp no-rib" commands. */ |
18906 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
18907 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
18908 | ||
e46723a5 DS |
18909 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
18910 | ||
d62a17ae | 18911 | /* "bgp confederation" commands. */ |
18912 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
18913 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
18914 | ||
18915 | /* "bgp confederation peers" commands. */ | |
18916 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
18917 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
18918 | ||
18919 | /* bgp max-med command */ | |
18920 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
18921 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
18922 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
18923 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
18924 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
18925 | ||
d864dd9e EB |
18926 | /* "neighbor role" commands. */ |
18927 | install_element(BGP_NODE, &neighbor_role_cmd); | |
18928 | install_element(BGP_NODE, &neighbor_role_strict_cmd); | |
18929 | install_element(BGP_NODE, &no_neighbor_role_cmd); | |
18930 | ||
97a52c82 DA |
18931 | /* "neighbor aigp" commands. */ |
18932 | install_element(BGP_NODE, &neighbor_aigp_cmd); | |
18933 | ||
4f770cf1 DA |
18934 | /* "neighbor graceful-shutdown" command */ |
18935 | install_element(BGP_NODE, &neighbor_graceful_shutdown_cmd); | |
18936 | ||
d62a17ae | 18937 | /* bgp disable-ebgp-connected-nh-check */ |
18938 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
18939 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
18940 | ||
18941 | /* bgp update-delay command */ | |
18942 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
18943 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 18944 | |
18945 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 18946 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 18947 | |
18948 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
18949 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
18950 | ||
18951 | /* "maximum-paths" commands. */ | |
18952 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
18953 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
18954 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
18955 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
18956 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
18957 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
18958 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
18959 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
18960 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
18961 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
18962 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18963 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18964 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
18965 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18966 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18967 | ||
39edabac PG |
18968 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
18969 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
18970 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18971 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18972 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 18973 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
18974 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
18975 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
18976 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
18977 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
18978 | ||
18979 | /* "timers bgp" commands. */ | |
18980 | install_element(BGP_NODE, &bgp_timers_cmd); | |
18981 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
18982 | ||
b042667a TI |
18983 | /* "minimum-holdtime" commands. */ |
18984 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
18985 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
18986 | ||
d62a17ae | 18987 | /* route-map delay-timer commands - per instance for backwards compat. |
18988 | */ | |
18989 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
18990 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
18991 | ||
18992 | /* "bgp client-to-client reflection" commands */ | |
18993 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
18994 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
18995 | ||
18996 | /* "bgp always-compare-med" commands */ | |
18997 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
18998 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
18999 | ||
9dac9fc8 DA |
19000 | /* bgp ebgp-requires-policy */ |
19001 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
19002 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
19003 | ||
2adac256 DA |
19004 | /* bgp suppress-duplicates */ |
19005 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
19006 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
19007 | ||
fb29348a DA |
19008 | /* bgp reject-as-sets */ |
19009 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
19010 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
19011 | ||
d62a17ae | 19012 | /* "bgp deterministic-med" commands */ |
19013 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
19014 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
19015 | ||
055679e9 | 19016 | /* "bgp graceful-restart" command */ |
36235319 QY |
19017 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
19018 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 19019 | |
19020 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
19021 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
19022 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 19023 | |
19024 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
19025 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
19026 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 19027 | |
19028 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
19029 | install_element(BGP_NODE, | |
19030 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
19031 | install_element(BGP_NODE, | |
19032 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
19033 | ||
19034 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
19035 | install_element(BGP_NODE, | |
19036 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
19037 | install_element(BGP_NODE, | |
19038 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
19039 | ||
d62a17ae | 19040 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
19041 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
19042 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
19043 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 19044 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 19045 | install_element(BGP_NODE, |
19046 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 19047 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
19048 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
f2ca5c5b | 19049 | install_element(BGP_NODE, &bgp_graceful_restart_notification_cmd); |
d62a17ae | 19050 | |
d6e3c15b | 19051 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
19052 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 19053 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
19054 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 19055 | |
7f323236 DW |
19056 | /* "bgp graceful-shutdown" commands */ |
19057 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
19058 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
19059 | ||
1ae314be DA |
19060 | /* "bgp hard-administrative-reset" commands */ |
19061 | install_element(BGP_NODE, &bgp_administrative_reset_cmd); | |
19062 | ||
8606be87 DA |
19063 | /* "bgp long-lived-graceful-restart" commands */ |
19064 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
19065 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
19066 | ||
d62a17ae | 19067 | /* "bgp fast-external-failover" commands */ |
19068 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
19069 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
19070 | ||
97a52c82 DA |
19071 | /* "bgp bestpath aigp" commands */ |
19072 | install_element(BGP_NODE, &bgp_bestpath_aigp_cmd); | |
19073 | ||
d62a17ae | 19074 | /* "bgp bestpath compare-routerid" commands */ |
19075 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
19076 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
19077 | ||
19078 | /* "bgp bestpath as-path ignore" commands */ | |
19079 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
19080 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
19081 | ||
19082 | /* "bgp bestpath as-path confed" commands */ | |
19083 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
19084 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
19085 | ||
19086 | /* "bgp bestpath as-path multipath-relax" commands */ | |
19087 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
19088 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
19089 | ||
ee88563a JM |
19090 | /* "bgp bestpath peer-type multipath-relax" commands */ |
19091 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
19092 | install_element(BGP_NODE, | |
19093 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
19094 | ||
d62a17ae | 19095 | /* "bgp log-neighbor-changes" commands */ |
19096 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
19097 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
19098 | ||
19099 | /* "bgp bestpath med" commands */ | |
19100 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
19101 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
19102 | ||
f7e1c681 | 19103 | /* "bgp bestpath bandwidth" commands */ |
19104 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 19105 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 19106 | |
b16bcbba TA |
19107 | /* "no bgp default <afi>-<safi>" commands. */ |
19108 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 19109 | |
d62a17ae | 19110 | /* "bgp network import-check" commands. */ |
19111 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
19112 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
19113 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
19114 | ||
19115 | /* "bgp default local-preference" commands. */ | |
19116 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
19117 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
19118 | ||
19119 | /* bgp default show-hostname */ | |
19120 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
19121 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
19122 | ||
aef999a2 DA |
19123 | /* bgp default show-nexthop-hostname */ |
19124 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
19125 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
19126 | ||
d62a17ae | 19127 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
19128 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
19129 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
19130 | ||
19131 | /* bgp ibgp-allow-policy-mods command */ | |
19132 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
19133 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
19134 | ||
19135 | /* "bgp listen limit" commands. */ | |
19136 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
19137 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
19138 | ||
19139 | /* "bgp listen range" commands. */ | |
19140 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
19141 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
19142 | ||
8175f54a | 19143 | /* "bgp default shutdown" command */ |
f26845f9 | 19144 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
19145 | |
19146 | /* "bgp shutdown" commands */ | |
19147 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 19148 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 19149 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 19150 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 19151 | |
d62a17ae | 19152 | /* "neighbor remote-as" commands. */ |
19153 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
19154 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
19155 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
19156 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
19157 | install_element(BGP_NODE, | |
19158 | &neighbor_interface_v6only_config_remote_as_cmd); | |
19159 | install_element(BGP_NODE, &no_neighbor_cmd); | |
19160 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
19161 | ||
19162 | /* "neighbor peer-group" commands. */ | |
19163 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
19164 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
19165 | install_element(BGP_NODE, | |
19166 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
19167 | ||
19168 | /* "neighbor local-as" commands. */ | |
19169 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
19170 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
19171 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
19172 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
19173 | ||
19174 | /* "neighbor solo" commands. */ | |
19175 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
19176 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
19177 | ||
19178 | /* "neighbor password" commands. */ | |
19179 | install_element(BGP_NODE, &neighbor_password_cmd); | |
19180 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
19181 | ||
19182 | /* "neighbor activate" commands. */ | |
19183 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
19184 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
19185 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
19186 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
19187 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
19188 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
19189 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
19190 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
19191 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 19192 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
19193 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 19194 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
19195 | ||
19196 | /* "no neighbor activate" commands. */ | |
19197 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
19198 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
19199 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
19200 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
19201 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
19202 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
19203 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
19204 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
19205 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 19206 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
19207 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 19208 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
19209 | ||
19210 | /* "neighbor peer-group" set commands. */ | |
19211 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
19212 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19213 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19214 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19215 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19216 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19217 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
19218 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 19219 | install_element(BGP_FLOWSPECV4_NODE, |
19220 | &neighbor_set_peer_group_hidden_cmd); | |
19221 | install_element(BGP_FLOWSPECV6_NODE, | |
19222 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 19223 | |
19224 | /* "no neighbor peer-group unset" commands. */ | |
19225 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
19226 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19227 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19228 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19229 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19230 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19231 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
19232 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 19233 | install_element(BGP_FLOWSPECV4_NODE, |
19234 | &no_neighbor_set_peer_group_hidden_cmd); | |
19235 | install_element(BGP_FLOWSPECV6_NODE, | |
19236 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 19237 | |
19238 | /* "neighbor softreconfiguration inbound" commands.*/ | |
19239 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
19240 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
19241 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
19242 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19243 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
19244 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19245 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
19246 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19247 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
19248 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19249 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
19250 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19251 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
19252 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19253 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
19254 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
19255 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
19256 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 19257 | install_element(BGP_FLOWSPECV4_NODE, |
19258 | &neighbor_soft_reconfiguration_cmd); | |
19259 | install_element(BGP_FLOWSPECV4_NODE, | |
19260 | &no_neighbor_soft_reconfiguration_cmd); | |
19261 | install_element(BGP_FLOWSPECV6_NODE, | |
19262 | &neighbor_soft_reconfiguration_cmd); | |
19263 | install_element(BGP_FLOWSPECV6_NODE, | |
19264 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
19265 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
19266 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 19267 | |
19268 | /* "neighbor attribute-unchanged" commands. */ | |
19269 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
19270 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
19271 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
19272 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19273 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
19274 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
19275 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
19276 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
19277 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
19278 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19279 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
19280 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
19281 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
19282 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
19283 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
19284 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19285 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
19286 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19287 | ||
19288 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
19289 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
19290 | ||
b8ad84d2 PG |
19291 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
19292 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
19293 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
19294 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
19295 | ||
d62a17ae | 19296 | /* "nexthop-local unchanged" commands */ |
19297 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
19298 | install_element(BGP_IPV6_NODE, | |
19299 | &no_neighbor_nexthop_local_unchanged_cmd); | |
19300 | ||
19301 | /* "neighbor next-hop-self" commands. */ | |
19302 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
19303 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
19304 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
19305 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19306 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
19307 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
19308 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
19309 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
19310 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
19311 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
19312 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
19313 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
19314 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
19315 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
19316 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
19317 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
19318 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
19319 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
19320 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
19321 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 19322 | |
19323 | /* "neighbor next-hop-self force" commands. */ | |
19324 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
19325 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
19326 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19327 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19328 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
19329 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19330 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19331 | install_element(BGP_IPV4_NODE, | |
19332 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19333 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
19334 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19335 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19336 | install_element(BGP_IPV4M_NODE, | |
19337 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19338 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
19339 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19340 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19341 | install_element(BGP_IPV4L_NODE, | |
19342 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19343 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
19344 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19345 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19346 | install_element(BGP_IPV6_NODE, | |
19347 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19348 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
19349 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19350 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19351 | install_element(BGP_IPV6M_NODE, | |
19352 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19353 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
19354 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19355 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19356 | install_element(BGP_IPV6L_NODE, | |
19357 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19358 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
19359 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19360 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19361 | install_element(BGP_VPNV4_NODE, | |
19362 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 19363 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
19364 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
19365 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
19366 | install_element(BGP_VPNV6_NODE, | |
19367 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
19368 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
19369 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 19370 | |
19371 | /* "neighbor as-override" commands. */ | |
19372 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
19373 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
19374 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
19375 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
19376 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
19377 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
19378 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
19379 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
19380 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
19381 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
19382 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
19383 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
19384 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
19385 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
19386 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
19387 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
19388 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
19389 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
19390 | ||
19391 | /* "neighbor remove-private-AS" commands. */ | |
19392 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
19393 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
19394 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
19395 | install_element(BGP_NODE, | |
19396 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
19397 | install_element(BGP_NODE, | |
19398 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
19399 | install_element(BGP_NODE, | |
19400 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
19401 | install_element(BGP_NODE, | |
19402 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19403 | install_element( | |
19404 | BGP_NODE, | |
19405 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
19406 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
19407 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19408 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19409 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19410 | install_element(BGP_IPV4_NODE, | |
19411 | &neighbor_remove_private_as_replace_as_cmd); | |
19412 | install_element(BGP_IPV4_NODE, | |
19413 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19414 | install_element(BGP_IPV4_NODE, | |
19415 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19416 | install_element(BGP_IPV4_NODE, | |
19417 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19418 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
19419 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
19420 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
19421 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19422 | install_element(BGP_IPV4M_NODE, | |
19423 | &neighbor_remove_private_as_replace_as_cmd); | |
19424 | install_element(BGP_IPV4M_NODE, | |
19425 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19426 | install_element(BGP_IPV4M_NODE, | |
19427 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19428 | install_element(BGP_IPV4M_NODE, | |
19429 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19430 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
19431 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
19432 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
19433 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19434 | install_element(BGP_IPV4L_NODE, | |
19435 | &neighbor_remove_private_as_replace_as_cmd); | |
19436 | install_element(BGP_IPV4L_NODE, | |
19437 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19438 | install_element(BGP_IPV4L_NODE, | |
19439 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19440 | install_element(BGP_IPV4L_NODE, | |
19441 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19442 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
19443 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19444 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19445 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19446 | install_element(BGP_IPV6_NODE, | |
19447 | &neighbor_remove_private_as_replace_as_cmd); | |
19448 | install_element(BGP_IPV6_NODE, | |
19449 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19450 | install_element(BGP_IPV6_NODE, | |
19451 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19452 | install_element(BGP_IPV6_NODE, | |
19453 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19454 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
19455 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
19456 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
19457 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19458 | install_element(BGP_IPV6M_NODE, | |
19459 | &neighbor_remove_private_as_replace_as_cmd); | |
19460 | install_element(BGP_IPV6M_NODE, | |
19461 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19462 | install_element(BGP_IPV6M_NODE, | |
19463 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19464 | install_element(BGP_IPV6M_NODE, | |
19465 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19466 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
19467 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
19468 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
19469 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19470 | install_element(BGP_IPV6L_NODE, | |
19471 | &neighbor_remove_private_as_replace_as_cmd); | |
19472 | install_element(BGP_IPV6L_NODE, | |
19473 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19474 | install_element(BGP_IPV6L_NODE, | |
19475 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19476 | install_element(BGP_IPV6L_NODE, | |
19477 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19478 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
19479 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
19480 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
19481 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19482 | install_element(BGP_VPNV4_NODE, | |
19483 | &neighbor_remove_private_as_replace_as_cmd); | |
19484 | install_element(BGP_VPNV4_NODE, | |
19485 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19486 | install_element(BGP_VPNV4_NODE, | |
19487 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19488 | install_element(BGP_VPNV4_NODE, | |
19489 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19490 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
19491 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
19492 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
19493 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
19494 | install_element(BGP_VPNV6_NODE, | |
19495 | &neighbor_remove_private_as_replace_as_cmd); | |
19496 | install_element(BGP_VPNV6_NODE, | |
19497 | &no_neighbor_remove_private_as_replace_as_cmd); | |
19498 | install_element(BGP_VPNV6_NODE, | |
19499 | &neighbor_remove_private_as_all_replace_as_cmd); | |
19500 | install_element(BGP_VPNV6_NODE, | |
19501 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
19502 | ||
19503 | /* "neighbor send-community" commands.*/ | |
19504 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
19505 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
19506 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
19507 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
19508 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
19509 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
19510 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
19511 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
19512 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
19513 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
19514 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
19515 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
19516 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
19517 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
19518 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
19519 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
19520 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
19521 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
19522 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
19523 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
19524 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
19525 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
19526 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
19527 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
19528 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
19529 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
19530 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
19531 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
19532 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
19533 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
19534 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
19535 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
19536 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
19537 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
19538 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
19539 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
19540 | ||
19541 | /* "neighbor route-reflector" commands.*/ | |
19542 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
19543 | install_element(BGP_NODE, | |
19544 | &no_neighbor_route_reflector_client_hidden_cmd); | |
19545 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
19546 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
19547 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
19548 | install_element(BGP_IPV4M_NODE, | |
19549 | &no_neighbor_route_reflector_client_cmd); | |
19550 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
19551 | install_element(BGP_IPV4L_NODE, | |
19552 | &no_neighbor_route_reflector_client_cmd); | |
19553 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
19554 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
19555 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
19556 | install_element(BGP_IPV6M_NODE, | |
19557 | &no_neighbor_route_reflector_client_cmd); | |
19558 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
19559 | install_element(BGP_IPV6L_NODE, | |
19560 | &no_neighbor_route_reflector_client_cmd); | |
19561 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
19562 | install_element(BGP_VPNV4_NODE, | |
19563 | &no_neighbor_route_reflector_client_cmd); | |
19564 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
19565 | install_element(BGP_VPNV6_NODE, | |
19566 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 19567 | install_element(BGP_FLOWSPECV4_NODE, |
19568 | &neighbor_route_reflector_client_cmd); | |
19569 | install_element(BGP_FLOWSPECV4_NODE, | |
19570 | &no_neighbor_route_reflector_client_cmd); | |
19571 | install_element(BGP_FLOWSPECV6_NODE, | |
19572 | &neighbor_route_reflector_client_cmd); | |
19573 | install_element(BGP_FLOWSPECV6_NODE, | |
19574 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 19575 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
19576 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
19577 | ||
19578 | /* "neighbor route-server" commands.*/ | |
19579 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
19580 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
19581 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
19582 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
19583 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
19584 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
19585 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
19586 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
19587 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
19588 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
19589 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
19590 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
19591 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
19592 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
19593 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
19594 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
19595 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
19596 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
19597 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
19598 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 19599 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
19600 | install_element(BGP_FLOWSPECV4_NODE, | |
19601 | &no_neighbor_route_server_client_cmd); | |
19602 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
19603 | install_element(BGP_FLOWSPECV6_NODE, | |
19604 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 19605 | |
7c0e4312 DA |
19606 | /* "neighbor disable-addpath-rx" commands. */ |
19607 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19608 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19609 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19610 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19611 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19612 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19613 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19614 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19615 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
19616 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19617 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
19618 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19619 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
19620 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19621 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
19622 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
19623 | ||
d62a17ae | 19624 | /* "neighbor addpath-tx-all-paths" commands.*/ |
19625 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
19626 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
19627 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19628 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19629 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19630 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19631 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19632 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19633 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19634 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19635 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19636 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19637 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19638 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19639 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19640 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19641 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
19642 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
19643 | ||
19644 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
19645 | install_element(BGP_NODE, | |
19646 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19647 | install_element(BGP_NODE, | |
19648 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
19649 | install_element(BGP_IPV4_NODE, | |
19650 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19651 | install_element(BGP_IPV4_NODE, | |
19652 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19653 | install_element(BGP_IPV4M_NODE, | |
19654 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19655 | install_element(BGP_IPV4M_NODE, | |
19656 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19657 | install_element(BGP_IPV4L_NODE, | |
19658 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19659 | install_element(BGP_IPV4L_NODE, | |
19660 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19661 | install_element(BGP_IPV6_NODE, | |
19662 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19663 | install_element(BGP_IPV6_NODE, | |
19664 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19665 | install_element(BGP_IPV6M_NODE, | |
19666 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19667 | install_element(BGP_IPV6M_NODE, | |
19668 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19669 | install_element(BGP_IPV6L_NODE, | |
19670 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19671 | install_element(BGP_IPV6L_NODE, | |
19672 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19673 | install_element(BGP_VPNV4_NODE, | |
19674 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19675 | install_element(BGP_VPNV4_NODE, | |
19676 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19677 | install_element(BGP_VPNV6_NODE, | |
19678 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
19679 | install_element(BGP_VPNV6_NODE, | |
19680 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
19681 | ||
2b31007c RZ |
19682 | /* "neighbor sender-as-path-loop-detection" commands. */ |
19683 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
19684 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
19685 | ||
a5c6a9b1 DA |
19686 | /* "neighbor path-attribute discard" commands. */ |
19687 | install_element(BGP_NODE, &neighbor_path_attribute_discard_cmd); | |
b986d7f4 | 19688 | install_element(BGP_NODE, &no_neighbor_path_attribute_discard_cmd); |
a5c6a9b1 | 19689 | |
d62a17ae | 19690 | /* "neighbor passive" commands. */ |
19691 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
19692 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
19693 | ||
19694 | ||
19695 | /* "neighbor shutdown" commands. */ | |
19696 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
19697 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
19698 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
19699 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
19700 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
19701 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 19702 | |
19703 | /* "neighbor capability extended-nexthop" commands.*/ | |
19704 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
19705 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
19706 | ||
19707 | /* "neighbor capability orf prefix-list" commands.*/ | |
19708 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
19709 | install_element(BGP_NODE, | |
19710 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
19711 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
19712 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19713 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19714 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19715 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19716 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19717 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
19718 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19719 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
19720 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19721 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
19722 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
19723 | ||
19724 | /* "neighbor capability dynamic" commands.*/ | |
19725 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
19726 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
19727 | ||
19728 | /* "neighbor dont-capability-negotiate" commands. */ | |
19729 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
19730 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
19731 | ||
19732 | /* "neighbor ebgp-multihop" commands. */ | |
19733 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
19734 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
19735 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
19736 | ||
19737 | /* "neighbor disable-connected-check" commands. */ | |
19738 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
19739 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
19740 | ||
7ab294ea DA |
19741 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
19742 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
19743 | install_element(BGP_NODE, | |
19744 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 19745 | |
d08c0c80 DA |
19746 | /* "neighbor extended-optional-parameters" commands. */ |
19747 | install_element(BGP_NODE, &neighbor_extended_optional_parameters_cmd); | |
19748 | install_element(BGP_NODE, | |
19749 | &no_neighbor_extended_optional_parameters_cmd); | |
19750 | ||
47cbc09b PM |
19751 | /* "neighbor enforce-first-as" commands. */ |
19752 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
19753 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
19754 | ||
d62a17ae | 19755 | /* "neighbor description" commands. */ |
19756 | install_element(BGP_NODE, &neighbor_description_cmd); | |
19757 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 19758 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 19759 | |
19760 | /* "neighbor update-source" commands. "*/ | |
19761 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
19762 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
19763 | ||
19764 | /* "neighbor default-originate" commands. */ | |
19765 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
19766 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
19767 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
19768 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
19769 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
19770 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
19771 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
19772 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
19773 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
19774 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
19775 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
19776 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
19777 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
19778 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
19779 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
19780 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
19781 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
19782 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
19783 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
19784 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
19785 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
19786 | ||
19787 | /* "neighbor port" commands. */ | |
19788 | install_element(BGP_NODE, &neighbor_port_cmd); | |
19789 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
19790 | ||
19791 | /* "neighbor weight" commands. */ | |
19792 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
19793 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
19794 | ||
19795 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
19796 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
19797 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
19798 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
19799 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
19800 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
19801 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
19802 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
19803 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
19804 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
19805 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
19806 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
19807 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
19808 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
19809 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
19810 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
19811 | ||
19812 | /* "neighbor override-capability" commands. */ | |
19813 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
19814 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
19815 | ||
19816 | /* "neighbor strict-capability-match" commands. */ | |
19817 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
19818 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
19819 | ||
19820 | /* "neighbor timers" commands. */ | |
19821 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
19822 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
19823 | ||
19824 | /* "neighbor timers connect" commands. */ | |
19825 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
19826 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
19827 | ||
d43114f3 DS |
19828 | /* "neighbor timers delayopen" commands. */ |
19829 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
19830 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
19831 | ||
d62a17ae | 19832 | /* "neighbor advertisement-interval" commands. */ |
19833 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
19834 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
19835 | ||
19836 | /* "neighbor interface" commands. */ | |
19837 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
19838 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
19839 | ||
19840 | /* "neighbor distribute" commands. */ | |
19841 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
19842 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
19843 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
19844 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
19845 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
19846 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
19847 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
19848 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
19849 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
19850 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
19851 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
19852 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
19853 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
19854 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
19855 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
19856 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
19857 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
19858 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
19859 | ||
19860 | /* "neighbor prefix-list" commands. */ | |
19861 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 19862 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 19863 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19864 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19865 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19866 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19867 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19868 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19869 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19870 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19871 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19872 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19873 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19874 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19875 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19876 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19877 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19878 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19879 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19880 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 19881 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 19882 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 19883 | |
19884 | /* "neighbor filter-list" commands. */ | |
19885 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
19886 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
19887 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
19888 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
19889 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
19890 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
19891 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
19892 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
19893 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
19894 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
19895 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
19896 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
19897 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
19898 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
19899 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
19900 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
19901 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
19902 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 19903 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
19904 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
19905 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
19906 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 19907 | |
19908 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
19909 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
19910 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 19911 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19912 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19913 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19914 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19915 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19916 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19917 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19918 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19919 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19920 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19921 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19922 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19923 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19924 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19925 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19926 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19927 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19928 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 19929 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19930 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 19931 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 19932 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 19933 | |
19934 | /* "neighbor unsuppress-map" commands. */ | |
19935 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
19936 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
19937 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
19938 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19939 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
19940 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19941 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
19942 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19943 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
19944 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19945 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
19946 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
19947 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
19948 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
19949 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
19950 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
19951 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
19952 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
19953 | ||
7f7940e6 | 19954 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 19955 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 19956 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 19957 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19958 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19959 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19960 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19961 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19962 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19963 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19964 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 19965 | |
fde246e8 DA |
19966 | /* neighbor maximum-prefix-out commands. */ |
19967 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
19968 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19969 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19970 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19971 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19972 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19973 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19974 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19975 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19976 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19977 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
19978 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19979 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
19980 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19981 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
19982 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19983 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
19984 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
19985 | ||
d62a17ae | 19986 | /* "neighbor maximum-prefix" commands. */ |
19987 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
19988 | install_element(BGP_NODE, | |
19989 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
19990 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
19991 | install_element(BGP_NODE, | |
19992 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
19993 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
19994 | install_element(BGP_NODE, | |
19995 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
19996 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
19997 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
19998 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19999 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20000 | install_element(BGP_IPV4_NODE, | |
20001 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20002 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20003 | install_element(BGP_IPV4_NODE, | |
20004 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20005 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
20006 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
20007 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
20008 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20009 | install_element(BGP_IPV4M_NODE, | |
20010 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20011 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20012 | install_element(BGP_IPV4M_NODE, | |
20013 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20014 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
20015 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
20016 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
20017 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20018 | install_element(BGP_IPV4L_NODE, | |
20019 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20020 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20021 | install_element(BGP_IPV4L_NODE, | |
20022 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20023 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
20024 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
20025 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
20026 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20027 | install_element(BGP_IPV6_NODE, | |
20028 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20029 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20030 | install_element(BGP_IPV6_NODE, | |
20031 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20032 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
20033 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
20034 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
20035 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20036 | install_element(BGP_IPV6M_NODE, | |
20037 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20038 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20039 | install_element(BGP_IPV6M_NODE, | |
20040 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20041 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
20042 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
20043 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
20044 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20045 | install_element(BGP_IPV6L_NODE, | |
20046 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20047 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20048 | install_element(BGP_IPV6L_NODE, | |
20049 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20050 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
20051 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
20052 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
20053 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20054 | install_element(BGP_VPNV4_NODE, | |
20055 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20056 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20057 | install_element(BGP_VPNV4_NODE, | |
20058 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20059 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
20060 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
20061 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
20062 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
20063 | install_element(BGP_VPNV6_NODE, | |
20064 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
20065 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
20066 | install_element(BGP_VPNV6_NODE, | |
20067 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
20068 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
20069 | ||
20070 | /* "neighbor allowas-in" */ | |
20071 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
20072 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
20073 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
20074 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
20075 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
20076 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
20077 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
20078 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
20079 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
20080 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
20081 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
20082 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
20083 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
20084 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
20085 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
20086 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
20087 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
20088 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
20089 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
20090 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
20091 | ||
46dbf9d0 DA |
20092 | /* neighbor accept-own */ |
20093 | install_element(BGP_VPNV4_NODE, &neighbor_accept_own_cmd); | |
20094 | install_element(BGP_VPNV6_NODE, &neighbor_accept_own_cmd); | |
20095 | ||
01da2d26 DA |
20096 | /* "neighbor soo" */ |
20097 | install_element(BGP_IPV4_NODE, &neighbor_soo_cmd); | |
20098 | install_element(BGP_IPV4_NODE, &no_neighbor_soo_cmd); | |
20099 | install_element(BGP_IPV4M_NODE, &neighbor_soo_cmd); | |
20100 | install_element(BGP_IPV4M_NODE, &no_neighbor_soo_cmd); | |
20101 | install_element(BGP_IPV4L_NODE, &neighbor_soo_cmd); | |
20102 | install_element(BGP_IPV4L_NODE, &no_neighbor_soo_cmd); | |
20103 | install_element(BGP_IPV6_NODE, &neighbor_soo_cmd); | |
20104 | install_element(BGP_IPV6_NODE, &no_neighbor_soo_cmd); | |
20105 | install_element(BGP_IPV6M_NODE, &neighbor_soo_cmd); | |
20106 | install_element(BGP_IPV6M_NODE, &no_neighbor_soo_cmd); | |
20107 | install_element(BGP_IPV6L_NODE, &neighbor_soo_cmd); | |
20108 | install_element(BGP_IPV6L_NODE, &no_neighbor_soo_cmd); | |
20109 | install_element(BGP_VPNV4_NODE, &neighbor_soo_cmd); | |
20110 | install_element(BGP_VPNV4_NODE, &no_neighbor_soo_cmd); | |
20111 | install_element(BGP_VPNV6_NODE, &neighbor_soo_cmd); | |
20112 | install_element(BGP_VPNV6_NODE, &no_neighbor_soo_cmd); | |
20113 | install_element(BGP_EVPN_NODE, &neighbor_soo_cmd); | |
20114 | install_element(BGP_EVPN_NODE, &no_neighbor_soo_cmd); | |
20115 | ||
d62a17ae | 20116 | /* address-family commands. */ |
20117 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
20118 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 20119 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 20120 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
20121 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 20122 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 20123 | |
d62a17ae | 20124 | install_element(BGP_NODE, &address_family_evpn_cmd); |
20125 | ||
20126 | /* "exit-address-family" command. */ | |
20127 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
20128 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
20129 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
20130 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
20131 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
20132 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
20133 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
20134 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 20135 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
20136 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 20137 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
20138 | ||
a486300b PG |
20139 | /* BGP retain all route-target */ |
20140 | install_element(BGP_VPNV4_NODE, &bgp_retain_route_target_cmd); | |
20141 | install_element(BGP_VPNV6_NODE, &bgp_retain_route_target_cmd); | |
20142 | ||
d62a17ae | 20143 | /* "clear ip bgp commands" */ |
20144 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
20145 | ||
20146 | /* clear ip bgp prefix */ | |
20147 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
20148 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
20149 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
20150 | ||
20151 | /* "show [ip] bgp summary" commands. */ | |
20152 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 20153 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 20154 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 20155 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 20156 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
20157 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 20158 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
20159 | ||
20160 | /* "show [ip] bgp neighbors" commands. */ | |
20161 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
20162 | ||
36235319 | 20163 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 20164 | |
d62a17ae | 20165 | /* "show [ip] bgp peer-group" commands. */ |
20166 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
20167 | ||
20168 | /* "show [ip] bgp paths" commands. */ | |
20169 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
20170 | ||
20171 | /* "show [ip] bgp community" commands. */ | |
20172 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
20173 | ||
20174 | /* "show ip bgp large-community" commands. */ | |
20175 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
20176 | /* "show [ip] bgp attribute-info" commands. */ | |
20177 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 20178 | /* "show [ip] bgp route-leak" command */ |
20179 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 20180 | |
20181 | /* "redistribute" commands. */ | |
20182 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
20183 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
20184 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
20185 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
20186 | install_element(BGP_NODE, | |
20187 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
20188 | install_element(BGP_NODE, | |
20189 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
20190 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
20191 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
20192 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
20193 | install_element(BGP_NODE, | |
20194 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
20195 | install_element(BGP_NODE, | |
20196 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
20197 | install_element(BGP_NODE, | |
20198 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
20199 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
20200 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
20201 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
20202 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
20203 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
20204 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
20205 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
20206 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
20207 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
20208 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
20209 | install_element(BGP_IPV4_NODE, | |
20210 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
20211 | install_element(BGP_IPV4_NODE, | |
20212 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
20213 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
20214 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
20215 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
20216 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
20217 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
20218 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
20219 | ||
70dd370f | 20220 | /* import|export vpn [route-map RMAP_NAME] */ |
b9c7bc5a PZ |
20221 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); |
20222 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 20223 | |
12a844a5 DS |
20224 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
20225 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
20226 | ||
d62a17ae | 20227 | /* ttl_security commands */ |
20228 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
20229 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
20230 | ||
d1adb448 PG |
20231 | /* "bgp tcp-keepalive" commands */ |
20232 | install_element(BGP_NODE, &bgp_tcp_keepalive_cmd); | |
20233 | install_element(BGP_NODE, &no_bgp_tcp_keepalive_cmd); | |
20234 | ||
d62a17ae | 20235 | /* "show [ip] bgp memory" commands. */ |
20236 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
20237 | ||
acf71666 MK |
20238 | /* "show bgp martian next-hop" */ |
20239 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
20240 | ||
48ecf8f5 DS |
20241 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
20242 | ||
d62a17ae | 20243 | /* "show [ip] bgp views" commands. */ |
20244 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
20245 | ||
20246 | /* "show [ip] bgp vrfs" commands. */ | |
20247 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
20248 | ||
20249 | /* Community-list. */ | |
20250 | community_list_vty(); | |
ddb5b488 | 20251 | |
ed0e57e3 DA |
20252 | community_alias_vty(); |
20253 | ||
ddb5b488 | 20254 | /* vpn-policy commands */ |
b9c7bc5a PZ |
20255 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
20256 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
20257 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
20258 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
20259 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
20260 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
20261 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
20262 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
20263 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
20264 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20265 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
20266 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 20267 | |
301ad80a PG |
20268 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
20269 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
20270 | ||
b9c7bc5a PZ |
20271 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
20272 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
20273 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
20274 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
20275 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
20276 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
20277 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
20278 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
20279 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
20280 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
20281 | |
20282 | /* tcp-mss command */ | |
20283 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
20284 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
20285 | |
20286 | /* srv6 commands */ | |
ea372e81 | 20287 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 20288 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 20289 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 20290 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 20291 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
20292 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
20293 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
527588aa | 20294 | install_element(BGP_NODE, &bgp_sid_vpn_export_cmd); |
e606d8ec | 20295 | install_element(BGP_NODE, &no_bgp_sid_vpn_export_cmd); |
4cd690ae PG |
20296 | |
20297 | bgp_vty_if_init(); | |
718e3744 | 20298 | } |
6b0655a2 | 20299 | |
718e3744 | 20300 | #include "memory.h" |
20301 | #include "bgp_regex.h" | |
20302 | #include "bgp_clist.h" | |
20303 | #include "bgp_ecommunity.h" | |
20304 | ||
20305 | /* VTY functions. */ | |
20306 | ||
20307 | /* Direction value to string conversion. */ | |
d62a17ae | 20308 | static const char *community_direct_str(int direct) |
20309 | { | |
20310 | switch (direct) { | |
20311 | case COMMUNITY_DENY: | |
20312 | return "deny"; | |
20313 | case COMMUNITY_PERMIT: | |
20314 | return "permit"; | |
20315 | default: | |
20316 | return "unknown"; | |
20317 | } | |
718e3744 | 20318 | } |
20319 | ||
20320 | /* Display error string. */ | |
d62a17ae | 20321 | static void community_list_perror(struct vty *vty, int ret) |
20322 | { | |
20323 | switch (ret) { | |
20324 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
20325 | vty_out(vty, "%% Can't find community-list\n"); | |
20326 | break; | |
20327 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
20328 | vty_out(vty, "%% Malformed community-list value\n"); | |
20329 | break; | |
20330 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
20331 | vty_out(vty, | |
20332 | "%% Community name conflict, previously defined as standard community\n"); | |
20333 | break; | |
20334 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
20335 | vty_out(vty, | |
20336 | "%% Community name conflict, previously defined as expanded community\n"); | |
20337 | break; | |
20338 | } | |
718e3744 | 20339 | } |
20340 | ||
5bf15956 DW |
20341 | /* "community-list" keyword help string. */ |
20342 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
20343 | ||
7336e101 SP |
20344 | /*community-list standard */ |
20345 | DEFUN (community_list_standard, | |
20346 | bgp_community_list_standard_cmd, | |
a2099c1d | 20347 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 20348 | BGP_STR |
718e3744 | 20349 | COMMUNITY_LIST_STR |
20350 | "Community list number (standard)\n" | |
5bf15956 | 20351 | "Add an standard community-list entry\n" |
718e3744 | 20352 | "Community list name\n" |
2f8cc0e5 DA |
20353 | "Sequence number of an entry\n" |
20354 | "Sequence number\n" | |
718e3744 | 20355 | "Specify community to reject\n" |
20356 | "Specify community to accept\n" | |
20357 | COMMUNITY_VAL_STR) | |
20358 | { | |
d62a17ae | 20359 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20360 | char *seq = NULL; |
d62a17ae | 20361 | int direct = 0; |
20362 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 20363 | int idx = 0; |
7336e101 | 20364 | |
e34627f9 | 20365 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20366 | seq = argv[idx]->arg; |
20367 | ||
20368 | idx = 0; | |
d62a17ae | 20369 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20370 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20371 | cl_name_or_number = argv[idx]->arg; |
20372 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20373 | : COMMUNITY_DENY; | |
20374 | argv_find(argv, argc, "AA:NN", &idx); | |
20375 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20376 | |
2f8cc0e5 DA |
20377 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20378 | direct, style); | |
42f914d4 | 20379 | |
d62a17ae | 20380 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20381 | |
d62a17ae | 20382 | if (ret < 0) { |
20383 | /* Display error string. */ | |
20384 | community_list_perror(vty, ret); | |
20385 | return CMD_WARNING_CONFIG_FAILED; | |
20386 | } | |
42f914d4 | 20387 | |
d62a17ae | 20388 | return CMD_SUCCESS; |
718e3744 | 20389 | } |
20390 | ||
7336e101 SP |
20391 | DEFUN (no_community_list_standard_all, |
20392 | no_bgp_community_list_standard_all_cmd, | |
a2099c1d | 20393 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20394 | NO_STR |
20395 | BGP_STR | |
20396 | COMMUNITY_LIST_STR | |
20397 | "Community list number (standard)\n" | |
20398 | "Add an standard community-list entry\n" | |
20399 | "Community list name\n" | |
2f8cc0e5 DA |
20400 | "Sequence number of an entry\n" |
20401 | "Sequence number\n" | |
7336e101 SP |
20402 | "Specify community to reject\n" |
20403 | "Specify community to accept\n" | |
20404 | COMMUNITY_VAL_STR) | |
718e3744 | 20405 | { |
d62a17ae | 20406 | char *cl_name_or_number = NULL; |
174b5cb9 | 20407 | char *str = NULL; |
d62a17ae | 20408 | int direct = 0; |
20409 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 20410 | char *seq = NULL; |
d62a17ae | 20411 | int idx = 0; |
7336e101 | 20412 | |
e34627f9 | 20413 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20414 | seq = argv[idx]->arg; |
20415 | ||
20416 | idx = 0; | |
174b5cb9 DA |
20417 | argv_find(argv, argc, "permit", &idx); |
20418 | argv_find(argv, argc, "deny", &idx); | |
20419 | ||
20420 | if (idx) { | |
20421 | direct = argv_find(argv, argc, "permit", &idx) | |
20422 | ? COMMUNITY_PERMIT | |
20423 | : COMMUNITY_DENY; | |
20424 | ||
20425 | idx = 0; | |
20426 | argv_find(argv, argc, "AA:NN", &idx); | |
20427 | str = argv_concat(argv, argc, idx); | |
20428 | } | |
20429 | ||
20430 | idx = 0; | |
d62a17ae | 20431 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20432 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20433 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20434 | |
2f8cc0e5 | 20435 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20436 | direct, style); |
42f914d4 | 20437 | |
d62a17ae | 20438 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20439 | |
d62a17ae | 20440 | if (ret < 0) { |
20441 | community_list_perror(vty, ret); | |
20442 | return CMD_WARNING_CONFIG_FAILED; | |
20443 | } | |
42f914d4 | 20444 | |
d62a17ae | 20445 | return CMD_SUCCESS; |
718e3744 | 20446 | } |
7336e101 | 20447 | |
174b5cb9 | 20448 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
a2099c1d | 20449 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", |
174b5cb9 DA |
20450 | NO_STR BGP_STR COMMUNITY_LIST_STR |
20451 | "Community list number (standard)\n" | |
20452 | "Add an standard community-list entry\n" | |
20453 | "Community list name\n") | |
20454 | ||
7336e101 SP |
20455 | /*community-list expanded */ |
20456 | DEFUN (community_list_expanded_all, | |
20457 | bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20458 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20459 | BGP_STR |
20460 | COMMUNITY_LIST_STR | |
718e3744 | 20461 | "Community list number (expanded)\n" |
5bf15956 | 20462 | "Add an expanded community-list entry\n" |
718e3744 | 20463 | "Community list name\n" |
2f8cc0e5 DA |
20464 | "Sequence number of an entry\n" |
20465 | "Sequence number\n" | |
718e3744 | 20466 | "Specify community to reject\n" |
20467 | "Specify community to accept\n" | |
20468 | COMMUNITY_VAL_STR) | |
20469 | { | |
d62a17ae | 20470 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20471 | char *seq = NULL; |
d62a17ae | 20472 | int direct = 0; |
20473 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20474 | int idx = 0; |
7b9a4750 | 20475 | |
e34627f9 | 20476 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20477 | seq = argv[idx]->arg; |
20478 | ||
20479 | idx = 0; | |
20480 | ||
d62a17ae | 20481 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20482 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20483 | cl_name_or_number = argv[idx]->arg; |
20484 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
20485 | : COMMUNITY_DENY; | |
20486 | argv_find(argv, argc, "AA:NN", &idx); | |
20487 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20488 | |
2f8cc0e5 DA |
20489 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
20490 | direct, style); | |
42f914d4 | 20491 | |
d62a17ae | 20492 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20493 | |
d62a17ae | 20494 | if (ret < 0) { |
20495 | /* Display error string. */ | |
20496 | community_list_perror(vty, ret); | |
20497 | return CMD_WARNING_CONFIG_FAILED; | |
20498 | } | |
42f914d4 | 20499 | |
d62a17ae | 20500 | return CMD_SUCCESS; |
718e3744 | 20501 | } |
20502 | ||
7336e101 SP |
20503 | DEFUN (no_community_list_expanded_all, |
20504 | no_bgp_community_list_expanded_all_cmd, | |
a2099c1d | 20505 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20506 | NO_STR |
20507 | BGP_STR | |
20508 | COMMUNITY_LIST_STR | |
20509 | "Community list number (expanded)\n" | |
20510 | "Add an expanded community-list entry\n" | |
20511 | "Community list name\n" | |
2f8cc0e5 DA |
20512 | "Sequence number of an entry\n" |
20513 | "Sequence number\n" | |
7336e101 SP |
20514 | "Specify community to reject\n" |
20515 | "Specify community to accept\n" | |
20516 | COMMUNITY_VAL_STR) | |
718e3744 | 20517 | { |
d62a17ae | 20518 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 20519 | char *seq = NULL; |
174b5cb9 | 20520 | char *str = NULL; |
d62a17ae | 20521 | int direct = 0; |
20522 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 20523 | int idx = 0; |
174b5cb9 | 20524 | |
e34627f9 | 20525 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20526 | seq = argv[idx]->arg; |
20527 | ||
20528 | idx = 0; | |
174b5cb9 DA |
20529 | argv_find(argv, argc, "permit", &idx); |
20530 | argv_find(argv, argc, "deny", &idx); | |
20531 | ||
20532 | if (idx) { | |
20533 | direct = argv_find(argv, argc, "permit", &idx) | |
20534 | ? COMMUNITY_PERMIT | |
20535 | : COMMUNITY_DENY; | |
20536 | ||
20537 | idx = 0; | |
20538 | argv_find(argv, argc, "AA:NN", &idx); | |
20539 | str = argv_concat(argv, argc, idx); | |
7336e101 | 20540 | } |
174b5cb9 DA |
20541 | |
20542 | idx = 0; | |
d62a17ae | 20543 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20544 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20545 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 20546 | |
2f8cc0e5 | 20547 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 20548 | direct, style); |
42f914d4 | 20549 | |
d62a17ae | 20550 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 20551 | |
d62a17ae | 20552 | if (ret < 0) { |
20553 | community_list_perror(vty, ret); | |
20554 | return CMD_WARNING_CONFIG_FAILED; | |
20555 | } | |
42f914d4 | 20556 | |
d62a17ae | 20557 | return CMD_SUCCESS; |
718e3744 | 20558 | } |
20559 | ||
36d4bb44 EB |
20560 | ALIAS(no_community_list_expanded_all, |
20561 | no_bgp_community_list_expanded_all_list_cmd, | |
a2099c1d | 20562 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", |
36d4bb44 | 20563 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
20564 | "Community list number (expanded)\n" |
20565 | "Add an expanded community-list entry\n" | |
20566 | "Community list name\n") | |
20567 | ||
8d9b8ed9 PM |
20568 | /* Return configuration string of community-list entry. */ |
20569 | static const char *community_list_config_str(struct community_entry *entry) | |
20570 | { | |
20571 | const char *str; | |
20572 | ||
20573 | if (entry->any) | |
20574 | str = ""; | |
20575 | else { | |
20576 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
c0945b78 | 20577 | str = community_str(entry->u.com, false, false); |
8d9b8ed9 | 20578 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) |
c0945b78 | 20579 | str = lcommunity_str(entry->u.lcom, false, false); |
8d9b8ed9 PM |
20580 | else |
20581 | str = entry->config; | |
20582 | } | |
20583 | return str; | |
20584 | } | |
20585 | ||
d62a17ae | 20586 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20587 | { |
d62a17ae | 20588 | struct community_entry *entry; |
718e3744 | 20589 | |
d62a17ae | 20590 | for (entry = list->head; entry; entry = entry->next) { |
20591 | if (entry == list->head) { | |
20592 | if (all_digit(list->name)) | |
20593 | vty_out(vty, "Community %s list %s\n", | |
20594 | entry->style == COMMUNITY_LIST_STANDARD | |
20595 | ? "standard" | |
20596 | : "(expanded) access", | |
20597 | list->name); | |
20598 | else | |
20599 | vty_out(vty, "Named Community %s list %s\n", | |
20600 | entry->style == COMMUNITY_LIST_STANDARD | |
20601 | ? "standard" | |
20602 | : "expanded", | |
20603 | list->name); | |
20604 | } | |
20605 | if (entry->any) | |
20606 | vty_out(vty, " %s\n", | |
20607 | community_direct_str(entry->direct)); | |
20608 | else | |
20609 | vty_out(vty, " %s %s\n", | |
20610 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20611 | community_list_config_str(entry)); |
d62a17ae | 20612 | } |
718e3744 | 20613 | } |
20614 | ||
7336e101 SP |
20615 | DEFUN (show_community_list, |
20616 | show_bgp_community_list_cmd, | |
20617 | "show bgp community-list", | |
718e3744 | 20618 | SHOW_STR |
7336e101 | 20619 | BGP_STR |
718e3744 | 20620 | "List community-list\n") |
20621 | { | |
d62a17ae | 20622 | struct community_list *list; |
20623 | struct community_list_master *cm; | |
718e3744 | 20624 | |
d62a17ae | 20625 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
20626 | if (!cm) | |
20627 | return CMD_SUCCESS; | |
718e3744 | 20628 | |
d62a17ae | 20629 | for (list = cm->num.head; list; list = list->next) |
20630 | community_list_show(vty, list); | |
718e3744 | 20631 | |
d62a17ae | 20632 | for (list = cm->str.head; list; list = list->next) |
20633 | community_list_show(vty, list); | |
718e3744 | 20634 | |
d62a17ae | 20635 | return CMD_SUCCESS; |
718e3744 | 20636 | } |
20637 | ||
7336e101 SP |
20638 | DEFUN (show_community_list_arg, |
20639 | show_bgp_community_list_arg_cmd, | |
a2099c1d | 20640 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20641 | SHOW_STR |
20642 | BGP_STR | |
718e3744 | 20643 | "List community-list\n" |
20644 | "Community-list number\n" | |
960b69b9 | 20645 | "Community-list name\n" |
20646 | "Detailed information on community-list\n") | |
718e3744 | 20647 | { |
d62a17ae | 20648 | int idx_comm_list = 3; |
20649 | struct community_list *list; | |
718e3744 | 20650 | |
e237b0d2 | 20651 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20652 | COMMUNITY_LIST_MASTER); |
20653 | if (!list) { | |
20654 | vty_out(vty, "%% Can't find community-list\n"); | |
20655 | return CMD_WARNING; | |
20656 | } | |
718e3744 | 20657 | |
d62a17ae | 20658 | community_list_show(vty, list); |
718e3744 | 20659 | |
d62a17ae | 20660 | return CMD_SUCCESS; |
718e3744 | 20661 | } |
6b0655a2 | 20662 | |
57d187bc JS |
20663 | /* |
20664 | * Large Community code. | |
20665 | */ | |
d62a17ae | 20666 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
20667 | struct cmd_token **argv, int style, | |
20668 | int reject_all_digit_name) | |
20669 | { | |
20670 | int ret; | |
20671 | int direct; | |
20672 | char *str; | |
20673 | int idx = 0; | |
20674 | char *cl_name; | |
2f8cc0e5 DA |
20675 | char *seq = NULL; |
20676 | ||
a08032fe | 20677 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20678 | seq = argv[idx]->arg; |
d62a17ae | 20679 | |
2f8cc0e5 | 20680 | idx = 0; |
d62a17ae | 20681 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20682 | : COMMUNITY_DENY; | |
20683 | ||
20684 | /* All digit name check. */ | |
20685 | idx = 0; | |
a2099c1d | 20686 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20687 | argv_find(argv, argc, "(1-99)", &idx); |
20688 | argv_find(argv, argc, "(100-500)", &idx); | |
20689 | cl_name = argv[idx]->arg; | |
20690 | if (reject_all_digit_name && all_digit(cl_name)) { | |
20691 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
20692 | return CMD_WARNING_CONFIG_FAILED; | |
20693 | } | |
20694 | ||
20695 | idx = 0; | |
20696 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
20697 | argv_find(argv, argc, "LINE", &idx); | |
20698 | /* Concat community string argument. */ | |
20699 | if (idx) | |
20700 | str = argv_concat(argv, argc, idx); | |
20701 | else | |
20702 | str = NULL; | |
20703 | ||
2f8cc0e5 | 20704 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 20705 | |
20706 | /* Free temporary community list string allocated by | |
20707 | argv_concat(). */ | |
0a22ddfb | 20708 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20709 | |
20710 | if (ret < 0) { | |
20711 | community_list_perror(vty, ret); | |
20712 | return CMD_WARNING_CONFIG_FAILED; | |
20713 | } | |
20714 | return CMD_SUCCESS; | |
20715 | } | |
20716 | ||
20717 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
20718 | struct cmd_token **argv, int style) | |
20719 | { | |
20720 | int ret; | |
20721 | int direct = 0; | |
20722 | char *str = NULL; | |
20723 | int idx = 0; | |
2f8cc0e5 | 20724 | char *seq = NULL; |
d62a17ae | 20725 | |
a08032fe | 20726 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 20727 | seq = argv[idx]->arg; |
d62a17ae | 20728 | |
2f8cc0e5 | 20729 | idx = 0; |
d62a17ae | 20730 | argv_find(argv, argc, "permit", &idx); |
20731 | argv_find(argv, argc, "deny", &idx); | |
20732 | ||
20733 | if (idx) { | |
20734 | /* Check the list direct. */ | |
20735 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
20736 | direct = COMMUNITY_PERMIT; | |
20737 | else | |
20738 | direct = COMMUNITY_DENY; | |
20739 | ||
20740 | idx = 0; | |
20741 | argv_find(argv, argc, "LINE", &idx); | |
20742 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
20743 | /* Concat community string argument. */ | |
20744 | str = argv_concat(argv, argc, idx); | |
20745 | } | |
20746 | ||
20747 | idx = 0; | |
20748 | argv_find(argv, argc, "(1-99)", &idx); | |
20749 | argv_find(argv, argc, "(100-500)", &idx); | |
a2099c1d | 20750 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20751 | |
20752 | /* Unset community list. */ | |
2f8cc0e5 | 20753 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 20754 | style); |
20755 | ||
20756 | /* Free temporary community list string allocated by | |
20757 | argv_concat(). */ | |
0a22ddfb | 20758 | XFREE(MTYPE_TMP, str); |
d62a17ae | 20759 | |
20760 | if (ret < 0) { | |
20761 | community_list_perror(vty, ret); | |
20762 | return CMD_WARNING_CONFIG_FAILED; | |
20763 | } | |
20764 | ||
20765 | return CMD_SUCCESS; | |
57d187bc JS |
20766 | } |
20767 | ||
20768 | /* "large-community-list" keyword help string. */ | |
20769 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
20770 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
20771 | ||
7336e101 SP |
20772 | DEFUN (lcommunity_list_standard, |
20773 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20774 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20775 | BGP_STR |
20776 | LCOMMUNITY_LIST_STR | |
20777 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20778 | "Sequence number of an entry\n" |
20779 | "Sequence number\n" | |
7336e101 SP |
20780 | "Specify large community to reject\n" |
20781 | "Specify large community to accept\n" | |
20782 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20783 | { |
d62a17ae | 20784 | return lcommunity_list_set_vty(vty, argc, argv, |
20785 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
20786 | } |
20787 | ||
7336e101 SP |
20788 | DEFUN (lcommunity_list_expanded, |
20789 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20790 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20791 | BGP_STR |
20792 | LCOMMUNITY_LIST_STR | |
20793 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20794 | "Sequence number of an entry\n" |
20795 | "Sequence number\n" | |
7336e101 SP |
20796 | "Specify large community to reject\n" |
20797 | "Specify large community to accept\n" | |
20798 | "An ordered list as a regular-expression\n") | |
57d187bc | 20799 | { |
d62a17ae | 20800 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20801 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
20802 | } |
20803 | ||
7336e101 SP |
20804 | DEFUN (lcommunity_list_name_standard, |
20805 | bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20806 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
20807 | BGP_STR |
20808 | LCOMMUNITY_LIST_STR | |
20809 | "Specify standard large-community-list\n" | |
20810 | "Large Community list name\n" | |
2f8cc0e5 DA |
20811 | "Sequence number of an entry\n" |
20812 | "Sequence number\n" | |
7336e101 SP |
20813 | "Specify large community to reject\n" |
20814 | "Specify large community to accept\n" | |
20815 | LCOMMUNITY_VAL_STR) | |
52951b63 | 20816 | { |
d62a17ae | 20817 | return lcommunity_list_set_vty(vty, argc, argv, |
20818 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
20819 | } |
20820 | ||
7336e101 SP |
20821 | DEFUN (lcommunity_list_name_expanded, |
20822 | bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20823 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20824 | BGP_STR |
20825 | LCOMMUNITY_LIST_STR | |
20826 | "Specify expanded large-community-list\n" | |
20827 | "Large Community list name\n" | |
2f8cc0e5 DA |
20828 | "Sequence number of an entry\n" |
20829 | "Sequence number\n" | |
7336e101 SP |
20830 | "Specify large community to reject\n" |
20831 | "Specify large community to accept\n" | |
20832 | "An ordered list as a regular-expression\n") | |
57d187bc | 20833 | { |
d62a17ae | 20834 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 20835 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
20836 | } |
20837 | ||
4378f57c DA |
20838 | DEFUN (no_lcommunity_list_all, |
20839 | no_bgp_lcommunity_list_all_cmd, | |
a2099c1d | 20840 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", |
7336e101 SP |
20841 | NO_STR |
20842 | BGP_STR | |
20843 | LCOMMUNITY_LIST_STR | |
20844 | "Large Community list number (standard)\n" | |
20845 | "Large Community list number (expanded)\n" | |
20846 | "Large Community list name\n") | |
57d187bc | 20847 | { |
7336e101 SP |
20848 | return lcommunity_list_unset_vty(vty, argc, argv, |
20849 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
20850 | } |
20851 | ||
4378f57c DA |
20852 | DEFUN (no_lcommunity_list_name_standard_all, |
20853 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
a2099c1d | 20854 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", |
4378f57c DA |
20855 | NO_STR |
20856 | BGP_STR | |
20857 | LCOMMUNITY_LIST_STR | |
20858 | "Specify standard large-community-list\n" | |
20859 | "Large Community list name\n") | |
20860 | { | |
20861 | return lcommunity_list_unset_vty(vty, argc, argv, | |
20862 | LARGE_COMMUNITY_LIST_STANDARD); | |
20863 | } | |
20864 | ||
7336e101 SP |
20865 | DEFUN (no_lcommunity_list_name_expanded_all, |
20866 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
a2099c1d | 20867 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", |
7336e101 SP |
20868 | NO_STR |
20869 | BGP_STR | |
20870 | LCOMMUNITY_LIST_STR | |
20871 | "Specify expanded large-community-list\n" | |
20872 | "Large Community list name\n") | |
57d187bc | 20873 | { |
d62a17ae | 20874 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20875 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20876 | } |
20877 | ||
7336e101 SP |
20878 | DEFUN (no_lcommunity_list_standard, |
20879 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 20880 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20881 | NO_STR |
20882 | BGP_STR | |
20883 | LCOMMUNITY_LIST_STR | |
20884 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
20885 | "Sequence number of an entry\n" |
20886 | "Sequence number\n" | |
7336e101 SP |
20887 | "Specify large community to reject\n" |
20888 | "Specify large community to accept\n" | |
20889 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20890 | { |
d62a17ae | 20891 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20892 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20893 | } |
20894 | ||
7336e101 SP |
20895 | DEFUN (no_lcommunity_list_expanded, |
20896 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 20897 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20898 | NO_STR |
20899 | BGP_STR | |
20900 | LCOMMUNITY_LIST_STR | |
20901 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
20902 | "Sequence number of an entry\n" |
20903 | "Sequence number\n" | |
7336e101 SP |
20904 | "Specify large community to reject\n" |
20905 | "Specify large community to accept\n" | |
20906 | "An ordered list as a regular-expression\n") | |
57d187bc | 20907 | { |
d62a17ae | 20908 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20909 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20910 | } |
20911 | ||
7336e101 SP |
20912 | DEFUN (no_lcommunity_list_name_standard, |
20913 | no_bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 20914 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
20915 | NO_STR |
20916 | BGP_STR | |
20917 | LCOMMUNITY_LIST_STR | |
20918 | "Specify standard large-community-list\n" | |
20919 | "Large Community list name\n" | |
2f8cc0e5 DA |
20920 | "Sequence number of an entry\n" |
20921 | "Sequence number\n" | |
7336e101 SP |
20922 | "Specify large community to reject\n" |
20923 | "Specify large community to accept\n" | |
20924 | LCOMMUNITY_VAL_STR) | |
57d187bc | 20925 | { |
d62a17ae | 20926 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20927 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
20928 | } |
20929 | ||
7336e101 SP |
20930 | DEFUN (no_lcommunity_list_name_expanded, |
20931 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 20932 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20933 | NO_STR |
20934 | BGP_STR | |
20935 | LCOMMUNITY_LIST_STR | |
20936 | "Specify expanded large-community-list\n" | |
20937 | "Large community list name\n" | |
2f8cc0e5 DA |
20938 | "Sequence number of an entry\n" |
20939 | "Sequence number\n" | |
7336e101 SP |
20940 | "Specify large community to reject\n" |
20941 | "Specify large community to accept\n" | |
20942 | "An ordered list as a regular-expression\n") | |
57d187bc | 20943 | { |
d62a17ae | 20944 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 20945 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
20946 | } |
20947 | ||
d62a17ae | 20948 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
20949 | { | |
20950 | struct community_entry *entry; | |
20951 | ||
20952 | for (entry = list->head; entry; entry = entry->next) { | |
20953 | if (entry == list->head) { | |
20954 | if (all_digit(list->name)) | |
20955 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 20956 | entry->style == |
20957 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20958 | ? "standard" |
20959 | : "(expanded) access", | |
20960 | list->name); | |
20961 | else | |
20962 | vty_out(vty, | |
20963 | "Named large community %s list %s\n", | |
169b72c8 | 20964 | entry->style == |
20965 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 20966 | ? "standard" |
20967 | : "expanded", | |
20968 | list->name); | |
20969 | } | |
20970 | if (entry->any) | |
20971 | vty_out(vty, " %s\n", | |
20972 | community_direct_str(entry->direct)); | |
20973 | else | |
20974 | vty_out(vty, " %s %s\n", | |
20975 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20976 | community_list_config_str(entry)); |
d62a17ae | 20977 | } |
57d187bc JS |
20978 | } |
20979 | ||
7336e101 SP |
20980 | DEFUN (show_lcommunity_list, |
20981 | show_bgp_lcommunity_list_cmd, | |
20982 | "show bgp large-community-list", | |
57d187bc | 20983 | SHOW_STR |
7336e101 | 20984 | BGP_STR |
57d187bc JS |
20985 | "List large-community list\n") |
20986 | { | |
d62a17ae | 20987 | struct community_list *list; |
20988 | struct community_list_master *cm; | |
57d187bc | 20989 | |
d62a17ae | 20990 | cm = community_list_master_lookup(bgp_clist, |
20991 | LARGE_COMMUNITY_LIST_MASTER); | |
20992 | if (!cm) | |
20993 | return CMD_SUCCESS; | |
57d187bc | 20994 | |
d62a17ae | 20995 | for (list = cm->num.head; list; list = list->next) |
20996 | lcommunity_list_show(vty, list); | |
57d187bc | 20997 | |
d62a17ae | 20998 | for (list = cm->str.head; list; list = list->next) |
20999 | lcommunity_list_show(vty, list); | |
57d187bc | 21000 | |
d62a17ae | 21001 | return CMD_SUCCESS; |
57d187bc JS |
21002 | } |
21003 | ||
7336e101 SP |
21004 | DEFUN (show_lcommunity_list_arg, |
21005 | show_bgp_lcommunity_list_arg_cmd, | |
a2099c1d | 21006 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
21007 | SHOW_STR |
21008 | BGP_STR | |
57d187bc | 21009 | "List large-community list\n" |
960b69b9 | 21010 | "Large-community-list number\n" |
21011 | "Large-community-list name\n" | |
21012 | "Detailed information on large-community-list\n") | |
57d187bc | 21013 | { |
d62a17ae | 21014 | struct community_list *list; |
57d187bc | 21015 | |
e237b0d2 | 21016 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 21017 | LARGE_COMMUNITY_LIST_MASTER); |
21018 | if (!list) { | |
960b69b9 | 21019 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 21020 | return CMD_WARNING; |
21021 | } | |
57d187bc | 21022 | |
d62a17ae | 21023 | lcommunity_list_show(vty, list); |
57d187bc | 21024 | |
d62a17ae | 21025 | return CMD_SUCCESS; |
57d187bc JS |
21026 | } |
21027 | ||
718e3744 | 21028 | /* "extcommunity-list" keyword help string. */ |
21029 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
21030 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
21031 | ||
7336e101 SP |
21032 | DEFUN (extcommunity_list_standard, |
21033 | bgp_extcommunity_list_standard_cmd, | |
a2099c1d | 21034 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 21035 | BGP_STR |
718e3744 | 21036 | EXTCOMMUNITY_LIST_STR |
21037 | "Extended Community list number (standard)\n" | |
718e3744 | 21038 | "Specify standard extcommunity-list\n" |
5bf15956 | 21039 | "Community list name\n" |
2f8cc0e5 DA |
21040 | "Sequence number of an entry\n" |
21041 | "Sequence number\n" | |
718e3744 | 21042 | "Specify community to reject\n" |
21043 | "Specify community to accept\n" | |
21044 | EXTCOMMUNITY_VAL_STR) | |
21045 | { | |
d62a17ae | 21046 | int style = EXTCOMMUNITY_LIST_STANDARD; |
21047 | int direct = 0; | |
21048 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 21049 | char *seq = NULL; |
42f914d4 | 21050 | |
d62a17ae | 21051 | int idx = 0; |
7b9a4750 | 21052 | |
d62a17ae | 21053 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 21054 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 21055 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 21056 | |
a08032fe | 21057 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
21058 | seq = argv[idx]->arg; |
21059 | ||
d62a17ae | 21060 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
21061 | : COMMUNITY_DENY; | |
21062 | argv_find(argv, argc, "AA:NN", &idx); | |
21063 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 21064 | |
2f8cc0e5 | 21065 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 21066 | direct, style); |
42f914d4 | 21067 | |
d62a17ae | 21068 | XFREE(MTYPE_TMP, str); |
42f914d4 | 21069 | |
d62a17ae | 21070 | if (ret < 0) { |
21071 | community_list_perror(vty, ret); | |
21072 | return CMD_WARNING_CONFIG_FAILED; | |
21073 | } | |
42f914d4 | 21074 | |
d62a17ae | 21075 | return CMD_SUCCESS; |
718e3744 | 21076 | } |
21077 | ||
7336e101 SP |
21078 | DEFUN (extcommunity_list_name_expanded, |
21079 | bgp_extcommunity_list_name_expanded_cmd, | |
a2099c1d | 21080 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
21081 | BGP_STR |
21082 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 21083 | "Extended Community list number (expanded)\n" |
718e3744 | 21084 | "Specify expanded extcommunity-list\n" |
21085 | "Extended Community list name\n" | |
2f8cc0e5 DA |
21086 | "Sequence number of an entry\n" |
21087 | "Sequence number\n" | |
718e3744 | 21088 | "Specify community to reject\n" |
21089 | "Specify community to accept\n" | |
21090 | "An ordered list as a regular-expression\n") | |
21091 | { | |
d62a17ae | 21092 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
21093 | int direct = 0; | |
21094 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 21095 | char *seq = NULL; |
d62a17ae | 21096 | int idx = 0; |
7336e101 | 21097 | |
d62a17ae | 21098 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 21099 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 21100 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 21101 | |
a08032fe | 21102 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
21103 | seq = argv[idx]->arg; |
21104 | ||
d62a17ae | 21105 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
21106 | : COMMUNITY_DENY; | |
21107 | argv_find(argv, argc, "LINE", &idx); | |
21108 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 21109 | |
2f8cc0e5 | 21110 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 21111 | direct, style); |
42f914d4 | 21112 | |
d62a17ae | 21113 | XFREE(MTYPE_TMP, str); |
42f914d4 | 21114 | |
d62a17ae | 21115 | if (ret < 0) { |
21116 | community_list_perror(vty, ret); | |
21117 | return CMD_WARNING_CONFIG_FAILED; | |
21118 | } | |
42f914d4 | 21119 | |
d62a17ae | 21120 | return CMD_SUCCESS; |
718e3744 | 21121 | } |
21122 | ||
7336e101 SP |
21123 | DEFUN (no_extcommunity_list_standard_all, |
21124 | no_bgp_extcommunity_list_standard_all_cmd, | |
a2099c1d | 21125 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
21126 | NO_STR |
21127 | BGP_STR | |
21128 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 21129 | "Extended Community list number (standard)\n" |
718e3744 | 21130 | "Specify standard extcommunity-list\n" |
5bf15956 | 21131 | "Community list name\n" |
2f8cc0e5 DA |
21132 | "Sequence number of an entry\n" |
21133 | "Sequence number\n" | |
718e3744 | 21134 | "Specify community to reject\n" |
21135 | "Specify community to accept\n" | |
21136 | EXTCOMMUNITY_VAL_STR) | |
21137 | { | |
d62a17ae | 21138 | int style = EXTCOMMUNITY_LIST_STANDARD; |
21139 | int direct = 0; | |
21140 | char *cl_number_or_name = NULL; | |
d4455c89 | 21141 | char *str = NULL; |
2f8cc0e5 | 21142 | char *seq = NULL; |
d62a17ae | 21143 | int idx = 0; |
d4455c89 | 21144 | |
a08032fe | 21145 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
21146 | seq = argv[idx]->arg; |
21147 | ||
21148 | idx = 0; | |
d4455c89 DA |
21149 | argv_find(argv, argc, "permit", &idx); |
21150 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
21151 | if (idx) { |
21152 | direct = argv_find(argv, argc, "permit", &idx) | |
21153 | ? COMMUNITY_PERMIT | |
21154 | : COMMUNITY_DENY; | |
21155 | ||
21156 | idx = 0; | |
21157 | argv_find(argv, argc, "AA:NN", &idx); | |
21158 | str = argv_concat(argv, argc, idx); | |
21159 | } | |
21160 | ||
21161 | idx = 0; | |
d62a17ae | 21162 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 21163 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 21164 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 21165 | |
d62a17ae | 21166 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 21167 | seq, direct, style); |
42f914d4 | 21168 | |
d62a17ae | 21169 | XFREE(MTYPE_TMP, str); |
42f914d4 | 21170 | |
d62a17ae | 21171 | if (ret < 0) { |
21172 | community_list_perror(vty, ret); | |
21173 | return CMD_WARNING_CONFIG_FAILED; | |
21174 | } | |
42f914d4 | 21175 | |
d62a17ae | 21176 | return CMD_SUCCESS; |
718e3744 | 21177 | } |
21178 | ||
d4455c89 DA |
21179 | ALIAS(no_extcommunity_list_standard_all, |
21180 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
a2099c1d | 21181 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 21182 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
21183 | "Extended Community list number (standard)\n" |
21184 | "Specify standard extcommunity-list\n" | |
21185 | "Community list name\n") | |
21186 | ||
7336e101 SP |
21187 | DEFUN (no_extcommunity_list_expanded_all, |
21188 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a2099c1d | 21189 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
21190 | NO_STR |
21191 | BGP_STR | |
21192 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 21193 | "Extended Community list number (expanded)\n" |
718e3744 | 21194 | "Specify expanded extcommunity-list\n" |
5bf15956 | 21195 | "Extended Community list name\n" |
2f8cc0e5 DA |
21196 | "Sequence number of an entry\n" |
21197 | "Sequence number\n" | |
718e3744 | 21198 | "Specify community to reject\n" |
21199 | "Specify community to accept\n" | |
21200 | "An ordered list as a regular-expression\n") | |
21201 | { | |
d62a17ae | 21202 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
21203 | int direct = 0; | |
21204 | char *cl_number_or_name = NULL; | |
d4455c89 | 21205 | char *str = NULL; |
2f8cc0e5 | 21206 | char *seq = NULL; |
d62a17ae | 21207 | int idx = 0; |
d4455c89 | 21208 | |
a08032fe | 21209 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
21210 | seq = argv[idx]->arg; |
21211 | ||
21212 | idx = 0; | |
d4455c89 DA |
21213 | argv_find(argv, argc, "permit", &idx); |
21214 | argv_find(argv, argc, "deny", &idx); | |
21215 | ||
21216 | if (idx) { | |
21217 | direct = argv_find(argv, argc, "permit", &idx) | |
21218 | ? COMMUNITY_PERMIT | |
21219 | : COMMUNITY_DENY; | |
21220 | ||
21221 | idx = 0; | |
21222 | argv_find(argv, argc, "LINE", &idx); | |
21223 | str = argv_concat(argv, argc, idx); | |
21224 | } | |
21225 | ||
21226 | idx = 0; | |
d62a17ae | 21227 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 21228 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 21229 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 21230 | |
d62a17ae | 21231 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 21232 | seq, direct, style); |
42f914d4 | 21233 | |
d62a17ae | 21234 | XFREE(MTYPE_TMP, str); |
42f914d4 | 21235 | |
d62a17ae | 21236 | if (ret < 0) { |
21237 | community_list_perror(vty, ret); | |
21238 | return CMD_WARNING_CONFIG_FAILED; | |
21239 | } | |
42f914d4 | 21240 | |
d62a17ae | 21241 | return CMD_SUCCESS; |
718e3744 | 21242 | } |
21243 | ||
d4455c89 DA |
21244 | ALIAS(no_extcommunity_list_expanded_all, |
21245 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
a2099c1d | 21246 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 21247 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
21248 | "Extended Community list number (expanded)\n" |
21249 | "Specify expanded extcommunity-list\n" | |
21250 | "Extended Community list name\n") | |
21251 | ||
d62a17ae | 21252 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 21253 | { |
d62a17ae | 21254 | struct community_entry *entry; |
718e3744 | 21255 | |
d62a17ae | 21256 | for (entry = list->head; entry; entry = entry->next) { |
21257 | if (entry == list->head) { | |
21258 | if (all_digit(list->name)) | |
21259 | vty_out(vty, "Extended community %s list %s\n", | |
21260 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
21261 | ? "standard" | |
21262 | : "(expanded) access", | |
21263 | list->name); | |
21264 | else | |
21265 | vty_out(vty, | |
21266 | "Named extended community %s list %s\n", | |
21267 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
21268 | ? "standard" | |
21269 | : "expanded", | |
21270 | list->name); | |
21271 | } | |
21272 | if (entry->any) | |
21273 | vty_out(vty, " %s\n", | |
21274 | community_direct_str(entry->direct)); | |
21275 | else | |
21276 | vty_out(vty, " %s %s\n", | |
21277 | community_direct_str(entry->direct), | |
8d9b8ed9 | 21278 | community_list_config_str(entry)); |
d62a17ae | 21279 | } |
718e3744 | 21280 | } |
21281 | ||
7336e101 SP |
21282 | DEFUN (show_extcommunity_list, |
21283 | show_bgp_extcommunity_list_cmd, | |
21284 | "show bgp extcommunity-list", | |
718e3744 | 21285 | SHOW_STR |
7336e101 | 21286 | BGP_STR |
718e3744 | 21287 | "List extended-community list\n") |
21288 | { | |
d62a17ae | 21289 | struct community_list *list; |
21290 | struct community_list_master *cm; | |
718e3744 | 21291 | |
d62a17ae | 21292 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
21293 | if (!cm) | |
21294 | return CMD_SUCCESS; | |
718e3744 | 21295 | |
d62a17ae | 21296 | for (list = cm->num.head; list; list = list->next) |
21297 | extcommunity_list_show(vty, list); | |
718e3744 | 21298 | |
d62a17ae | 21299 | for (list = cm->str.head; list; list = list->next) |
21300 | extcommunity_list_show(vty, list); | |
718e3744 | 21301 | |
d62a17ae | 21302 | return CMD_SUCCESS; |
718e3744 | 21303 | } |
21304 | ||
7336e101 SP |
21305 | DEFUN (show_extcommunity_list_arg, |
21306 | show_bgp_extcommunity_list_arg_cmd, | |
a2099c1d | 21307 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
21308 | SHOW_STR |
21309 | BGP_STR | |
718e3744 | 21310 | "List extended-community list\n" |
21311 | "Extcommunity-list number\n" | |
960b69b9 | 21312 | "Extcommunity-list name\n" |
21313 | "Detailed information on extcommunity-list\n") | |
718e3744 | 21314 | { |
d62a17ae | 21315 | int idx_comm_list = 3; |
21316 | struct community_list *list; | |
718e3744 | 21317 | |
e237b0d2 | 21318 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 21319 | EXTCOMMUNITY_LIST_MASTER); |
21320 | if (!list) { | |
21321 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
21322 | return CMD_WARNING; | |
21323 | } | |
718e3744 | 21324 | |
d62a17ae | 21325 | extcommunity_list_show(vty, list); |
718e3744 | 21326 | |
d62a17ae | 21327 | return CMD_SUCCESS; |
718e3744 | 21328 | } |
6b0655a2 | 21329 | |
718e3744 | 21330 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 21331 | static int community_list_config_write(struct vty *vty) |
21332 | { | |
21333 | struct community_list *list; | |
21334 | struct community_entry *entry; | |
21335 | struct community_list_master *cm; | |
21336 | int write = 0; | |
21337 | ||
21338 | /* Community-list. */ | |
21339 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
21340 | ||
21341 | for (list = cm->num.head; list; list = list->next) | |
21342 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21343 | vty_out(vty, |
21344 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
21345 | list->name, entry->seq, | |
d62a17ae | 21346 | community_direct_str(entry->direct), |
21347 | community_list_config_str(entry)); | |
21348 | write++; | |
21349 | } | |
21350 | for (list = cm->str.head; list; list = list->next) | |
21351 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21352 | vty_out(vty, |
21353 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 21354 | entry->style == COMMUNITY_LIST_STANDARD |
21355 | ? "standard" | |
21356 | : "expanded", | |
2f8cc0e5 DA |
21357 | list->name, entry->seq, |
21358 | community_direct_str(entry->direct), | |
d62a17ae | 21359 | community_list_config_str(entry)); |
21360 | write++; | |
21361 | } | |
21362 | ||
21363 | /* Extcommunity-list. */ | |
21364 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
21365 | ||
21366 | for (list = cm->num.head; list; list = list->next) | |
21367 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
21368 | vty_out(vty, |
21369 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
21370 | list->name, entry->seq, | |
21371 | community_direct_str(entry->direct), | |
d62a17ae | 21372 | community_list_config_str(entry)); |
21373 | write++; | |
21374 | } | |
21375 | for (list = cm->str.head; list; list = list->next) | |
21376 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21377 | vty_out(vty, |
6cde4b45 | 21378 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 21379 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
21380 | ? "standard" | |
21381 | : "expanded", | |
2f8cc0e5 DA |
21382 | list->name, entry->seq, |
21383 | community_direct_str(entry->direct), | |
d62a17ae | 21384 | community_list_config_str(entry)); |
21385 | write++; | |
21386 | } | |
21387 | ||
21388 | ||
21389 | /* lcommunity-list. */ | |
21390 | cm = community_list_master_lookup(bgp_clist, | |
21391 | LARGE_COMMUNITY_LIST_MASTER); | |
21392 | ||
21393 | for (list = cm->num.head; list; list = list->next) | |
21394 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21395 | vty_out(vty, |
6cde4b45 | 21396 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
21397 | list->name, entry->seq, |
21398 | community_direct_str(entry->direct), | |
d62a17ae | 21399 | community_list_config_str(entry)); |
21400 | write++; | |
21401 | } | |
21402 | for (list = cm->str.head; list; list = list->next) | |
21403 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 21404 | vty_out(vty, |
6cde4b45 | 21405 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 21406 | |
d62a17ae | 21407 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
21408 | ? "standard" | |
21409 | : "expanded", | |
2f8cc0e5 | 21410 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 21411 | community_list_config_str(entry)); |
21412 | write++; | |
21413 | } | |
21414 | ||
21415 | return write; | |
21416 | } | |
21417 | ||
612c2c15 | 21418 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 21419 | static struct cmd_node community_list_node = { |
f4b8291f | 21420 | .name = "community list", |
62b346ee DL |
21421 | .node = COMMUNITY_LIST_NODE, |
21422 | .prompt = "", | |
612c2c15 | 21423 | .config_write = community_list_config_write, |
718e3744 | 21424 | }; |
21425 | ||
d62a17ae | 21426 | static void community_list_vty(void) |
21427 | { | |
612c2c15 | 21428 | install_node(&community_list_node); |
d62a17ae | 21429 | |
21430 | /* Community-list. */ | |
7336e101 SP |
21431 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
21432 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
21433 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 21434 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 21435 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 21436 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
21437 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
21438 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 21439 | |
21440 | /* Extcommunity-list. */ | |
7336e101 SP |
21441 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
21442 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
21443 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
21444 | install_element(CONFIG_NODE, |
21445 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 21446 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
21447 | install_element(CONFIG_NODE, |
21448 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
21449 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
21450 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 21451 | |
21452 | /* Large Community List */ | |
7336e101 | 21453 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
21454 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
21455 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 21456 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
21457 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
21458 | install_element(CONFIG_NODE, | |
21459 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
21460 | install_element(CONFIG_NODE, |
21461 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
21462 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
21463 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
21464 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
21465 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
21466 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
21467 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
21468 | |
21469 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 21470 | } |
ed0e57e3 DA |
21471 | |
21472 | static struct cmd_node community_alias_node = { | |
21473 | .name = "community alias", | |
21474 | .node = COMMUNITY_ALIAS_NODE, | |
21475 | .prompt = "", | |
21476 | .config_write = bgp_community_alias_write, | |
21477 | }; | |
21478 | ||
21479 | void community_alias_vty(void) | |
21480 | { | |
21481 | install_node(&community_alias_node); | |
21482 | ||
21483 | /* Community-list. */ | |
21484 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
21485 | |
21486 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 21487 | } |