]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
4ab46701 | 25 | #include "lib/sockopt.h" |
5cb5f4d0 | 26 | #include "lib_errors.h" |
ec0ab544 | 27 | #include "lib/zclient.h" |
6f4eacf3 | 28 | #include "lib/printfrr.h" |
718e3744 | 29 | #include "prefix.h" |
30 | #include "plist.h" | |
31 | #include "buffer.h" | |
32 | #include "linklist.h" | |
33 | #include "stream.h" | |
34 | #include "thread.h" | |
35 | #include "log.h" | |
3b8b1855 | 36 | #include "memory.h" |
1c0d8808 | 37 | #include "lib_vty.h" |
4bf6a362 | 38 | #include "hash.h" |
3f9c7369 | 39 | #include "queue.h" |
039f3a34 | 40 | #include "filter.h" |
5d5ba018 | 41 | #include "frrstr.h" |
718e3744 | 42 | |
43 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 44 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 45 | #include "bgpd/bgp_advertise.h" |
718e3744 | 46 | #include "bgpd/bgp_attr.h" |
47 | #include "bgpd/bgp_aspath.h" | |
48 | #include "bgpd/bgp_community.h" | |
ed0e57e3 | 49 | #include "bgpd/bgp_community_alias.h" |
4bf6a362 | 50 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 51 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 52 | #include "bgpd/bgp_damp.h" |
718e3744 | 53 | #include "bgpd/bgp_debug.h" |
14454c9f | 54 | #include "bgpd/bgp_errors.h" |
e0701b79 | 55 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 56 | #include "bgpd/bgp_nexthop.h" |
4122b697 | 57 | #include "bgpd/bgp_network.h" |
718e3744 | 58 | #include "bgpd/bgp_open.h" |
4bf6a362 | 59 | #include "bgpd/bgp_regex.h" |
718e3744 | 60 | #include "bgpd/bgp_route.h" |
c016b6c7 | 61 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 62 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 63 | #include "bgpd/bgp_table.h" |
94f2b392 | 64 | #include "bgpd/bgp_vty.h" |
165b5fff | 65 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 66 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 67 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 68 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 69 | #include "bgpd/bgp_io.h" |
94c2f693 | 70 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 71 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 72 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 73 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 74 | #include "bgpd/bgp_mac.h" |
dd65f45e | 75 | #include "bgpd/bgp_flowspec.h" |
389e4f92 | 76 | #include "bgpd/bgp_conditional_adv.h" |
49e5a4a0 | 77 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
78 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
79 | #endif | |
80 | ||
5d5393b9 | 81 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
82 | { |
83 | .val_bool = false, | |
84 | .match_profile = "traditional", | |
85 | .match_version = "< 7.4", | |
86 | }, | |
87 | { .val_bool = true }, | |
67b0f40c | 88 | ); |
5d5393b9 | 89 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, |
4c1458b5 DL |
90 | { .val_bool = true, .match_profile = "datacenter", }, |
91 | { .val_bool = false }, | |
67b0f40c | 92 | ); |
aef999a2 DA |
93 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
94 | { .val_bool = true, .match_profile = "datacenter", }, | |
95 | { .val_bool = false }, | |
67b0f40c | 96 | ); |
5d5393b9 | 97 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
98 | { .val_bool = true, .match_profile = "datacenter", }, |
99 | { .val_bool = false }, | |
67b0f40c | 100 | ); |
5d5393b9 | 101 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, |
4c1458b5 DL |
102 | { .val_bool = true, .match_profile = "datacenter", }, |
103 | { .val_bool = false }, | |
67b0f40c | 104 | ); |
5d5393b9 DL |
105 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, |
106 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
107 | { .val_ulong = 120 }, | |
67b0f40c | 108 | ); |
5d5393b9 DL |
109 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, |
110 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
111 | { .val_ulong = 180 }, | |
67b0f40c | 112 | ); |
5d5393b9 DL |
113 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, |
114 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
115 | { .val_ulong = 60 }, | |
67b0f40c | 116 | ); |
1d3fdccf DA |
117 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
118 | { .val_bool = false, .match_profile = "datacenter", }, | |
119 | { .val_bool = false, .match_version = "< 7.4", }, | |
120 | { .val_bool = true }, | |
67b0f40c | 121 | ); |
2adac256 DA |
122 | FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES, |
123 | { .val_bool = false, .match_version = "< 7.6", }, | |
124 | { .val_bool = true }, | |
67b0f40c | 125 | ); |
f2ca5c5b DA |
126 | FRR_CFG_DEFAULT_BOOL(BGP_GRACEFUL_NOTIFICATION, |
127 | { .val_bool = false, .match_version = "< 8.3", }, | |
128 | { .val_bool = true }, | |
129 | ); | |
1ae314be DA |
130 | FRR_CFG_DEFAULT_BOOL(BGP_HARD_ADMIN_RESET, |
131 | { .val_bool = false, .match_version = "< 8.3", }, | |
132 | { .val_bool = true }, | |
133 | ); | |
5d5393b9 | 134 | |
dd65f45e DL |
135 | DEFINE_HOOK(bgp_inst_config_write, |
136 | (struct bgp *bgp, struct vty *vty), | |
8451921b DL |
137 | (bgp, vty)); |
138 | DEFINE_HOOK(bgp_snmp_update_last_changed, (struct bgp *bgp), (bgp)); | |
1ca2fd11 | 139 | DEFINE_HOOK(bgp_snmp_init_stats, (struct bgp *bgp), (bgp)); |
718e3744 | 140 | |
d62a17ae | 141 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
142 | struct prefix *range, int exact); | |
143 | ||
055679e9 | 144 | /* Show BGP peer's information. */ |
145 | enum show_type { | |
146 | show_all, | |
147 | show_peer, | |
148 | show_ipv4_all, | |
149 | show_ipv6_all, | |
150 | show_ipv4_peer, | |
151 | show_ipv6_peer | |
152 | }; | |
153 | ||
36235319 QY |
154 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
155 | struct prefix *range, int exact); | |
2986cac2 | 156 | |
36235319 QY |
157 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
158 | struct bgp *bgp, | |
159 | bool use_json, | |
160 | json_object *json); | |
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; | |
5c525538 RW |
182 | default: |
183 | /* not expected */ | |
184 | return BGP_IPV4_NODE; | |
d62a17ae | 185 | } |
d62a17ae | 186 | case AFI_IP6: |
187 | switch (safi) { | |
188 | case SAFI_UNICAST: | |
189 | return BGP_IPV6_NODE; | |
d62a17ae | 190 | case SAFI_MULTICAST: |
191 | return BGP_IPV6M_NODE; | |
d62a17ae | 192 | case SAFI_LABELED_UNICAST: |
193 | return BGP_IPV6L_NODE; | |
d62a17ae | 194 | case SAFI_MPLS_VPN: |
195 | return BGP_VPNV6_NODE; | |
7c40bf39 | 196 | case SAFI_FLOWSPEC: |
197 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
198 | default: |
199 | /* not expected */ | |
200 | return BGP_IPV4_NODE; | |
d62a17ae | 201 | } |
d62a17ae | 202 | case AFI_L2VPN: |
203 | return BGP_EVPN_NODE; | |
b26f891d | 204 | case AFI_UNSPEC: |
d62a17ae | 205 | case AFI_MAX: |
206 | // We should never be here but to clarify the switch statement.. | |
207 | return BGP_IPV4_NODE; | |
d62a17ae | 208 | } |
209 | ||
210 | // Impossible to happen | |
211 | return BGP_IPV4_NODE; | |
f51bae9c | 212 | } |
20eb8864 | 213 | |
5cb5f4d0 DD |
214 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
215 | { | |
7d0d37de DS |
216 | if (afi == AFI_IP) { |
217 | if (safi == SAFI_UNICAST) | |
218 | return "IPv4 Unicast"; | |
219 | if (safi == SAFI_MULTICAST) | |
220 | return "IPv4 Multicast"; | |
221 | if (safi == SAFI_LABELED_UNICAST) | |
222 | return "IPv4 Labeled Unicast"; | |
223 | if (safi == SAFI_MPLS_VPN) | |
224 | return "IPv4 VPN"; | |
225 | if (safi == SAFI_ENCAP) | |
226 | return "IPv4 Encap"; | |
227 | if (safi == SAFI_FLOWSPEC) | |
228 | return "IPv4 Flowspec"; | |
229 | } else if (afi == AFI_IP6) { | |
230 | if (safi == SAFI_UNICAST) | |
231 | return "IPv6 Unicast"; | |
232 | if (safi == SAFI_MULTICAST) | |
233 | return "IPv6 Multicast"; | |
234 | if (safi == SAFI_LABELED_UNICAST) | |
235 | return "IPv6 Labeled Unicast"; | |
236 | if (safi == SAFI_MPLS_VPN) | |
237 | return "IPv6 VPN"; | |
238 | if (safi == SAFI_ENCAP) | |
239 | return "IPv6 Encap"; | |
240 | if (safi == SAFI_FLOWSPEC) | |
241 | return "IPv6 Flowspec"; | |
242 | } else if (afi == AFI_L2VPN) { | |
243 | if (safi == SAFI_EVPN) | |
244 | return "L2VPN EVPN"; | |
245 | } | |
246 | ||
247 | return "Unknown"; | |
5cb5f4d0 DD |
248 | } |
249 | ||
250 | /* | |
251 | * Please note that we have intentionally camelCased | |
252 | * the return strings here. So if you want | |
253 | * to use this function, please ensure you | |
254 | * are doing this within json output | |
255 | */ | |
256 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
257 | { | |
7d0d37de DS |
258 | if (afi == AFI_IP) { |
259 | if (safi == SAFI_UNICAST) | |
260 | return "ipv4Unicast"; | |
261 | if (safi == SAFI_MULTICAST) | |
262 | return "ipv4Multicast"; | |
263 | if (safi == SAFI_LABELED_UNICAST) | |
264 | return "ipv4LabeledUnicast"; | |
265 | if (safi == SAFI_MPLS_VPN) | |
266 | return "ipv4Vpn"; | |
267 | if (safi == SAFI_ENCAP) | |
268 | return "ipv4Encap"; | |
269 | if (safi == SAFI_FLOWSPEC) | |
270 | return "ipv4Flowspec"; | |
271 | } else if (afi == AFI_IP6) { | |
272 | if (safi == SAFI_UNICAST) | |
273 | return "ipv6Unicast"; | |
274 | if (safi == SAFI_MULTICAST) | |
275 | return "ipv6Multicast"; | |
276 | if (safi == SAFI_LABELED_UNICAST) | |
277 | return "ipv6LabeledUnicast"; | |
278 | if (safi == SAFI_MPLS_VPN) | |
279 | return "ipv6Vpn"; | |
280 | if (safi == SAFI_ENCAP) | |
281 | return "ipv6Encap"; | |
282 | if (safi == SAFI_FLOWSPEC) | |
283 | return "ipv6Flowspec"; | |
284 | } else if (afi == AFI_L2VPN) { | |
285 | if (safi == SAFI_EVPN) | |
286 | return "l2VpnEvpn"; | |
287 | } | |
288 | ||
289 | return "Unknown"; | |
5cb5f4d0 DD |
290 | } |
291 | ||
0249b8b6 HS |
292 | /* unset srv6 locator */ |
293 | static int bgp_srv6_locator_unset(struct bgp *bgp) | |
294 | { | |
295 | int ret; | |
296 | struct listnode *node, *nnode; | |
1c21a234 | 297 | struct srv6_locator_chunk *chunk; |
0249b8b6 HS |
298 | struct bgp_srv6_function *func; |
299 | struct bgp *bgp_vrf; | |
300 | struct in6_addr *tovpn_sid; | |
301 | ||
302 | /* release chunk notification via ZAPI */ | |
303 | ret = bgp_zebra_srv6_manager_release_locator_chunk( | |
304 | bgp->srv6_locator_name); | |
305 | if (ret < 0) | |
306 | return -1; | |
307 | ||
308 | /* refresh chunks */ | |
309 | for (ALL_LIST_ELEMENTS(bgp->srv6_locator_chunks, node, nnode, chunk)) | |
310 | listnode_delete(bgp->srv6_locator_chunks, chunk); | |
311 | ||
312 | /* refresh functions */ | |
313 | for (ALL_LIST_ELEMENTS(bgp->srv6_functions, node, nnode, func)) | |
314 | listnode_delete(bgp->srv6_functions, func); | |
315 | ||
316 | /* refresh tovpn_sid */ | |
317 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { | |
318 | if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) | |
319 | continue; | |
320 | ||
321 | /* refresh vpnv4 tovpn_sid */ | |
322 | tovpn_sid = bgp_vrf->vpn_policy[AFI_IP].tovpn_sid; | |
323 | if (tovpn_sid) | |
324 | XFREE(MTYPE_BGP_SRV6_SID, | |
325 | bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); | |
326 | ||
327 | /* refresh vpnv6 tovpn_sid */ | |
328 | tovpn_sid = bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid; | |
329 | if (tovpn_sid) | |
330 | XFREE(MTYPE_BGP_SRV6_SID, | |
331 | bgp_vrf->vpn_policy[AFI_IP6].tovpn_sid); | |
332 | } | |
333 | ||
334 | /* update vpn bgp processes */ | |
335 | vpn_leak_postchange_all(); | |
336 | ||
337 | /* clear locator name */ | |
338 | memset(bgp->srv6_locator_name, 0, sizeof(bgp->srv6_locator_name)); | |
339 | ||
340 | return 0; | |
341 | } | |
342 | ||
718e3744 | 343 | /* Utility function to get address family from current node. */ |
d62a17ae | 344 | afi_t bgp_node_afi(struct vty *vty) |
345 | { | |
346 | afi_t afi; | |
347 | switch (vty->node) { | |
348 | case BGP_IPV6_NODE: | |
349 | case BGP_IPV6M_NODE: | |
350 | case BGP_IPV6L_NODE: | |
351 | case BGP_VPNV6_NODE: | |
7c40bf39 | 352 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 353 | afi = AFI_IP6; |
354 | break; | |
355 | case BGP_EVPN_NODE: | |
356 | afi = AFI_L2VPN; | |
357 | break; | |
358 | default: | |
359 | afi = AFI_IP; | |
360 | break; | |
361 | } | |
362 | return afi; | |
718e3744 | 363 | } |
364 | ||
365 | /* Utility function to get subsequent address family from current | |
366 | node. */ | |
d62a17ae | 367 | safi_t bgp_node_safi(struct vty *vty) |
368 | { | |
369 | safi_t safi; | |
370 | switch (vty->node) { | |
371 | case BGP_VPNV4_NODE: | |
372 | case BGP_VPNV6_NODE: | |
373 | safi = SAFI_MPLS_VPN; | |
374 | break; | |
375 | case BGP_IPV4M_NODE: | |
376 | case BGP_IPV6M_NODE: | |
377 | safi = SAFI_MULTICAST; | |
378 | break; | |
379 | case BGP_EVPN_NODE: | |
380 | safi = SAFI_EVPN; | |
381 | break; | |
382 | case BGP_IPV4L_NODE: | |
383 | case BGP_IPV6L_NODE: | |
384 | safi = SAFI_LABELED_UNICAST; | |
385 | break; | |
7c40bf39 | 386 | case BGP_FLOWSPECV4_NODE: |
387 | case BGP_FLOWSPECV6_NODE: | |
388 | safi = SAFI_FLOWSPEC; | |
389 | break; | |
d62a17ae | 390 | default: |
391 | safi = SAFI_UNICAST; | |
392 | break; | |
393 | } | |
394 | return safi; | |
718e3744 | 395 | } |
396 | ||
55f91488 QY |
397 | /** |
398 | * Converts an AFI in string form to afi_t | |
399 | * | |
400 | * @param afi string, one of | |
401 | * - "ipv4" | |
402 | * - "ipv6" | |
81cf0de5 | 403 | * - "l2vpn" |
55f91488 QY |
404 | * @return the corresponding afi_t |
405 | */ | |
d62a17ae | 406 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
407 | { | |
408 | afi_t afi = AFI_MAX; /* unknown */ | |
409 | if (strmatch(afi_str, "ipv4")) | |
410 | afi = AFI_IP; | |
411 | else if (strmatch(afi_str, "ipv6")) | |
412 | afi = AFI_IP6; | |
81cf0de5 CS |
413 | else if (strmatch(afi_str, "l2vpn")) |
414 | afi = AFI_L2VPN; | |
d62a17ae | 415 | return afi; |
416 | } | |
417 | ||
418 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
419 | afi_t *afi) | |
420 | { | |
421 | int ret = 0; | |
422 | if (argv_find(argv, argc, "ipv4", index)) { | |
423 | ret = 1; | |
424 | if (afi) | |
425 | *afi = AFI_IP; | |
426 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
427 | ret = 1; | |
428 | if (afi) | |
429 | *afi = AFI_IP6; | |
8688b3e7 DS |
430 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
431 | ret = 1; | |
432 | if (afi) | |
433 | *afi = AFI_L2VPN; | |
d62a17ae | 434 | } |
435 | return ret; | |
46f296b4 LB |
436 | } |
437 | ||
375a2e67 | 438 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 439 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
440 | { | |
441 | safi_t safi = SAFI_MAX; /* unknown */ | |
442 | if (strmatch(safi_str, "multicast")) | |
443 | safi = SAFI_MULTICAST; | |
444 | else if (strmatch(safi_str, "unicast")) | |
445 | safi = SAFI_UNICAST; | |
446 | else if (strmatch(safi_str, "vpn")) | |
447 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
448 | else if (strmatch(safi_str, "evpn")) |
449 | safi = SAFI_EVPN; | |
d62a17ae | 450 | else if (strmatch(safi_str, "labeled-unicast")) |
451 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 452 | else if (strmatch(safi_str, "flowspec")) |
453 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 454 | return safi; |
455 | } | |
456 | ||
457 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
458 | safi_t *safi) | |
459 | { | |
460 | int ret = 0; | |
461 | if (argv_find(argv, argc, "unicast", index)) { | |
462 | ret = 1; | |
463 | if (safi) | |
464 | *safi = SAFI_UNICAST; | |
465 | } else if (argv_find(argv, argc, "multicast", index)) { | |
466 | ret = 1; | |
467 | if (safi) | |
468 | *safi = SAFI_MULTICAST; | |
469 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
470 | ret = 1; | |
471 | if (safi) | |
472 | *safi = SAFI_LABELED_UNICAST; | |
473 | } else if (argv_find(argv, argc, "vpn", index)) { | |
474 | ret = 1; | |
475 | if (safi) | |
476 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
477 | } else if (argv_find(argv, argc, "evpn", index)) { |
478 | ret = 1; | |
479 | if (safi) | |
480 | *safi = SAFI_EVPN; | |
7c40bf39 | 481 | } else if (argv_find(argv, argc, "flowspec", index)) { |
482 | ret = 1; | |
483 | if (safi) | |
484 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 485 | } |
486 | return ret; | |
46f296b4 LB |
487 | } |
488 | ||
b16bcbba TA |
489 | /* |
490 | * Convert an afi_t/safi_t pair to matching BGP_DEFAULT_AF* flag. | |
491 | * | |
492 | * afi | |
493 | * address-family identifier | |
494 | * | |
495 | * safi | |
496 | * subsequent address-family identifier | |
497 | * | |
498 | * Returns: | |
499 | * default_af string corresponding to the supplied afi/safi pair. | |
500 | * If afi/safi is invalid or if flag for afi/safi doesn't exist, | |
501 | * return -1. | |
502 | */ | |
503 | static const char *get_bgp_default_af_flag(afi_t afi, safi_t safi) | |
504 | { | |
505 | switch (afi) { | |
506 | case AFI_IP: | |
507 | switch (safi) { | |
508 | case SAFI_UNICAST: | |
509 | return "ipv4-unicast"; | |
510 | case SAFI_MULTICAST: | |
511 | return "ipv4-multicast"; | |
512 | case SAFI_MPLS_VPN: | |
513 | return "ipv4-vpn"; | |
514 | case SAFI_ENCAP: | |
515 | return "ipv4-encap"; | |
516 | case SAFI_LABELED_UNICAST: | |
517 | return "ipv4-labeled-unicast"; | |
518 | case SAFI_FLOWSPEC: | |
519 | return "ipv4-flowspec"; | |
520 | default: | |
521 | return "unknown-afi/safi"; | |
522 | } | |
523 | break; | |
524 | case AFI_IP6: | |
525 | switch (safi) { | |
526 | case SAFI_UNICAST: | |
527 | return "ipv6-unicast"; | |
528 | case SAFI_MULTICAST: | |
529 | return "ipv6-multicast"; | |
530 | case SAFI_MPLS_VPN: | |
531 | return "ipv6-vpn"; | |
532 | case SAFI_ENCAP: | |
533 | return "ipv6-encap"; | |
534 | case SAFI_LABELED_UNICAST: | |
535 | return "ipv6-labeled-unicast"; | |
536 | case SAFI_FLOWSPEC: | |
537 | return "ipv6-flowspec"; | |
538 | default: | |
539 | return "unknown-afi/safi"; | |
540 | } | |
541 | break; | |
542 | case AFI_L2VPN: | |
543 | switch (safi) { | |
544 | case SAFI_EVPN: | |
545 | return "l2vpn-evpn"; | |
546 | default: | |
547 | return "unknown-afi/safi"; | |
548 | } | |
549 | case AFI_UNSPEC: | |
550 | case AFI_MAX: | |
551 | return "unknown-afi/safi"; | |
552 | } | |
553 | /* all AFIs are accounted for above, so this shouldn't happen */ | |
554 | return "unknown-afi/safi"; | |
555 | } | |
556 | ||
5d5393b9 DL |
557 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
558 | enum bgp_instance_type inst_type) | |
559 | { | |
560 | int ret = bgp_get(bgp, as, name, inst_type); | |
561 | ||
562 | if (ret == BGP_CREATED) { | |
563 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
d43114f3 | 564 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); |
5d5393b9 DL |
565 | |
566 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 567 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 568 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 569 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
570 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
571 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 572 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 573 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 574 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 575 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
576 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
577 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2adac256 DA |
578 | if (DFLT_BGP_SUPPRESS_DUPLICATES) |
579 | SET_FLAG((*bgp)->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
f2ca5c5b DA |
580 | if (DFLT_BGP_GRACEFUL_NOTIFICATION) |
581 | SET_FLAG((*bgp)->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
1ae314be DA |
582 | if (DFLT_BGP_HARD_ADMIN_RESET) |
583 | SET_FLAG((*bgp)->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
5d5393b9 DL |
584 | |
585 | ret = BGP_SUCCESS; | |
586 | } | |
587 | return ret; | |
588 | } | |
589 | ||
7eeee51e | 590 | /* |
f212a857 | 591 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 592 | * |
f212a857 DS |
593 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
594 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
595 | * to appropriate values for the calling function. This is to allow the |
596 | * calling function to make decisions appropriate for the show command | |
597 | * that is being parsed. | |
598 | * | |
599 | * The show commands are generally of the form: | |
d62a17ae | 600 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
601 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
602 | * |
603 | * Since we use argv_find if the show command in particular doesn't have: | |
604 | * [ip] | |
18c57037 | 605 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 606 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
607 | * The command parsing should still be ok. |
608 | * | |
609 | * vty -> The vty for the command so we can output some useful data in | |
610 | * the event of a parse error in the vrf. | |
611 | * argv -> The command tokens | |
612 | * argc -> How many command tokens we have | |
d62a17ae | 613 | * idx -> The current place in the command, generally should be 0 for this |
614 | * function | |
7eeee51e DS |
615 | * afi -> The parsed afi if it was included in the show command, returned here |
616 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 617 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 618 | * use_json -> json is configured or not |
7eeee51e DS |
619 | * |
620 | * The function returns the correct location in the parse tree for the | |
621 | * last token found. | |
0e37c258 DS |
622 | * |
623 | * Returns 0 for failure to parse correctly, else the idx position of where | |
624 | * it found the last token. | |
7eeee51e | 625 | */ |
d62a17ae | 626 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
627 | struct cmd_token **argv, int argc, | |
628 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 629 | struct bgp **bgp, bool use_json) |
d62a17ae | 630 | { |
631 | char *vrf_name = NULL; | |
632 | ||
633 | assert(afi); | |
634 | assert(safi); | |
635 | assert(bgp); | |
636 | ||
637 | if (argv_find(argv, argc, "ip", idx)) | |
638 | *afi = AFI_IP; | |
639 | ||
9a8bdf1c | 640 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 641 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
642 | else if (argv_find(argv, argc, "vrf", idx)) { |
643 | vrf_name = argv[*idx + 1]->arg; | |
644 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
645 | vrf_name = NULL; | |
646 | } | |
647 | if (vrf_name) { | |
d62a17ae | 648 | if (strmatch(vrf_name, "all")) |
649 | *bgp = NULL; | |
650 | else { | |
651 | *bgp = bgp_lookup_by_name(vrf_name); | |
652 | if (!*bgp) { | |
52e5b8c4 SP |
653 | if (use_json) { |
654 | json_object *json = NULL; | |
655 | json = json_object_new_object(); | |
656 | json_object_string_add( | |
657 | json, "warning", | |
658 | "View/Vrf is unknown"); | |
75eeda93 | 659 | vty_json(vty, json); |
52e5b8c4 | 660 | } |
ca61fd25 DS |
661 | else |
662 | vty_out(vty, "View/Vrf %s is unknown\n", | |
663 | vrf_name); | |
d62a17ae | 664 | *idx = 0; |
665 | return 0; | |
666 | } | |
667 | } | |
668 | } else { | |
669 | *bgp = bgp_get_default(); | |
670 | if (!*bgp) { | |
52e5b8c4 SP |
671 | if (use_json) { |
672 | json_object *json = NULL; | |
673 | json = json_object_new_object(); | |
674 | json_object_string_add( | |
675 | json, "warning", | |
676 | "Default BGP instance not found"); | |
75eeda93 | 677 | vty_json(vty, json); |
52e5b8c4 | 678 | } |
ca61fd25 DS |
679 | else |
680 | vty_out(vty, | |
681 | "Default BGP instance not found\n"); | |
d62a17ae | 682 | *idx = 0; |
683 | return 0; | |
684 | } | |
685 | } | |
686 | ||
687 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
688 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
689 | ||
690 | *idx += 1; | |
691 | return *idx; | |
692 | } | |
693 | ||
28c6e247 | 694 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 695 | { |
696 | struct interface *ifp = NULL; | |
4122b697 DA |
697 | struct listnode *node; |
698 | struct bgp_listener *listener; | |
699 | union sockunion all_su; | |
d62a17ae | 700 | |
4122b697 | 701 | if (su->sa.sa_family == AF_INET) { |
3d2a2725 | 702 | (void)str2sockunion("0.0.0.0", &all_su); |
d62a17ae | 703 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); |
4122b697 | 704 | } else if (su->sa.sa_family == AF_INET6) { |
3d2a2725 | 705 | (void)str2sockunion("::", &all_su); |
d62a17ae | 706 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, |
707 | su->sin6.sin6_scope_id, | |
708 | bgp->vrf_id); | |
4122b697 | 709 | } |
d62a17ae | 710 | |
4122b697 DA |
711 | if (ifp) { |
712 | for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, listener)) { | |
713 | if (sockunion_family(su) != | |
714 | sockunion_family(&listener->su)) | |
715 | continue; | |
716 | ||
717 | /* If 0.0.0.0/:: is a listener, then treat as self and | |
718 | * reject. | |
719 | */ | |
720 | if (!sockunion_cmp(&listener->su, su) || | |
721 | !sockunion_cmp(&listener->su, &all_su)) | |
722 | return true; | |
723 | } | |
724 | } | |
d62a17ae | 725 | |
3dc339cd | 726 | return false; |
718e3744 | 727 | } |
728 | ||
28c6e247 IR |
729 | /* Utility function for looking up peer from VTY. */ |
730 | /* This is used only for configuration, so disallow if attempted on | |
731 | * a dynamic neighbor. | |
732 | */ | |
733 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) | |
734 | { | |
735 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
736 | int ret; | |
737 | union sockunion su; | |
738 | struct peer *peer; | |
739 | ||
740 | if (!bgp) { | |
741 | return NULL; | |
742 | } | |
743 | ||
744 | ret = str2sockunion(ip_str, &su); | |
745 | if (ret < 0) { | |
746 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
747 | if (!peer) { | |
748 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
749 | == NULL) { | |
750 | vty_out(vty, | |
751 | "%% Malformed address or name: %s\n", | |
752 | ip_str); | |
753 | return NULL; | |
754 | } | |
755 | } | |
756 | } else { | |
757 | peer = peer_lookup(bgp, &su); | |
758 | if (!peer) { | |
759 | vty_out(vty, | |
760 | "%% Specify remote-as or peer-group commands first\n"); | |
761 | return NULL; | |
762 | } | |
763 | if (peer_dynamic_neighbor(peer)) { | |
764 | vty_out(vty, | |
765 | "%% Operation not allowed on a dynamic neighbor\n"); | |
766 | return NULL; | |
767 | } | |
768 | } | |
769 | return peer; | |
770 | } | |
771 | ||
718e3744 | 772 | /* Utility function for looking up peer or peer group. */ |
f14e6fdb DS |
773 | /* This is used only for configuration, so disallow if attempted on |
774 | * a dynamic neighbor. | |
775 | */ | |
d62a17ae | 776 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
777 | { | |
778 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
779 | int ret; | |
780 | union sockunion su; | |
781 | struct peer *peer = NULL; | |
782 | struct peer_group *group = NULL; | |
783 | ||
784 | if (!bgp) { | |
785 | return NULL; | |
786 | } | |
787 | ||
788 | ret = str2sockunion(peer_str, &su); | |
789 | if (ret == 0) { | |
790 | /* IP address, locate peer. */ | |
791 | peer = peer_lookup(bgp, &su); | |
792 | } else { | |
793 | /* Not IP, could match either peer configured on interface or a | |
794 | * group. */ | |
795 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
796 | if (!peer) | |
797 | group = peer_group_lookup(bgp, peer_str); | |
798 | } | |
799 | ||
800 | if (peer) { | |
801 | if (peer_dynamic_neighbor(peer)) { | |
802 | vty_out(vty, | |
803 | "%% Operation not allowed on a dynamic neighbor\n"); | |
804 | return NULL; | |
805 | } | |
806 | ||
807 | return peer; | |
808 | } | |
809 | ||
810 | if (group) | |
811 | return group->conf; | |
812 | ||
813 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
814 | ||
815 | return NULL; | |
816 | } | |
817 | ||
4b7e23e9 | 818 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret) |
d62a17ae | 819 | { |
820 | const char *str = NULL; | |
821 | ||
822 | switch (ret) { | |
4b7e23e9 DS |
823 | case BGP_SUCCESS: |
824 | case BGP_CREATED: | |
825 | case BGP_GR_NO_OPERATION: | |
826 | break; | |
d62a17ae | 827 | case BGP_ERR_INVALID_VALUE: |
828 | str = "Invalid value"; | |
829 | break; | |
830 | case BGP_ERR_INVALID_FLAG: | |
831 | str = "Invalid flag"; | |
832 | break; | |
833 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
834 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
835 | break; | |
836 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
837 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
838 | break; | |
839 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
840 | str = "Specify remote-as or peer-group remote AS first"; | |
841 | break; | |
842 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
843 | str = "Cannot change the peer-group. Deconfigure first"; | |
844 | break; | |
845 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
846 | str = "Peer is not a member of this peer-group"; | |
847 | break; | |
848 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
849 | str = "Prefix/distribute list can not co-exist"; | |
850 | break; | |
851 | case BGP_ERR_NOT_INTERNAL_PEER: | |
852 | str = "Invalid command. Not an internal neighbor"; | |
853 | break; | |
854 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
855 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
856 | break; | |
857 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
858 | str = "Local-AS allowed only for EBGP peers"; | |
859 | break; | |
860 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
861 | str = "Cannot have local-as same as BGP AS number"; | |
862 | break; | |
863 | case BGP_ERR_TCPSIG_FAILED: | |
864 | str = "Error while applying TCP-Sig to session(s)"; | |
865 | break; | |
866 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
867 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
868 | break; | |
869 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
870 | str = "ttl-security only allowed for EBGP peers"; | |
871 | break; | |
872 | case BGP_ERR_AS_OVERRIDE: | |
873 | str = "as-override cannot be configured for IBGP peers"; | |
874 | break; | |
875 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
876 | str = "Invalid limit for number of dynamic neighbors"; | |
877 | break; | |
878 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
879 | str = "Dynamic neighbor listen range already exists"; | |
880 | break; | |
881 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
882 | str = "Operation not allowed on a dynamic neighbor"; | |
883 | break; | |
884 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
885 | str = "Operation not allowed on a directly connected neighbor"; | |
886 | break; | |
887 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
a59803d0 | 888 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; |
055679e9 | 889 | break; |
890 | case BGP_ERR_GR_INVALID_CMD: | |
891 | str = "The Graceful Restart command used is not valid at this moment."; | |
892 | break; | |
893 | case BGP_ERR_GR_OPERATION_FAILED: | |
894 | str = "The Graceful Restart Operation failed due to an err."; | |
895 | break; | |
6dcea6fe DS |
896 | case BGP_ERR_PEER_GROUP_MEMBER: |
897 | str = "Peer-group member cannot override remote-as of peer-group."; | |
898 | break; | |
899 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
900 | str = "Peer-group members must be all internal or all external."; | |
901 | break; | |
4b7e23e9 DS |
902 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND: |
903 | str = "Range specified cannot be deleted because it is not part of current config."; | |
904 | break; | |
905 | case BGP_ERR_INSTANCE_MISMATCH: | |
906 | str = "Instance specified does not match the current instance."; | |
907 | break; | |
908 | case BGP_ERR_NO_INTERFACE_CONFIG: | |
909 | str = "Interface specified is not being used for interface based peer."; | |
910 | break; | |
911 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
912 | str = "No configuration already specified for soft reconfiguration."; | |
913 | break; | |
914 | case BGP_ERR_AS_MISMATCH: | |
915 | str = "BGP is already running."; | |
916 | break; | |
917 | case BGP_ERR_AF_UNCONFIGURED: | |
918 | str = "AFI/SAFI specified is not currently configured."; | |
919 | break; | |
920 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS_REMOTE_AS: | |
921 | str = "AS specified for local as is the same as the remote as and this is not allowed."; | |
922 | break; | |
923 | case BGP_ERR_INVALID_AS: | |
924 | str = "Confederation AS specified is the same AS as our AS."; | |
925 | break; | |
d62a17ae | 926 | } |
927 | if (str) { | |
928 | vty_out(vty, "%% %s\n", str); | |
929 | return CMD_WARNING_CONFIG_FAILED; | |
930 | } | |
931 | return CMD_SUCCESS; | |
718e3744 | 932 | } |
933 | ||
7aafcaca | 934 | /* BGP clear sort. */ |
d62a17ae | 935 | enum clear_sort { |
936 | clear_all, | |
937 | clear_peer, | |
938 | clear_group, | |
939 | clear_external, | |
940 | clear_as | |
7aafcaca DS |
941 | }; |
942 | ||
1ca2fd11 IR |
943 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
944 | safi_t safi, int error) | |
d62a17ae | 945 | { |
946 | switch (error) { | |
947 | case BGP_ERR_AF_UNCONFIGURED: | |
1ca2fd11 | 948 | vty_out(vty, |
664b6f18 | 949 | "%% BGP: Enable %s address family for the neighbor %s\n", |
1ca2fd11 | 950 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 951 | break; |
952 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
1ca2fd11 | 953 | vty_out(vty, |
664b6f18 | 954 | "%% BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", |
d62a17ae | 955 | peer->host); |
956 | break; | |
957 | default: | |
958 | break; | |
959 | } | |
7aafcaca DS |
960 | } |
961 | ||
dc912615 | 962 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 963 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
964 | { |
965 | int ret = 0; | |
2adac256 | 966 | struct peer_af *paf; |
dc912615 DS |
967 | |
968 | /* if afi/.safi not specified, spin thru all of them */ | |
969 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
970 | afi_t tmp_afi; | |
971 | safi_t tmp_safi; | |
0e5cdd59 DS |
972 | enum bgp_af_index index; |
973 | ||
974 | for (index = BGP_AF_START; index < BGP_AF_MAX; index++) { | |
975 | paf = peer->peer_af_array[index]; | |
976 | if (!paf) | |
977 | continue; | |
dc912615 | 978 | |
2adac256 DA |
979 | if (paf && paf->subgroup) |
980 | SET_FLAG(paf->subgroup->sflags, | |
981 | SUBGRP_STATUS_FORCE_UPDATES); | |
982 | ||
0e5cdd59 DS |
983 | tmp_afi = paf->afi; |
984 | tmp_safi = paf->safi; | |
dc912615 DS |
985 | if (!peer->afc[tmp_afi][tmp_safi]) |
986 | continue; | |
987 | ||
988 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 989 | ret = peer_clear(peer, nnode); |
dc912615 DS |
990 | else |
991 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
992 | stype); | |
993 | } | |
994 | /* if afi specified and safi not, spin thru safis on this afi */ | |
995 | } else if (safi == SAFI_UNSPEC) { | |
996 | safi_t tmp_safi; | |
997 | ||
998 | for (tmp_safi = SAFI_UNICAST; | |
999 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
1000 | if (!peer->afc[afi][tmp_safi]) | |
1001 | continue; | |
1002 | ||
2adac256 DA |
1003 | paf = peer_af_find(peer, afi, tmp_safi); |
1004 | if (paf && paf->subgroup) | |
1005 | SET_FLAG(paf->subgroup->sflags, | |
1006 | SUBGRP_STATUS_FORCE_UPDATES); | |
1007 | ||
dc912615 | 1008 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1009 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1010 | else |
1011 | ret = peer_clear_soft(peer, afi, | |
1012 | tmp_safi, stype); | |
1013 | } | |
1014 | /* both afi/safi specified, let the caller know if not defined */ | |
1015 | } else { | |
1016 | if (!peer->afc[afi][safi]) | |
1017 | return 1; | |
1018 | ||
2adac256 DA |
1019 | paf = peer_af_find(peer, afi, safi); |
1020 | if (paf && paf->subgroup) | |
1021 | SET_FLAG(paf->subgroup->sflags, | |
1022 | SUBGRP_STATUS_FORCE_UPDATES); | |
1023 | ||
dc912615 | 1024 | if (stype == BGP_CLEAR_SOFT_NONE) |
c368171c | 1025 | ret = peer_clear(peer, nnode); |
dc912615 DS |
1026 | else |
1027 | ret = peer_clear_soft(peer, afi, safi, stype); | |
1028 | } | |
1029 | ||
1030 | return ret; | |
1031 | } | |
1032 | ||
7aafcaca | 1033 | /* `clear ip bgp' functions. */ |
1ca2fd11 | 1034 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 1035 | enum clear_sort sort, enum bgp_clear_type stype, |
1ca2fd11 | 1036 | const char *arg) |
d62a17ae | 1037 | { |
dc912615 | 1038 | int ret = 0; |
3ae8bfa5 | 1039 | bool found = false; |
d62a17ae | 1040 | struct peer *peer; |
dc95985f | 1041 | |
1042 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 1043 | |
1044 | /* Clear all neighbors. */ | |
1045 | /* | |
1046 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
1047 | * nodes on the BGP instance as that may get freed if it is a |
1048 | * doppelganger | |
d62a17ae | 1049 | */ |
1050 | if (sort == clear_all) { | |
1051 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 1052 | |
1053 | bgp_peer_gr_flags_update(peer); | |
1054 | ||
36235319 | 1055 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 1056 | gr_router_detected = true; |
1057 | ||
c368171c | 1058 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 1059 | stype); |
d62a17ae | 1060 | |
1061 | if (ret < 0) | |
1ca2fd11 | 1062 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
dc95985f | 1063 | } |
1064 | ||
36235319 QY |
1065 | if (gr_router_detected |
1066 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1067 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1068 | } else if (!gr_router_detected |
1069 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1070 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 1071 | } |
d62a17ae | 1072 | |
1073 | /* This is to apply read-only mode on this clear. */ | |
1074 | if (stype == BGP_CLEAR_SOFT_NONE) | |
1075 | bgp->update_delay_over = 0; | |
1076 | ||
1077 | return CMD_SUCCESS; | |
7aafcaca DS |
1078 | } |
1079 | ||
3ae8bfa5 | 1080 | /* Clear specified neighbor. */ |
d62a17ae | 1081 | if (sort == clear_peer) { |
1082 | union sockunion su; | |
d62a17ae | 1083 | |
1084 | /* Make sockunion for lookup. */ | |
1085 | ret = str2sockunion(arg, &su); | |
1086 | if (ret < 0) { | |
1087 | peer = peer_lookup_by_conf_if(bgp, arg); | |
1088 | if (!peer) { | |
1089 | peer = peer_lookup_by_hostname(bgp, arg); | |
1090 | if (!peer) { | |
1ca2fd11 IR |
1091 | vty_out(vty, |
1092 | "Malformed address or name: %s\n", | |
d62a17ae | 1093 | arg); |
1094 | return CMD_WARNING; | |
1095 | } | |
1096 | } | |
1097 | } else { | |
1098 | peer = peer_lookup(bgp, &su); | |
1099 | if (!peer) { | |
1ca2fd11 | 1100 | vty_out(vty, |
664b6f18 | 1101 | "%% BGP: Unknown neighbor - \"%s\"\n", |
1ca2fd11 | 1102 | arg); |
d62a17ae | 1103 | return CMD_WARNING; |
1104 | } | |
1105 | } | |
7aafcaca | 1106 | |
dc95985f | 1107 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
1108 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
1109 | ||
dc912615 DS |
1110 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
1111 | ||
1112 | /* if afi/safi not defined for this peer, let caller know */ | |
1113 | if (ret == 1) | |
3ae8bfa5 | 1114 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 1115 | |
d62a17ae | 1116 | if (ret < 0) |
1ca2fd11 | 1117 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
7aafcaca | 1118 | |
d62a17ae | 1119 | return CMD_SUCCESS; |
7aafcaca | 1120 | } |
7aafcaca | 1121 | |
3ae8bfa5 | 1122 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 1123 | if (sort == clear_group) { |
1124 | struct peer_group *group; | |
7aafcaca | 1125 | |
d62a17ae | 1126 | group = peer_group_lookup(bgp, arg); |
1127 | if (!group) { | |
664b6f18 | 1128 | vty_out(vty, "%% BGP: No such peer-group %s\n", arg); |
d62a17ae | 1129 | return CMD_WARNING; |
1130 | } | |
1131 | ||
1132 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 1133 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1134 | |
d62a17ae | 1135 | if (ret < 0) |
1ca2fd11 | 1136 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1137 | else |
1138 | found = true; | |
d62a17ae | 1139 | } |
3ae8bfa5 PM |
1140 | |
1141 | if (!found) | |
1ca2fd11 | 1142 | vty_out(vty, |
664b6f18 | 1143 | "%% BGP: No %s peer belonging to peer-group %s is configured\n", |
5cb5f4d0 | 1144 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1145 | |
d62a17ae | 1146 | return CMD_SUCCESS; |
7aafcaca | 1147 | } |
7aafcaca | 1148 | |
3ae8bfa5 | 1149 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 1150 | if (sort == clear_external) { |
1151 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1152 | if (peer->sort == BGP_PEER_IBGP) | |
1153 | continue; | |
7aafcaca | 1154 | |
dc95985f | 1155 | bgp_peer_gr_flags_update(peer); |
1156 | ||
36235319 | 1157 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1158 | gr_router_detected = true; |
dc95985f | 1159 | |
c368171c | 1160 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 1161 | |
d62a17ae | 1162 | if (ret < 0) |
1ca2fd11 | 1163 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1164 | else |
1165 | found = true; | |
d62a17ae | 1166 | } |
3ae8bfa5 | 1167 | |
36235319 QY |
1168 | if (gr_router_detected |
1169 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1170 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1171 | } else if (!gr_router_detected |
1172 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1173 | bgp_zebra_send_capabilities(bgp, true); |
1174 | } | |
1175 | ||
3ae8bfa5 | 1176 | if (!found) |
1ca2fd11 | 1177 | vty_out(vty, |
664b6f18 | 1178 | "%% BGP: No external %s peer is configured\n", |
1ca2fd11 | 1179 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 1180 | |
d62a17ae | 1181 | return CMD_SUCCESS; |
1182 | } | |
1183 | ||
3ae8bfa5 | 1184 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 1185 | if (sort == clear_as) { |
3ae8bfa5 | 1186 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 1187 | |
1188 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1189 | if (peer->as != as) | |
1190 | continue; | |
1191 | ||
dc95985f | 1192 | bgp_peer_gr_flags_update(peer); |
1193 | ||
36235319 | 1194 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 1195 | gr_router_detected = true; |
dc95985f | 1196 | |
c368171c | 1197 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1198 | |
1199 | if (ret < 0) | |
1ca2fd11 | 1200 | bgp_clear_vty_error(vty, peer, afi, safi, ret); |
3ae8bfa5 PM |
1201 | else |
1202 | found = true; | |
d62a17ae | 1203 | } |
3ae8bfa5 | 1204 | |
36235319 QY |
1205 | if (gr_router_detected |
1206 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1207 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1208 | } else if (!gr_router_detected |
1209 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1210 | bgp_zebra_send_capabilities(bgp, true); |
1211 | } | |
1212 | ||
3ae8bfa5 | 1213 | if (!found) |
1ca2fd11 | 1214 | vty_out(vty, |
664b6f18 | 1215 | "%% BGP: No %s peer is configured with AS %s\n", |
1ca2fd11 | 1216 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 1217 | |
d62a17ae | 1218 | return CMD_SUCCESS; |
1219 | } | |
1220 | ||
1221 | return CMD_SUCCESS; | |
1222 | } | |
1223 | ||
1ca2fd11 IR |
1224 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, |
1225 | safi_t safi, enum clear_sort sort, | |
1226 | enum bgp_clear_type stype, const char *arg) | |
d62a17ae | 1227 | { |
1228 | struct bgp *bgp; | |
1229 | ||
1230 | /* BGP structure lookup. */ | |
1231 | if (name) { | |
1232 | bgp = bgp_lookup_by_name(name); | |
1233 | if (bgp == NULL) { | |
1ca2fd11 | 1234 | vty_out(vty, "Can't find BGP instance %s\n", name); |
d62a17ae | 1235 | return CMD_WARNING; |
1236 | } | |
1237 | } else { | |
1238 | bgp = bgp_get_default(); | |
1239 | if (bgp == NULL) { | |
1ca2fd11 | 1240 | vty_out(vty, "No BGP process is configured\n"); |
d62a17ae | 1241 | return CMD_WARNING; |
1242 | } | |
1243 | } | |
1244 | ||
1ca2fd11 | 1245 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); |
7aafcaca DS |
1246 | } |
1247 | ||
1248 | /* clear soft inbound */ | |
1ca2fd11 | 1249 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1250 | { |
99b3ebd3 NS |
1251 | afi_t afi; |
1252 | safi_t safi; | |
1253 | ||
1ca2fd11 IR |
1254 | FOREACH_AFI_SAFI (afi, safi) |
1255 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1256 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1257 | } |
1258 | ||
1259 | /* clear soft outbound */ | |
1ca2fd11 | 1260 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1261 | { |
99b3ebd3 NS |
1262 | afi_t afi; |
1263 | safi_t safi; | |
1264 | ||
1ca2fd11 IR |
1265 | FOREACH_AFI_SAFI (afi, safi) |
1266 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1267 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1268 | } |
1269 | ||
1270 | ||
f787d7a0 | 1271 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1272 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1273 | #endif |
1274 | ||
8029b216 AK |
1275 | DEFUN_HIDDEN (bgp_local_mac, |
1276 | bgp_local_mac_cmd, | |
093e3f23 | 1277 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1278 | BGP_STR |
1279 | "Local MAC config\n" | |
1280 | "VxLAN Network Identifier\n" | |
1281 | "VNI number\n" | |
1282 | "local mac\n" | |
1283 | "mac address\n" | |
1284 | "mac-mobility sequence\n" | |
1285 | "seq number\n") | |
1286 | { | |
1287 | int rv; | |
1288 | vni_t vni; | |
1289 | struct ethaddr mac; | |
1290 | struct ipaddr ip; | |
1291 | uint32_t seq; | |
1292 | struct bgp *bgp; | |
1293 | ||
1294 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1295 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1296 | vty_out(vty, "%% Malformed MAC address\n"); | |
1297 | return CMD_WARNING; | |
1298 | } | |
1299 | memset(&ip, 0, sizeof(ip)); | |
1300 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1301 | ||
1302 | bgp = bgp_get_default(); | |
1303 | if (!bgp) { | |
1304 | vty_out(vty, "Default BGP instance is not there\n"); | |
1305 | return CMD_WARNING; | |
1306 | } | |
1307 | ||
b5e140c8 AK |
1308 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1309 | zero_esi); | |
8029b216 AK |
1310 | if (rv < 0) { |
1311 | vty_out(vty, "Internal error\n"); | |
1312 | return CMD_WARNING; | |
1313 | } | |
1314 | ||
1315 | return CMD_SUCCESS; | |
1316 | } | |
1317 | ||
1318 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1319 | no_bgp_local_mac_cmd, | |
093e3f23 | 1320 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1321 | NO_STR |
1322 | BGP_STR | |
1323 | "Local MAC config\n" | |
1324 | "VxLAN Network Identifier\n" | |
1325 | "VNI number\n" | |
1326 | "local mac\n" | |
1327 | "mac address\n") | |
1328 | { | |
1329 | int rv; | |
1330 | vni_t vni; | |
1331 | struct ethaddr mac; | |
1332 | struct ipaddr ip; | |
1333 | struct bgp *bgp; | |
1334 | ||
1335 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1336 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1337 | vty_out(vty, "%% Malformed MAC address\n"); | |
1338 | return CMD_WARNING; | |
1339 | } | |
1340 | memset(&ip, 0, sizeof(ip)); | |
1341 | ||
1342 | bgp = bgp_get_default(); | |
1343 | if (!bgp) { | |
1344 | vty_out(vty, "Default BGP instance is not there\n"); | |
1345 | return CMD_WARNING; | |
1346 | } | |
1347 | ||
ec0ab544 | 1348 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1349 | if (rv < 0) { |
1350 | vty_out(vty, "Internal error\n"); | |
1351 | return CMD_WARNING; | |
1352 | } | |
1353 | ||
1354 | return CMD_SUCCESS; | |
1355 | } | |
1356 | ||
718e3744 | 1357 | DEFUN (no_synchronization, |
1358 | no_synchronization_cmd, | |
1359 | "no synchronization", | |
1360 | NO_STR | |
1361 | "Perform IGP synchronization\n") | |
1362 | { | |
d62a17ae | 1363 | return CMD_SUCCESS; |
718e3744 | 1364 | } |
1365 | ||
1366 | DEFUN (no_auto_summary, | |
1367 | no_auto_summary_cmd, | |
1368 | "no auto-summary", | |
1369 | NO_STR | |
1370 | "Enable automatic network number summarization\n") | |
1371 | { | |
d62a17ae | 1372 | return CMD_SUCCESS; |
718e3744 | 1373 | } |
3d515fd9 | 1374 | |
718e3744 | 1375 | /* "router bgp" commands. */ |
1ca2fd11 IR |
1376 | DEFUN_NOSH (router_bgp, |
1377 | router_bgp_cmd, | |
1378 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1379 | ROUTER_STR | |
1380 | BGP_STR | |
1381 | AS_STR | |
1382 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1383 | { |
d62a17ae | 1384 | int idx_asn = 2; |
1385 | int idx_view_vrf = 3; | |
1386 | int idx_vrf = 4; | |
1ca2fd11 IR |
1387 | int is_new_bgp = 0; |
1388 | int ret; | |
d62a17ae | 1389 | as_t as; |
1390 | struct bgp *bgp; | |
1391 | const char *name = NULL; | |
1392 | enum bgp_instance_type inst_type; | |
1393 | ||
1394 | // "router bgp" without an ASN | |
1395 | if (argc == 2) { | |
1396 | // Pending: Make VRF option available for ASN less config | |
1abef40f | 1397 | bgp = bgp_get_default(); |
d62a17ae | 1398 | |
1abef40f | 1399 | if (bgp == NULL) { |
d62a17ae | 1400 | vty_out(vty, "%% No BGP process is configured\n"); |
1401 | return CMD_WARNING_CONFIG_FAILED; | |
1402 | } | |
1403 | ||
1404 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1405 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1406 | return CMD_WARNING_CONFIG_FAILED; |
1407 | } | |
1408 | } | |
1409 | ||
1410 | // "router bgp X" | |
1411 | else { | |
ff8a8a7a | 1412 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1ca2fd11 | 1413 | |
cc413e2a DA |
1414 | if (as == BGP_PRIVATE_AS_MAX || as == BGP_AS4_MAX) |
1415 | vty_out(vty, "Reserved AS used (%u|%u); AS is %u\n", | |
1416 | BGP_PRIVATE_AS_MAX, BGP_AS4_MAX, as); | |
1417 | ||
d62a17ae | 1418 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1419 | if (argc > 3) { | |
1420 | name = argv[idx_vrf]->arg; | |
1421 | ||
9a8bdf1c PG |
1422 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1423 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1424 | name = NULL; | |
1425 | else | |
1426 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1ca2fd11 | 1427 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
d62a17ae | 1428 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
d62a17ae | 1429 | } |
1430 | ||
1ca2fd11 IR |
1431 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1432 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
3bd70bf8 | 1433 | |
1ca2fd11 IR |
1434 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
1435 | switch (ret) { | |
1436 | case BGP_ERR_AS_MISMATCH: | |
1437 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1438 | return CMD_WARNING_CONFIG_FAILED; | |
1439 | case BGP_ERR_INSTANCE_MISMATCH: | |
1440 | vty_out(vty, | |
1441 | "BGP instance name and AS number mismatch\n"); | |
1442 | vty_out(vty, | |
1443 | "BGP instance is already running; AS is %u\n", | |
1444 | as); | |
1445 | return CMD_WARNING_CONFIG_FAILED; | |
ff8a8a7a | 1446 | } |
1ca2fd11 IR |
1447 | |
1448 | /* | |
1449 | * If we just instantiated the default instance, complete | |
1450 | * any pending VRF-VPN leaking that was configured via | |
1451 | * earlier "router bgp X vrf FOO" blocks. | |
1452 | */ | |
1453 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
1454 | vpn_leak_postchange_all(); | |
1455 | ||
1456 | if (inst_type == BGP_INSTANCE_TYPE_VRF) | |
1457 | bgp_vpn_leak_export(bgp); | |
1458 | /* Pending: handle when user tries to change a view to vrf n vv. | |
1459 | */ | |
d62a17ae | 1460 | } |
1461 | ||
1ca2fd11 IR |
1462 | /* unset the auto created flag as the user config is now present */ |
1463 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
1464 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1465 | ||
1466 | return CMD_SUCCESS; | |
718e3744 | 1467 | } |
1468 | ||
718e3744 | 1469 | /* "no router bgp" commands. */ |
1ca2fd11 IR |
1470 | DEFUN (no_router_bgp, |
1471 | no_router_bgp_cmd, | |
1472 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1473 | NO_STR | |
1474 | ROUTER_STR | |
1475 | BGP_STR | |
1476 | AS_STR | |
1477 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1478 | { |
4fd9919e | 1479 | int idx_asn = 3; |
d62a17ae | 1480 | int idx_vrf = 5; |
1ca2fd11 | 1481 | as_t as; |
4fd9919e | 1482 | struct bgp *bgp; |
d62a17ae | 1483 | const char *name = NULL; |
718e3744 | 1484 | |
d62a17ae | 1485 | // "no router bgp" without an ASN |
1486 | if (argc == 3) { | |
1487 | // Pending: Make VRF option available for ASN less config | |
8382083a | 1488 | bgp = bgp_get_default(); |
718e3744 | 1489 | |
8382083a | 1490 | if (bgp == NULL) { |
d62a17ae | 1491 | vty_out(vty, "%% No BGP process is configured\n"); |
1492 | return CMD_WARNING_CONFIG_FAILED; | |
1493 | } | |
7fb21a9f | 1494 | |
d62a17ae | 1495 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1496 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1497 | return CMD_WARNING_CONFIG_FAILED; |
1498 | } | |
4fd9919e | 1499 | |
4fd9919e | 1500 | if (bgp->l3vni) { |
be125e6f | 1501 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
4fd9919e IR |
1502 | bgp->l3vni); |
1503 | return CMD_WARNING_CONFIG_FAILED; | |
1504 | } | |
d62a17ae | 1505 | } else { |
4fd9919e IR |
1506 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
1507 | ||
1ca42c8d | 1508 | if (argc > 4) { |
d62a17ae | 1509 | name = argv[idx_vrf]->arg; |
1ca42c8d IR |
1510 | if (strmatch(argv[idx_vrf - 1]->text, "vrf") |
1511 | && strmatch(name, VRF_DEFAULT_NAME)) | |
1512 | name = NULL; | |
1513 | } | |
7fb21a9f | 1514 | |
4fd9919e IR |
1515 | /* Lookup bgp structure. */ |
1516 | bgp = bgp_lookup(as, name); | |
1517 | if (!bgp) { | |
1518 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1519 | return CMD_WARNING_CONFIG_FAILED; | |
1520 | } | |
1521 | ||
1522 | if (bgp->l3vni) { | |
1523 | vty_out(vty, "%% Please unconfigure l3vni %u\n", | |
1524 | bgp->l3vni); | |
1525 | return CMD_WARNING_CONFIG_FAILED; | |
1526 | } | |
1527 | ||
1528 | /* Cannot delete default instance if vrf instances exist */ | |
1529 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1530 | struct listnode *node; | |
1531 | struct bgp *tmp_bgp; | |
1532 | ||
1533 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1534 | if (tmp_bgp->inst_type != BGP_INSTANCE_TYPE_VRF) | |
1535 | continue; | |
1536 | if (CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1537 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1538 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1539 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT) || | |
1540 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1541 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1542 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1543 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) || | |
1544 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP][SAFI_UNICAST], | |
1545 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1546 | CHECK_FLAG(tmp_bgp->af_flags[AFI_IP6][SAFI_UNICAST], | |
1547 | BGP_CONFIG_VRF_TO_VRF_EXPORT) || | |
1548 | (bgp == bgp_get_evpn() && | |
1549 | (CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1550 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST) || | |
1551 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1552 | BGP_L2VPN_EVPN_ADV_IPV4_UNICAST_GW_IP) || | |
1553 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1554 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST) || | |
1555 | CHECK_FLAG(tmp_bgp->af_flags[AFI_L2VPN][SAFI_EVPN], | |
1556 | BGP_L2VPN_EVPN_ADV_IPV6_UNICAST_GW_IP))) || | |
f33bf7c0 | 1557 | (hashcount(tmp_bgp->vnihash))) { |
4fd9919e IR |
1558 | vty_out(vty, |
1559 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1560 | return CMD_WARNING_CONFIG_FAILED; | |
1561 | } | |
1562 | } | |
1563 | } | |
d62a17ae | 1564 | } |
718e3744 | 1565 | |
1ca2fd11 | 1566 | bgp_delete(bgp); |
718e3744 | 1567 | |
1ca2fd11 | 1568 | return CMD_SUCCESS; |
718e3744 | 1569 | } |
1570 | ||
425bd64b PS |
1571 | /* bgp session-dscp */ |
1572 | ||
1573 | DEFPY (bgp_session_dscp, | |
1574 | bgp_session_dscp_cmd, | |
1575 | "bgp session-dscp (0-63)$dscp", | |
1576 | BGP_STR | |
1577 | "Override default (C6) bgp TCP session DSCP value\n" | |
1578 | "Manually configured dscp parameter\n") | |
1579 | { | |
1580 | bm->tcp_dscp = dscp << 2; | |
1581 | ||
1582 | return CMD_SUCCESS; | |
1583 | } | |
1584 | ||
1585 | DEFPY (no_bgp_session_dscp, | |
1586 | no_bgp_session_dscp_cmd, | |
1587 | "no bgp session-dscp [(0-63)]", | |
1588 | NO_STR | |
1589 | BGP_STR | |
1590 | "Override default (C6) bgp TCP session DSCP value\n" | |
1591 | "Manually configured dscp parameter\n") | |
1592 | { | |
1593 | bm->tcp_dscp = IPTOS_PREC_INTERNETCONTROL; | |
1594 | ||
1595 | return CMD_SUCCESS; | |
1596 | } | |
718e3744 | 1597 | |
ff8a8a7a CS |
1598 | /* BGP router-id. */ |
1599 | ||
1ca2fd11 IR |
1600 | DEFPY (bgp_router_id, |
1601 | bgp_router_id_cmd, | |
1602 | "bgp router-id A.B.C.D", | |
1603 | BGP_STR | |
1604 | "Override configured router identifier\n" | |
1605 | "Manually configured router identifier\n") | |
718e3744 | 1606 | { |
1ca2fd11 IR |
1607 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1608 | bgp_router_id_static_set(bgp, router_id); | |
1609 | return CMD_SUCCESS; | |
ff8a8a7a | 1610 | } |
718e3744 | 1611 | |
1ca2fd11 IR |
1612 | DEFPY (no_bgp_router_id, |
1613 | no_bgp_router_id_cmd, | |
1614 | "no bgp router-id [A.B.C.D]", | |
1615 | NO_STR | |
1616 | BGP_STR | |
1617 | "Override configured router identifier\n" | |
1618 | "Manually configured router identifier\n") | |
ff8a8a7a | 1619 | { |
1ca2fd11 | 1620 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1621 | |
1ca2fd11 IR |
1622 | if (router_id_str) { |
1623 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1624 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1625 | return CMD_WARNING_CONFIG_FAILED; | |
1626 | } | |
1627 | } | |
718e3744 | 1628 | |
1ca2fd11 IR |
1629 | router_id.s_addr = 0; |
1630 | bgp_router_id_static_set(bgp, router_id); | |
1631 | ||
1632 | return CMD_SUCCESS; | |
ff8a8a7a | 1633 | } |
6b0655a2 | 1634 | |
ed0e57e3 | 1635 | DEFPY(bgp_community_alias, bgp_community_alias_cmd, |
b4ad2fae | 1636 | "[no$no] bgp community alias WORD$community ALIAS_NAME$alias_name", |
ed0e57e3 DA |
1637 | NO_STR BGP_STR |
1638 | "Add community specific parameters\n" | |
1639 | "Create an alias for a community\n" | |
1640 | "Community (AA:BB or AA:BB:CC)\n" | |
1641 | "Alias name\n") | |
1642 | { | |
8cfa1e78 | 1643 | struct community_alias ca = {}; |
ed0e57e3 DA |
1644 | struct community_alias *lookup_community; |
1645 | struct community_alias *lookup_alias; | |
d13d137a DA |
1646 | struct community *comm; |
1647 | struct lcommunity *lcomm; | |
1648 | uint8_t invalid = 0; | |
ed0e57e3 | 1649 | |
d13d137a DA |
1650 | comm = community_str2com(community); |
1651 | if (!comm) | |
1652 | invalid++; | |
1653 | community_free(&comm); | |
1654 | ||
1655 | lcomm = lcommunity_str2com(community); | |
1656 | if (!lcomm) | |
1657 | invalid++; | |
1658 | lcommunity_free(&lcomm); | |
1659 | ||
1660 | if (invalid > 1) { | |
ed0e57e3 DA |
1661 | vty_out(vty, "Invalid community format\n"); |
1662 | return CMD_WARNING; | |
1663 | } | |
1664 | ||
8cfa1e78 DA |
1665 | strlcpy(ca.community, community, sizeof(ca.community)); |
1666 | strlcpy(ca.alias, alias_name, sizeof(ca.alias)); | |
ed0e57e3 | 1667 | |
8cfa1e78 DA |
1668 | lookup_community = bgp_ca_community_lookup(&ca); |
1669 | lookup_alias = bgp_ca_alias_lookup(&ca); | |
ed0e57e3 DA |
1670 | |
1671 | if (no) { | |
8cfa1e78 DA |
1672 | bgp_ca_alias_delete(&ca); |
1673 | bgp_ca_community_delete(&ca); | |
ed0e57e3 DA |
1674 | } else { |
1675 | if (lookup_alias) { | |
1676 | /* Lookup if community hash table has an item | |
1677 | * with the same alias name. | |
1678 | */ | |
8cfa1e78 DA |
1679 | strlcpy(ca.community, lookup_alias->community, |
1680 | sizeof(ca.community)); | |
1681 | if (bgp_ca_community_lookup(&ca)) { | |
ed0e57e3 DA |
1682 | vty_out(vty, |
1683 | "community (%s) already has this alias (%s)\n", | |
1684 | lookup_alias->community, | |
1685 | lookup_alias->alias); | |
1686 | return CMD_WARNING; | |
1687 | } | |
8cfa1e78 | 1688 | bgp_ca_alias_delete(&ca); |
ed0e57e3 DA |
1689 | } |
1690 | ||
8cfa1e78 DA |
1691 | if (lookup_community) { |
1692 | /* Lookup if alias hash table has an item | |
1693 | * with the same community. | |
1694 | */ | |
1695 | strlcpy(ca.alias, lookup_community->alias, | |
1696 | sizeof(ca.alias)); | |
1697 | if (bgp_ca_alias_lookup(&ca)) { | |
1698 | vty_out(vty, | |
1699 | "alias (%s) already has this community (%s)\n", | |
1700 | lookup_community->alias, | |
1701 | lookup_community->community); | |
1702 | return CMD_WARNING; | |
1703 | } | |
1704 | bgp_ca_community_delete(&ca); | |
1705 | } | |
ed0e57e3 | 1706 | |
8cfa1e78 DA |
1707 | bgp_ca_alias_insert(&ca); |
1708 | bgp_ca_community_insert(&ca); | |
ed0e57e3 DA |
1709 | } |
1710 | ||
1711 | return CMD_SUCCESS; | |
1712 | } | |
1713 | ||
9acb67cb DS |
1714 | DEFPY (bgp_global_suppress_fib_pending, |
1715 | bgp_global_suppress_fib_pending_cmd, | |
1716 | "[no] bgp suppress-fib-pending", | |
1717 | NO_STR | |
1718 | BGP_STR | |
1719 | "Advertise only routes that are programmed in kernel to peers globally\n") | |
1720 | { | |
1721 | bm_wait_for_fib_set(!no); | |
1722 | ||
1723 | return CMD_SUCCESS; | |
1724 | } | |
1725 | ||
c208c586 S |
1726 | DEFPY (bgp_suppress_fib_pending, |
1727 | bgp_suppress_fib_pending_cmd, | |
1728 | "[no] bgp suppress-fib-pending", | |
1729 | NO_STR | |
1730 | BGP_STR | |
1731 | "Advertise only routes that are programmed in kernel to peers\n") | |
1732 | { | |
1733 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1734 | ||
1735 | bgp_suppress_fib_pending_set(bgp, !no); | |
1736 | return CMD_SUCCESS; | |
1737 | } | |
1738 | ||
1739 | ||
718e3744 | 1740 | /* BGP Cluster ID. */ |
1ca2fd11 IR |
1741 | DEFUN (bgp_cluster_id, |
1742 | bgp_cluster_id_cmd, | |
1743 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1744 | BGP_STR | |
1745 | "Configure Route-Reflector Cluster-id\n" | |
1746 | "Route-Reflector Cluster-id in IP address format\n" | |
1747 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1748 | { |
1ca2fd11 | 1749 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1750 | int idx_ipv4 = 2; |
1ca2fd11 IR |
1751 | int ret; |
1752 | struct in_addr cluster; | |
1753 | ||
1754 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); | |
1755 | if (!ret) { | |
1756 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1757 | return CMD_WARNING_CONFIG_FAILED; | |
1758 | } | |
718e3744 | 1759 | |
1ca2fd11 IR |
1760 | bgp_cluster_id_set(bgp, &cluster); |
1761 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1762 | |
1ca2fd11 | 1763 | return CMD_SUCCESS; |
718e3744 | 1764 | } |
1765 | ||
1ca2fd11 IR |
1766 | DEFUN (no_bgp_cluster_id, |
1767 | no_bgp_cluster_id_cmd, | |
1768 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1769 | NO_STR | |
1770 | BGP_STR | |
1771 | "Configure Route-Reflector Cluster-id\n" | |
1772 | "Route-Reflector Cluster-id in IP address format\n" | |
1773 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1774 | { |
1ca2fd11 IR |
1775 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1776 | bgp_cluster_id_unset(bgp); | |
1777 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1778 | |
1ca2fd11 | 1779 | return CMD_SUCCESS; |
718e3744 | 1780 | } |
1781 | ||
c163f297 DS |
1782 | DEFPY (bgp_norib, |
1783 | bgp_norib_cmd, | |
1784 | "bgp no-rib", | |
1785 | BGP_STR | |
1786 | "Disable BGP route installation to RIB (Zebra)\n") | |
1787 | { | |
1788 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1789 | vty_out(vty, | |
1790 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1791 | return CMD_SUCCESS; | |
1792 | } | |
1793 | ||
1794 | bgp_option_norib_set_runtime(); | |
1795 | ||
1796 | return CMD_SUCCESS; | |
1797 | } | |
1798 | ||
1799 | DEFPY (no_bgp_norib, | |
1800 | no_bgp_norib_cmd, | |
1801 | "no bgp no-rib", | |
1802 | NO_STR | |
1803 | BGP_STR | |
1804 | "Disable BGP route installation to RIB (Zebra)\n") | |
1805 | { | |
1806 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1807 | vty_out(vty, | |
1808 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1809 | return CMD_SUCCESS; | |
1810 | } | |
1811 | ||
1812 | bgp_option_norib_unset_runtime(); | |
1813 | ||
1814 | return CMD_SUCCESS; | |
1815 | } | |
1816 | ||
e46723a5 DS |
1817 | DEFPY (no_bgp_send_extra_data, |
1818 | no_bgp_send_extra_data_cmd, | |
1819 | "[no] bgp send-extra-data zebra", | |
1820 | NO_STR | |
1821 | BGP_STR | |
1822 | "Extra data to Zebra for display/use\n" | |
1823 | "To zebra\n") | |
1824 | { | |
ec0acb80 DA |
1825 | if (no) |
1826 | UNSET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
1827 | else | |
1828 | SET_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA); | |
e46723a5 DS |
1829 | |
1830 | return CMD_SUCCESS; | |
1831 | } | |
1832 | ||
1ca2fd11 IR |
1833 | DEFUN (bgp_confederation_identifier, |
1834 | bgp_confederation_identifier_cmd, | |
1835 | "bgp confederation identifier (1-4294967295)", | |
e9273987 | 1836 | BGP_STR |
1ca2fd11 IR |
1837 | "AS confederation parameters\n" |
1838 | "AS number\n" | |
1839 | "Set routing domain confederation AS\n") | |
718e3744 | 1840 | { |
1ca2fd11 | 1841 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1842 | int idx_number = 3; |
1ca2fd11 | 1843 | as_t as; |
718e3744 | 1844 | |
1ca2fd11 | 1845 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1846 | |
1ca2fd11 | 1847 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1848 | |
1ca2fd11 | 1849 | return CMD_SUCCESS; |
718e3744 | 1850 | } |
1851 | ||
1ca2fd11 IR |
1852 | DEFUN (no_bgp_confederation_identifier, |
1853 | no_bgp_confederation_identifier_cmd, | |
1854 | "no bgp confederation identifier [(1-4294967295)]", | |
1855 | NO_STR | |
e9273987 | 1856 | BGP_STR |
1ca2fd11 IR |
1857 | "AS confederation parameters\n" |
1858 | "AS number\n" | |
1859 | "Set routing domain confederation AS\n") | |
ff8a8a7a | 1860 | { |
1ca2fd11 IR |
1861 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1862 | bgp_confederation_id_unset(bgp); | |
1863 | ||
1864 | return CMD_SUCCESS; | |
ff8a8a7a CS |
1865 | } |
1866 | ||
1ca2fd11 IR |
1867 | DEFUN (bgp_confederation_peers, |
1868 | bgp_confederation_peers_cmd, | |
1869 | "bgp confederation peers (1-4294967295)...", | |
e9273987 | 1870 | BGP_STR |
1ca2fd11 IR |
1871 | "AS confederation parameters\n" |
1872 | "Peer ASs in BGP confederation\n" | |
1873 | AS_STR) | |
718e3744 | 1874 | { |
1ca2fd11 | 1875 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1876 | int idx_asn = 3; |
1ca2fd11 | 1877 | as_t as; |
d62a17ae | 1878 | int i; |
718e3744 | 1879 | |
1ca2fd11 IR |
1880 | for (i = idx_asn; i < argc; i++) { |
1881 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1882 | |
1ca2fd11 IR |
1883 | if (bgp->as == as) { |
1884 | vty_out(vty, | |
1885 | "%% Local member-AS not allowed in confed peer list\n"); | |
1886 | continue; | |
1887 | } | |
1888 | ||
1889 | bgp_confederation_peers_add(bgp, as); | |
1890 | } | |
1891 | return CMD_SUCCESS; | |
718e3744 | 1892 | } |
1893 | ||
1ca2fd11 IR |
1894 | DEFUN (no_bgp_confederation_peers, |
1895 | no_bgp_confederation_peers_cmd, | |
1896 | "no bgp confederation peers (1-4294967295)...", | |
1897 | NO_STR | |
e9273987 | 1898 | BGP_STR |
1ca2fd11 IR |
1899 | "AS confederation parameters\n" |
1900 | "Peer ASs in BGP confederation\n" | |
1901 | AS_STR) | |
718e3744 | 1902 | { |
1ca2fd11 | 1903 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1904 | int idx_asn = 4; |
1ca2fd11 | 1905 | as_t as; |
d62a17ae | 1906 | int i; |
718e3744 | 1907 | |
1ca2fd11 IR |
1908 | for (i = idx_asn; i < argc; i++) { |
1909 | as = strtoul(argv[i]->arg, NULL, 10); | |
ff8a8a7a | 1910 | |
1ca2fd11 IR |
1911 | bgp_confederation_peers_remove(bgp, as); |
1912 | } | |
1913 | return CMD_SUCCESS; | |
718e3744 | 1914 | } |
6b0655a2 | 1915 | |
5e242b0d DS |
1916 | /** |
1917 | * Central routine for maximum-paths configuration. | |
1918 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1919 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1920 | */ | |
585f1adc IR |
1921 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1922 | const char *mpaths, uint16_t options, | |
1923 | int set) | |
d62a17ae | 1924 | { |
585f1adc IR |
1925 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1926 | uint16_t maxpaths = 0; | |
d62a17ae | 1927 | int ret; |
585f1adc IR |
1928 | afi_t afi; |
1929 | safi_t safi; | |
1930 | ||
1931 | afi = bgp_node_afi(vty); | |
1932 | safi = bgp_node_safi(vty); | |
d62a17ae | 1933 | |
1934 | if (set) { | |
585f1adc | 1935 | maxpaths = strtol(mpaths, NULL, 10); |
d62a17ae | 1936 | if (maxpaths > multipath_num) { |
585f1adc | 1937 | vty_out(vty, |
d62a17ae | 1938 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", |
1939 | maxpaths, multipath_num); | |
1940 | return CMD_WARNING_CONFIG_FAILED; | |
1941 | } | |
1942 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1943 | options); | |
1944 | } else | |
1945 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1946 | ||
1947 | if (ret < 0) { | |
585f1adc | 1948 | vty_out(vty, |
d62a17ae | 1949 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", |
1950 | (set == 1) ? "" : "un", | |
1951 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1952 | maxpaths, afi, safi); | |
1953 | return CMD_WARNING_CONFIG_FAILED; | |
1954 | } | |
1955 | ||
1956 | bgp_recalculate_all_bestpaths(bgp); | |
1957 | ||
1958 | return CMD_SUCCESS; | |
165b5fff JB |
1959 | } |
1960 | ||
1ca2fd11 IR |
1961 | DEFUN (bgp_maxmed_admin, |
1962 | bgp_maxmed_admin_cmd, | |
1963 | "bgp max-med administrative ", | |
1964 | BGP_STR | |
1965 | "Advertise routes with max-med\n" | |
1966 | "Administratively applied, for an indefinite period\n") | |
abc920f8 | 1967 | { |
1ca2fd11 | 1968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1969 | |
1ca2fd11 IR |
1970 | bgp->v_maxmed_admin = 1; |
1971 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
ff8a8a7a | 1972 | |
1ca2fd11 | 1973 | bgp_maxmed_update(bgp); |
abc920f8 | 1974 | |
1ca2fd11 | 1975 | return CMD_SUCCESS; |
ff8a8a7a CS |
1976 | } |
1977 | ||
1ca2fd11 IR |
1978 | DEFUN (bgp_maxmed_admin_medv, |
1979 | bgp_maxmed_admin_medv_cmd, | |
1980 | "bgp max-med administrative (0-4294967295)", | |
1981 | BGP_STR | |
1982 | "Advertise routes with max-med\n" | |
1983 | "Administratively applied, for an indefinite period\n" | |
1984 | "Max MED value to be used\n") | |
abc920f8 | 1985 | { |
1ca2fd11 | 1986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 1987 | int idx_number = 3; |
abc920f8 | 1988 | |
1ca2fd11 IR |
1989 | bgp->v_maxmed_admin = 1; |
1990 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1991 | |
1ca2fd11 | 1992 | bgp_maxmed_update(bgp); |
abc920f8 | 1993 | |
1ca2fd11 | 1994 | return CMD_SUCCESS; |
abc920f8 DS |
1995 | } |
1996 | ||
1ca2fd11 IR |
1997 | DEFUN (no_bgp_maxmed_admin, |
1998 | no_bgp_maxmed_admin_cmd, | |
1999 | "no bgp max-med administrative [(0-4294967295)]", | |
2000 | NO_STR | |
2001 | BGP_STR | |
2002 | "Advertise routes with max-med\n" | |
2003 | "Administratively applied, for an indefinite period\n" | |
2004 | "Max MED value to be used\n") | |
abc920f8 | 2005 | { |
1ca2fd11 IR |
2006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2007 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
2008 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
2009 | bgp_maxmed_update(bgp); | |
ff8a8a7a | 2010 | |
1ca2fd11 | 2011 | return CMD_SUCCESS; |
abc920f8 DS |
2012 | } |
2013 | ||
1ca2fd11 IR |
2014 | DEFUN (bgp_maxmed_onstartup, |
2015 | bgp_maxmed_onstartup_cmd, | |
2016 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
2017 | BGP_STR | |
2018 | "Advertise routes with max-med\n" | |
2019 | "Effective on a startup\n" | |
2020 | "Time (seconds) period for max-med\n" | |
2021 | "Max MED value to be used\n") | |
abc920f8 | 2022 | { |
1ca2fd11 | 2023 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2024 | int idx = 0; |
4668a151 | 2025 | |
9b01d289 DA |
2026 | if (argv_find(argv, argc, "(5-86400)", &idx)) |
2027 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
d62a17ae | 2028 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
1ca2fd11 | 2029 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); |
d62a17ae | 2030 | else |
1ca2fd11 | 2031 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 | 2032 | |
1ca2fd11 IR |
2033 | bgp_maxmed_update(bgp); |
2034 | ||
2035 | return CMD_SUCCESS; | |
abc920f8 DS |
2036 | } |
2037 | ||
1ca2fd11 IR |
2038 | DEFUN (no_bgp_maxmed_onstartup, |
2039 | no_bgp_maxmed_onstartup_cmd, | |
2040 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
2041 | NO_STR | |
2042 | BGP_STR | |
2043 | "Advertise routes with max-med\n" | |
2044 | "Effective on a startup\n" | |
2045 | "Time (seconds) period for max-med\n" | |
2046 | "Max MED value to be used\n") | |
abc920f8 | 2047 | { |
1ca2fd11 IR |
2048 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2049 | ||
2050 | /* Cancel max-med onstartup if its on */ | |
2051 | if (bgp->t_maxmed_onstartup) { | |
2052 | thread_cancel(&bgp->t_maxmed_onstartup); | |
2053 | bgp->maxmed_onstartup_over = 1; | |
2054 | } | |
abc920f8 | 2055 | |
1ca2fd11 IR |
2056 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
2057 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 2058 | |
1ca2fd11 IR |
2059 | bgp_maxmed_update(bgp); |
2060 | ||
2061 | return CMD_SUCCESS; | |
abc920f8 DS |
2062 | } |
2063 | ||
d70583f7 D |
2064 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
2065 | uint16_t update_delay, | |
2066 | uint16_t establish_wait) | |
2067 | { | |
2068 | struct listnode *node, *nnode; | |
2069 | struct bgp *bgp; | |
2070 | bool vrf_cfg = false; | |
2071 | ||
2072 | /* | |
2073 | * See if update-delay is set per-vrf and warn user to delete it | |
2074 | * Note that we only need to check this if this is the first time | |
2075 | * setting the global config. | |
2076 | */ | |
2077 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
2078 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2079 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
2080 | vty_out(vty, | |
2081 | "%% update-delay configuration found in vrf %s\n", | |
2082 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
2083 | ? VRF_DEFAULT_NAME | |
2084 | : bgp->name); | |
2085 | vrf_cfg = true; | |
2086 | } | |
2087 | } | |
2088 | } | |
2089 | ||
2090 | if (vrf_cfg) { | |
2091 | vty_out(vty, | |
2092 | "%%Failed: global update-delay config not permitted\n"); | |
2093 | return CMD_WARNING; | |
2094 | } | |
2095 | ||
2096 | if (!establish_wait) { /* update-delay <delay> */ | |
2097 | bm->v_update_delay = update_delay; | |
2098 | bm->v_establish_wait = bm->v_update_delay; | |
2099 | } else { | |
2100 | /* update-delay <delay> <establish-wait> */ | |
2101 | if (update_delay < establish_wait) { | |
2102 | vty_out(vty, | |
2103 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2104 | return CMD_WARNING_CONFIG_FAILED; | |
2105 | } | |
2106 | ||
2107 | bm->v_update_delay = update_delay; | |
2108 | bm->v_establish_wait = establish_wait; | |
2109 | } | |
2110 | ||
2111 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2112 | bgp->v_update_delay = bm->v_update_delay; | |
2113 | bgp->v_establish_wait = bm->v_establish_wait; | |
2114 | } | |
2115 | ||
2116 | return CMD_SUCCESS; | |
2117 | } | |
2118 | ||
2119 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
2120 | { | |
2121 | struct listnode *node, *nnode; | |
2122 | struct bgp *bgp; | |
2123 | ||
2124 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
2125 | bm->v_establish_wait = bm->v_update_delay; | |
2126 | ||
2127 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2128 | bgp->v_update_delay = bm->v_update_delay; | |
2129 | bgp->v_establish_wait = bm->v_establish_wait; | |
2130 | } | |
2131 | ||
2132 | return CMD_SUCCESS; | |
2133 | } | |
2134 | ||
2135 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
2136 | uint16_t establish_wait) | |
f188f2c4 | 2137 | { |
d62a17ae | 2138 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2139 | |
d70583f7 D |
2140 | /* if configured globally, per-instance config is not allowed */ |
2141 | if (bm->v_update_delay) { | |
2142 | vty_out(vty, | |
2143 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
2144 | return CMD_WARNING_CONFIG_FAILED; | |
2145 | } | |
2146 | ||
f188f2c4 | 2147 | |
d70583f7 | 2148 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 2149 | { |
2150 | bgp->v_update_delay = update_delay; | |
2151 | bgp->v_establish_wait = bgp->v_update_delay; | |
2152 | return CMD_SUCCESS; | |
2153 | } | |
f188f2c4 | 2154 | |
d62a17ae | 2155 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 2156 | if (update_delay < establish_wait) { |
2157 | vty_out(vty, | |
2158 | "%%Failed: update-delay less than the establish-wait!\n"); | |
2159 | return CMD_WARNING_CONFIG_FAILED; | |
2160 | } | |
f188f2c4 | 2161 | |
d62a17ae | 2162 | bgp->v_update_delay = update_delay; |
2163 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 2164 | |
d62a17ae | 2165 | return CMD_SUCCESS; |
f188f2c4 DS |
2166 | } |
2167 | ||
d62a17ae | 2168 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 2169 | { |
d62a17ae | 2170 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 2171 | |
d70583f7 D |
2172 | /* If configured globally, cannot remove from one bgp instance */ |
2173 | if (bm->v_update_delay) { | |
2174 | vty_out(vty, | |
2175 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
2176 | return CMD_WARNING_CONFIG_FAILED; | |
2177 | } | |
d62a17ae | 2178 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
2179 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 2180 | |
d62a17ae | 2181 | return CMD_SUCCESS; |
f188f2c4 DS |
2182 | } |
2183 | ||
2b791107 | 2184 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 2185 | { |
d70583f7 D |
2186 | /* If configured globally, no need to display per-instance value */ |
2187 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 2188 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
2189 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
2190 | vty_out(vty, " %d", bgp->v_establish_wait); | |
2191 | vty_out(vty, "\n"); | |
2192 | } | |
f188f2c4 DS |
2193 | } |
2194 | ||
d70583f7 D |
2195 | /* Global update-delay configuration */ |
2196 | DEFPY (bgp_global_update_delay, | |
2197 | bgp_global_update_delay_cmd, | |
2198 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
2199 | BGP_STR | |
2200 | "Force initial delay for best-path and updates for all bgp instances\n" | |
2201 | "Max delay in seconds\n" | |
2202 | "Establish wait in seconds\n") | |
2203 | { | |
2204 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
2205 | } | |
f188f2c4 | 2206 | |
d70583f7 D |
2207 | /* Global update-delay deconfiguration */ |
2208 | DEFPY (no_bgp_global_update_delay, | |
2209 | no_bgp_global_update_delay_cmd, | |
2210 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
2211 | NO_STR | |
2212 | BGP_STR | |
f188f2c4 | 2213 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2214 | "Max delay in seconds\n" |
2215 | "Establish wait in seconds\n") | |
f188f2c4 | 2216 | { |
d70583f7 | 2217 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2218 | } |
2219 | ||
d70583f7 D |
2220 | /* Update-delay configuration */ |
2221 | ||
2222 | DEFPY (bgp_update_delay, | |
2223 | bgp_update_delay_cmd, | |
2224 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 2225 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2226 | "Max delay in seconds\n" |
2227 | "Establish wait in seconds\n") | |
f188f2c4 | 2228 | { |
d70583f7 | 2229 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
2230 | } |
2231 | ||
2232 | /* Update-delay deconfiguration */ | |
d70583f7 | 2233 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 2234 | no_bgp_update_delay_cmd, |
838758ac DW |
2235 | "no update-delay [(0-3600) [(1-3600)]]", |
2236 | NO_STR | |
f188f2c4 | 2237 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
2238 | "Max delay in seconds\n" |
2239 | "Establish wait in seconds\n") | |
f188f2c4 | 2240 | { |
d62a17ae | 2241 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
2242 | } |
2243 | ||
5e242b0d | 2244 | |
1ca2fd11 IR |
2245 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2246 | bool set) | |
cb1faec9 | 2247 | { |
1ca2fd11 IR |
2248 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2249 | ||
8fa7732f QY |
2250 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
2251 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
2252 | |
2253 | return CMD_SUCCESS; | |
2254 | } | |
2255 | ||
1ca2fd11 IR |
2256 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
2257 | bool set) | |
555e09d4 | 2258 | { |
1ca2fd11 IR |
2259 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2260 | ||
8fa7732f QY |
2261 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
2262 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 2263 | |
d62a17ae | 2264 | return CMD_SUCCESS; |
cb1faec9 DS |
2265 | } |
2266 | ||
2b791107 | 2267 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 2268 | { |
555e09d4 QY |
2269 | uint32_t quanta = |
2270 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
2271 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 2272 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
2273 | } |
2274 | ||
555e09d4 QY |
2275 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
2276 | { | |
2277 | uint32_t quanta = | |
2278 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
2279 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 2280 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 2281 | } |
cb1faec9 | 2282 | |
8fa7732f QY |
2283 | /* Packet quanta configuration |
2284 | * | |
2285 | * XXX: The value set here controls the size of a stack buffer in the IO | |
2286 | * thread. When changing these limits be careful to prevent stack overflow. | |
2287 | * | |
2288 | * Furthermore, the maximums used here should correspond to | |
2289 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
2290 | */ | |
1ca2fd11 IR |
2291 | DEFPY (bgp_wpkt_quanta, |
2292 | bgp_wpkt_quanta_cmd, | |
2293 | "[no] write-quanta (1-64)$quanta", | |
2294 | NO_STR | |
2295 | "How many packets to write to peer socket per run\n" | |
2296 | "Number of packets\n") | |
2297 | { | |
2298 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); | |
2299 | } | |
cb1faec9 | 2300 | |
1ca2fd11 IR |
2301 | DEFPY (bgp_rpkt_quanta, |
2302 | bgp_rpkt_quanta_cmd, | |
2303 | "[no] read-quanta (1-10)$quanta", | |
2304 | NO_STR | |
2305 | "How many packets to read from peer socket per I/O cycle\n" | |
2306 | "Number of packets\n") | |
2307 | { | |
2308 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); | |
555e09d4 QY |
2309 | } |
2310 | ||
2b791107 | 2311 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2312 | { |
37a333fe | 2313 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2314 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2315 | } |
2316 | ||
4668a151 | 2317 | |
1ca2fd11 IR |
2318 | DEFUN (bgp_coalesce_time, |
2319 | bgp_coalesce_time_cmd, | |
2320 | "coalesce-time (0-4294967295)", | |
2321 | "Subgroup coalesce timer\n" | |
2322 | "Subgroup coalesce timer value (in ms)\n") | |
ff8a8a7a | 2323 | { |
1ca2fd11 | 2324 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 2325 | |
1ca2fd11 | 2326 | int idx = 0; |
9b01d289 | 2327 | |
1ca2fd11 | 2328 | bgp->heuristic_coalesce = false; |
9b01d289 DA |
2329 | |
2330 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
2331 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
2332 | ||
1ca2fd11 | 2333 | return CMD_SUCCESS; |
3f9c7369 DS |
2334 | } |
2335 | ||
1ca2fd11 IR |
2336 | DEFUN (no_bgp_coalesce_time, |
2337 | no_bgp_coalesce_time_cmd, | |
2338 | "no coalesce-time (0-4294967295)", | |
2339 | NO_STR | |
2340 | "Subgroup coalesce timer\n" | |
2341 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2342 | { |
1ca2fd11 | 2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 2344 | |
1ca2fd11 IR |
2345 | bgp->heuristic_coalesce = true; |
2346 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
2347 | return CMD_SUCCESS; | |
3f9c7369 DS |
2348 | } |
2349 | ||
5e242b0d | 2350 | /* Maximum-paths configuration */ |
585f1adc IR |
2351 | DEFUN (bgp_maxpaths, |
2352 | bgp_maxpaths_cmd, | |
2353 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2354 | "Forward packets over multiple paths\n" | |
2355 | "Number of paths\n") | |
5e242b0d | 2356 | { |
d62a17ae | 2357 | int idx_number = 1; |
585f1adc IR |
2358 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, |
2359 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2360 | } |
2361 | ||
d62a17ae | 2362 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2363 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2364 | "Forward packets over multiple paths\n" | |
2365 | "Number of paths\n") | |
596c17ba | 2366 | |
585f1adc IR |
2367 | DEFUN (bgp_maxpaths_ibgp, |
2368 | bgp_maxpaths_ibgp_cmd, | |
2369 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2370 | "Forward packets over multiple paths\n" | |
2371 | "iBGP-multipath\n" | |
2372 | "Number of paths\n") | |
165b5fff | 2373 | { |
d62a17ae | 2374 | int idx_number = 2; |
585f1adc IR |
2375 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2376 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2377 | } |
165b5fff | 2378 | |
d62a17ae | 2379 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2380 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2381 | "Forward packets over multiple paths\n" | |
2382 | "iBGP-multipath\n" | |
2383 | "Number of paths\n") | |
596c17ba | 2384 | |
585f1adc IR |
2385 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2386 | bgp_maxpaths_ibgp_cluster_cmd, | |
2387 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", | |
2388 | "Forward packets over multiple paths\n" | |
2389 | "iBGP-multipath\n" | |
2390 | "Number of paths\n" | |
2391 | "Match the cluster length\n") | |
5e242b0d | 2392 | { |
d62a17ae | 2393 | int idx_number = 2; |
aa53c036 DS |
2394 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, |
2395 | argv[idx_number]->arg, true, 1); | |
165b5fff JB |
2396 | } |
2397 | ||
d62a17ae | 2398 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2399 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2400 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2401 | "Forward packets over multiple paths\n" | |
2402 | "iBGP-multipath\n" | |
2403 | "Number of paths\n" | |
2404 | "Match the cluster length\n") | |
596c17ba | 2405 | |
585f1adc IR |
2406 | DEFUN (no_bgp_maxpaths, |
2407 | no_bgp_maxpaths_cmd, | |
2408 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", | |
2409 | NO_STR | |
2410 | "Forward packets over multiple paths\n" | |
2411 | "Number of paths\n") | |
165b5fff | 2412 | { |
585f1adc | 2413 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2414 | } |
2415 | ||
d62a17ae | 2416 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2417 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2418 | "Forward packets over multiple paths\n" |
2419 | "Number of paths\n") | |
596c17ba | 2420 | |
585f1adc IR |
2421 | DEFUN (no_bgp_maxpaths_ibgp, |
2422 | no_bgp_maxpaths_ibgp_cmd, | |
2423 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2424 | NO_STR | |
2425 | "Forward packets over multiple paths\n" | |
2426 | "iBGP-multipath\n" | |
2427 | "Number of paths\n" | |
2428 | "Match the cluster length\n") | |
165b5fff | 2429 | { |
585f1adc | 2430 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2431 | } |
2432 | ||
d62a17ae | 2433 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2434 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2435 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2436 | NO_STR | |
2437 | "Forward packets over multiple paths\n" | |
2438 | "iBGP-multipath\n" | |
2439 | "Number of paths\n" | |
2440 | "Match the cluster length\n") | |
596c17ba | 2441 | |
dd65f45e DL |
2442 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2443 | afi_t afi, safi_t safi) | |
165b5fff | 2444 | { |
00908b7a | 2445 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != multipath_num) { |
d62a17ae | 2446 | vty_out(vty, " maximum-paths %d\n", |
2447 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2448 | } | |
165b5fff | 2449 | |
00908b7a | 2450 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != multipath_num) { |
d62a17ae | 2451 | vty_out(vty, " maximum-paths ibgp %d", |
2452 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
aa53c036 | 2453 | if (bgp->maxpaths[afi][safi].same_clusterlen) |
d62a17ae | 2454 | vty_out(vty, " equal-cluster-length"); |
2455 | vty_out(vty, "\n"); | |
2456 | } | |
165b5fff | 2457 | } |
6b0655a2 | 2458 | |
718e3744 | 2459 | /* BGP timers. */ |
2460 | ||
1ca2fd11 IR |
2461 | DEFUN (bgp_timers, |
2462 | bgp_timers_cmd, | |
2463 | "timers bgp (0-65535) (0-65535)", | |
2464 | "Adjust routing timers\n" | |
2465 | "BGP timers\n" | |
2466 | "Keepalive interval\n" | |
2467 | "Holdtime\n") | |
718e3744 | 2468 | { |
1ca2fd11 | 2469 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 2470 | int idx_number = 2; |
2471 | int idx_number_2 = 3; | |
1ca2fd11 IR |
2472 | unsigned long keepalive = 0; |
2473 | unsigned long holdtime = 0; | |
718e3744 | 2474 | |
1ca2fd11 IR |
2475 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
2476 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 2477 | |
1ca2fd11 IR |
2478 | /* Holdtime value check. */ |
2479 | if (holdtime < 3 && holdtime != 0) { | |
2480 | vty_out(vty, | |
2481 | "%% hold time value must be either 0 or greater than 3\n"); | |
2482 | return CMD_WARNING_CONFIG_FAILED; | |
2483 | } | |
718e3744 | 2484 | |
1ca2fd11 IR |
2485 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY, |
2486 | BGP_DEFAULT_DELAYOPEN); | |
718e3744 | 2487 | |
1ca2fd11 | 2488 | return CMD_SUCCESS; |
718e3744 | 2489 | } |
2490 | ||
1ca2fd11 IR |
2491 | DEFUN (no_bgp_timers, |
2492 | no_bgp_timers_cmd, | |
2493 | "no timers bgp [(0-65535) (0-65535)]", | |
2494 | NO_STR | |
2495 | "Adjust routing timers\n" | |
2496 | "BGP timers\n" | |
2497 | "Keepalive interval\n" | |
2498 | "Holdtime\n") | |
718e3744 | 2499 | { |
1ca2fd11 IR |
2500 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2501 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
2502 | DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN); | |
ff8a8a7a | 2503 | |
1ca2fd11 | 2504 | return CMD_SUCCESS; |
718e3744 | 2505 | } |
2506 | ||
b042667a TI |
2507 | /* BGP minimum holdtime. */ |
2508 | ||
2509 | DEFUN(bgp_minimum_holdtime, bgp_minimum_holdtime_cmd, | |
2510 | "bgp minimum-holdtime (1-65535)", | |
2511 | "BGP specific commands\n" | |
2512 | "BGP minimum holdtime\n" | |
2513 | "Seconds\n") | |
2514 | { | |
2515 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2516 | int idx_number = 2; | |
2517 | unsigned long min_holdtime; | |
2518 | ||
2519 | min_holdtime = strtoul(argv[idx_number]->arg, NULL, 10); | |
2520 | ||
2521 | bgp->default_min_holdtime = min_holdtime; | |
2522 | ||
2523 | return CMD_SUCCESS; | |
2524 | } | |
2525 | ||
2526 | DEFUN(no_bgp_minimum_holdtime, no_bgp_minimum_holdtime_cmd, | |
2527 | "no bgp minimum-holdtime [(1-65535)]", | |
2528 | NO_STR | |
2529 | "BGP specific commands\n" | |
2530 | "BGP minimum holdtime\n" | |
2531 | "Seconds\n") | |
2532 | { | |
2533 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2534 | ||
2535 | bgp->default_min_holdtime = 0; | |
2536 | ||
2537 | return CMD_SUCCESS; | |
2538 | } | |
ff8a8a7a | 2539 | |
1ca2fd11 IR |
2540 | DEFUN (bgp_client_to_client_reflection, |
2541 | bgp_client_to_client_reflection_cmd, | |
2542 | "bgp client-to-client reflection", | |
e9273987 | 2543 | BGP_STR |
1ca2fd11 IR |
2544 | "Configure client to client route reflection\n" |
2545 | "reflection of routes allowed\n") | |
718e3744 | 2546 | { |
1ca2fd11 IR |
2547 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2548 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2549 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2550 | |
1ca2fd11 | 2551 | return CMD_SUCCESS; |
718e3744 | 2552 | } |
2553 | ||
1ca2fd11 IR |
2554 | DEFUN (no_bgp_client_to_client_reflection, |
2555 | no_bgp_client_to_client_reflection_cmd, | |
2556 | "no bgp client-to-client reflection", | |
2557 | NO_STR | |
e9273987 | 2558 | BGP_STR |
1ca2fd11 IR |
2559 | "Configure client to client route reflection\n" |
2560 | "reflection of routes allowed\n") | |
718e3744 | 2561 | { |
1ca2fd11 IR |
2562 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2563 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
2564 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 2565 | |
1ca2fd11 | 2566 | return CMD_SUCCESS; |
718e3744 | 2567 | } |
2568 | ||
2569 | /* "bgp always-compare-med" configuration. */ | |
1ca2fd11 IR |
2570 | DEFUN (bgp_always_compare_med, |
2571 | bgp_always_compare_med_cmd, | |
2572 | "bgp always-compare-med", | |
e9273987 | 2573 | BGP_STR |
1ca2fd11 | 2574 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2575 | { |
1ca2fd11 IR |
2576 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2577 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2578 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2579 | |
1ca2fd11 | 2580 | return CMD_SUCCESS; |
718e3744 | 2581 | } |
2582 | ||
1ca2fd11 IR |
2583 | DEFUN (no_bgp_always_compare_med, |
2584 | no_bgp_always_compare_med_cmd, | |
2585 | "no bgp always-compare-med", | |
2586 | NO_STR | |
e9273987 | 2587 | BGP_STR |
1ca2fd11 | 2588 | "Allow comparing MED from different neighbors\n") |
718e3744 | 2589 | { |
1ca2fd11 IR |
2590 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2591 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); | |
2592 | bgp_recalculate_all_bestpaths(bgp); | |
6b0655a2 | 2593 | |
1ca2fd11 | 2594 | return CMD_SUCCESS; |
2adac256 DA |
2595 | } |
2596 | ||
2adac256 | 2597 | |
1ca2fd11 IR |
2598 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, |
2599 | "bgp ebgp-requires-policy", | |
e9273987 | 2600 | BGP_STR |
1ca2fd11 | 2601 | "Require in and out policy for eBGP peers (RFC8212)\n") |
2adac256 | 2602 | { |
1ca2fd11 IR |
2603 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2604 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2605 | return CMD_SUCCESS; | |
2adac256 DA |
2606 | } |
2607 | ||
1ca2fd11 IR |
2608 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, |
2609 | "no bgp ebgp-requires-policy", | |
2610 | NO_STR | |
e9273987 | 2611 | BGP_STR |
1ca2fd11 | 2612 | "Require in and out policy for eBGP peers (RFC8212)\n") |
ff8a8a7a | 2613 | { |
1ca2fd11 IR |
2614 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2615 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
2616 | return CMD_SUCCESS; | |
ff8a8a7a | 2617 | } |
9dac9fc8 | 2618 | |
1ca2fd11 IR |
2619 | DEFUN(bgp_suppress_duplicates, bgp_suppress_duplicates_cmd, |
2620 | "bgp suppress-duplicates", | |
e9273987 | 2621 | BGP_STR |
1ca2fd11 | 2622 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2623 | { |
1ca2fd11 IR |
2624 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2625 | SET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2626 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2627 | } |
2628 | ||
1ca2fd11 IR |
2629 | DEFUN(no_bgp_suppress_duplicates, no_bgp_suppress_duplicates_cmd, |
2630 | "no bgp suppress-duplicates", | |
2631 | NO_STR | |
e9273987 | 2632 | BGP_STR |
1ca2fd11 | 2633 | "Suppress duplicate updates if the route actually not changed\n") |
9dac9fc8 | 2634 | { |
1ca2fd11 IR |
2635 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2636 | UNSET_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES); | |
2637 | return CMD_SUCCESS; | |
9dac9fc8 DA |
2638 | } |
2639 | ||
fb29348a DA |
2640 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2641 | "bgp reject-as-sets", | |
e9273987 | 2642 | BGP_STR |
fb29348a DA |
2643 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2644 | { | |
2645 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2646 | struct listnode *node, *nnode; | |
2647 | struct peer *peer; | |
2648 | ||
7f972cd8 | 2649 | bgp->reject_as_sets = true; |
fb29348a DA |
2650 | |
2651 | /* Reset existing BGP sessions to reject routes | |
2652 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2653 | */ | |
2654 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2655 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2656 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2657 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2658 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2659 | } | |
2660 | } | |
2661 | ||
2662 | return CMD_SUCCESS; | |
2663 | } | |
2664 | ||
2665 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2666 | "no bgp reject-as-sets", | |
2667 | NO_STR | |
e9273987 | 2668 | BGP_STR |
fb29348a DA |
2669 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") |
2670 | { | |
2671 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2672 | struct listnode *node, *nnode; | |
2673 | struct peer *peer; | |
2674 | ||
7f972cd8 | 2675 | bgp->reject_as_sets = false; |
fb29348a DA |
2676 | |
2677 | /* Reset existing BGP sessions to reject routes | |
2678 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2679 | */ | |
2680 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2681 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2682 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2683 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2684 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2685 | } | |
2686 | } | |
2687 | ||
2688 | return CMD_SUCCESS; | |
2689 | } | |
9dac9fc8 | 2690 | |
718e3744 | 2691 | /* "bgp deterministic-med" configuration. */ |
1ca2fd11 | 2692 | DEFUN (bgp_deterministic_med, |
718e3744 | 2693 | bgp_deterministic_med_cmd, |
2694 | "bgp deterministic-med", | |
e9273987 | 2695 | BGP_STR |
718e3744 | 2696 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2697 | { | |
1ca2fd11 IR |
2698 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2699 | ||
2700 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2701 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2702 | bgp_recalculate_all_bestpaths(bgp); | |
2703 | } | |
7aafcaca | 2704 | |
1ca2fd11 | 2705 | return CMD_SUCCESS; |
718e3744 | 2706 | } |
2707 | ||
1ca2fd11 | 2708 | DEFUN (no_bgp_deterministic_med, |
718e3744 | 2709 | no_bgp_deterministic_med_cmd, |
2710 | "no bgp deterministic-med", | |
2711 | NO_STR | |
e9273987 | 2712 | BGP_STR |
718e3744 | 2713 | "Pick the best-MED path among paths advertised from the neighboring AS\n") |
2714 | { | |
1ca2fd11 IR |
2715 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2716 | int bestpath_per_as_used; | |
2717 | afi_t afi; | |
2718 | safi_t safi; | |
2719 | struct peer *peer; | |
2720 | struct listnode *node, *nnode; | |
2721 | ||
2722 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { | |
2723 | bestpath_per_as_used = 0; | |
2724 | ||
2725 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2726 | FOREACH_AFI_SAFI (afi, safi) | |
2727 | if (bgp_addpath_dmed_required( | |
2728 | peer->addpath_type[afi][safi])) { | |
2729 | bestpath_per_as_used = 1; | |
2730 | break; | |
2731 | } | |
2732 | ||
2733 | if (bestpath_per_as_used) | |
2734 | break; | |
2735 | } | |
2736 | ||
2737 | if (bestpath_per_as_used) { | |
2738 | vty_out(vty, | |
2739 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2740 | return CMD_WARNING_CONFIG_FAILED; | |
2741 | } else { | |
2742 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
2743 | bgp_recalculate_all_bestpaths(bgp); | |
2744 | } | |
2745 | } | |
d62a17ae | 2746 | |
1ca2fd11 | 2747 | return CMD_SUCCESS; |
718e3744 | 2748 | } |
538621f2 | 2749 | |
055679e9 | 2750 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2751 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2752 | bgp_graceful_restart_cmd, |
2753 | "bgp graceful-restart", | |
e9273987 | 2754 | BGP_STR |
2ba1fe69 | 2755 | GR_CMD |
055679e9 | 2756 | ) |
538621f2 | 2757 | { |
055679e9 | 2758 | int ret = BGP_GR_FAILURE; |
2759 | ||
2760 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2761 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2762 | |
d62a17ae | 2763 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2764 | |
2765 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2766 | ||
36235319 QY |
2767 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2768 | ret); | |
5cce3f05 | 2769 | |
055679e9 | 2770 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2771 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2772 | vty_out(vty, |
2773 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2774 | return bgp_vty_return(vty, ret); |
538621f2 | 2775 | } |
2776 | ||
2777 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2778 | no_bgp_graceful_restart_cmd, |
2779 | "no bgp graceful-restart", | |
2780 | NO_STR | |
e9273987 | 2781 | BGP_STR |
2ba1fe69 | 2782 | NO_GR_CMD |
055679e9 | 2783 | ) |
538621f2 | 2784 | { |
d62a17ae | 2785 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2786 | |
2787 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2788 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2789 | |
2790 | int ret = BGP_GR_FAILURE; | |
2791 | ||
2792 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2793 | ||
36235319 QY |
2794 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2795 | ret); | |
5cce3f05 | 2796 | |
055679e9 | 2797 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2798 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2799 | vty_out(vty, |
2800 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2801 | |
2802 | return bgp_vty_return(vty, ret); | |
538621f2 | 2803 | } |
2804 | ||
93406d87 | 2805 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2806 | bgp_graceful_restart_stalepath_time_cmd, |
2807 | "bgp graceful-restart stalepath-time (1-4095)", | |
e9273987 | 2808 | BGP_STR |
2ba1fe69 | 2809 | "Graceful restart capability parameters\n" |
2810 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2811 | "Delay value (seconds)\n") | |
93406d87 | 2812 | { |
d62a17ae | 2813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2814 | int idx_number = 3; | |
d7c0a89a | 2815 | uint32_t stalepath; |
93406d87 | 2816 | |
d62a17ae | 2817 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2818 | bgp->stalepath_time = stalepath; | |
2819 | return CMD_SUCCESS; | |
93406d87 | 2820 | } |
2821 | ||
eb6f1b41 | 2822 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2823 | bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2824 | "bgp graceful-restart restart-time (0-4095)", |
e9273987 | 2825 | BGP_STR |
2ba1fe69 | 2826 | "Graceful restart capability parameters\n" |
2827 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2828 | "Delay value (seconds)\n") | |
eb6f1b41 | 2829 | { |
d62a17ae | 2830 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2831 | int idx_number = 3; | |
d7c0a89a | 2832 | uint32_t restart; |
eb6f1b41 | 2833 | |
d62a17ae | 2834 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2835 | bgp->restart_time = restart; | |
2836 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2837 | } |
2838 | ||
cfd47646 | 2839 | DEFUN (bgp_graceful_restart_select_defer_time, |
2840 | bgp_graceful_restart_select_defer_time_cmd, | |
2841 | "bgp graceful-restart select-defer-time (0-3600)", | |
e9273987 | 2842 | BGP_STR |
cfd47646 | 2843 | "Graceful restart capability parameters\n" |
2844 | "Set the time to defer the BGP route selection after restart\n" | |
2845 | "Delay value (seconds, 0 - disable)\n") | |
2846 | { | |
2847 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2848 | int idx_number = 3; | |
2849 | uint32_t defer_time; | |
2850 | ||
2851 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2852 | bgp->select_defer_time = defer_time; | |
2853 | if (defer_time == 0) | |
892fedb6 | 2854 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2855 | else |
892fedb6 | 2856 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2857 | |
2858 | return CMD_SUCCESS; | |
2859 | } | |
2860 | ||
93406d87 | 2861 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2862 | no_bgp_graceful_restart_stalepath_time_cmd, |
2863 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2864 | NO_STR | |
e9273987 | 2865 | BGP_STR |
2ba1fe69 | 2866 | "Graceful restart capability parameters\n" |
2867 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2868 | "Delay value (seconds)\n") | |
93406d87 | 2869 | { |
d62a17ae | 2870 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2871 | |
d62a17ae | 2872 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2873 | return CMD_SUCCESS; | |
93406d87 | 2874 | } |
2875 | ||
eb6f1b41 | 2876 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2877 | no_bgp_graceful_restart_restart_time_cmd, |
dcbebfd3 | 2878 | "no bgp graceful-restart restart-time [(0-4095)]", |
2ba1fe69 | 2879 | NO_STR |
e9273987 | 2880 | BGP_STR |
2ba1fe69 | 2881 | "Graceful restart capability parameters\n" |
2882 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2883 | "Delay value (seconds)\n") | |
eb6f1b41 | 2884 | { |
d62a17ae | 2885 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2886 | |
d62a17ae | 2887 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2888 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2889 | } |
2890 | ||
cfd47646 | 2891 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2892 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2893 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2894 | NO_STR | |
e9273987 | 2895 | BGP_STR |
cfd47646 | 2896 | "Graceful restart capability parameters\n" |
2897 | "Set the time to defer the BGP route selection after restart\n" | |
2898 | "Delay value (seconds)\n") | |
2899 | { | |
2900 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2901 | ||
2902 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2903 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2904 | |
2905 | return CMD_SUCCESS; | |
2906 | } | |
2907 | ||
43fc21b3 | 2908 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2909 | bgp_graceful_restart_preserve_fw_cmd, |
2910 | "bgp graceful-restart preserve-fw-state", | |
e9273987 | 2911 | BGP_STR |
2ba1fe69 | 2912 | "Graceful restart capability parameters\n" |
2913 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2914 | { |
d62a17ae | 2915 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2916 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2917 | return CMD_SUCCESS; |
43fc21b3 JC |
2918 | } |
2919 | ||
2920 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2921 | no_bgp_graceful_restart_preserve_fw_cmd, |
2922 | "no bgp graceful-restart preserve-fw-state", | |
2923 | NO_STR | |
e9273987 | 2924 | BGP_STR |
2ba1fe69 | 2925 | "Graceful restart capability parameters\n" |
2926 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2927 | { |
d62a17ae | 2928 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2929 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2930 | return CMD_SUCCESS; |
43fc21b3 JC |
2931 | } |
2932 | ||
f2ca5c5b DA |
2933 | DEFPY (bgp_graceful_restart_notification, |
2934 | bgp_graceful_restart_notification_cmd, | |
2935 | "[no$no] bgp graceful-restart notification", | |
2936 | NO_STR | |
2937 | BGP_STR | |
2938 | "Graceful restart capability parameters\n" | |
2939 | "Indicate Graceful Restart support for BGP NOTIFICATION messages\n") | |
2940 | { | |
2941 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2942 | ||
2943 | if (no) | |
2944 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
2945 | else | |
2946 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION); | |
2947 | ||
2948 | return CMD_SUCCESS; | |
2949 | } | |
2950 | ||
1ae314be DA |
2951 | DEFPY (bgp_administrative_reset, |
2952 | bgp_administrative_reset_cmd, | |
2953 | "[no$no] bgp hard-administrative-reset", | |
2954 | NO_STR | |
2955 | BGP_STR | |
2956 | "Send Hard Reset CEASE Notification for 'Administrative Reset'\n") | |
2957 | { | |
2958 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2959 | ||
2960 | if (no) | |
2961 | UNSET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
2962 | else | |
2963 | SET_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET); | |
2964 | ||
2965 | return CMD_SUCCESS; | |
2966 | } | |
2967 | ||
055679e9 | 2968 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2969 | bgp_graceful_restart_disable_cmd, |
2970 | "bgp graceful-restart-disable", | |
e9273987 | 2971 | BGP_STR |
2ba1fe69 | 2972 | GR_DISABLE) |
055679e9 | 2973 | { |
2974 | int ret = BGP_GR_FAILURE; | |
2975 | ||
2976 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2977 | zlog_debug( | |
2ba1fe69 | 2978 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2979 | |
055679e9 | 2980 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2981 | ||
2982 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2983 | ||
dc95985f | 2984 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2985 | bgp->peer, ret); | |
5cce3f05 | 2986 | |
055679e9 | 2987 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2988 | zlog_debug( | |
2ba1fe69 | 2989 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2990 | vty_out(vty, |
2991 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2992 | ||
055679e9 | 2993 | return bgp_vty_return(vty, ret); |
2994 | } | |
2995 | ||
2996 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2997 | no_bgp_graceful_restart_disable_cmd, |
2998 | "no bgp graceful-restart-disable", | |
2999 | NO_STR | |
e9273987 | 3000 | BGP_STR |
2ba1fe69 | 3001 | NO_GR_DISABLE |
055679e9 | 3002 | ) |
3003 | { | |
3004 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3005 | ||
3006 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3007 | zlog_debug( | |
2ba1fe69 | 3008 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 3009 | |
3010 | int ret = BGP_GR_FAILURE; | |
3011 | ||
3012 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
3013 | ||
36235319 QY |
3014 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
3015 | ret); | |
5cce3f05 | 3016 | |
055679e9 | 3017 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3018 | zlog_debug( | |
2ba1fe69 | 3019 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 3020 | vty_out(vty, |
3021 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 3022 | |
3023 | return bgp_vty_return(vty, ret); | |
3024 | } | |
3025 | ||
3026 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 3027 | bgp_neighbor_graceful_restart_set_cmd, |
3028 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3029 | NEIGHBOR_STR | |
3030 | NEIGHBOR_ADDR_STR2 | |
3031 | GR_NEIGHBOR_CMD | |
055679e9 | 3032 | ) |
3033 | { | |
3034 | int idx_peer = 1; | |
3035 | struct peer *peer; | |
3036 | int ret = BGP_GR_FAILURE; | |
3037 | ||
dc95985f | 3038 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3039 | ||
055679e9 | 3040 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3041 | zlog_debug( | |
2ba1fe69 | 3042 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 3043 | |
055679e9 | 3044 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3045 | if (!peer) | |
3046 | return CMD_WARNING_CONFIG_FAILED; | |
3047 | ||
3048 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
3049 | ||
dc95985f | 3050 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3051 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3052 | |
3053 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3054 | zlog_debug( | |
2ba1fe69 | 3055 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3056 | vty_out(vty, |
3057 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3058 | |
3059 | return bgp_vty_return(vty, ret); | |
3060 | } | |
3061 | ||
3062 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 3063 | no_bgp_neighbor_graceful_restart_set_cmd, |
3064 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
3065 | NO_STR | |
3066 | NEIGHBOR_STR | |
3067 | NEIGHBOR_ADDR_STR2 | |
3068 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 3069 | ) |
3070 | { | |
3071 | int idx_peer = 2; | |
3072 | int ret = BGP_GR_FAILURE; | |
3073 | struct peer *peer; | |
3074 | ||
dc95985f | 3075 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3076 | ||
055679e9 | 3077 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3078 | if (!peer) | |
3079 | return CMD_WARNING_CONFIG_FAILED; | |
3080 | ||
3081 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3082 | zlog_debug( | |
2ba1fe69 | 3083 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 3084 | |
3085 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
3086 | ||
dc95985f | 3087 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3088 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3089 | |
3090 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3091 | zlog_debug( | |
2ba1fe69 | 3092 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 3093 | vty_out(vty, |
3094 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3095 | |
3096 | return bgp_vty_return(vty, ret); | |
3097 | } | |
3098 | ||
3099 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 3100 | bgp_neighbor_graceful_restart_helper_set_cmd, |
3101 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3102 | NEIGHBOR_STR | |
3103 | NEIGHBOR_ADDR_STR2 | |
3104 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3105 | ) |
3106 | { | |
3107 | int idx_peer = 1; | |
3108 | struct peer *peer; | |
3109 | int ret = BGP_GR_FAILURE; | |
3110 | ||
dc95985f | 3111 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3112 | ||
055679e9 | 3113 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3114 | zlog_debug( | |
2ba1fe69 | 3115 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 3116 | |
055679e9 | 3117 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3118 | ||
055679e9 | 3119 | if (!peer) |
3120 | return CMD_WARNING_CONFIG_FAILED; | |
3121 | ||
3122 | ||
3123 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 3124 | |
dc95985f | 3125 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3126 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 3127 | |
055679e9 | 3128 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3129 | zlog_debug( | |
2ba1fe69 | 3130 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3131 | vty_out(vty, |
3132 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3133 | |
3134 | return bgp_vty_return(vty, ret); | |
3135 | } | |
3136 | ||
3137 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 3138 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
3139 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
3140 | NO_STR | |
3141 | NEIGHBOR_STR | |
3142 | NEIGHBOR_ADDR_STR2 | |
3143 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 3144 | ) |
3145 | { | |
3146 | int idx_peer = 2; | |
3147 | int ret = BGP_GR_FAILURE; | |
3148 | struct peer *peer; | |
3149 | ||
dc95985f | 3150 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3151 | ||
055679e9 | 3152 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3153 | if (!peer) | |
3154 | return CMD_WARNING_CONFIG_FAILED; | |
3155 | ||
3156 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3157 | zlog_debug( | |
2ba1fe69 | 3158 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 3159 | |
36235319 | 3160 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 3161 | |
dc95985f | 3162 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3163 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3164 | |
3165 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3166 | zlog_debug( | |
2ba1fe69 | 3167 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 3168 | vty_out(vty, |
3169 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3170 | |
3171 | return bgp_vty_return(vty, ret); | |
3172 | } | |
3173 | ||
3174 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 3175 | bgp_neighbor_graceful_restart_disable_set_cmd, |
3176 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3177 | NEIGHBOR_STR | |
3178 | NEIGHBOR_ADDR_STR2 | |
3179 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3180 | ) |
3181 | { | |
3182 | int idx_peer = 1; | |
3183 | struct peer *peer; | |
3184 | int ret = BGP_GR_FAILURE; | |
3185 | ||
dc95985f | 3186 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3187 | ||
055679e9 | 3188 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3189 | zlog_debug( | |
2ba1fe69 | 3190 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3191 | |
3192 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3193 | if (!peer) | |
3194 | return CMD_WARNING_CONFIG_FAILED; | |
3195 | ||
36235319 | 3196 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 3197 | |
3198 | if (peer->bgp->t_startup) | |
3199 | bgp_peer_gr_flags_update(peer); | |
3200 | ||
dc95985f | 3201 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3202 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
3203 | ||
055679e9 | 3204 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
3205 | zlog_debug( | |
2ba1fe69 | 3206 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3207 | vty_out(vty, |
3208 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3209 | |
3210 | return bgp_vty_return(vty, ret); | |
3211 | } | |
3212 | ||
3213 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 3214 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
3215 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
3216 | NO_STR | |
3217 | NEIGHBOR_STR | |
3218 | NEIGHBOR_ADDR_STR2 | |
3219 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 3220 | ) |
3221 | { | |
3222 | int idx_peer = 2; | |
3223 | int ret = BGP_GR_FAILURE; | |
3224 | struct peer *peer; | |
3225 | ||
dc95985f | 3226 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
3227 | ||
055679e9 | 3228 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3229 | if (!peer) | |
3230 | return CMD_WARNING_CONFIG_FAILED; | |
3231 | ||
3232 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3233 | zlog_debug( | |
2ba1fe69 | 3234 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 3235 | |
3236 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
3237 | ||
dc95985f | 3238 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
3239 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 3240 | |
3241 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
3242 | zlog_debug( | |
2ba1fe69 | 3243 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 3244 | vty_out(vty, |
3245 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 3246 | |
3247 | return bgp_vty_return(vty, ret); | |
3248 | } | |
3249 | ||
d6e3c15b | 3250 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
3251 | bgp_graceful_restart_disable_eor_cmd, | |
3252 | "bgp graceful-restart disable-eor", | |
e9273987 | 3253 | BGP_STR |
d6e3c15b | 3254 | "Graceful restart configuration parameters\n" |
3255 | "Disable EOR Check\n") | |
3256 | { | |
3257 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3258 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3259 | |
d6e3c15b | 3260 | return CMD_SUCCESS; |
3261 | } | |
3262 | ||
3263 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
3264 | no_bgp_graceful_restart_disable_eor_cmd, | |
3265 | "no bgp graceful-restart disable-eor", | |
3266 | NO_STR | |
e9273987 | 3267 | BGP_STR |
d6e3c15b | 3268 | "Graceful restart configuration parameters\n" |
3269 | "Disable EOR Check\n") | |
3270 | { | |
3271 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 3272 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 3273 | |
3274 | return CMD_SUCCESS; | |
3275 | } | |
3276 | ||
3277 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
3278 | bgp_graceful_restart_rib_stale_time_cmd, | |
3279 | "bgp graceful-restart rib-stale-time (1-3600)", | |
e9273987 | 3280 | BGP_STR |
dc95985f | 3281 | "Graceful restart configuration parameters\n" |
3282 | "Specify the stale route removal timer in rib\n" | |
3283 | "Delay value (seconds)\n") | |
3284 | { | |
3285 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3286 | int idx_number = 3; | |
3287 | uint32_t stale_time; | |
3288 | ||
3289 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
3290 | bgp->rib_stale_time = stale_time; | |
3291 | /* Send the stale timer update message to RIB */ | |
3292 | if (bgp_zebra_stale_timer_update(bgp)) | |
3293 | return CMD_WARNING; | |
3294 | ||
3295 | return CMD_SUCCESS; | |
3296 | } | |
3297 | ||
3298 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
3299 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
3300 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
3301 | NO_STR | |
e9273987 | 3302 | BGP_STR |
dc95985f | 3303 | "Graceful restart configuration parameters\n" |
3304 | "Specify the stale route removal timer in rib\n" | |
3305 | "Delay value (seconds)\n") | |
3306 | { | |
3307 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3308 | ||
3309 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
3310 | /* Send the stale timer update message to RIB */ | |
3311 | if (bgp_zebra_stale_timer_update(bgp)) | |
3312 | return CMD_WARNING; | |
3313 | ||
d6e3c15b | 3314 | return CMD_SUCCESS; |
3315 | } | |
3316 | ||
8606be87 | 3317 | DEFUN(bgp_llgr_stalepath_time, bgp_llgr_stalepath_time_cmd, |
7f8a9a24 DA |
3318 | "bgp long-lived-graceful-restart stale-time (1-4294967295)", |
3319 | BGP_STR | |
8606be87 DA |
3320 | "Enable Long-lived Graceful Restart\n" |
3321 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3322 | "Stale time value (seconds)\n") | |
3323 | { | |
3324 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3325 | ||
3326 | uint32_t llgr_stale_time; | |
3327 | ||
3328 | llgr_stale_time = strtoul(argv[3]->arg, NULL, 10); | |
3329 | bgp->llgr_stale_time = llgr_stale_time; | |
3330 | ||
3331 | return CMD_SUCCESS; | |
3332 | } | |
3333 | ||
3334 | DEFUN(no_bgp_llgr_stalepath_time, no_bgp_llgr_stalepath_time_cmd, | |
7f8a9a24 | 3335 | "no bgp long-lived-graceful-restart stale-time [(1-4294967295)]", |
8606be87 DA |
3336 | NO_STR BGP_STR |
3337 | "Enable Long-lived Graceful Restart\n" | |
3338 | "Specifies maximum time to wait before purging long-lived stale routes\n" | |
3339 | "Stale time value (seconds)\n") | |
3340 | { | |
3341 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3342 | ||
3343 | bgp->llgr_stale_time = BGP_DEFAULT_LLGR_STALE_TIME; | |
3344 | ||
3345 | return CMD_SUCCESS; | |
3346 | } | |
3347 | ||
1ca2fd11 IR |
3348 | static inline void bgp_initiate_graceful_shut_unshut(struct vty *vty, |
3349 | struct bgp *bgp) | |
05bd726c | 3350 | { |
3351 | bgp_static_redo_import_check(bgp); | |
3352 | bgp_redistribute_redo(bgp); | |
1ca2fd11 IR |
3353 | bgp_clear_star_soft_out(vty, bgp->name); |
3354 | bgp_clear_star_soft_in(vty, bgp->name); | |
05bd726c | 3355 | } |
3356 | ||
3357 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
3358 | { | |
3359 | struct listnode *node, *nnode; | |
3360 | struct bgp *bgp; | |
3361 | bool vrf_cfg = false; | |
3362 | ||
3363 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3364 | return CMD_SUCCESS; | |
3365 | ||
3366 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
3367 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
3368 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3369 | vty_out(vty, | |
3370 | "%% graceful-shutdown configuration found in vrf %s\n", | |
3371 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
3372 | VRF_DEFAULT_NAME : bgp->name); | |
3373 | vrf_cfg = true; | |
3374 | } | |
3375 | } | |
3376 | ||
3377 | if (vrf_cfg) { | |
3378 | vty_out(vty, | |
3379 | "%%Failed: global graceful-shutdown not permitted\n"); | |
3380 | return CMD_WARNING; | |
3381 | } | |
3382 | ||
3383 | /* Set flag globally */ | |
3384 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3385 | ||
3386 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3387 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3388 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3389 | |
3390 | return CMD_SUCCESS; | |
3391 | } | |
3392 | ||
3393 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3394 | { | |
3395 | struct listnode *node, *nnode; | |
3396 | struct bgp *bgp; | |
3397 | ||
3398 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3399 | return CMD_SUCCESS; | |
3400 | ||
3401 | /* Unset flag globally */ | |
3402 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3403 | ||
3404 | /* Initiate processing for all BGP instances. */ | |
1ca2fd11 IR |
3405 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) |
3406 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
05bd726c | 3407 | |
3408 | return CMD_SUCCESS; | |
3409 | } | |
3410 | ||
7f323236 DW |
3411 | /* "bgp graceful-shutdown" configuration */ |
3412 | DEFUN (bgp_graceful_shutdown, | |
3413 | bgp_graceful_shutdown_cmd, | |
3414 | "bgp graceful-shutdown", | |
3415 | BGP_STR | |
3416 | "Graceful shutdown parameters\n") | |
3417 | { | |
05bd726c | 3418 | if (vty->node == CONFIG_NODE) |
3419 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3420 | ||
1ca2fd11 | 3421 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
7f323236 | 3422 | |
1ca2fd11 IR |
3423 | /* if configured globally, per-instance config is not allowed */ |
3424 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3425 | vty_out(vty, | |
3426 | "%%Failed: per-vrf graceful-shutdown config not permitted with global graceful-shutdown\n"); | |
3427 | return CMD_WARNING_CONFIG_FAILED; | |
3428 | } | |
3429 | ||
3430 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
3431 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3432 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3433 | } | |
3434 | ||
3435 | return CMD_SUCCESS; | |
7f323236 DW |
3436 | } |
3437 | ||
1ca2fd11 | 3438 | DEFUN (no_bgp_graceful_shutdown, |
7f323236 DW |
3439 | no_bgp_graceful_shutdown_cmd, |
3440 | "no bgp graceful-shutdown", | |
3441 | NO_STR | |
3442 | BGP_STR | |
3443 | "Graceful shutdown parameters\n") | |
3444 | { | |
05bd726c | 3445 | if (vty->node == CONFIG_NODE) |
3446 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3447 | ||
1ca2fd11 | 3448 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
05bd726c | 3449 | |
1ca2fd11 IR |
3450 | /* If configured globally, cannot remove from one bgp instance */ |
3451 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) { | |
3452 | vty_out(vty, | |
3453 | "%%Failed: bgp graceful-shutdown configured globally. Delete per-vrf not permitted\n"); | |
3454 | return CMD_WARNING_CONFIG_FAILED; | |
3455 | } | |
7f323236 | 3456 | |
1ca2fd11 IR |
3457 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
3458 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
3459 | bgp_initiate_graceful_shut_unshut(vty, bgp); | |
3460 | } | |
3461 | ||
3462 | return CMD_SUCCESS; | |
7f323236 DW |
3463 | } |
3464 | ||
718e3744 | 3465 | /* "bgp fast-external-failover" configuration. */ |
1ca2fd11 | 3466 | DEFUN (bgp_fast_external_failover, |
718e3744 | 3467 | bgp_fast_external_failover_cmd, |
3468 | "bgp fast-external-failover", | |
3469 | BGP_STR | |
3470 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3471 | { | |
1ca2fd11 IR |
3472 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3473 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3474 | return CMD_SUCCESS; | |
718e3744 | 3475 | } |
3476 | ||
1ca2fd11 | 3477 | DEFUN (no_bgp_fast_external_failover, |
718e3744 | 3478 | no_bgp_fast_external_failover_cmd, |
3479 | "no bgp fast-external-failover", | |
3480 | NO_STR | |
3481 | BGP_STR | |
3482 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3483 | { | |
1ca2fd11 IR |
3484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3485 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
3486 | return CMD_SUCCESS; | |
718e3744 | 3487 | } |
6b0655a2 | 3488 | |
718e3744 | 3489 | /* "bgp bestpath compare-routerid" configuration. */ |
1ca2fd11 IR |
3490 | DEFUN (bgp_bestpath_compare_router_id, |
3491 | bgp_bestpath_compare_router_id_cmd, | |
3492 | "bgp bestpath compare-routerid", | |
e9273987 | 3493 | BGP_STR |
1ca2fd11 IR |
3494 | "Change the default bestpath selection\n" |
3495 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3496 | { |
1ca2fd11 IR |
3497 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3498 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3499 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3500 | |
1ca2fd11 | 3501 | return CMD_SUCCESS; |
718e3744 | 3502 | } |
3503 | ||
1ca2fd11 IR |
3504 | DEFUN (no_bgp_bestpath_compare_router_id, |
3505 | no_bgp_bestpath_compare_router_id_cmd, | |
3506 | "no bgp bestpath compare-routerid", | |
3507 | NO_STR | |
e9273987 | 3508 | BGP_STR |
1ca2fd11 IR |
3509 | "Change the default bestpath selection\n" |
3510 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3511 | { |
1ca2fd11 IR |
3512 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3513 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); | |
3514 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3515 | |
1ca2fd11 | 3516 | return CMD_SUCCESS; |
718e3744 | 3517 | } |
6b0655a2 | 3518 | |
718e3744 | 3519 | /* "bgp bestpath as-path ignore" configuration. */ |
1ca2fd11 IR |
3520 | DEFUN (bgp_bestpath_aspath_ignore, |
3521 | bgp_bestpath_aspath_ignore_cmd, | |
3522 | "bgp bestpath as-path ignore", | |
e9273987 | 3523 | BGP_STR |
1ca2fd11 IR |
3524 | "Change the default bestpath selection\n" |
3525 | "AS-path attribute\n" | |
3526 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3527 | { |
1ca2fd11 IR |
3528 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3529 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3530 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3531 | |
1ca2fd11 | 3532 | return CMD_SUCCESS; |
718e3744 | 3533 | } |
3534 | ||
1ca2fd11 IR |
3535 | DEFUN (no_bgp_bestpath_aspath_ignore, |
3536 | no_bgp_bestpath_aspath_ignore_cmd, | |
3537 | "no bgp bestpath as-path ignore", | |
3538 | NO_STR | |
e9273987 | 3539 | BGP_STR |
1ca2fd11 IR |
3540 | "Change the default bestpath selection\n" |
3541 | "AS-path attribute\n" | |
3542 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3543 | { |
1ca2fd11 IR |
3544 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3545 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); | |
3546 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3547 | |
1ca2fd11 | 3548 | return CMD_SUCCESS; |
718e3744 | 3549 | } |
6b0655a2 | 3550 | |
6811845b | 3551 | /* "bgp bestpath as-path confed" configuration. */ |
1ca2fd11 | 3552 | DEFUN (bgp_bestpath_aspath_confed, |
6811845b | 3553 | bgp_bestpath_aspath_confed_cmd, |
3554 | "bgp bestpath as-path confed", | |
e9273987 | 3555 | BGP_STR |
6811845b | 3556 | "Change the default bestpath selection\n" |
3557 | "AS-path attribute\n" | |
3558 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3559 | { | |
1ca2fd11 IR |
3560 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3561 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3562 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3563 | |
1ca2fd11 | 3564 | return CMD_SUCCESS; |
6811845b | 3565 | } |
3566 | ||
1ca2fd11 | 3567 | DEFUN (no_bgp_bestpath_aspath_confed, |
6811845b | 3568 | no_bgp_bestpath_aspath_confed_cmd, |
3569 | "no bgp bestpath as-path confed", | |
3570 | NO_STR | |
e9273987 | 3571 | BGP_STR |
6811845b | 3572 | "Change the default bestpath selection\n" |
3573 | "AS-path attribute\n" | |
3574 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3575 | { | |
1ca2fd11 IR |
3576 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3577 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); | |
3578 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3579 | |
1ca2fd11 | 3580 | return CMD_SUCCESS; |
6811845b | 3581 | } |
6b0655a2 | 3582 | |
2fdd455c | 3583 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1ca2fd11 | 3584 | DEFUN (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3585 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3586 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
e9273987 | 3587 | BGP_STR |
16fc1eec DS |
3588 | "Change the default bestpath selection\n" |
3589 | "AS-path attribute\n" | |
3590 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3591 | "Generate an AS_SET\n" |
16fc1eec DS |
3592 | "Do not generate an AS_SET\n") |
3593 | { | |
1ca2fd11 | 3594 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3595 | int idx = 0; |
1ca2fd11 | 3596 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 3597 | |
1ca2fd11 IR |
3598 | /* no-as-set is now the default behavior so we can silently |
3599 | * ignore it */ | |
d62a17ae | 3600 | if (argv_find(argv, argc, "as-set", &idx)) |
1ca2fd11 | 3601 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 3602 | else |
1ca2fd11 | 3603 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca | 3604 | |
1ca2fd11 IR |
3605 | bgp_recalculate_all_bestpaths(bgp); |
3606 | ||
3607 | return CMD_SUCCESS; | |
16fc1eec DS |
3608 | } |
3609 | ||
1ca2fd11 | 3610 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3611 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3612 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec | 3613 | NO_STR |
e9273987 | 3614 | BGP_STR |
16fc1eec DS |
3615 | "Change the default bestpath selection\n" |
3616 | "AS-path attribute\n" | |
3617 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3618 | "Generate an AS_SET\n" |
16fc1eec DS |
3619 | "Do not generate an AS_SET\n") |
3620 | { | |
1ca2fd11 IR |
3621 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3622 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
3623 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
3624 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 3625 | |
1ca2fd11 | 3626 | return CMD_SUCCESS; |
2fdd455c | 3627 | } |
6b0655a2 | 3628 | |
ee88563a JM |
3629 | /* "bgp bestpath peer-type multipath-relax" configuration. */ |
3630 | DEFUN(bgp_bestpath_peer_type_multipath_relax, | |
3631 | bgp_bestpath_peer_type_multipath_relax_cmd, | |
3632 | "bgp bestpath peer-type multipath-relax", | |
3633 | BGP_STR | |
3634 | "Change the default bestpath selection\n" | |
3635 | "Peer type\n" | |
3636 | "Allow load sharing across routes learned from different peer types\n") | |
3637 | { | |
3638 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3639 | SET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3640 | bgp_recalculate_all_bestpaths(bgp); | |
3641 | ||
3642 | return CMD_SUCCESS; | |
3643 | } | |
3644 | ||
3645 | DEFUN(no_bgp_bestpath_peer_type_multipath_relax, | |
3646 | no_bgp_bestpath_peer_type_multipath_relax_cmd, | |
3647 | "no bgp bestpath peer-type multipath-relax", | |
3648 | NO_STR BGP_STR | |
3649 | "Change the default bestpath selection\n" | |
3650 | "Peer type\n" | |
3651 | "Allow load sharing across routes learned from different peer types\n") | |
3652 | { | |
3653 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3654 | UNSET_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX); | |
3655 | bgp_recalculate_all_bestpaths(bgp); | |
3656 | ||
3657 | return CMD_SUCCESS; | |
3658 | } | |
3659 | ||
848973c7 | 3660 | /* "bgp log-neighbor-changes" configuration. */ |
1ca2fd11 IR |
3661 | DEFUN (bgp_log_neighbor_changes, |
3662 | bgp_log_neighbor_changes_cmd, | |
3663 | "bgp log-neighbor-changes", | |
e9273987 | 3664 | BGP_STR |
1ca2fd11 | 3665 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3666 | { |
1ca2fd11 IR |
3667 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3668 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3669 | return CMD_SUCCESS; | |
848973c7 | 3670 | } |
3671 | ||
1ca2fd11 IR |
3672 | DEFUN (no_bgp_log_neighbor_changes, |
3673 | no_bgp_log_neighbor_changes_cmd, | |
3674 | "no bgp log-neighbor-changes", | |
3675 | NO_STR | |
e9273987 | 3676 | BGP_STR |
1ca2fd11 | 3677 | "Log neighbor up/down and reset reason\n") |
848973c7 | 3678 | { |
1ca2fd11 IR |
3679 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3680 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
3681 | return CMD_SUCCESS; | |
848973c7 | 3682 | } |
6b0655a2 | 3683 | |
718e3744 | 3684 | /* "bgp bestpath med" configuration. */ |
1ca2fd11 | 3685 | DEFUN (bgp_bestpath_med, |
718e3744 | 3686 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3687 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
e9273987 | 3688 | BGP_STR |
718e3744 | 3689 | "Change the default bestpath selection\n" |
3690 | "MED attribute\n" | |
3691 | "Compare MED among confederation paths\n" | |
838758ac DW |
3692 | "Treat missing MED as the least preferred one\n" |
3693 | "Treat missing MED as the least preferred one\n" | |
3694 | "Compare MED among confederation paths\n") | |
718e3744 | 3695 | { |
1ca2fd11 | 3696 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3697 | |
1ca2fd11 | 3698 | int idx = 0; |
d62a17ae | 3699 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3700 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3701 | idx = 0; |
3702 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 | 3703 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 3704 | |
1ca2fd11 | 3705 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 3706 | |
1ca2fd11 | 3707 | return CMD_SUCCESS; |
718e3744 | 3708 | } |
3709 | ||
1ca2fd11 | 3710 | DEFUN (no_bgp_bestpath_med, |
718e3744 | 3711 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3712 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3713 | NO_STR |
e9273987 | 3714 | BGP_STR |
718e3744 | 3715 | "Change the default bestpath selection\n" |
3716 | "MED attribute\n" | |
3717 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3718 | "Treat missing MED as the least preferred one\n" |
3719 | "Treat missing MED as the least preferred one\n" | |
3720 | "Compare MED among confederation paths\n") | |
718e3744 | 3721 | { |
1ca2fd11 | 3722 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3723 | |
1ca2fd11 | 3724 | int idx = 0; |
d62a17ae | 3725 | if (argv_find(argv, argc, "confed", &idx)) |
1ca2fd11 | 3726 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 3727 | idx = 0; |
3728 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
1ca2fd11 IR |
3729 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
3730 | ||
3731 | bgp_recalculate_all_bestpaths(bgp); | |
718e3744 | 3732 | |
1ca2fd11 | 3733 | return CMD_SUCCESS; |
718e3744 | 3734 | } |
3735 | ||
f7e1c681 | 3736 | /* "bgp bestpath bandwidth" configuration. */ |
3737 | DEFPY (bgp_bestpath_bw, | |
3738 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3739 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
e9273987 | 3740 | BGP_STR |
f7e1c681 | 3741 | "Change the default bestpath selection\n" |
3742 | "Link Bandwidth attribute\n" | |
3743 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3744 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3745 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3746 | { | |
3747 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3748 | afi_t afi; | |
3749 | safi_t safi; | |
3750 | ||
ad36d216 DS |
3751 | if (!bw_cfg) { |
3752 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3753 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3754 | } |
ad36d216 DS |
3755 | if (!strcmp(bw_cfg, "ignore")) |
3756 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3757 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3758 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3759 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3760 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3761 | else | |
3762 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3763 | |
3764 | /* This config is used in route install, so redo that. */ | |
3765 | FOREACH_AFI_SAFI (afi, safi) { | |
3766 | if (!bgp_fibupd_safi(safi)) | |
3767 | continue; | |
3768 | bgp_zebra_announce_table(bgp, afi, safi); | |
3769 | } | |
3770 | ||
3771 | return CMD_SUCCESS; | |
3772 | } | |
3773 | ||
ad36d216 DS |
3774 | DEFPY (no_bgp_bestpath_bw, |
3775 | no_bgp_bestpath_bw_cmd, | |
3776 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3777 | NO_STR | |
e9273987 | 3778 | BGP_STR |
ad36d216 DS |
3779 | "Change the default bestpath selection\n" |
3780 | "Link Bandwidth attribute\n" | |
3781 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3782 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3783 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3784 | { | |
3785 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3786 | afi_t afi; | |
3787 | safi_t safi; | |
3788 | ||
3789 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3790 | ||
3791 | /* This config is used in route install, so redo that. */ | |
3792 | FOREACH_AFI_SAFI (afi, safi) { | |
3793 | if (!bgp_fibupd_safi(safi)) | |
3794 | continue; | |
3795 | bgp_zebra_announce_table(bgp, afi, safi); | |
3796 | } | |
3797 | return CMD_SUCCESS; | |
3798 | } | |
3799 | ||
b16bcbba | 3800 | DEFPY(bgp_default_afi_safi, bgp_default_afi_safi_cmd, |
38d11af5 TA |
3801 | "[no] bgp default <ipv4-unicast|" |
3802 | "ipv4-multicast|" | |
3803 | "ipv4-vpn|" | |
3804 | "ipv4-labeled-unicast|" | |
3805 | "ipv4-flowspec|" | |
3806 | "ipv6-unicast|" | |
3807 | "ipv6-multicast|" | |
3808 | "ipv6-vpn|" | |
3809 | "ipv6-labeled-unicast|" | |
3810 | "ipv6-flowspec|" | |
3811 | "l2vpn-evpn>$afi_safi", | |
b16bcbba | 3812 | NO_STR |
e9273987 | 3813 | BGP_STR |
e84c59af | 3814 | "Configure BGP defaults\n" |
b16bcbba | 3815 | "Activate ipv4-unicast for a peer by default\n" |
38d11af5 TA |
3816 | "Activate ipv4-multicast for a peer by default\n" |
3817 | "Activate ipv4-vpn for a peer by default\n" | |
3818 | "Activate ipv4-labeled-unicast for a peer by default\n" | |
3819 | "Activate ipv4-flowspec for a peer by default\n" | |
3820 | "Activate ipv6-unicast for a peer by default\n" | |
3821 | "Activate ipv6-multicast for a peer by default\n" | |
3822 | "Activate ipv6-vpn for a peer by default\n" | |
3823 | "Activate ipv6-labeled-unicast for a peer by default\n" | |
3824 | "Activate ipv6-flowspec for a peer by default\n" | |
3825 | "Activate l2vpn-evpn for a peer by default\n") | |
e84c59af DA |
3826 | { |
3827 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b16bcbba TA |
3828 | char afi_safi_str[strlen(afi_safi) + 1]; |
3829 | char *afi_safi_str_tok; | |
e84c59af | 3830 | |
b16bcbba TA |
3831 | strlcpy(afi_safi_str, afi_safi, sizeof(afi_safi_str)); |
3832 | char *afi_str = strtok_r(afi_safi_str, "-", &afi_safi_str_tok); | |
3833 | char *safi_str = strtok_r(NULL, "-", &afi_safi_str_tok); | |
3834 | afi_t afi = bgp_vty_afi_from_str(afi_str); | |
38d11af5 | 3835 | safi_t safi; |
e84c59af | 3836 | |
38d11af5 TA |
3837 | if (strmatch(safi_str, "labeled")) |
3838 | safi = bgp_vty_safi_from_str("labeled-unicast"); | |
3839 | else | |
3840 | safi = bgp_vty_safi_from_str(safi_str); | |
b16bcbba TA |
3841 | |
3842 | if (no) | |
3843 | bgp->default_af[afi][safi] = false; | |
38d11af5 TA |
3844 | else { |
3845 | if ((safi == SAFI_LABELED_UNICAST | |
3846 | && bgp->default_af[afi][SAFI_UNICAST]) | |
3847 | || (safi == SAFI_UNICAST | |
3848 | && bgp->default_af[afi][SAFI_LABELED_UNICAST])) | |
3849 | bgp_vty_return(vty, BGP_ERR_PEER_SAFI_CONFLICT); | |
3850 | else | |
3851 | bgp->default_af[afi][safi] = true; | |
3852 | } | |
718e3744 | 3853 | |
d62a17ae | 3854 | return CMD_SUCCESS; |
718e3744 | 3855 | } |
6b0655a2 | 3856 | |
04b6bdc0 | 3857 | /* Display hostname in certain command outputs */ |
1ca2fd11 | 3858 | DEFUN (bgp_default_show_hostname, |
04b6bdc0 DW |
3859 | bgp_default_show_hostname_cmd, |
3860 | "bgp default show-hostname", | |
e9273987 | 3861 | BGP_STR |
04b6bdc0 | 3862 | "Configure BGP defaults\n" |
0437e105 | 3863 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3864 | { |
1ca2fd11 IR |
3865 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3866 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3867 | return CMD_SUCCESS; | |
ff8a8a7a CS |
3868 | } |
3869 | ||
1ca2fd11 IR |
3870 | DEFUN (no_bgp_default_show_hostname, |
3871 | no_bgp_default_show_hostname_cmd, | |
3872 | "no bgp default show-hostname", | |
3873 | NO_STR | |
e9273987 | 3874 | BGP_STR |
1ca2fd11 IR |
3875 | "Configure BGP defaults\n" |
3876 | "Show hostname in certain command outputs\n") | |
ff8a8a7a | 3877 | { |
1ca2fd11 IR |
3878 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3879 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); | |
3880 | return CMD_SUCCESS; | |
04b6bdc0 DW |
3881 | } |
3882 | ||
aef999a2 | 3883 | /* Display hostname in certain command outputs */ |
1d80f243 IR |
3884 | DEFUN (bgp_default_show_nexthop_hostname, |
3885 | bgp_default_show_nexthop_hostname_cmd, | |
3886 | "bgp default show-nexthop-hostname", | |
e9273987 | 3887 | BGP_STR |
1d80f243 IR |
3888 | "Configure BGP defaults\n" |
3889 | "Show hostname for nexthop in certain command outputs\n") | |
aef999a2 | 3890 | { |
1ca2fd11 IR |
3891 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3892 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3893 | return CMD_SUCCESS; | |
aef999a2 DA |
3894 | } |
3895 | ||
3896 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3897 | no_bgp_default_show_nexthop_hostname_cmd, | |
3898 | "no bgp default show-nexthop-hostname", | |
3899 | NO_STR | |
e9273987 | 3900 | BGP_STR |
aef999a2 DA |
3901 | "Configure BGP defaults\n" |
3902 | "Show hostname for nexthop in certain command outputs\n") | |
3903 | { | |
1ca2fd11 IR |
3904 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3905 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
3906 | return CMD_SUCCESS; | |
aef999a2 DA |
3907 | } |
3908 | ||
8233ef81 | 3909 | /* "bgp network import-check" configuration. */ |
1ca2fd11 IR |
3910 | DEFUN (bgp_network_import_check, |
3911 | bgp_network_import_check_cmd, | |
3912 | "bgp network import-check", | |
e9273987 | 3913 | BGP_STR |
1ca2fd11 IR |
3914 | "BGP network command\n" |
3915 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3916 | { |
1ca2fd11 IR |
3917 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3918 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3919 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3920 | bgp_static_redo_import_check(bgp); | |
3921 | } | |
078430f6 | 3922 | |
1ca2fd11 | 3923 | return CMD_SUCCESS; |
718e3744 | 3924 | } |
3925 | ||
d62a17ae | 3926 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3927 | "bgp network import-check exact", | |
e9273987 | 3928 | BGP_STR |
d62a17ae | 3929 | "BGP network command\n" |
3930 | "Check BGP network route exists in IGP\n" | |
3931 | "Match route precisely\n") | |
8233ef81 | 3932 | |
1ca2fd11 IR |
3933 | DEFUN (no_bgp_network_import_check, |
3934 | no_bgp_network_import_check_cmd, | |
3935 | "no bgp network import-check", | |
3936 | NO_STR | |
e9273987 | 3937 | BGP_STR |
1ca2fd11 IR |
3938 | "BGP network command\n" |
3939 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3940 | { |
1ca2fd11 IR |
3941 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3942 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | |
3943 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
3944 | bgp_static_redo_import_check(bgp); | |
3945 | } | |
6b0655a2 | 3946 | |
1ca2fd11 | 3947 | return CMD_SUCCESS; |
ff8a8a7a | 3948 | } |
718e3744 | 3949 | |
1ca2fd11 IR |
3950 | DEFUN (bgp_default_local_preference, |
3951 | bgp_default_local_preference_cmd, | |
3952 | "bgp default local-preference (0-4294967295)", | |
e9273987 | 3953 | BGP_STR |
1ca2fd11 IR |
3954 | "Configure BGP defaults\n" |
3955 | "local preference (higher=more preferred)\n" | |
3956 | "Configure default local preference value\n") | |
ff8a8a7a | 3957 | { |
1ca2fd11 | 3958 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 3959 | int idx_number = 3; |
1ca2fd11 | 3960 | uint32_t local_pref; |
718e3744 | 3961 | |
1ca2fd11 | 3962 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3963 | |
1ca2fd11 IR |
3964 | bgp_default_local_preference_set(bgp, local_pref); |
3965 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3966 | |
1ca2fd11 | 3967 | return CMD_SUCCESS; |
718e3744 | 3968 | } |
3969 | ||
1ca2fd11 IR |
3970 | DEFUN (no_bgp_default_local_preference, |
3971 | no_bgp_default_local_preference_cmd, | |
3972 | "no bgp default local-preference [(0-4294967295)]", | |
3973 | NO_STR | |
e9273987 | 3974 | BGP_STR |
1ca2fd11 IR |
3975 | "Configure BGP defaults\n" |
3976 | "local preference (higher=more preferred)\n" | |
3977 | "Configure default local preference value\n") | |
ff8a8a7a | 3978 | { |
1ca2fd11 IR |
3979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3980 | bgp_default_local_preference_unset(bgp); | |
3981 | bgp_clear_star_soft_in(vty, bgp->name); | |
3982 | ||
3983 | return CMD_SUCCESS; | |
ff8a8a7a | 3984 | } |
6b0655a2 | 3985 | |
ff8a8a7a | 3986 | |
1ca2fd11 IR |
3987 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3988 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3989 | "bgp default subgroup-pkt-queue-max (20-100)", | |
e9273987 | 3990 | BGP_STR |
1ca2fd11 IR |
3991 | "Configure BGP defaults\n" |
3992 | "subgroup-pkt-queue-max\n" | |
3993 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3994 | { |
1ca2fd11 | 3995 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 3996 | int idx_number = 3; |
1ca2fd11 | 3997 | uint32_t max_size; |
3f9c7369 | 3998 | |
1ca2fd11 | 3999 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 4000 | |
1ca2fd11 | 4001 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
ff8a8a7a | 4002 | |
1ca2fd11 | 4003 | return CMD_SUCCESS; |
8bd9d948 DS |
4004 | } |
4005 | ||
1ca2fd11 IR |
4006 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, |
4007 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
4008 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
4009 | NO_STR | |
e9273987 | 4010 | BGP_STR |
1ca2fd11 IR |
4011 | "Configure BGP defaults\n" |
4012 | "subgroup-pkt-queue-max\n" | |
4013 | "Configure subgroup packet queue max\n") | |
ff8a8a7a | 4014 | { |
1ca2fd11 IR |
4015 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4016 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
4017 | return CMD_SUCCESS; | |
ff8a8a7a | 4018 | } |
813d4307 | 4019 | |
8bd9d948 | 4020 | |
1ca2fd11 IR |
4021 | DEFUN (bgp_rr_allow_outbound_policy, |
4022 | bgp_rr_allow_outbound_policy_cmd, | |
4023 | "bgp route-reflector allow-outbound-policy", | |
e9273987 | 4024 | BGP_STR |
1ca2fd11 IR |
4025 | "Allow modifications made by out route-map\n" |
4026 | "on ibgp neighbors\n") | |
ff8a8a7a | 4027 | { |
1ca2fd11 | 4028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ff8a8a7a | 4029 | |
1ca2fd11 IR |
4030 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4031 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4032 | update_group_announce_rrclients(bgp); | |
4033 | bgp_clear_star_soft_out(vty, bgp->name); | |
4034 | } | |
8bd9d948 | 4035 | |
1ca2fd11 IR |
4036 | return CMD_SUCCESS; |
4037 | } | |
ff8a8a7a | 4038 | |
1ca2fd11 IR |
4039 | DEFUN (no_bgp_rr_allow_outbound_policy, |
4040 | no_bgp_rr_allow_outbound_policy_cmd, | |
4041 | "no bgp route-reflector allow-outbound-policy", | |
4042 | NO_STR | |
e9273987 | 4043 | BGP_STR |
1ca2fd11 IR |
4044 | "Allow modifications made by out route-map\n" |
4045 | "on ibgp neighbors\n") | |
8bd9d948 | 4046 | { |
1ca2fd11 | 4047 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 4048 | |
1ca2fd11 IR |
4049 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
4050 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
4051 | update_group_announce_rrclients(bgp); | |
4052 | bgp_clear_star_soft_out(vty, bgp->name); | |
d62a17ae | 4053 | } |
8bd9d948 | 4054 | |
1ca2fd11 | 4055 | return CMD_SUCCESS; |
8bd9d948 DS |
4056 | } |
4057 | ||
1ca2fd11 IR |
4058 | DEFUN (bgp_listen_limit, |
4059 | bgp_listen_limit_cmd, | |
4060 | "bgp listen limit (1-65535)", | |
e9273987 | 4061 | BGP_STR |
1ca2fd11 IR |
4062 | "BGP Dynamic Neighbors listen commands\n" |
4063 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4064 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4065 | { |
1ca2fd11 | 4066 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4067 | int idx_number = 3; |
1ca2fd11 IR |
4068 | int listen_limit; |
4069 | ||
4070 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); | |
f14e6fdb | 4071 | |
1ca2fd11 | 4072 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 4073 | |
1ca2fd11 | 4074 | return CMD_SUCCESS; |
f14e6fdb DS |
4075 | } |
4076 | ||
1ca2fd11 IR |
4077 | DEFUN (no_bgp_listen_limit, |
4078 | no_bgp_listen_limit_cmd, | |
4079 | "no bgp listen limit [(1-65535)]", | |
4080 | NO_STR | |
e9273987 | 4081 | BGP_STR |
1ca2fd11 IR |
4082 | "BGP Dynamic Neighbors listen commands\n" |
4083 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
4084 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 4085 | { |
1ca2fd11 IR |
4086 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4087 | bgp_listen_limit_unset(bgp); | |
4088 | return CMD_SUCCESS; | |
f14e6fdb DS |
4089 | } |
4090 | ||
4091 | ||
20eb8864 | 4092 | /* |
4093 | * Check if this listen range is already configured. Check for exact | |
4094 | * match or overlap based on input. | |
4095 | */ | |
d62a17ae | 4096 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
4097 | struct prefix *range, int exact) | |
4098 | { | |
4099 | struct listnode *node, *nnode; | |
4100 | struct listnode *node1, *nnode1; | |
4101 | struct peer_group *group; | |
4102 | struct prefix *lr; | |
4103 | afi_t afi; | |
4104 | int match; | |
4105 | ||
4106 | afi = family2afi(range->family); | |
4107 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4108 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
4109 | lr)) { | |
4110 | if (exact) | |
4111 | match = prefix_same(range, lr); | |
4112 | else | |
4113 | match = (prefix_match(range, lr) | |
4114 | || prefix_match(lr, range)); | |
4115 | if (match) | |
4116 | return group; | |
4117 | } | |
4118 | } | |
4119 | ||
4120 | return NULL; | |
20eb8864 | 4121 | } |
4122 | ||
f14e6fdb DS |
4123 | DEFUN (bgp_listen_range, |
4124 | bgp_listen_range_cmd, | |
d7b9898c | 4125 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
e9273987 | 4126 | BGP_STR |
d7fa34c1 QY |
4127 | "Configure BGP dynamic neighbors listen range\n" |
4128 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
4129 | NEIGHBOR_ADDR_STR |
4130 | "Member of the peer-group\n" | |
4131 | "Peer-group name\n") | |
f14e6fdb | 4132 | { |
d62a17ae | 4133 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4134 | struct prefix range; | |
4135 | struct peer_group *group, *existing_group; | |
4136 | afi_t afi; | |
4137 | int ret; | |
4138 | int idx = 0; | |
4139 | ||
4140 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4141 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4142 | char *prefix = argv[idx]->arg; | |
d7b9898c | 4143 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4144 | char *peergroup = argv[idx]->arg; |
4145 | ||
4146 | /* Convert IP prefix string to struct prefix. */ | |
4147 | ret = str2prefix(prefix, &range); | |
4148 | if (!ret) { | |
4149 | vty_out(vty, "%% Malformed listen range\n"); | |
4150 | return CMD_WARNING_CONFIG_FAILED; | |
4151 | } | |
4152 | ||
4153 | afi = family2afi(range.family); | |
4154 | ||
4155 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4156 | vty_out(vty, | |
4157 | "%% Malformed listen range (link-local address)\n"); | |
4158 | return CMD_WARNING_CONFIG_FAILED; | |
4159 | } | |
4160 | ||
4161 | apply_mask(&range); | |
4162 | ||
4163 | /* Check if same listen range is already configured. */ | |
4164 | existing_group = listen_range_exists(bgp, &range, 1); | |
4165 | if (existing_group) { | |
4166 | if (strcmp(existing_group->name, peergroup) == 0) | |
4167 | return CMD_SUCCESS; | |
4168 | else { | |
4169 | vty_out(vty, | |
4170 | "%% Same listen range is attached to peer-group %s\n", | |
4171 | existing_group->name); | |
4172 | return CMD_WARNING_CONFIG_FAILED; | |
4173 | } | |
4174 | } | |
4175 | ||
4176 | /* Check if an overlapping listen range exists. */ | |
4177 | if (listen_range_exists(bgp, &range, 0)) { | |
4178 | vty_out(vty, | |
4179 | "%% Listen range overlaps with existing listen range\n"); | |
4180 | return CMD_WARNING_CONFIG_FAILED; | |
4181 | } | |
4182 | ||
4183 | group = peer_group_lookup(bgp, peergroup); | |
4184 | if (!group) { | |
4185 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4186 | return CMD_WARNING_CONFIG_FAILED; | |
4187 | } | |
4188 | ||
4189 | ret = peer_group_listen_range_add(group, &range); | |
4190 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
4191 | } |
4192 | ||
4193 | DEFUN (no_bgp_listen_range, | |
4194 | no_bgp_listen_range_cmd, | |
d7b9898c | 4195 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 4196 | NO_STR |
e9273987 | 4197 | BGP_STR |
d7fa34c1 QY |
4198 | "Unconfigure BGP dynamic neighbors listen range\n" |
4199 | "Unconfigure BGP dynamic neighbors listen range\n" | |
4200 | NEIGHBOR_ADDR_STR | |
4201 | "Member of the peer-group\n" | |
4202 | "Peer-group name\n") | |
f14e6fdb | 4203 | { |
d62a17ae | 4204 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4205 | struct prefix range; | |
4206 | struct peer_group *group; | |
4207 | afi_t afi; | |
4208 | int ret; | |
4209 | int idx = 0; | |
4210 | ||
4211 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
4212 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
4213 | char *prefix = argv[idx]->arg; | |
21d88a71 | 4214 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 4215 | char *peergroup = argv[idx]->arg; |
4216 | ||
4217 | /* Convert IP prefix string to struct prefix. */ | |
4218 | ret = str2prefix(prefix, &range); | |
4219 | if (!ret) { | |
4220 | vty_out(vty, "%% Malformed listen range\n"); | |
4221 | return CMD_WARNING_CONFIG_FAILED; | |
4222 | } | |
4223 | ||
4224 | afi = family2afi(range.family); | |
4225 | ||
4226 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
4227 | vty_out(vty, | |
4228 | "%% Malformed listen range (link-local address)\n"); | |
4229 | return CMD_WARNING_CONFIG_FAILED; | |
4230 | } | |
4231 | ||
4232 | apply_mask(&range); | |
4233 | ||
4234 | group = peer_group_lookup(bgp, peergroup); | |
4235 | if (!group) { | |
4236 | vty_out(vty, "%% Peer-group does not exist\n"); | |
4237 | return CMD_WARNING_CONFIG_FAILED; | |
4238 | } | |
4239 | ||
4240 | ret = peer_group_listen_range_del(group, &range); | |
4241 | return bgp_vty_return(vty, ret); | |
4242 | } | |
4243 | ||
2b791107 | 4244 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 4245 | { |
4246 | struct peer_group *group; | |
4247 | struct listnode *node, *nnode, *rnode, *nrnode; | |
4248 | struct prefix *range; | |
4249 | afi_t afi; | |
d62a17ae | 4250 | |
4251 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
4252 | vty_out(vty, " bgp listen limit %d\n", | |
4253 | bgp->dynamic_neighbors_limit); | |
4254 | ||
4255 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
4256 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
4257 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
4258 | nrnode, range)) { | |
d62a17ae | 4259 | vty_out(vty, |
2dbe669b DA |
4260 | " bgp listen range %pFX peer-group %s\n", |
4261 | range, group->name); | |
d62a17ae | 4262 | } |
4263 | } | |
4264 | } | |
f14e6fdb DS |
4265 | } |
4266 | ||
4267 | ||
1ca2fd11 IR |
4268 | DEFUN (bgp_disable_connected_route_check, |
4269 | bgp_disable_connected_route_check_cmd, | |
4270 | "bgp disable-ebgp-connected-route-check", | |
e9273987 | 4271 | BGP_STR |
1ca2fd11 | 4272 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4273 | { |
1ca2fd11 IR |
4274 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4275 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4276 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 4277 | |
1ca2fd11 | 4278 | return CMD_SUCCESS; |
907f92c8 DS |
4279 | } |
4280 | ||
1ca2fd11 IR |
4281 | DEFUN (no_bgp_disable_connected_route_check, |
4282 | no_bgp_disable_connected_route_check_cmd, | |
4283 | "no bgp disable-ebgp-connected-route-check", | |
4284 | NO_STR | |
e9273987 | 4285 | BGP_STR |
1ca2fd11 | 4286 | "Disable checking if nexthop is connected on ebgp sessions\n") |
907f92c8 | 4287 | { |
1ca2fd11 IR |
4288 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4289 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
4290 | bgp_clear_star_soft_in(vty, bgp->name); | |
d62a17ae | 4291 | |
1ca2fd11 | 4292 | return CMD_SUCCESS; |
d62a17ae | 4293 | } |
4294 | ||
4295 | ||
28c6e247 IR |
4296 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, |
4297 | const char *as_str) | |
4298 | { | |
4299 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4300 | int ret; | |
4301 | as_t as; | |
4302 | int as_type = AS_SPECIFIED; | |
4303 | union sockunion su; | |
4304 | ||
4305 | if (as_str[0] == 'i') { | |
4306 | as = 0; | |
4307 | as_type = AS_INTERNAL; | |
4308 | } else if (as_str[0] == 'e') { | |
4309 | as = 0; | |
4310 | as_type = AS_EXTERNAL; | |
4311 | } else { | |
4312 | /* Get AS number. */ | |
4313 | as = strtoul(as_str, NULL, 10); | |
4314 | } | |
4315 | ||
4316 | /* If peer is peer group or interface peer, call proper function. */ | |
4317 | ret = str2sockunion(peer_str, &su); | |
4318 | if (ret < 0) { | |
4319 | struct peer *peer; | |
4320 | ||
4321 | /* Check if existing interface peer */ | |
4322 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
4323 | ||
4324 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type); | |
4325 | ||
4326 | /* if not interface peer, check peer-group settings */ | |
4327 | if (ret < 0 && !peer) { | |
4328 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
4329 | if (ret < 0) { | |
4330 | vty_out(vty, | |
4331 | "%% Create the peer-group or interface first\n"); | |
4332 | return CMD_WARNING_CONFIG_FAILED; | |
4333 | } | |
4334 | return CMD_SUCCESS; | |
4335 | } | |
4336 | } else { | |
4337 | if (peer_address_self_check(bgp, &su)) { | |
4338 | vty_out(vty, | |
4339 | "%% Can not configure the local system as neighbor\n"); | |
4340 | return CMD_WARNING_CONFIG_FAILED; | |
4341 | } | |
4342 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type); | |
4343 | } | |
4344 | ||
28c6e247 IR |
4345 | return bgp_vty_return(vty, ret); |
4346 | } | |
4347 | ||
1ca2fd11 IR |
4348 | DEFUN (bgp_default_shutdown, |
4349 | bgp_default_shutdown_cmd, | |
4350 | "[no] bgp default shutdown", | |
4351 | NO_STR | |
4352 | BGP_STR | |
4353 | "Configure BGP defaults\n" | |
4354 | "Apply administrative shutdown to newly configured peers\n") | |
ff8a8a7a | 4355 | { |
1ca2fd11 IR |
4356 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4357 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
4358 | return CMD_SUCCESS; | |
f26845f9 QY |
4359 | } |
4360 | ||
736b68f3 DS |
4361 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4362 | BGP_STR | |
9ddf4b81 | 4363 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4364 | "Add a shutdown message (RFC 8203)\n" |
4365 | "Shutdown message\n") | |
9cf59432 | 4366 | { |
736b68f3 | 4367 | char *msgstr = NULL; |
8389c83a | 4368 | |
9cf59432 DS |
4369 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4370 | ||
8389c83a | 4371 | if (argc > 3) |
f80e35b6 | 4372 | msgstr = argv_concat(argv, argc, 3); |
8389c83a | 4373 | |
b776f48c DA |
4374 | if (msgstr && strlen(msgstr) > BGP_ADMIN_SHUTDOWN_MSG_LEN) { |
4375 | vty_out(vty, "%% Shutdown message size exceeded %d\n", | |
4376 | BGP_ADMIN_SHUTDOWN_MSG_LEN); | |
4377 | return CMD_WARNING_CONFIG_FAILED; | |
4378 | } | |
4379 | ||
8389c83a DS |
4380 | bgp_shutdown_enable(bgp, msgstr); |
4381 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4382 | |
4383 | return CMD_SUCCESS; | |
4384 | } | |
4385 | ||
736b68f3 | 4386 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4387 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4388 | { |
4389 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4390 | ||
4391 | bgp_shutdown_enable(bgp, NULL); | |
4392 | ||
4393 | return CMD_SUCCESS; | |
4394 | } | |
8389c83a | 4395 | |
736b68f3 | 4396 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4397 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4398 | { |
4399 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4400 | ||
4401 | bgp_shutdown_disable(bgp); | |
4402 | ||
4403 | return CMD_SUCCESS; | |
4404 | } | |
4405 | ||
9ddf4b81 | 4406 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4407 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4408 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4409 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4410 | |
28c6e247 IR |
4411 | DEFUN (neighbor_remote_as, |
4412 | neighbor_remote_as_cmd, | |
4413 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", | |
4414 | NEIGHBOR_STR | |
4415 | NEIGHBOR_ADDR_STR2 | |
4416 | "Specify a BGP neighbor\n" | |
4417 | AS_STR | |
4418 | "Internal BGP peer\n" | |
4419 | "External BGP peer\n") | |
718e3744 | 4420 | { |
d62a17ae | 4421 | int idx_peer = 1; |
4422 | int idx_remote_as = 3; | |
28c6e247 IR |
4423 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, |
4424 | argv[idx_remote_as]->arg); | |
d62a17ae | 4425 | } |
f852eb98 PG |
4426 | /* Enable fast convergence of bgp sessions. If this is enabled, bgp |
4427 | * sessions do not wait for hold timer expiry to bring down the sessions | |
4428 | * when nexthop becomes unreachable | |
4429 | */ | |
4430 | DEFUN(bgp_fast_convergence, bgp_fast_convergence_cmd, "bgp fast-convergence", | |
4431 | BGP_STR "Fast convergence for bgp sessions\n") | |
4432 | { | |
4433 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4434 | bgp->fast_convergence = true; | |
4435 | ||
4436 | return CMD_SUCCESS; | |
4437 | } | |
4438 | ||
4439 | DEFUN(no_bgp_fast_convergence, no_bgp_fast_convergence_cmd, | |
4440 | "no bgp fast-convergence", | |
4441 | NO_STR BGP_STR "Fast convergence for bgp sessions\n") | |
4442 | { | |
4443 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4444 | bgp->fast_convergence = false; | |
4445 | ||
4446 | return CMD_SUCCESS; | |
4447 | } | |
d62a17ae | 4448 | |
28c6e247 IR |
4449 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, |
4450 | int v6only, | |
4451 | const char *peer_group_name, | |
4452 | const char *as_str) | |
d62a17ae | 4453 | { |
28c6e247 IR |
4454 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4455 | as_t as = 0; | |
4456 | int as_type = AS_UNSPECIFIED; | |
d62a17ae | 4457 | struct peer *peer; |
4458 | struct peer_group *group; | |
4459 | int ret = 0; | |
d62a17ae | 4460 | |
4461 | group = peer_group_lookup(bgp, conf_if); | |
4462 | ||
4463 | if (group) { | |
28c6e247 IR |
4464 | vty_out(vty, "%% Name conflict with peer-group \n"); |
4465 | return CMD_WARNING_CONFIG_FAILED; | |
4466 | } | |
4467 | ||
4468 | if (as_str) { | |
4469 | if (as_str[0] == 'i') { | |
4470 | as_type = AS_INTERNAL; | |
4471 | } else if (as_str[0] == 'e') { | |
4472 | as_type = AS_EXTERNAL; | |
4473 | } else { | |
4474 | /* Get AS number. */ | |
4475 | as = strtoul(as_str, NULL, 10); | |
4476 | as_type = AS_SPECIFIED; | |
4477 | } | |
d62a17ae | 4478 | } |
4479 | ||
4480 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4481 | if (peer) { | |
28c6e247 | 4482 | if (as_str) |
e84c59af | 4483 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type); |
d62a17ae | 4484 | } else { |
e84c59af DA |
4485 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, as_type, |
4486 | NULL); | |
d62a17ae | 4487 | |
4488 | if (!peer) { | |
28c6e247 IR |
4489 | vty_out(vty, "%% BGP failed to create peer\n"); |
4490 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4491 | } |
4492 | ||
4493 | if (v6only) | |
527de3dc | 4494 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4495 | |
4496 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4497 | * this | |
4498 | * any unnumbered peer in order to not worry about run-time | |
4499 | * transitions | |
4500 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4501 | * address | |
4502 | * gets deleted later etc.) | |
4503 | */ | |
4504 | if (peer->ifp) | |
4505 | bgp_zebra_initiate_radv(bgp, peer); | |
4506 | } | |
4507 | ||
4508 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4509 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4510 | if (v6only) | |
527de3dc | 4511 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4512 | else |
527de3dc | 4513 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4514 | |
4515 | /* v6only flag changed. Reset bgp seesion */ | |
4516 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4517 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4518 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4519 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4520 | } else | |
4521 | bgp_session_reset(peer); | |
4522 | } | |
4523 | ||
9fb964de PM |
4524 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4525 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4526 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4527 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4528 | } |
d62a17ae | 4529 | |
4530 | if (peer_group_name) { | |
4531 | group = peer_group_lookup(bgp, peer_group_name); | |
4532 | if (!group) { | |
28c6e247 IR |
4533 | vty_out(vty, "%% Configure the peer-group first\n"); |
4534 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4535 | } |
4536 | ||
8395c1f8 | 4537 | ret = peer_group_bind(bgp, NULL, peer, group, &as); |
d62a17ae | 4538 | } |
4539 | ||
28c6e247 | 4540 | return bgp_vty_return(vty, ret); |
a80beece DS |
4541 | } |
4542 | ||
28c6e247 IR |
4543 | DEFUN (neighbor_interface_config, |
4544 | neighbor_interface_config_cmd, | |
4545 | "neighbor WORD interface [peer-group PGNAME]", | |
4546 | NEIGHBOR_STR | |
4547 | "Interface name or neighbor tag\n" | |
4548 | "Enable BGP on interface\n" | |
4549 | "Member of the peer-group\n" | |
4550 | "Peer-group name\n") | |
4c48cf63 | 4551 | { |
d62a17ae | 4552 | int idx_word = 1; |
4553 | int idx_peer_group_word = 4; | |
f4b8ec07 | 4554 | |
d62a17ae | 4555 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4556 | return peer_conf_interface_get( |
4557 | vty, argv[idx_word]->arg, 0, | |
4558 | argv[idx_peer_group_word]->arg, NULL); | |
4559 | else | |
4560 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, | |
4561 | NULL, NULL); | |
4c48cf63 DW |
4562 | } |
4563 | ||
28c6e247 IR |
4564 | DEFUN (neighbor_interface_config_v6only, |
4565 | neighbor_interface_config_v6only_cmd, | |
4566 | "neighbor WORD interface v6only [peer-group PGNAME]", | |
4567 | NEIGHBOR_STR | |
4568 | "Interface name or neighbor tag\n" | |
4569 | "Enable BGP on interface\n" | |
4570 | "Enable BGP with v6 link-local only\n" | |
4571 | "Member of the peer-group\n" | |
4572 | "Peer-group name\n") | |
4c48cf63 | 4573 | { |
d62a17ae | 4574 | int idx_word = 1; |
4575 | int idx_peer_group_word = 5; | |
31500417 | 4576 | |
d62a17ae | 4577 | if (argc > idx_peer_group_word) |
28c6e247 IR |
4578 | return peer_conf_interface_get( |
4579 | vty, argv[idx_word]->arg, 1, | |
4580 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4581 | |
28c6e247 | 4582 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, NULL); |
4c48cf63 DW |
4583 | } |
4584 | ||
a80beece | 4585 | |
28c6e247 IR |
4586 | DEFUN (neighbor_interface_config_remote_as, |
4587 | neighbor_interface_config_remote_as_cmd, | |
4588 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", | |
4589 | NEIGHBOR_STR | |
4590 | "Interface name or neighbor tag\n" | |
4591 | "Enable BGP on interface\n" | |
4592 | "Specify a BGP neighbor\n" | |
4593 | AS_STR | |
4594 | "Internal BGP peer\n" | |
4595 | "External BGP peer\n") | |
b3a39dc5 | 4596 | { |
d62a17ae | 4597 | int idx_word = 1; |
4598 | int idx_remote_as = 4; | |
28c6e247 IR |
4599 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 0, NULL, |
4600 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4601 | } |
4602 | ||
28c6e247 IR |
4603 | DEFUN (neighbor_interface_v6only_config_remote_as, |
4604 | neighbor_interface_v6only_config_remote_as_cmd, | |
4605 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", | |
4606 | NEIGHBOR_STR | |
4607 | "Interface name or neighbor tag\n" | |
4608 | "Enable BGP with v6 link-local only\n" | |
4609 | "Enable BGP on interface\n" | |
4610 | "Specify a BGP neighbor\n" | |
4611 | AS_STR | |
4612 | "Internal BGP peer\n" | |
4613 | "External BGP peer\n") | |
b3a39dc5 | 4614 | { |
d62a17ae | 4615 | int idx_word = 1; |
4616 | int idx_remote_as = 5; | |
28c6e247 IR |
4617 | return peer_conf_interface_get(vty, argv[idx_word]->arg, 1, NULL, |
4618 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4619 | } |
4620 | ||
28c6e247 IR |
4621 | DEFUN (neighbor_peer_group, |
4622 | neighbor_peer_group_cmd, | |
4623 | "neighbor WORD peer-group", | |
4624 | NEIGHBOR_STR | |
4625 | "Interface name or neighbor tag\n" | |
4626 | "Configure peer-group\n") | |
718e3744 | 4627 | { |
28c6e247 | 4628 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4629 | int idx_word = 1; |
28c6e247 IR |
4630 | struct peer *peer; |
4631 | struct peer_group *group; | |
718e3744 | 4632 | |
28c6e247 IR |
4633 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4634 | if (peer) { | |
4635 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4636 | return CMD_WARNING_CONFIG_FAILED; | |
4637 | } | |
718e3744 | 4638 | |
28c6e247 IR |
4639 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4640 | if (!group) { | |
4641 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4642 | return CMD_WARNING_CONFIG_FAILED; | |
4643 | } | |
718e3744 | 4644 | |
28c6e247 | 4645 | return CMD_SUCCESS; |
718e3744 | 4646 | } |
4647 | ||
1d80f243 IR |
4648 | DEFUN (no_neighbor, |
4649 | no_neighbor_cmd, | |
4650 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", | |
4651 | NO_STR | |
4652 | NEIGHBOR_STR | |
4653 | NEIGHBOR_ADDR_STR2 | |
4654 | "Specify a BGP neighbor\n" | |
4655 | AS_STR | |
4656 | "Internal BGP peer\n" | |
4657 | "External BGP peer\n") | |
718e3744 | 4658 | { |
28c6e247 | 4659 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4660 | int idx_peer = 2; |
28c6e247 | 4661 | int ret; |
d62a17ae | 4662 | union sockunion su; |
28c6e247 IR |
4663 | struct peer_group *group; |
4664 | struct peer *peer; | |
4665 | struct peer *other; | |
d62a17ae | 4666 | |
28c6e247 IR |
4667 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4668 | if (ret < 0) { | |
4669 | /* look up for neighbor by interface name config. */ | |
4670 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4671 | if (peer) { | |
4672 | /* Request zebra to terminate IPv6 RAs on this | |
4673 | * interface. */ | |
4674 | if (peer->ifp) | |
4675 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4676 | peer_notify_unconfig(peer); | |
4677 | peer_delete(peer); | |
4678 | return CMD_SUCCESS; | |
d62a17ae | 4679 | } |
28c6e247 IR |
4680 | |
4681 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); | |
4682 | if (group) { | |
4683 | peer_group_notify_unconfig(group); | |
4684 | peer_group_delete(group); | |
4e2786df | 4685 | } else { |
28c6e247 | 4686 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4687 | return CMD_WARNING_CONFIG_FAILED; |
4688 | } | |
28c6e247 IR |
4689 | } else { |
4690 | peer = peer_lookup(bgp, &su); | |
4691 | if (peer) { | |
4692 | if (peer_dynamic_neighbor(peer)) { | |
4693 | vty_out(vty, | |
4694 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4695 | return CMD_WARNING_CONFIG_FAILED; | |
4696 | } | |
d62a17ae | 4697 | |
28c6e247 | 4698 | other = peer->doppelganger; |
f4b8ec07 | 4699 | |
28c6e247 IR |
4700 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4701 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
f4b8ec07 | 4702 | |
28c6e247 IR |
4703 | peer_notify_unconfig(peer); |
4704 | peer_delete(peer); | |
4705 | if (other && other->status != Deleted) { | |
4706 | peer_notify_unconfig(other); | |
4707 | peer_delete(other); | |
4708 | } | |
4709 | } | |
4710 | } | |
4711 | ||
4712 | return CMD_SUCCESS; | |
a80beece DS |
4713 | } |
4714 | ||
28c6e247 IR |
4715 | DEFUN (no_neighbor_interface_config, |
4716 | no_neighbor_interface_config_cmd, | |
4717 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", | |
4718 | NO_STR | |
4719 | NEIGHBOR_STR | |
4720 | "Interface name\n" | |
4721 | "Configure BGP on interface\n" | |
4722 | "Enable BGP with v6 link-local only\n" | |
4723 | "Member of the peer-group\n" | |
4724 | "Peer-group name\n" | |
4725 | "Specify a BGP neighbor\n" | |
4726 | AS_STR | |
4727 | "Internal BGP peer\n" | |
4728 | "External BGP peer\n") | |
718e3744 | 4729 | { |
28c6e247 | 4730 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 4731 | int idx_word = 2; |
28c6e247 | 4732 | struct peer *peer; |
718e3744 | 4733 | |
28c6e247 IR |
4734 | /* look up for neighbor by interface name config. */ |
4735 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4736 | if (peer) { | |
4737 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4738 | if (peer->ifp) | |
4739 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4740 | peer_notify_unconfig(peer); | |
4741 | peer_delete(peer); | |
4742 | } else { | |
4743 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4744 | return CMD_WARNING_CONFIG_FAILED; | |
4745 | } | |
4746 | return CMD_SUCCESS; | |
718e3744 | 4747 | } |
4748 | ||
28c6e247 IR |
4749 | DEFUN (no_neighbor_peer_group, |
4750 | no_neighbor_peer_group_cmd, | |
4751 | "no neighbor WORD peer-group", | |
4752 | NO_STR | |
4753 | NEIGHBOR_STR | |
4754 | "Neighbor tag\n" | |
4755 | "Configure peer-group\n") | |
718e3744 | 4756 | { |
28c6e247 IR |
4757 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4758 | int idx_word = 2; | |
4759 | struct peer_group *group; | |
f4b8ec07 | 4760 | |
28c6e247 IR |
4761 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4762 | if (group) { | |
4763 | peer_group_notify_unconfig(group); | |
4764 | peer_group_delete(group); | |
f4b8ec07 | 4765 | } else { |
28c6e247 | 4766 | vty_out(vty, "%% Create the peer-group first\n"); |
d62a17ae | 4767 | return CMD_WARNING_CONFIG_FAILED; |
4768 | } | |
28c6e247 IR |
4769 | return CMD_SUCCESS; |
4770 | } | |
f4b8ec07 | 4771 | |
28c6e247 IR |
4772 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4773 | no_neighbor_interface_peer_group_remote_as_cmd, | |
4774 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", | |
4775 | NO_STR | |
4776 | NEIGHBOR_STR | |
4777 | "Interface name or neighbor tag\n" | |
4778 | "Specify a BGP neighbor\n" | |
4779 | AS_STR | |
4780 | "Internal BGP peer\n" | |
4781 | "External BGP peer\n") | |
4782 | { | |
4783 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4784 | int idx_word = 2; | |
4785 | struct peer_group *group; | |
4786 | struct peer *peer; | |
f4b8ec07 | 4787 | |
28c6e247 IR |
4788 | /* look up for neighbor by interface name config. */ |
4789 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4790 | if (peer) { | |
4791 | peer_as_change(peer, 0, AS_UNSPECIFIED); | |
4792 | return CMD_SUCCESS; | |
4793 | } | |
f4b8ec07 | 4794 | |
28c6e247 IR |
4795 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4796 | if (group) | |
4797 | peer_group_remote_as_delete(group); | |
4798 | else { | |
4799 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4800 | return CMD_WARNING_CONFIG_FAILED; | |
4801 | } | |
4802 | return CMD_SUCCESS; | |
718e3744 | 4803 | } |
6b0655a2 | 4804 | |
28c6e247 IR |
4805 | DEFUN (neighbor_local_as, |
4806 | neighbor_local_as_cmd, | |
4807 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", | |
4808 | NEIGHBOR_STR | |
4809 | NEIGHBOR_ADDR_STR2 | |
4810 | "Specify a local-as number\n" | |
4811 | "AS number used as local AS\n") | |
718e3744 | 4812 | { |
d62a17ae | 4813 | int idx_peer = 1; |
4814 | int idx_number = 3; | |
28c6e247 IR |
4815 | struct peer *peer; |
4816 | int ret; | |
4817 | as_t as; | |
718e3744 | 4818 | |
28c6e247 IR |
4819 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4820 | if (!peer) | |
d62a17ae | 4821 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4822 | |
28c6e247 IR |
4823 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4824 | ret = peer_local_as_set(peer, as, 0, 0); | |
4825 | return bgp_vty_return(vty, ret); | |
718e3744 | 4826 | } |
4827 | ||
28c6e247 IR |
4828 | DEFUN (neighbor_local_as_no_prepend, |
4829 | neighbor_local_as_no_prepend_cmd, | |
4830 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", | |
4831 | NEIGHBOR_STR | |
4832 | NEIGHBOR_ADDR_STR2 | |
4833 | "Specify a local-as number\n" | |
4834 | "AS number used as local AS\n" | |
4835 | "Do not prepend local-as to updates from ebgp peers\n") | |
718e3744 | 4836 | { |
d62a17ae | 4837 | int idx_peer = 1; |
4838 | int idx_number = 3; | |
28c6e247 IR |
4839 | struct peer *peer; |
4840 | int ret; | |
4841 | as_t as; | |
718e3744 | 4842 | |
28c6e247 IR |
4843 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4844 | if (!peer) | |
d62a17ae | 4845 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4846 | |
28c6e247 IR |
4847 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4848 | ret = peer_local_as_set(peer, as, 1, 0); | |
4849 | return bgp_vty_return(vty, ret); | |
718e3744 | 4850 | } |
4851 | ||
28c6e247 IR |
4852 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4853 | neighbor_local_as_no_prepend_replace_as_cmd, | |
4854 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", | |
4855 | NEIGHBOR_STR | |
4856 | NEIGHBOR_ADDR_STR2 | |
4857 | "Specify a local-as number\n" | |
4858 | "AS number used as local AS\n" | |
4859 | "Do not prepend local-as to updates from ebgp peers\n" | |
4860 | "Do not prepend local-as to updates from ibgp peers\n") | |
9d3f9705 | 4861 | { |
d62a17ae | 4862 | int idx_peer = 1; |
4863 | int idx_number = 3; | |
28c6e247 IR |
4864 | struct peer *peer; |
4865 | int ret; | |
4866 | as_t as; | |
9d3f9705 | 4867 | |
28c6e247 IR |
4868 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4869 | if (!peer) | |
d62a17ae | 4870 | return CMD_WARNING_CONFIG_FAILED; |
9d3f9705 | 4871 | |
28c6e247 IR |
4872 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4873 | ret = peer_local_as_set(peer, as, 1, 1); | |
4874 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4875 | } |
4876 | ||
28c6e247 IR |
4877 | DEFUN (no_neighbor_local_as, |
4878 | no_neighbor_local_as_cmd, | |
4879 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", | |
4880 | NO_STR | |
4881 | NEIGHBOR_STR | |
4882 | NEIGHBOR_ADDR_STR2 | |
4883 | "Specify a local-as number\n" | |
4884 | "AS number used as local AS\n" | |
4885 | "Do not prepend local-as to updates from ebgp peers\n" | |
4886 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4887 | { |
d62a17ae | 4888 | int idx_peer = 2; |
28c6e247 IR |
4889 | struct peer *peer; |
4890 | int ret; | |
718e3744 | 4891 | |
28c6e247 IR |
4892 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4893 | if (!peer) | |
d62a17ae | 4894 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4895 | |
28c6e247 IR |
4896 | ret = peer_local_as_unset(peer); |
4897 | return bgp_vty_return(vty, ret); | |
718e3744 | 4898 | } |
4899 | ||
718e3744 | 4900 | |
3f9c7369 DS |
4901 | DEFUN (neighbor_solo, |
4902 | neighbor_solo_cmd, | |
9ccf14f7 | 4903 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4904 | NEIGHBOR_STR |
4905 | NEIGHBOR_ADDR_STR2 | |
4906 | "Solo peer - part of its own update group\n") | |
4907 | { | |
d62a17ae | 4908 | int idx_peer = 1; |
4909 | struct peer *peer; | |
4910 | int ret; | |
3f9c7369 | 4911 | |
d62a17ae | 4912 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4913 | if (!peer) | |
4914 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4915 | |
d62a17ae | 4916 | ret = update_group_adjust_soloness(peer, 1); |
4917 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4918 | } |
4919 | ||
4920 | DEFUN (no_neighbor_solo, | |
4921 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4922 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4923 | NO_STR |
4924 | NEIGHBOR_STR | |
4925 | NEIGHBOR_ADDR_STR2 | |
4926 | "Solo peer - part of its own update group\n") | |
4927 | { | |
d62a17ae | 4928 | int idx_peer = 2; |
4929 | struct peer *peer; | |
4930 | int ret; | |
3f9c7369 | 4931 | |
d62a17ae | 4932 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4933 | if (!peer) | |
4934 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4935 | |
d62a17ae | 4936 | ret = update_group_adjust_soloness(peer, 0); |
4937 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4938 | } |
4939 | ||
28c6e247 IR |
4940 | DEFUN (neighbor_password, |
4941 | neighbor_password_cmd, | |
4942 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", | |
4943 | NEIGHBOR_STR | |
4944 | NEIGHBOR_ADDR_STR2 | |
4945 | "Set a password\n" | |
4946 | "The password\n") | |
0df7c91f | 4947 | { |
d62a17ae | 4948 | int idx_peer = 1; |
4949 | int idx_line = 3; | |
28c6e247 IR |
4950 | struct peer *peer; |
4951 | int ret; | |
0df7c91f | 4952 | |
28c6e247 IR |
4953 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4954 | if (!peer) | |
d62a17ae | 4955 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4956 | |
28c6e247 IR |
4957 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4958 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4959 | } |
4960 | ||
28c6e247 IR |
4961 | DEFUN (no_neighbor_password, |
4962 | no_neighbor_password_cmd, | |
4963 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", | |
4964 | NO_STR | |
4965 | NEIGHBOR_STR | |
4966 | NEIGHBOR_ADDR_STR2 | |
4967 | "Set a password\n" | |
4968 | "The password\n") | |
0df7c91f | 4969 | { |
d62a17ae | 4970 | int idx_peer = 2; |
28c6e247 IR |
4971 | struct peer *peer; |
4972 | int ret; | |
0df7c91f | 4973 | |
28c6e247 IR |
4974 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4975 | if (!peer) | |
d62a17ae | 4976 | return CMD_WARNING_CONFIG_FAILED; |
0df7c91f | 4977 | |
28c6e247 IR |
4978 | ret = peer_password_unset(peer); |
4979 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4980 | } |
6b0655a2 | 4981 | |
28c6e247 IR |
4982 | DEFUN (neighbor_activate, |
4983 | neighbor_activate_cmd, | |
4984 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4985 | NEIGHBOR_STR | |
4986 | NEIGHBOR_ADDR_STR2 | |
4987 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 4988 | { |
d62a17ae | 4989 | int idx_peer = 1; |
28c6e247 IR |
4990 | int ret; |
4991 | struct peer *peer; | |
56ceae84 | 4992 | |
28c6e247 IR |
4993 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4994 | if (!peer) | |
d62a17ae | 4995 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 4996 | |
28c6e247 IR |
4997 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4998 | return bgp_vty_return(vty, ret); | |
718e3744 | 4999 | } |
5000 | ||
d62a17ae | 5001 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
5002 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5003 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5004 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5005 | |
28c6e247 IR |
5006 | DEFUN (no_neighbor_activate, |
5007 | no_neighbor_activate_cmd, | |
5008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5009 | NO_STR | |
5010 | NEIGHBOR_STR | |
5011 | NEIGHBOR_ADDR_STR2 | |
5012 | "Enable the Address Family for this Neighbor\n") | |
718e3744 | 5013 | { |
d62a17ae | 5014 | int idx_peer = 2; |
28c6e247 IR |
5015 | int ret; |
5016 | struct peer *peer; | |
f4b8ec07 | 5017 | |
28c6e247 IR |
5018 | /* Lookup peer. */ |
5019 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5020 | if (!peer) | |
d62a17ae | 5021 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 5022 | |
28c6e247 IR |
5023 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
5024 | return bgp_vty_return(vty, ret); | |
718e3744 | 5025 | } |
6b0655a2 | 5026 | |
d62a17ae | 5027 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
5028 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
5029 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5030 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 5031 | |
28c6e247 IR |
5032 | DEFUN (neighbor_set_peer_group, |
5033 | neighbor_set_peer_group_cmd, | |
5034 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5035 | NEIGHBOR_STR | |
5036 | NEIGHBOR_ADDR_STR2 | |
5037 | "Member of the peer-group\n" | |
5038 | "Peer-group name\n") | |
718e3744 | 5039 | { |
28c6e247 | 5040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5041 | int idx_peer = 1; |
5042 | int idx_word = 3; | |
28c6e247 IR |
5043 | int ret; |
5044 | as_t as; | |
5045 | union sockunion su; | |
5046 | struct peer *peer; | |
5047 | struct peer_group *group; | |
5048 | ||
5049 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
5050 | if (ret < 0) { | |
5051 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
5052 | if (!peer) { | |
5053 | vty_out(vty, "%% Malformed address or name: %s\n", | |
5054 | argv[idx_peer]->arg); | |
5055 | return CMD_WARNING_CONFIG_FAILED; | |
5056 | } | |
5057 | } else { | |
5058 | if (peer_address_self_check(bgp, &su)) { | |
5059 | vty_out(vty, | |
5060 | "%% Can not configure the local system as neighbor\n"); | |
5061 | return CMD_WARNING_CONFIG_FAILED; | |
5062 | } | |
2a059a54 | 5063 | |
28c6e247 IR |
5064 | /* Disallow for dynamic neighbor. */ |
5065 | peer = peer_lookup(bgp, &su); | |
5066 | if (peer && peer_dynamic_neighbor(peer)) { | |
5067 | vty_out(vty, | |
5068 | "%% Operation not allowed on a dynamic neighbor\n"); | |
5069 | return CMD_WARNING_CONFIG_FAILED; | |
5070 | } | |
5071 | } | |
5072 | ||
5073 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
5074 | if (!group) { | |
5075 | vty_out(vty, "%% Configure the peer-group first\n"); | |
d62a17ae | 5076 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 | 5077 | } |
d62a17ae | 5078 | |
28c6e247 | 5079 | ret = peer_group_bind(bgp, &su, peer, group, &as); |
2a059a54 | 5080 | |
28c6e247 | 5081 | return bgp_vty_return(vty, ret); |
d62a17ae | 5082 | } |
5083 | ||
5084 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 5085 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5086 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5087 | "Member of the peer-group\n" | |
5088 | "Peer-group name\n") | |
596c17ba | 5089 | |
28c6e247 IR |
5090 | DEFUN (no_neighbor_set_peer_group, |
5091 | no_neighbor_set_peer_group_cmd, | |
5092 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", | |
5093 | NO_STR | |
5094 | NEIGHBOR_STR | |
5095 | NEIGHBOR_ADDR_STR2 | |
5096 | "Member of the peer-group\n" | |
5097 | "Peer-group name\n") | |
718e3744 | 5098 | { |
28c6e247 | 5099 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 5100 | int idx_peer = 2; |
28c6e247 IR |
5101 | int idx_word = 4; |
5102 | int ret; | |
5103 | struct peer *peer; | |
5104 | struct peer_group *group; | |
d62a17ae | 5105 | |
28c6e247 IR |
5106 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); |
5107 | if (!peer) | |
d62a17ae | 5108 | return CMD_WARNING_CONFIG_FAILED; |
b3a3290e | 5109 | |
28c6e247 IR |
5110 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
5111 | if (!group) { | |
5112 | vty_out(vty, "%% Configure the peer-group first\n"); | |
5113 | return CMD_WARNING_CONFIG_FAILED; | |
5114 | } | |
718e3744 | 5115 | |
28c6e247 IR |
5116 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
5117 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
5118 | ||
5119 | peer_notify_unconfig(peer); | |
5120 | ret = peer_delete(peer); | |
5121 | ||
5122 | return bgp_vty_return(vty, ret); | |
718e3744 | 5123 | } |
6b0655a2 | 5124 | |
d62a17ae | 5125 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
71cc0c88 | 5126 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 5127 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
5128 | "Member of the peer-group\n" | |
5129 | "Peer-group name\n") | |
596c17ba | 5130 | |
d62a17ae | 5131 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5132 | uint32_t flag, int set) |
718e3744 | 5133 | { |
d62a17ae | 5134 | int ret; |
5135 | struct peer *peer; | |
718e3744 | 5136 | |
d62a17ae | 5137 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5138 | if (!peer) | |
5139 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5140 | |
7ebe625c QY |
5141 | /* |
5142 | * If 'neighbor <interface>', then this is for directly connected peers, | |
5143 | * we should not accept disable-connected-check. | |
5144 | */ | |
5145 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
5146 | vty_out(vty, | |
3efd0893 | 5147 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
5148 | ip_str); |
5149 | return CMD_WARNING_CONFIG_FAILED; | |
5150 | } | |
5151 | ||
d62a17ae | 5152 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
5153 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 5154 | |
d62a17ae | 5155 | if (set) |
5156 | ret = peer_flag_set(peer, flag); | |
5157 | else | |
5158 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 5159 | |
d62a17ae | 5160 | return bgp_vty_return(vty, ret); |
718e3744 | 5161 | } |
5162 | ||
47cbc09b | 5163 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 5164 | { |
d62a17ae | 5165 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 5166 | } |
5167 | ||
d62a17ae | 5168 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 5169 | uint32_t flag) |
718e3744 | 5170 | { |
d62a17ae | 5171 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 5172 | } |
5173 | ||
5174 | /* neighbor passive. */ | |
28c6e247 IR |
5175 | DEFUN (neighbor_passive, |
5176 | neighbor_passive_cmd, | |
5177 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5178 | NEIGHBOR_STR | |
5179 | NEIGHBOR_ADDR_STR2 | |
5180 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5181 | { |
d62a17ae | 5182 | int idx_peer = 1; |
28c6e247 | 5183 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5184 | } |
5185 | ||
28c6e247 IR |
5186 | DEFUN (no_neighbor_passive, |
5187 | no_neighbor_passive_cmd, | |
5188 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", | |
5189 | NO_STR | |
5190 | NEIGHBOR_STR | |
5191 | NEIGHBOR_ADDR_STR2 | |
5192 | "Don't send open messages to this neighbor\n") | |
718e3744 | 5193 | { |
d62a17ae | 5194 | int idx_peer = 2; |
28c6e247 | 5195 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); |
718e3744 | 5196 | } |
6b0655a2 | 5197 | |
718e3744 | 5198 | /* neighbor shutdown. */ |
28c6e247 IR |
5199 | DEFUN (neighbor_shutdown_msg, |
5200 | neighbor_shutdown_msg_cmd, | |
5201 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5202 | NEIGHBOR_STR | |
5203 | NEIGHBOR_ADDR_STR2 | |
5204 | "Administratively shut down this neighbor\n" | |
5205 | "Add a shutdown message (RFC 8203)\n" | |
5206 | "Shutdown message\n") | |
718e3744 | 5207 | { |
d62a17ae | 5208 | int idx_peer = 1; |
73d70fa6 | 5209 | |
d62a17ae | 5210 | if (argc >= 5) { |
28c6e247 IR |
5211 | struct peer *peer = |
5212 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
d62a17ae | 5213 | char *message; |
73d70fa6 | 5214 | |
28c6e247 IR |
5215 | if (!peer) |
5216 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5217 | message = argv_concat(argv, argc, 4); |
28c6e247 IR |
5218 | peer_tx_shutdown_message_set(peer, message); |
5219 | XFREE(MTYPE_TMP, message); | |
d62a17ae | 5220 | } |
73d70fa6 | 5221 | |
28c6e247 | 5222 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 5223 | } |
5224 | ||
1d80f243 | 5225 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
d62a17ae | 5226 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5227 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5228 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5229 | |
28c6e247 IR |
5230 | DEFUN (no_neighbor_shutdown_msg, |
5231 | no_neighbor_shutdown_msg_cmd, | |
5232 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
5233 | NO_STR | |
5234 | NEIGHBOR_STR | |
5235 | NEIGHBOR_ADDR_STR2 | |
5236 | "Administratively shut down this neighbor\n" | |
5237 | "Remove a shutdown message (RFC 8203)\n" | |
5238 | "Shutdown message\n") | |
718e3744 | 5239 | { |
d62a17ae | 5240 | int idx_peer = 2; |
73d70fa6 | 5241 | |
28c6e247 IR |
5242 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5243 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 5244 | } |
6b0655a2 | 5245 | |
1d80f243 | 5246 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
d62a17ae | 5247 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
5248 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5249 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 5250 | |
8336c896 DA |
5251 | DEFUN(neighbor_shutdown_rtt, |
5252 | neighbor_shutdown_rtt_cmd, | |
5253 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
5254 | NEIGHBOR_STR | |
5255 | NEIGHBOR_ADDR_STR2 | |
5256 | "Administratively shut down this neighbor\n" | |
5257 | "Shutdown if round-trip-time is higher than expected\n" | |
5258 | "Round-trip-time in milliseconds\n" | |
5259 | "Specify the number of keepalives before shutdown\n" | |
5260 | "The number of keepalives with higher RTT to shutdown\n") | |
5261 | { | |
5262 | int idx_peer = 1; | |
5263 | int idx_rtt = 4; | |
5264 | int idx_count = 0; | |
5265 | struct peer *peer; | |
5266 | ||
5267 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5268 | ||
5269 | if (!peer) | |
5270 | return CMD_WARNING_CONFIG_FAILED; | |
5271 | ||
5272 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
5273 | ||
5274 | if (argv_find(argv, argc, "count", &idx_count)) | |
5275 | peer->rtt_keepalive_conf = | |
5276 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
5277 | ||
5278 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5279 | PEER_FLAG_RTT_SHUTDOWN); | |
5280 | } | |
5281 | ||
5282 | DEFUN(no_neighbor_shutdown_rtt, | |
5283 | no_neighbor_shutdown_rtt_cmd, | |
5284 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
5285 | NO_STR | |
5286 | NEIGHBOR_STR | |
5287 | NEIGHBOR_ADDR_STR2 | |
5288 | "Administratively shut down this neighbor\n" | |
5289 | "Shutdown if round-trip-time is higher than expected\n" | |
5290 | "Round-trip-time in milliseconds\n" | |
5291 | "Specify the number of keepalives before shutdown\n" | |
5292 | "The number of keepalives with higher RTT to shutdown\n") | |
5293 | { | |
5294 | int idx_peer = 2; | |
5295 | struct peer *peer; | |
5296 | ||
5297 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5298 | ||
5299 | if (!peer) | |
5300 | return CMD_WARNING_CONFIG_FAILED; | |
5301 | ||
5302 | peer->rtt_expected = 0; | |
5303 | peer->rtt_keepalive_conf = 1; | |
5304 | ||
5305 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5306 | PEER_FLAG_RTT_SHUTDOWN); | |
5307 | } | |
5308 | ||
718e3744 | 5309 | /* neighbor capability dynamic. */ |
28c6e247 IR |
5310 | DEFUN (neighbor_capability_dynamic, |
5311 | neighbor_capability_dynamic_cmd, | |
5312 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5313 | NEIGHBOR_STR | |
5314 | NEIGHBOR_ADDR_STR2 | |
5315 | "Advertise capability to the peer\n" | |
5316 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5317 | { |
d62a17ae | 5318 | int idx_peer = 1; |
28c6e247 IR |
5319 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5320 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5321 | } |
5322 | ||
28c6e247 IR |
5323 | DEFUN (no_neighbor_capability_dynamic, |
5324 | no_neighbor_capability_dynamic_cmd, | |
5325 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", | |
5326 | NO_STR | |
5327 | NEIGHBOR_STR | |
5328 | NEIGHBOR_ADDR_STR2 | |
5329 | "Advertise capability to the peer\n" | |
5330 | "Advertise dynamic capability to this neighbor\n") | |
718e3744 | 5331 | { |
d62a17ae | 5332 | int idx_peer = 2; |
28c6e247 IR |
5333 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5334 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 5335 | } |
6b0655a2 | 5336 | |
718e3744 | 5337 | /* neighbor dont-capability-negotiate */ |
5338 | DEFUN (neighbor_dont_capability_negotiate, | |
5339 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5340 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5341 | NEIGHBOR_STR |
5342 | NEIGHBOR_ADDR_STR2 | |
5343 | "Do not perform capability negotiation\n") | |
5344 | { | |
d62a17ae | 5345 | int idx_peer = 1; |
5346 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5347 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5348 | } |
5349 | ||
5350 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5351 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5352 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5353 | NO_STR |
5354 | NEIGHBOR_STR | |
5355 | NEIGHBOR_ADDR_STR2 | |
5356 | "Do not perform capability negotiation\n") | |
5357 | { | |
28c6e247 IR |
5358 | int idx_peer = 2; |
5359 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5360 | PEER_FLAG_DONT_CAPABILITY); | |
f4b8ec07 CS |
5361 | } |
5362 | ||
28c6e247 IR |
5363 | /* neighbor capability extended next hop encoding */ |
5364 | DEFUN (neighbor_capability_enhe, | |
5365 | neighbor_capability_enhe_cmd, | |
5366 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5367 | NEIGHBOR_STR | |
5368 | NEIGHBOR_ADDR_STR2 | |
5369 | "Advertise capability to the peer\n" | |
5370 | "Advertise extended next-hop capability to the peer\n") | |
f4b8ec07 | 5371 | { |
28c6e247 | 5372 | int idx_peer = 1; |
c4786405 DS |
5373 | struct peer *peer; |
5374 | ||
5375 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5376 | if (peer && peer->conf_if) | |
5377 | return CMD_SUCCESS; | |
5378 | ||
28c6e247 IR |
5379 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
5380 | PEER_FLAG_CAPABILITY_ENHE); | |
5381 | } | |
f4b8ec07 | 5382 | |
28c6e247 IR |
5383 | DEFUN (no_neighbor_capability_enhe, |
5384 | no_neighbor_capability_enhe_cmd, | |
5385 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", | |
5386 | NO_STR | |
5387 | NEIGHBOR_STR | |
5388 | NEIGHBOR_ADDR_STR2 | |
5389 | "Advertise capability to the peer\n" | |
5390 | "Advertise extended next-hop capability to the peer\n") | |
5391 | { | |
5392 | int idx_peer = 2; | |
c4786405 DS |
5393 | struct peer *peer; |
5394 | ||
5395 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5396 | if (peer && peer->conf_if) { | |
5397 | vty_out(vty, | |
5398 | "Peer %s cannot have capability extended-nexthop turned off\n", | |
5399 | argv[idx_peer]->arg); | |
5400 | return CMD_WARNING_CONFIG_FAILED; | |
5401 | } | |
5402 | ||
28c6e247 IR |
5403 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
5404 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5405 | } |
5406 | ||
d62a17ae | 5407 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5408 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5409 | int set) |
718e3744 | 5410 | { |
d62a17ae | 5411 | int ret; |
5412 | struct peer *peer; | |
718e3744 | 5413 | |
d62a17ae | 5414 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5415 | if (!peer) | |
5416 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5417 | |
d62a17ae | 5418 | if (set) |
5419 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5420 | else | |
5421 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5422 | |
d62a17ae | 5423 | return bgp_vty_return(vty, ret); |
718e3744 | 5424 | } |
5425 | ||
d62a17ae | 5426 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5427 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5428 | { |
d62a17ae | 5429 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5430 | } |
5431 | ||
d62a17ae | 5432 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5433 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5434 | { |
d62a17ae | 5435 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5436 | } |
6b0655a2 | 5437 | |
718e3744 | 5438 | /* neighbor capability orf prefix-list. */ |
5439 | DEFUN (neighbor_capability_orf_prefix, | |
5440 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5441 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5442 | NEIGHBOR_STR |
5443 | NEIGHBOR_ADDR_STR2 | |
5444 | "Advertise capability to the peer\n" | |
5445 | "Advertise ORF capability to the peer\n" | |
5446 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5447 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5448 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5449 | "Capability to SEND the ORF to this neighbor\n") | |
5450 | { | |
d62a17ae | 5451 | int idx_send_recv = 5; |
db45f64d DS |
5452 | char *peer_str = argv[1]->arg; |
5453 | struct peer *peer; | |
5454 | afi_t afi = bgp_node_afi(vty); | |
5455 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5456 | |
db45f64d DS |
5457 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5458 | if (!peer) | |
d62a17ae | 5459 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5460 | |
db45f64d DS |
5461 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5462 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5463 | PEER_FLAG_ORF_PREFIX_SM); | |
5464 | ||
5465 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5466 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5467 | PEER_FLAG_ORF_PREFIX_RM); | |
5468 | ||
5469 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5470 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5471 | PEER_FLAG_ORF_PREFIX_SM) | |
5472 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5473 | PEER_FLAG_ORF_PREFIX_RM); | |
5474 | ||
5475 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5476 | } |
5477 | ||
5478 | ALIAS_HIDDEN( | |
5479 | neighbor_capability_orf_prefix, | |
5480 | neighbor_capability_orf_prefix_hidden_cmd, | |
5481 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5482 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5483 | "Advertise capability to the peer\n" | |
5484 | "Advertise ORF capability to the peer\n" | |
5485 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5486 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5487 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5488 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5489 | |
718e3744 | 5490 | DEFUN (no_neighbor_capability_orf_prefix, |
5491 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5492 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5493 | NO_STR |
5494 | NEIGHBOR_STR | |
5495 | NEIGHBOR_ADDR_STR2 | |
5496 | "Advertise capability to the peer\n" | |
5497 | "Advertise ORF capability to the peer\n" | |
5498 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5499 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5500 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5501 | "Capability to SEND the ORF to this neighbor\n") | |
5502 | { | |
d62a17ae | 5503 | int idx_send_recv = 6; |
db45f64d DS |
5504 | char *peer_str = argv[2]->arg; |
5505 | struct peer *peer; | |
5506 | afi_t afi = bgp_node_afi(vty); | |
5507 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5508 | |
db45f64d DS |
5509 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5510 | if (!peer) | |
d62a17ae | 5511 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5512 | |
db45f64d DS |
5513 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5514 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5515 | PEER_FLAG_ORF_PREFIX_SM); | |
5516 | ||
5517 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5518 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5519 | PEER_FLAG_ORF_PREFIX_RM); | |
5520 | ||
5521 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5522 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5523 | PEER_FLAG_ORF_PREFIX_SM) | |
5524 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5525 | PEER_FLAG_ORF_PREFIX_RM); | |
5526 | ||
5527 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5528 | } |
5529 | ||
5530 | ALIAS_HIDDEN( | |
5531 | no_neighbor_capability_orf_prefix, | |
5532 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5533 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5534 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5535 | "Advertise capability to the peer\n" | |
5536 | "Advertise ORF capability to the peer\n" | |
5537 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5538 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5539 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5540 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5541 | |
718e3744 | 5542 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5543 | DEFUN (neighbor_nexthop_self, |
5544 | neighbor_nexthop_self_cmd, | |
5545 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5546 | NEIGHBOR_STR | |
5547 | NEIGHBOR_ADDR_STR2 | |
5548 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5549 | { |
d62a17ae | 5550 | int idx_peer = 1; |
28c6e247 IR |
5551 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5552 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5553 | } |
9e7a53c1 | 5554 | |
d62a17ae | 5555 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5556 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5557 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5558 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5559 | |
f4b8ec07 | 5560 | /* neighbor next-hop-self. */ |
28c6e247 IR |
5561 | DEFUN (neighbor_nexthop_self_force, |
5562 | neighbor_nexthop_self_force_cmd, | |
5563 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5564 | NEIGHBOR_STR | |
5565 | NEIGHBOR_ADDR_STR2 | |
5566 | "Disable the next hop calculation for this neighbor\n" | |
5567 | "Set the next hop to self for reflected routes\n") | |
f4b8ec07 CS |
5568 | { |
5569 | int idx_peer = 1; | |
28c6e247 IR |
5570 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5571 | bgp_node_safi(vty), | |
5572 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5573 | } |
5574 | ||
d62a17ae | 5575 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5576 | neighbor_nexthop_self_force_hidden_cmd, | |
5577 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5578 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5579 | "Disable the next hop calculation for this neighbor\n" | |
5580 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5581 | |
1bc4e531 DA |
5582 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5583 | neighbor_nexthop_self_all_hidden_cmd, | |
5584 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5585 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5586 | "Disable the next hop calculation for this neighbor\n" | |
5587 | "Set the next hop to self for reflected routes\n") | |
5588 | ||
28c6e247 IR |
5589 | DEFUN (no_neighbor_nexthop_self, |
5590 | no_neighbor_nexthop_self_cmd, | |
5591 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5592 | NO_STR | |
5593 | NEIGHBOR_STR | |
5594 | NEIGHBOR_ADDR_STR2 | |
5595 | "Disable the next hop calculation for this neighbor\n") | |
718e3744 | 5596 | { |
d62a17ae | 5597 | int idx_peer = 2; |
28c6e247 IR |
5598 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5599 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5600 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5601 | } |
6b0655a2 | 5602 | |
d62a17ae | 5603 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5604 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5605 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5606 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5607 | |
28c6e247 IR |
5608 | DEFUN (no_neighbor_nexthop_self_force, |
5609 | no_neighbor_nexthop_self_force_cmd, | |
5610 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5611 | NO_STR | |
5612 | NEIGHBOR_STR | |
5613 | NEIGHBOR_ADDR_STR2 | |
5614 | "Disable the next hop calculation for this neighbor\n" | |
5615 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5616 | { |
d62a17ae | 5617 | int idx_peer = 2; |
28c6e247 IR |
5618 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5619 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5620 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5621 | } |
a538debe | 5622 | |
d62a17ae | 5623 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5624 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5625 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5626 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5627 | "Disable the next hop calculation for this neighbor\n" | |
5628 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5629 | |
1bc4e531 DA |
5630 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5631 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5632 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5633 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5634 | "Disable the next hop calculation for this neighbor\n" | |
5635 | "Set the next hop to self for reflected routes\n") | |
5636 | ||
c7122e14 | 5637 | /* neighbor as-override */ |
28c6e247 IR |
5638 | DEFUN (neighbor_as_override, |
5639 | neighbor_as_override_cmd, | |
5640 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5641 | NEIGHBOR_STR | |
5642 | NEIGHBOR_ADDR_STR2 | |
5643 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5644 | { |
d62a17ae | 5645 | int idx_peer = 1; |
28c6e247 IR |
5646 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5647 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5648 | } |
5649 | ||
d62a17ae | 5650 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5651 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5652 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5653 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5654 | |
28c6e247 IR |
5655 | DEFUN (no_neighbor_as_override, |
5656 | no_neighbor_as_override_cmd, | |
5657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5658 | NO_STR | |
5659 | NEIGHBOR_STR | |
5660 | NEIGHBOR_ADDR_STR2 | |
5661 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
c7122e14 | 5662 | { |
d62a17ae | 5663 | int idx_peer = 2; |
28c6e247 IR |
5664 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5665 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5666 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5667 | } |
5668 | ||
d62a17ae | 5669 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5670 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5671 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5672 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5673 | |
718e3744 | 5674 | /* neighbor remove-private-AS. */ |
28c6e247 IR |
5675 | DEFUN (neighbor_remove_private_as, |
5676 | neighbor_remove_private_as_cmd, | |
5677 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5678 | NEIGHBOR_STR | |
5679 | NEIGHBOR_ADDR_STR2 | |
5680 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5681 | { |
d62a17ae | 5682 | int idx_peer = 1; |
28c6e247 IR |
5683 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5684 | bgp_node_safi(vty), | |
5685 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5686 | } |
5687 | ||
d62a17ae | 5688 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5689 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5690 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5691 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5692 | |
28c6e247 IR |
5693 | DEFUN (neighbor_remove_private_as_all, |
5694 | neighbor_remove_private_as_all_cmd, | |
5695 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5696 | NEIGHBOR_STR | |
5697 | NEIGHBOR_ADDR_STR2 | |
5698 | "Remove private ASNs in outbound updates\n" | |
5699 | "Apply to all AS numbers\n") | |
5000f21c | 5700 | { |
d62a17ae | 5701 | int idx_peer = 1; |
28c6e247 IR |
5702 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5703 | bgp_node_safi(vty), | |
5704 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5705 | } |
5706 | ||
d62a17ae | 5707 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5708 | neighbor_remove_private_as_all_hidden_cmd, | |
5709 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5710 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5711 | "Remove private ASNs in outbound updates\n" | |
5712 | "Apply to all AS numbers") | |
596c17ba | 5713 | |
28c6e247 IR |
5714 | DEFUN (neighbor_remove_private_as_replace_as, |
5715 | neighbor_remove_private_as_replace_as_cmd, | |
5716 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5717 | NEIGHBOR_STR | |
5718 | NEIGHBOR_ADDR_STR2 | |
5719 | "Remove private ASNs in outbound updates\n" | |
5720 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5721 | { |
d62a17ae | 5722 | int idx_peer = 1; |
28c6e247 IR |
5723 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5724 | bgp_node_safi(vty), | |
5725 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5726 | } |
5727 | ||
d62a17ae | 5728 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5729 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5730 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5731 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5732 | "Remove private ASNs in outbound updates\n" | |
5733 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5734 | |
28c6e247 IR |
5735 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5736 | neighbor_remove_private_as_all_replace_as_cmd, | |
5737 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5738 | NEIGHBOR_STR | |
5739 | NEIGHBOR_ADDR_STR2 | |
5740 | "Remove private ASNs in outbound updates\n" | |
5741 | "Apply to all AS numbers\n" | |
5742 | "Replace private ASNs with our ASN in outbound updates\n") | |
5000f21c | 5743 | { |
d62a17ae | 5744 | int idx_peer = 1; |
28c6e247 IR |
5745 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5746 | bgp_node_safi(vty), | |
5747 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5748 | } |
5749 | ||
d62a17ae | 5750 | ALIAS_HIDDEN( |
5751 | neighbor_remove_private_as_all_replace_as, | |
5752 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5753 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5754 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5755 | "Remove private ASNs in outbound updates\n" | |
5756 | "Apply to all AS numbers\n" | |
5757 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5758 | |
28c6e247 IR |
5759 | DEFUN (no_neighbor_remove_private_as, |
5760 | no_neighbor_remove_private_as_cmd, | |
5761 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5762 | NO_STR | |
5763 | NEIGHBOR_STR | |
5764 | NEIGHBOR_ADDR_STR2 | |
5765 | "Remove private ASNs in outbound updates\n") | |
718e3744 | 5766 | { |
d62a17ae | 5767 | int idx_peer = 2; |
28c6e247 IR |
5768 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5769 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5770 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5771 | } |
6b0655a2 | 5772 | |
d62a17ae | 5773 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5774 | no_neighbor_remove_private_as_hidden_cmd, | |
5775 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5776 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5777 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5778 | |
28c6e247 IR |
5779 | DEFUN (no_neighbor_remove_private_as_all, |
5780 | no_neighbor_remove_private_as_all_cmd, | |
5781 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5782 | NO_STR | |
5783 | NEIGHBOR_STR | |
5784 | NEIGHBOR_ADDR_STR2 | |
5785 | "Remove private ASNs in outbound updates\n" | |
5786 | "Apply to all AS numbers\n") | |
88b8ed8d | 5787 | { |
d62a17ae | 5788 | int idx_peer = 2; |
28c6e247 IR |
5789 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5790 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5791 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5792 | } |
5000f21c | 5793 | |
d62a17ae | 5794 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5795 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5796 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5797 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5798 | "Remove private ASNs in outbound updates\n" | |
5799 | "Apply to all AS numbers\n") | |
596c17ba | 5800 | |
28c6e247 IR |
5801 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5802 | no_neighbor_remove_private_as_replace_as_cmd, | |
5803 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5804 | NO_STR | |
5805 | NEIGHBOR_STR | |
5806 | NEIGHBOR_ADDR_STR2 | |
5807 | "Remove private ASNs in outbound updates\n" | |
5808 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5809 | { |
d62a17ae | 5810 | int idx_peer = 2; |
28c6e247 IR |
5811 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5812 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5813 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5814 | } |
5000f21c | 5815 | |
d62a17ae | 5816 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5817 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5818 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5819 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5820 | "Remove private ASNs in outbound updates\n" | |
5821 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5822 | |
28c6e247 IR |
5823 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5824 | no_neighbor_remove_private_as_all_replace_as_cmd, | |
5825 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5826 | NO_STR | |
5827 | NEIGHBOR_STR | |
5828 | NEIGHBOR_ADDR_STR2 | |
5829 | "Remove private ASNs in outbound updates\n" | |
5830 | "Apply to all AS numbers\n" | |
5831 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5832 | { |
d62a17ae | 5833 | int idx_peer = 2; |
28c6e247 IR |
5834 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5835 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5836 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5837 | } |
5000f21c | 5838 | |
d62a17ae | 5839 | ALIAS_HIDDEN( |
5840 | no_neighbor_remove_private_as_all_replace_as, | |
5841 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5842 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5843 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5844 | "Remove private ASNs in outbound updates\n" | |
5845 | "Apply to all AS numbers\n" | |
5846 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5847 | |
5000f21c | 5848 | |
718e3744 | 5849 | /* neighbor send-community. */ |
28c6e247 IR |
5850 | DEFUN (neighbor_send_community, |
5851 | neighbor_send_community_cmd, | |
5852 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5853 | NEIGHBOR_STR | |
5854 | NEIGHBOR_ADDR_STR2 | |
5855 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5856 | { |
d62a17ae | 5857 | int idx_peer = 1; |
27c05d4d | 5858 | |
f63d4054 IR |
5859 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5860 | bgp_node_safi(vty), | |
5861 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5862 | } |
5863 | ||
d62a17ae | 5864 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5865 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5866 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5867 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5868 | |
28c6e247 IR |
5869 | DEFUN (no_neighbor_send_community, |
5870 | no_neighbor_send_community_cmd, | |
5871 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5872 | NO_STR | |
5873 | NEIGHBOR_STR | |
5874 | NEIGHBOR_ADDR_STR2 | |
5875 | "Send Community attribute to this neighbor\n") | |
718e3744 | 5876 | { |
d62a17ae | 5877 | int idx_peer = 2; |
27c05d4d | 5878 | |
f63d4054 IR |
5879 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5880 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5881 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5882 | } |
6b0655a2 | 5883 | |
d62a17ae | 5884 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5885 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5886 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5887 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5888 | |
718e3744 | 5889 | /* neighbor send-community extended. */ |
28c6e247 IR |
5890 | DEFUN (neighbor_send_community_type, |
5891 | neighbor_send_community_type_cmd, | |
5892 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5893 | NEIGHBOR_STR | |
5894 | NEIGHBOR_ADDR_STR2 | |
5895 | "Send Community attribute to this neighbor\n" | |
5896 | "Send Standard and Extended Community attributes\n" | |
5897 | "Send Standard, Large and Extended Community attributes\n" | |
5898 | "Send Extended Community attributes\n" | |
5899 | "Send Standard Community attributes\n" | |
5900 | "Send Large Community attributes\n") | |
718e3744 | 5901 | { |
27c05d4d | 5902 | const char *type = argv[argc - 1]->text; |
db45f64d | 5903 | char *peer_str = argv[1]->arg; |
28c6e247 | 5904 | struct peer *peer; |
db45f64d | 5905 | afi_t afi = bgp_node_afi(vty); |
28c6e247 | 5906 | safi_t safi = bgp_node_safi(vty); |
f4b8ec07 | 5907 | |
28c6e247 IR |
5908 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5909 | if (!peer) | |
5910 | return CMD_WARNING_CONFIG_FAILED; | |
f4b8ec07 | 5911 | |
28c6e247 IR |
5912 | if (strmatch(type, "standard")) |
5913 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5914 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5915 | |
28c6e247 IR |
5916 | if (strmatch(type, "extended")) |
5917 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5918 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5919 | |
28c6e247 IR |
5920 | if (strmatch(type, "large")) |
5921 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5922 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 | 5923 | |
28c6e247 IR |
5924 | if (strmatch(type, "both")) { |
5925 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5926 | PEER_FLAG_SEND_COMMUNITY) | |
5927 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5928 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5929 | } |
28c6e247 IR |
5930 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, |
5931 | PEER_FLAG_SEND_COMMUNITY) | |
5932 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5933 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5934 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5935 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5936 | } |
5937 | ||
5938 | ALIAS_HIDDEN( | |
5939 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5940 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5941 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5942 | "Send Community attribute to this neighbor\n" | |
5943 | "Send Standard and Extended Community attributes\n" | |
5944 | "Send Standard, Large and Extended Community attributes\n" | |
5945 | "Send Extended Community attributes\n" | |
5946 | "Send Standard Community attributes\n" | |
5947 | "Send Large Community attributes\n") | |
596c17ba | 5948 | |
28c6e247 IR |
5949 | DEFUN (no_neighbor_send_community_type, |
5950 | no_neighbor_send_community_type_cmd, | |
5951 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5952 | NO_STR | |
5953 | NEIGHBOR_STR | |
5954 | NEIGHBOR_ADDR_STR2 | |
5955 | "Send Community attribute to this neighbor\n" | |
5956 | "Send Standard and Extended Community attributes\n" | |
5957 | "Send Standard, Large and Extended Community attributes\n" | |
5958 | "Send Extended Community attributes\n" | |
5959 | "Send Standard Community attributes\n" | |
5960 | "Send Large Community attributes\n") | |
718e3744 | 5961 | { |
d62a17ae | 5962 | const char *type = argv[argc - 1]->text; |
db45f64d | 5963 | char *peer_str = argv[2]->arg; |
28c6e247 | 5964 | struct peer *peer; |
db45f64d DS |
5965 | afi_t afi = bgp_node_afi(vty); |
5966 | safi_t safi = bgp_node_safi(vty); | |
5967 | ||
28c6e247 IR |
5968 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5969 | if (!peer) | |
f4b8ec07 CS |
5970 | return CMD_WARNING_CONFIG_FAILED; |
5971 | ||
28c6e247 IR |
5972 | if (strmatch(type, "standard")) |
5973 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5974 | PEER_FLAG_SEND_COMMUNITY); | |
f4b8ec07 | 5975 | |
28c6e247 IR |
5976 | if (strmatch(type, "extended")) |
5977 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5978 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
f4b8ec07 | 5979 | |
28c6e247 IR |
5980 | if (strmatch(type, "large")) |
5981 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5982 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
f4b8ec07 CS |
5983 | |
5984 | if (strmatch(type, "both")) { | |
db45f64d | 5985 | |
28c6e247 IR |
5986 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5987 | PEER_FLAG_SEND_COMMUNITY) | |
5988 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5989 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5990 | } |
5991 | ||
28c6e247 IR |
5992 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5993 | PEER_FLAG_SEND_COMMUNITY) | |
5994 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5995 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5996 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5997 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5998 | } |
5999 | ||
6000 | ALIAS_HIDDEN( | |
6001 | no_neighbor_send_community_type, | |
6002 | no_neighbor_send_community_type_hidden_cmd, | |
6003 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
6004 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6005 | "Send Community attribute to this neighbor\n" | |
6006 | "Send Standard and Extended Community attributes\n" | |
6007 | "Send Standard, Large and Extended Community attributes\n" | |
6008 | "Send Extended Community attributes\n" | |
6009 | "Send Standard Community attributes\n" | |
6010 | "Send Large Community attributes\n") | |
596c17ba | 6011 | |
718e3744 | 6012 | /* neighbor soft-reconfig. */ |
28c6e247 IR |
6013 | DEFUN (neighbor_soft_reconfiguration, |
6014 | neighbor_soft_reconfiguration_cmd, | |
6015 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6016 | NEIGHBOR_STR | |
6017 | NEIGHBOR_ADDR_STR2 | |
6018 | "Per neighbor soft reconfiguration\n" | |
6019 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6020 | { |
d62a17ae | 6021 | int idx_peer = 1; |
28c6e247 IR |
6022 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6023 | bgp_node_safi(vty), | |
6024 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6025 | } |
6026 | ||
d62a17ae | 6027 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
6028 | neighbor_soft_reconfiguration_hidden_cmd, | |
6029 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6030 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6031 | "Per neighbor soft reconfiguration\n" | |
6032 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6033 | |
28c6e247 IR |
6034 | DEFUN (no_neighbor_soft_reconfiguration, |
6035 | no_neighbor_soft_reconfiguration_cmd, | |
6036 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6037 | NO_STR | |
6038 | NEIGHBOR_STR | |
6039 | NEIGHBOR_ADDR_STR2 | |
6040 | "Per neighbor soft reconfiguration\n" | |
6041 | "Allow inbound soft reconfiguration for this neighbor\n") | |
718e3744 | 6042 | { |
d62a17ae | 6043 | int idx_peer = 2; |
28c6e247 IR |
6044 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
6045 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6046 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 6047 | } |
6b0655a2 | 6048 | |
d62a17ae | 6049 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
6050 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
6051 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
6052 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6053 | "Per neighbor soft reconfiguration\n" | |
6054 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 6055 | |
28c6e247 IR |
6056 | DEFUN (neighbor_route_reflector_client, |
6057 | neighbor_route_reflector_client_cmd, | |
6058 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6059 | NEIGHBOR_STR | |
6060 | NEIGHBOR_ADDR_STR2 | |
6061 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 6062 | { |
d62a17ae | 6063 | int idx_peer = 1; |
28c6e247 | 6064 | struct peer *peer; |
718e3744 | 6065 | |
6066 | ||
28c6e247 IR |
6067 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6068 | if (!peer) | |
d62a17ae | 6069 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6070 | |
28c6e247 IR |
6071 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6072 | bgp_node_safi(vty), | |
6073 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 6074 | } |
6075 | ||
d62a17ae | 6076 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
6077 | neighbor_route_reflector_client_hidden_cmd, | |
6078 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6079 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6080 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6081 | |
28c6e247 IR |
6082 | DEFUN (no_neighbor_route_reflector_client, |
6083 | no_neighbor_route_reflector_client_cmd, | |
6084 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6085 | NO_STR | |
6086 | NEIGHBOR_STR | |
6087 | NEIGHBOR_ADDR_STR2 | |
6088 | "Configure a neighbor as Route Reflector client\n") | |
718e3744 | 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_REFLECTOR_CLIENT); | |
718e3744 | 6094 | } |
6b0655a2 | 6095 | |
d62a17ae | 6096 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
6097 | no_neighbor_route_reflector_client_hidden_cmd, | |
6098 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
6099 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6100 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 6101 | |
718e3744 | 6102 | /* neighbor route-server-client. */ |
28c6e247 IR |
6103 | DEFUN (neighbor_route_server_client, |
6104 | neighbor_route_server_client_cmd, | |
6105 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6106 | NEIGHBOR_STR | |
6107 | NEIGHBOR_ADDR_STR2 | |
6108 | "Configure a neighbor as Route Server client\n") | |
718e3744 | 6109 | { |
d62a17ae | 6110 | int idx_peer = 1; |
28c6e247 | 6111 | struct peer *peer; |
f4b8ec07 | 6112 | |
28c6e247 IR |
6113 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6114 | if (!peer) | |
d62a17ae | 6115 | return CMD_WARNING_CONFIG_FAILED; |
28c6e247 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_RSERVER_CLIENT); | |
718e3744 | 6119 | } |
6120 | ||
d62a17ae | 6121 | ALIAS_HIDDEN(neighbor_route_server_client, |
6122 | neighbor_route_server_client_hidden_cmd, | |
6123 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6124 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6125 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6126 | |
28c6e247 IR |
6127 | DEFUN (no_neighbor_route_server_client, |
6128 | no_neighbor_route_server_client_cmd, | |
6129 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6130 | NO_STR | |
6131 | NEIGHBOR_STR | |
6132 | NEIGHBOR_ADDR_STR2 | |
6133 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 6134 | { |
d62a17ae | 6135 | int idx_peer = 2; |
28c6e247 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_RSERVER_CLIENT); | |
fee0f4c6 | 6139 | } |
6b0655a2 | 6140 | |
d62a17ae | 6141 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
6142 | no_neighbor_route_server_client_hidden_cmd, | |
6143 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
6144 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6145 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 6146 | |
fee0f4c6 | 6147 | DEFUN (neighbor_nexthop_local_unchanged, |
6148 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6149 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6150 | NEIGHBOR_STR |
6151 | NEIGHBOR_ADDR_STR2 | |
6152 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
6153 | "Leave link-local nexthop unchanged for this peer\n") | |
6154 | { | |
d62a17ae | 6155 | int idx_peer = 1; |
6156 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6157 | bgp_node_safi(vty), | |
6158 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 6159 | } |
6b0655a2 | 6160 | |
fee0f4c6 | 6161 | DEFUN (no_neighbor_nexthop_local_unchanged, |
6162 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 6163 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 6164 | NO_STR |
6165 | NEIGHBOR_STR | |
6166 | NEIGHBOR_ADDR_STR2 | |
6167 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
6168 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 6169 | { |
d62a17ae | 6170 | int idx_peer = 2; |
6171 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6172 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6173 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 6174 | } |
6b0655a2 | 6175 | |
28c6e247 IR |
6176 | DEFUN (neighbor_attr_unchanged, |
6177 | neighbor_attr_unchanged_cmd, | |
6178 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6179 | NEIGHBOR_STR | |
6180 | NEIGHBOR_ADDR_STR2 | |
6181 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6182 | "As-path attribute\n" | |
6183 | "Nexthop attribute\n" | |
6184 | "Med attribute\n") | |
718e3744 | 6185 | { |
d62a17ae | 6186 | int idx = 0; |
8eeb0335 | 6187 | char *peer_str = argv[1]->arg; |
28c6e247 | 6188 | struct peer *peer; |
db45f64d DS |
6189 | bool aspath = false; |
6190 | bool nexthop = false; | |
6191 | bool med = false; | |
8eeb0335 DW |
6192 | afi_t afi = bgp_node_afi(vty); |
6193 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6194 | int ret = 0; |
f4b8ec07 | 6195 | |
28c6e247 IR |
6196 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6197 | if (!peer) | |
8eeb0335 | 6198 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6199 | |
6200 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6201 | aspath = true; |
6202 | ||
d62a17ae | 6203 | idx = 0; |
6204 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6205 | nexthop = true; |
6206 | ||
d62a17ae | 6207 | idx = 0; |
6208 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6209 | med = true; |
d62a17ae | 6210 | |
8eeb0335 | 6211 | /* no flags means all of them! */ |
db45f64d | 6212 | if (!aspath && !nexthop && !med) { |
28c6e247 IR |
6213 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, |
6214 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6215 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6216 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6217 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6218 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 6219 | } else { |
28c6e247 IR |
6220 | if (!aspath) { |
6221 | if (peer_af_flag_check(peer, afi, safi, | |
6222 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
6223 | ret |= peer_af_flag_unset_vty( | |
6224 | vty, peer_str, afi, safi, | |
6225 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6226 | } | |
6227 | } else | |
6228 | ret |= peer_af_flag_set_vty( | |
6229 | vty, peer_str, afi, safi, | |
6230 | PEER_FLAG_AS_PATH_UNCHANGED); | |
6231 | ||
6232 | if (!nexthop) { | |
6233 | if (peer_af_flag_check(peer, afi, safi, | |
6234 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
6235 | ret |= peer_af_flag_unset_vty( | |
6236 | vty, peer_str, afi, safi, | |
6237 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6238 | } | |
6239 | } else | |
6240 | ret |= peer_af_flag_set_vty( | |
6241 | vty, peer_str, afi, safi, | |
6242 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
6243 | ||
6244 | if (!med) { | |
6245 | if (peer_af_flag_check(peer, afi, safi, | |
6246 | PEER_FLAG_MED_UNCHANGED)) { | |
6247 | ret |= peer_af_flag_unset_vty( | |
6248 | vty, peer_str, afi, safi, | |
6249 | PEER_FLAG_MED_UNCHANGED); | |
6250 | } | |
6251 | } else | |
6252 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
6253 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 6254 | } |
6255 | ||
28c6e247 | 6256 | return ret; |
d62a17ae | 6257 | } |
6258 | ||
6259 | ALIAS_HIDDEN( | |
6260 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
6261 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6262 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6263 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6264 | "As-path attribute\n" | |
6265 | "Nexthop attribute\n" | |
6266 | "Med attribute\n") | |
596c17ba | 6267 | |
28c6e247 IR |
6268 | DEFUN (no_neighbor_attr_unchanged, |
6269 | no_neighbor_attr_unchanged_cmd, | |
6270 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6271 | NO_STR | |
6272 | NEIGHBOR_STR | |
6273 | NEIGHBOR_ADDR_STR2 | |
6274 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6275 | "As-path attribute\n" | |
6276 | "Nexthop attribute\n" | |
6277 | "Med attribute\n") | |
718e3744 | 6278 | { |
d62a17ae | 6279 | int idx = 0; |
db45f64d | 6280 | char *peer_str = argv[2]->arg; |
28c6e247 | 6281 | struct peer *peer; |
db45f64d DS |
6282 | bool aspath = false; |
6283 | bool nexthop = false; | |
6284 | bool med = false; | |
6285 | afi_t afi = bgp_node_afi(vty); | |
6286 | safi_t safi = bgp_node_safi(vty); | |
28c6e247 | 6287 | int ret = 0; |
f4b8ec07 | 6288 | |
28c6e247 IR |
6289 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6290 | if (!peer) | |
db45f64d | 6291 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 6292 | |
6293 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
6294 | aspath = true; |
6295 | ||
d62a17ae | 6296 | idx = 0; |
6297 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
6298 | nexthop = true; |
6299 | ||
d62a17ae | 6300 | idx = 0; |
6301 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 6302 | med = true; |
d62a17ae | 6303 | |
28c6e247 IR |
6304 | if (!aspath && !nexthop && !med) // no flags means all of them! |
6305 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6306 | PEER_FLAG_AS_PATH_UNCHANGED) | |
6307 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6308 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
6309 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
6310 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d DS |
6311 | |
6312 | if (aspath) | |
28c6e247 IR |
6313 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6314 | PEER_FLAG_AS_PATH_UNCHANGED); | |
db45f64d DS |
6315 | |
6316 | if (nexthop) | |
28c6e247 IR |
6317 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6318 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 6319 | |
db45f64d | 6320 | if (med) |
28c6e247 IR |
6321 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
6322 | PEER_FLAG_MED_UNCHANGED); | |
db45f64d | 6323 | |
28c6e247 | 6324 | return ret; |
d62a17ae | 6325 | } |
6326 | ||
6327 | ALIAS_HIDDEN( | |
6328 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
6329 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
6330 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6331 | "BGP attribute is propagated unchanged to this neighbor\n" | |
6332 | "As-path attribute\n" | |
6333 | "Nexthop attribute\n" | |
6334 | "Med attribute\n") | |
718e3744 | 6335 | |
28c6e247 IR |
6336 | /* EBGP multihop configuration. */ |
6337 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, | |
6338 | const char *ttl_str) | |
718e3744 | 6339 | { |
28c6e247 IR |
6340 | struct peer *peer; |
6341 | unsigned int ttl; | |
718e3744 | 6342 | |
28c6e247 IR |
6343 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6344 | if (!peer) | |
d62a17ae | 6345 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6346 | |
28c6e247 IR |
6347 | if (peer->conf_if) |
6348 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
6349 | ||
6350 | if (!ttl_str) | |
6351 | ttl = MAXTTL; | |
6352 | else | |
6353 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 6354 | |
28c6e247 | 6355 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 6356 | } |
6357 | ||
28c6e247 | 6358 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6359 | { |
28c6e247 | 6360 | struct peer *peer; |
718e3744 | 6361 | |
28c6e247 IR |
6362 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6363 | if (!peer) | |
d62a17ae | 6364 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6365 | |
28c6e247 | 6366 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6367 | } |
6368 | ||
28c6e247 IR |
6369 | /* neighbor ebgp-multihop. */ |
6370 | DEFUN (neighbor_ebgp_multihop, | |
6371 | neighbor_ebgp_multihop_cmd, | |
6372 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", | |
6373 | NEIGHBOR_STR | |
6374 | NEIGHBOR_ADDR_STR2 | |
6375 | "Allow EBGP neighbors not on directly connected networks\n") | |
718e3744 | 6376 | { |
28c6e247 IR |
6377 | int idx_peer = 1; |
6378 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
6379 | } | |
f4b8ec07 | 6380 | |
28c6e247 IR |
6381 | DEFUN (neighbor_ebgp_multihop_ttl, |
6382 | neighbor_ebgp_multihop_ttl_cmd, | |
6383 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", | |
6384 | NEIGHBOR_STR | |
6385 | NEIGHBOR_ADDR_STR2 | |
6386 | "Allow EBGP neighbors not on directly connected networks\n" | |
6387 | "maximum hop count\n") | |
6388 | { | |
6389 | int idx_peer = 1; | |
6390 | int idx_number = 3; | |
6391 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6392 | argv[idx_number]->arg); | |
6393 | } | |
f4b8ec07 | 6394 | |
28c6e247 IR |
6395 | DEFUN (no_neighbor_ebgp_multihop, |
6396 | no_neighbor_ebgp_multihop_cmd, | |
6397 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", | |
6398 | NO_STR | |
6399 | NEIGHBOR_STR | |
6400 | NEIGHBOR_ADDR_STR2 | |
6401 | "Allow EBGP neighbors not on directly connected networks\n" | |
6402 | "maximum hop count\n") | |
6403 | { | |
6404 | int idx_peer = 2; | |
6405 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6406 | } |
6407 | ||
6b0655a2 | 6408 | |
6ffd2079 | 6409 | /* disable-connected-check */ |
28c6e247 IR |
6410 | DEFUN (neighbor_disable_connected_check, |
6411 | neighbor_disable_connected_check_cmd, | |
6412 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6413 | NEIGHBOR_STR | |
6414 | NEIGHBOR_ADDR_STR2 | |
6415 | "one-hop away EBGP peer using loopback address\n" | |
6416 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6417 | { |
d62a17ae | 6418 | int idx_peer = 1; |
28c6e247 IR |
6419 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6420 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6421 | } |
6422 | ||
28c6e247 IR |
6423 | DEFUN (no_neighbor_disable_connected_check, |
6424 | no_neighbor_disable_connected_check_cmd, | |
6425 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", | |
6426 | NO_STR | |
6427 | NEIGHBOR_STR | |
6428 | NEIGHBOR_ADDR_STR2 | |
6429 | "one-hop away EBGP peer using loopback address\n" | |
6430 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6431 | { |
d62a17ae | 6432 | int idx_peer = 2; |
28c6e247 IR |
6433 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6434 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6435 | } |
6436 | ||
7ab294ea DA |
6437 | /* disable-link-bw-encoding-ieee */ |
6438 | DEFUN(neighbor_disable_link_bw_encoding_ieee, | |
6439 | neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6440 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6441 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6442 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6443 | { |
6444 | int idx_peer = 1; | |
6445 | ||
6446 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6447 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6448 | } | |
6449 | ||
7ab294ea DA |
6450 | DEFUN(no_neighbor_disable_link_bw_encoding_ieee, |
6451 | no_neighbor_disable_link_bw_encoding_ieee_cmd, | |
27aa23a4 DA |
6452 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-link-bw-encoding-ieee", |
6453 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7ab294ea | 6454 | "Disable IEEE floating-point encoding for extended community bandwidth\n") |
27aa23a4 DA |
6455 | { |
6456 | int idx_peer = 2; | |
6457 | ||
6458 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6459 | PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE); | |
6460 | } | |
6461 | ||
d08c0c80 DA |
6462 | /* extended-optional-parameters */ |
6463 | DEFUN(neighbor_extended_optional_parameters, | |
6464 | neighbor_extended_optional_parameters_cmd, | |
6465 | "neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6466 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6467 | "Force the extended optional parameters format for OPEN messages\n") | |
6468 | { | |
6469 | int idx_peer = 1; | |
6470 | ||
6471 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6472 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6473 | } | |
6474 | ||
6475 | DEFUN(no_neighbor_extended_optional_parameters, | |
6476 | no_neighbor_extended_optional_parameters_cmd, | |
6477 | "no neighbor <A.B.C.D|X:X::X:X|WORD> extended-optional-parameters", | |
6478 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6479 | "Force the extended optional parameters format for OPEN messages\n") | |
6480 | { | |
6481 | int idx_peer = 2; | |
6482 | ||
6483 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6484 | PEER_FLAG_EXTENDED_OPT_PARAMS); | |
6485 | } | |
47cbc09b PM |
6486 | |
6487 | /* enforce-first-as */ | |
28c6e247 IR |
6488 | DEFUN (neighbor_enforce_first_as, |
6489 | neighbor_enforce_first_as_cmd, | |
6490 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6491 | NEIGHBOR_STR | |
6492 | NEIGHBOR_ADDR_STR2 | |
6493 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6494 | { |
6495 | int idx_peer = 1; | |
f4b8ec07 | 6496 | |
28c6e247 IR |
6497 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6498 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6499 | } |
6500 | ||
28c6e247 IR |
6501 | DEFUN (no_neighbor_enforce_first_as, |
6502 | no_neighbor_enforce_first_as_cmd, | |
6503 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6504 | NO_STR | |
6505 | NEIGHBOR_STR | |
6506 | NEIGHBOR_ADDR_STR2 | |
6507 | "Enforce the first AS for EBGP routes\n") | |
47cbc09b PM |
6508 | { |
6509 | int idx_peer = 2; | |
f4b8ec07 | 6510 | |
28c6e247 IR |
6511 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6512 | PEER_FLAG_ENFORCE_FIRST_AS); | |
47cbc09b PM |
6513 | } |
6514 | ||
6515 | ||
28c6e247 IR |
6516 | DEFUN (neighbor_description, |
6517 | neighbor_description_cmd, | |
6518 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6519 | NEIGHBOR_STR | |
6520 | NEIGHBOR_ADDR_STR2 | |
6521 | "Neighbor specific description\n" | |
6522 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 6523 | { |
d62a17ae | 6524 | int idx_peer = 1; |
6525 | int idx_line = 3; | |
28c6e247 | 6526 | struct peer *peer; |
d62a17ae | 6527 | char *str; |
718e3744 | 6528 | |
28c6e247 IR |
6529 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6530 | if (!peer) | |
d62a17ae | 6531 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6532 | |
d62a17ae | 6533 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6534 | |
28c6e247 | 6535 | peer_description_set(peer, str); |
718e3744 | 6536 | |
d62a17ae | 6537 | XFREE(MTYPE_TMP, str); |
718e3744 | 6538 | |
28c6e247 | 6539 | return CMD_SUCCESS; |
718e3744 | 6540 | } |
6541 | ||
28c6e247 IR |
6542 | DEFUN (no_neighbor_description, |
6543 | no_neighbor_description_cmd, | |
6544 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", | |
6545 | NO_STR | |
6546 | NEIGHBOR_STR | |
6547 | NEIGHBOR_ADDR_STR2 | |
6548 | "Neighbor specific description\n") | |
718e3744 | 6549 | { |
d62a17ae | 6550 | int idx_peer = 2; |
28c6e247 | 6551 | struct peer *peer; |
f4b8ec07 | 6552 | |
28c6e247 IR |
6553 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6554 | if (!peer) | |
d62a17ae | 6555 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6556 | |
28c6e247 | 6557 | peer_description_unset(peer); |
718e3744 | 6558 | |
28c6e247 | 6559 | return CMD_SUCCESS; |
718e3744 | 6560 | } |
6561 | ||
1d80f243 | 6562 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
a14810f4 PM |
6563 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
6564 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6565 | "Neighbor specific description\n" | |
6566 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6567 | |
28c6e247 IR |
6568 | /* Neighbor update-source. */ |
6569 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, | |
6570 | const char *source_str) | |
6571 | { | |
6572 | struct peer *peer; | |
6573 | struct prefix p; | |
6574 | union sockunion su; | |
6575 | ||
6576 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6577 | if (!peer) | |
6578 | return CMD_WARNING_CONFIG_FAILED; | |
6579 | ||
6580 | if (peer->conf_if) | |
6581 | return CMD_WARNING; | |
6582 | ||
6583 | if (source_str) { | |
6584 | if (str2sockunion(source_str, &su) == 0) | |
6585 | peer_update_source_addr_set(peer, &su); | |
6586 | else { | |
6587 | if (str2prefix(source_str, &p)) { | |
6588 | vty_out(vty, | |
6589 | "%% Invalid update-source, remove prefix length \n"); | |
6590 | return CMD_WARNING_CONFIG_FAILED; | |
6591 | } else | |
6592 | peer_update_source_if_set(peer, source_str); | |
6593 | } | |
6594 | } else | |
6595 | peer_update_source_unset(peer); | |
6596 | ||
6597 | return CMD_SUCCESS; | |
6598 | } | |
6599 | ||
d62a17ae | 6600 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
6601 | "IPv4 address\n" \ | |
6602 | "IPv6 address\n" \ | |
6603 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6604 | |
28c6e247 IR |
6605 | DEFUN (neighbor_update_source, |
6606 | neighbor_update_source_cmd, | |
6607 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", | |
6608 | NEIGHBOR_STR | |
6609 | NEIGHBOR_ADDR_STR2 | |
6610 | "Source of routing updates\n" | |
6611 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6612 | { |
d62a17ae | 6613 | int idx_peer = 1; |
6614 | int idx_peer_2 = 3; | |
28c6e247 | 6615 | return peer_update_source_vty(vty, argv[idx_peer]->arg, |
d62a17ae | 6616 | argv[idx_peer_2]->arg); |
718e3744 | 6617 | } |
6618 | ||
28c6e247 IR |
6619 | DEFUN (no_neighbor_update_source, |
6620 | no_neighbor_update_source_cmd, | |
6621 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", | |
6622 | NO_STR | |
6623 | NEIGHBOR_STR | |
6624 | NEIGHBOR_ADDR_STR2 | |
6625 | "Source of routing updates\n" | |
6626 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6627 | { |
d62a17ae | 6628 | int idx_peer = 2; |
28c6e247 | 6629 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 6630 | } |
6b0655a2 | 6631 | |
d62a17ae | 6632 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6633 | afi_t afi, safi_t safi, | |
6634 | const char *rmap, int set) | |
718e3744 | 6635 | { |
d62a17ae | 6636 | int ret; |
6637 | struct peer *peer; | |
80912664 | 6638 | struct route_map *route_map = NULL; |
718e3744 | 6639 | |
d62a17ae | 6640 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6641 | if (!peer) | |
6642 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6643 | |
1de27621 | 6644 | if (set) { |
80912664 DS |
6645 | if (rmap) |
6646 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6647 | ret = peer_default_originate_set(peer, afi, safi, |
6648 | rmap, route_map); | |
6649 | } else | |
d62a17ae | 6650 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6651 | |
d62a17ae | 6652 | return bgp_vty_return(vty, ret); |
718e3744 | 6653 | } |
6654 | ||
6655 | /* neighbor default-originate. */ | |
6656 | DEFUN (neighbor_default_originate, | |
6657 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6658 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6659 | NEIGHBOR_STR |
6660 | NEIGHBOR_ADDR_STR2 | |
6661 | "Originate default route to this neighbor\n") | |
6662 | { | |
d62a17ae | 6663 | int idx_peer = 1; |
6664 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6665 | bgp_node_afi(vty), | |
6666 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6667 | } |
6668 | ||
d62a17ae | 6669 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6670 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6671 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6672 | "Originate default route to this neighbor\n") | |
596c17ba | 6673 | |
718e3744 | 6674 | DEFUN (neighbor_default_originate_rmap, |
6675 | neighbor_default_originate_rmap_cmd, | |
70dd370f | 6676 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
718e3744 | 6677 | NEIGHBOR_STR |
6678 | NEIGHBOR_ADDR_STR2 | |
6679 | "Originate default route to this neighbor\n" | |
6680 | "Route-map to specify criteria to originate default\n" | |
6681 | "route-map name\n") | |
6682 | { | |
d62a17ae | 6683 | int idx_peer = 1; |
6684 | int idx_word = 4; | |
6685 | return peer_default_originate_set_vty( | |
6686 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6687 | argv[idx_word]->arg, 1); | |
718e3744 | 6688 | } |
6689 | ||
d62a17ae | 6690 | ALIAS_HIDDEN( |
6691 | neighbor_default_originate_rmap, | |
6692 | neighbor_default_originate_rmap_hidden_cmd, | |
70dd370f | 6693 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map RMAP_NAME", |
d62a17ae | 6694 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6695 | "Originate default route to this neighbor\n" | |
6696 | "Route-map to specify criteria to originate default\n" | |
6697 | "route-map name\n") | |
596c17ba | 6698 | |
718e3744 | 6699 | DEFUN (no_neighbor_default_originate, |
6700 | no_neighbor_default_originate_cmd, | |
70dd370f | 6701 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
718e3744 | 6702 | NO_STR |
6703 | NEIGHBOR_STR | |
6704 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6705 | "Originate default route to this neighbor\n" |
6706 | "Route-map to specify criteria to originate default\n" | |
6707 | "route-map name\n") | |
718e3744 | 6708 | { |
d62a17ae | 6709 | int idx_peer = 2; |
6710 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6711 | bgp_node_afi(vty), | |
6712 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6713 | } |
6714 | ||
d62a17ae | 6715 | ALIAS_HIDDEN( |
6716 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
70dd370f | 6717 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map RMAP_NAME]", |
d62a17ae | 6718 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
6719 | "Originate default route to this neighbor\n" | |
6720 | "Route-map to specify criteria to originate default\n" | |
6721 | "route-map name\n") | |
596c17ba | 6722 | |
6b0655a2 | 6723 | |
28c6e247 IR |
6724 | /* Set neighbor's BGP port. */ |
6725 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, | |
6726 | const char *port_str) | |
718e3744 | 6727 | { |
28c6e247 IR |
6728 | struct peer *peer; |
6729 | uint16_t port; | |
6730 | struct servent *sp; | |
6731 | ||
6732 | peer = peer_lookup_vty(vty, ip_str); | |
6733 | if (!peer) | |
6734 | return CMD_WARNING_CONFIG_FAILED; | |
6735 | ||
6736 | if (!port_str) { | |
6737 | sp = getservbyname("bgp", "tcp"); | |
6738 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6739 | } else { | |
6740 | port = strtoul(port_str, NULL, 10); | |
6741 | } | |
718e3744 | 6742 | |
28c6e247 | 6743 | peer_port_set(peer, port); |
718e3744 | 6744 | |
28c6e247 IR |
6745 | return CMD_SUCCESS; |
6746 | } | |
f4b8ec07 | 6747 | |
28c6e247 IR |
6748 | /* Set specified peer's BGP port. */ |
6749 | DEFUN (neighbor_port, | |
6750 | neighbor_port_cmd, | |
6751 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", | |
6752 | NEIGHBOR_STR | |
6753 | NEIGHBOR_ADDR_STR | |
6754 | "Neighbor's BGP port\n" | |
6755 | "TCP port number\n") | |
6756 | { | |
6757 | int idx_ip = 1; | |
6758 | int idx_number = 3; | |
6759 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6760 | argv[idx_number]->arg); | |
f4b8ec07 | 6761 | } |
6b0655a2 | 6762 | |
28c6e247 IR |
6763 | DEFUN (no_neighbor_port, |
6764 | no_neighbor_port_cmd, | |
6765 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", | |
6766 | NO_STR | |
6767 | NEIGHBOR_STR | |
6768 | NEIGHBOR_ADDR_STR | |
6769 | "Neighbor's BGP port\n" | |
6770 | "TCP port number\n") | |
718e3744 | 6771 | { |
f4b8ec07 | 6772 | int idx_ip = 2; |
28c6e247 IR |
6773 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); |
6774 | } | |
6775 | ||
6776 | ||
6777 | /* neighbor weight. */ | |
6778 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, | |
6779 | safi_t safi, const char *weight_str) | |
6780 | { | |
6781 | int ret; | |
6782 | struct peer *peer; | |
6783 | unsigned long weight; | |
718e3744 | 6784 | |
28c6e247 IR |
6785 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6786 | if (!peer) | |
6787 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6788 | |
28c6e247 | 6789 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 6790 | |
28c6e247 IR |
6791 | ret = peer_weight_set(peer, afi, safi, weight); |
6792 | return bgp_vty_return(vty, ret); | |
718e3744 | 6793 | } |
6794 | ||
28c6e247 IR |
6795 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6796 | safi_t safi) | |
718e3744 | 6797 | { |
28c6e247 IR |
6798 | int ret; |
6799 | struct peer *peer; | |
f4b8ec07 | 6800 | |
28c6e247 IR |
6801 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6802 | if (!peer) | |
d62a17ae | 6803 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6804 | |
28c6e247 IR |
6805 | ret = peer_weight_unset(peer, afi, safi); |
6806 | return bgp_vty_return(vty, ret); | |
6807 | } | |
f4b8ec07 | 6808 | |
28c6e247 IR |
6809 | DEFUN (neighbor_weight, |
6810 | neighbor_weight_cmd, | |
6811 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6812 | NEIGHBOR_STR | |
6813 | NEIGHBOR_ADDR_STR2 | |
6814 | "Set default weight for routes from this neighbor\n" | |
6815 | "default weight\n") | |
6816 | { | |
6817 | int idx_peer = 1; | |
6818 | int idx_number = 3; | |
6819 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6820 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 6821 | } |
6822 | ||
d62a17ae | 6823 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
6824 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6825 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6826 | "Set default weight for routes from this neighbor\n" | |
6827 | "default weight\n") | |
596c17ba | 6828 | |
28c6e247 IR |
6829 | DEFUN (no_neighbor_weight, |
6830 | no_neighbor_weight_cmd, | |
6831 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6832 | NO_STR | |
6833 | NEIGHBOR_STR | |
6834 | NEIGHBOR_ADDR_STR2 | |
6835 | "Set default weight for routes from this neighbor\n" | |
6836 | "default weight\n") | |
718e3744 | 6837 | { |
d62a17ae | 6838 | int idx_peer = 2; |
28c6e247 IR |
6839 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, |
6840 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 6841 | } |
6842 | ||
d62a17ae | 6843 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
6844 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6845 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6846 | "Set default weight for routes from this neighbor\n" | |
6847 | "default weight\n") | |
596c17ba | 6848 | |
6b0655a2 | 6849 | |
718e3744 | 6850 | /* Override capability negotiation. */ |
c36bc05f IR |
6851 | DEFUN (neighbor_override_capability, |
6852 | neighbor_override_capability_cmd, | |
6853 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6854 | NEIGHBOR_STR | |
6855 | NEIGHBOR_ADDR_STR2 | |
6856 | "Override capability negotiation result\n") | |
718e3744 | 6857 | { |
d62a17ae | 6858 | int idx_peer = 1; |
c36bc05f IR |
6859 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6860 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6861 | } |
6862 | ||
c36bc05f IR |
6863 | DEFUN (no_neighbor_override_capability, |
6864 | no_neighbor_override_capability_cmd, | |
6865 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", | |
6866 | NO_STR | |
6867 | NEIGHBOR_STR | |
6868 | NEIGHBOR_ADDR_STR2 | |
6869 | "Override capability negotiation result\n") | |
718e3744 | 6870 | { |
d62a17ae | 6871 | int idx_peer = 2; |
c36bc05f IR |
6872 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6873 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6874 | } |
6b0655a2 | 6875 | |
c36bc05f IR |
6876 | DEFUN (neighbor_strict_capability, |
6877 | neighbor_strict_capability_cmd, | |
6878 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6879 | NEIGHBOR_STR | |
6880 | NEIGHBOR_ADDR_STR2 | |
6881 | "Strict capability negotiation match\n") | |
718e3744 | 6882 | { |
9fb964de PM |
6883 | int idx_peer = 1; |
6884 | ||
c36bc05f IR |
6885 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, |
6886 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6887 | } |
6888 | ||
c36bc05f IR |
6889 | DEFUN (no_neighbor_strict_capability, |
6890 | no_neighbor_strict_capability_cmd, | |
6891 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", | |
6892 | NO_STR | |
6893 | NEIGHBOR_STR | |
6894 | NEIGHBOR_ADDR_STR2 | |
6895 | "Strict capability negotiation match\n") | |
718e3744 | 6896 | { |
9fb964de | 6897 | int idx_peer = 2; |
8611c7f3 | 6898 | |
c36bc05f IR |
6899 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
6900 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 6901 | } |
6b0655a2 | 6902 | |
28c6e247 IR |
6903 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6904 | const char *keep_str, const char *hold_str) | |
718e3744 | 6905 | { |
28c6e247 IR |
6906 | int ret; |
6907 | struct peer *peer; | |
6908 | uint32_t keepalive; | |
6909 | uint32_t holdtime; | |
718e3744 | 6910 | |
28c6e247 IR |
6911 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6912 | if (!peer) | |
d62a17ae | 6913 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6914 | |
28c6e247 IR |
6915 | keepalive = strtoul(keep_str, NULL, 10); |
6916 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6917 | |
28c6e247 | 6918 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6919 | |
28c6e247 | 6920 | return bgp_vty_return(vty, ret); |
718e3744 | 6921 | } |
6b0655a2 | 6922 | |
28c6e247 | 6923 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6924 | { |
28c6e247 IR |
6925 | int ret; |
6926 | struct peer *peer; | |
718e3744 | 6927 | |
28c6e247 IR |
6928 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6929 | if (!peer) | |
d62a17ae | 6930 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6931 | |
28c6e247 | 6932 | ret = peer_timers_unset(peer); |
718e3744 | 6933 | |
28c6e247 | 6934 | return bgp_vty_return(vty, ret); |
718e3744 | 6935 | } |
6b0655a2 | 6936 | |
28c6e247 IR |
6937 | DEFUN (neighbor_timers, |
6938 | neighbor_timers_cmd, | |
6939 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", | |
6940 | NEIGHBOR_STR | |
6941 | NEIGHBOR_ADDR_STR2 | |
6942 | "BGP per neighbor timers\n" | |
6943 | "Keepalive interval\n" | |
6944 | "Holdtime\n") | |
718e3744 | 6945 | { |
f4b8ec07 | 6946 | int idx_peer = 1; |
28c6e247 IR |
6947 | int idx_number = 3; |
6948 | int idx_number_2 = 4; | |
6949 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6950 | argv[idx_number]->arg, | |
6951 | argv[idx_number_2]->arg); | |
6952 | } | |
6953 | ||
6954 | DEFUN (no_neighbor_timers, | |
6955 | no_neighbor_timers_cmd, | |
6956 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", | |
6957 | NO_STR | |
6958 | NEIGHBOR_STR | |
6959 | NEIGHBOR_ADDR_STR2 | |
6960 | "BGP per neighbor timers\n" | |
6961 | "Keepalive interval\n" | |
6962 | "Holdtime\n") | |
6963 | { | |
6964 | int idx_peer = 2; | |
6965 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
6966 | } | |
6967 | ||
6968 | ||
6969 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, | |
6970 | const char *time_str) | |
6971 | { | |
6972 | int ret; | |
6973 | struct peer *peer; | |
6974 | uint32_t connect; | |
718e3744 | 6975 | |
28c6e247 IR |
6976 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6977 | if (!peer) | |
d62a17ae | 6978 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6979 | |
28c6e247 IR |
6980 | connect = strtoul(time_str, NULL, 10); |
6981 | ||
6982 | ret = peer_timers_connect_set(peer, connect); | |
718e3744 | 6983 | |
28c6e247 | 6984 | return bgp_vty_return(vty, ret); |
718e3744 | 6985 | } |
6986 | ||
28c6e247 | 6987 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6988 | { |
28c6e247 IR |
6989 | int ret; |
6990 | struct peer *peer; | |
718e3744 | 6991 | |
28c6e247 IR |
6992 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6993 | if (!peer) | |
d62a17ae | 6994 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 6995 | |
28c6e247 IR |
6996 | ret = peer_timers_connect_unset(peer); |
6997 | ||
6998 | return bgp_vty_return(vty, ret); | |
6999 | } | |
7000 | ||
7001 | DEFUN (neighbor_timers_connect, | |
7002 | neighbor_timers_connect_cmd, | |
7003 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", | |
7004 | NEIGHBOR_STR | |
7005 | NEIGHBOR_ADDR_STR2 | |
7006 | "BGP per neighbor timers\n" | |
7007 | "BGP connect timer\n" | |
7008 | "Connect timer\n") | |
7009 | { | |
7010 | int idx_peer = 1; | |
7011 | int idx_number = 4; | |
7012 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
7013 | argv[idx_number]->arg); | |
7014 | } | |
718e3744 | 7015 | |
28c6e247 IR |
7016 | DEFUN (no_neighbor_timers_connect, |
7017 | no_neighbor_timers_connect_cmd, | |
7018 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", | |
7019 | NO_STR | |
7020 | NEIGHBOR_STR | |
7021 | NEIGHBOR_ADDR_STR2 | |
7022 | "BGP per neighbor timers\n" | |
7023 | "BGP connect timer\n" | |
7024 | "Connect timer\n") | |
7025 | { | |
7026 | int idx_peer = 2; | |
7027 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 7028 | } |
7029 | ||
d43114f3 DS |
7030 | DEFPY (neighbor_timers_delayopen, |
7031 | neighbor_timers_delayopen_cmd, | |
7032 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval", | |
7033 | NEIGHBOR_STR | |
7034 | NEIGHBOR_ADDR_STR2 | |
7035 | "BGP per neighbor timers\n" | |
7036 | "RFC 4271 DelayOpenTimer\n" | |
7037 | "DelayOpenTime timer interval\n") | |
7038 | { | |
7039 | struct peer *peer; | |
7040 | ||
7041 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7042 | if (!peer) | |
7043 | return CMD_WARNING_CONFIG_FAILED; | |
7044 | ||
7045 | if (!interval) { | |
7046 | if (peer_timers_delayopen_unset(peer)) | |
7047 | return CMD_WARNING_CONFIG_FAILED; | |
7048 | } else { | |
7049 | if (peer_timers_delayopen_set(peer, interval)) | |
7050 | return CMD_WARNING_CONFIG_FAILED; | |
7051 | } | |
7052 | ||
7053 | return CMD_SUCCESS; | |
7054 | } | |
7055 | ||
7056 | DEFPY (no_neighbor_timers_delayopen, | |
7057 | no_neighbor_timers_delayopen_cmd, | |
7058 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]", | |
7059 | NO_STR | |
7060 | NEIGHBOR_STR | |
7061 | NEIGHBOR_ADDR_STR2 | |
7062 | "BGP per neighbor timers\n" | |
7063 | "RFC 4271 DelayOpenTimer\n" | |
7064 | "DelayOpenTime timer interval\n") | |
7065 | { | |
7066 | struct peer *peer; | |
7067 | ||
7068 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7069 | if (!peer) | |
7070 | return CMD_WARNING_CONFIG_FAILED; | |
7071 | ||
7072 | if (peer_timers_delayopen_unset(peer)) | |
7073 | return CMD_WARNING_CONFIG_FAILED; | |
7074 | ||
7075 | return CMD_SUCCESS; | |
7076 | } | |
7077 | ||
28c6e247 IR |
7078 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
7079 | const char *time_str, int set) | |
718e3744 | 7080 | { |
28c6e247 IR |
7081 | int ret; |
7082 | struct peer *peer; | |
7083 | uint32_t routeadv = 0; | |
718e3744 | 7084 | |
28c6e247 IR |
7085 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7086 | if (!peer) | |
d62a17ae | 7087 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7088 | |
28c6e247 IR |
7089 | if (time_str) |
7090 | routeadv = strtoul(time_str, NULL, 10); | |
7091 | ||
7092 | if (set) | |
7093 | ret = peer_advertise_interval_set(peer, routeadv); | |
7094 | else | |
7095 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 7096 | |
28c6e247 | 7097 | return bgp_vty_return(vty, ret); |
718e3744 | 7098 | } |
7099 | ||
28c6e247 IR |
7100 | DEFUN (neighbor_advertise_interval, |
7101 | neighbor_advertise_interval_cmd, | |
7102 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", | |
7103 | NEIGHBOR_STR | |
7104 | NEIGHBOR_ADDR_STR2 | |
7105 | "Minimum interval between sending BGP routing updates\n" | |
7106 | "time in seconds\n") | |
718e3744 | 7107 | { |
28c6e247 IR |
7108 | int idx_peer = 1; |
7109 | int idx_number = 3; | |
7110 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
7111 | argv[idx_number]->arg, 1); | |
7112 | } | |
f4b8ec07 | 7113 | |
28c6e247 IR |
7114 | DEFUN (no_neighbor_advertise_interval, |
7115 | no_neighbor_advertise_interval_cmd, | |
7116 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", | |
7117 | NO_STR | |
7118 | NEIGHBOR_STR | |
7119 | NEIGHBOR_ADDR_STR2 | |
7120 | "Minimum interval between sending BGP routing updates\n" | |
7121 | "time in seconds\n") | |
7122 | { | |
7123 | int idx_peer = 2; | |
7124 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 7125 | } |
7126 | ||
6b0655a2 | 7127 | |
518f0eb1 DS |
7128 | /* Time to wait before processing route-map updates */ |
7129 | DEFUN (bgp_set_route_map_delay_timer, | |
7130 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 7131 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
7132 | SET_STR |
7133 | "BGP route-map delay timer\n" | |
7134 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 7135 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 7136 | { |
d62a17ae | 7137 | int idx_number = 3; |
d7c0a89a | 7138 | uint32_t rmap_delay_timer; |
d62a17ae | 7139 | |
7140 | if (argv[idx_number]->arg) { | |
7141 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
7142 | bm->rmap_update_timer = rmap_delay_timer; | |
7143 | ||
7144 | /* if the dynamic update handling is being disabled, and a timer | |
7145 | * is | |
7146 | * running, stop the timer and act as if the timer has already | |
7147 | * fired. | |
7148 | */ | |
7149 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
7150 | BGP_TIMER_OFF(bm->t_rmap_update); | |
7151 | thread_execute(bm->master, bgp_route_map_update_timer, | |
7152 | NULL, 0); | |
7153 | } | |
7154 | return CMD_SUCCESS; | |
7155 | } else { | |
7156 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
7157 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 7158 | } |
518f0eb1 DS |
7159 | } |
7160 | ||
7161 | DEFUN (no_bgp_set_route_map_delay_timer, | |
7162 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 7163 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 7164 | NO_STR |
3a2d747c | 7165 | BGP_STR |
518f0eb1 | 7166 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
7167 | "Reset to default time to wait for processing route-map changes\n" |
7168 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 7169 | { |
518f0eb1 | 7170 | |
d62a17ae | 7171 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 7172 | |
d62a17ae | 7173 | return CMD_SUCCESS; |
518f0eb1 DS |
7174 | } |
7175 | ||
28c6e247 IR |
7176 | /* neighbor interface */ |
7177 | static int peer_interface_vty(struct vty *vty, const char *ip_str, | |
7178 | const char *str) | |
718e3744 | 7179 | { |
28c6e247 | 7180 | struct peer *peer; |
718e3744 | 7181 | |
28c6e247 IR |
7182 | peer = peer_lookup_vty(vty, ip_str); |
7183 | if (!peer || peer->conf_if) { | |
7184 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
7185 | return CMD_WARNING_CONFIG_FAILED; | |
7186 | } | |
718e3744 | 7187 | |
28c6e247 IR |
7188 | if (str) |
7189 | peer_interface_set(peer, str); | |
7190 | else | |
7191 | peer_interface_unset(peer); | |
718e3744 | 7192 | |
28c6e247 | 7193 | return CMD_SUCCESS; |
718e3744 | 7194 | } |
7195 | ||
28c6e247 IR |
7196 | DEFUN (neighbor_interface, |
7197 | neighbor_interface_cmd, | |
7198 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", | |
7199 | NEIGHBOR_STR | |
7200 | NEIGHBOR_ADDR_STR | |
7201 | "Interface\n" | |
7202 | "Interface name\n") | |
718e3744 | 7203 | { |
28c6e247 IR |
7204 | int idx_ip = 1; |
7205 | int idx_word = 3; | |
294d8425 | 7206 | |
28c6e247 IR |
7207 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
7208 | } | |
f4b8ec07 | 7209 | |
28c6e247 IR |
7210 | DEFUN (no_neighbor_interface, |
7211 | no_neighbor_interface_cmd, | |
294d8425 | 7212 | "no neighbor <A.B.C.D|X:X::X:X> interface WORD", |
28c6e247 IR |
7213 | NO_STR |
7214 | NEIGHBOR_STR | |
294d8425 | 7215 | NEIGHBOR_ADDR_STR |
28c6e247 IR |
7216 | "Interface\n" |
7217 | "Interface name\n") | |
7218 | { | |
7219 | int idx_peer = 2; | |
294d8425 | 7220 | |
28c6e247 | 7221 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); |
718e3744 | 7222 | } |
6b0655a2 | 7223 | |
718e3744 | 7224 | DEFUN (neighbor_distribute_list, |
7225 | neighbor_distribute_list_cmd, | |
c60dec36 | 7226 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7227 | NEIGHBOR_STR |
7228 | NEIGHBOR_ADDR_STR2 | |
7229 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7230 | "IP Access-list name\n" |
7231 | "Filter incoming updates\n" | |
7232 | "Filter outgoing updates\n") | |
7233 | { | |
d62a17ae | 7234 | int idx_peer = 1; |
7235 | int idx_acl = 3; | |
7236 | int direct, ret; | |
7237 | struct peer *peer; | |
a8206004 | 7238 | |
d62a17ae | 7239 | const char *pstr = argv[idx_peer]->arg; |
7240 | const char *acl = argv[idx_acl]->arg; | |
7241 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7242 | |
d62a17ae | 7243 | peer = peer_and_group_lookup_vty(vty, pstr); |
7244 | if (!peer) | |
7245 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7246 | |
d62a17ae | 7247 | /* Check filter direction. */ |
7248 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7249 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7250 | direct, acl); | |
a8206004 | 7251 | |
d62a17ae | 7252 | return bgp_vty_return(vty, ret); |
718e3744 | 7253 | } |
7254 | ||
d62a17ae | 7255 | ALIAS_HIDDEN( |
7256 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7257 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7258 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7259 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7260 | "IP Access-list name\n" |
7261 | "Filter incoming updates\n" | |
7262 | "Filter outgoing updates\n") | |
596c17ba | 7263 | |
718e3744 | 7264 | DEFUN (no_neighbor_distribute_list, |
7265 | no_neighbor_distribute_list_cmd, | |
c60dec36 | 7266 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
718e3744 | 7267 | NO_STR |
7268 | NEIGHBOR_STR | |
7269 | NEIGHBOR_ADDR_STR2 | |
7270 | "Filter updates to/from this neighbor\n" | |
718e3744 | 7271 | "IP Access-list name\n" |
7272 | "Filter incoming updates\n" | |
7273 | "Filter outgoing updates\n") | |
7274 | { | |
d62a17ae | 7275 | int idx_peer = 2; |
7276 | int direct, ret; | |
7277 | struct peer *peer; | |
a8206004 | 7278 | |
d62a17ae | 7279 | const char *pstr = argv[idx_peer]->arg; |
7280 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 7281 | |
d62a17ae | 7282 | peer = peer_and_group_lookup_vty(vty, pstr); |
7283 | if (!peer) | |
7284 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 7285 | |
d62a17ae | 7286 | /* Check filter direction. */ |
7287 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
7288 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7289 | direct); | |
a8206004 | 7290 | |
d62a17ae | 7291 | return bgp_vty_return(vty, ret); |
718e3744 | 7292 | } |
6b0655a2 | 7293 | |
d62a17ae | 7294 | ALIAS_HIDDEN( |
7295 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
c60dec36 | 7296 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list ACCESSLIST_NAME <in|out>", |
d62a17ae | 7297 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7298 | "Filter updates to/from this neighbor\n" | |
d62a17ae | 7299 | "IP Access-list name\n" |
7300 | "Filter incoming updates\n" | |
7301 | "Filter outgoing updates\n") | |
596c17ba | 7302 | |
718e3744 | 7303 | /* Set prefix list to the peer. */ |
642ef664 IR |
7304 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
7305 | afi_t afi, safi_t safi, | |
7306 | const char *name_str, | |
7307 | const char *direct_str) | |
718e3744 | 7308 | { |
642ef664 IR |
7309 | int ret; |
7310 | int direct = FILTER_IN; | |
7311 | struct peer *peer; | |
718e3744 | 7312 | |
642ef664 IR |
7313 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7314 | if (!peer) | |
d62a17ae | 7315 | return CMD_WARNING_CONFIG_FAILED; |
e52702f2 | 7316 | |
642ef664 IR |
7317 | /* Check filter direction. */ |
7318 | if (strncmp(direct_str, "i", 1) == 0) | |
7319 | direct = FILTER_IN; | |
7320 | else if (strncmp(direct_str, "o", 1) == 0) | |
7321 | direct = FILTER_OUT; | |
718e3744 | 7322 | |
642ef664 | 7323 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 7324 | |
642ef664 IR |
7325 | return bgp_vty_return(vty, ret); |
7326 | } | |
7327 | ||
7328 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, | |
7329 | afi_t afi, safi_t safi, | |
7330 | const char *direct_str) | |
7331 | { | |
7332 | int ret; | |
7333 | struct peer *peer; | |
7334 | int direct = FILTER_IN; | |
7335 | ||
7336 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7337 | if (!peer) | |
7338 | return CMD_WARNING_CONFIG_FAILED; | |
7339 | ||
7340 | /* Check filter direction. */ | |
7341 | if (strncmp(direct_str, "i", 1) == 0) | |
7342 | direct = FILTER_IN; | |
7343 | else if (strncmp(direct_str, "o", 1) == 0) | |
7344 | direct = FILTER_OUT; | |
7345 | ||
7346 | ret = peer_prefix_list_unset(peer, afi, safi, direct); | |
7347 | ||
7348 | return bgp_vty_return(vty, ret); | |
7349 | } | |
7350 | ||
7351 | DEFUN (neighbor_prefix_list, | |
7352 | neighbor_prefix_list_cmd, | |
7353 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7354 | NEIGHBOR_STR | |
7355 | NEIGHBOR_ADDR_STR2 | |
7356 | "Filter updates to/from this neighbor\n" | |
7357 | "Name of a prefix list\n" | |
7358 | "Filter incoming updates\n" | |
7359 | "Filter outgoing updates\n") | |
7360 | { | |
7361 | int idx_peer = 1; | |
7362 | int idx_word = 3; | |
7363 | int idx_in_out = 4; | |
7364 | return peer_prefix_list_set_vty( | |
7365 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7366 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7367 | } |
7368 | ||
d62a17ae | 7369 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
7370 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7371 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7372 | "Filter updates to/from this neighbor\n" | |
7373 | "Name of a prefix list\n" | |
7374 | "Filter incoming updates\n" | |
7375 | "Filter outgoing updates\n") | |
596c17ba | 7376 | |
642ef664 IR |
7377 | DEFUN (no_neighbor_prefix_list, |
7378 | no_neighbor_prefix_list_cmd, | |
7379 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7380 | NO_STR | |
7381 | NEIGHBOR_STR | |
7382 | NEIGHBOR_ADDR_STR2 | |
7383 | "Filter updates to/from this neighbor\n" | |
7384 | "Name of a prefix list\n" | |
7385 | "Filter incoming updates\n" | |
7386 | "Filter outgoing updates\n") | |
7387 | { | |
7388 | int idx_peer = 2; | |
7389 | int idx_in_out = 5; | |
7390 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
7391 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7392 | argv[idx_in_out]->arg); | |
7393 | } | |
7394 | ||
7395 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, | |
7396 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
7397 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7398 | "Filter updates to/from this neighbor\n" | |
7399 | "Name of a prefix list\n" | |
7400 | "Filter incoming updates\n" | |
7401 | "Filter outgoing updates\n") | |
7402 | ||
d62a17ae | 7403 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7404 | safi_t safi, const char *name_str, | |
7405 | const char *direct_str) | |
718e3744 | 7406 | { |
d62a17ae | 7407 | int ret; |
7408 | struct peer *peer; | |
7409 | int direct = FILTER_IN; | |
718e3744 | 7410 | |
d62a17ae | 7411 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7412 | if (!peer) | |
7413 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7414 | |
d62a17ae | 7415 | /* Check filter direction. */ |
7416 | if (strncmp(direct_str, "i", 1) == 0) | |
7417 | direct = FILTER_IN; | |
7418 | else if (strncmp(direct_str, "o", 1) == 0) | |
7419 | direct = FILTER_OUT; | |
718e3744 | 7420 | |
d62a17ae | 7421 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 7422 | |
d62a17ae | 7423 | return bgp_vty_return(vty, ret); |
718e3744 | 7424 | } |
7425 | ||
d62a17ae | 7426 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
7427 | safi_t safi, const char *direct_str) | |
718e3744 | 7428 | { |
d62a17ae | 7429 | int ret; |
7430 | struct peer *peer; | |
7431 | int direct = FILTER_IN; | |
718e3744 | 7432 | |
d62a17ae | 7433 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7434 | if (!peer) | |
7435 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7436 | |
d62a17ae | 7437 | /* Check filter direction. */ |
7438 | if (strncmp(direct_str, "i", 1) == 0) | |
7439 | direct = FILTER_IN; | |
7440 | else if (strncmp(direct_str, "o", 1) == 0) | |
7441 | direct = FILTER_OUT; | |
718e3744 | 7442 | |
d62a17ae | 7443 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 7444 | |
d62a17ae | 7445 | return bgp_vty_return(vty, ret); |
718e3744 | 7446 | } |
7447 | ||
7448 | DEFUN (neighbor_filter_list, | |
7449 | neighbor_filter_list_cmd, | |
de71d43e | 7450 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7451 | NEIGHBOR_STR |
7452 | NEIGHBOR_ADDR_STR2 | |
7453 | "Establish BGP filters\n" | |
7454 | "AS path access-list name\n" | |
7455 | "Filter incoming routes\n" | |
7456 | "Filter outgoing routes\n") | |
7457 | { | |
d62a17ae | 7458 | int idx_peer = 1; |
7459 | int idx_word = 3; | |
7460 | int idx_in_out = 4; | |
7461 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7462 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7463 | argv[idx_in_out]->arg); | |
718e3744 | 7464 | } |
7465 | ||
d62a17ae | 7466 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
de71d43e | 7467 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7468 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7469 | "Establish BGP filters\n" | |
7470 | "AS path access-list name\n" | |
7471 | "Filter incoming routes\n" | |
7472 | "Filter outgoing routes\n") | |
596c17ba | 7473 | |
718e3744 | 7474 | DEFUN (no_neighbor_filter_list, |
7475 | no_neighbor_filter_list_cmd, | |
de71d43e | 7476 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
718e3744 | 7477 | NO_STR |
7478 | NEIGHBOR_STR | |
7479 | NEIGHBOR_ADDR_STR2 | |
7480 | "Establish BGP filters\n" | |
7481 | "AS path access-list name\n" | |
7482 | "Filter incoming routes\n" | |
7483 | "Filter outgoing routes\n") | |
7484 | { | |
d62a17ae | 7485 | int idx_peer = 2; |
7486 | int idx_in_out = 5; | |
7487 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7488 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7489 | argv[idx_in_out]->arg); | |
718e3744 | 7490 | } |
6b0655a2 | 7491 | |
d62a17ae | 7492 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
de71d43e | 7493 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list AS_PATH_FILTER_NAME <in|out>", |
d62a17ae | 7494 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7495 | "Establish BGP filters\n" | |
7496 | "AS path access-list name\n" | |
7497 | "Filter incoming routes\n" | |
7498 | "Filter outgoing routes\n") | |
596c17ba | 7499 | |
7f7940e6 MK |
7500 | /* Set advertise-map to the peer. */ |
7501 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7502 | afi_t afi, safi_t safi, | |
cf2ad4d8 MK |
7503 | const char *advertise_str, |
7504 | const char *condition_str, bool condition, | |
7505 | bool set) | |
7f7940e6 MK |
7506 | { |
7507 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7508 | struct peer *peer; | |
7509 | struct route_map *advertise_map; | |
7510 | struct route_map *condition_map; | |
7511 | ||
7512 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7513 | if (!peer) | |
7514 | return ret; | |
7515 | ||
7516 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7517 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7518 | ||
cf2ad4d8 MK |
7519 | if (set) |
7520 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7521 | advertise_map, condition_str, | |
7522 | condition_map, condition); | |
7523 | else | |
7524 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7525 | advertise_map, condition_str, | |
7526 | condition_map, condition); | |
7f7940e6 MK |
7527 | |
7528 | return bgp_vty_return(vty, ret); | |
7529 | } | |
7530 | ||
389e4f92 QY |
7531 | DEFPY (bgp_condadv_period, |
7532 | bgp_condadv_period_cmd, | |
7533 | "[no$no] bgp conditional-advertisement timer (5-240)$period", | |
7534 | NO_STR | |
7535 | BGP_STR | |
7536 | "Conditional advertisement settings\n" | |
7537 | "Set period to rescan BGP table to check if condition is met\n" | |
7538 | "Period between BGP table scans, in seconds; default 60\n") | |
7539 | { | |
7540 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7541 | ||
7542 | bgp->condition_check_period = | |
7543 | no ? DEFAULT_CONDITIONAL_ROUTES_POLL_TIME : period; | |
7544 | ||
7545 | return CMD_SUCCESS; | |
7546 | } | |
7547 | ||
cf2ad4d8 | 7548 | DEFPY (neighbor_advertise_map, |
7f7940e6 | 7549 | neighbor_advertise_map_cmd, |
3ccddc25 | 7550 | "[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 | 7551 | NO_STR |
7f7940e6 MK |
7552 | NEIGHBOR_STR |
7553 | NEIGHBOR_ADDR_STR2 | |
7554 | "Route-map to conditionally advertise routes\n" | |
7555 | "Name of advertise map\n" | |
7556 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7557 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7558 | "Name of the exist or non exist map\n") |
7f7940e6 | 7559 | { |
7f7940e6 MK |
7560 | bool condition = CONDITION_EXIST; |
7561 | ||
52b84062 | 7562 | if (!strcmp(exist, "non-exist-map")) |
7f7940e6 MK |
7563 | condition = CONDITION_NON_EXIST; |
7564 | ||
52b84062 MK |
7565 | return peer_advertise_map_set_vty(vty, neighbor, bgp_node_afi(vty), |
7566 | bgp_node_safi(vty), advertise_str, | |
7567 | condition_str, condition, !no); | |
7f7940e6 MK |
7568 | } |
7569 | ||
7570 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
3ccddc25 | 7571 | "[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 |
7572 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7573 | "Route-map to conditionally advertise routes\n" | |
7574 | "Name of advertise map\n" | |
7575 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7f7940e6 | 7576 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" |
52b84062 | 7577 | "Name of the exist or non exist map\n") |
7f7940e6 | 7578 | |
718e3744 | 7579 | /* Set route-map to the peer. */ |
0ea8d871 IR |
7580 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7581 | afi_t afi, safi_t safi, const char *name_str, | |
7582 | const char *direct_str) | |
718e3744 | 7583 | { |
0ea8d871 IR |
7584 | int ret; |
7585 | struct peer *peer; | |
7586 | int direct = RMAP_IN; | |
7587 | struct route_map *route_map; | |
718e3744 | 7588 | |
0ea8d871 IR |
7589 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7590 | if (!peer) | |
d62a17ae | 7591 | return CMD_WARNING_CONFIG_FAILED; |
718e3744 | 7592 | |
0ea8d871 IR |
7593 | /* Check filter direction. */ |
7594 | if (strncmp(direct_str, "in", 2) == 0) | |
7595 | direct = RMAP_IN; | |
7596 | else if (strncmp(direct_str, "o", 1) == 0) | |
7597 | direct = RMAP_OUT; | |
718e3744 | 7598 | |
0ea8d871 IR |
7599 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7600 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7601 | |
0ea8d871 IR |
7602 | return bgp_vty_return(vty, ret); |
7603 | } | |
7604 | ||
7605 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, | |
7606 | afi_t afi, safi_t safi, | |
7607 | const char *direct_str) | |
7608 | { | |
7609 | int ret; | |
7610 | struct peer *peer; | |
7611 | int direct = RMAP_IN; | |
7612 | ||
7613 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7614 | if (!peer) | |
7615 | return CMD_WARNING_CONFIG_FAILED; | |
7616 | ||
7617 | /* Check filter direction. */ | |
7618 | if (strncmp(direct_str, "in", 2) == 0) | |
7619 | direct = RMAP_IN; | |
7620 | else if (strncmp(direct_str, "o", 1) == 0) | |
7621 | direct = RMAP_OUT; | |
7622 | ||
7623 | ret = peer_route_map_unset(peer, afi, safi, direct); | |
7624 | ||
7625 | return bgp_vty_return(vty, ret); | |
7626 | } | |
7627 | ||
7628 | DEFUN (neighbor_route_map, | |
7629 | neighbor_route_map_cmd, | |
70dd370f | 7630 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7631 | NEIGHBOR_STR |
7632 | NEIGHBOR_ADDR_STR2 | |
7633 | "Apply route map to neighbor\n" | |
7634 | "Name of route map\n" | |
7635 | "Apply map to incoming routes\n" | |
7636 | "Apply map to outbound routes\n") | |
7637 | { | |
7638 | int idx_peer = 1; | |
7639 | int idx_word = 3; | |
7640 | int idx_in_out = 4; | |
7641 | return peer_route_map_set_vty( | |
7642 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7643 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7644 | } |
7645 | ||
d6d7ed37 | 7646 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
70dd370f | 7647 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7648 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7649 | "Apply route map to neighbor\n" | |
7650 | "Name of route map\n" | |
7651 | "Apply map to incoming routes\n" | |
7652 | "Apply map to outbound routes\n") | |
7653 | ||
0ea8d871 IR |
7654 | DEFUN (no_neighbor_route_map, |
7655 | no_neighbor_route_map_cmd, | |
70dd370f | 7656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
0ea8d871 IR |
7657 | NO_STR |
7658 | NEIGHBOR_STR | |
7659 | NEIGHBOR_ADDR_STR2 | |
7660 | "Apply route map to neighbor\n" | |
7661 | "Name of route map\n" | |
7662 | "Apply map to incoming routes\n" | |
7663 | "Apply map to outbound routes\n") | |
7664 | { | |
7665 | int idx_peer = 2; | |
7666 | int idx_in_out = 5; | |
7667 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7668 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7669 | argv[idx_in_out]->arg); | |
7670 | } | |
7671 | ||
7672 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, | |
70dd370f | 7673 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map RMAP_NAME <in|out>", |
d6d7ed37 IR |
7674 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7675 | "Apply route map to neighbor\n" | |
7676 | "Name of route map\n" | |
7677 | "Apply map to incoming routes\n" | |
7678 | "Apply map to outbound routes\n") | |
7679 | ||
718e3744 | 7680 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7681 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7682 | afi_t afi, safi_t safi, | |
7683 | const char *name_str) | |
718e3744 | 7684 | { |
d62a17ae | 7685 | int ret; |
7686 | struct peer *peer; | |
1de27621 | 7687 | struct route_map *route_map; |
718e3744 | 7688 | |
d62a17ae | 7689 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7690 | if (!peer) | |
7691 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7692 | |
1de27621 DA |
7693 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7694 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7695 | |
d62a17ae | 7696 | return bgp_vty_return(vty, ret); |
718e3744 | 7697 | } |
7698 | ||
7699 | /* Unset route-map from the peer. */ | |
d62a17ae | 7700 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7701 | afi_t afi, safi_t safi) | |
718e3744 | 7702 | { |
d62a17ae | 7703 | int ret; |
7704 | struct peer *peer; | |
718e3744 | 7705 | |
d62a17ae | 7706 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7707 | if (!peer) | |
7708 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7709 | |
d62a17ae | 7710 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7711 | |
d62a17ae | 7712 | return bgp_vty_return(vty, ret); |
718e3744 | 7713 | } |
7714 | ||
7715 | DEFUN (neighbor_unsuppress_map, | |
7716 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7717 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7718 | NEIGHBOR_STR |
7719 | NEIGHBOR_ADDR_STR2 | |
7720 | "Route-map to selectively unsuppress suppressed routes\n" | |
7721 | "Name of route map\n") | |
7722 | { | |
d62a17ae | 7723 | int idx_peer = 1; |
7724 | int idx_word = 3; | |
7725 | return peer_unsuppress_map_set_vty( | |
7726 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7727 | argv[idx_word]->arg); | |
718e3744 | 7728 | } |
7729 | ||
d62a17ae | 7730 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7731 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7732 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7733 | "Route-map to selectively unsuppress suppressed routes\n" | |
7734 | "Name of route map\n") | |
596c17ba | 7735 | |
718e3744 | 7736 | DEFUN (no_neighbor_unsuppress_map, |
7737 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7738 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7739 | NO_STR |
7740 | NEIGHBOR_STR | |
7741 | NEIGHBOR_ADDR_STR2 | |
7742 | "Route-map to selectively unsuppress suppressed routes\n" | |
7743 | "Name of route map\n") | |
7744 | { | |
d62a17ae | 7745 | int idx_peer = 2; |
7746 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7747 | bgp_node_afi(vty), | |
7748 | bgp_node_safi(vty)); | |
718e3744 | 7749 | } |
6b0655a2 | 7750 | |
d62a17ae | 7751 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
7752 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7753 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7754 | "Route-map to selectively unsuppress suppressed routes\n" | |
7755 | "Name of route map\n") | |
596c17ba | 7756 | |
7e62b792 IR |
7757 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
7758 | afi_t afi, safi_t safi, | |
7759 | const char *num_str, | |
7760 | const char *threshold_str, int warning, | |
7761 | const char *restart_str, | |
7762 | const char *force_str) | |
7763 | { | |
7764 | int ret; | |
7765 | struct peer *peer; | |
7766 | uint32_t max; | |
7767 | uint8_t threshold; | |
7768 | uint16_t restart; | |
7769 | ||
7770 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7771 | if (!peer) | |
7772 | return CMD_WARNING_CONFIG_FAILED; | |
7773 | ||
7774 | max = strtoul(num_str, NULL, 10); | |
7775 | if (threshold_str) | |
7776 | threshold = atoi(threshold_str); | |
7777 | else | |
7778 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
7779 | ||
7780 | if (restart_str) | |
7781 | restart = atoi(restart_str); | |
7782 | else | |
7783 | restart = 0; | |
7784 | ||
7785 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, | |
7786 | restart, force_str ? true : false); | |
7787 | ||
7788 | return bgp_vty_return(vty, ret); | |
7789 | } | |
7790 | ||
7791 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, | |
7792 | afi_t afi, safi_t safi) | |
7793 | { | |
7794 | int ret; | |
7795 | struct peer *peer; | |
7796 | ||
7797 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7798 | if (!peer) | |
7799 | return CMD_WARNING_CONFIG_FAILED; | |
7800 | ||
7801 | ret = peer_maximum_prefix_unset(peer, afi, safi); | |
7802 | ||
7803 | return bgp_vty_return(vty, ret); | |
7804 | } | |
7805 | ||
fde246e8 | 7806 | /* Maximum number of prefix to be sent to the neighbor. */ |
1d80f243 IR |
7807 | DEFUN(neighbor_maximum_prefix_out, |
7808 | neighbor_maximum_prefix_out_cmd, | |
7809 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7810 | NEIGHBOR_STR | |
7811 | NEIGHBOR_ADDR_STR2 | |
7812 | "Maximum number of prefixes to be sent to this peer\n" | |
7813 | "Maximum no. of prefix limit\n") | |
fde246e8 | 7814 | { |
80444d30 | 7815 | int ret; |
fde246e8 DA |
7816 | int idx_peer = 1; |
7817 | int idx_number = 3; | |
7e62b792 IR |
7818 | struct peer *peer; |
7819 | uint32_t max; | |
fde246e8 DA |
7820 | afi_t afi = bgp_node_afi(vty); |
7821 | safi_t safi = bgp_node_safi(vty); | |
7822 | ||
7e62b792 IR |
7823 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7824 | if (!peer) | |
fde246e8 DA |
7825 | return CMD_WARNING_CONFIG_FAILED; |
7826 | ||
7e62b792 | 7827 | max = strtoul(argv[idx_number]->arg, NULL, 10); |
fde246e8 | 7828 | |
80444d30 | 7829 | ret = peer_maximum_prefix_out_set(peer, afi, safi, max); |
fde246e8 | 7830 | |
80444d30 | 7831 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
7832 | } |
7833 | ||
1d80f243 IR |
7834 | DEFUN(no_neighbor_maximum_prefix_out, |
7835 | no_neighbor_maximum_prefix_out_cmd, | |
bc03c622 | 7836 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out [(1-4294967295)]", |
1d80f243 IR |
7837 | NO_STR |
7838 | NEIGHBOR_STR | |
7839 | NEIGHBOR_ADDR_STR2 | |
bc03c622 LS |
7840 | "Maximum number of prefixes to be sent to this peer\n" |
7841 | "Maximum no. of prefix limit\n") | |
fde246e8 | 7842 | { |
80444d30 | 7843 | int ret; |
fde246e8 | 7844 | int idx_peer = 2; |
7e62b792 | 7845 | struct peer *peer; |
fde246e8 DA |
7846 | afi_t afi = bgp_node_afi(vty); |
7847 | safi_t safi = bgp_node_safi(vty); | |
7848 | ||
7e62b792 IR |
7849 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7850 | if (!peer) | |
fde246e8 DA |
7851 | return CMD_WARNING_CONFIG_FAILED; |
7852 | ||
80444d30 | 7853 | ret = peer_maximum_prefix_out_unset(peer, afi, safi); |
fde246e8 | 7854 | |
80444d30 | 7855 | return bgp_vty_return(vty, ret); |
fde246e8 DA |
7856 | } |
7857 | ||
9cbd06e0 DA |
7858 | /* Maximum number of prefix configuration. Prefix count is different |
7859 | for each peer configuration. So this configuration can be set for | |
718e3744 | 7860 | each peer configuration. */ |
1d80f243 IR |
7861 | DEFUN (neighbor_maximum_prefix, |
7862 | neighbor_maximum_prefix_cmd, | |
7863 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", | |
7864 | NEIGHBOR_STR | |
7865 | NEIGHBOR_ADDR_STR2 | |
7866 | "Maximum number of prefix accept from this peer\n" | |
7867 | "maximum no. of prefix limit\n" | |
7868 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7869 | { |
d62a17ae | 7870 | int idx_peer = 1; |
7871 | int idx_number = 3; | |
9cbd06e0 | 7872 | int idx_force = 0; |
7e62b792 | 7873 | char *force = NULL; |
9cbd06e0 DA |
7874 | |
7875 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7876 | force = argv[idx_force]->arg; |
9cbd06e0 | 7877 | |
7e62b792 IR |
7878 | return peer_maximum_prefix_set_vty( |
7879 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7880 | argv[idx_number]->arg, NULL, 0, NULL, force); | |
718e3744 | 7881 | } |
7882 | ||
d62a17ae | 7883 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 7884 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 7885 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7886 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7887 | "maximum no. of prefix limit\n" |
7888 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7889 | |
1d80f243 IR |
7890 | DEFUN (neighbor_maximum_prefix_threshold, |
7891 | neighbor_maximum_prefix_threshold_cmd, | |
7892 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", | |
7893 | NEIGHBOR_STR | |
7894 | NEIGHBOR_ADDR_STR2 | |
7895 | "Maximum number of prefix accept from this peer\n" | |
7896 | "maximum no. of prefix limit\n" | |
7897 | "Threshold value (%) at which to generate a warning msg\n" | |
7898 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7899 | { |
d62a17ae | 7900 | int idx_peer = 1; |
7901 | int idx_number = 3; | |
7902 | int idx_number_2 = 4; | |
9cbd06e0 | 7903 | int idx_force = 0; |
7e62b792 | 7904 | char *force = NULL; |
9cbd06e0 DA |
7905 | |
7906 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7907 | force = argv[idx_force]->arg; |
9cbd06e0 | 7908 | |
7e62b792 IR |
7909 | return peer_maximum_prefix_set_vty( |
7910 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7911 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); | |
0a486e5f | 7912 | } |
e0701b79 | 7913 | |
d62a17ae | 7914 | ALIAS_HIDDEN( |
7915 | neighbor_maximum_prefix_threshold, | |
7916 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 7917 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 7918 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7919 | "Maximum number of prefix accept from this peer\n" | |
7920 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7921 | "Threshold value (%) at which to generate a warning msg\n" |
7922 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7923 | |
1d80f243 IR |
7924 | DEFUN (neighbor_maximum_prefix_warning, |
7925 | neighbor_maximum_prefix_warning_cmd, | |
7926 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", | |
7927 | NEIGHBOR_STR | |
7928 | NEIGHBOR_ADDR_STR2 | |
7929 | "Maximum number of prefix accept from this peer\n" | |
7930 | "maximum no. of prefix limit\n" | |
7931 | "Only give warning message when limit is exceeded\n" | |
7932 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7933 | { |
d62a17ae | 7934 | int idx_peer = 1; |
7935 | int idx_number = 3; | |
9cbd06e0 | 7936 | int idx_force = 0; |
7e62b792 | 7937 | char *force = NULL; |
9cbd06e0 DA |
7938 | |
7939 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7940 | force = argv[idx_force]->arg; |
9cbd06e0 | 7941 | |
7e62b792 IR |
7942 | return peer_maximum_prefix_set_vty( |
7943 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7944 | argv[idx_number]->arg, NULL, 1, NULL, force); | |
718e3744 | 7945 | } |
7946 | ||
d62a17ae | 7947 | ALIAS_HIDDEN( |
7948 | neighbor_maximum_prefix_warning, | |
7949 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 7950 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 7951 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7952 | "Maximum number of prefix accept from this peer\n" | |
7953 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7954 | "Only give warning message when limit is exceeded\n" |
7955 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7956 | |
1d80f243 IR |
7957 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
7958 | neighbor_maximum_prefix_threshold_warning_cmd, | |
7959 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", | |
7960 | NEIGHBOR_STR | |
7961 | NEIGHBOR_ADDR_STR2 | |
7962 | "Maximum number of prefix accept from this peer\n" | |
7963 | "maximum no. of prefix limit\n" | |
7964 | "Threshold value (%) at which to generate a warning msg\n" | |
7965 | "Only give warning message when limit is exceeded\n" | |
7966 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7967 | { |
d62a17ae | 7968 | int idx_peer = 1; |
7969 | int idx_number = 3; | |
7970 | int idx_number_2 = 4; | |
9cbd06e0 | 7971 | int idx_force = 0; |
7e62b792 | 7972 | char *force = NULL; |
9cbd06e0 DA |
7973 | |
7974 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 7975 | force = argv[idx_force]->arg; |
9cbd06e0 | 7976 | |
7e62b792 IR |
7977 | return peer_maximum_prefix_set_vty( |
7978 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7979 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); | |
0a486e5f | 7980 | } |
7981 | ||
d62a17ae | 7982 | ALIAS_HIDDEN( |
7983 | neighbor_maximum_prefix_threshold_warning, | |
7984 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 7985 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 7986 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7987 | "Maximum number of prefix accept from this peer\n" | |
7988 | "maximum no. of prefix limit\n" | |
7989 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7990 | "Only give warning message when limit is exceeded\n" |
7991 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7992 | |
1d80f243 IR |
7993 | DEFUN (neighbor_maximum_prefix_restart, |
7994 | neighbor_maximum_prefix_restart_cmd, | |
7995 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", | |
7996 | NEIGHBOR_STR | |
7997 | NEIGHBOR_ADDR_STR2 | |
7998 | "Maximum number of prefix accept from this peer\n" | |
7999 | "maximum no. of prefix limit\n" | |
8000 | "Restart bgp connection after limit is exceeded\n" | |
8001 | "Restart interval in minutes\n" | |
8002 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8003 | { |
d62a17ae | 8004 | int idx_peer = 1; |
8005 | int idx_number = 3; | |
8006 | int idx_number_2 = 5; | |
9cbd06e0 | 8007 | int idx_force = 0; |
7e62b792 | 8008 | char *force = NULL; |
9cbd06e0 DA |
8009 | |
8010 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8011 | force = argv[idx_force]->arg; |
9cbd06e0 | 8012 | |
7e62b792 IR |
8013 | return peer_maximum_prefix_set_vty( |
8014 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8015 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); | |
0a486e5f | 8016 | } |
8017 | ||
d62a17ae | 8018 | ALIAS_HIDDEN( |
8019 | neighbor_maximum_prefix_restart, | |
8020 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 8021 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 8022 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8023 | "Maximum number of prefix accept from this peer\n" | |
8024 | "maximum no. of prefix limit\n" | |
8025 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8026 | "Restart interval in minutes\n" |
8027 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8028 | |
1d80f243 IR |
8029 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
8030 | neighbor_maximum_prefix_threshold_restart_cmd, | |
8031 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", | |
8032 | NEIGHBOR_STR | |
8033 | NEIGHBOR_ADDR_STR2 | |
8034 | "Maximum number of prefixes to accept from this peer\n" | |
8035 | "maximum no. of prefix limit\n" | |
8036 | "Threshold value (%) at which to generate a warning msg\n" | |
8037 | "Restart bgp connection after limit is exceeded\n" | |
8038 | "Restart interval in minutes\n" | |
8039 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 8040 | { |
d62a17ae | 8041 | int idx_peer = 1; |
8042 | int idx_number = 3; | |
8043 | int idx_number_2 = 4; | |
8044 | int idx_number_3 = 6; | |
9cbd06e0 | 8045 | int idx_force = 0; |
7e62b792 | 8046 | char *force = NULL; |
9cbd06e0 DA |
8047 | |
8048 | if (argv_find(argv, argc, "force", &idx_force)) | |
7e62b792 | 8049 | force = argv[idx_force]->arg; |
9cbd06e0 | 8050 | |
7e62b792 IR |
8051 | return peer_maximum_prefix_set_vty( |
8052 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
8053 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
8054 | argv[idx_number_3]->arg, force); | |
d62a17ae | 8055 | } |
8056 | ||
8057 | ALIAS_HIDDEN( | |
8058 | neighbor_maximum_prefix_threshold_restart, | |
8059 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 8060 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 8061 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8062 | "Maximum number of prefixes to accept from this peer\n" | |
8063 | "maximum no. of prefix limit\n" | |
8064 | "Threshold value (%) at which to generate a warning msg\n" | |
8065 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
8066 | "Restart interval in minutes\n" |
8067 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8068 | |
1d80f243 IR |
8069 | DEFUN (no_neighbor_maximum_prefix, |
8070 | no_neighbor_maximum_prefix_cmd, | |
8071 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", | |
8072 | NO_STR | |
8073 | NEIGHBOR_STR | |
8074 | NEIGHBOR_ADDR_STR2 | |
8075 | "Maximum number of prefixes to accept from this peer\n" | |
8076 | "maximum no. of prefix limit\n" | |
8077 | "Threshold value (%) at which to generate a warning msg\n" | |
8078 | "Restart bgp connection after limit is exceeded\n" | |
8079 | "Restart interval in minutes\n" | |
8080 | "Only give warning message when limit is exceeded\n" | |
8081 | "Force checking all received routes not only accepted\n") | |
718e3744 | 8082 | { |
d62a17ae | 8083 | int idx_peer = 2; |
7e62b792 IR |
8084 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, |
8085 | bgp_node_afi(vty), | |
8086 | bgp_node_safi(vty)); | |
718e3744 | 8087 | } |
e52702f2 | 8088 | |
d62a17ae | 8089 | ALIAS_HIDDEN( |
8090 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 8091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 8092 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
8093 | "Maximum number of prefixes to accept from this peer\n" | |
8094 | "maximum no. of prefix limit\n" | |
8095 | "Threshold value (%) at which to generate a warning msg\n" | |
8096 | "Restart bgp connection after limit is exceeded\n" | |
8097 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
8098 | "Only give warning message when limit is exceeded\n" |
8099 | "Force checking all received routes not only accepted\n") | |
596c17ba | 8100 | |
718e3744 | 8101 | |
718e3744 | 8102 | /* "neighbor allowas-in" */ |
8103 | DEFUN (neighbor_allowas_in, | |
8104 | neighbor_allowas_in_cmd, | |
fd8503f5 | 8105 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8106 | NEIGHBOR_STR |
8107 | NEIGHBOR_ADDR_STR2 | |
31500417 | 8108 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 8109 | "Number of occurrences of AS number\n" |
fd8503f5 | 8110 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8111 | { |
d62a17ae | 8112 | int idx_peer = 1; |
8113 | int idx_number_origin = 3; | |
8114 | int ret; | |
8115 | int origin = 0; | |
8116 | struct peer *peer; | |
8117 | int allow_num = 0; | |
8118 | ||
8119 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8120 | if (!peer) | |
8121 | return CMD_WARNING_CONFIG_FAILED; | |
8122 | ||
8123 | if (argc <= idx_number_origin) | |
8124 | allow_num = 3; | |
8125 | else { | |
8126 | if (argv[idx_number_origin]->type == WORD_TKN) | |
8127 | origin = 1; | |
8128 | else | |
8129 | allow_num = atoi(argv[idx_number_origin]->arg); | |
8130 | } | |
8131 | ||
8132 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8133 | allow_num, origin); | |
8134 | ||
8135 | return bgp_vty_return(vty, ret); | |
8136 | } | |
8137 | ||
8138 | ALIAS_HIDDEN( | |
8139 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
8140 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8141 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8142 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 8143 | "Number of occurrences of AS number\n" |
d62a17ae | 8144 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8145 | |
718e3744 | 8146 | DEFUN (no_neighbor_allowas_in, |
8147 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 8148 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 8149 | NO_STR |
8150 | NEIGHBOR_STR | |
8151 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 8152 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 8153 | "Number of occurrences of AS number\n" |
fd8503f5 | 8154 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 8155 | { |
d62a17ae | 8156 | int idx_peer = 2; |
8157 | int ret; | |
8158 | struct peer *peer; | |
718e3744 | 8159 | |
d62a17ae | 8160 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8161 | if (!peer) | |
8162 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 8163 | |
d62a17ae | 8164 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
8165 | bgp_node_safi(vty)); | |
718e3744 | 8166 | |
d62a17ae | 8167 | return bgp_vty_return(vty, ret); |
718e3744 | 8168 | } |
6b0655a2 | 8169 | |
d62a17ae | 8170 | ALIAS_HIDDEN( |
8171 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
8172 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
8173 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8174 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 8175 | "Number of occurrences of AS number\n" |
d62a17ae | 8176 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 8177 | |
28c6e247 IR |
8178 | DEFUN (neighbor_ttl_security, |
8179 | neighbor_ttl_security_cmd, | |
8180 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8181 | NEIGHBOR_STR | |
8182 | NEIGHBOR_ADDR_STR2 | |
8183 | "BGP ttl-security parameters\n" | |
8184 | "Specify the maximum number of hops to the BGP peer\n" | |
8185 | "Number of hops to BGP peer\n") | |
fa411a21 | 8186 | { |
d62a17ae | 8187 | int idx_peer = 1; |
8188 | int idx_number = 4; | |
28c6e247 IR |
8189 | struct peer *peer; |
8190 | int gtsm_hops; | |
d62a17ae | 8191 | |
28c6e247 IR |
8192 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8193 | if (!peer) | |
d62a17ae | 8194 | return CMD_WARNING_CONFIG_FAILED; |
8195 | ||
28c6e247 IR |
8196 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); |
8197 | ||
8198 | /* | |
8199 | * If 'neighbor swpX', then this is for directly connected peers, | |
8200 | * we should not accept a ttl-security hops value greater than 1. | |
8201 | */ | |
8202 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { | |
8203 | vty_out(vty, | |
8204 | "%s is directly connected peer, hops cannot exceed 1\n", | |
8205 | argv[idx_peer]->arg); | |
8206 | return CMD_WARNING_CONFIG_FAILED; | |
8207 | } | |
7ebe625c | 8208 | |
28c6e247 | 8209 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
8210 | } |
8211 | ||
1d80f243 IR |
8212 | DEFUN (no_neighbor_ttl_security, |
8213 | no_neighbor_ttl_security_cmd, | |
8214 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", | |
8215 | NO_STR | |
8216 | NEIGHBOR_STR | |
8217 | NEIGHBOR_ADDR_STR2 | |
8218 | "BGP ttl-security parameters\n" | |
8219 | "Specify the maximum number of hops to the BGP peer\n" | |
8220 | "Number of hops to BGP peer\n") | |
fa411a21 | 8221 | { |
d62a17ae | 8222 | int idx_peer = 2; |
28c6e247 | 8223 | struct peer *peer; |
fa411a21 | 8224 | |
28c6e247 IR |
8225 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8226 | if (!peer) | |
d62a17ae | 8227 | return CMD_WARNING_CONFIG_FAILED; |
fa411a21 | 8228 | |
28c6e247 | 8229 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 8230 | } |
6b0655a2 | 8231 | |
7c0e4312 DA |
8232 | /* disable-addpath-rx */ |
8233 | DEFUN(neighbor_disable_addpath_rx, | |
8234 | neighbor_disable_addpath_rx_cmd, | |
8235 | "neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8236 | NEIGHBOR_STR | |
8237 | NEIGHBOR_ADDR_STR2 | |
8238 | "Do not accept additional paths\n") | |
8239 | { | |
8240 | char *peer_str = argv[1]->arg; | |
8241 | struct peer *peer; | |
8242 | afi_t afi = bgp_node_afi(vty); | |
8243 | safi_t safi = bgp_node_safi(vty); | |
8244 | ||
8245 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8246 | if (!peer) | |
8247 | return CMD_WARNING_CONFIG_FAILED; | |
8248 | ||
8249 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
8250 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8251 | } | |
8252 | ||
8253 | DEFUN(no_neighbor_disable_addpath_rx, | |
8254 | no_neighbor_disable_addpath_rx_cmd, | |
8255 | "no neighbor <A.B.C.D|X:X::X:X|WORD> disable-addpath-rx", | |
8256 | NO_STR | |
8257 | NEIGHBOR_STR | |
8258 | NEIGHBOR_ADDR_STR2 | |
8259 | "Do not accept additional paths\n") | |
8260 | { | |
8261 | char *peer_str = argv[2]->arg; | |
8262 | struct peer *peer; | |
8263 | afi_t afi = bgp_node_afi(vty); | |
8264 | safi_t safi = bgp_node_safi(vty); | |
8265 | ||
8266 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
8267 | if (!peer) | |
8268 | return CMD_WARNING_CONFIG_FAILED; | |
8269 | ||
8270 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
8271 | PEER_FLAG_DISABLE_ADDPATH_RX); | |
8272 | } | |
8273 | ||
adbac85e DW |
8274 | DEFUN (neighbor_addpath_tx_all_paths, |
8275 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8276 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8277 | NEIGHBOR_STR |
8278 | NEIGHBOR_ADDR_STR2 | |
8279 | "Use addpath to advertise all paths to a neighbor\n") | |
8280 | { | |
d62a17ae | 8281 | int idx_peer = 1; |
8282 | struct peer *peer; | |
adbac85e | 8283 | |
d62a17ae | 8284 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8285 | if (!peer) | |
8286 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 8287 | |
dcc68b5e MS |
8288 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8289 | BGP_ADDPATH_ALL); | |
8290 | return CMD_SUCCESS; | |
adbac85e DW |
8291 | } |
8292 | ||
d62a17ae | 8293 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
8294 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
8295 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8296 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8297 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8298 | |
adbac85e DW |
8299 | DEFUN (no_neighbor_addpath_tx_all_paths, |
8300 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 8301 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
8302 | NO_STR |
8303 | NEIGHBOR_STR | |
8304 | NEIGHBOR_ADDR_STR2 | |
8305 | "Use addpath to advertise all paths to a neighbor\n") | |
8306 | { | |
d62a17ae | 8307 | int idx_peer = 2; |
dcc68b5e MS |
8308 | struct peer *peer; |
8309 | ||
8310 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8311 | if (!peer) | |
8312 | return CMD_WARNING_CONFIG_FAILED; | |
8313 | ||
8314 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8315 | != BGP_ADDPATH_ALL) { | |
8316 | vty_out(vty, | |
8317 | "%% Peer not currently configured to transmit all paths."); | |
8318 | return CMD_WARNING_CONFIG_FAILED; | |
8319 | } | |
8320 | ||
8321 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8322 | BGP_ADDPATH_NONE); | |
8323 | ||
8324 | return CMD_SUCCESS; | |
adbac85e DW |
8325 | } |
8326 | ||
d62a17ae | 8327 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
8328 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
8329 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
8330 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8331 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 8332 | |
06370dac DW |
8333 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
8334 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8335 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8336 | NEIGHBOR_STR |
8337 | NEIGHBOR_ADDR_STR2 | |
8338 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8339 | { | |
d62a17ae | 8340 | int idx_peer = 1; |
8341 | struct peer *peer; | |
06370dac | 8342 | |
d62a17ae | 8343 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
8344 | if (!peer) | |
8345 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 8346 | |
dcc68b5e MS |
8347 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
8348 | BGP_ADDPATH_BEST_PER_AS); | |
8349 | ||
8350 | return CMD_SUCCESS; | |
06370dac DW |
8351 | } |
8352 | ||
d62a17ae | 8353 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
8354 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8355 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8356 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8357 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8358 | |
06370dac DW |
8359 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
8360 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 8361 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
8362 | NO_STR |
8363 | NEIGHBOR_STR | |
8364 | NEIGHBOR_ADDR_STR2 | |
8365 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
8366 | { | |
d62a17ae | 8367 | int idx_peer = 2; |
dcc68b5e MS |
8368 | struct peer *peer; |
8369 | ||
8370 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
8371 | if (!peer) | |
8372 | return CMD_WARNING_CONFIG_FAILED; | |
8373 | ||
8374 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
8375 | != BGP_ADDPATH_BEST_PER_AS) { | |
8376 | vty_out(vty, | |
8377 | "%% Peer not currently configured to transmit all best path per as."); | |
8378 | return CMD_WARNING_CONFIG_FAILED; | |
8379 | } | |
8380 | ||
8381 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
8382 | BGP_ADDPATH_NONE); | |
8383 | ||
8384 | return CMD_SUCCESS; | |
06370dac DW |
8385 | } |
8386 | ||
d62a17ae | 8387 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
8388 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
8389 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
8390 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
8391 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 8392 | |
2b31007c RZ |
8393 | DEFPY( |
8394 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
8395 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8396 | NEIGHBOR_STR | |
8397 | NEIGHBOR_ADDR_STR2 | |
8398 | "Detect AS loops before sending to neighbor\n") | |
8399 | { | |
8400 | struct peer *peer; | |
8401 | ||
8402 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8403 | if (!peer) | |
8404 | return CMD_WARNING_CONFIG_FAILED; | |
8405 | ||
8406 | peer->as_path_loop_detection = true; | |
8407 | ||
8408 | return CMD_SUCCESS; | |
8409 | } | |
8410 | ||
8411 | DEFPY( | |
8412 | no_neighbor_aspath_loop_detection, | |
8413 | no_neighbor_aspath_loop_detection_cmd, | |
8414 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
8415 | NO_STR | |
8416 | NEIGHBOR_STR | |
8417 | NEIGHBOR_ADDR_STR2 | |
8418 | "Detect AS loops before sending to neighbor\n") | |
8419 | { | |
8420 | struct peer *peer; | |
8421 | ||
8422 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
8423 | if (!peer) | |
8424 | return CMD_WARNING_CONFIG_FAILED; | |
8425 | ||
8426 | peer->as_path_loop_detection = false; | |
8427 | ||
8428 | return CMD_SUCCESS; | |
8429 | } | |
8430 | ||
b9c7bc5a | 8431 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 8432 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 8433 | { |
b9c7bc5a PZ |
8434 | struct ecommunity *ecom = NULL; |
8435 | struct ecommunity *ecomadd; | |
ddb5b488 | 8436 | |
b9c7bc5a | 8437 | for (; argc; --argc, ++argv) { |
9a659715 PG |
8438 | if (is_rt6) |
8439 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
8440 | ECOMMUNITY_ROUTE_TARGET, | |
8441 | 0); | |
8442 | else | |
8443 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
8444 | ECOMMUNITY_ROUTE_TARGET, | |
8445 | 0); | |
b9c7bc5a PZ |
8446 | if (!ecomadd) { |
8447 | vty_out(vty, "Malformed community-list value\n"); | |
8448 | if (ecom) | |
8449 | ecommunity_free(&ecom); | |
8450 | return CMD_WARNING_CONFIG_FAILED; | |
8451 | } | |
ddb5b488 | 8452 | |
b9c7bc5a PZ |
8453 | if (ecom) { |
8454 | ecommunity_merge(ecom, ecomadd); | |
8455 | ecommunity_free(&ecomadd); | |
8456 | } else { | |
8457 | ecom = ecomadd; | |
8458 | } | |
8459 | } | |
8460 | ||
8461 | if (*list) { | |
8462 | ecommunity_free(&*list); | |
ddb5b488 | 8463 | } |
b9c7bc5a PZ |
8464 | *list = ecom; |
8465 | ||
8466 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8467 | } |
8468 | ||
0ca70ba5 DS |
8469 | /* |
8470 | * v2vimport is true if we are handling a `import vrf ...` command | |
8471 | */ | |
8472 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8473 | { |
0ca70ba5 DS |
8474 | afi_t afi; |
8475 | ||
ddb5b488 | 8476 | switch (vty->node) { |
b9c7bc5a | 8477 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8478 | afi = AFI_IP; |
8479 | break; | |
b9c7bc5a | 8480 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8481 | afi = AFI_IP6; |
8482 | break; | |
ddb5b488 PZ |
8483 | default: |
8484 | vty_out(vty, | |
b9c7bc5a | 8485 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8486 | return AFI_MAX; |
ddb5b488 | 8487 | } |
69b07479 | 8488 | |
0ca70ba5 DS |
8489 | if (!v2vimport) { |
8490 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8491 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8492 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8493 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8494 | vty_out(vty, | |
8495 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8496 | return AFI_MAX; | |
8497 | } | |
8498 | } else { | |
8499 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8500 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8501 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8502 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8503 | vty_out(vty, | |
8504 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8505 | return AFI_MAX; | |
8506 | } | |
8507 | } | |
8508 | return afi; | |
ddb5b488 PZ |
8509 | } |
8510 | ||
585f1adc IR |
8511 | DEFPY (af_rd_vpn_export, |
8512 | af_rd_vpn_export_cmd, | |
8513 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8514 | NO_STR | |
8515 | "Specify route distinguisher\n" | |
8516 | "Between current address-family and vpn\n" | |
8517 | "For routes leaked from current address-family to vpn\n" | |
8518 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") | |
ddb5b488 | 8519 | { |
585f1adc IR |
8520 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8521 | struct prefix_rd prd; | |
8522 | int ret; | |
ddb5b488 | 8523 | afi_t afi; |
b9c7bc5a | 8524 | int idx = 0; |
585f1adc | 8525 | bool yes = true; |
b9c7bc5a | 8526 | |
585f1adc IR |
8527 | if (argv_find(argv, argc, "no", &idx)) |
8528 | yes = false; | |
ddb5b488 | 8529 | |
585f1adc IR |
8530 | if (yes) { |
8531 | ret = str2prefix_rd(rd_str, &prd); | |
8532 | if (!ret) { | |
8533 | vty_out(vty, "%% Malformed rd\n"); | |
8534 | return CMD_WARNING_CONFIG_FAILED; | |
8535 | } | |
8536 | } | |
ddb5b488 | 8537 | |
585f1adc IR |
8538 | afi = vpn_policy_getafi(vty, bgp, false); |
8539 | if (afi == AFI_MAX) | |
8540 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8541 | |
585f1adc IR |
8542 | /* |
8543 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8544 | */ | |
8545 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8546 | bgp_get_default(), bgp); | |
ddb5b488 | 8547 | |
585f1adc IR |
8548 | if (yes) { |
8549 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8550 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8551 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8552 | } else { | |
8553 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8554 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8555 | } | |
69b07479 | 8556 | |
585f1adc IR |
8557 | /* post-change: re-export vpn routes */ |
8558 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8559 | bgp_get_default(), bgp); | |
8560 | ||
8561 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8562 | } |
8563 | ||
b9c7bc5a PZ |
8564 | ALIAS (af_rd_vpn_export, |
8565 | af_no_rd_vpn_export_cmd, | |
8566 | "no rd vpn export", | |
ddb5b488 | 8567 | NO_STR |
b9c7bc5a PZ |
8568 | "Specify route distinguisher\n" |
8569 | "Between current address-family and vpn\n" | |
8570 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8571 | |
b9c7bc5a PZ |
8572 | DEFPY (af_label_vpn_export, |
8573 | af_label_vpn_export_cmd, | |
e70e9f8e | 8574 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8575 | NO_STR |
ddb5b488 | 8576 | "label value for VRF\n" |
b9c7bc5a PZ |
8577 | "Between current address-family and vpn\n" |
8578 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8579 | "Label Value <0-1048575>\n" |
8580 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8581 | { |
8582 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8583 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8584 | afi_t afi; |
b9c7bc5a | 8585 | int idx = 0; |
c6423c31 | 8586 | bool yes = true; |
b9c7bc5a PZ |
8587 | |
8588 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8589 | yes = false; |
ddb5b488 | 8590 | |
21a16cc2 PZ |
8591 | /* If "no ...", squash trailing parameter */ |
8592 | if (!yes) | |
8593 | label_auto = NULL; | |
8594 | ||
e70e9f8e PZ |
8595 | if (yes) { |
8596 | if (!label_auto) | |
8597 | label = label_val; /* parser should force unsigned */ | |
8598 | } | |
ddb5b488 | 8599 | |
0ca70ba5 | 8600 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8601 | if (afi == AFI_MAX) |
8602 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8603 | |
e70e9f8e | 8604 | |
69b07479 DS |
8605 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8606 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8607 | /* no change */ | |
8608 | return CMD_SUCCESS; | |
e70e9f8e | 8609 | |
69b07479 DS |
8610 | /* |
8611 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8612 | */ | |
8613 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8614 | bgp_get_default(), bgp); | |
8615 | ||
8616 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8617 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8618 | ||
8619 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8620 | ||
8621 | /* | |
8622 | * label has previously been automatically | |
8623 | * assigned by labelpool: release it | |
8624 | * | |
8625 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8626 | * means the automatic assignment is in flight | |
8627 | * and therefore the labelpool callback must | |
8628 | * detect that the auto label is not needed. | |
8629 | */ | |
8630 | ||
8631 | bgp_lp_release(LP_TYPE_VRF, | |
8632 | &bgp->vpn_policy[afi], | |
8633 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8634 | } |
69b07479 DS |
8635 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8636 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8637 | } | |
ddb5b488 | 8638 | |
69b07479 DS |
8639 | bgp->vpn_policy[afi].tovpn_label = label; |
8640 | if (label_auto) { | |
8641 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8642 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8643 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8644 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8645 | } |
8646 | ||
69b07479 DS |
8647 | /* post-change: re-export vpn routes */ |
8648 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8649 | bgp_get_default(), bgp); | |
8650 | ||
0d020cd6 | 8651 | hook_call(bgp_snmp_update_last_changed, bgp); |
ddb5b488 PZ |
8652 | return CMD_SUCCESS; |
8653 | } | |
8654 | ||
b72c9e14 HS |
8655 | DEFPY (af_sid_vpn_export, |
8656 | af_sid_vpn_export_cmd, | |
8657 | "[no] sid vpn export <(1-255)$sid_idx|auto$sid_auto>", | |
8658 | NO_STR | |
8659 | "sid value for VRF\n" | |
8660 | "Between current address-family and vpn\n" | |
8661 | "For routes leaked from current address-family to vpn\n" | |
8662 | "Sid allocation index\n" | |
8663 | "Automatically assign a label\n") | |
8664 | { | |
8665 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8666 | afi_t afi; | |
8667 | int debug = 0; | |
8668 | int idx = 0; | |
8669 | bool yes = true; | |
8670 | ||
8671 | if (argv_find(argv, argc, "no", &idx)) | |
8672 | yes = false; | |
8673 | debug = (BGP_DEBUG(vpn, VPN_LEAK_TO_VRF) | | |
8674 | BGP_DEBUG(vpn, VPN_LEAK_FROM_VRF)); | |
8675 | ||
8676 | afi = vpn_policy_getafi(vty, bgp, false); | |
8677 | if (afi == AFI_MAX) | |
8678 | return CMD_WARNING_CONFIG_FAILED; | |
8679 | ||
8680 | if (!yes) { | |
8681 | /* implement me */ | |
4d4c404b | 8682 | vty_out(vty, "It's not implemented\n"); |
b72c9e14 HS |
8683 | return CMD_WARNING_CONFIG_FAILED; |
8684 | } | |
8685 | ||
8686 | /* skip when it's already configured */ | |
8687 | if ((sid_idx != 0 && bgp->vpn_policy[afi].tovpn_sid_index != 0) | |
8688 | || (sid_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8689 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) | |
8690 | return CMD_SUCCESS; | |
8691 | ||
7de4c885 HS |
8692 | /* |
8693 | * mode change between sid_idx and sid_auto isn't supported. | |
8694 | * user must negate sid vpn export when they want to change the mode | |
8695 | */ | |
b72c9e14 HS |
8696 | if ((sid_auto && bgp->vpn_policy[afi].tovpn_sid_index != 0) |
8697 | || (sid_idx != 0 && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8698 | BGP_VPN_POLICY_TOVPN_SID_AUTO))) { | |
8699 | vty_out(vty, "it's already configured as %s.\n", | |
8700 | sid_auto ? "auto-mode" : "idx-mode"); | |
8701 | return CMD_WARNING_CONFIG_FAILED; | |
8702 | } | |
8703 | ||
8704 | /* pre-change */ | |
8705 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8706 | bgp_get_default(), bgp); | |
8707 | ||
8708 | if (sid_auto) { | |
8709 | /* SID allocation auto-mode */ | |
8710 | if (debug) | |
8711 | zlog_debug("%s: auto sid alloc.", __func__); | |
8712 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8713 | BGP_VPN_POLICY_TOVPN_SID_AUTO); | |
8714 | } else { | |
8715 | /* SID allocation index-mode */ | |
8716 | if (debug) | |
8717 | zlog_debug("%s: idx %ld sid alloc.", __func__, sid_idx); | |
8718 | bgp->vpn_policy[afi].tovpn_sid_index = sid_idx; | |
8719 | } | |
8720 | ||
8721 | /* post-change */ | |
8722 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8723 | bgp_get_default(), bgp); | |
8724 | return CMD_SUCCESS; | |
8725 | } | |
8726 | ||
b9c7bc5a PZ |
8727 | ALIAS (af_label_vpn_export, |
8728 | af_no_label_vpn_export_cmd, | |
8729 | "no label vpn export", | |
8730 | NO_STR | |
8731 | "label value for VRF\n" | |
8732 | "Between current address-family and vpn\n" | |
8733 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8734 | |
585f1adc | 8735 | DEFPY (af_nexthop_vpn_export, |
b9c7bc5a | 8736 | af_nexthop_vpn_export_cmd, |
8c85ca28 | 8737 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 8738 | NO_STR |
ddb5b488 | 8739 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
8740 | "Between current address-family and vpn\n" |
8741 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8742 | "IPv4 prefix\n" |
8743 | "IPv6 prefix\n") | |
8744 | { | |
585f1adc | 8745 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
ddb5b488 | 8746 | afi_t afi; |
ddb5b488 PZ |
8747 | struct prefix p; |
8748 | ||
8c85ca28 QY |
8749 | if (!no) { |
8750 | if (!nexthop_su) { | |
8751 | vty_out(vty, "%% Nexthop required\n"); | |
8752 | return CMD_WARNING_CONFIG_FAILED; | |
8753 | } | |
8c85ca28 | 8754 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
8755 | return CMD_WARNING_CONFIG_FAILED; |
8756 | } | |
ddb5b488 | 8757 | |
585f1adc IR |
8758 | afi = vpn_policy_getafi(vty, bgp, false); |
8759 | if (afi == AFI_MAX) | |
8760 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8761 | |
585f1adc IR |
8762 | /* |
8763 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8764 | */ | |
8765 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8766 | bgp_get_default(), bgp); | |
ddb5b488 | 8767 | |
585f1adc IR |
8768 | if (!no) { |
8769 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
8770 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8771 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8772 | } else { | |
8773 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8774 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8775 | } | |
69b07479 | 8776 | |
585f1adc IR |
8777 | /* post-change: re-export vpn routes */ |
8778 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8779 | bgp_get_default(), bgp); | |
37a87b8f | 8780 | |
585f1adc | 8781 | return CMD_SUCCESS; |
ddb5b488 PZ |
8782 | } |
8783 | ||
b9c7bc5a | 8784 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 8785 | { |
b9c7bc5a PZ |
8786 | if (!strcmp(dstr, "import")) { |
8787 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8788 | } else if (!strcmp(dstr, "export")) { | |
8789 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8790 | } else if (!strcmp(dstr, "both")) { | |
8791 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8792 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8793 | } else { | |
8794 | vty_out(vty, "%% direction parse error\n"); | |
8795 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8796 | } |
ddb5b488 PZ |
8797 | return CMD_SUCCESS; |
8798 | } | |
8799 | ||
b9c7bc5a PZ |
8800 | DEFPY (af_rt_vpn_imexport, |
8801 | af_rt_vpn_imexport_cmd, | |
8802 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8803 | NO_STR | |
8804 | "Specify route target list\n" | |
ddb5b488 | 8805 | "Specify route target list\n" |
b9c7bc5a PZ |
8806 | "Between current address-family and vpn\n" |
8807 | "For routes leaked from vpn to current address-family: match any\n" | |
8808 | "For routes leaked from current address-family to vpn: set\n" | |
8809 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
8810 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
8811 | { | |
8812 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8813 | int ret; | |
8814 | struct ecommunity *ecom = NULL; | |
8815 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 8816 | enum vpn_policy_direction dir; |
ddb5b488 PZ |
8817 | afi_t afi; |
8818 | int idx = 0; | |
c6423c31 | 8819 | bool yes = true; |
ddb5b488 | 8820 | |
b9c7bc5a | 8821 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8822 | yes = false; |
b9c7bc5a | 8823 | |
0ca70ba5 | 8824 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8825 | if (afi == AFI_MAX) |
8826 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8827 | |
b9c7bc5a | 8828 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8829 | if (ret != CMD_SUCCESS) |
8830 | return ret; | |
8831 | ||
b9c7bc5a PZ |
8832 | if (yes) { |
8833 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8834 | vty_out(vty, "%% Missing RTLIST\n"); | |
8835 | return CMD_WARNING_CONFIG_FAILED; | |
8836 | } | |
c6423c31 | 8837 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
8838 | if (ret != CMD_SUCCESS) { |
8839 | return ret; | |
8840 | } | |
ddb5b488 PZ |
8841 | } |
8842 | ||
69b07479 DS |
8843 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8844 | if (!dodir[dir]) | |
ddb5b488 | 8845 | continue; |
ddb5b488 | 8846 | |
69b07479 | 8847 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8848 | |
69b07479 DS |
8849 | if (yes) { |
8850 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8851 | ecommunity_free( | |
8852 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8853 | bgp->vpn_policy[afi].rtlist[dir] = | |
8854 | ecommunity_dup(ecom); | |
8855 | } else { | |
8856 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8857 | ecommunity_free( | |
8858 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8859 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 8860 | } |
69b07479 DS |
8861 | |
8862 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 8863 | } |
69b07479 | 8864 | |
d555f3e9 PZ |
8865 | if (ecom) |
8866 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
8867 | |
8868 | return CMD_SUCCESS; | |
8869 | } | |
8870 | ||
b9c7bc5a PZ |
8871 | ALIAS (af_rt_vpn_imexport, |
8872 | af_no_rt_vpn_imexport_cmd, | |
8873 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
8874 | NO_STR |
8875 | "Specify route target list\n" | |
b9c7bc5a PZ |
8876 | "Specify route target list\n" |
8877 | "Between current address-family and vpn\n" | |
8878 | "For routes leaked from vpn to current address-family\n" | |
8879 | "For routes leaked from current address-family to vpn\n" | |
8880 | "both import and export\n") | |
8881 | ||
585f1adc | 8882 | DEFPY (af_route_map_vpn_imexport, |
b9c7bc5a PZ |
8883 | af_route_map_vpn_imexport_cmd, |
8884 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8885 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8886 | NO_STR | |
ddb5b488 | 8887 | "Specify route map\n" |
b9c7bc5a PZ |
8888 | "Between current address-family and vpn\n" |
8889 | "For routes leaked from vpn to current address-family\n" | |
8890 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8891 | "name of route-map\n") |
8892 | { | |
585f1adc IR |
8893 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8894 | int ret; | |
8895 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
9c2fd3fe | 8896 | enum vpn_policy_direction dir; |
ddb5b488 | 8897 | afi_t afi; |
ddb5b488 | 8898 | int idx = 0; |
585f1adc | 8899 | bool yes = true; |
ddb5b488 | 8900 | |
585f1adc IR |
8901 | if (argv_find(argv, argc, "no", &idx)) |
8902 | yes = false; | |
ddb5b488 | 8903 | |
585f1adc IR |
8904 | afi = vpn_policy_getafi(vty, bgp, false); |
8905 | if (afi == AFI_MAX) | |
8906 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8907 | |
585f1adc IR |
8908 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
8909 | if (ret != CMD_SUCCESS) | |
8910 | return ret; | |
ddb5b488 | 8911 | |
585f1adc IR |
8912 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8913 | if (!dodir[dir]) | |
8914 | continue; | |
69b07479 | 8915 | |
585f1adc IR |
8916 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
8917 | ||
8918 | if (yes) { | |
8919 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8920 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8921 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8922 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8923 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8924 | bgp->vpn_policy[afi].rmap[dir] = | |
8925 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8926 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8927 | return CMD_SUCCESS; | |
8928 | } else { | |
8929 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8930 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8931 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8932 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8933 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8934 | } | |
8935 | ||
8936 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8937 | } | |
ddb5b488 | 8938 | |
585f1adc | 8939 | return CMD_SUCCESS; |
ddb5b488 PZ |
8940 | } |
8941 | ||
b9c7bc5a PZ |
8942 | ALIAS (af_route_map_vpn_imexport, |
8943 | af_no_route_map_vpn_imexport_cmd, | |
8944 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
8945 | NO_STR |
8946 | "Specify route map\n" | |
b9c7bc5a PZ |
8947 | "Between current address-family and vpn\n" |
8948 | "For routes leaked from vpn to current address-family\n" | |
8949 | "For routes leaked from current address-family to vpn\n") | |
8950 | ||
bb4f6190 | 8951 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 8952 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
8953 | "Import routes from another VRF\n" |
8954 | "Vrf routes being filtered\n" | |
8955 | "Specify route map\n" | |
8956 | "name of route-map\n") | |
8957 | { | |
8958 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 8959 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
bb4f6190 | 8960 | afi_t afi; |
bb4f6190 DS |
8961 | struct bgp *bgp_default; |
8962 | ||
0ca70ba5 | 8963 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
8964 | if (afi == AFI_MAX) |
8965 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
8966 | |
8967 | bgp_default = bgp_get_default(); | |
8968 | if (!bgp_default) { | |
8969 | int32_t ret; | |
8970 | as_t as = bgp->as; | |
8971 | ||
8972 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8973 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8974 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
8975 | |
8976 | if (ret) { | |
8977 | vty_out(vty, | |
8978 | "VRF default is not configured as a bgp instance\n"); | |
8979 | return CMD_WARNING; | |
8980 | } | |
8981 | } | |
8982 | ||
69b07479 | 8983 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 8984 | |
ae6a6fb4 DS |
8985 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
8986 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8987 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8988 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8989 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8990 | bgp->vpn_policy[afi].rmap[dir] = | |
8991 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8992 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8993 | return CMD_SUCCESS; | |
8994 | ||
8995 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8996 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 8997 | |
69b07479 DS |
8998 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8999 | ||
bb4f6190 DS |
9000 | return CMD_SUCCESS; |
9001 | } | |
9002 | ||
ae6a6fb4 DS |
9003 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
9004 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
9005 | NO_STR |
9006 | "Import routes from another VRF\n" | |
9007 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
9008 | "Specify route map\n" |
9009 | "name of route-map\n") | |
9010 | { | |
9011 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9c2fd3fe | 9012 | enum vpn_policy_direction dir = BGP_VPN_POLICY_DIR_FROMVPN; |
ae6a6fb4 DS |
9013 | afi_t afi; |
9014 | ||
9015 | afi = vpn_policy_getafi(vty, bgp, true); | |
9016 | if (afi == AFI_MAX) | |
9017 | return CMD_WARNING_CONFIG_FAILED; | |
9018 | ||
9019 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9020 | ||
9021 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
9022 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
9023 | bgp->vpn_policy[afi].rmap_name[dir]); | |
9024 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
9025 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
9026 | ||
9027 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
9028 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
9029 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
9030 | ||
9031 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9032 | ||
9033 | return CMD_SUCCESS; | |
9034 | } | |
bb4f6190 | 9035 | |
585f1adc IR |
9036 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
9037 | "[no] import vrf VIEWVRFNAME$import_name", | |
9038 | NO_STR | |
9039 | "Import routes from another VRF\n" | |
9040 | "VRF to import from\n" | |
9041 | "The name of the VRF\n") | |
12a844a5 | 9042 | { |
585f1adc IR |
9043 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9044 | struct listnode *node; | |
9045 | struct bgp *vrf_bgp, *bgp_default; | |
9046 | int32_t ret = 0; | |
9047 | as_t as = bgp->as; | |
9048 | bool remove = false; | |
9049 | int32_t idx = 0; | |
9050 | char *vname; | |
9051 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; | |
12a844a5 DS |
9052 | safi_t safi; |
9053 | afi_t afi; | |
9054 | ||
867f0cca | 9055 | if (import_name == NULL) { |
9056 | vty_out(vty, "%% Missing import name\n"); | |
9057 | return CMD_WARNING; | |
9058 | } | |
9059 | ||
ae6a6fb4 DS |
9060 | if (strcmp(import_name, "route-map") == 0) { |
9061 | vty_out(vty, "%% Must include route-map name\n"); | |
9062 | return CMD_WARNING; | |
9063 | } | |
9064 | ||
585f1adc IR |
9065 | if (argv_find(argv, argc, "no", &idx)) |
9066 | remove = true; | |
9067 | ||
9068 | afi = vpn_policy_getafi(vty, bgp, true); | |
9069 | if (afi == AFI_MAX) | |
9070 | return CMD_WARNING_CONFIG_FAILED; | |
9071 | ||
12a844a5 DS |
9072 | safi = bgp_node_safi(vty); |
9073 | ||
585f1adc IR |
9074 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
9075 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) | |
9076 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
9077 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
9078 | remove ? "unimport" : "import", import_name); | |
9079 | return CMD_WARNING; | |
9080 | } | |
25679caa | 9081 | |
585f1adc IR |
9082 | bgp_default = bgp_get_default(); |
9083 | if (!bgp_default) { | |
9084 | /* Auto-create assuming the same AS */ | |
9085 | ret = bgp_get_vty(&bgp_default, &as, NULL, | |
9086 | BGP_INSTANCE_TYPE_DEFAULT); | |
12a844a5 | 9087 | |
585f1adc IR |
9088 | if (ret) { |
9089 | vty_out(vty, | |
9090 | "VRF default is not configured as a bgp instance\n"); | |
9091 | return CMD_WARNING; | |
9092 | } | |
9093 | } | |
12a844a5 | 9094 | |
585f1adc IR |
9095 | vrf_bgp = bgp_lookup_by_name(import_name); |
9096 | if (!vrf_bgp) { | |
9097 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) | |
9098 | vrf_bgp = bgp_default; | |
9099 | else | |
9100 | /* Auto-create assuming the same AS */ | |
9101 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); | |
9102 | ||
9103 | if (ret) { | |
9104 | vty_out(vty, | |
9105 | "VRF %s is not configured as a bgp instance\n", | |
9106 | import_name); | |
9107 | return CMD_WARNING; | |
9108 | } | |
9109 | } | |
9110 | ||
9111 | if (remove) { | |
9112 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); | |
9113 | } else { | |
9114 | /* Already importing from "import_vrf"? */ | |
9115 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
9116 | vname)) { | |
9117 | if (strcmp(vname, import_name) == 0) | |
9118 | return CMD_WARNING; | |
9119 | } | |
9120 | ||
9121 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); | |
9122 | } | |
9123 | ||
9124 | return CMD_SUCCESS; | |
12a844a5 DS |
9125 | } |
9126 | ||
b9c7bc5a | 9127 | /* This command is valid only in a bgp vrf instance or the default instance */ |
585f1adc | 9128 | DEFPY (bgp_imexport_vpn, |
b9c7bc5a PZ |
9129 | bgp_imexport_vpn_cmd, |
9130 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
9131 | NO_STR |
9132 | "Import routes to this address-family\n" | |
9133 | "Export routes from this address-family\n" | |
9134 | "to/from default instance VPN RIB\n") | |
ddb5b488 | 9135 | { |
585f1adc IR |
9136 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9137 | int previous_state; | |
37a87b8f | 9138 | afi_t afi; |
585f1adc IR |
9139 | safi_t safi; |
9140 | int idx = 0; | |
9141 | bool yes = true; | |
9142 | int flag; | |
9c2fd3fe | 9143 | enum vpn_policy_direction dir; |
585f1adc IR |
9144 | |
9145 | if (argv_find(argv, argc, "no", &idx)) | |
9146 | yes = false; | |
9147 | ||
9148 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && | |
9149 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
9150 | ||
9151 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); | |
9152 | return CMD_WARNING_CONFIG_FAILED; | |
9153 | } | |
ddb5b488 | 9154 | |
b9c7bc5a PZ |
9155 | afi = bgp_node_afi(vty); |
9156 | safi = bgp_node_safi(vty); | |
585f1adc IR |
9157 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { |
9158 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
9159 | return CMD_WARNING_CONFIG_FAILED; | |
9160 | } | |
ddb5b488 | 9161 | |
b9c7bc5a | 9162 | if (!strcmp(direction_str, "import")) { |
585f1adc IR |
9163 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; |
9164 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b9c7bc5a | 9165 | } else if (!strcmp(direction_str, "export")) { |
585f1adc IR |
9166 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; |
9167 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b9c7bc5a PZ |
9168 | } else { |
9169 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
9170 | return CMD_WARNING_CONFIG_FAILED; | |
9171 | } | |
9172 | ||
585f1adc | 9173 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); |
ddb5b488 | 9174 | |
585f1adc IR |
9175 | if (yes) { |
9176 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
9177 | if (!previous_state) { | |
9178 | /* trigger export current vrf */ | |
9179 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
9180 | } | |
9181 | } else { | |
9182 | if (previous_state) { | |
9183 | /* trigger un-export current vrf */ | |
9184 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
9185 | } | |
9186 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
9187 | } | |
37a87b8f | 9188 | |
1ca2fd11 IR |
9189 | hook_call(bgp_snmp_init_stats, bgp); |
9190 | ||
585f1adc | 9191 | return CMD_SUCCESS; |
ddb5b488 PZ |
9192 | } |
9193 | ||
301ad80a PG |
9194 | DEFPY (af_routetarget_import, |
9195 | af_routetarget_import_cmd, | |
9a659715 | 9196 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
9197 | NO_STR |
9198 | "Specify route target list\n" | |
9199 | "Specify route target list\n" | |
9a659715 PG |
9200 | "Specify route target list\n" |
9201 | "Specify route target list\n" | |
301ad80a PG |
9202 | "Flow-spec redirect type route target\n" |
9203 | "Import routes to this address-family\n" | |
9a659715 | 9204 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
9205 | { |
9206 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9207 | int ret; | |
9208 | struct ecommunity *ecom = NULL; | |
301ad80a | 9209 | afi_t afi; |
9a659715 | 9210 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
9211 | bool yes = true; |
9212 | bool rt6 = false; | |
301ad80a PG |
9213 | |
9214 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 9215 | yes = false; |
301ad80a | 9216 | |
9a659715 PG |
9217 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
9218 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 9219 | rt6 = true; |
301ad80a | 9220 | |
0ca70ba5 | 9221 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
9222 | if (afi == AFI_MAX) |
9223 | return CMD_WARNING_CONFIG_FAILED; | |
9224 | ||
9a659715 PG |
9225 | if (rt6 && afi != AFI_IP6) |
9226 | return CMD_WARNING_CONFIG_FAILED; | |
9227 | ||
301ad80a PG |
9228 | if (yes) { |
9229 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
9230 | vty_out(vty, "%% Missing RTLIST\n"); | |
9231 | return CMD_WARNING_CONFIG_FAILED; | |
9232 | } | |
9a659715 | 9233 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
9234 | if (ret != CMD_SUCCESS) |
9235 | return ret; | |
9236 | } | |
69b07479 DS |
9237 | |
9238 | if (yes) { | |
9239 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9240 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9241 | .import_redirect_rtlist); |
69b07479 DS |
9242 | bgp->vpn_policy[afi].import_redirect_rtlist = |
9243 | ecommunity_dup(ecom); | |
9244 | } else { | |
9245 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
9246 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 9247 | .import_redirect_rtlist); |
69b07479 | 9248 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 9249 | } |
69b07479 | 9250 | |
301ad80a PG |
9251 | if (ecom) |
9252 | ecommunity_free(&ecom); | |
9253 | ||
9254 | return CMD_SUCCESS; | |
9255 | } | |
9256 | ||
505e5056 | 9257 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 9258 | address_family_ipv4_safi_cmd, |
9259 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9260 | "Enter Address Family command mode\n" | |
9261 | "Address Family\n" | |
9262 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 9263 | { |
f51bae9c | 9264 | |
d62a17ae | 9265 | if (argc == 3) { |
585f1adc IR |
9266 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9267 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9268 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9269 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9270 | && safi != SAFI_EVPN) { |
31947174 MK |
9271 | vty_out(vty, |
9272 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9273 | return CMD_WARNING_CONFIG_FAILED; |
9274 | } | |
585f1adc IR |
9275 | vty->node = bgp_node_type(AFI_IP, safi); |
9276 | } else | |
9277 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 9278 | |
d62a17ae | 9279 | return CMD_SUCCESS; |
718e3744 | 9280 | } |
9281 | ||
505e5056 | 9282 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 9283 | address_family_ipv6_safi_cmd, |
9284 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
9285 | "Enter Address Family command mode\n" | |
9286 | "Address Family\n" | |
9287 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 9288 | { |
d62a17ae | 9289 | if (argc == 3) { |
585f1adc IR |
9290 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
9291 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
9292 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT | |
a4d82a8a | 9293 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST |
9d00a487 | 9294 | && safi != SAFI_EVPN) { |
31947174 MK |
9295 | vty_out(vty, |
9296 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
9297 | return CMD_WARNING_CONFIG_FAILED; |
9298 | } | |
585f1adc IR |
9299 | vty->node = bgp_node_type(AFI_IP6, safi); |
9300 | } else | |
9301 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 9302 | |
d62a17ae | 9303 | return CMD_SUCCESS; |
25ffbdc1 | 9304 | } |
718e3744 | 9305 | |
d6902373 | 9306 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 9307 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 9308 | address_family_vpnv4_cmd, |
8334fd5a | 9309 | "address-family vpnv4 [unicast]", |
718e3744 | 9310 | "Enter Address Family command mode\n" |
8c3deaae | 9311 | "Address Family\n" |
3a2d747c | 9312 | "Address Family modifier\n") |
718e3744 | 9313 | { |
d62a17ae | 9314 | vty->node = BGP_VPNV4_NODE; |
9315 | return CMD_SUCCESS; | |
718e3744 | 9316 | } |
9317 | ||
505e5056 | 9318 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 9319 | address_family_vpnv6_cmd, |
8334fd5a | 9320 | "address-family vpnv6 [unicast]", |
8ecd3266 | 9321 | "Enter Address Family command mode\n" |
8c3deaae | 9322 | "Address Family\n" |
3a2d747c | 9323 | "Address Family modifier\n") |
8ecd3266 | 9324 | { |
d62a17ae | 9325 | vty->node = BGP_VPNV6_NODE; |
9326 | return CMD_SUCCESS; | |
8ecd3266 | 9327 | } |
64e4a6c5 | 9328 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 9329 | |
505e5056 | 9330 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 9331 | address_family_evpn_cmd, |
7111c1a0 | 9332 | "address-family l2vpn evpn", |
4e0b7b6d | 9333 | "Enter Address Family command mode\n" |
7111c1a0 QY |
9334 | "Address Family\n" |
9335 | "Address Family modifier\n") | |
4e0b7b6d | 9336 | { |
2131d5cf | 9337 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 9338 | vty->node = BGP_EVPN_NODE; |
9339 | return CMD_SUCCESS; | |
4e0b7b6d PG |
9340 | } |
9341 | ||
bfaab44d HS |
9342 | DEFUN_NOSH (bgp_segment_routing_srv6, |
9343 | bgp_segment_routing_srv6_cmd, | |
9344 | "segment-routing srv6", | |
9345 | "Segment-Routing configuration\n" | |
9346 | "Segment-Routing SRv6 configuration\n") | |
9347 | { | |
9348 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
92a9e6f2 | 9349 | bgp->srv6_enabled = true; |
bfaab44d HS |
9350 | vty->node = BGP_SRV6_NODE; |
9351 | return CMD_SUCCESS; | |
9352 | } | |
9353 | ||
0249b8b6 HS |
9354 | DEFUN (no_bgp_segment_routing_srv6, |
9355 | no_bgp_segment_routing_srv6_cmd, | |
9356 | "no segment-routing srv6", | |
9357 | NO_STR | |
9358 | "Segment-Routing configuration\n" | |
9359 | "Segment-Routing SRv6 configuration\n") | |
9360 | { | |
9361 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9362 | ||
9363 | if (strlen(bgp->srv6_locator_name) > 0) | |
9364 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9365 | return CMD_WARNING_CONFIG_FAILED; | |
9366 | ||
9367 | bgp->srv6_enabled = false; | |
9368 | return CMD_SUCCESS; | |
9369 | } | |
9370 | ||
a0281b2e HS |
9371 | DEFPY (bgp_srv6_locator, |
9372 | bgp_srv6_locator_cmd, | |
9373 | "locator NAME$name", | |
9374 | "Specify SRv6 locator\n" | |
9375 | "Specify SRv6 locator\n") | |
9376 | { | |
9377 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7de4c885 | 9378 | int ret; |
a0281b2e HS |
9379 | |
9380 | if (strlen(bgp->srv6_locator_name) > 0 | |
9381 | && strcmp(name, bgp->srv6_locator_name) != 0) { | |
9382 | vty_out(vty, "srv6 locator is already configured\n"); | |
9383 | return CMD_WARNING_CONFIG_FAILED; | |
7de4c885 HS |
9384 | } |
9385 | ||
9386 | snprintf(bgp->srv6_locator_name, | |
9387 | sizeof(bgp->srv6_locator_name), "%s", name); | |
a0281b2e | 9388 | |
7de4c885 | 9389 | ret = bgp_zebra_srv6_manager_get_locator_chunk(name); |
a0281b2e HS |
9390 | if (ret < 0) |
9391 | return CMD_WARNING_CONFIG_FAILED; | |
9392 | ||
9393 | return CMD_SUCCESS; | |
9394 | } | |
9395 | ||
0249b8b6 HS |
9396 | DEFPY (no_bgp_srv6_locator, |
9397 | no_bgp_srv6_locator_cmd, | |
9398 | "no locator NAME$name", | |
9399 | NO_STR | |
9400 | "Specify SRv6 locator\n" | |
9401 | "Specify SRv6 locator\n") | |
9402 | { | |
9403 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
9404 | ||
9405 | /* when locator isn't configured, do nothing */ | |
9406 | if (strlen(bgp->srv6_locator_name) < 1) | |
9407 | return CMD_SUCCESS; | |
9408 | ||
9409 | /* name validation */ | |
9410 | if (strcmp(name, bgp->srv6_locator_name) != 0) { | |
9411 | vty_out(vty, "%% No srv6 locator is configured\n"); | |
9412 | return CMD_WARNING_CONFIG_FAILED; | |
9413 | } | |
9414 | ||
9415 | /* unset locator */ | |
9416 | if (bgp_srv6_locator_unset(bgp) < 0) | |
9417 | return CMD_WARNING_CONFIG_FAILED; | |
9418 | ||
9419 | return CMD_SUCCESS; | |
9420 | } | |
9421 | ||
ea372e81 HS |
9422 | DEFPY (show_bgp_srv6, |
9423 | show_bgp_srv6_cmd, | |
9424 | "show bgp segment-routing srv6", | |
9425 | SHOW_STR | |
9426 | BGP_STR | |
9427 | "BGP Segment Routing\n" | |
9428 | "BGP Segment Routing SRv6\n") | |
9429 | { | |
9430 | struct bgp *bgp; | |
9431 | struct listnode *node; | |
1c21a234 | 9432 | struct srv6_locator_chunk *chunk; |
ea372e81 HS |
9433 | struct bgp_srv6_function *func; |
9434 | struct in6_addr *tovpn4_sid; | |
9435 | struct in6_addr *tovpn6_sid; | |
9436 | char buf[256]; | |
9437 | char buf_tovpn4_sid[256]; | |
9438 | char buf_tovpn6_sid[256]; | |
9439 | ||
9440 | bgp = bgp_get_default(); | |
96db4340 | 9441 | if (!bgp) |
ea372e81 HS |
9442 | return CMD_SUCCESS; |
9443 | ||
9444 | vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); | |
9445 | vty_out(vty, "locator_chunks:\n"); | |
9446 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { | |
1c21a234 | 9447 | prefix2str(&chunk->prefix, buf, sizeof(buf)); |
ea372e81 HS |
9448 | vty_out(vty, "- %s\n", buf); |
9449 | } | |
9450 | ||
9451 | vty_out(vty, "functions:\n"); | |
9452 | for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { | |
9453 | inet_ntop(AF_INET6, &func->sid, buf, sizeof(buf)); | |
9454 | vty_out(vty, "- sid: %s\n", buf); | |
9455 | vty_out(vty, " locator: %s\n", func->locator_name); | |
9456 | } | |
9457 | ||
9458 | vty_out(vty, "bgps:\n"); | |
9459 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) { | |
9460 | vty_out(vty, "- name: %s\n", | |
9461 | bgp->name ? bgp->name : "default"); | |
9462 | ||
9463 | tovpn4_sid = bgp->vpn_policy[AFI_IP].tovpn_sid; | |
9464 | tovpn6_sid = bgp->vpn_policy[AFI_IP6].tovpn_sid; | |
9465 | if (tovpn4_sid) | |
9466 | inet_ntop(AF_INET6, tovpn4_sid, buf_tovpn4_sid, | |
9467 | sizeof(buf_tovpn4_sid)); | |
9468 | if (tovpn6_sid) | |
9469 | inet_ntop(AF_INET6, tovpn6_sid, buf_tovpn6_sid, | |
9470 | sizeof(buf_tovpn6_sid)); | |
9471 | ||
9472 | vty_out(vty, " vpn_policy[AFI_IP].tovpn_sid: %s\n", | |
9473 | tovpn4_sid ? buf_tovpn4_sid : "none"); | |
9474 | vty_out(vty, " vpn_policy[AFI_IP6].tovpn_sid: %s\n", | |
9475 | tovpn6_sid ? buf_tovpn6_sid : "none"); | |
9476 | } | |
9477 | ||
9478 | return CMD_SUCCESS; | |
9479 | } | |
9480 | ||
505e5056 | 9481 | DEFUN_NOSH (exit_address_family, |
718e3744 | 9482 | exit_address_family_cmd, |
9483 | "exit-address-family", | |
9484 | "Exit from Address Family configuration mode\n") | |
9485 | { | |
d62a17ae | 9486 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
9487 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
9488 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
9489 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
9490 | || vty->node == BGP_EVPN_NODE |
9491 | || vty->node == BGP_FLOWSPECV4_NODE | |
9492 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 9493 | vty->node = BGP_NODE; |
9494 | return CMD_SUCCESS; | |
718e3744 | 9495 | } |
6b0655a2 | 9496 | |
8ad7271d | 9497 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 9498 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
9499 | const char *ip_str, afi_t afi, safi_t safi, | |
9500 | struct prefix_rd *prd) | |
9501 | { | |
9502 | int ret; | |
9503 | struct prefix match; | |
9bcb3eef DS |
9504 | struct bgp_dest *dest; |
9505 | struct bgp_dest *rm; | |
d62a17ae | 9506 | struct bgp *bgp; |
9507 | struct bgp_table *table; | |
9508 | struct bgp_table *rib; | |
9509 | ||
9510 | /* BGP structure lookup. */ | |
9511 | if (view_name) { | |
9512 | bgp = bgp_lookup_by_name(view_name); | |
9513 | if (bgp == NULL) { | |
9514 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
9515 | view_name); | |
9516 | return CMD_WARNING; | |
9517 | } | |
9518 | } else { | |
9519 | bgp = bgp_get_default(); | |
9520 | if (bgp == NULL) { | |
9521 | vty_out(vty, "%% No BGP process is configured\n"); | |
9522 | return CMD_WARNING; | |
9523 | } | |
9524 | } | |
9525 | ||
9526 | /* Check IP address argument. */ | |
9527 | ret = str2prefix(ip_str, &match); | |
9528 | if (!ret) { | |
9529 | vty_out(vty, "%% address is malformed\n"); | |
9530 | return CMD_WARNING; | |
9531 | } | |
9532 | ||
9533 | match.family = afi2family(afi); | |
9534 | rib = bgp->rib[afi][safi]; | |
9535 | ||
9536 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
9537 | for (dest = bgp_table_top(rib); dest; |
9538 | dest = bgp_route_next(dest)) { | |
9539 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 9540 | |
9bcb3eef | 9541 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 9542 | continue; |
9543 | ||
9bcb3eef | 9544 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
9545 | if (table == NULL) |
9546 | continue; | |
9547 | ||
4953391b DA |
9548 | rm = bgp_node_match(table, &match); |
9549 | if (rm != NULL) { | |
b54892e0 | 9550 | const struct prefix *rm_p = |
9bcb3eef | 9551 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
9552 | |
9553 | if (rm_p->prefixlen == match.prefixlen) { | |
9554 | SET_FLAG(rm->flags, | |
9555 | BGP_NODE_USER_CLEAR); | |
9556 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 9557 | } |
9bcb3eef | 9558 | bgp_dest_unlock_node(rm); |
d62a17ae | 9559 | } |
9560 | } | |
9561 | } else { | |
4953391b DA |
9562 | dest = bgp_node_match(rib, &match); |
9563 | if (dest != NULL) { | |
9bcb3eef | 9564 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); |
b54892e0 | 9565 | |
9bcb3eef DS |
9566 | if (dest_p->prefixlen == match.prefixlen) { |
9567 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
9568 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 9569 | } |
9bcb3eef | 9570 | bgp_dest_unlock_node(dest); |
d62a17ae | 9571 | } |
9572 | } | |
9573 | ||
9574 | return CMD_SUCCESS; | |
8ad7271d DS |
9575 | } |
9576 | ||
b09b5ae0 | 9577 | /* one clear bgp command to rule them all */ |
718e3744 | 9578 | DEFUN (clear_ip_bgp_all, |
9579 | clear_ip_bgp_all_cmd, | |
3cb14f26 | 9580 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]", |
718e3744 | 9581 | CLEAR_STR |
9582 | IP_STR | |
9583 | BGP_STR | |
838758ac | 9584 | BGP_INSTANCE_HELP_STR |
510afcd6 | 9585 | BGP_AFI_HELP_STR |
fd5e7b70 | 9586 | "Address Family\n" |
510afcd6 | 9587 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 9588 | "Address Family modifier\n" |
b09b5ae0 | 9589 | "Clear all peers\n" |
453c92f6 | 9590 | "BGP IPv4 neighbor to clear\n" |
a80beece | 9591 | "BGP IPv6 neighbor to clear\n" |
838758ac | 9592 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
9593 | "Clear peers with the AS number\n" |
9594 | "Clear all external peers\n" | |
718e3744 | 9595 | "Clear all members of peer-group\n" |
b09b5ae0 | 9596 | "BGP peer-group name\n" |
b09b5ae0 DW |
9597 | BGP_SOFT_STR |
9598 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
9599 | BGP_SOFT_OUT_STR |
9600 | BGP_SOFT_IN_STR | |
9601 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
3cb14f26 DS |
9602 | BGP_SOFT_OUT_STR |
9603 | "Reset message statistics\n") | |
718e3744 | 9604 | { |
d62a17ae | 9605 | char *vrf = NULL; |
9606 | ||
dc912615 DS |
9607 | afi_t afi = AFI_UNSPEC; |
9608 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 9609 | enum clear_sort clr_sort = clear_peer; |
9610 | enum bgp_clear_type clr_type; | |
9611 | char *clr_arg = NULL; | |
9612 | ||
9613 | int idx = 0; | |
9614 | ||
9615 | /* clear [ip] bgp */ | |
9616 | if (argv_find(argv, argc, "ip", &idx)) | |
9617 | afi = AFI_IP; | |
9618 | ||
9a8bdf1c PG |
9619 | /* [<vrf> VIEWVRFNAME] */ |
9620 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9621 | vrf = argv[idx + 1]->arg; | |
9622 | idx += 2; | |
9623 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9624 | vrf = NULL; | |
9625 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9626 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 9627 | vrf = argv[idx + 1]->arg; |
9628 | idx += 2; | |
9629 | } | |
d62a17ae | 9630 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9631 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
9632 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9633 | ||
d7b9898c | 9634 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 9635 | if (argv_find(argv, argc, "*", &idx)) { |
9636 | clr_sort = clear_all; | |
9637 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
9638 | clr_sort = clear_peer; | |
9639 | clr_arg = argv[idx]->arg; | |
9640 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
9641 | clr_sort = clear_peer; | |
9642 | clr_arg = argv[idx]->arg; | |
9643 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
9644 | clr_sort = clear_group; | |
9645 | idx++; | |
9646 | clr_arg = argv[idx]->arg; | |
d7b9898c | 9647 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 9648 | clr_sort = clear_peer; |
9649 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
9650 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
9651 | clr_sort = clear_peer; | |
9652 | clr_arg = argv[idx]->arg; | |
d62a17ae | 9653 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
9654 | clr_sort = clear_as; | |
9655 | clr_arg = argv[idx]->arg; | |
9656 | } else if (argv_find(argv, argc, "external", &idx)) { | |
9657 | clr_sort = clear_external; | |
9658 | } | |
9659 | ||
3cb14f26 | 9660 | /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */ |
d62a17ae | 9661 | if (argv_find(argv, argc, "soft", &idx)) { |
9662 | if (argv_find(argv, argc, "in", &idx) | |
9663 | || argv_find(argv, argc, "out", &idx)) | |
9664 | clr_type = strmatch(argv[idx]->text, "in") | |
9665 | ? BGP_CLEAR_SOFT_IN | |
9666 | : BGP_CLEAR_SOFT_OUT; | |
9667 | else | |
9668 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9669 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9670 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9671 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9672 | : BGP_CLEAR_SOFT_IN; | |
9673 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9674 | clr_type = BGP_CLEAR_SOFT_OUT; | |
3cb14f26 DS |
9675 | } else if (argv_find(argv, argc, "message-stats", &idx)) { |
9676 | clr_type = BGP_CLEAR_MESSAGE_STATS; | |
d62a17ae | 9677 | } else |
9678 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9679 | ||
1ca2fd11 | 9680 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 9681 | } |
01080f7c | 9682 | |
8ad7271d DS |
9683 | DEFUN (clear_ip_bgp_prefix, |
9684 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9685 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9686 | CLEAR_STR |
9687 | IP_STR | |
9688 | BGP_STR | |
838758ac | 9689 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9690 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9691 | "IPv4 prefix\n") |
8ad7271d | 9692 | { |
d62a17ae | 9693 | char *vrf = NULL; |
9694 | char *prefix = NULL; | |
8ad7271d | 9695 | |
d62a17ae | 9696 | int idx = 0; |
01080f7c | 9697 | |
d62a17ae | 9698 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9699 | if (argv_find(argv, argc, "vrf", &idx)) { |
9700 | vrf = argv[idx + 1]->arg; | |
9701 | idx += 2; | |
9702 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9703 | vrf = NULL; | |
9704 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9705 | /* [<view> VIEWVRFNAME] */ | |
9706 | vrf = argv[idx + 1]->arg; | |
9707 | idx += 2; | |
9708 | } | |
0c7b1b01 | 9709 | |
d62a17ae | 9710 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9711 | |
d62a17ae | 9712 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9713 | } |
8ad7271d | 9714 | |
b09b5ae0 DW |
9715 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9716 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9717 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9718 | CLEAR_STR |
3a2d747c | 9719 | IP_STR |
718e3744 | 9720 | BGP_STR |
8c3deaae | 9721 | "Address Family\n" |
46f296b4 | 9722 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9723 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9724 | "IPv6 prefix\n") |
718e3744 | 9725 | { |
9b475e76 PG |
9726 | int idx_safi = 0; |
9727 | int idx_ipv6_prefix = 0; | |
9728 | safi_t safi = SAFI_UNICAST; | |
9729 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9730 | argv[idx_ipv6_prefix]->arg : NULL; | |
9731 | ||
9732 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9733 | return bgp_clear_prefix( |
9b475e76 PG |
9734 | vty, NULL, prefix, AFI_IP6, |
9735 | safi, NULL); | |
838758ac | 9736 | } |
01080f7c | 9737 | |
b09b5ae0 DW |
9738 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9739 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9740 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9741 | CLEAR_STR |
3a2d747c | 9742 | IP_STR |
718e3744 | 9743 | BGP_STR |
838758ac | 9744 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9745 | "Address Family\n" |
46f296b4 | 9746 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9747 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9748 | "IPv6 prefix\n") |
718e3744 | 9749 | { |
9b475e76 | 9750 | int idx_safi = 0; |
9a8bdf1c | 9751 | int idx_vrfview = 0; |
9b475e76 PG |
9752 | int idx_ipv6_prefix = 0; |
9753 | safi_t safi = SAFI_UNICAST; | |
9754 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9755 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9756 | char *vrfview = NULL; |
9b475e76 | 9757 | |
9a8bdf1c PG |
9758 | /* [<view|vrf> VIEWVRFNAME] */ |
9759 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9760 | vrfview = argv[idx_vrfview + 1]->arg; | |
9761 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9762 | vrfview = NULL; | |
9763 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9764 | /* [<view> VIEWVRFNAME] */ | |
9765 | vrfview = argv[idx_vrfview + 1]->arg; | |
9766 | } | |
9b475e76 PG |
9767 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9768 | ||
d62a17ae | 9769 | return bgp_clear_prefix( |
9b475e76 PG |
9770 | vty, vrfview, prefix, |
9771 | AFI_IP6, safi, NULL); | |
718e3744 | 9772 | } |
9773 | ||
b09b5ae0 DW |
9774 | DEFUN (show_bgp_views, |
9775 | show_bgp_views_cmd, | |
d6e3c605 | 9776 | "show [ip] bgp views", |
b09b5ae0 | 9777 | SHOW_STR |
d6e3c605 | 9778 | IP_STR |
01080f7c | 9779 | BGP_STR |
b09b5ae0 | 9780 | "Show the defined BGP views\n") |
01080f7c | 9781 | { |
d62a17ae | 9782 | struct list *inst = bm->bgp; |
9783 | struct listnode *node; | |
9784 | struct bgp *bgp; | |
01080f7c | 9785 | |
d62a17ae | 9786 | vty_out(vty, "Defined BGP views:\n"); |
9787 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9788 | /* Skip VRFs. */ | |
9789 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9790 | continue; | |
9791 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9792 | bgp->as); | |
9793 | } | |
e52702f2 | 9794 | |
d62a17ae | 9795 | return CMD_SUCCESS; |
e0081f70 ML |
9796 | } |
9797 | ||
8386ac43 | 9798 | DEFUN (show_bgp_vrfs, |
9799 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9800 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9801 | SHOW_STR |
d6e3c605 | 9802 | IP_STR |
8386ac43 | 9803 | BGP_STR |
9804 | "Show BGP VRFs\n" | |
9973d184 | 9805 | JSON_STR) |
8386ac43 | 9806 | { |
fe1dc5a3 | 9807 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9808 | struct list *inst = bm->bgp; |
9809 | struct listnode *node; | |
9810 | struct bgp *bgp; | |
9f049418 | 9811 | bool uj = use_json(argc, argv); |
d62a17ae | 9812 | json_object *json = NULL; |
9813 | json_object *json_vrfs = NULL; | |
9814 | int count = 0; | |
d62a17ae | 9815 | |
d62a17ae | 9816 | if (uj) { |
9817 | json = json_object_new_object(); | |
9818 | json_vrfs = json_object_new_object(); | |
9819 | } | |
9820 | ||
9821 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9822 | const char *name, *type; | |
9823 | struct peer *peer; | |
7fe96307 | 9824 | struct listnode *node2, *nnode2; |
d62a17ae | 9825 | int peers_cfg, peers_estb; |
9826 | json_object *json_vrf = NULL; | |
d62a17ae | 9827 | |
9828 | /* Skip Views. */ | |
9829 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9830 | continue; | |
9831 | ||
9832 | count++; | |
efb4077a | 9833 | if (!uj && count == 1) { |
fe1dc5a3 | 9834 | vty_out(vty, |
efb4077a | 9835 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9836 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9837 | "#PeersEstb", "Name"); |
9838 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9839 | "L3-VNI", "RouterMAC", "Interface"); | |
9840 | } | |
d62a17ae | 9841 | |
9842 | peers_cfg = peers_estb = 0; | |
9843 | if (uj) | |
9844 | json_vrf = json_object_new_object(); | |
9845 | ||
9846 | ||
7fe96307 | 9847 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9848 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9849 | continue; | |
9850 | peers_cfg++; | |
feb17238 | 9851 | if (peer_established(peer)) |
d62a17ae | 9852 | peers_estb++; |
9853 | } | |
9854 | ||
9855 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 9856 | name = VRF_DEFAULT_NAME; |
d62a17ae | 9857 | type = "DFLT"; |
9858 | } else { | |
9859 | name = bgp->name; | |
9860 | type = "VRF"; | |
9861 | } | |
9862 | ||
a8bf7d9c | 9863 | |
d62a17ae | 9864 | if (uj) { |
a4d82a8a PZ |
9865 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9866 | ? -1 | |
9867 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
9868 | char buf[BUFSIZ] = {0}; |
9869 | ||
d62a17ae | 9870 | json_object_string_add(json_vrf, "type", type); |
9871 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
c949c771 DA |
9872 | json_object_string_addf(json_vrf, "routerId", "%pI4", |
9873 | &bgp->router_id); | |
d62a17ae | 9874 | json_object_int_add(json_vrf, "numConfiguredPeers", |
9875 | peers_cfg); | |
9876 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9877 | peers_estb); | |
9878 | ||
fe1dc5a3 | 9879 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
9880 | json_object_string_add( |
9881 | json_vrf, "rmac", | |
9882 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
9883 | json_object_string_add(json_vrf, "interface", |
9884 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9885 | bgp->vrf_id)); | |
d62a17ae | 9886 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 9887 | } else { |
23d0a753 | 9888 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
9889 | type, |
9890 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9891 | : (int)bgp->vrf_id, | |
23d0a753 | 9892 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
9893 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
9894 | bgp->l3vni, | |
9895 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9896 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9897 | bgp->vrf_id)); | |
9898 | } | |
d62a17ae | 9899 | } |
9900 | ||
9901 | if (uj) { | |
9902 | json_object_object_add(json, "vrfs", json_vrfs); | |
9903 | ||
9904 | json_object_int_add(json, "totalVrfs", count); | |
9905 | ||
75eeda93 | 9906 | vty_json(vty, json); |
d62a17ae | 9907 | } else { |
9908 | if (count) | |
9909 | vty_out(vty, | |
9910 | "\nTotal number of VRFs (including default): %d\n", | |
9911 | count); | |
9912 | } | |
9913 | ||
9914 | return CMD_SUCCESS; | |
8386ac43 | 9915 | } |
9916 | ||
48ecf8f5 DS |
9917 | DEFUN (show_bgp_mac_hash, |
9918 | show_bgp_mac_hash_cmd, | |
9919 | "show bgp mac hash", | |
9920 | SHOW_STR | |
9921 | BGP_STR | |
9922 | "Mac Address\n" | |
9923 | "Mac Address database\n") | |
9924 | { | |
9925 | bgp_mac_dump_table(vty); | |
9926 | ||
9927 | return CMD_SUCCESS; | |
9928 | } | |
acf71666 | 9929 | |
e3b78da8 | 9930 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 9931 | { |
0291c246 | 9932 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 9933 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 9934 | |
23d0a753 | 9935 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
9936 | } |
9937 | ||
9938 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9939 | { | |
9940 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 9941 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
9942 | |
9943 | vty_out(vty, "Tunnel-ip database:\n"); | |
9944 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 9945 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
9946 | vty); |
9947 | } | |
9948 | ||
15c81ca4 DS |
9949 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
9950 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9951 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
9952 | "martian next-hops\n" |
9953 | "martian next-hop database\n") | |
acf71666 | 9954 | { |
0291c246 | 9955 | struct bgp *bgp = NULL; |
15c81ca4 | 9956 | int idx = 0; |
9a8bdf1c PG |
9957 | char *name = NULL; |
9958 | ||
9959 | /* [<vrf> VIEWVRFNAME] */ | |
9960 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9961 | name = argv[idx + 1]->arg; | |
9962 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9963 | name = NULL; | |
9964 | } else if (argv_find(argv, argc, "view", &idx)) | |
9965 | /* [<view> VIEWVRFNAME] */ | |
9966 | name = argv[idx + 1]->arg; | |
9967 | if (name) | |
9968 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
9969 | else |
9970 | bgp = bgp_get_default(); | |
acf71666 | 9971 | |
acf71666 MK |
9972 | if (!bgp) { |
9973 | vty_out(vty, "%% No BGP process is configured\n"); | |
9974 | return CMD_WARNING; | |
9975 | } | |
9976 | bgp_show_martian_nexthops(vty, bgp); | |
9977 | ||
9978 | return CMD_SUCCESS; | |
9979 | } | |
9980 | ||
f412b39a | 9981 | DEFUN (show_bgp_memory, |
4bf6a362 | 9982 | show_bgp_memory_cmd, |
7fa12b13 | 9983 | "show [ip] bgp memory", |
4bf6a362 | 9984 | SHOW_STR |
3a2d747c | 9985 | IP_STR |
4bf6a362 PJ |
9986 | BGP_STR |
9987 | "Global BGP memory statistics\n") | |
9988 | { | |
d62a17ae | 9989 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
9990 | unsigned long count; | |
9991 | ||
9992 | /* RIB related usage stats */ | |
9993 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9994 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9995 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 9996 | count * sizeof(struct bgp_dest))); |
d62a17ae | 9997 | |
9998 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9999 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
10000 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 10001 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 10002 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
10003 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
10004 | count, | |
4b7e6066 DS |
10005 | mtype_memstr( |
10006 | memstrbuf, sizeof(memstrbuf), | |
10007 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 10008 | |
10009 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
10010 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
10011 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10012 | count * sizeof(struct bgp_static))); | |
10013 | ||
10014 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
10015 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
10016 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10017 | count * sizeof(struct bpacket))); | |
10018 | ||
10019 | /* Adj-In/Out */ | |
10020 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
10021 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
10022 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10023 | count * sizeof(struct bgp_adj_in))); | |
10024 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
10025 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
10026 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10027 | count * sizeof(struct bgp_adj_out))); | |
10028 | ||
10029 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
10030 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
10031 | count, | |
10032 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10033 | count * sizeof(struct bgp_nexthop_cache))); | |
10034 | ||
10035 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
10036 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
10037 | count, | |
10038 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10039 | count * sizeof(struct bgp_damp_info))); | |
10040 | ||
10041 | /* Attributes */ | |
10042 | count = attr_count(); | |
10043 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
10044 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10045 | count * sizeof(struct attr))); | |
10046 | ||
10047 | if ((count = attr_unknown_count())) | |
10048 | vty_out(vty, "%ld unknown attributes\n", count); | |
10049 | ||
10050 | /* AS_PATH attributes */ | |
10051 | count = aspath_count(); | |
10052 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
10053 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10054 | count * sizeof(struct aspath))); | |
10055 | ||
10056 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
10057 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
10058 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10059 | count * sizeof(struct assegment))); | |
10060 | ||
10061 | /* Other attributes */ | |
10062 | if ((count = community_count())) | |
10063 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10064 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10065 | count * sizeof(struct community))); | |
d62a17ae | 10066 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
10067 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
10068 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10069 | count * sizeof(struct ecommunity))); | |
d62a17ae | 10070 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
10071 | vty_out(vty, | |
10072 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
10073 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10074 | count * sizeof(struct lcommunity))); | |
d62a17ae | 10075 | |
10076 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
10077 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
10078 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10079 | count * sizeof(struct cluster_list))); | |
10080 | ||
10081 | /* Peer related usage */ | |
10082 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
10083 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
10084 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10085 | count * sizeof(struct peer))); | |
10086 | ||
10087 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
10088 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
10089 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
10090 | count * sizeof(struct peer_group))); | |
10091 | ||
10092 | /* Other */ | |
d62a17ae | 10093 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
10094 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
10095 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
10096 | count * sizeof(regex_t))); | |
d62a17ae | 10097 | return CMD_SUCCESS; |
4bf6a362 | 10098 | } |
fee0f4c6 | 10099 | |
57a9c8a8 DS |
10100 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
10101 | { | |
10102 | json_object *bestpath = json_object_new_object(); | |
10103 | ||
892fedb6 | 10104 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
10105 | json_object_string_add(bestpath, "asPath", "ignore"); |
10106 | ||
892fedb6 | 10107 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
10108 | json_object_string_add(bestpath, "asPath", "confed"); |
10109 | ||
892fedb6 DA |
10110 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
10111 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 10112 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10113 | "as-set"); |
10114 | else | |
a4d82a8a | 10115 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
10116 | "true"); |
10117 | } else | |
a4d82a8a | 10118 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 10119 | |
ee88563a JM |
10120 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
10121 | json_object_boolean_true_add(bestpath, "peerTypeRelax"); | |
10122 | ||
892fedb6 | 10123 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 10124 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
10125 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
10126 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
10127 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 10128 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 10129 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
10130 | json_object_string_add(bestpath, "med", |
10131 | "missing-as-worst"); | |
10132 | else | |
10133 | json_object_string_add(bestpath, "med", "true"); | |
10134 | } | |
10135 | ||
10136 | json_object_object_add(json, "bestPath", bestpath); | |
10137 | } | |
10138 | ||
3577f1c5 DD |
10139 | /* Print the error code/subcode for why the peer is down */ |
10140 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
10141 | json_object *json_peer, bool use_json) | |
10142 | { | |
10143 | const char *code_str; | |
10144 | const char *subcode_str; | |
10145 | ||
10146 | if (use_json) { | |
10147 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10148 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10149 | char errorcodesubcode_hexstr[5]; | |
10150 | char errorcodesubcode_str[256]; | |
10151 | ||
10152 | code_str = bgp_notify_code_str(peer->notify.code); | |
10153 | subcode_str = bgp_notify_subcode_str( | |
10154 | peer->notify.code, | |
10155 | peer->notify.subcode); | |
10156 | ||
772270f3 QY |
10157 | snprintf(errorcodesubcode_hexstr, |
10158 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
10159 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
10160 | json_object_string_add(json_peer, |
10161 | "lastErrorCodeSubcode", | |
10162 | errorcodesubcode_hexstr); | |
10163 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10164 | code_str, subcode_str); | |
10165 | json_object_string_add(json_peer, | |
10166 | "lastNotificationReason", | |
10167 | errorcodesubcode_str); | |
eea685b6 DA |
10168 | json_object_boolean_add(json_peer, |
10169 | "lastNotificationHardReset", | |
10170 | peer->notify.hard_reset); | |
3577f1c5 DD |
10171 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED |
10172 | && peer->notify.code == BGP_NOTIFY_CEASE | |
10173 | && (peer->notify.subcode | |
10174 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10175 | || peer->notify.subcode | |
10176 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10177 | && peer->notify.length) { | |
10178 | char msgbuf[1024]; | |
10179 | const char *msg_str; | |
10180 | ||
10181 | msg_str = bgp_notify_admin_message( | |
10182 | msgbuf, sizeof(msgbuf), | |
10183 | (uint8_t *)peer->notify.data, | |
10184 | peer->notify.length); | |
10185 | if (msg_str) | |
10186 | json_object_string_add( | |
10187 | json_peer, | |
10188 | "lastShutdownDescription", | |
10189 | msg_str); | |
10190 | } | |
10191 | ||
c258527b | 10192 | } |
3577f1c5 DD |
10193 | json_object_string_add(json_peer, "lastResetDueTo", |
10194 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
10195 | json_object_int_add(json_peer, "lastResetCode", |
10196 | peer->last_reset); | |
3577f1c5 DD |
10197 | } else { |
10198 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
10199 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10200 | code_str = bgp_notify_code_str(peer->notify.code); | |
10201 | subcode_str = | |
10202 | bgp_notify_subcode_str(peer->notify.code, | |
10203 | peer->notify.subcode); | |
eea685b6 | 10204 | vty_out(vty, " Notification %s (%s%s%s)\n", |
3577f1c5 | 10205 | peer->last_reset == PEER_DOWN_NOTIFY_SEND |
eea685b6 DA |
10206 | ? "sent" |
10207 | : "received", | |
10208 | code_str, subcode_str, | |
10209 | peer->notify.hard_reset | |
10210 | ? bgp_notify_subcode_str( | |
10211 | BGP_NOTIFY_CEASE, | |
10212 | BGP_NOTIFY_CEASE_HARD_RESET) | |
10213 | : ""); | |
3577f1c5 | 10214 | } else { |
e91c24c8 | 10215 | vty_out(vty, " %s\n", |
3577f1c5 DD |
10216 | peer_down_str[(int)peer->last_reset]); |
10217 | } | |
10218 | } | |
10219 | } | |
10220 | ||
10221 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
10222 | safi_t safi) | |
10223 | { | |
feb17238 | 10224 | return ((!peer_established(peer)) || !peer->afc_recv[afi][safi]); |
3577f1c5 DD |
10225 | } |
10226 | ||
10227 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
10228 | struct peer *peer, json_object *json_peer, | |
10229 | int max_neighbor_width, bool use_json) | |
10230 | { | |
10231 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10232 | int len; | |
10233 | ||
10234 | if (use_json) { | |
10235 | if (peer_dynamic_neighbor(peer)) | |
10236 | json_object_boolean_true_add(json_peer, | |
10237 | "dynamicPeer"); | |
10238 | if (peer->hostname) | |
10239 | json_object_string_add(json_peer, "hostname", | |
10240 | peer->hostname); | |
10241 | ||
10242 | if (peer->domainname) | |
10243 | json_object_string_add(json_peer, "domainname", | |
10244 | peer->domainname); | |
10245 | json_object_int_add(json_peer, "connectionsEstablished", | |
10246 | peer->established); | |
10247 | json_object_int_add(json_peer, "connectionsDropped", | |
10248 | peer->dropped); | |
10249 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
10250 | use_json, json_peer); | |
feb17238 | 10251 | if (peer_established(peer)) |
3577f1c5 DD |
10252 | json_object_string_add(json_peer, "lastResetDueTo", |
10253 | "AFI/SAFI Not Negotiated"); | |
10254 | else | |
10255 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
10256 | } else { | |
10257 | dn_flag[1] = '\0'; | |
10258 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
10259 | if (peer->hostname | |
892fedb6 | 10260 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
10261 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
10262 | peer->hostname, peer->host); | |
10263 | else | |
10264 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
10265 | ||
10266 | /* pad the neighbor column with spaces */ | |
10267 | if (len < max_neighbor_width) | |
10268 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10269 | " "); | |
e91c24c8 | 10270 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
10271 | peer->dropped, |
10272 | peer_uptime(peer->uptime, timebuf, | |
10273 | BGP_UPTIME_LEN, 0, NULL)); | |
feb17238 | 10274 | if (peer_established(peer)) |
3577f1c5 DD |
10275 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); |
10276 | else | |
10277 | bgp_show_peer_reset(vty, peer, NULL, | |
10278 | false); | |
10279 | } | |
10280 | } | |
c258527b | 10281 | |
565e9ddd | 10282 | /* Strip peer's description to the given size. */ |
cb75bb31 DA |
10283 | static char *bgp_peer_description_stripped(char *desc, uint32_t size) |
10284 | { | |
10285 | static char stripped[BUFSIZ]; | |
cb75bb31 DA |
10286 | uint32_t len = size > strlen(desc) ? strlen(desc) : size; |
10287 | ||
cb75bb31 DA |
10288 | strlcpy(stripped, desc, len + 1); |
10289 | ||
10290 | return stripped; | |
10291 | } | |
3577f1c5 | 10292 | |
8c1d4cd5 LS |
10293 | /* Determine whether var peer should be filtered out of the summary. */ |
10294 | static bool bgp_show_summary_is_peer_filtered(struct peer *peer, | |
10295 | struct peer *fpeer, int as_type, | |
10296 | as_t as) | |
10297 | { | |
10298 | ||
10299 | /* filter neighbor XXXX */ | |
10300 | if (fpeer && fpeer != peer) | |
10301 | return true; | |
10302 | ||
10303 | /* filter remote-as (internal|external) */ | |
10304 | if (as_type != AS_UNSPECIFIED) { | |
10305 | if (peer->as_type == AS_SPECIFIED) { | |
10306 | if (as_type == AS_INTERNAL) { | |
10307 | if (peer->as != peer->local_as) | |
10308 | return true; | |
10309 | } else if (peer->as == peer->local_as) | |
10310 | return true; | |
10311 | } else if (as_type != peer->as_type) | |
10312 | return true; | |
10313 | } else if (as && as != peer->as) /* filter remote-as XXX */ | |
10314 | return true; | |
10315 | ||
10316 | return false; | |
10317 | } | |
10318 | ||
565e9ddd DA |
10319 | /* Show BGP peer's summary information. |
10320 | * | |
10321 | * Peer's description is stripped according to if `wide` option is given | |
10322 | * or not. | |
10323 | * | |
10324 | * When adding new columns to `show bgp summary` output, please make | |
10325 | * sure `Desc` is the lastest column to show because it can contain | |
10326 | * whitespaces and the whole output will be tricky. | |
10327 | */ | |
d62a17ae | 10328 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
8c1d4cd5 | 10329 | struct peer *fpeer, int as_type, as_t as, |
96c81f66 | 10330 | uint16_t show_flags) |
d62a17ae | 10331 | { |
10332 | struct peer *peer; | |
10333 | struct listnode *node, *nnode; | |
10334 | unsigned int count = 0, dn_count = 0; | |
10335 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
10336 | char neighbor_buf[VTY_BUFSIZ]; | |
10337 | int neighbor_col_default_width = 16; | |
3577f1c5 | 10338 | int len, failed_count = 0; |
ce1944f0 | 10339 | unsigned int filtered_count = 0; |
d62a17ae | 10340 | int max_neighbor_width = 0; |
10341 | int pfx_rcd_safi; | |
3c13337d | 10342 | json_object *json = NULL; |
d62a17ae | 10343 | json_object *json_peer = NULL; |
10344 | json_object *json_peers = NULL; | |
50e05855 | 10345 | struct peer_af *paf; |
d3ada366 | 10346 | struct bgp_filter *filter; |
85eeb029 DA |
10347 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
10348 | bool show_failed = CHECK_FLAG(show_flags, BGP_SHOW_OPT_FAILED); | |
10349 | bool show_established = | |
10350 | CHECK_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); | |
10351 | bool show_wide = CHECK_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
96c81f66 | 10352 | bool show_terse = CHECK_FLAG(show_flags, BGP_SHOW_OPT_TERSE); |
d62a17ae | 10353 | |
10354 | /* labeled-unicast routes are installed in the unicast table so in order | |
10355 | * to | |
10356 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
10357 | */ | |
3577f1c5 | 10358 | |
d62a17ae | 10359 | if (safi == SAFI_LABELED_UNICAST) |
10360 | pfx_rcd_safi = SAFI_UNICAST; | |
10361 | else | |
10362 | pfx_rcd_safi = safi; | |
10363 | ||
10364 | if (use_json) { | |
3c13337d | 10365 | json = json_object_new_object(); |
d62a17ae | 10366 | json_peers = json_object_new_object(); |
3577f1c5 | 10367 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8c1d4cd5 LS |
10368 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10369 | as_type, as)) { | |
ce1944f0 | 10370 | filtered_count++; |
8c1d4cd5 LS |
10371 | count++; |
10372 | continue; | |
10373 | } | |
10374 | ||
3577f1c5 DD |
10375 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10376 | continue; | |
10377 | ||
10378 | if (peer->afc[afi][safi]) { | |
10379 | /* See if we have at least a single failed peer */ | |
10380 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10381 | failed_count++; | |
10382 | count++; | |
10383 | } | |
10384 | if (peer_dynamic_neighbor(peer)) | |
10385 | dn_count++; | |
10386 | } | |
c258527b | 10387 | |
d62a17ae | 10388 | } else { |
10389 | /* Loop over all neighbors that will be displayed to determine | |
10390 | * how many | |
10391 | * characters are needed for the Neighbor column | |
10392 | */ | |
10393 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8c1d4cd5 LS |
10394 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
10395 | as_type, as)) { | |
ce1944f0 | 10396 | filtered_count++; |
8c1d4cd5 LS |
10397 | count++; |
10398 | continue; | |
10399 | } | |
10400 | ||
d62a17ae | 10401 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
10402 | continue; | |
10403 | ||
10404 | if (peer->afc[afi][safi]) { | |
10405 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10406 | if (peer_dynamic_neighbor(peer)) | |
10407 | dn_flag[0] = '*'; | |
10408 | ||
10409 | if (peer->hostname | |
892fedb6 DA |
10410 | && CHECK_FLAG(bgp->flags, |
10411 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
10412 | snprintf(neighbor_buf, |
10413 | sizeof(neighbor_buf), | |
10414 | "%s%s(%s) ", dn_flag, | |
10415 | peer->hostname, peer->host); | |
d62a17ae | 10416 | else |
772270f3 QY |
10417 | snprintf(neighbor_buf, |
10418 | sizeof(neighbor_buf), "%s%s ", | |
10419 | dn_flag, peer->host); | |
d62a17ae | 10420 | |
10421 | len = strlen(neighbor_buf); | |
10422 | ||
10423 | if (len > max_neighbor_width) | |
10424 | max_neighbor_width = len; | |
c258527b | 10425 | |
3577f1c5 DD |
10426 | /* See if we have at least a single failed peer */ |
10427 | if (bgp_has_peer_failed(peer, afi, safi)) | |
10428 | failed_count++; | |
10429 | count++; | |
d62a17ae | 10430 | } |
10431 | } | |
f933309e | 10432 | |
d62a17ae | 10433 | /* Originally we displayed the Neighbor column as 16 |
10434 | * characters wide so make that the default | |
10435 | */ | |
10436 | if (max_neighbor_width < neighbor_col_default_width) | |
10437 | max_neighbor_width = neighbor_col_default_width; | |
10438 | } | |
f933309e | 10439 | |
3577f1c5 DD |
10440 | if (show_failed && !failed_count) { |
10441 | if (use_json) { | |
10442 | json_object_int_add(json, "failedPeersCount", 0); | |
10443 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 10444 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 | 10445 | |
75eeda93 | 10446 | vty_json(vty, json); |
3577f1c5 DD |
10447 | } else { |
10448 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
3577f1c5 DD |
10449 | } |
10450 | return CMD_SUCCESS; | |
10451 | } | |
c258527b | 10452 | |
3577f1c5 | 10453 | count = 0; /* Reset the value as its used again */ |
ce1944f0 | 10454 | filtered_count = 0; |
800867d8 | 10455 | dn_count = 0; |
d62a17ae | 10456 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
10457 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10458 | continue; | |
10459 | ||
ea47320b DL |
10460 | if (!peer->afc[afi][safi]) |
10461 | continue; | |
d62a17ae | 10462 | |
ea47320b DL |
10463 | if (!count) { |
10464 | unsigned long ents; | |
10465 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 10466 | int64_t vrf_id_ui; |
d62a17ae | 10467 | |
a4d82a8a PZ |
10468 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
10469 | ? -1 | |
10470 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
10471 | |
10472 | /* Usage summary and header */ | |
10473 | if (use_json) { | |
c949c771 DA |
10474 | json_object_string_addf(json, "routerId", |
10475 | "%pI4", | |
10476 | &bgp->router_id); | |
60466a63 QY |
10477 | json_object_int_add(json, "as", bgp->as); |
10478 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
10479 | json_object_string_add( |
10480 | json, "vrfName", | |
10481 | (bgp->inst_type | |
10482 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10483 | ? VRF_DEFAULT_NAME |
ea47320b DL |
10484 | : bgp->name); |
10485 | } else { | |
10486 | vty_out(vty, | |
23d0a753 DA |
10487 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
10488 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
10489 | bgp->vrf_id == VRF_UNKNOWN |
10490 | ? -1 | |
10491 | : (int)bgp->vrf_id); | |
ea47320b DL |
10492 | vty_out(vty, "\n"); |
10493 | } | |
d62a17ae | 10494 | |
ea47320b | 10495 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 10496 | if (use_json) { |
ea47320b | 10497 | json_object_int_add( |
60466a63 | 10498 | json, "updateDelayLimit", |
ea47320b | 10499 | bgp->v_update_delay); |
d62a17ae | 10500 | |
ea47320b DL |
10501 | if (bgp->v_update_delay |
10502 | != bgp->v_establish_wait) | |
d62a17ae | 10503 | json_object_int_add( |
10504 | json, | |
ea47320b DL |
10505 | "updateDelayEstablishWait", |
10506 | bgp->v_establish_wait); | |
d62a17ae | 10507 | |
60466a63 | 10508 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10509 | json_object_string_add( |
10510 | json, | |
10511 | "updateDelayFirstNeighbor", | |
10512 | bgp->update_delay_begin_time); | |
10513 | json_object_boolean_true_add( | |
10514 | json, | |
10515 | "updateDelayInProgress"); | |
10516 | } else { | |
10517 | if (bgp->update_delay_over) { | |
d62a17ae | 10518 | json_object_string_add( |
10519 | json, | |
10520 | "updateDelayFirstNeighbor", | |
10521 | bgp->update_delay_begin_time); | |
ea47320b | 10522 | json_object_string_add( |
d62a17ae | 10523 | json, |
ea47320b DL |
10524 | "updateDelayBestpathResumed", |
10525 | bgp->update_delay_end_time); | |
10526 | json_object_string_add( | |
d62a17ae | 10527 | json, |
ea47320b DL |
10528 | "updateDelayZebraUpdateResume", |
10529 | bgp->update_delay_zebra_resume_time); | |
10530 | json_object_string_add( | |
10531 | json, | |
10532 | "updateDelayPeerUpdateResume", | |
10533 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10534 | } |
ea47320b DL |
10535 | } |
10536 | } else { | |
10537 | vty_out(vty, | |
10538 | "Read-only mode update-delay limit: %d seconds\n", | |
10539 | bgp->v_update_delay); | |
10540 | if (bgp->v_update_delay | |
10541 | != bgp->v_establish_wait) | |
d62a17ae | 10542 | vty_out(vty, |
ea47320b DL |
10543 | " Establish wait: %d seconds\n", |
10544 | bgp->v_establish_wait); | |
d62a17ae | 10545 | |
60466a63 | 10546 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
10547 | vty_out(vty, |
10548 | " First neighbor established: %s\n", | |
10549 | bgp->update_delay_begin_time); | |
10550 | vty_out(vty, | |
10551 | " Delay in progress\n"); | |
10552 | } else { | |
10553 | if (bgp->update_delay_over) { | |
d62a17ae | 10554 | vty_out(vty, |
10555 | " First neighbor established: %s\n", | |
10556 | bgp->update_delay_begin_time); | |
10557 | vty_out(vty, | |
ea47320b DL |
10558 | " Best-paths resumed: %s\n", |
10559 | bgp->update_delay_end_time); | |
10560 | vty_out(vty, | |
10561 | " zebra update resumed: %s\n", | |
10562 | bgp->update_delay_zebra_resume_time); | |
10563 | vty_out(vty, | |
10564 | " peers update resumed: %s\n", | |
10565 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 10566 | } |
10567 | } | |
10568 | } | |
ea47320b | 10569 | } |
d62a17ae | 10570 | |
ea47320b DL |
10571 | if (use_json) { |
10572 | if (bgp_maxmed_onstartup_configured(bgp) | |
10573 | && bgp->maxmed_active) | |
10574 | json_object_boolean_true_add( | |
60466a63 | 10575 | json, "maxMedOnStartup"); |
ea47320b DL |
10576 | if (bgp->v_maxmed_admin) |
10577 | json_object_boolean_true_add( | |
60466a63 | 10578 | json, "maxMedAdministrative"); |
d62a17ae | 10579 | |
ea47320b DL |
10580 | json_object_int_add( |
10581 | json, "tableVersion", | |
60466a63 | 10582 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 10583 | |
60466a63 QY |
10584 | ents = bgp_table_count(bgp->rib[afi][safi]); |
10585 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
10586 | json_object_int_add( |
10587 | json, "ribMemory", | |
9bcb3eef | 10588 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 10589 | |
210ec2a0 | 10590 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
10591 | json_object_int_add(json, "peerCount", ents); |
10592 | json_object_int_add(json, "peerMemory", | |
10593 | ents * sizeof(struct peer)); | |
d62a17ae | 10594 | |
ea47320b DL |
10595 | if ((ents = listcount(bgp->group))) { |
10596 | json_object_int_add( | |
60466a63 | 10597 | json, "peerGroupCount", ents); |
ea47320b DL |
10598 | json_object_int_add( |
10599 | json, "peerGroupMemory", | |
996c9314 LB |
10600 | ents * sizeof(struct |
10601 | peer_group)); | |
ea47320b | 10602 | } |
d62a17ae | 10603 | |
ea47320b DL |
10604 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
10605 | BGP_CONFIG_DAMPENING)) | |
10606 | json_object_boolean_true_add( | |
60466a63 | 10607 | json, "dampeningEnabled"); |
ea47320b | 10608 | } else { |
96c81f66 LS |
10609 | if (!show_terse) { |
10610 | if (bgp_maxmed_onstartup_configured(bgp) | |
10611 | && bgp->maxmed_active) | |
10612 | vty_out(vty, | |
10613 | "Max-med on-startup active\n"); | |
10614 | if (bgp->v_maxmed_admin) | |
10615 | vty_out(vty, | |
10616 | "Max-med administrative active\n"); | |
d62a17ae | 10617 | |
96c81f66 LS |
10618 | vty_out(vty, |
10619 | "BGP table version %" PRIu64 | |
10620 | "\n", | |
10621 | bgp_table_version( | |
10622 | bgp->rib[afi][safi])); | |
ea47320b | 10623 | |
96c81f66 LS |
10624 | ents = bgp_table_count( |
10625 | bgp->rib[afi][safi]); | |
d62a17ae | 10626 | vty_out(vty, |
96c81f66 | 10627 | "RIB entries %ld, using %s of memory\n", |
d62a17ae | 10628 | ents, |
10629 | mtype_memstr( | |
10630 | memstrbuf, | |
10631 | sizeof(memstrbuf), | |
96c81f66 LS |
10632 | ents |
10633 | * sizeof( | |
10634 | struct | |
10635 | bgp_dest))); | |
d62a17ae | 10636 | |
96c81f66 LS |
10637 | /* Peer related usage */ |
10638 | ents = bgp->af_peer_count[afi][safi]; | |
10639 | vty_out(vty, | |
10640 | "Peers %ld, using %s of memory\n", | |
10641 | ents, | |
10642 | mtype_memstr( | |
10643 | memstrbuf, | |
10644 | sizeof(memstrbuf), | |
10645 | ents | |
10646 | * sizeof( | |
10647 | struct | |
10648 | peer))); | |
d62a17ae | 10649 | |
96c81f66 LS |
10650 | if ((ents = listcount(bgp->group))) |
10651 | vty_out(vty, | |
10652 | "Peer groups %ld, using %s of memory\n", | |
10653 | ents, | |
10654 | mtype_memstr( | |
10655 | memstrbuf, | |
10656 | sizeof(memstrbuf), | |
10657 | ents | |
10658 | * sizeof( | |
10659 | struct | |
10660 | peer_group))); | |
10661 | ||
10662 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
10663 | BGP_CONFIG_DAMPENING)) | |
10664 | vty_out(vty, | |
10665 | "Dampening enabled.\n"); | |
10666 | } | |
10667 | if (show_failed) { | |
10668 | vty_out(vty, "\n"); | |
10669 | ||
10670 | /* Subtract 8 here because 'Neighbor' is | |
10671 | * 8 characters */ | |
10672 | vty_out(vty, "Neighbor"); | |
10673 | vty_out(vty, "%*s", | |
10674 | max_neighbor_width - 8, " "); | |
85eeb029 DA |
10675 | vty_out(vty, |
10676 | BGP_SHOW_SUMMARY_HEADER_FAILED); | |
96c81f66 | 10677 | } |
d62a17ae | 10678 | } |
ea47320b | 10679 | } |
d62a17ae | 10680 | |
d55811cc | 10681 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 10682 | filter = &peer->filter[afi][safi]; |
db92d226 | 10683 | |
ea47320b | 10684 | count++; |
3577f1c5 DD |
10685 | /* Works for both failed & successful cases */ |
10686 | if (peer_dynamic_neighbor(peer)) | |
10687 | dn_count++; | |
d62a17ae | 10688 | |
ea47320b | 10689 | if (use_json) { |
3577f1c5 | 10690 | json_peer = NULL; |
8c1d4cd5 | 10691 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10692 | as_type, as)) { |
10693 | filtered_count++; | |
8c1d4cd5 | 10694 | continue; |
ce1944f0 | 10695 | } |
3577f1c5 DD |
10696 | if (show_failed && |
10697 | bgp_has_peer_failed(peer, afi, safi)) { | |
10698 | json_peer = json_object_new_object(); | |
10699 | bgp_show_failed_summary(vty, bgp, peer, | |
10700 | json_peer, 0, use_json); | |
10701 | } else if (!show_failed) { | |
10b49f14 | 10702 | if (show_established |
ce1944f0 LS |
10703 | && bgp_has_peer_failed(peer, afi, safi)) { |
10704 | filtered_count++; | |
10b49f14 | 10705 | continue; |
ce1944f0 | 10706 | } |
10b49f14 | 10707 | |
3577f1c5 DD |
10708 | json_peer = json_object_new_object(); |
10709 | if (peer_dynamic_neighbor(peer)) { | |
10710 | json_object_boolean_true_add(json_peer, | |
10711 | "dynamicPeer"); | |
10712 | } | |
d62a17ae | 10713 | |
3577f1c5 DD |
10714 | if (peer->hostname) |
10715 | json_object_string_add(json_peer, "hostname", | |
10716 | peer->hostname); | |
10717 | ||
10718 | if (peer->domainname) | |
10719 | json_object_string_add(json_peer, "domainname", | |
10720 | peer->domainname); | |
10721 | ||
10722 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
c854765f DA |
10723 | json_object_int_add( |
10724 | json_peer, "localAs", | |
10725 | peer->change_local_as | |
10726 | ? peer->change_local_as | |
10727 | : peer->local_as); | |
3577f1c5 DD |
10728 | json_object_int_add(json_peer, "version", 4); |
10729 | json_object_int_add(json_peer, "msgRcvd", | |
10730 | PEER_TOTAL_RX(peer)); | |
10731 | json_object_int_add(json_peer, "msgSent", | |
10732 | PEER_TOTAL_TX(peer)); | |
10733 | ||
43aa5965 QY |
10734 | atomic_size_t outq_count, inq_count; |
10735 | outq_count = atomic_load_explicit( | |
10736 | &peer->obuf->count, | |
10737 | memory_order_relaxed); | |
10738 | inq_count = atomic_load_explicit( | |
10739 | &peer->ibuf->count, | |
10740 | memory_order_relaxed); | |
10741 | ||
3577f1c5 DD |
10742 | json_object_int_add(json_peer, "tableVersion", |
10743 | peer->version[afi][safi]); | |
10744 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
10745 | outq_count); |
10746 | json_object_int_add(json_peer, "inq", | |
10747 | inq_count); | |
3577f1c5 DD |
10748 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
10749 | use_json, json_peer); | |
10750 | ||
3577f1c5 DD |
10751 | json_object_int_add(json_peer, "pfxRcd", |
10752 | peer->pcount[afi][pfx_rcd_safi]); | |
10753 | ||
3577f1c5 | 10754 | if (paf && PAF_SUBGRP(paf)) |
a616dd1f DA |
10755 | json_object_int_add( |
10756 | json_peer, "pfxSnt", | |
10757 | (PAF_SUBGRP(paf))->scount); | |
10758 | else | |
10759 | json_object_int_add(json_peer, "pfxSnt", | |
10760 | 0); | |
0e1f8ab5 DA |
10761 | |
10762 | /* BGP FSM state */ | |
cb9196e7 | 10763 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10764 | || CHECK_FLAG(peer->bgp->flags, |
10765 | BGP_FLAG_SHUTDOWN)) | |
0e1f8ab5 DA |
10766 | json_object_string_add(json_peer, |
10767 | "state", | |
3577f1c5 DD |
10768 | "Idle (Admin)"); |
10769 | else if (peer->afc_recv[afi][safi]) | |
10770 | json_object_string_add( | |
0e1f8ab5 DA |
10771 | json_peer, "state", |
10772 | lookup_msg(bgp_status_msg, | |
10773 | peer->status, NULL)); | |
10774 | else if (CHECK_FLAG( | |
10775 | peer->sflags, | |
10776 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10777 | json_object_string_add(json_peer, | |
10778 | "state", | |
3577f1c5 DD |
10779 | "Idle (PfxCt)"); |
10780 | else | |
10781 | json_object_string_add( | |
0e1f8ab5 DA |
10782 | json_peer, "state", |
10783 | lookup_msg(bgp_status_msg, | |
10784 | peer->status, NULL)); | |
10785 | ||
10786 | /* BGP peer state */ | |
10787 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) | |
10788 | || CHECK_FLAG(peer->bgp->flags, | |
10789 | BGP_FLAG_SHUTDOWN)) | |
10790 | json_object_string_add(json_peer, | |
10791 | "peerState", | |
10792 | "Admin"); | |
10793 | else if (CHECK_FLAG( | |
10794 | peer->sflags, | |
10795 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10796 | json_object_string_add(json_peer, | |
10797 | "peerState", | |
10798 | "PfxCt"); | |
10799 | else if (CHECK_FLAG(peer->flags, | |
10800 | PEER_FLAG_PASSIVE)) | |
10801 | json_object_string_add(json_peer, | |
10802 | "peerState", | |
10803 | "Passive"); | |
10804 | else if (CHECK_FLAG(peer->sflags, | |
10805 | PEER_STATUS_NSF_WAIT)) | |
10806 | json_object_string_add(json_peer, | |
10807 | "peerState", | |
10808 | "NSF passive"); | |
10809 | else if (CHECK_FLAG( | |
10810 | peer->bgp->flags, | |
10811 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10812 | && (!bgp_inbound_policy_exists(peer, | |
10813 | filter) | |
10814 | || !bgp_outbound_policy_exists( | |
10815 | peer, filter))) | |
10816 | json_object_string_add(json_peer, | |
10817 | "peerState", | |
10818 | "Policy"); | |
10819 | else | |
10820 | json_object_string_add( | |
10821 | json_peer, "peerState", "OK"); | |
10822 | ||
200116db DD |
10823 | json_object_int_add(json_peer, "connectionsEstablished", |
10824 | peer->established); | |
10825 | json_object_int_add(json_peer, "connectionsDropped", | |
10826 | peer->dropped); | |
aa72bd7e PG |
10827 | if (peer->desc) |
10828 | json_object_string_add( | |
10829 | json_peer, "desc", peer->desc); | |
b4e9dcba | 10830 | } |
3577f1c5 DD |
10831 | /* Avoid creating empty peer dicts in JSON */ |
10832 | if (json_peer == NULL) | |
10833 | continue; | |
ea47320b DL |
10834 | |
10835 | if (peer->conf_if) | |
60466a63 | 10836 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10837 | "interface"); |
10838 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10839 | json_object_string_add(json_peer, "idType", |
10840 | "ipv4"); | |
ea47320b | 10841 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10842 | json_object_string_add(json_peer, "idType", |
10843 | "ipv6"); | |
ea47320b DL |
10844 | json_object_object_add(json_peers, peer->host, |
10845 | json_peer); | |
10846 | } else { | |
8c1d4cd5 | 10847 | if (bgp_show_summary_is_peer_filtered(peer, fpeer, |
ce1944f0 LS |
10848 | as_type, as)) { |
10849 | filtered_count++; | |
8c1d4cd5 | 10850 | continue; |
ce1944f0 | 10851 | } |
3577f1c5 DD |
10852 | if (show_failed && |
10853 | bgp_has_peer_failed(peer, afi, safi)) { | |
10854 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10855 | max_neighbor_width, | |
10856 | use_json); | |
10857 | } else if (!show_failed) { | |
10b49f14 | 10858 | if (show_established |
ce1944f0 LS |
10859 | && bgp_has_peer_failed(peer, afi, safi)) { |
10860 | filtered_count++; | |
10b49f14 | 10861 | continue; |
ce1944f0 | 10862 | } |
96c81f66 LS |
10863 | |
10864 | if ((count - filtered_count) == 1) { | |
10865 | /* display headline before the first | |
10866 | * neighbor line */ | |
10867 | vty_out(vty, "\n"); | |
10868 | ||
10869 | /* Subtract 8 here because 'Neighbor' is | |
10870 | * 8 characters */ | |
10871 | vty_out(vty, "Neighbor"); | |
10872 | vty_out(vty, "%*s", | |
10873 | max_neighbor_width - 8, " "); | |
10874 | vty_out(vty, | |
10875 | show_wide | |
10876 | ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE | |
10877 | : BGP_SHOW_SUMMARY_HEADER_ALL); | |
10878 | } | |
10879 | ||
3577f1c5 DD |
10880 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10881 | if (peer_dynamic_neighbor(peer)) { | |
10882 | dn_flag[0] = '*'; | |
10883 | } | |
d62a17ae | 10884 | |
3577f1c5 | 10885 | if (peer->hostname |
892fedb6 DA |
10886 | && CHECK_FLAG(bgp->flags, |
10887 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10888 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10889 | peer->hostname, |
10890 | peer->host); | |
d62a17ae | 10891 | else |
3577f1c5 DD |
10892 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10893 | ||
10894 | /* pad the neighbor column with spaces */ | |
10895 | if (len < max_neighbor_width) | |
10896 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10897 | " "); | |
10898 | ||
43aa5965 QY |
10899 | atomic_size_t outq_count, inq_count; |
10900 | outq_count = atomic_load_explicit( | |
10901 | &peer->obuf->count, | |
10902 | memory_order_relaxed); | |
10903 | inq_count = atomic_load_explicit( | |
10904 | &peer->ibuf->count, | |
10905 | memory_order_relaxed); | |
10906 | ||
85eeb029 DA |
10907 | if (show_wide) |
10908 | vty_out(vty, | |
10909 | "4 %10u %10u %9u %9u %8" PRIu64 | |
10910 | " %4zu %4zu %8s", | |
10911 | peer->as, | |
10912 | peer->change_local_as | |
10913 | ? peer->change_local_as | |
10914 | : peer->local_as, | |
10915 | PEER_TOTAL_RX(peer), | |
10916 | PEER_TOTAL_TX(peer), | |
10917 | peer->version[afi][safi], | |
10918 | inq_count, outq_count, | |
10919 | peer_uptime(peer->uptime, | |
10920 | timebuf, | |
10921 | BGP_UPTIME_LEN, 0, | |
10922 | NULL)); | |
10923 | else | |
10924 | vty_out(vty, "4 %10u %9u %9u %8" PRIu64 | |
10925 | " %4zu %4zu %8s", | |
10926 | peer->as, PEER_TOTAL_RX(peer), | |
10927 | PEER_TOTAL_TX(peer), | |
10928 | peer->version[afi][safi], | |
10929 | inq_count, outq_count, | |
10930 | peer_uptime(peer->uptime, | |
10931 | timebuf, | |
10932 | BGP_UPTIME_LEN, 0, | |
10933 | NULL)); | |
3577f1c5 | 10934 | |
feb17238 | 10935 | if (peer_established(peer)) { |
d3ada366 DA |
10936 | if (peer->afc_recv[afi][safi]) { |
10937 | if (CHECK_FLAG( | |
10938 | bgp->flags, | |
10939 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10940 | && !bgp_inbound_policy_exists( | |
10941 | peer, filter)) | |
10942 | vty_out(vty, " %12s", | |
10943 | "(Policy)"); | |
10944 | else | |
10945 | vty_out(vty, | |
6cde4b45 | 10946 | " %12u", |
d3ada366 DA |
10947 | peer->pcount |
10948 | [afi] | |
10949 | [pfx_rcd_safi]); | |
10950 | } else { | |
749d0f27 | 10951 | vty_out(vty, " NoNeg"); |
d3ada366 | 10952 | } |
db92d226 | 10953 | |
d3ada366 DA |
10954 | if (paf && PAF_SUBGRP(paf)) { |
10955 | if (CHECK_FLAG( | |
10956 | bgp->flags, | |
10957 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10958 | && !bgp_outbound_policy_exists( | |
10959 | peer, filter)) | |
10960 | vty_out(vty, " %8s", | |
10961 | "(Policy)"); | |
10962 | else | |
10963 | vty_out(vty, | |
6cde4b45 | 10964 | " %8u", |
d3ada366 DA |
10965 | (PAF_SUBGRP( |
10966 | paf)) | |
10967 | ->scount); | |
749d0f27 DA |
10968 | } else { |
10969 | vty_out(vty, " NoNeg"); | |
d3ada366 | 10970 | } |
db92d226 | 10971 | } else { |
736b68f3 DS |
10972 | if (CHECK_FLAG(peer->flags, |
10973 | PEER_FLAG_SHUTDOWN) | |
10974 | || CHECK_FLAG(peer->bgp->flags, | |
10975 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10976 | vty_out(vty, " Idle (Admin)"); |
10977 | else if (CHECK_FLAG( | |
10978 | peer->sflags, | |
10979 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10980 | vty_out(vty, " Idle (PfxCt)"); | |
10981 | else | |
10982 | vty_out(vty, " %12s", | |
10983 | lookup_msg(bgp_status_msg, | |
10984 | peer->status, NULL)); | |
db92d226 | 10985 | |
6cde4b45 | 10986 | vty_out(vty, " %8u", 0); |
3577f1c5 | 10987 | } |
565e9ddd DA |
10988 | /* Make sure `Desc` column is the lastest in |
10989 | * the output. | |
10990 | */ | |
aa72bd7e | 10991 | if (peer->desc) |
cb75bb31 DA |
10992 | vty_out(vty, " %s", |
10993 | bgp_peer_description_stripped( | |
85eeb029 DA |
10994 | peer->desc, |
10995 | show_wide ? 64 : 20)); | |
aa72bd7e PG |
10996 | else |
10997 | vty_out(vty, " N/A"); | |
3577f1c5 | 10998 | vty_out(vty, "\n"); |
d62a17ae | 10999 | } |
3577f1c5 | 11000 | |
d62a17ae | 11001 | } |
11002 | } | |
f933309e | 11003 | |
d62a17ae | 11004 | if (use_json) { |
11005 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 11006 | json_object_int_add(json, "failedPeers", failed_count); |
ce1944f0 LS |
11007 | json_object_int_add(json, "displayedPeers", |
11008 | count - filtered_count); | |
d62a17ae | 11009 | json_object_int_add(json, "totalPeers", count); |
11010 | json_object_int_add(json, "dynamicPeers", dn_count); | |
11011 | ||
3577f1c5 DD |
11012 | if (!show_failed) |
11013 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 11014 | |
75eeda93 | 11015 | vty_json(vty, json); |
d62a17ae | 11016 | } else { |
ce1944f0 | 11017 | if (count) { |
96c81f66 LS |
11018 | if (filtered_count == count) |
11019 | vty_out(vty, "\n%% No matching neighbor\n"); | |
11020 | else { | |
11021 | if (show_failed) | |
11022 | vty_out(vty, "\nDisplayed neighbors %d", | |
11023 | failed_count); | |
11024 | else if (as_type != AS_UNSPECIFIED || as | |
11025 | || fpeer || show_established) | |
ce1944f0 LS |
11026 | vty_out(vty, "\nDisplayed neighbors %d", |
11027 | count - filtered_count); | |
96c81f66 LS |
11028 | |
11029 | vty_out(vty, "\nTotal number of neighbors %d\n", | |
11030 | count); | |
ce1944f0 | 11031 | } |
ce1944f0 | 11032 | } else { |
d6ceaca3 | 11033 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 11034 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11035 | } |
b05a1c8b | 11036 | |
d6ceaca3 | 11037 | if (dn_count) { |
d62a17ae | 11038 | vty_out(vty, "* - dynamic neighbor\n"); |
11039 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
11040 | dn_count, bgp->dynamic_neighbors_limit); | |
11041 | } | |
11042 | } | |
1ff9a340 | 11043 | |
d62a17ae | 11044 | return CMD_SUCCESS; |
718e3744 | 11045 | } |
11046 | ||
d62a17ae | 11047 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
8c1d4cd5 | 11048 | int safi, struct peer *fpeer, int as_type, |
96c81f66 | 11049 | as_t as, uint16_t show_flags) |
d62a17ae | 11050 | { |
11051 | int is_first = 1; | |
11052 | int afi_wildcard = (afi == AFI_MAX); | |
11053 | int safi_wildcard = (safi == SAFI_MAX); | |
11054 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 11055 | bool nbr_output = false; |
85eeb029 | 11056 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11057 | |
11058 | if (use_json && is_wildcard) | |
11059 | vty_out(vty, "{\n"); | |
11060 | if (afi_wildcard) | |
11061 | afi = 1; /* AFI_IP */ | |
11062 | while (afi < AFI_MAX) { | |
11063 | if (safi_wildcard) | |
11064 | safi = 1; /* SAFI_UNICAST */ | |
11065 | while (safi < SAFI_MAX) { | |
318cac96 | 11066 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 11067 | nbr_output = true; |
f86897b9 | 11068 | |
d62a17ae | 11069 | if (is_wildcard) { |
11070 | /* | |
11071 | * So limit output to those afi/safi | |
11072 | * pairs that | |
11073 | * actualy have something interesting in | |
11074 | * them | |
11075 | */ | |
11076 | if (use_json) { | |
d62a17ae | 11077 | if (!is_first) |
11078 | vty_out(vty, ",\n"); | |
11079 | else | |
11080 | is_first = 0; | |
11081 | ||
11082 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
11083 | get_afi_safi_str(afi, |
11084 | safi, | |
11085 | true)); | |
d62a17ae | 11086 | } else { |
6cac2fcc LS |
11087 | vty_out(vty, |
11088 | "\n%s Summary (%s):\n", | |
5cb5f4d0 DD |
11089 | get_afi_safi_str(afi, |
11090 | safi, | |
6cac2fcc LS |
11091 | false), |
11092 | bgp->name_pretty); | |
d62a17ae | 11093 | } |
11094 | } | |
8c1d4cd5 LS |
11095 | bgp_show_summary(vty, bgp, afi, safi, fpeer, |
11096 | as_type, as, show_flags); | |
d62a17ae | 11097 | } |
11098 | safi++; | |
d62a17ae | 11099 | if (!safi_wildcard) |
11100 | safi = SAFI_MAX; | |
11101 | } | |
11102 | afi++; | |
ee851c8c | 11103 | if (!afi_wildcard) |
d62a17ae | 11104 | afi = AFI_MAX; |
11105 | } | |
11106 | ||
11107 | if (use_json && is_wildcard) | |
11108 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
11109 | else if (!nbr_output) { |
11110 | if (use_json) | |
11111 | vty_out(vty, "{}\n"); | |
11112 | else | |
6cac2fcc LS |
11113 | vty_out(vty, "%% No BGP neighbors found in %s\n", |
11114 | bgp->name_pretty); | |
ca61fd25 | 11115 | } |
d62a17ae | 11116 | } |
11117 | ||
11118 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
8c1d4cd5 LS |
11119 | safi_t safi, |
11120 | const char *neighbor, | |
11121 | int as_type, as_t as, | |
96c81f66 | 11122 | uint16_t show_flags) |
d62a17ae | 11123 | { |
11124 | struct listnode *node, *nnode; | |
11125 | struct bgp *bgp; | |
8c1d4cd5 | 11126 | struct peer *fpeer = NULL; |
d62a17ae | 11127 | int is_first = 1; |
9f049418 | 11128 | bool nbr_output = false; |
85eeb029 | 11129 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
d62a17ae | 11130 | |
11131 | if (use_json) | |
11132 | vty_out(vty, "{\n"); | |
11133 | ||
11134 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11135 | nbr_output = true; |
d62a17ae | 11136 | if (use_json) { |
d62a17ae | 11137 | if (!is_first) |
11138 | vty_out(vty, ",\n"); | |
11139 | else | |
11140 | is_first = 0; | |
11141 | ||
11142 | vty_out(vty, "\"%s\":", | |
11143 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11144 | ? VRF_DEFAULT_NAME |
d62a17ae | 11145 | : bgp->name); |
d62a17ae | 11146 | } |
8c1d4cd5 LS |
11147 | if (neighbor) { |
11148 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11149 | use_json); | |
11150 | if (!fpeer) | |
11151 | continue; | |
11152 | } | |
11153 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11154 | as, show_flags); | |
d62a17ae | 11155 | } |
11156 | ||
11157 | if (use_json) | |
11158 | vty_out(vty, "}\n"); | |
9f049418 DS |
11159 | else if (!nbr_output) |
11160 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11161 | } |
11162 | ||
11163 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
8c1d4cd5 | 11164 | safi_t safi, const char *neighbor, int as_type, |
96c81f66 | 11165 | as_t as, uint16_t show_flags) |
d62a17ae | 11166 | { |
11167 | struct bgp *bgp; | |
85eeb029 | 11168 | bool use_json = CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); |
8c1d4cd5 | 11169 | struct peer *fpeer = NULL; |
d62a17ae | 11170 | |
11171 | if (name) { | |
11172 | if (strmatch(name, "all")) { | |
85eeb029 | 11173 | bgp_show_all_instances_summary_vty(vty, afi, safi, |
8c1d4cd5 LS |
11174 | neighbor, as_type, |
11175 | as, show_flags); | |
d62a17ae | 11176 | return CMD_SUCCESS; |
11177 | } else { | |
11178 | bgp = bgp_lookup_by_name(name); | |
11179 | ||
11180 | if (!bgp) { | |
11181 | if (use_json) | |
11182 | vty_out(vty, "{}\n"); | |
11183 | else | |
11184 | vty_out(vty, | |
ca61fd25 | 11185 | "%% BGP instance not found\n"); |
d62a17ae | 11186 | return CMD_WARNING; |
11187 | } | |
11188 | ||
8c1d4cd5 LS |
11189 | if (neighbor) { |
11190 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11191 | use_json); | |
11192 | if (!fpeer) | |
11193 | return CMD_WARNING; | |
11194 | } | |
11195 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, | |
11196 | as_type, as, show_flags); | |
d62a17ae | 11197 | return CMD_SUCCESS; |
11198 | } | |
11199 | } | |
11200 | ||
11201 | bgp = bgp_get_default(); | |
11202 | ||
8c1d4cd5 LS |
11203 | if (bgp) { |
11204 | if (neighbor) { | |
11205 | fpeer = peer_lookup_in_view(vty, bgp, neighbor, | |
11206 | use_json); | |
11207 | if (!fpeer) | |
11208 | return CMD_WARNING; | |
11209 | } | |
11210 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, fpeer, as_type, | |
11211 | as, show_flags); | |
11212 | } else { | |
ca61fd25 DS |
11213 | if (use_json) |
11214 | vty_out(vty, "{}\n"); | |
11215 | else | |
11216 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
11217 | return CMD_WARNING; |
11218 | } | |
d62a17ae | 11219 | |
11220 | return CMD_SUCCESS; | |
4fb25c53 DW |
11221 | } |
11222 | ||
716b2d8a | 11223 | /* `show [ip] bgp summary' commands. */ |
8c1d4cd5 LS |
11224 | DEFPY(show_ip_bgp_summary, show_ip_bgp_summary_cmd, |
11225 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [" BGP_AFI_CMD_STR | |
11226 | " [" BGP_SAFI_WITH_LABEL_CMD_STR | |
96c81f66 | 11227 | "]] [all$all] summary [established|failed] [<neighbor <A.B.C.D|X:X::X:X|WORD>|remote-as <(1-4294967295)|internal|external>>] [terse] [wide] [json$uj]", |
8c1d4cd5 LS |
11228 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR |
11229 | BGP_SAFI_WITH_LABEL_HELP_STR | |
11230 | "Display the entries for all address families\n" | |
11231 | "Summary of BGP neighbor status\n" | |
11232 | "Show only sessions in Established state\n" | |
11233 | "Show only sessions not in Established state\n" | |
11234 | "Show only the specified neighbor session\n" | |
11235 | "Neighbor to display information about\n" | |
11236 | "Neighbor to display information about\n" | |
11237 | "Neighbor on BGP configured interface\n" | |
11238 | "Show only the specified remote AS sessions\n" | |
11239 | "AS number\n" | |
11240 | "Internal (iBGP) AS sessions\n" | |
11241 | "External (eBGP) AS sessions\n" | |
96c81f66 | 11242 | "Shorten the information on BGP instances\n" |
8c1d4cd5 | 11243 | "Increase table width for longer output\n" JSON_STR) |
718e3744 | 11244 | { |
d62a17ae | 11245 | char *vrf = NULL; |
11246 | afi_t afi = AFI_MAX; | |
11247 | safi_t safi = SAFI_MAX; | |
8c1d4cd5 LS |
11248 | as_t as = 0; /* 0 means AS filter not set */ |
11249 | int as_type = AS_UNSPECIFIED; | |
96c81f66 | 11250 | uint16_t show_flags = 0; |
d62a17ae | 11251 | |
11252 | int idx = 0; | |
11253 | ||
11254 | /* show [ip] bgp */ | |
96f3485c | 11255 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 11256 | afi = AFI_IP; |
9a8bdf1c PG |
11257 | /* [<vrf> VIEWVRFNAME] */ |
11258 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11259 | vrf = argv[idx + 1]->arg; | |
11260 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11261 | vrf = NULL; | |
11262 | } else if (argv_find(argv, argc, "view", &idx)) | |
11263 | /* [<view> VIEWVRFNAME] */ | |
11264 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11265 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11266 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11267 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11268 | } | |
11269 | ||
3577f1c5 | 11270 | if (argv_find(argv, argc, "failed", &idx)) |
85eeb029 DA |
11271 | SET_FLAG(show_flags, BGP_SHOW_OPT_FAILED); |
11272 | ||
10b49f14 | 11273 | if (argv_find(argv, argc, "established", &idx)) |
85eeb029 DA |
11274 | SET_FLAG(show_flags, BGP_SHOW_OPT_ESTABLISHED); |
11275 | ||
8c1d4cd5 LS |
11276 | if (argv_find(argv, argc, "remote-as", &idx)) { |
11277 | if (argv[idx + 1]->arg[0] == 'i') | |
11278 | as_type = AS_INTERNAL; | |
11279 | else if (argv[idx + 1]->arg[0] == 'e') | |
11280 | as_type = AS_EXTERNAL; | |
11281 | else | |
11282 | as = (as_t)atoi(argv[idx + 1]->arg); | |
11283 | } | |
11284 | ||
96c81f66 LS |
11285 | if (argv_find(argv, argc, "terse", &idx)) |
11286 | SET_FLAG(show_flags, BGP_SHOW_OPT_TERSE); | |
11287 | ||
85eeb029 DA |
11288 | if (argv_find(argv, argc, "wide", &idx)) |
11289 | SET_FLAG(show_flags, BGP_SHOW_OPT_WIDE); | |
11290 | ||
11291 | if (argv_find(argv, argc, "json", &idx)) | |
11292 | SET_FLAG(show_flags, BGP_SHOW_OPT_JSON); | |
3577f1c5 | 11293 | |
8c1d4cd5 LS |
11294 | return bgp_show_summary_vty(vty, vrf, afi, safi, neighbor, as_type, as, |
11295 | show_flags); | |
d62a17ae | 11296 | } |
11297 | ||
5cb5f4d0 | 11298 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 11299 | { |
5cb5f4d0 DD |
11300 | if (for_json) |
11301 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 11302 | else |
5cb5f4d0 | 11303 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
11304 | } |
11305 | ||
d62a17ae | 11306 | |
11307 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
11308 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
11309 | uint16_t adv_smcap, uint16_t adv_rmcap, |
11310 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 11311 | bool use_json, json_object *json_pref) |
d62a17ae | 11312 | { |
11313 | /* Send-Mode */ | |
11314 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11315 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
11316 | if (use_json) { | |
11317 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
11318 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11319 | json_object_string_add(json_pref, "sendMode", | |
11320 | "advertisedAndReceived"); | |
11321 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11322 | json_object_string_add(json_pref, "sendMode", | |
11323 | "advertised"); | |
11324 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11325 | json_object_string_add(json_pref, "sendMode", | |
11326 | "received"); | |
11327 | } else { | |
11328 | vty_out(vty, " Send-mode: "); | |
11329 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
11330 | vty_out(vty, "advertised"); | |
11331 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
11332 | vty_out(vty, "%sreceived", | |
11333 | CHECK_FLAG(p->af_cap[afi][safi], | |
11334 | adv_smcap) | |
11335 | ? ", " | |
11336 | : ""); | |
11337 | vty_out(vty, "\n"); | |
11338 | } | |
11339 | } | |
11340 | ||
11341 | /* Receive-Mode */ | |
11342 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11343 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
11344 | if (use_json) { | |
11345 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
11346 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11347 | json_object_string_add(json_pref, "recvMode", | |
11348 | "advertisedAndReceived"); | |
11349 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11350 | json_object_string_add(json_pref, "recvMode", | |
11351 | "advertised"); | |
11352 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11353 | json_object_string_add(json_pref, "recvMode", | |
11354 | "received"); | |
11355 | } else { | |
11356 | vty_out(vty, " Receive-mode: "); | |
11357 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
11358 | vty_out(vty, "advertised"); | |
11359 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
11360 | vty_out(vty, "%sreceived", | |
11361 | CHECK_FLAG(p->af_cap[afi][safi], | |
11362 | adv_rmcap) | |
11363 | ? ", " | |
11364 | : ""); | |
11365 | vty_out(vty, "\n"); | |
11366 | } | |
11367 | } | |
11368 | } | |
11369 | ||
eea685b6 DA |
11370 | static void bgp_show_neighnor_graceful_restart_flags(struct vty *vty, |
11371 | struct peer *p, | |
11372 | bool use_json, | |
11373 | json_object *json) | |
2986cac2 | 11374 | { |
eea685b6 DA |
11375 | bool rbit = false; |
11376 | bool nbit = false; | |
2986cac2 | 11377 | |
13909c4f DS |
11378 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
11379 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
feb17238 | 11380 | && (peer_established(p))) { |
eea685b6 DA |
11381 | rbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV); |
11382 | nbit = CHECK_FLAG(p->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV); | |
2986cac2 | 11383 | } |
11384 | ||
eea685b6 DA |
11385 | if (use_json) { |
11386 | json_object_boolean_add(json, "rBit", rbit); | |
11387 | json_object_boolean_add(json, "nBit", nbit); | |
2986cac2 | 11388 | } else { |
eea685b6 DA |
11389 | vty_out(vty, "\n R bit: %s", rbit ? "True" : "False"); |
11390 | vty_out(vty, "\n N bit: %s\n", nbit ? "True" : "False"); | |
2986cac2 | 11391 | } |
11392 | } | |
11393 | ||
13909c4f DS |
11394 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
11395 | struct peer *peer, | |
11396 | bool use_json, | |
11397 | json_object *json) | |
2986cac2 | 11398 | { |
2bb5d39b | 11399 | const char *mode = "NotApplicable"; |
2986cac2 | 11400 | |
11401 | if (!use_json) | |
a53ca37b | 11402 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 11403 | |
13909c4f | 11404 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
feb17238 | 11405 | && (peer_established(peer))) { |
2986cac2 | 11406 | |
13909c4f DS |
11407 | if ((peer->nsf_af_count == 0) |
11408 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11409 | |
2986cac2 | 11410 | mode = "Disable"; |
11411 | ||
13909c4f DS |
11412 | } else if (peer->nsf_af_count == 0 |
11413 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11414 | |
2986cac2 | 11415 | mode = "Helper"; |
11416 | ||
13909c4f DS |
11417 | } else if (peer->nsf_af_count != 0 |
11418 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11419 | |
2986cac2 | 11420 | mode = "Restart"; |
2986cac2 | 11421 | } |
11422 | } | |
11423 | ||
11424 | if (use_json) { | |
13909c4f | 11425 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 11426 | } else |
11427 | vty_out(vty, mode, "\n"); | |
11428 | } | |
11429 | ||
13909c4f DS |
11430 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
11431 | struct peer *p, | |
11432 | bool use_json, | |
11433 | json_object *json) | |
2986cac2 | 11434 | { |
11435 | const char *mode = "Invalid"; | |
11436 | ||
11437 | if (!use_json) | |
a53ca37b | 11438 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 11439 | |
11440 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
11441 | mode = "Helper"; | |
11442 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
11443 | mode = "Restart"; | |
11444 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
11445 | mode = "Disable"; | |
2ba1fe69 | 11446 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 11447 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
11448 | mode = "Helper*"; | |
11449 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
11450 | mode = "Restart*"; | |
11451 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
11452 | mode = "Disable*"; | |
11453 | else | |
11454 | mode = "Invalid*"; | |
2ba1fe69 | 11455 | } |
2986cac2 | 11456 | |
11457 | if (use_json) { | |
13909c4f | 11458 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 11459 | } else { |
11460 | vty_out(vty, mode, "\n"); | |
11461 | } | |
11462 | } | |
11463 | ||
13909c4f DS |
11464 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
11465 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 11466 | { |
2ba1fe69 | 11467 | afi_t afi; |
11468 | safi_t safi; | |
2986cac2 | 11469 | json_object *json_afi_safi = NULL; |
11470 | json_object *json_timer = NULL; | |
11471 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 11472 | bool eor_flag = false; |
2986cac2 | 11473 | |
df8d723c DA |
11474 | FOREACH_AFI_SAFI_NSF (afi, safi) { |
11475 | if (!peer->afc[afi][safi]) | |
11476 | continue; | |
2986cac2 | 11477 | |
df8d723c DA |
11478 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) || |
11479 | !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
11480 | continue; | |
9e3b51a7 | 11481 | |
df8d723c DA |
11482 | if (use_json) { |
11483 | json_afi_safi = json_object_new_object(); | |
11484 | json_endofrib_status = json_object_new_object(); | |
11485 | json_timer = json_object_new_object(); | |
11486 | } | |
2986cac2 | 11487 | |
df8d723c DA |
11488 | if (peer->eor_stime[afi][safi] >= peer->pkt_stime[afi][safi]) |
11489 | eor_flag = true; | |
11490 | else | |
11491 | eor_flag = false; | |
2986cac2 | 11492 | |
df8d723c DA |
11493 | if (!use_json) { |
11494 | vty_out(vty, " %s:\n", | |
11495 | get_afi_safi_str(afi, safi, false)); | |
2986cac2 | 11496 | |
df8d723c DA |
11497 | vty_out(vty, " F bit: "); |
11498 | } | |
2986cac2 | 11499 | |
df8d723c DA |
11500 | if (peer->nsf[afi][safi] && |
11501 | CHECK_FLAG(peer->af_cap[afi][safi], | |
11502 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 11503 | |
df8d723c DA |
11504 | if (use_json) { |
11505 | json_object_boolean_true_add(json_afi_safi, | |
11506 | "fBit"); | |
11507 | } else | |
11508 | vty_out(vty, "True\n"); | |
11509 | } else { | |
11510 | if (use_json) | |
11511 | json_object_boolean_false_add(json_afi_safi, | |
11512 | "fBit"); | |
11513 | else | |
11514 | vty_out(vty, "False\n"); | |
11515 | } | |
2986cac2 | 11516 | |
df8d723c DA |
11517 | if (!use_json) |
11518 | vty_out(vty, " End-of-RIB sent: "); | |
2986cac2 | 11519 | |
df8d723c DA |
11520 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11521 | PEER_STATUS_EOR_SEND)) { | |
11522 | if (use_json) { | |
11523 | json_object_boolean_true_add( | |
11524 | json_endofrib_status, "endOfRibSend"); | |
9e3b51a7 | 11525 | |
df8d723c DA |
11526 | PRINT_EOR_JSON(eor_flag); |
11527 | } else { | |
11528 | vty_out(vty, "Yes\n"); | |
11529 | vty_out(vty, | |
11530 | " End-of-RIB sent after update: "); | |
2986cac2 | 11531 | |
df8d723c DA |
11532 | PRINT_EOR(eor_flag); |
11533 | } | |
11534 | } else { | |
11535 | if (use_json) { | |
11536 | json_object_boolean_false_add( | |
11537 | json_endofrib_status, "endOfRibSend"); | |
11538 | json_object_boolean_false_add( | |
11539 | json_endofrib_status, | |
11540 | "endOfRibSentAfterUpdate"); | |
13909c4f | 11541 | } else { |
df8d723c DA |
11542 | vty_out(vty, "No\n"); |
11543 | vty_out(vty, | |
11544 | " End-of-RIB sent after update: "); | |
11545 | vty_out(vty, "No\n"); | |
13909c4f | 11546 | } |
df8d723c | 11547 | } |
2986cac2 | 11548 | |
df8d723c DA |
11549 | if (!use_json) |
11550 | vty_out(vty, " End-of-RIB received: "); | |
a53ca37b | 11551 | |
df8d723c DA |
11552 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
11553 | PEER_STATUS_EOR_RECEIVED)) { | |
11554 | if (use_json) | |
11555 | json_object_boolean_true_add( | |
11556 | json_endofrib_status, "endOfRibRecv"); | |
11557 | else | |
11558 | vty_out(vty, "Yes\n"); | |
11559 | } else { | |
11560 | if (use_json) | |
11561 | json_object_boolean_false_add( | |
11562 | json_endofrib_status, "endOfRibRecv"); | |
11563 | else | |
11564 | vty_out(vty, "No\n"); | |
11565 | } | |
11566 | ||
11567 | if (use_json) { | |
11568 | json_object_int_add(json_timer, "stalePathTimer", | |
11569 | peer->bgp->stalepath_time); | |
11570 | ||
11571 | if (peer->t_gr_stale != NULL) { | |
11572 | json_object_int_add(json_timer, | |
11573 | "stalePathTimerRemaining", | |
11574 | thread_timer_remain_second( | |
11575 | peer->t_gr_stale)); | |
a53ca37b DA |
11576 | } |
11577 | ||
df8d723c DA |
11578 | /* Display Configured Selection |
11579 | * Deferral only when when | |
11580 | * Gr mode is enabled. | |
11581 | */ | |
11582 | if (CHECK_FLAG(peer->flags, | |
11583 | PEER_FLAG_GRACEFUL_RESTART)) { | |
13909c4f | 11584 | json_object_int_add(json_timer, |
df8d723c | 11585 | "selectionDeferralTimer", |
13909c4f | 11586 | peer->bgp->stalepath_time); |
df8d723c | 11587 | } |
2986cac2 | 11588 | |
df8d723c DA |
11589 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
11590 | NULL) { | |
2986cac2 | 11591 | |
df8d723c DA |
11592 | json_object_int_add( |
11593 | json_timer, | |
11594 | "selectionDeferralTimerRemaining", | |
11595 | thread_timer_remain_second( | |
11596 | peer->bgp->gr_info[afi][safi] | |
11597 | .t_select_deferral)); | |
11598 | } | |
11599 | } else { | |
11600 | vty_out(vty, " Timers:\n"); | |
11601 | vty_out(vty, | |
11602 | " Configured Stale Path Time(sec): %u\n", | |
11603 | peer->bgp->stalepath_time); | |
2986cac2 | 11604 | |
df8d723c | 11605 | if (peer->t_gr_stale != NULL) |
13909c4f | 11606 | vty_out(vty, |
df8d723c DA |
11607 | " Stale Path Remaining(sec): %ld\n", |
11608 | thread_timer_remain_second( | |
11609 | peer->t_gr_stale)); | |
11610 | /* Display Configured Selection | |
11611 | * Deferral only when when | |
11612 | * Gr mode is enabled. | |
11613 | */ | |
11614 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) | |
11615 | vty_out(vty, | |
11616 | " Configured Selection Deferral Time(sec): %u\n", | |
11617 | peer->bgp->select_defer_time); | |
2986cac2 | 11618 | |
df8d723c DA |
11619 | if (peer->bgp->gr_info[afi][safi].t_select_deferral != |
11620 | NULL) | |
11621 | vty_out(vty, | |
11622 | " Selection Deferral Time Remaining(sec): %ld\n", | |
11623 | thread_timer_remain_second( | |
11624 | peer->bgp->gr_info[afi][safi] | |
11625 | .t_select_deferral)); | |
11626 | } | |
11627 | if (use_json) { | |
11628 | json_object_object_add(json_afi_safi, "endOfRibStatus", | |
11629 | json_endofrib_status); | |
11630 | json_object_object_add(json_afi_safi, "timers", | |
11631 | json_timer); | |
11632 | json_object_object_add( | |
11633 | json, get_afi_safi_str(afi, safi, true), | |
11634 | json_afi_safi); | |
2986cac2 | 11635 | } |
11636 | } | |
11637 | } | |
11638 | ||
36235319 QY |
11639 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
11640 | struct peer *p, | |
11641 | bool use_json, | |
11642 | json_object *json) | |
2986cac2 | 11643 | { |
11644 | if (use_json) { | |
11645 | json_object *json_timer = NULL; | |
11646 | ||
11647 | json_timer = json_object_new_object(); | |
11648 | ||
13909c4f DS |
11649 | json_object_int_add(json_timer, "configuredRestartTimer", |
11650 | p->bgp->restart_time); | |
2986cac2 | 11651 | |
13909c4f DS |
11652 | json_object_int_add(json_timer, "receivedRestartTimer", |
11653 | p->v_gr_restart); | |
2986cac2 | 11654 | |
13909c4f DS |
11655 | if (p->t_gr_restart != NULL) |
11656 | json_object_int_add( | |
11657 | json_timer, "restartTimerRemaining", | |
11658 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 11659 | |
11660 | json_object_object_add(json, "timers", json_timer); | |
11661 | } else { | |
11662 | ||
a53ca37b DA |
11663 | vty_out(vty, " Timers:\n"); |
11664 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 11665 | p->bgp->restart_time); |
2986cac2 | 11666 | |
a53ca37b | 11667 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
11668 | p->v_gr_restart); |
11669 | if (p->t_gr_restart != NULL) | |
a53ca37b | 11670 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 11671 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 11672 | if (p->t_gr_restart != NULL) { |
a53ca37b | 11673 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
11674 | thread_timer_remain_second(p->t_gr_restart)); |
11675 | } | |
2986cac2 | 11676 | } |
11677 | } | |
11678 | ||
11679 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 11680 | bool use_json, json_object *json) |
2986cac2 | 11681 | { |
11682 | char buf[SU_ADDRSTRLEN] = {0}; | |
11683 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
11684 | /* '*' + v6 address of neighbor */ |
11685 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 11686 | |
2986cac2 | 11687 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
11688 | dn_flag[0] = '*'; | |
11689 | ||
11690 | if (p->conf_if) { | |
11691 | if (use_json) | |
13909c4f DS |
11692 | json_object_string_add( |
11693 | json, "neighborAddr", | |
2986cac2 | 11694 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
11695 | ? "none" |
11696 | : sockunion2str(&p->su, buf, | |
11697 | SU_ADDRSTRLEN)); | |
2986cac2 | 11698 | else |
13909c4f | 11699 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 11700 | BGP_PEER_SU_UNSPEC(p) |
11701 | ? "none" | |
11702 | : sockunion2str(&p->su, buf, | |
11703 | SU_ADDRSTRLEN)); | |
11704 | } else { | |
772270f3 QY |
11705 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
11706 | p->host); | |
2986cac2 | 11707 | |
11708 | if (use_json) | |
36235319 QY |
11709 | json_object_string_add(json, "neighborAddr", |
11710 | neighborAddr); | |
2986cac2 | 11711 | else |
36235319 | 11712 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 11713 | } |
11714 | ||
11715 | /* more gr info in new format */ | |
11716 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
11717 | } | |
11718 | ||
d62a17ae | 11719 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 11720 | safi_t safi, bool use_json, |
d62a17ae | 11721 | json_object *json_neigh) |
11722 | { | |
0291c246 MK |
11723 | struct bgp_filter *filter; |
11724 | struct peer_af *paf; | |
11725 | char orf_pfx_name[BUFSIZ]; | |
11726 | int orf_pfx_count; | |
11727 | json_object *json_af = NULL; | |
11728 | json_object *json_prefA = NULL; | |
11729 | json_object *json_prefB = NULL; | |
11730 | json_object *json_addr = NULL; | |
fa36596c | 11731 | json_object *json_advmap = NULL; |
d62a17ae | 11732 | |
11733 | if (use_json) { | |
11734 | json_addr = json_object_new_object(); | |
11735 | json_af = json_object_new_object(); | |
11736 | filter = &p->filter[afi][safi]; | |
11737 | ||
11738 | if (peer_group_active(p)) | |
11739 | json_object_string_add(json_addr, "peerGroupMember", | |
11740 | p->group->name); | |
11741 | ||
11742 | paf = peer_af_find(p, afi, safi); | |
11743 | if (paf && PAF_SUBGRP(paf)) { | |
11744 | json_object_int_add(json_addr, "updateGroupId", | |
11745 | PAF_UPDGRP(paf)->id); | |
11746 | json_object_int_add(json_addr, "subGroupId", | |
11747 | PAF_SUBGRP(paf)->id); | |
11748 | json_object_int_add(json_addr, "packetQueueLength", | |
11749 | bpacket_queue_virtual_length(paf)); | |
11750 | } | |
11751 | ||
11752 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11753 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11754 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11755 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11756 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11757 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11758 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11759 | json_object_int_add(json_af, "orfType", | |
11760 | ORF_TYPE_PREFIX); | |
11761 | json_prefA = json_object_new_object(); | |
11762 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
11763 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
11764 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11765 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11766 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
11767 | use_json, json_prefA); | |
11768 | json_object_object_add(json_af, "orfPrefixList", | |
11769 | json_prefA); | |
11770 | } | |
11771 | ||
11772 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11773 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11774 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11775 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11776 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11777 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11778 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11779 | json_object_int_add(json_af, "orfOldType", | |
11780 | ORF_TYPE_PREFIX_OLD); | |
11781 | json_prefB = json_object_new_object(); | |
11782 | bgp_show_peer_afi_orf_cap( | |
11783 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11784 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11785 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11786 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
11787 | json_prefB); | |
11788 | json_object_object_add(json_af, "orfOldPrefixList", | |
11789 | json_prefB); | |
11790 | } | |
11791 | ||
11792 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11793 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11794 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11795 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11796 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11797 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11798 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11799 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11800 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11801 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11802 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11803 | json_object_object_add(json_addr, "afDependentCap", | |
11804 | json_af); | |
11805 | else | |
11806 | json_object_free(json_af); | |
11807 | ||
772270f3 QY |
11808 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11809 | p->host, afi, safi); | |
d62a17ae | 11810 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11811 | NULL, afi, orf_pfx_name, use_json); | |
11812 | ||
11813 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11814 | PEER_STATUS_ORF_PREFIX_SEND) | |
11815 | || orf_pfx_count) { | |
11816 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11817 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11818 | json_object_boolean_true_add(json_neigh, | |
11819 | "orfSent"); | |
11820 | if (orf_pfx_count) | |
11821 | json_object_int_add(json_addr, "orfRecvCounter", | |
11822 | orf_pfx_count); | |
11823 | } | |
11824 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11825 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11826 | json_object_string_add( | |
11827 | json_addr, "orfFirstUpdate", | |
11828 | "deferredUntilORFOrRouteRefreshRecvd"); | |
11829 | ||
11830 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11831 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11832 | json_object_boolean_true_add(json_addr, | |
11833 | "routeReflectorClient"); | |
11834 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11835 | PEER_FLAG_RSERVER_CLIENT)) | |
11836 | json_object_boolean_true_add(json_addr, | |
11837 | "routeServerClient"); | |
11838 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11839 | json_object_boolean_true_add(json_addr, | |
11840 | "inboundSoftConfigPermit"); | |
11841 | ||
11842 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11843 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11844 | json_object_boolean_true_add( | |
11845 | json_addr, | |
11846 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
11847 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11848 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11849 | json_object_boolean_true_add( | |
11850 | json_addr, | |
11851 | "privateAsNumsReplacedInUpdatesToNbr"); | |
11852 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11853 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11854 | json_object_boolean_true_add( | |
11855 | json_addr, | |
11856 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
11857 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11858 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11859 | json_object_boolean_true_add( | |
11860 | json_addr, | |
11861 | "privateAsNumsRemovedInUpdatesToNbr"); | |
11862 | ||
dcc68b5e MS |
11863 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11864 | json_object_boolean_true_add( | |
11865 | json_addr, | |
11866 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11867 | ->type_json_name); | |
d62a17ae | 11868 | |
11869 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11870 | json_object_string_add(json_addr, | |
11871 | "overrideASNsInOutboundUpdates", | |
11872 | "ifAspathEqualRemoteAs"); | |
11873 | ||
11874 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11875 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11876 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11877 | json_object_boolean_true_add(json_addr, | |
11878 | "routerAlwaysNextHop"); | |
11879 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11880 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11881 | json_object_boolean_true_add( | |
11882 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
11883 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11884 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11885 | json_object_boolean_true_add( | |
11886 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
11887 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11888 | json_object_boolean_true_add( | |
11889 | json_addr, "unchangedMedPropogatedToNbr"); | |
11890 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11891 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11892 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11893 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11894 | PEER_FLAG_SEND_COMMUNITY) | |
11895 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11896 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11897 | json_object_string_add(json_addr, | |
11898 | "commAttriSentToNbr", | |
11899 | "extendedAndStandard"); | |
11900 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11901 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11902 | json_object_string_add(json_addr, | |
11903 | "commAttriSentToNbr", | |
11904 | "extended"); | |
11905 | else | |
11906 | json_object_string_add(json_addr, | |
11907 | "commAttriSentToNbr", | |
11908 | "standard"); | |
11909 | } | |
11910 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11911 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11912 | if (p->default_rmap[afi][safi].name) | |
11913 | json_object_string_add( | |
11914 | json_addr, "defaultRouteMap", | |
11915 | p->default_rmap[afi][safi].name); | |
11916 | ||
11917 | if (paf && PAF_SUBGRP(paf) | |
11918 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11919 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11920 | json_object_boolean_true_add(json_addr, | |
11921 | "defaultSent"); | |
11922 | else | |
11923 | json_object_boolean_true_add(json_addr, | |
11924 | "defaultNotSent"); | |
11925 | } | |
11926 | ||
dff8f48d | 11927 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11928 | if (is_evpn_enabled()) |
60466a63 QY |
11929 | json_object_boolean_true_add( |
11930 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11931 | } |
11932 | ||
d62a17ae | 11933 | if (filter->plist[FILTER_IN].name |
11934 | || filter->dlist[FILTER_IN].name | |
11935 | || filter->aslist[FILTER_IN].name | |
11936 | || filter->map[RMAP_IN].name) | |
11937 | json_object_boolean_true_add(json_addr, | |
11938 | "inboundPathPolicyConfig"); | |
11939 | if (filter->plist[FILTER_OUT].name | |
11940 | || filter->dlist[FILTER_OUT].name | |
11941 | || filter->aslist[FILTER_OUT].name | |
11942 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11943 | json_object_boolean_true_add( | |
11944 | json_addr, "outboundPathPolicyConfig"); | |
11945 | ||
11946 | /* prefix-list */ | |
11947 | if (filter->plist[FILTER_IN].name) | |
11948 | json_object_string_add(json_addr, | |
11949 | "incomingUpdatePrefixFilterList", | |
11950 | filter->plist[FILTER_IN].name); | |
11951 | if (filter->plist[FILTER_OUT].name) | |
11952 | json_object_string_add(json_addr, | |
11953 | "outgoingUpdatePrefixFilterList", | |
11954 | filter->plist[FILTER_OUT].name); | |
11955 | ||
11956 | /* distribute-list */ | |
11957 | if (filter->dlist[FILTER_IN].name) | |
11958 | json_object_string_add( | |
11959 | json_addr, "incomingUpdateNetworkFilterList", | |
11960 | filter->dlist[FILTER_IN].name); | |
11961 | if (filter->dlist[FILTER_OUT].name) | |
11962 | json_object_string_add( | |
11963 | json_addr, "outgoingUpdateNetworkFilterList", | |
11964 | filter->dlist[FILTER_OUT].name); | |
11965 | ||
11966 | /* filter-list. */ | |
11967 | if (filter->aslist[FILTER_IN].name) | |
11968 | json_object_string_add(json_addr, | |
11969 | "incomingUpdateAsPathFilterList", | |
11970 | filter->aslist[FILTER_IN].name); | |
11971 | if (filter->aslist[FILTER_OUT].name) | |
11972 | json_object_string_add(json_addr, | |
11973 | "outgoingUpdateAsPathFilterList", | |
11974 | filter->aslist[FILTER_OUT].name); | |
11975 | ||
11976 | /* route-map. */ | |
11977 | if (filter->map[RMAP_IN].name) | |
11978 | json_object_string_add( | |
11979 | json_addr, "routeMapForIncomingAdvertisements", | |
11980 | filter->map[RMAP_IN].name); | |
11981 | if (filter->map[RMAP_OUT].name) | |
11982 | json_object_string_add( | |
11983 | json_addr, "routeMapForOutgoingAdvertisements", | |
11984 | filter->map[RMAP_OUT].name); | |
11985 | ||
9dac9fc8 | 11986 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11987 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11988 | && !bgp_inbound_policy_exists(p, filter)) |
11989 | json_object_string_add( | |
11990 | json_addr, "inboundEbgpRequiresPolicy", | |
11991 | "Inbound updates discarded due to missing policy"); | |
11992 | ||
11993 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11994 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11995 | && (!bgp_outbound_policy_exists(p, filter))) |
11996 | json_object_string_add( | |
11997 | json_addr, "outboundEbgpRequiresPolicy", | |
11998 | "Outbound updates discarded due to missing policy"); | |
11999 | ||
d62a17ae | 12000 | /* unsuppress-map */ |
12001 | if (filter->usmap.name) | |
12002 | json_object_string_add(json_addr, | |
12003 | "selectiveUnsuppressRouteMap", | |
12004 | filter->usmap.name); | |
12005 | ||
fa36596c MK |
12006 | /* advertise-map */ |
12007 | if (filter->advmap.aname) { | |
12008 | json_advmap = json_object_new_object(); | |
12009 | json_object_string_add(json_advmap, "condition", | |
12010 | filter->advmap.condition | |
12011 | ? "EXIST" | |
12012 | : "NON_EXIST"); | |
12013 | json_object_string_add(json_advmap, "conditionMap", | |
12014 | filter->advmap.cname); | |
12015 | json_object_string_add(json_advmap, "advertiseMap", | |
12016 | filter->advmap.aname); | |
12017 | json_object_string_add(json_advmap, "advertiseStatus", | |
12018 | filter->advmap.update_type | |
12019 | == ADVERTISE | |
12020 | ? "Advertise" | |
12021 | : "Withdraw"); | |
12022 | json_object_object_add(json_addr, "advertiseMap", | |
12023 | json_advmap); | |
12024 | } | |
12025 | ||
d62a17ae | 12026 | /* Receive prefix count */ |
12027 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
12028 | p->pcount[afi][safi]); | |
50e05855 AD |
12029 | if (paf && PAF_SUBGRP(paf)) |
12030 | json_object_int_add(json_addr, "sentPrefixCounter", | |
12031 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 12032 | |
fde246e8 DA |
12033 | /* Maximum prefix */ |
12034 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
12035 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
12036 | p->pmax_out[afi][safi]); | |
12037 | ||
d62a17ae | 12038 | /* Maximum prefix */ |
12039 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
12040 | json_object_int_add(json_addr, "prefixAllowedMax", | |
12041 | p->pmax[afi][safi]); | |
12042 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12043 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
12044 | json_object_boolean_true_add( | |
12045 | json_addr, "prefixAllowedMaxWarning"); | |
12046 | json_object_int_add(json_addr, | |
12047 | "prefixAllowedWarningThresh", | |
12048 | p->pmax_threshold[afi][safi]); | |
12049 | if (p->pmax_restart[afi][safi]) | |
12050 | json_object_int_add( | |
12051 | json_addr, | |
12052 | "prefixAllowedRestartIntervalMsecs", | |
12053 | p->pmax_restart[afi][safi] * 60000); | |
12054 | } | |
2986cac2 | 12055 | json_object_object_add(json_neigh, |
36235319 | 12056 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 12057 | json_addr); |
12058 | ||
12059 | } else { | |
12060 | filter = &p->filter[afi][safi]; | |
12061 | ||
12062 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 12063 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 12064 | |
12065 | if (peer_group_active(p)) | |
12066 | vty_out(vty, " %s peer-group member\n", | |
12067 | p->group->name); | |
12068 | ||
12069 | paf = peer_af_find(p, afi, safi); | |
12070 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 12071 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 12072 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
12073 | vty_out(vty, " Packet Queue length %d\n", | |
12074 | bpacket_queue_virtual_length(paf)); | |
12075 | } else { | |
12076 | vty_out(vty, " Not part of any update group\n"); | |
12077 | } | |
12078 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12079 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12080 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12081 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12082 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12083 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12084 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12085 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12086 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
12087 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12088 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
12089 | vty_out(vty, " AF-dependant capabilities:\n"); | |
12090 | ||
12091 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12092 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12093 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
12094 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12095 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12096 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12097 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
12098 | vty_out(vty, | |
12099 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12100 | ORF_TYPE_PREFIX); | |
12101 | bgp_show_peer_afi_orf_cap( | |
12102 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12103 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12104 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
12105 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
12106 | } | |
12107 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
12108 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12109 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
12110 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12111 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
12112 | || CHECK_FLAG(p->af_cap[afi][safi], | |
12113 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
12114 | vty_out(vty, | |
12115 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
12116 | ORF_TYPE_PREFIX_OLD); | |
12117 | bgp_show_peer_afi_orf_cap( | |
12118 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
12119 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
12120 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
12121 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
12122 | } | |
12123 | ||
772270f3 QY |
12124 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
12125 | p->host, afi, safi); | |
d62a17ae | 12126 | orf_pfx_count = prefix_bgp_show_prefix_list( |
12127 | NULL, afi, orf_pfx_name, use_json); | |
12128 | ||
12129 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12130 | PEER_STATUS_ORF_PREFIX_SEND) | |
12131 | || orf_pfx_count) { | |
12132 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
12133 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12134 | PEER_STATUS_ORF_PREFIX_SEND)) | |
12135 | vty_out(vty, " sent;"); | |
12136 | if (orf_pfx_count) | |
12137 | vty_out(vty, " received (%d entries)", | |
12138 | orf_pfx_count); | |
12139 | vty_out(vty, "\n"); | |
12140 | } | |
12141 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12142 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
12143 | vty_out(vty, | |
12144 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
12145 | ||
12146 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12147 | PEER_FLAG_REFLECTOR_CLIENT)) | |
12148 | vty_out(vty, " Route-Reflector Client\n"); | |
12149 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12150 | PEER_FLAG_RSERVER_CLIENT)) | |
12151 | vty_out(vty, " Route-Server Client\n"); | |
12152 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
12153 | vty_out(vty, | |
12154 | " Inbound soft reconfiguration allowed\n"); | |
12155 | ||
12156 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12157 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
12158 | vty_out(vty, | |
12159 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
12160 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12161 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
12162 | vty_out(vty, | |
12163 | " Private AS numbers replaced in updates to this neighbor\n"); | |
12164 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12165 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
12166 | vty_out(vty, | |
12167 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
12168 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12169 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
12170 | vty_out(vty, | |
12171 | " Private AS numbers removed in updates to this neighbor\n"); | |
12172 | ||
dcc68b5e MS |
12173 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
12174 | vty_out(vty, " %s\n", | |
12175 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
12176 | ->human_description); | |
d62a17ae | 12177 | |
12178 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
12179 | vty_out(vty, | |
12180 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
12181 | ||
12182 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
12183 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12184 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
12185 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
12186 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12187 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
12188 | vty_out(vty, | |
12189 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
12190 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12191 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
12192 | vty_out(vty, | |
12193 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
12194 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
12195 | vty_out(vty, | |
12196 | " MED is propagated unchanged to this neighbor\n"); | |
12197 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
12198 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12199 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12200 | || CHECK_FLAG(p->af_flags[afi][safi], | |
12201 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
12202 | vty_out(vty, | |
12203 | " Community attribute sent to this neighbor"); | |
12204 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12205 | PEER_FLAG_SEND_COMMUNITY) | |
12206 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12207 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
12208 | && CHECK_FLAG(p->af_flags[afi][safi], | |
12209 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12210 | vty_out(vty, "(all)\n"); | |
12211 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12212 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
12213 | vty_out(vty, "(large)\n"); | |
12214 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
12215 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
12216 | vty_out(vty, "(extended)\n"); | |
12217 | else | |
12218 | vty_out(vty, "(standard)\n"); | |
12219 | } | |
12220 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12221 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
12222 | vty_out(vty, " Default information originate,"); | |
12223 | ||
12224 | if (p->default_rmap[afi][safi].name) | |
12225 | vty_out(vty, " default route-map %s%s,", | |
12226 | p->default_rmap[afi][safi].map ? "*" | |
12227 | : "", | |
12228 | p->default_rmap[afi][safi].name); | |
12229 | if (paf && PAF_SUBGRP(paf) | |
12230 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
12231 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
12232 | vty_out(vty, " default sent\n"); | |
12233 | else | |
12234 | vty_out(vty, " default not sent\n"); | |
12235 | } | |
12236 | ||
dff8f48d MK |
12237 | /* advertise-vni-all */ |
12238 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 12239 | if (is_evpn_enabled()) |
dff8f48d MK |
12240 | vty_out(vty, " advertise-all-vni\n"); |
12241 | } | |
12242 | ||
d62a17ae | 12243 | if (filter->plist[FILTER_IN].name |
12244 | || filter->dlist[FILTER_IN].name | |
12245 | || filter->aslist[FILTER_IN].name | |
12246 | || filter->map[RMAP_IN].name) | |
12247 | vty_out(vty, " Inbound path policy configured\n"); | |
12248 | if (filter->plist[FILTER_OUT].name | |
12249 | || filter->dlist[FILTER_OUT].name | |
12250 | || filter->aslist[FILTER_OUT].name | |
12251 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
12252 | vty_out(vty, " Outbound path policy configured\n"); | |
12253 | ||
12254 | /* prefix-list */ | |
12255 | if (filter->plist[FILTER_IN].name) | |
12256 | vty_out(vty, | |
12257 | " Incoming update prefix filter list is %s%s\n", | |
12258 | filter->plist[FILTER_IN].plist ? "*" : "", | |
12259 | filter->plist[FILTER_IN].name); | |
12260 | if (filter->plist[FILTER_OUT].name) | |
12261 | vty_out(vty, | |
12262 | " Outgoing update prefix filter list is %s%s\n", | |
12263 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
12264 | filter->plist[FILTER_OUT].name); | |
12265 | ||
12266 | /* distribute-list */ | |
12267 | if (filter->dlist[FILTER_IN].name) | |
12268 | vty_out(vty, | |
12269 | " Incoming update network filter list is %s%s\n", | |
12270 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
12271 | filter->dlist[FILTER_IN].name); | |
12272 | if (filter->dlist[FILTER_OUT].name) | |
12273 | vty_out(vty, | |
12274 | " Outgoing update network filter list is %s%s\n", | |
12275 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
12276 | filter->dlist[FILTER_OUT].name); | |
12277 | ||
12278 | /* filter-list. */ | |
12279 | if (filter->aslist[FILTER_IN].name) | |
12280 | vty_out(vty, | |
12281 | " Incoming update AS path filter list is %s%s\n", | |
12282 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
12283 | filter->aslist[FILTER_IN].name); | |
12284 | if (filter->aslist[FILTER_OUT].name) | |
12285 | vty_out(vty, | |
12286 | " Outgoing update AS path filter list is %s%s\n", | |
12287 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
12288 | filter->aslist[FILTER_OUT].name); | |
12289 | ||
12290 | /* route-map. */ | |
12291 | if (filter->map[RMAP_IN].name) | |
12292 | vty_out(vty, | |
12293 | " Route map for incoming advertisements is %s%s\n", | |
12294 | filter->map[RMAP_IN].map ? "*" : "", | |
12295 | filter->map[RMAP_IN].name); | |
12296 | if (filter->map[RMAP_OUT].name) | |
12297 | vty_out(vty, | |
12298 | " Route map for outgoing advertisements is %s%s\n", | |
12299 | filter->map[RMAP_OUT].map ? "*" : "", | |
12300 | filter->map[RMAP_OUT].name); | |
12301 | ||
9dac9fc8 | 12302 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 12303 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12304 | && !bgp_inbound_policy_exists(p, filter)) |
12305 | vty_out(vty, | |
12306 | " Inbound updates discarded due to missing policy\n"); | |
12307 | ||
12308 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 12309 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
12310 | && !bgp_outbound_policy_exists(p, filter)) |
12311 | vty_out(vty, | |
12312 | " Outbound updates discarded due to missing policy\n"); | |
12313 | ||
d62a17ae | 12314 | /* unsuppress-map */ |
12315 | if (filter->usmap.name) | |
12316 | vty_out(vty, | |
12317 | " Route map for selective unsuppress is %s%s\n", | |
12318 | filter->usmap.map ? "*" : "", | |
12319 | filter->usmap.name); | |
12320 | ||
7f7940e6 MK |
12321 | /* advertise-map */ |
12322 | if (filter->advmap.aname && filter->advmap.cname) | |
12323 | vty_out(vty, | |
12324 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
12325 | filter->advmap.condition ? "EXIST" | |
12326 | : "NON_EXIST", | |
12327 | filter->advmap.cmap ? "*" : "", | |
12328 | filter->advmap.cname, | |
12329 | filter->advmap.amap ? "*" : "", | |
12330 | filter->advmap.aname, | |
fa36596c | 12331 | filter->advmap.update_type == ADVERTISE |
c385f82a MK |
12332 | ? "Advertise" |
12333 | : "Withdraw"); | |
7f7940e6 | 12334 | |
d62a17ae | 12335 | /* Receive prefix count */ |
6cde4b45 | 12336 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 12337 | p->pcount[afi][safi]); |
d62a17ae | 12338 | |
fde246e8 DA |
12339 | /* maximum-prefix-out */ |
12340 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
12341 | PEER_FLAG_MAX_PREFIX_OUT)) | |
12342 | vty_out(vty, | |
6cde4b45 | 12343 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
12344 | p->pmax_out[afi][safi]); |
12345 | ||
d62a17ae | 12346 | /* Maximum prefix */ |
12347 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 12348 | vty_out(vty, |
6cde4b45 | 12349 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 12350 | p->pmax[afi][safi], |
12351 | CHECK_FLAG(p->af_flags[afi][safi], | |
12352 | PEER_FLAG_MAX_PREFIX_WARNING) | |
12353 | ? " (warning-only)" | |
12354 | : ""); | |
12355 | vty_out(vty, " Threshold for warning message %d%%", | |
12356 | p->pmax_threshold[afi][safi]); | |
12357 | if (p->pmax_restart[afi][safi]) | |
12358 | vty_out(vty, ", restart interval %d min", | |
12359 | p->pmax_restart[afi][safi]); | |
12360 | vty_out(vty, "\n"); | |
12361 | } | |
12362 | ||
12363 | vty_out(vty, "\n"); | |
12364 | } | |
12365 | } | |
12366 | ||
9f049418 | 12367 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 12368 | json_object *json) |
718e3744 | 12369 | { |
d62a17ae | 12370 | struct bgp *bgp; |
12371 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
12372 | char timebuf[BGP_UPTIME_LEN]; | |
12373 | char dn_flag[2]; | |
d62a17ae | 12374 | afi_t afi; |
12375 | safi_t safi; | |
d7c0a89a QY |
12376 | uint16_t i; |
12377 | uint8_t *msg; | |
d62a17ae | 12378 | json_object *json_neigh = NULL; |
12379 | time_t epoch_tbuf; | |
4ab46701 | 12380 | uint32_t sync_tcp_mss; |
718e3744 | 12381 | |
d62a17ae | 12382 | bgp = p->bgp; |
12383 | ||
12384 | if (use_json) | |
12385 | json_neigh = json_object_new_object(); | |
12386 | ||
12387 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
12388 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
12389 | dn_flag[0] = '*'; | |
12390 | ||
12391 | if (!use_json) { | |
12392 | if (p->conf_if) /* Configured interface name. */ | |
12393 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
12394 | BGP_PEER_SU_UNSPEC(p) | |
12395 | ? "None" | |
12396 | : sockunion2str(&p->su, buf, | |
12397 | SU_ADDRSTRLEN)); | |
12398 | else /* Configured IP address. */ | |
12399 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
12400 | p->host); | |
12401 | } | |
12402 | ||
12403 | if (use_json) { | |
12404 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
12405 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
12406 | "none"); | |
12407 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
12408 | json_object_string_add( | |
12409 | json_neigh, "bgpNeighborAddr", | |
12410 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
12411 | ||
12412 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
12413 | ||
12414 | if (p->change_local_as) | |
12415 | json_object_int_add(json_neigh, "localAs", | |
12416 | p->change_local_as); | |
12417 | else | |
12418 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
12419 | ||
12420 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
12421 | json_object_boolean_true_add(json_neigh, | |
12422 | "localAsNoPrepend"); | |
12423 | ||
12424 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
12425 | json_object_boolean_true_add(json_neigh, | |
12426 | "localAsReplaceAs"); | |
12427 | } else { | |
12428 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
12429 | || (p->as_type == AS_INTERNAL)) | |
12430 | vty_out(vty, "remote AS %u, ", p->as); | |
12431 | else | |
12432 | vty_out(vty, "remote AS Unspecified, "); | |
12433 | vty_out(vty, "local AS %u%s%s, ", | |
12434 | p->change_local_as ? p->change_local_as : p->local_as, | |
12435 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
12436 | ? " no-prepend" | |
12437 | : "", | |
12438 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
12439 | ? " replace-as" | |
12440 | : ""); | |
12441 | } | |
faa16034 DS |
12442 | /* peer type internal or confed-internal */ |
12443 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 12444 | if (use_json) { |
12445 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12446 | json_object_boolean_true_add( | |
12447 | json_neigh, "nbrConfedInternalLink"); | |
12448 | else | |
12449 | json_object_boolean_true_add(json_neigh, | |
12450 | "nbrInternalLink"); | |
12451 | } else { | |
12452 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12453 | vty_out(vty, "confed-internal link\n"); | |
12454 | else | |
12455 | vty_out(vty, "internal link\n"); | |
12456 | } | |
faa16034 DS |
12457 | /* peer type external or confed-external */ |
12458 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 12459 | if (use_json) { |
12460 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
12461 | json_object_boolean_true_add( | |
12462 | json_neigh, "nbrConfedExternalLink"); | |
12463 | else | |
12464 | json_object_boolean_true_add(json_neigh, | |
12465 | "nbrExternalLink"); | |
12466 | } else { | |
12467 | if (bgp_confederation_peers_check(bgp, p->as)) | |
12468 | vty_out(vty, "confed-external link\n"); | |
12469 | else | |
12470 | vty_out(vty, "external link\n"); | |
12471 | } | |
faa16034 DS |
12472 | } else { |
12473 | if (use_json) | |
12474 | json_object_boolean_true_add(json_neigh, | |
12475 | "nbrUnspecifiedLink"); | |
12476 | else | |
12477 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 12478 | } |
12479 | ||
12480 | /* Description. */ | |
12481 | if (p->desc) { | |
12482 | if (use_json) | |
12483 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
12484 | else | |
12485 | vty_out(vty, " Description: %s\n", p->desc); | |
12486 | } | |
12487 | ||
12488 | if (p->hostname) { | |
12489 | if (use_json) { | |
12490 | if (p->hostname) | |
12491 | json_object_string_add(json_neigh, "hostname", | |
12492 | p->hostname); | |
12493 | ||
12494 | if (p->domainname) | |
12495 | json_object_string_add(json_neigh, "domainname", | |
12496 | p->domainname); | |
12497 | } else { | |
12498 | if (p->domainname && (p->domainname[0] != '\0')) | |
12499 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
12500 | p->domainname); | |
12501 | else | |
12502 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
12503 | } | |
12504 | } | |
12505 | ||
12506 | /* Peer-group */ | |
12507 | if (p->group) { | |
12508 | if (use_json) { | |
12509 | json_object_string_add(json_neigh, "peerGroup", | |
12510 | p->group->name); | |
12511 | ||
12512 | if (dn_flag[0]) { | |
12513 | struct prefix prefix, *range = NULL; | |
12514 | ||
0154d8ce DS |
12515 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12516 | range = peer_group_lookup_dynamic_neighbor_range( | |
12517 | p->group, &prefix); | |
d62a17ae | 12518 | |
12519 | if (range) { | |
67d7e256 | 12520 | json_object_string_addf( |
d62a17ae | 12521 | json_neigh, |
67d7e256 DA |
12522 | "peerSubnetRangeGroup", "%pFX", |
12523 | range); | |
d62a17ae | 12524 | } |
12525 | } | |
12526 | } else { | |
12527 | vty_out(vty, | |
12528 | " Member of peer-group %s for session parameters\n", | |
12529 | p->group->name); | |
12530 | ||
12531 | if (dn_flag[0]) { | |
12532 | struct prefix prefix, *range = NULL; | |
12533 | ||
0154d8ce DS |
12534 | if (sockunion2hostprefix(&(p->su), &prefix)) |
12535 | range = peer_group_lookup_dynamic_neighbor_range( | |
12536 | p->group, &prefix); | |
d62a17ae | 12537 | |
12538 | if (range) { | |
d62a17ae | 12539 | vty_out(vty, |
1b78780b DL |
12540 | " Belongs to the subnet range group: %pFX\n", |
12541 | range); | |
d62a17ae | 12542 | } |
12543 | } | |
12544 | } | |
12545 | } | |
12546 | ||
12547 | if (use_json) { | |
12548 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12549 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12550 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12551 | json_object_boolean_true_add(json_neigh, |
12552 | "adminShutDown"); | |
12553 | ||
12554 | /* BGP Version. */ | |
12555 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
c949c771 DA |
12556 | json_object_string_addf(json_neigh, "remoteRouterId", "%pI4", |
12557 | &p->remote_id); | |
12558 | json_object_string_addf(json_neigh, "localRouterId", "%pI4", | |
12559 | &bgp->router_id); | |
d62a17ae | 12560 | |
12561 | /* Confederation */ | |
12562 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12563 | && bgp_confederation_peers_check(bgp, p->as)) | |
12564 | json_object_boolean_true_add(json_neigh, | |
12565 | "nbrCommonAdmin"); | |
12566 | ||
12567 | /* Status. */ | |
12568 | json_object_string_add( | |
12569 | json_neigh, "bgpState", | |
12570 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12571 | ||
feb17238 | 12572 | if (peer_established(p)) { |
d62a17ae | 12573 | time_t uptime; |
d62a17ae | 12574 | |
12575 | uptime = bgp_clock(); | |
12576 | uptime -= p->uptime; | |
d62a17ae | 12577 | epoch_tbuf = time(NULL) - uptime; |
12578 | ||
d3c7efed DS |
12579 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
12580 | uptime * 1000); | |
d62a17ae | 12581 | json_object_string_add(json_neigh, "bgpTimerUpString", |
12582 | peer_uptime(p->uptime, timebuf, | |
12583 | BGP_UPTIME_LEN, 0, | |
12584 | NULL)); | |
12585 | json_object_int_add(json_neigh, | |
12586 | "bgpTimerUpEstablishedEpoch", | |
12587 | epoch_tbuf); | |
12588 | } | |
12589 | ||
12590 | else if (p->status == Active) { | |
12591 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12592 | json_object_string_add(json_neigh, "bgpStateIs", | |
12593 | "passive"); | |
12594 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12595 | json_object_string_add(json_neigh, "bgpStateIs", | |
12596 | "passiveNSF"); | |
12597 | } | |
12598 | ||
12599 | /* read timer */ | |
12600 | time_t uptime; | |
a2700b50 | 12601 | struct tm tm; |
d62a17ae | 12602 | |
12603 | uptime = bgp_clock(); | |
12604 | uptime -= p->readtime; | |
a2700b50 MS |
12605 | gmtime_r(&uptime, &tm); |
12606 | ||
d62a17ae | 12607 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
12608 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12609 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12610 | |
12611 | uptime = bgp_clock(); | |
12612 | uptime -= p->last_write; | |
a2700b50 MS |
12613 | gmtime_r(&uptime, &tm); |
12614 | ||
d62a17ae | 12615 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
12616 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12617 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12618 | |
12619 | uptime = bgp_clock(); | |
12620 | uptime -= p->update_time; | |
a2700b50 MS |
12621 | gmtime_r(&uptime, &tm); |
12622 | ||
d62a17ae | 12623 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
12624 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
12625 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 12626 | |
12627 | /* Configured timer values. */ | |
12628 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
12629 | p->v_holdtime * 1000); | |
12630 | json_object_int_add(json_neigh, | |
12631 | "bgpTimerKeepAliveIntervalMsecs", | |
12632 | p->v_keepalive * 1000); | |
d43114f3 DS |
12633 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) { |
12634 | json_object_int_add(json_neigh, | |
12635 | "bgpTimerDelayOpenTimeMsecs", | |
12636 | p->v_delayopen * 1000); | |
12637 | } | |
12638 | ||
4ab46701 AR |
12639 | /* Configured and Synced tcp-mss value for peer */ |
12640 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12641 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12642 | json_object_int_add(json_neigh, "bgpTcpMssConfigured", | |
12643 | p->tcp_mss); | |
12644 | json_object_int_add(json_neigh, "bgpTcpMssSynced", | |
12645 | sync_tcp_mss); | |
12646 | } | |
12647 | ||
b90a8e13 | 12648 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12649 | json_object_int_add(json_neigh, |
12650 | "bgpTimerConfiguredHoldTimeMsecs", | |
12651 | p->holdtime * 1000); | |
12652 | json_object_int_add( | |
12653 | json_neigh, | |
12654 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12655 | p->keepalive * 1000); | |
5d5393b9 DL |
12656 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12657 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12658 | json_object_int_add(json_neigh, |
12659 | "bgpTimerConfiguredHoldTimeMsecs", | |
12660 | bgp->default_holdtime); | |
12661 | json_object_int_add( | |
12662 | json_neigh, | |
12663 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
12664 | bgp->default_keepalive); | |
d62a17ae | 12665 | } |
d08c0c80 DA |
12666 | |
12667 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
12668 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
12669 | json_object_boolean_true_add( | |
12670 | json_neigh, "extendedOptionalParametersLength"); | |
12671 | else | |
12672 | json_object_boolean_false_add( | |
12673 | json_neigh, "extendedOptionalParametersLength"); | |
6e37924b DA |
12674 | |
12675 | /* Conditional advertisements */ | |
12676 | json_object_int_add( | |
12677 | json_neigh, | |
12678 | "bgpTimerConfiguredConditionalAdvertisementsSec", | |
12679 | bgp->condition_check_period); | |
12680 | if (thread_is_scheduled(bgp->t_condition_check)) | |
12681 | json_object_int_add( | |
12682 | json_neigh, | |
12683 | "bgpTimerUntilConditionalAdvertisementsSec", | |
12684 | thread_timer_remain_second( | |
12685 | bgp->t_condition_check)); | |
d62a17ae | 12686 | } else { |
12687 | /* Administrative shutdown. */ | |
cb9196e7 DS |
12688 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
12689 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 12690 | vty_out(vty, " Administratively shut down\n"); |
12691 | ||
12692 | /* BGP Version. */ | |
12693 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 12694 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 12695 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
12696 | vty_out(vty, ", local router ID %s\n", |
12697 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
12698 | sizeof(buf1))); | |
d62a17ae | 12699 | |
12700 | /* Confederation */ | |
12701 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
12702 | && bgp_confederation_peers_check(bgp, p->as)) | |
12703 | vty_out(vty, | |
12704 | " Neighbor under common administration\n"); | |
12705 | ||
12706 | /* Status. */ | |
12707 | vty_out(vty, " BGP state = %s", | |
12708 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
12709 | ||
feb17238 | 12710 | if (peer_established(p)) |
d62a17ae | 12711 | vty_out(vty, ", up for %8s", |
12712 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
12713 | 0, NULL)); | |
12714 | ||
12715 | else if (p->status == Active) { | |
12716 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
12717 | vty_out(vty, " (passive)"); | |
12718 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
12719 | vty_out(vty, " (NSF passive)"); | |
12720 | } | |
12721 | vty_out(vty, "\n"); | |
12722 | ||
12723 | /* read timer */ | |
12724 | vty_out(vty, " Last read %s", | |
12725 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
12726 | NULL)); | |
12727 | vty_out(vty, ", Last write %s\n", | |
12728 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
12729 | NULL)); | |
12730 | ||
12731 | /* Configured timer values. */ | |
12732 | vty_out(vty, | |
12733 | " Hold time is %d, keepalive interval is %d seconds\n", | |
12734 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 12735 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 12736 | vty_out(vty, " Configured hold time is %d", |
12737 | p->holdtime); | |
12738 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12739 | p->keepalive); | |
5d5393b9 DL |
12740 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
12741 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
12742 | vty_out(vty, " Configured hold time is %d", |
12743 | bgp->default_holdtime); | |
12744 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
12745 | bgp->default_keepalive); | |
d62a17ae | 12746 | } |
d43114f3 DS |
12747 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER_DELAYOPEN)) |
12748 | vty_out(vty, | |
12749 | " Configured DelayOpenTime is %d seconds\n", | |
12750 | p->delayopen); | |
4ab46701 AR |
12751 | |
12752 | /* Configured and synced tcp-mss value for peer */ | |
12753 | if (CHECK_FLAG(p->flags, PEER_FLAG_TCP_MSS)) { | |
12754 | sync_tcp_mss = sockopt_tcp_mss_get(p->fd); | |
12755 | vty_out(vty, " Configured tcp-mss is %d", p->tcp_mss); | |
12756 | vty_out(vty, ", synced tcp-mss is %d\n", sync_tcp_mss); | |
12757 | } | |
d08c0c80 DA |
12758 | |
12759 | /* Extended Optional Parameters Length for BGP OPEN Message */ | |
12760 | if (BGP_OPEN_EXT_OPT_PARAMS_CAPABLE(p)) | |
12761 | vty_out(vty, | |
12762 | " Extended Optional Parameters Length is enabled\n"); | |
6e37924b DA |
12763 | |
12764 | /* Conditional advertisements */ | |
12765 | vty_out(vty, | |
12766 | " Configured conditional advertisements interval is %d seconds\n", | |
12767 | bgp->condition_check_period); | |
12768 | if (thread_is_scheduled(bgp->t_condition_check)) | |
12769 | vty_out(vty, | |
12770 | " Time until conditional advertisements begin is %lu seconds\n", | |
12771 | thread_timer_remain_second( | |
12772 | bgp->t_condition_check)); | |
d62a17ae | 12773 | } |
12774 | /* Capability. */ | |
10711563 DA |
12775 | if (peer_established(p) && |
12776 | (p->cap || peer_afc_advertised(p) || peer_afc_received(p))) { | |
12777 | if (use_json) { | |
12778 | json_object *json_cap = NULL; | |
d62a17ae | 12779 | |
10711563 | 12780 | json_cap = json_object_new_object(); |
d62a17ae | 12781 | |
10711563 DA |
12782 | /* AS4 */ |
12783 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
12784 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12785 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) && | |
12786 | CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
ef56aee4 | 12787 | json_object_string_add( |
10711563 | 12788 | json_cap, "4byteAs", |
ef56aee4 | 12789 | "advertisedAndReceived"); |
10711563 DA |
12790 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) |
12791 | json_object_string_add(json_cap, | |
12792 | "4byteAs", | |
12793 | "advertised"); | |
12794 | else if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
12795 | json_object_string_add(json_cap, | |
12796 | "4byteAs", | |
12797 | "received"); | |
12798 | } | |
ef56aee4 | 12799 | |
10711563 DA |
12800 | /* Extended Message Support */ |
12801 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV) && | |
12802 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12803 | json_object_string_add(json_cap, | |
12804 | "extendedMessage", | |
12805 | "advertisedAndReceived"); | |
12806 | else if (CHECK_FLAG(p->cap, | |
12807 | PEER_CAP_EXTENDED_MESSAGE_ADV)) | |
12808 | json_object_string_add(json_cap, | |
12809 | "extendedMessage", | |
12810 | "advertised"); | |
12811 | else if (CHECK_FLAG(p->cap, | |
12812 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
12813 | json_object_string_add(json_cap, | |
12814 | "extendedMessage", | |
12815 | "received"); | |
ef56aee4 | 12816 | |
10711563 DA |
12817 | /* AddPath */ |
12818 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
12819 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
12820 | json_object *json_add = NULL; | |
12821 | const char *print_store; | |
d62a17ae | 12822 | |
10711563 | 12823 | json_add = json_object_new_object(); |
d62a17ae | 12824 | |
10711563 DA |
12825 | FOREACH_AFI_SAFI (afi, safi) { |
12826 | json_object *json_sub = NULL; | |
12827 | json_sub = json_object_new_object(); | |
12828 | print_store = get_afi_safi_str( | |
12829 | afi, safi, true); | |
d62a17ae | 12830 | |
10711563 DA |
12831 | if (CHECK_FLAG( |
12832 | p->af_cap[afi][safi], | |
12833 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
12834 | CHECK_FLAG( | |
12835 | p->af_cap[afi][safi], | |
12836 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
05c7a1cc QY |
12837 | if (CHECK_FLAG( |
12838 | p->af_cap[afi] | |
12839 | [safi], | |
10711563 DA |
12840 | PEER_CAP_ADDPATH_AF_TX_ADV) && |
12841 | CHECK_FLAG( | |
05c7a1cc QY |
12842 | p->af_cap[afi] |
12843 | [safi], | |
10711563 DA |
12844 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
12845 | json_object_boolean_true_add( | |
12846 | json_sub, | |
12847 | "txAdvertisedAndReceived"); | |
12848 | else if ( | |
12849 | CHECK_FLAG( | |
12850 | p->af_cap[afi] | |
12851 | [safi], | |
12852 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
12853 | json_object_boolean_true_add( | |
12854 | json_sub, | |
12855 | "txAdvertised"); | |
12856 | else if ( | |
12857 | CHECK_FLAG( | |
12858 | p->af_cap[afi] | |
12859 | [safi], | |
12860 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12861 | json_object_boolean_true_add( | |
12862 | json_sub, | |
12863 | "txReceived"); | |
12864 | } | |
d62a17ae | 12865 | |
10711563 DA |
12866 | if (CHECK_FLAG( |
12867 | p->af_cap[afi][safi], | |
12868 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
12869 | CHECK_FLAG( | |
12870 | p->af_cap[afi][safi], | |
12871 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
05c7a1cc QY |
12872 | if (CHECK_FLAG( |
12873 | p->af_cap[afi] | |
12874 | [safi], | |
10711563 DA |
12875 | PEER_CAP_ADDPATH_AF_RX_ADV) && |
12876 | CHECK_FLAG( | |
12877 | p->af_cap[afi] | |
12878 | [safi], | |
12879 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12880 | json_object_boolean_true_add( | |
12881 | json_sub, | |
12882 | "rxAdvertisedAndReceived"); | |
12883 | else if ( | |
12884 | CHECK_FLAG( | |
12885 | p->af_cap[afi] | |
12886 | [safi], | |
12887 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
12888 | json_object_boolean_true_add( | |
12889 | json_sub, | |
12890 | "rxAdvertised"); | |
12891 | else if ( | |
12892 | CHECK_FLAG( | |
12893 | p->af_cap[afi] | |
12894 | [safi], | |
12895 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12896 | json_object_boolean_true_add( | |
12897 | json_sub, | |
12898 | "rxReceived"); | |
05c7a1cc QY |
12899 | } |
12900 | ||
10711563 DA |
12901 | if (CHECK_FLAG( |
12902 | p->af_cap[afi][safi], | |
12903 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
12904 | CHECK_FLAG( | |
12905 | p->af_cap[afi][safi], | |
12906 | PEER_CAP_ADDPATH_AF_TX_RCV) || | |
12907 | CHECK_FLAG( | |
12908 | p->af_cap[afi][safi], | |
12909 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
12910 | CHECK_FLAG( | |
12911 | p->af_cap[afi][safi], | |
12912 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
12913 | json_object_object_add( | |
12914 | json_add, print_store, | |
12915 | json_sub); | |
12916 | else | |
12917 | json_object_free(json_sub); | |
d62a17ae | 12918 | } |
12919 | ||
10711563 DA |
12920 | json_object_object_add(json_cap, "addPath", |
12921 | json_add); | |
12922 | } | |
d62a17ae | 12923 | |
10711563 DA |
12924 | /* Dynamic */ |
12925 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
12926 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
12927 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV) && | |
12928 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
12929 | json_object_string_add( | |
12930 | json_cap, "dynamic", | |
12931 | "advertisedAndReceived"); | |
12932 | else if (CHECK_FLAG(p->cap, | |
12933 | PEER_CAP_DYNAMIC_ADV)) | |
12934 | json_object_string_add(json_cap, | |
12935 | "dynamic", | |
12936 | "advertised"); | |
12937 | else if (CHECK_FLAG(p->cap, | |
12938 | PEER_CAP_DYNAMIC_RCV)) | |
12939 | json_object_string_add(json_cap, | |
12940 | "dynamic", | |
12941 | "received"); | |
12942 | } | |
d62a17ae | 12943 | |
10711563 DA |
12944 | /* Extended nexthop */ |
12945 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
12946 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12947 | json_object *json_nxt = NULL; | |
12948 | const char *print_store; | |
d62a17ae | 12949 | |
d62a17ae | 12950 | |
10711563 DA |
12951 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV) && |
12952 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
12953 | json_object_string_add( | |
12954 | json_cap, "extendedNexthop", | |
12955 | "advertisedAndReceived"); | |
12956 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
12957 | json_object_string_add( | |
12958 | json_cap, "extendedNexthop", | |
12959 | "advertised"); | |
12960 | else if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
12961 | json_object_string_add( | |
12962 | json_cap, "extendedNexthop", | |
12963 | "received"); | |
d62a17ae | 12964 | |
10711563 DA |
12965 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
12966 | json_nxt = json_object_new_object(); | |
d62a17ae | 12967 | |
10711563 DA |
12968 | for (safi = SAFI_UNICAST; |
12969 | safi < SAFI_MAX; safi++) { | |
12970 | if (CHECK_FLAG( | |
12971 | p->af_cap[AFI_IP] | |
12972 | [safi], | |
12973 | PEER_CAP_ENHE_AF_RCV)) { | |
12974 | print_store = | |
12975 | get_afi_safi_str( | |
d62a17ae | 12976 | AFI_IP, |
10711563 DA |
12977 | safi, |
12978 | true); | |
12979 | json_object_string_add( | |
12980 | json_nxt, | |
12981 | print_store, | |
12982 | "recieved"); /* misspelled for compatibility */ | |
d62a17ae | 12983 | } |
d62a17ae | 12984 | } |
10711563 DA |
12985 | json_object_object_add( |
12986 | json_cap, | |
12987 | "extendedNexthopFamililesByPeer", | |
12988 | json_nxt); | |
d62a17ae | 12989 | } |
10711563 | 12990 | } |
d62a17ae | 12991 | |
10711563 DA |
12992 | /* Long-lived Graceful Restart */ |
12993 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
12994 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
12995 | json_object *json_llgr = NULL; | |
12996 | const char *afi_safi_str; | |
8606be87 | 12997 | |
10711563 DA |
12998 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV) && |
12999 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13000 | json_object_string_add( | |
13001 | json_cap, | |
13002 | "longLivedGracefulRestart", | |
13003 | "advertisedAndReceived"); | |
13004 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13005 | json_object_string_add( | |
13006 | json_cap, | |
13007 | "longLivedGracefulRestart", | |
13008 | "advertised"); | |
13009 | else if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13010 | json_object_string_add( | |
13011 | json_cap, | |
13012 | "longLivedGracefulRestart", | |
13013 | "received"); | |
8606be87 | 13014 | |
10711563 DA |
13015 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
13016 | json_llgr = json_object_new_object(); | |
8606be87 | 13017 | |
10711563 DA |
13018 | FOREACH_AFI_SAFI (afi, safi) { |
13019 | if (CHECK_FLAG( | |
13020 | p->af_cap[afi] | |
13021 | [safi], | |
13022 | PEER_CAP_ENHE_AF_RCV)) { | |
13023 | afi_safi_str = | |
13024 | get_afi_safi_str( | |
8606be87 DA |
13025 | afi, |
13026 | safi, | |
13027 | true); | |
10711563 DA |
13028 | json_object_string_add( |
13029 | json_llgr, | |
13030 | afi_safi_str, | |
13031 | "received"); | |
8606be87 | 13032 | } |
8606be87 | 13033 | } |
10711563 DA |
13034 | json_object_object_add( |
13035 | json_cap, | |
13036 | "longLivedGracefulRestartByPeer", | |
13037 | json_llgr); | |
8606be87 | 13038 | } |
10711563 | 13039 | } |
8606be87 | 13040 | |
10711563 DA |
13041 | /* Route Refresh */ |
13042 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13043 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13044 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13045 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) && | |
13046 | (CHECK_FLAG(p->cap, | |
13047 | PEER_CAP_REFRESH_NEW_RCV) || | |
13048 | CHECK_FLAG(p->cap, | |
13049 | PEER_CAP_REFRESH_OLD_RCV))) { | |
13050 | if (CHECK_FLAG( | |
13051 | p->cap, | |
13052 | PEER_CAP_REFRESH_OLD_RCV) && | |
13053 | CHECK_FLAG( | |
13054 | p->cap, | |
13055 | PEER_CAP_REFRESH_NEW_RCV)) | |
13056 | json_object_string_add( | |
13057 | json_cap, | |
13058 | "routeRefresh", | |
13059 | "advertisedAndReceivedOldNew"); | |
13060 | else { | |
d62a17ae | 13061 | if (CHECK_FLAG( |
13062 | p->cap, | |
10711563 | 13063 | PEER_CAP_REFRESH_OLD_RCV)) |
d62a17ae | 13064 | json_object_string_add( |
13065 | json_cap, | |
13066 | "routeRefresh", | |
10711563 DA |
13067 | "advertisedAndReceivedOld"); |
13068 | else | |
13069 | json_object_string_add( | |
13070 | json_cap, | |
13071 | "routeRefresh", | |
13072 | "advertisedAndReceivedNew"); | |
d62a17ae | 13073 | } |
10711563 DA |
13074 | } else if (CHECK_FLAG(p->cap, |
13075 | PEER_CAP_REFRESH_ADV)) | |
13076 | json_object_string_add(json_cap, | |
13077 | "routeRefresh", | |
13078 | "advertised"); | |
13079 | else if (CHECK_FLAG(p->cap, | |
13080 | PEER_CAP_REFRESH_NEW_RCV) || | |
13081 | CHECK_FLAG(p->cap, | |
13082 | PEER_CAP_REFRESH_OLD_RCV)) | |
13083 | json_object_string_add(json_cap, | |
13084 | "routeRefresh", | |
13085 | "received"); | |
13086 | } | |
d62a17ae | 13087 | |
10711563 DA |
13088 | /* Enhanced Route Refresh */ |
13089 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13090 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13091 | if (CHECK_FLAG(p->cap, | |
13092 | PEER_CAP_ENHANCED_RR_ADV) && | |
13093 | CHECK_FLAG(p->cap, | |
13094 | PEER_CAP_ENHANCED_RR_RCV)) | |
d77114b7 | 13095 | json_object_string_add( |
10711563 DA |
13096 | json_cap, |
13097 | "enhancedRouteRefresh", | |
13098 | "advertisedAndReceived"); | |
13099 | else if (CHECK_FLAG(p->cap, | |
13100 | PEER_CAP_ENHANCED_RR_ADV)) | |
d77114b7 | 13101 | json_object_string_add( |
10711563 DA |
13102 | json_cap, |
13103 | "enhancedRouteRefresh", | |
13104 | "advertised"); | |
13105 | else if (CHECK_FLAG(p->cap, | |
9af52ccf | 13106 | PEER_CAP_ENHANCED_RR_RCV)) |
10711563 DA |
13107 | json_object_string_add( |
13108 | json_cap, | |
13109 | "enhancedRouteRefresh", | |
13110 | "received"); | |
13111 | } | |
d77114b7 | 13112 | |
10711563 DA |
13113 | /* Multiprotocol Extensions */ |
13114 | json_object *json_multi = NULL; | |
d77114b7 | 13115 | |
10711563 | 13116 | json_multi = json_object_new_object(); |
d77114b7 | 13117 | |
10711563 DA |
13118 | FOREACH_AFI_SAFI (afi, safi) { |
13119 | if (p->afc_adv[afi][safi] || | |
13120 | p->afc_recv[afi][safi]) { | |
13121 | json_object *json_exten = NULL; | |
13122 | json_exten = json_object_new_object(); | |
13123 | ||
13124 | if (p->afc_adv[afi][safi] && | |
13125 | p->afc_recv[afi][safi]) | |
13126 | json_object_boolean_true_add( | |
13127 | json_exten, | |
9af52ccf | 13128 | "advertisedAndReceived"); |
10711563 DA |
13129 | else if (p->afc_adv[afi][safi]) |
13130 | json_object_boolean_true_add( | |
13131 | json_exten, | |
9af52ccf | 13132 | "advertised"); |
10711563 DA |
13133 | else if (p->afc_recv[afi][safi]) |
13134 | json_object_boolean_true_add( | |
13135 | json_exten, "received"); | |
9af52ccf | 13136 | |
10711563 DA |
13137 | json_object_object_add( |
13138 | json_multi, | |
13139 | get_afi_safi_str(afi, safi, | |
13140 | true), | |
13141 | json_exten); | |
13142 | } | |
13143 | } | |
13144 | json_object_object_add(json_cap, | |
13145 | "multiprotocolExtensions", | |
13146 | json_multi); | |
d62a17ae | 13147 | |
10711563 DA |
13148 | /* Hostname capabilities */ |
13149 | json_object *json_hname = NULL; | |
d62a17ae | 13150 | |
10711563 | 13151 | json_hname = json_object_new_object(); |
d62a17ae | 13152 | |
10711563 DA |
13153 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
13154 | json_object_string_add( | |
13155 | json_hname, "advHostName", | |
13156 | bgp->peer_self->hostname | |
13157 | ? bgp->peer_self->hostname | |
13158 | : "n/a"); | |
13159 | json_object_string_add( | |
13160 | json_hname, "advDomainName", | |
13161 | bgp->peer_self->domainname | |
13162 | ? bgp->peer_self->domainname | |
13163 | : "n/a"); | |
13164 | } | |
d77114b7 | 13165 | |
d77114b7 | 13166 | |
10711563 DA |
13167 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13168 | json_object_string_add( | |
13169 | json_hname, "rcvHostName", | |
13170 | p->hostname ? p->hostname : "n/a"); | |
13171 | json_object_string_add( | |
13172 | json_hname, "rcvDomainName", | |
13173 | p->domainname ? p->domainname : "n/a"); | |
13174 | } | |
d77114b7 | 13175 | |
10711563 DA |
13176 | json_object_object_add(json_cap, "hostName", |
13177 | json_hname); | |
d77114b7 | 13178 | |
17be83bf | 13179 | /* Graceful Restart */ |
10711563 DA |
13180 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || |
13181 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13182 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) && | |
13183 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
d77114b7 | 13184 | json_object_string_add( |
10711563 DA |
13185 | json_cap, "gracefulRestart", |
13186 | "advertisedAndReceived"); | |
13187 | else if (CHECK_FLAG(p->cap, | |
13188 | PEER_CAP_RESTART_ADV)) | |
d77114b7 | 13189 | json_object_string_add( |
10711563 DA |
13190 | json_cap, |
13191 | "gracefulRestartCapability", | |
13192 | "advertised"); | |
13193 | else if (CHECK_FLAG(p->cap, | |
13194 | PEER_CAP_RESTART_RCV)) | |
13195 | json_object_string_add( | |
13196 | json_cap, | |
13197 | "gracefulRestartCapability", | |
13198 | "received"); | |
d77114b7 | 13199 | |
10711563 DA |
13200 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13201 | int restart_af_count = 0; | |
13202 | json_object *json_restart = NULL; | |
13203 | json_restart = json_object_new_object(); | |
d62a17ae | 13204 | |
10711563 DA |
13205 | json_object_int_add( |
13206 | json_cap, | |
13207 | "gracefulRestartRemoteTimerMsecs", | |
13208 | p->v_gr_restart * 1000); | |
d62a17ae | 13209 | |
10711563 | 13210 | FOREACH_AFI_SAFI (afi, safi) { |
05c7a1cc QY |
13211 | if (CHECK_FLAG( |
13212 | p->af_cap[afi] | |
13213 | [safi], | |
10711563 DA |
13214 | PEER_CAP_RESTART_AF_RCV)) { |
13215 | json_object *json_sub = | |
13216 | NULL; | |
13217 | json_sub = | |
13218 | json_object_new_object(); | |
d62a17ae | 13219 | |
05c7a1cc QY |
13220 | if (CHECK_FLAG( |
13221 | p->af_cap | |
13222 | [afi] | |
13223 | [safi], | |
10711563 DA |
13224 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
13225 | json_object_boolean_true_add( | |
13226 | json_sub, | |
13227 | "preserved"); | |
13228 | restart_af_count++; | |
d62a17ae | 13229 | json_object_object_add( |
10711563 DA |
13230 | json_restart, |
13231 | get_afi_safi_str( | |
13232 | afi, | |
13233 | safi, | |
13234 | true), | |
13235 | json_sub); | |
d62a17ae | 13236 | } |
d62a17ae | 13237 | } |
10711563 DA |
13238 | if (!restart_af_count) { |
13239 | json_object_string_add( | |
13240 | json_cap, | |
13241 | "addressFamiliesByPeer", | |
13242 | "none"); | |
13243 | json_object_free(json_restart); | |
13244 | } else | |
13245 | json_object_object_add( | |
13246 | json_cap, | |
13247 | "addressFamiliesByPeer", | |
13248 | json_restart); | |
d62a17ae | 13249 | } |
10711563 DA |
13250 | } |
13251 | json_object_object_add( | |
13252 | json_neigh, "neighborCapabilities", json_cap); | |
13253 | } else { | |
13254 | vty_out(vty, " Neighbor capabilities:\n"); | |
13255 | ||
13256 | /* AS4 */ | |
13257 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) || | |
13258 | CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
13259 | vty_out(vty, " 4 Byte AS:"); | |
13260 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) | |
13261 | vty_out(vty, " advertised"); | |
13262 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV)) | |
13263 | vty_out(vty, " %sreceived", | |
13264 | CHECK_FLAG(p->cap, | |
13265 | PEER_CAP_AS4_ADV) | |
13266 | ? "and " | |
13267 | : ""); | |
13268 | vty_out(vty, "\n"); | |
13269 | } | |
d62a17ae | 13270 | |
10711563 DA |
13271 | /* Extended Message Support */ |
13272 | if (CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_RCV) || | |
13273 | CHECK_FLAG(p->cap, PEER_CAP_EXTENDED_MESSAGE_ADV)) { | |
13274 | vty_out(vty, " Extended Message:"); | |
ef56aee4 | 13275 | if (CHECK_FLAG(p->cap, |
10711563 DA |
13276 | PEER_CAP_EXTENDED_MESSAGE_ADV)) |
13277 | vty_out(vty, " advertised"); | |
13278 | if (CHECK_FLAG(p->cap, | |
13279 | PEER_CAP_EXTENDED_MESSAGE_RCV)) | |
13280 | vty_out(vty, " %sreceived", | |
13281 | CHECK_FLAG( | |
13282 | p->cap, | |
13283 | PEER_CAP_EXTENDED_MESSAGE_ADV) | |
13284 | ? "and " | |
13285 | : ""); | |
13286 | vty_out(vty, "\n"); | |
13287 | } | |
d62a17ae | 13288 | |
10711563 DA |
13289 | /* AddPath */ |
13290 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) || | |
13291 | CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_ADV)) { | |
13292 | vty_out(vty, " AddPath:\n"); | |
d62a17ae | 13293 | |
10711563 | 13294 | FOREACH_AFI_SAFI (afi, safi) { |
ef56aee4 | 13295 | if (CHECK_FLAG( |
10711563 DA |
13296 | p->af_cap[afi][safi], |
13297 | PEER_CAP_ADDPATH_AF_TX_ADV) || | |
13298 | CHECK_FLAG( | |
13299 | p->af_cap[afi][safi], | |
13300 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
13301 | vty_out(vty, " %s: TX ", | |
13302 | get_afi_safi_str( | |
13303 | afi, safi, | |
13304 | false)); | |
ef56aee4 | 13305 | |
10711563 DA |
13306 | if (CHECK_FLAG( |
13307 | p->af_cap[afi] | |
13308 | [safi], | |
13309 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
13310 | vty_out(vty, | |
13311 | "advertised"); | |
d62a17ae | 13312 | |
05c7a1cc QY |
13313 | if (CHECK_FLAG( |
13314 | p->af_cap[afi] | |
13315 | [safi], | |
10711563 | 13316 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
05c7a1cc | 13317 | vty_out(vty, |
10711563 DA |
13318 | "%sreceived", |
13319 | CHECK_FLAG( | |
13320 | p->af_cap | |
13321 | [afi] | |
13322 | [safi], | |
13323 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
13324 | ? " and " | |
13325 | : ""); | |
05c7a1cc | 13326 | |
10711563 DA |
13327 | vty_out(vty, "\n"); |
13328 | } | |
d62a17ae | 13329 | |
9af52ccf | 13330 | if (CHECK_FLAG( |
10711563 DA |
13331 | p->af_cap[afi][safi], |
13332 | PEER_CAP_ADDPATH_AF_RX_ADV) || | |
13333 | CHECK_FLAG( | |
13334 | p->af_cap[afi][safi], | |
13335 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
13336 | vty_out(vty, " %s: RX ", | |
5cb5f4d0 | 13337 | get_afi_safi_str( |
10711563 DA |
13338 | afi, safi, |
13339 | false)); | |
d62a17ae | 13340 | |
05c7a1cc QY |
13341 | if (CHECK_FLAG( |
13342 | p->af_cap[afi] | |
13343 | [safi], | |
10711563 | 13344 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
05c7a1cc | 13345 | vty_out(vty, |
10711563 | 13346 | "advertised"); |
d62a17ae | 13347 | |
10711563 DA |
13348 | if (CHECK_FLAG( |
13349 | p->af_cap[afi] | |
13350 | [safi], | |
13351 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc | 13352 | vty_out(vty, |
10711563 DA |
13353 | "%sreceived", |
13354 | CHECK_FLAG( | |
13355 | p->af_cap | |
13356 | [afi] | |
13357 | [safi], | |
13358 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
13359 | ? " and " | |
05c7a1cc | 13360 | : ""); |
d62a17ae | 13361 | |
05c7a1cc | 13362 | vty_out(vty, "\n"); |
05c7a1cc | 13363 | } |
d62a17ae | 13364 | } |
10711563 | 13365 | } |
d62a17ae | 13366 | |
10711563 DA |
13367 | /* Dynamic */ |
13368 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) || | |
13369 | CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) { | |
13370 | vty_out(vty, " Dynamic:"); | |
13371 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_ADV)) | |
13372 | vty_out(vty, " advertised"); | |
13373 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV)) | |
13374 | vty_out(vty, " %sreceived", | |
13375 | CHECK_FLAG(p->cap, | |
13376 | PEER_CAP_DYNAMIC_ADV) | |
13377 | ? "and " | |
13378 | : ""); | |
13379 | vty_out(vty, "\n"); | |
13380 | } | |
d62a17ae | 13381 | |
10711563 DA |
13382 | /* Extended nexthop */ |
13383 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) || | |
13384 | CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
13385 | vty_out(vty, " Extended nexthop:"); | |
13386 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) | |
13387 | vty_out(vty, " advertised"); | |
13388 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) | |
13389 | vty_out(vty, " %sreceived", | |
13390 | CHECK_FLAG(p->cap, | |
13391 | PEER_CAP_ENHE_ADV) | |
13392 | ? "and " | |
13393 | : ""); | |
13394 | vty_out(vty, "\n"); | |
d62a17ae | 13395 | |
10711563 | 13396 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV)) { |
57f7feb6 | 13397 | vty_out(vty, |
10711563 DA |
13398 | " Address families by peer:\n "); |
13399 | for (safi = SAFI_UNICAST; | |
13400 | safi < SAFI_MAX; safi++) | |
13401 | if (CHECK_FLAG( | |
13402 | p->af_cap[AFI_IP] | |
13403 | [safi], | |
13404 | PEER_CAP_ENHE_AF_RCV)) | |
13405 | vty_out(vty, | |
13406 | " %s\n", | |
13407 | get_afi_safi_str( | |
13408 | AFI_IP, | |
13409 | safi, | |
13410 | false)); | |
d62a17ae | 13411 | } |
10711563 | 13412 | } |
d62a17ae | 13413 | |
10711563 DA |
13414 | /* Long-lived Graceful Restart */ |
13415 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV) || | |
13416 | CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) { | |
13417 | vty_out(vty, | |
13418 | " Long-lived Graceful Restart:"); | |
13419 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_ADV)) | |
13420 | vty_out(vty, " advertised"); | |
13421 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) | |
13422 | vty_out(vty, " %sreceived", | |
13423 | CHECK_FLAG(p->cap, | |
13424 | PEER_CAP_LLGR_ADV) | |
13425 | ? "and " | |
13426 | : ""); | |
13427 | vty_out(vty, "\n"); | |
8606be87 | 13428 | |
10711563 | 13429 | if (CHECK_FLAG(p->cap, PEER_CAP_LLGR_RCV)) { |
57f7feb6 | 13430 | vty_out(vty, |
10711563 DA |
13431 | " Address families by peer:\n"); |
13432 | FOREACH_AFI_SAFI (afi, safi) | |
13433 | if (CHECK_FLAG( | |
13434 | p->af_cap[afi] | |
13435 | [safi], | |
13436 | PEER_CAP_LLGR_AF_RCV)) | |
13437 | vty_out(vty, | |
13438 | " %s\n", | |
13439 | get_afi_safi_str( | |
13440 | afi, | |
13441 | safi, | |
13442 | false)); | |
8606be87 | 13443 | } |
10711563 | 13444 | } |
8606be87 | 13445 | |
10711563 DA |
13446 | /* Route Refresh */ |
13447 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) || | |
13448 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_NEW_RCV) || | |
13449 | CHECK_FLAG(p->cap, PEER_CAP_REFRESH_OLD_RCV)) { | |
13450 | vty_out(vty, " Route refresh:"); | |
13451 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV)) | |
13452 | vty_out(vty, " advertised"); | |
13453 | if (CHECK_FLAG(p->cap, | |
13454 | PEER_CAP_REFRESH_NEW_RCV) || | |
13455 | CHECK_FLAG(p->cap, | |
13456 | PEER_CAP_REFRESH_OLD_RCV)) | |
13457 | vty_out(vty, " %sreceived(%s)", | |
13458 | CHECK_FLAG(p->cap, | |
13459 | PEER_CAP_REFRESH_ADV) | |
13460 | ? "and " | |
13461 | : "", | |
13462 | (CHECK_FLAG( | |
13463 | p->cap, | |
13464 | PEER_CAP_REFRESH_OLD_RCV) && | |
13465 | CHECK_FLAG( | |
13466 | p->cap, | |
13467 | PEER_CAP_REFRESH_NEW_RCV)) | |
13468 | ? "old & new" | |
13469 | : CHECK_FLAG( | |
13470 | p->cap, | |
13471 | PEER_CAP_REFRESH_OLD_RCV) | |
13472 | ? "old" | |
13473 | : "new"); | |
d62a17ae | 13474 | |
d77114b7 | 13475 | vty_out(vty, "\n"); |
10711563 | 13476 | } |
d62a17ae | 13477 | |
10711563 DA |
13478 | /* Enhanced Route Refresh */ |
13479 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_ADV) || | |
13480 | CHECK_FLAG(p->cap, PEER_CAP_ENHANCED_RR_RCV)) { | |
13481 | vty_out(vty, " Enhanced Route Refresh:"); | |
13482 | if (CHECK_FLAG(p->cap, | |
13483 | PEER_CAP_ENHANCED_RR_ADV)) | |
13484 | vty_out(vty, " advertised"); | |
13485 | if (CHECK_FLAG(p->cap, | |
13486 | PEER_CAP_ENHANCED_RR_RCV)) | |
13487 | vty_out(vty, " %sreceived", | |
13488 | CHECK_FLAG(p->cap, | |
13489 | PEER_CAP_REFRESH_ADV) | |
13490 | ? "and " | |
13491 | : ""); | |
13492 | vty_out(vty, "\n"); | |
13493 | } | |
13494 | ||
13495 | /* Multiprotocol Extensions */ | |
13496 | FOREACH_AFI_SAFI (afi, safi) | |
13497 | if (p->afc_adv[afi][safi] || | |
13498 | p->afc_recv[afi][safi]) { | |
13499 | vty_out(vty, " Address Family %s:", | |
13500 | get_afi_safi_str(afi, safi, | |
13501 | false)); | |
13502 | if (p->afc_adv[afi][safi]) | |
9af52ccf | 13503 | vty_out(vty, " advertised"); |
10711563 | 13504 | if (p->afc_recv[afi][safi]) |
9af52ccf | 13505 | vty_out(vty, " %sreceived", |
10711563 | 13506 | p->afc_adv[afi][safi] |
9af52ccf DA |
13507 | ? "and " |
13508 | : ""); | |
13509 | vty_out(vty, "\n"); | |
13510 | } | |
13511 | ||
10711563 DA |
13512 | /* Hostname capability */ |
13513 | vty_out(vty, " Hostname Capability:"); | |
d62a17ae | 13514 | |
10711563 DA |
13515 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { |
13516 | vty_out(vty, | |
13517 | " advertised (name: %s,domain name: %s)", | |
13518 | bgp->peer_self->hostname | |
13519 | ? bgp->peer_self->hostname | |
13520 | : "n/a", | |
13521 | bgp->peer_self->domainname | |
13522 | ? bgp->peer_self->domainname | |
13523 | : "n/a"); | |
13524 | } else { | |
13525 | vty_out(vty, " not advertised"); | |
13526 | } | |
d77114b7 | 13527 | |
10711563 DA |
13528 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
13529 | vty_out(vty, | |
13530 | " received (name: %s,domain name: %s)", | |
13531 | p->hostname ? p->hostname : "n/a", | |
13532 | p->domainname ? p->domainname : "n/a"); | |
13533 | } else { | |
13534 | vty_out(vty, " not received"); | |
d62a17ae | 13535 | } |
d62a17ae | 13536 | |
10711563 | 13537 | vty_out(vty, "\n"); |
d77114b7 | 13538 | |
10711563 DA |
13539 | /* Graceful Restart */ |
13540 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || | |
13541 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) { | |
13542 | vty_out(vty, | |
13543 | " Graceful Restart Capability:"); | |
13544 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV)) | |
13545 | vty_out(vty, " advertised"); | |
13546 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
13547 | vty_out(vty, " %sreceived", | |
13548 | CHECK_FLAG(p->cap, | |
13549 | PEER_CAP_RESTART_ADV) | |
13550 | ? "and " | |
13551 | : ""); | |
d77114b7 MK |
13552 | vty_out(vty, "\n"); |
13553 | ||
10711563 DA |
13554 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { |
13555 | int restart_af_count = 0; | |
d62a17ae | 13556 | |
10711563 DA |
13557 | vty_out(vty, |
13558 | " Remote Restart timer is %d seconds\n", | |
13559 | p->v_gr_restart); | |
13560 | vty_out(vty, | |
13561 | " Address families by peer:\n "); | |
d62a17ae | 13562 | |
10711563 DA |
13563 | FOREACH_AFI_SAFI (afi, safi) |
13564 | if (CHECK_FLAG( | |
13565 | p->af_cap[afi] | |
13566 | [safi], | |
13567 | PEER_CAP_RESTART_AF_RCV)) { | |
13568 | vty_out(vty, "%s%s(%s)", | |
13569 | restart_af_count | |
13570 | ? ", " | |
13571 | : "", | |
13572 | get_afi_safi_str( | |
13573 | afi, | |
13574 | safi, | |
13575 | false), | |
13576 | CHECK_FLAG( | |
13577 | p->af_cap | |
13578 | [afi] | |
13579 | [safi], | |
13580 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
13581 | ? "preserved" | |
13582 | : "not preserved"); | |
13583 | restart_af_count++; | |
13584 | } | |
13585 | if (!restart_af_count) | |
13586 | vty_out(vty, "none"); | |
13587 | vty_out(vty, "\n"); | |
13588 | } | |
17be83bf | 13589 | } /* Graceful Restart */ |
d62a17ae | 13590 | } |
13591 | } | |
13592 | ||
13593 | /* graceful restart information */ | |
10711563 DA |
13594 | json_object *json_grace = NULL; |
13595 | json_object *json_grace_send = NULL; | |
13596 | json_object *json_grace_recv = NULL; | |
13597 | int eor_send_af_count = 0; | |
13598 | int eor_receive_af_count = 0; | |
d62a17ae | 13599 | |
10711563 DA |
13600 | if (use_json) { |
13601 | json_grace = json_object_new_object(); | |
13602 | json_grace_send = json_object_new_object(); | |
13603 | json_grace_recv = json_object_new_object(); | |
13604 | ||
13605 | if ((peer_established(p)) && | |
13606 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13607 | FOREACH_AFI_SAFI (afi, safi) { | |
13608 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13609 | PEER_STATUS_EOR_SEND)) { | |
13610 | json_object_boolean_true_add( | |
13611 | json_grace_send, | |
13612 | get_afi_safi_str(afi, safi, | |
13613 | true)); | |
13614 | eor_send_af_count++; | |
d62a17ae | 13615 | } |
10711563 DA |
13616 | } |
13617 | FOREACH_AFI_SAFI (afi, safi) { | |
13618 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13619 | PEER_STATUS_EOR_RECEIVED)) { | |
13620 | json_object_boolean_true_add( | |
13621 | json_grace_recv, | |
13622 | get_afi_safi_str(afi, safi, | |
13623 | true)); | |
13624 | eor_receive_af_count++; | |
d62a17ae | 13625 | } |
13626 | } | |
10711563 DA |
13627 | } |
13628 | json_object_object_add(json_grace, "endOfRibSend", | |
13629 | json_grace_send); | |
13630 | json_object_object_add(json_grace, "endOfRibRecv", | |
13631 | json_grace_recv); | |
d62a17ae | 13632 | |
d62a17ae | 13633 | |
10711563 DA |
13634 | if (p->t_gr_restart) |
13635 | json_object_int_add( | |
13636 | json_grace, "gracefulRestartTimerMsecs", | |
13637 | thread_timer_remain_second(p->t_gr_restart) * | |
13638 | 1000); | |
2986cac2 | 13639 | |
10711563 DA |
13640 | if (p->t_gr_stale) |
13641 | json_object_int_add( | |
13642 | json_grace, "gracefulStalepathTimerMsecs", | |
13643 | thread_timer_remain_second(p->t_gr_stale) * | |
13644 | 1000); | |
13645 | /* more gr info in new format */ | |
13646 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json_grace); | |
13647 | json_object_object_add(json_neigh, "gracefulRestartInfo", | |
13648 | json_grace); | |
13649 | } else { | |
13650 | vty_out(vty, " Graceful restart information:\n"); | |
13651 | if ((peer_established(p)) && | |
13652 | CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
13653 | ||
13654 | vty_out(vty, " End-of-RIB send: "); | |
13655 | FOREACH_AFI_SAFI (afi, safi) { | |
13656 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13657 | PEER_STATUS_EOR_SEND)) { | |
13658 | vty_out(vty, "%s%s", | |
13659 | eor_send_af_count ? ", " : "", | |
13660 | get_afi_safi_str(afi, safi, | |
13661 | false)); | |
13662 | eor_send_af_count++; | |
d62a17ae | 13663 | } |
10711563 DA |
13664 | } |
13665 | vty_out(vty, "\n"); | |
13666 | vty_out(vty, " End-of-RIB received: "); | |
13667 | FOREACH_AFI_SAFI (afi, safi) { | |
13668 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
13669 | PEER_STATUS_EOR_RECEIVED)) { | |
13670 | vty_out(vty, "%s%s", | |
13671 | eor_receive_af_count ? ", " | |
13672 | : "", | |
13673 | get_afi_safi_str(afi, safi, | |
13674 | false)); | |
13675 | eor_receive_af_count++; | |
d62a17ae | 13676 | } |
d62a17ae | 13677 | } |
10711563 DA |
13678 | vty_out(vty, "\n"); |
13679 | } | |
d62a17ae | 13680 | |
10711563 DA |
13681 | if (p->t_gr_restart) |
13682 | vty_out(vty, | |
13683 | " The remaining time of restart timer is %ld\n", | |
13684 | thread_timer_remain_second(p->t_gr_restart)); | |
d62a17ae | 13685 | |
10711563 DA |
13686 | if (p->t_gr_stale) |
13687 | vty_out(vty, | |
13688 | " The remaining time of stalepath timer is %ld\n", | |
13689 | thread_timer_remain_second(p->t_gr_stale)); | |
2986cac2 | 13690 | |
10711563 DA |
13691 | /* more gr info in new format */ |
13692 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
13693 | } | |
2986cac2 | 13694 | |
d62a17ae | 13695 | if (use_json) { |
13696 | json_object *json_stat = NULL; | |
13697 | json_stat = json_object_new_object(); | |
13698 | /* Packet counts. */ | |
43aa5965 QY |
13699 | |
13700 | atomic_size_t outq_count, inq_count; | |
13701 | outq_count = atomic_load_explicit(&p->obuf->count, | |
13702 | memory_order_relaxed); | |
13703 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13704 | memory_order_relaxed); | |
13705 | ||
13706 | json_object_int_add(json_stat, "depthInq", | |
13707 | (unsigned long)inq_count); | |
d62a17ae | 13708 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 13709 | (unsigned long)outq_count); |
0112e9e0 QY |
13710 | json_object_int_add(json_stat, "opensSent", |
13711 | atomic_load_explicit(&p->open_out, | |
13712 | memory_order_relaxed)); | |
13713 | json_object_int_add(json_stat, "opensRecv", | |
13714 | atomic_load_explicit(&p->open_in, | |
13715 | memory_order_relaxed)); | |
d62a17ae | 13716 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
13717 | atomic_load_explicit(&p->notify_out, |
13718 | memory_order_relaxed)); | |
d62a17ae | 13719 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
13720 | atomic_load_explicit(&p->notify_in, |
13721 | memory_order_relaxed)); | |
13722 | json_object_int_add(json_stat, "updatesSent", | |
13723 | atomic_load_explicit(&p->update_out, | |
13724 | memory_order_relaxed)); | |
13725 | json_object_int_add(json_stat, "updatesRecv", | |
13726 | atomic_load_explicit(&p->update_in, | |
13727 | memory_order_relaxed)); | |
d62a17ae | 13728 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
13729 | atomic_load_explicit(&p->keepalive_out, |
13730 | memory_order_relaxed)); | |
d62a17ae | 13731 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
13732 | atomic_load_explicit(&p->keepalive_in, |
13733 | memory_order_relaxed)); | |
d62a17ae | 13734 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
13735 | atomic_load_explicit(&p->refresh_out, |
13736 | memory_order_relaxed)); | |
d62a17ae | 13737 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
13738 | atomic_load_explicit(&p->refresh_in, |
13739 | memory_order_relaxed)); | |
d62a17ae | 13740 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
13741 | atomic_load_explicit(&p->dynamic_cap_out, |
13742 | memory_order_relaxed)); | |
d62a17ae | 13743 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
13744 | atomic_load_explicit(&p->dynamic_cap_in, |
13745 | memory_order_relaxed)); | |
13746 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
13747 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 13748 | json_object_object_add(json_neigh, "messageStats", json_stat); |
13749 | } else { | |
cb93e0a2 IS |
13750 | atomic_size_t outq_count, inq_count, open_out, open_in, |
13751 | notify_out, notify_in, update_out, update_in, | |
13752 | keepalive_out, keepalive_in, refresh_out, refresh_in, | |
13753 | dynamic_cap_out, dynamic_cap_in; | |
43aa5965 QY |
13754 | outq_count = atomic_load_explicit(&p->obuf->count, |
13755 | memory_order_relaxed); | |
13756 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
13757 | memory_order_relaxed); | |
cb93e0a2 IS |
13758 | open_out = atomic_load_explicit(&p->open_out, |
13759 | memory_order_relaxed); | |
13760 | open_in = | |
13761 | atomic_load_explicit(&p->open_in, memory_order_relaxed); | |
13762 | notify_out = atomic_load_explicit(&p->notify_out, | |
13763 | memory_order_relaxed); | |
13764 | notify_in = atomic_load_explicit(&p->notify_in, | |
13765 | memory_order_relaxed); | |
13766 | update_out = atomic_load_explicit(&p->update_out, | |
13767 | memory_order_relaxed); | |
13768 | update_in = atomic_load_explicit(&p->update_in, | |
13769 | memory_order_relaxed); | |
13770 | keepalive_out = atomic_load_explicit(&p->keepalive_out, | |
13771 | memory_order_relaxed); | |
13772 | keepalive_in = atomic_load_explicit(&p->keepalive_in, | |
13773 | memory_order_relaxed); | |
13774 | refresh_out = atomic_load_explicit(&p->refresh_out, | |
13775 | memory_order_relaxed); | |
13776 | refresh_in = atomic_load_explicit(&p->refresh_in, | |
13777 | memory_order_relaxed); | |
13778 | dynamic_cap_out = atomic_load_explicit(&p->dynamic_cap_out, | |
13779 | memory_order_relaxed); | |
13780 | dynamic_cap_in = atomic_load_explicit(&p->dynamic_cap_in, | |
13781 | memory_order_relaxed); | |
43aa5965 | 13782 | |
d62a17ae | 13783 | /* Packet counts. */ |
13784 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
13785 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
13786 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 13787 | vty_out(vty, " Sent Rcvd\n"); |
cb93e0a2 IS |
13788 | vty_out(vty, " Opens: %10zu %10zu\n", open_out, |
13789 | open_in); | |
13790 | vty_out(vty, " Notifications: %10zu %10zu\n", notify_out, | |
13791 | notify_in); | |
13792 | vty_out(vty, " Updates: %10zu %10zu\n", update_out, | |
13793 | update_in); | |
13794 | vty_out(vty, " Keepalives: %10zu %10zu\n", keepalive_out, | |
13795 | keepalive_in); | |
13796 | vty_out(vty, " Route Refresh: %10zu %10zu\n", refresh_out, | |
13797 | refresh_in); | |
13798 | vty_out(vty, " Capability: %10zu %10zu\n", | |
13799 | dynamic_cap_out, dynamic_cap_in); | |
13800 | vty_out(vty, " Total: %10u %10u\n", | |
13801 | (uint32_t)PEER_TOTAL_TX(p), (uint32_t)PEER_TOTAL_RX(p)); | |
d62a17ae | 13802 | } |
13803 | ||
13804 | if (use_json) { | |
13805 | /* advertisement-interval */ | |
13806 | json_object_int_add(json_neigh, | |
13807 | "minBtwnAdvertisementRunsTimerMsecs", | |
13808 | p->v_routeadv * 1000); | |
13809 | ||
13810 | /* Update-source. */ | |
13811 | if (p->update_if || p->update_source) { | |
13812 | if (p->update_if) | |
13813 | json_object_string_add(json_neigh, | |
13814 | "updateSource", | |
13815 | p->update_if); | |
13816 | else if (p->update_source) | |
13817 | json_object_string_add( | |
13818 | json_neigh, "updateSource", | |
13819 | sockunion2str(p->update_source, buf1, | |
13820 | SU_ADDRSTRLEN)); | |
13821 | } | |
13822 | } else { | |
13823 | /* advertisement-interval */ | |
13824 | vty_out(vty, | |
13825 | " Minimum time between advertisement runs is %d seconds\n", | |
13826 | p->v_routeadv); | |
13827 | ||
13828 | /* Update-source. */ | |
13829 | if (p->update_if || p->update_source) { | |
13830 | vty_out(vty, " Update source is "); | |
13831 | if (p->update_if) | |
13832 | vty_out(vty, "%s", p->update_if); | |
13833 | else if (p->update_source) | |
13834 | vty_out(vty, "%s", | |
13835 | sockunion2str(p->update_source, buf1, | |
13836 | SU_ADDRSTRLEN)); | |
13837 | vty_out(vty, "\n"); | |
13838 | } | |
13839 | ||
13840 | vty_out(vty, "\n"); | |
13841 | } | |
13842 | ||
13843 | /* Address Family Information */ | |
13844 | json_object *json_hold = NULL; | |
13845 | ||
13846 | if (use_json) | |
13847 | json_hold = json_object_new_object(); | |
13848 | ||
05c7a1cc QY |
13849 | FOREACH_AFI_SAFI (afi, safi) |
13850 | if (p->afc[afi][safi]) | |
13851 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
13852 | json_hold); | |
d62a17ae | 13853 | |
13854 | if (use_json) { | |
13855 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
13856 | json_hold); | |
13857 | json_object_int_add(json_neigh, "connectionsEstablished", | |
13858 | p->established); | |
13859 | json_object_int_add(json_neigh, "connectionsDropped", | |
13860 | p->dropped); | |
13861 | } else | |
13862 | vty_out(vty, " Connections established %d; dropped %d\n", | |
13863 | p->established, p->dropped); | |
13864 | ||
13865 | if (!p->last_reset) { | |
13866 | if (use_json) | |
13867 | json_object_string_add(json_neigh, "lastReset", | |
13868 | "never"); | |
13869 | else | |
13870 | vty_out(vty, " Last reset never\n"); | |
13871 | } else { | |
13872 | if (use_json) { | |
13873 | time_t uptime; | |
a2700b50 | 13874 | struct tm tm; |
d62a17ae | 13875 | |
13876 | uptime = bgp_clock(); | |
13877 | uptime -= p->resettime; | |
a2700b50 MS |
13878 | gmtime_r(&uptime, &tm); |
13879 | ||
d62a17ae | 13880 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
13881 | (tm.tm_sec * 1000) |
13882 | + (tm.tm_min * 60000) | |
13883 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 13884 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 13885 | } else { |
13886 | vty_out(vty, " Last reset %s, ", | |
13887 | peer_uptime(p->resettime, timebuf, | |
13888 | BGP_UPTIME_LEN, 0, NULL)); | |
13889 | ||
3577f1c5 | 13890 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 13891 | if (p->last_reset_cause_size) { |
13892 | msg = p->last_reset_cause; | |
13893 | vty_out(vty, | |
13894 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
13895 | for (i = 1; i <= p->last_reset_cause_size; | |
13896 | i++) { | |
13897 | vty_out(vty, "%02X", *msg++); | |
13898 | ||
13899 | if (i != p->last_reset_cause_size) { | |
13900 | if (i % 16 == 0) { | |
13901 | vty_out(vty, "\n "); | |
13902 | } else if (i % 4 == 0) { | |
13903 | vty_out(vty, " "); | |
13904 | } | |
13905 | } | |
13906 | } | |
13907 | vty_out(vty, "\n"); | |
13908 | } | |
13909 | } | |
13910 | } | |
13911 | ||
13912 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
13913 | if (use_json) | |
13914 | json_object_boolean_true_add(json_neigh, | |
13915 | "prefixesConfigExceedMax"); | |
13916 | else | |
13917 | vty_out(vty, | |
13918 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
13919 | ||
13920 | if (p->t_pmax_restart) { | |
13921 | if (use_json) { | |
13922 | json_object_boolean_true_add( | |
13923 | json_neigh, "reducePrefixNumFrom"); | |
13924 | json_object_int_add(json_neigh, | |
13925 | "restartInTimerMsec", | |
13926 | thread_timer_remain_second( | |
13927 | p->t_pmax_restart) | |
13928 | * 1000); | |
13929 | } else | |
13930 | vty_out(vty, | |
13931 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
13932 | p->host, thread_timer_remain_second( |
13933 | p->t_pmax_restart)); | |
d62a17ae | 13934 | } else { |
13935 | if (use_json) | |
13936 | json_object_boolean_true_add( | |
13937 | json_neigh, | |
13938 | "reducePrefixNumAndClearIpBgp"); | |
13939 | else | |
13940 | vty_out(vty, | |
13941 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
13942 | p->host); | |
13943 | } | |
13944 | } | |
13945 | ||
13946 | /* EBGP Multihop and GTSM */ | |
13947 | if (p->sort != BGP_PEER_IBGP) { | |
13948 | if (use_json) { | |
e2521429 | 13949 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13950 | json_object_int_add(json_neigh, |
13951 | "externalBgpNbrMaxHopsAway", | |
13952 | p->gtsm_hops); | |
be8d1733 | 13953 | else |
d62a17ae | 13954 | json_object_int_add(json_neigh, |
13955 | "externalBgpNbrMaxHopsAway", | |
13956 | p->ttl); | |
13957 | } else { | |
e2521429 | 13958 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 13959 | vty_out(vty, |
13960 | " External BGP neighbor may be up to %d hops away.\n", | |
13961 | p->gtsm_hops); | |
be8d1733 | 13962 | else |
d62a17ae | 13963 | vty_out(vty, |
13964 | " External BGP neighbor may be up to %d hops away.\n", | |
13965 | p->ttl); | |
13966 | } | |
13967 | } else { | |
be8d1733 DA |
13968 | if (use_json) { |
13969 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 13970 | json_object_int_add(json_neigh, |
13971 | "internalBgpNbrMaxHopsAway", | |
13972 | p->gtsm_hops); | |
13973 | else | |
be8d1733 DA |
13974 | json_object_int_add(json_neigh, |
13975 | "internalBgpNbrMaxHopsAway", | |
13976 | p->ttl); | |
13977 | } else { | |
13978 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) | |
d62a17ae | 13979 | vty_out(vty, |
13980 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13981 | p->gtsm_hops); | |
be8d1733 DA |
13982 | else |
13983 | vty_out(vty, | |
13984 | " Internal BGP neighbor may be up to %d hops away.\n", | |
13985 | p->ttl); | |
d62a17ae | 13986 | } |
13987 | } | |
13988 | ||
13989 | /* Local address. */ | |
13990 | if (p->su_local) { | |
13991 | if (use_json) { | |
13992 | json_object_string_add(json_neigh, "hostLocal", | |
13993 | sockunion2str(p->su_local, buf1, | |
13994 | SU_ADDRSTRLEN)); | |
13995 | json_object_int_add(json_neigh, "portLocal", | |
13996 | ntohs(p->su_local->sin.sin_port)); | |
13997 | } else | |
13998 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13999 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
14000 | ntohs(p->su_local->sin.sin_port)); | |
14001 | } | |
14002 | ||
14003 | /* Remote address. */ | |
14004 | if (p->su_remote) { | |
14005 | if (use_json) { | |
14006 | json_object_string_add(json_neigh, "hostForeign", | |
14007 | sockunion2str(p->su_remote, buf1, | |
14008 | SU_ADDRSTRLEN)); | |
14009 | json_object_int_add(json_neigh, "portForeign", | |
14010 | ntohs(p->su_remote->sin.sin_port)); | |
14011 | } else | |
14012 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
14013 | sockunion2str(p->su_remote, buf1, | |
14014 | SU_ADDRSTRLEN), | |
14015 | ntohs(p->su_remote->sin.sin_port)); | |
14016 | } | |
14017 | ||
14018 | /* Nexthop display. */ | |
14019 | if (p->su_local) { | |
14020 | if (use_json) { | |
c949c771 DA |
14021 | json_object_string_addf(json_neigh, "nexthop", "%pI4", |
14022 | &p->nexthop.v4); | |
14023 | json_object_string_addf(json_neigh, "nexthopGlobal", | |
14024 | "%pI6", &p->nexthop.v6_global); | |
14025 | json_object_string_addf(json_neigh, "nexthopLocal", | |
14026 | "%pI6", &p->nexthop.v6_local); | |
d62a17ae | 14027 | if (p->shared_network) |
14028 | json_object_string_add(json_neigh, | |
14029 | "bgpConnection", | |
14030 | "sharedNetwork"); | |
14031 | else | |
14032 | json_object_string_add(json_neigh, | |
14033 | "bgpConnection", | |
14034 | "nonSharedNetwork"); | |
14035 | } else { | |
14036 | vty_out(vty, "Nexthop: %s\n", | |
14037 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
14038 | sizeof(buf1))); | |
14039 | vty_out(vty, "Nexthop global: %s\n", | |
14040 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
14041 | sizeof(buf1))); | |
14042 | vty_out(vty, "Nexthop local: %s\n", | |
14043 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
14044 | sizeof(buf1))); | |
14045 | vty_out(vty, "BGP connection: %s\n", | |
14046 | p->shared_network ? "shared network" | |
14047 | : "non shared network"); | |
14048 | } | |
14049 | } | |
14050 | ||
14051 | /* Timer information. */ | |
14052 | if (use_json) { | |
14053 | json_object_int_add(json_neigh, "connectRetryTimer", | |
14054 | p->v_connect); | |
feb17238 | 14055 | if (peer_established(p) && p->rtt) |
d62a17ae | 14056 | json_object_int_add(json_neigh, "estimatedRttInMsecs", |
14057 | p->rtt); | |
14058 | if (p->t_start) | |
14059 | json_object_int_add( | |
14060 | json_neigh, "nextStartTimerDueInMsecs", | |
14061 | thread_timer_remain_second(p->t_start) * 1000); | |
14062 | if (p->t_connect) | |
14063 | json_object_int_add( | |
14064 | json_neigh, "nextConnectTimerDueInMsecs", | |
14065 | thread_timer_remain_second(p->t_connect) | |
14066 | * 1000); | |
14067 | if (p->t_routeadv) { | |
14068 | json_object_int_add(json_neigh, "mraiInterval", | |
14069 | p->v_routeadv); | |
14070 | json_object_int_add( | |
14071 | json_neigh, "mraiTimerExpireInMsecs", | |
14072 | thread_timer_remain_second(p->t_routeadv) | |
14073 | * 1000); | |
14074 | } | |
14075 | if (p->password) | |
14076 | json_object_int_add(json_neigh, "authenticationEnabled", | |
14077 | 1); | |
14078 | ||
14079 | if (p->t_read) | |
14080 | json_object_string_add(json_neigh, "readThread", "on"); | |
14081 | else | |
14082 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
14083 | |
14084 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 14085 | json_object_string_add(json_neigh, "writeThread", "on"); |
14086 | else | |
14087 | json_object_string_add(json_neigh, "writeThread", | |
14088 | "off"); | |
14089 | } else { | |
14090 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
14091 | p->v_connect); | |
feb17238 | 14092 | if (peer_established(p) && p->rtt) |
d62a17ae | 14093 | vty_out(vty, "Estimated round trip time: %d ms\n", |
14094 | p->rtt); | |
14095 | if (p->t_start) | |
14096 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
14097 | thread_timer_remain_second(p->t_start)); | |
14098 | if (p->t_connect) | |
14099 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
14100 | thread_timer_remain_second(p->t_connect)); | |
14101 | if (p->t_routeadv) | |
14102 | vty_out(vty, | |
14103 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
14104 | p->v_routeadv, | |
14105 | thread_timer_remain_second(p->t_routeadv)); | |
14106 | if (p->password) | |
14107 | vty_out(vty, "Peer Authentication Enabled\n"); | |
14108 | ||
cac9e917 | 14109 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
14110 | p->t_read ? "on" : "off", |
14111 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
14112 | ? "on" | |
cac9e917 | 14113 | : "off", p->fd); |
d62a17ae | 14114 | } |
14115 | ||
14116 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
14117 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
14118 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
14119 | ||
14120 | if (!use_json) | |
14121 | vty_out(vty, "\n"); | |
14122 | ||
14123 | /* BFD information. */ | |
21bfce98 RZ |
14124 | if (p->bfd_config) |
14125 | bgp_bfd_show_info(vty, p, json_neigh); | |
d62a17ae | 14126 | |
14127 | if (use_json) { | |
14128 | if (p->conf_if) /* Configured interface name. */ | |
14129 | json_object_object_add(json, p->conf_if, json_neigh); | |
14130 | else /* Configured IP address. */ | |
14131 | json_object_object_add(json, p->host, json_neigh); | |
14132 | } | |
14133 | } | |
14134 | ||
36235319 QY |
14135 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
14136 | enum show_type type, | |
14137 | union sockunion *su, | |
14138 | const char *conf_if, afi_t afi, | |
74a630b6 | 14139 | bool use_json) |
2986cac2 | 14140 | { |
14141 | struct listnode *node, *nnode; | |
14142 | struct peer *peer; | |
14143 | int find = 0; | |
14144 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 14145 | json_object *json = NULL; |
2986cac2 | 14146 | json_object *json_neighbor = NULL; |
14147 | ||
74a630b6 NT |
14148 | if (use_json) { |
14149 | json = json_object_new_object(); | |
14150 | json_neighbor = json_object_new_object(); | |
14151 | } | |
14152 | ||
2986cac2 | 14153 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
14154 | ||
14155 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14156 | continue; | |
14157 | ||
14158 | if ((peer->afc[afi][safi]) == 0) | |
14159 | continue; | |
14160 | ||
2ba1fe69 | 14161 | if (type == show_all) { |
2986cac2 | 14162 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 14163 | json_neighbor); |
2986cac2 | 14164 | |
74a630b6 | 14165 | if (use_json) { |
13909c4f DS |
14166 | json_object_object_add(json, peer->host, |
14167 | json_neighbor); | |
74a630b6 NT |
14168 | json_neighbor = NULL; |
14169 | } | |
2986cac2 | 14170 | |
2ba1fe69 | 14171 | } else if (type == show_peer) { |
2986cac2 | 14172 | if (conf_if) { |
14173 | if ((peer->conf_if | |
13909c4f DS |
14174 | && !strcmp(peer->conf_if, conf_if)) |
14175 | || (peer->hostname | |
2986cac2 | 14176 | && !strcmp(peer->hostname, conf_if))) { |
14177 | find = 1; | |
13909c4f DS |
14178 | bgp_show_peer_gr_status(vty, peer, |
14179 | use_json, | |
14180 | json_neighbor); | |
2986cac2 | 14181 | } |
14182 | } else { | |
14183 | if (sockunion_same(&peer->su, su)) { | |
14184 | find = 1; | |
13909c4f DS |
14185 | bgp_show_peer_gr_status(vty, peer, |
14186 | use_json, | |
14187 | json_neighbor); | |
2986cac2 | 14188 | } |
14189 | } | |
13909c4f DS |
14190 | if (use_json && find) |
14191 | json_object_object_add(json, peer->host, | |
14192 | json_neighbor); | |
2986cac2 | 14193 | } |
14194 | ||
74a630b6 NT |
14195 | if (find) { |
14196 | json_neighbor = NULL; | |
2986cac2 | 14197 | break; |
74a630b6 | 14198 | } |
2986cac2 | 14199 | } |
14200 | ||
14201 | if (type == show_peer && !find) { | |
14202 | if (use_json) | |
13909c4f | 14203 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 14204 | else |
14205 | vty_out(vty, "%% No such neighbor\n"); | |
14206 | } | |
14207 | if (use_json) { | |
74a630b6 NT |
14208 | if (json_neighbor) |
14209 | json_object_free(json_neighbor); | |
75eeda93 | 14210 | vty_json(vty, json); |
2986cac2 | 14211 | } else { |
14212 | vty_out(vty, "\n"); | |
14213 | } | |
14214 | ||
14215 | return CMD_SUCCESS; | |
14216 | } | |
14217 | ||
d62a17ae | 14218 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
14219 | enum show_type type, union sockunion *su, | |
9f049418 | 14220 | const char *conf_if, bool use_json, |
d62a17ae | 14221 | json_object *json) |
14222 | { | |
14223 | struct listnode *node, *nnode; | |
14224 | struct peer *peer; | |
14225 | int find = 0; | |
9f049418 | 14226 | bool nbr_output = false; |
d1927ebe AS |
14227 | afi_t afi = AFI_MAX; |
14228 | safi_t safi = SAFI_MAX; | |
14229 | ||
14230 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
14231 | afi = AFI_IP; | |
14232 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
14233 | afi = AFI_IP6; | |
14234 | } | |
d62a17ae | 14235 | |
14236 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14237 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14238 | continue; | |
14239 | ||
14240 | switch (type) { | |
14241 | case show_all: | |
14242 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 14243 | nbr_output = true; |
d62a17ae | 14244 | break; |
14245 | case show_peer: | |
14246 | if (conf_if) { | |
14247 | if ((peer->conf_if | |
14248 | && !strcmp(peer->conf_if, conf_if)) | |
14249 | || (peer->hostname | |
14250 | && !strcmp(peer->hostname, conf_if))) { | |
14251 | find = 1; | |
14252 | bgp_show_peer(vty, peer, use_json, | |
14253 | json); | |
14254 | } | |
14255 | } else { | |
14256 | if (sockunion_same(&peer->su, su)) { | |
14257 | find = 1; | |
14258 | bgp_show_peer(vty, peer, use_json, | |
14259 | json); | |
14260 | } | |
14261 | } | |
14262 | break; | |
d1927ebe AS |
14263 | case show_ipv4_peer: |
14264 | case show_ipv6_peer: | |
14265 | FOREACH_SAFI (safi) { | |
14266 | if (peer->afc[afi][safi]) { | |
14267 | if (conf_if) { | |
14268 | if ((peer->conf_if | |
14269 | && !strcmp(peer->conf_if, conf_if)) | |
14270 | || (peer->hostname | |
14271 | && !strcmp(peer->hostname, conf_if))) { | |
14272 | find = 1; | |
14273 | bgp_show_peer(vty, peer, use_json, | |
14274 | json); | |
14275 | break; | |
14276 | } | |
14277 | } else { | |
14278 | if (sockunion_same(&peer->su, su)) { | |
14279 | find = 1; | |
14280 | bgp_show_peer(vty, peer, use_json, | |
14281 | json); | |
14282 | break; | |
14283 | } | |
14284 | } | |
14285 | } | |
14286 | } | |
14287 | break; | |
14288 | case show_ipv4_all: | |
14289 | case show_ipv6_all: | |
14290 | FOREACH_SAFI (safi) { | |
14291 | if (peer->afc[afi][safi]) { | |
14292 | bgp_show_peer(vty, peer, use_json, json); | |
14293 | nbr_output = true; | |
14294 | break; | |
14295 | } | |
14296 | } | |
14297 | break; | |
d62a17ae | 14298 | } |
14299 | } | |
14300 | ||
d1927ebe AS |
14301 | if ((type == show_peer || type == show_ipv4_peer || |
14302 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 14303 | if (use_json) |
14304 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
14305 | else | |
88b7d255 | 14306 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 14307 | } |
14308 | ||
d1927ebe AS |
14309 | if (type != show_peer && type != show_ipv4_peer && |
14310 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 14311 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 14312 | |
d62a17ae | 14313 | if (use_json) { |
996c9314 LB |
14314 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
14315 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 14316 | } else { |
14317 | vty_out(vty, "\n"); | |
14318 | } | |
14319 | ||
14320 | return CMD_SUCCESS; | |
14321 | } | |
14322 | ||
36235319 QY |
14323 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
14324 | enum show_type type, | |
14325 | const char *ip_str, | |
14326 | afi_t afi, bool use_json) | |
2986cac2 | 14327 | { |
14328 | ||
14329 | int ret; | |
14330 | struct bgp *bgp; | |
14331 | union sockunion su; | |
2986cac2 | 14332 | |
14333 | bgp = bgp_get_default(); | |
14334 | ||
13909c4f DS |
14335 | if (!bgp) |
14336 | return; | |
2986cac2 | 14337 | |
13909c4f DS |
14338 | if (!use_json) |
14339 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
14340 | NULL); | |
2986cac2 | 14341 | |
13909c4f DS |
14342 | if (ip_str) { |
14343 | ret = str2sockunion(ip_str, &su); | |
14344 | if (ret < 0) | |
13909c4f | 14345 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
14346 | vty, bgp, type, NULL, ip_str, afi, use_json); |
14347 | else | |
14348 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
14349 | NULL, afi, use_json); | |
13909c4f DS |
14350 | } else |
14351 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 14352 | afi, use_json); |
2986cac2 | 14353 | } |
14354 | ||
d62a17ae | 14355 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
14356 | enum show_type type, |
14357 | const char *ip_str, | |
9f049418 | 14358 | bool use_json) |
d62a17ae | 14359 | { |
0291c246 MK |
14360 | struct listnode *node, *nnode; |
14361 | struct bgp *bgp; | |
71aedaa3 | 14362 | union sockunion su; |
0291c246 | 14363 | json_object *json = NULL; |
71aedaa3 | 14364 | int ret, is_first = 1; |
9f049418 | 14365 | bool nbr_output = false; |
d62a17ae | 14366 | |
14367 | if (use_json) | |
14368 | vty_out(vty, "{\n"); | |
14369 | ||
14370 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 14371 | nbr_output = true; |
d62a17ae | 14372 | if (use_json) { |
14373 | if (!(json = json_object_new_object())) { | |
af4c2728 | 14374 | flog_err( |
e50f7cfd | 14375 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 14376 | "Unable to allocate memory for JSON object"); |
14377 | vty_out(vty, | |
14378 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
14379 | return; | |
14380 | } | |
14381 | ||
14382 | json_object_int_add(json, "vrfId", | |
14383 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
14384 | ? -1 |
14385 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 14386 | json_object_string_add( |
14387 | json, "vrfName", | |
14388 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14389 | ? VRF_DEFAULT_NAME |
d62a17ae | 14390 | : bgp->name); |
14391 | ||
14392 | if (!is_first) | |
14393 | vty_out(vty, ",\n"); | |
14394 | else | |
14395 | is_first = 0; | |
14396 | ||
14397 | vty_out(vty, "\"%s\":", | |
14398 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14399 | ? VRF_DEFAULT_NAME |
d62a17ae | 14400 | : bgp->name); |
14401 | } else { | |
14402 | vty_out(vty, "\nInstance %s:\n", | |
14403 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14404 | ? VRF_DEFAULT_NAME |
d62a17ae | 14405 | : bgp->name); |
14406 | } | |
71aedaa3 | 14407 | |
d1927ebe AS |
14408 | if (type == show_peer || type == show_ipv4_peer || |
14409 | type == show_ipv6_peer) { | |
71aedaa3 DS |
14410 | ret = str2sockunion(ip_str, &su); |
14411 | if (ret < 0) | |
14412 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14413 | use_json, json); | |
14414 | else | |
14415 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14416 | use_json, json); | |
14417 | } else { | |
d1927ebe | 14418 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
14419 | use_json, json); |
14420 | } | |
b77004d6 | 14421 | json_object_free(json); |
121067e9 | 14422 | json = NULL; |
d62a17ae | 14423 | } |
14424 | ||
3e78a6ce | 14425 | if (use_json) |
d62a17ae | 14426 | vty_out(vty, "}\n"); |
9f049418 DS |
14427 | else if (!nbr_output) |
14428 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14429 | } |
14430 | ||
14431 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
14432 | enum show_type type, const char *ip_str, | |
9f049418 | 14433 | bool use_json) |
d62a17ae | 14434 | { |
14435 | int ret; | |
14436 | struct bgp *bgp; | |
14437 | union sockunion su; | |
14438 | json_object *json = NULL; | |
14439 | ||
14440 | if (name) { | |
14441 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
14442 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
14443 | use_json); | |
d62a17ae | 14444 | return CMD_SUCCESS; |
14445 | } else { | |
14446 | bgp = bgp_lookup_by_name(name); | |
14447 | if (!bgp) { | |
14448 | if (use_json) { | |
14449 | json = json_object_new_object(); | |
75eeda93 | 14450 | vty_json(vty, json); |
d62a17ae | 14451 | } else |
14452 | vty_out(vty, | |
9f049418 | 14453 | "%% BGP instance not found\n"); |
d62a17ae | 14454 | |
14455 | return CMD_WARNING; | |
14456 | } | |
14457 | } | |
14458 | } else { | |
14459 | bgp = bgp_get_default(); | |
14460 | } | |
14461 | ||
14462 | if (bgp) { | |
14463 | json = json_object_new_object(); | |
14464 | if (ip_str) { | |
14465 | ret = str2sockunion(ip_str, &su); | |
14466 | if (ret < 0) | |
14467 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
14468 | use_json, json); | |
14469 | else | |
14470 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
14471 | use_json, json); | |
14472 | } else { | |
14473 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
14474 | json); | |
14475 | } | |
14476 | json_object_free(json); | |
ca61fd25 DS |
14477 | } else { |
14478 | if (use_json) | |
14479 | vty_out(vty, "{}\n"); | |
14480 | else | |
14481 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 14482 | } |
14483 | ||
14484 | return CMD_SUCCESS; | |
4fb25c53 DW |
14485 | } |
14486 | ||
2986cac2 | 14487 | |
14488 | ||
14489 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
14490 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
14491 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
14492 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
14493 | SHOW_STR | |
14494 | BGP_STR | |
14495 | IP_STR | |
14496 | IPV6_STR | |
14497 | NEIGHBOR_STR | |
14498 | "Neighbor to display information about\n" | |
14499 | "Neighbor to display information about\n" | |
14500 | "Neighbor on BGP configured interface\n" | |
14501 | GR_SHOW | |
14502 | JSON_STR) | |
14503 | { | |
14504 | char *sh_arg = NULL; | |
14505 | enum show_type sh_type; | |
14506 | int idx = 0; | |
14507 | afi_t afi = AFI_MAX; | |
2986cac2 | 14508 | bool uj = use_json(argc, argv); |
14509 | ||
36235319 | 14510 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 14511 | afi = AFI_MAX; |
14512 | ||
14513 | idx++; | |
14514 | ||
14515 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
14516 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14517 | || argv_find(argv, argc, "WORD", &idx)) { | |
14518 | sh_type = show_peer; | |
14519 | sh_arg = argv[idx]->arg; | |
14520 | } else | |
14521 | sh_type = show_all; | |
14522 | ||
14523 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
14524 | return CMD_SUCCESS; | |
14525 | ||
14526 | ||
36235319 QY |
14527 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
14528 | afi, uj); | |
2986cac2 | 14529 | } |
14530 | ||
716b2d8a | 14531 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 14532 | DEFUN (show_ip_bgp_neighbors, |
14533 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 14534 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 14535 | SHOW_STR |
14536 | IP_STR | |
14537 | BGP_STR | |
f2a8972b | 14538 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
14539 | "Address Family\n" |
14540 | "Address Family\n" | |
718e3744 | 14541 | "Detailed information on TCP and BGP neighbor connections\n" |
14542 | "Neighbor to display information about\n" | |
a80beece | 14543 | "Neighbor to display information about\n" |
91d37724 | 14544 | "Neighbor on BGP configured interface\n" |
9973d184 | 14545 | JSON_STR) |
718e3744 | 14546 | { |
d62a17ae | 14547 | char *vrf = NULL; |
14548 | char *sh_arg = NULL; | |
14549 | enum show_type sh_type; | |
d1927ebe | 14550 | afi_t afi = AFI_MAX; |
718e3744 | 14551 | |
9f049418 | 14552 | bool uj = use_json(argc, argv); |
718e3744 | 14553 | |
d62a17ae | 14554 | int idx = 0; |
718e3744 | 14555 | |
9a8bdf1c PG |
14556 | /* [<vrf> VIEWVRFNAME] */ |
14557 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14558 | vrf = argv[idx + 1]->arg; | |
14559 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14560 | vrf = NULL; | |
14561 | } else if (argv_find(argv, argc, "view", &idx)) | |
14562 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 14563 | vrf = argv[idx + 1]->arg; |
718e3744 | 14564 | |
d62a17ae | 14565 | idx++; |
d1927ebe AS |
14566 | |
14567 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
14568 | sh_type = show_ipv4_all; | |
14569 | afi = AFI_IP; | |
14570 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
14571 | sh_type = show_ipv6_all; | |
14572 | afi = AFI_IP6; | |
14573 | } else { | |
14574 | sh_type = show_all; | |
14575 | } | |
14576 | ||
d62a17ae | 14577 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
14578 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
14579 | || argv_find(argv, argc, "WORD", &idx)) { | |
14580 | sh_type = show_peer; | |
14581 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
14582 | } |
14583 | ||
14584 | if (sh_type == show_peer && afi == AFI_IP) { | |
14585 | sh_type = show_ipv4_peer; | |
14586 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
14587 | sh_type = show_ipv6_peer; | |
14588 | } | |
856ca177 | 14589 | |
d62a17ae | 14590 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 14591 | } |
14592 | ||
716b2d8a | 14593 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 14594 | paths' and `show ip mbgp paths'. Those functions results are the |
14595 | same.*/ | |
f412b39a | 14596 | DEFUN (show_ip_bgp_paths, |
718e3744 | 14597 | show_ip_bgp_paths_cmd, |
46f296b4 | 14598 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 14599 | SHOW_STR |
14600 | IP_STR | |
14601 | BGP_STR | |
46f296b4 | 14602 | BGP_SAFI_HELP_STR |
718e3744 | 14603 | "Path information\n") |
14604 | { | |
d62a17ae | 14605 | vty_out(vty, "Address Refcnt Path\n"); |
14606 | aspath_print_all_vty(vty); | |
14607 | return CMD_SUCCESS; | |
718e3744 | 14608 | } |
14609 | ||
718e3744 | 14610 | #include "hash.h" |
14611 | ||
e3b78da8 | 14612 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14613 | struct vty *vty) |
718e3744 | 14614 | { |
d62a17ae | 14615 | struct community *com; |
718e3744 | 14616 | |
e3b78da8 | 14617 | com = (struct community *)bucket->data; |
3f65c5b1 | 14618 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
c0945b78 | 14619 | community_str(com, false, false)); |
718e3744 | 14620 | } |
14621 | ||
14622 | /* Show BGP's community internal data. */ | |
f412b39a | 14623 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 14624 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 14625 | "show [ip] bgp community-info", |
718e3744 | 14626 | SHOW_STR |
14627 | IP_STR | |
14628 | BGP_STR | |
14629 | "List all bgp community information\n") | |
14630 | { | |
d62a17ae | 14631 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 14632 | |
d62a17ae | 14633 | hash_iterate(community_hash(), |
e3b78da8 | 14634 | (void (*)(struct hash_bucket *, |
d62a17ae | 14635 | void *))community_show_all_iterator, |
14636 | vty); | |
718e3744 | 14637 | |
d62a17ae | 14638 | return CMD_SUCCESS; |
718e3744 | 14639 | } |
14640 | ||
e3b78da8 | 14641 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 14642 | struct vty *vty) |
57d187bc | 14643 | { |
d62a17ae | 14644 | struct lcommunity *lcom; |
57d187bc | 14645 | |
e3b78da8 | 14646 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 14647 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
c0945b78 | 14648 | lcommunity_str(lcom, false, false)); |
57d187bc JS |
14649 | } |
14650 | ||
14651 | /* Show BGP's community internal data. */ | |
14652 | DEFUN (show_ip_bgp_lcommunity_info, | |
14653 | show_ip_bgp_lcommunity_info_cmd, | |
14654 | "show ip bgp large-community-info", | |
14655 | SHOW_STR | |
14656 | IP_STR | |
14657 | BGP_STR | |
14658 | "List all bgp large-community information\n") | |
14659 | { | |
d62a17ae | 14660 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 14661 | |
d62a17ae | 14662 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 14663 | (void (*)(struct hash_bucket *, |
d62a17ae | 14664 | void *))lcommunity_show_all_iterator, |
14665 | vty); | |
57d187bc | 14666 | |
d62a17ae | 14667 | return CMD_SUCCESS; |
57d187bc | 14668 | } |
2986cac2 | 14669 | /* Graceful Restart */ |
14670 | ||
14671 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
14672 | struct bgp *bgp, |
14673 | bool use_json, | |
14674 | json_object *json) | |
2986cac2 | 14675 | { |
57d187bc JS |
14676 | |
14677 | ||
2986cac2 | 14678 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
14679 | ||
7318ae88 | 14680 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 14681 | |
14682 | switch (bgp_global_gr_mode) { | |
14683 | ||
14684 | case GLOBAL_HELPER: | |
13909c4f | 14685 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 14686 | break; |
14687 | ||
14688 | case GLOBAL_GR: | |
13909c4f | 14689 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 14690 | break; |
14691 | ||
14692 | case GLOBAL_DISABLE: | |
13909c4f | 14693 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 14694 | break; |
14695 | ||
14696 | case GLOBAL_INVALID: | |
2986cac2 | 14697 | vty_out(vty, |
2ba1fe69 | 14698 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 14699 | break; |
14700 | } | |
14701 | vty_out(vty, "\n"); | |
14702 | } | |
14703 | ||
36235319 QY |
14704 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
14705 | enum show_type type, | |
14706 | const char *ip_str, | |
14707 | afi_t afi, bool use_json) | |
2986cac2 | 14708 | { |
14709 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
14710 | afi = AFI_IP; | |
14711 | ||
14712 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
14713 | ||
36235319 QY |
14714 | bgp_show_neighbor_graceful_restart_vty( |
14715 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 14716 | afi++; |
14717 | } | |
14718 | } else if (afi != AFI_MAX) { | |
36235319 QY |
14719 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
14720 | use_json); | |
2986cac2 | 14721 | } else { |
14722 | return CMD_ERR_INCOMPLETE; | |
14723 | } | |
14724 | ||
14725 | return CMD_SUCCESS; | |
14726 | } | |
14727 | /* Graceful Restart */ | |
14728 | ||
f412b39a | 14729 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 14730 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 14731 | "show [ip] bgp attribute-info", |
718e3744 | 14732 | SHOW_STR |
14733 | IP_STR | |
14734 | BGP_STR | |
14735 | "List all bgp attribute information\n") | |
14736 | { | |
d62a17ae | 14737 | attr_show_all(vty); |
14738 | return CMD_SUCCESS; | |
718e3744 | 14739 | } |
6b0655a2 | 14740 | |
03915806 CS |
14741 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
14742 | afi_t afi, safi_t safi, | |
14743 | bool use_json, json_object *json) | |
53089bec | 14744 | { |
14745 | struct bgp *bgp; | |
14746 | struct listnode *node; | |
14747 | char *vname; | |
14748 | char buf1[INET6_ADDRSTRLEN]; | |
14749 | char *ecom_str; | |
9c2fd3fe | 14750 | enum vpn_policy_direction dir; |
53089bec | 14751 | |
03915806 | 14752 | if (json) { |
b46dfd20 DS |
14753 | json_object *json_import_vrfs = NULL; |
14754 | json_object *json_export_vrfs = NULL; | |
14755 | ||
b46dfd20 DS |
14756 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14757 | ||
53089bec | 14758 | if (!bgp) { |
75eeda93 | 14759 | vty_json(vty, json); |
b46dfd20 | 14760 | |
53089bec | 14761 | return CMD_WARNING; |
14762 | } | |
b46dfd20 | 14763 | |
94d4c685 DS |
14764 | /* Provide context for the block */ |
14765 | json_object_string_add(json, "vrf", name ? name : "default"); | |
14766 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 14767 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 14768 | |
b46dfd20 DS |
14769 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14770 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
14771 | json_object_string_add(json, "importFromVrfs", "none"); | |
14772 | json_object_string_add(json, "importRts", "none"); | |
14773 | } else { | |
6ce24e52 DS |
14774 | json_import_vrfs = json_object_new_array(); |
14775 | ||
b46dfd20 DS |
14776 | for (ALL_LIST_ELEMENTS_RO( |
14777 | bgp->vpn_policy[afi].import_vrf, | |
14778 | node, vname)) | |
14779 | json_object_array_add(json_import_vrfs, | |
14780 | json_object_new_string(vname)); | |
14781 | ||
b20875ea CS |
14782 | json_object_object_add(json, "importFromVrfs", |
14783 | json_import_vrfs); | |
b46dfd20 | 14784 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
14785 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14786 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14787 | bgp->vpn_policy[afi].rtlist[dir], |
14788 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14789 | json_object_string_add(json, "importRts", |
14790 | ecom_str); | |
14791 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14792 | } else | |
14793 | json_object_string_add(json, "importRts", | |
14794 | "none"); | |
b46dfd20 DS |
14795 | } |
14796 | ||
14797 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
14798 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
14799 | json_object_string_add(json, "exportToVrfs", "none"); | |
14800 | json_object_string_add(json, "routeDistinguisher", | |
14801 | "none"); | |
14802 | json_object_string_add(json, "exportRts", "none"); | |
14803 | } else { | |
6ce24e52 DS |
14804 | json_export_vrfs = json_object_new_array(); |
14805 | ||
b46dfd20 DS |
14806 | for (ALL_LIST_ELEMENTS_RO( |
14807 | bgp->vpn_policy[afi].export_vrf, | |
14808 | node, vname)) | |
14809 | json_object_array_add(json_export_vrfs, | |
14810 | json_object_new_string(vname)); | |
14811 | json_object_object_add(json, "exportToVrfs", | |
14812 | json_export_vrfs); | |
14813 | json_object_string_add(json, "routeDistinguisher", | |
14814 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14815 | buf1, RD_ADDRSTRLEN)); | |
14816 | ||
14817 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14818 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14819 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14820 | bgp->vpn_policy[afi].rtlist[dir], |
14821 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14822 | json_object_string_add(json, "exportRts", |
14823 | ecom_str); | |
14824 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14825 | } else | |
14826 | json_object_string_add(json, "exportRts", | |
14827 | "none"); | |
b46dfd20 DS |
14828 | } |
14829 | ||
03915806 | 14830 | if (use_json) { |
75eeda93 | 14831 | vty_json(vty, json); |
03915806 | 14832 | } |
53089bec | 14833 | } else { |
b46dfd20 DS |
14834 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
14835 | ||
53089bec | 14836 | if (!bgp) { |
b46dfd20 | 14837 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 14838 | return CMD_WARNING; |
14839 | } | |
53089bec | 14840 | |
b46dfd20 DS |
14841 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14842 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
14843 | vty_out(vty, | |
14844 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 14845 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14846 | else { |
14847 | vty_out(vty, | |
14848 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 14849 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14850 | |
14851 | for (ALL_LIST_ELEMENTS_RO( | |
14852 | bgp->vpn_policy[afi].import_vrf, | |
14853 | node, vname)) | |
14854 | vty_out(vty, " %s\n", vname); | |
14855 | ||
14856 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
14857 | ecom_str = NULL; |
14858 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
14859 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14860 | bgp->vpn_policy[afi].rtlist[dir], |
14861 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 14862 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 14863 | |
b20875ea CS |
14864 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
14865 | } else | |
14866 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14867 | } |
53089bec | 14868 | |
b46dfd20 DS |
14869 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
14870 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14871 | vty_out(vty, | |
14872 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 14873 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14874 | else { |
14875 | vty_out(vty, | |
04c9077f | 14876 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 14877 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
14878 | |
14879 | for (ALL_LIST_ELEMENTS_RO( | |
14880 | bgp->vpn_policy[afi].export_vrf, | |
14881 | node, vname)) | |
14882 | vty_out(vty, " %s\n", vname); | |
14883 | ||
14884 | vty_out(vty, "RD: %s\n", | |
14885 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
14886 | buf1, RD_ADDRSTRLEN)); | |
14887 | ||
14888 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
14889 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
14890 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
14891 | bgp->vpn_policy[afi].rtlist[dir], |
14892 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
14893 | vty_out(vty, "Export RT: %s\n", ecom_str); |
14894 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
14895 | } else | |
14896 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 14897 | } |
53089bec | 14898 | } |
14899 | ||
14900 | return CMD_SUCCESS; | |
14901 | } | |
14902 | ||
03915806 CS |
14903 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
14904 | safi_t safi, bool use_json) | |
14905 | { | |
14906 | struct listnode *node, *nnode; | |
14907 | struct bgp *bgp; | |
14908 | char *vrf_name = NULL; | |
14909 | json_object *json = NULL; | |
14910 | json_object *json_vrf = NULL; | |
14911 | json_object *json_vrfs = NULL; | |
14912 | ||
14913 | if (use_json) { | |
14914 | json = json_object_new_object(); | |
14915 | json_vrfs = json_object_new_object(); | |
14916 | } | |
14917 | ||
14918 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
14919 | ||
14920 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
14921 | vrf_name = bgp->name; | |
14922 | ||
14923 | if (use_json) { | |
14924 | json_vrf = json_object_new_object(); | |
14925 | } else { | |
14926 | vty_out(vty, "\nInstance %s:\n", | |
14927 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14928 | ? VRF_DEFAULT_NAME : bgp->name); | |
14929 | } | |
14930 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
14931 | if (use_json) { | |
14932 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
14933 | json_object_object_add(json_vrfs, | |
14934 | VRF_DEFAULT_NAME, json_vrf); | |
14935 | else | |
14936 | json_object_object_add(json_vrfs, vrf_name, | |
14937 | json_vrf); | |
14938 | } | |
14939 | } | |
14940 | ||
14941 | if (use_json) { | |
14942 | json_object_object_add(json, "vrfs", json_vrfs); | |
75eeda93 | 14943 | vty_json(vty, json); |
03915806 CS |
14944 | } |
14945 | ||
14946 | return CMD_SUCCESS; | |
14947 | } | |
14948 | ||
53089bec | 14949 | /* "show [ip] bgp route-leak" command. */ |
14950 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
14951 | show_ip_bgp_route_leak_cmd, |
14952 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
14953 | SHOW_STR |
14954 | IP_STR | |
14955 | BGP_STR | |
14956 | BGP_INSTANCE_HELP_STR | |
14957 | BGP_AFI_HELP_STR | |
14958 | BGP_SAFI_HELP_STR | |
14959 | "Route leaking information\n" | |
14960 | JSON_STR) | |
53089bec | 14961 | { |
14962 | char *vrf = NULL; | |
14963 | afi_t afi = AFI_MAX; | |
14964 | safi_t safi = SAFI_MAX; | |
14965 | ||
9f049418 | 14966 | bool uj = use_json(argc, argv); |
53089bec | 14967 | int idx = 0; |
03915806 | 14968 | json_object *json = NULL; |
53089bec | 14969 | |
14970 | /* show [ip] bgp */ | |
14971 | if (argv_find(argv, argc, "ip", &idx)) { | |
14972 | afi = AFI_IP; | |
14973 | safi = SAFI_UNICAST; | |
14974 | } | |
14975 | /* [vrf VIEWVRFNAME] */ | |
14976 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14977 | vty_out(vty, |
14978 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14979 | return CMD_WARNING; |
14980 | } | |
14981 | ||
9a8bdf1c PG |
14982 | if (argv_find(argv, argc, "vrf", &idx)) { |
14983 | vrf = argv[idx + 1]->arg; | |
14984 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14985 | vrf = NULL; | |
14986 | } | |
53089bec | 14987 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
c48349e3 | 14988 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
53089bec | 14989 | argv_find_and_parse_safi(argv, argc, &idx, &safi); |
53089bec | 14990 | |
14991 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14992 | vty_out(vty, |
14993 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14994 | return CMD_WARNING; |
14995 | } | |
14996 | ||
03915806 CS |
14997 | if (vrf && strmatch(vrf, "all")) |
14998 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14999 | ||
15000 | if (uj) | |
15001 | json = json_object_new_object(); | |
15002 | ||
15003 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 15004 | } |
15005 | ||
d62a17ae | 15006 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
15007 | safi_t safi) | |
f186de26 | 15008 | { |
d62a17ae | 15009 | struct listnode *node, *nnode; |
15010 | struct bgp *bgp; | |
f186de26 | 15011 | |
d62a17ae | 15012 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
15013 | vty_out(vty, "\nInstance %s:\n", | |
15014 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 15015 | ? VRF_DEFAULT_NAME |
d62a17ae | 15016 | : bgp->name); |
15017 | update_group_show(bgp, afi, safi, vty, 0); | |
15018 | } | |
f186de26 | 15019 | } |
15020 | ||
d62a17ae | 15021 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
15022 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 15023 | { |
d62a17ae | 15024 | struct bgp *bgp; |
4fb25c53 | 15025 | |
d62a17ae | 15026 | if (name) { |
15027 | if (strmatch(name, "all")) { | |
15028 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
15029 | return CMD_SUCCESS; | |
15030 | } else { | |
15031 | bgp = bgp_lookup_by_name(name); | |
15032 | } | |
15033 | } else { | |
15034 | bgp = bgp_get_default(); | |
15035 | } | |
4fb25c53 | 15036 | |
d62a17ae | 15037 | if (bgp) |
15038 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
15039 | return CMD_SUCCESS; | |
4fb25c53 DW |
15040 | } |
15041 | ||
8fe8a7f6 DS |
15042 | DEFUN (show_ip_bgp_updgrps, |
15043 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 15044 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 15045 | SHOW_STR |
15046 | IP_STR | |
15047 | BGP_STR | |
15048 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 15049 | BGP_AFI_HELP_STR |
9bedbb1e | 15050 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
15051 | "Detailed info about dynamic update groups\n" |
15052 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 15053 | { |
d62a17ae | 15054 | char *vrf = NULL; |
15055 | afi_t afi = AFI_IP6; | |
15056 | safi_t safi = SAFI_UNICAST; | |
15057 | uint64_t subgrp_id = 0; | |
15058 | ||
15059 | int idx = 0; | |
15060 | ||
15061 | /* show [ip] bgp */ | |
15062 | if (argv_find(argv, argc, "ip", &idx)) | |
15063 | afi = AFI_IP; | |
9a8bdf1c PG |
15064 | /* [<vrf> VIEWVRFNAME] */ |
15065 | if (argv_find(argv, argc, "vrf", &idx)) { | |
15066 | vrf = argv[idx + 1]->arg; | |
15067 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
15068 | vrf = NULL; | |
15069 | } else if (argv_find(argv, argc, "view", &idx)) | |
15070 | /* [<view> VIEWVRFNAME] */ | |
15071 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 15072 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
15073 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
15074 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
15075 | } | |
5bf15956 | 15076 | |
d62a17ae | 15077 | /* get subgroup id, if provided */ |
15078 | idx = argc - 1; | |
15079 | if (argv[idx]->type == VARIABLE_TKN) | |
15080 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 15081 | |
d62a17ae | 15082 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
15083 | } |
15084 | ||
f186de26 | 15085 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
15086 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 15087 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 15088 | SHOW_STR |
716b2d8a | 15089 | IP_STR |
f186de26 | 15090 | BGP_STR |
15091 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 15092 | "Detailed info about dynamic update groups\n") |
f186de26 | 15093 | { |
d62a17ae | 15094 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
15095 | return CMD_SUCCESS; | |
f186de26 | 15096 | } |
15097 | ||
43d3f4fc DS |
15098 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
15099 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
15100 | "show [ip] bgp l2vpn evpn update-groups", | |
15101 | SHOW_STR | |
15102 | IP_STR | |
15103 | BGP_STR | |
15104 | "l2vpn address family\n" | |
15105 | "evpn sub-address family\n" | |
15106 | "Detailed info about dynamic update groups\n") | |
15107 | { | |
15108 | char *vrf = NULL; | |
15109 | uint64_t subgrp_id = 0; | |
15110 | ||
15111 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
15112 | return CMD_SUCCESS; | |
15113 | } | |
15114 | ||
5bf15956 DW |
15115 | DEFUN (show_bgp_updgrps_stats, |
15116 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 15117 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 15118 | SHOW_STR |
716b2d8a | 15119 | IP_STR |
3f9c7369 | 15120 | BGP_STR |
0c7b1b01 | 15121 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
15122 | "Statistics\n") |
15123 | { | |
d62a17ae | 15124 | struct bgp *bgp; |
3f9c7369 | 15125 | |
d62a17ae | 15126 | bgp = bgp_get_default(); |
15127 | if (bgp) | |
15128 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 15129 | |
d62a17ae | 15130 | return CMD_SUCCESS; |
3f9c7369 DS |
15131 | } |
15132 | ||
8386ac43 | 15133 | DEFUN (show_bgp_instance_updgrps_stats, |
15134 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 15135 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 15136 | SHOW_STR |
716b2d8a | 15137 | IP_STR |
8386ac43 | 15138 | BGP_STR |
15139 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 15140 | "Detailed info about dynamic update groups\n" |
8386ac43 | 15141 | "Statistics\n") |
15142 | { | |
d62a17ae | 15143 | int idx_word = 3; |
15144 | struct bgp *bgp; | |
8386ac43 | 15145 | |
d62a17ae | 15146 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
15147 | if (bgp) | |
15148 | update_group_show_stats(bgp, vty); | |
8386ac43 | 15149 | |
d62a17ae | 15150 | return CMD_SUCCESS; |
8386ac43 | 15151 | } |
15152 | ||
d62a17ae | 15153 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
15154 | afi_t afi, safi_t safi, | |
15155 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 15156 | { |
d62a17ae | 15157 | struct bgp *bgp; |
8386ac43 | 15158 | |
d62a17ae | 15159 | if (name) |
15160 | bgp = bgp_lookup_by_name(name); | |
15161 | else | |
15162 | bgp = bgp_get_default(); | |
8386ac43 | 15163 | |
d62a17ae | 15164 | if (bgp) { |
15165 | if (!strcmp(what, "advertise-queue")) | |
15166 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
15167 | subgrp_id); | |
15168 | else if (!strcmp(what, "advertised-routes")) | |
15169 | update_group_show_advertised(bgp, afi, safi, vty, | |
15170 | subgrp_id); | |
15171 | else if (!strcmp(what, "packet-queue")) | |
15172 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
15173 | subgrp_id); | |
15174 | } | |
3f9c7369 DS |
15175 | } |
15176 | ||
dc64bdec QY |
15177 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
15178 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
15179 | "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", | |
15180 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
15181 | BGP_SAFI_HELP_STR | |
15182 | "Detailed info about dynamic update groups\n" | |
15183 | "Specific subgroup to display info for\n" | |
15184 | "Advertisement queue\n" | |
15185 | "Announced routes\n" | |
15186 | "Packet queue\n") | |
3f9c7369 | 15187 | { |
dc64bdec QY |
15188 | uint64_t subgrp_id = 0; |
15189 | afi_t afiz; | |
15190 | safi_t safiz; | |
15191 | if (sgid) | |
15192 | subgrp_id = strtoull(sgid, NULL, 10); | |
15193 | ||
15194 | if (!ip && !afi) | |
15195 | afiz = AFI_IP6; | |
15196 | if (!ip && afi) | |
15197 | afiz = bgp_vty_afi_from_str(afi); | |
15198 | if (ip && !afi) | |
15199 | afiz = AFI_IP; | |
15200 | if (ip && afi) { | |
15201 | afiz = bgp_vty_afi_from_str(afi); | |
15202 | if (afiz != AFI_IP) | |
15203 | vty_out(vty, | |
15204 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
15205 | return CMD_WARNING; | |
15206 | } | |
d62a17ae | 15207 | |
dc64bdec | 15208 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 15209 | |
dc64bdec | 15210 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 15211 | return CMD_SUCCESS; |
15212 | } | |
15213 | ||
6f4eacf3 DA |
15214 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group, |
15215 | json_object *json) | |
d62a17ae | 15216 | { |
15217 | struct listnode *node, *nnode; | |
15218 | struct prefix *range; | |
15219 | struct peer *conf; | |
15220 | struct peer *peer; | |
d62a17ae | 15221 | afi_t afi; |
15222 | safi_t safi; | |
15223 | const char *peer_status; | |
d62a17ae | 15224 | int lr_count; |
15225 | int dynamic; | |
6f4eacf3 DA |
15226 | bool af_cfgd; |
15227 | json_object *json_peer_group = NULL; | |
15228 | json_object *json_peer_group_afc = NULL; | |
15229 | json_object *json_peer_group_members = NULL; | |
15230 | json_object *json_peer_group_dynamic = NULL; | |
15231 | json_object *json_peer_group_dynamic_af = NULL; | |
15232 | json_object *json_peer_group_ranges = NULL; | |
d62a17ae | 15233 | |
15234 | conf = group->conf; | |
15235 | ||
6f4eacf3 DA |
15236 | if (json) { |
15237 | json_peer_group = json_object_new_object(); | |
15238 | json_peer_group_afc = json_object_new_array(); | |
15239 | } | |
15240 | ||
d62a17ae | 15241 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { |
6f4eacf3 DA |
15242 | if (json) |
15243 | json_object_int_add(json_peer_group, "remoteAs", | |
15244 | conf->as); | |
15245 | else | |
15246 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15247 | group->name, conf->as); | |
d62a17ae | 15248 | } else if (conf->as_type == AS_INTERNAL) { |
6f4eacf3 DA |
15249 | if (json) |
15250 | json_object_int_add(json_peer_group, "remoteAs", | |
15251 | group->bgp->as); | |
15252 | else | |
15253 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", | |
15254 | group->name, group->bgp->as); | |
d62a17ae | 15255 | } else { |
6f4eacf3 DA |
15256 | if (!json) |
15257 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
d62a17ae | 15258 | } |
f14e6fdb | 15259 | |
6f4eacf3 DA |
15260 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) { |
15261 | if (json) | |
15262 | json_object_string_add(json_peer_group, "type", | |
15263 | "internal"); | |
15264 | else | |
15265 | vty_out(vty, " Peer-group type is internal\n"); | |
15266 | } else { | |
15267 | if (json) | |
15268 | json_object_string_add(json_peer_group, "type", | |
15269 | "external"); | |
15270 | else | |
15271 | vty_out(vty, " Peer-group type is external\n"); | |
15272 | } | |
d62a17ae | 15273 | |
15274 | /* Display AFs configured. */ | |
6f4eacf3 DA |
15275 | if (!json) |
15276 | vty_out(vty, " Configured address-families:"); | |
15277 | ||
05c7a1cc QY |
15278 | FOREACH_AFI_SAFI (afi, safi) { |
15279 | if (conf->afc[afi][safi]) { | |
6f4eacf3 DA |
15280 | af_cfgd = true; |
15281 | if (json) | |
15282 | json_object_array_add( | |
15283 | json_peer_group_afc, | |
15284 | json_object_new_string(get_afi_safi_str( | |
15285 | afi, safi, false))); | |
15286 | else | |
15287 | vty_out(vty, " %s;", | |
15288 | get_afi_safi_str(afi, safi, false)); | |
d62a17ae | 15289 | } |
05c7a1cc | 15290 | } |
6f4eacf3 DA |
15291 | |
15292 | if (json) { | |
15293 | json_object_object_add(json_peer_group, | |
15294 | "addressFamiliesConfigured", | |
15295 | json_peer_group_afc); | |
15296 | } else { | |
15297 | if (!af_cfgd) | |
15298 | vty_out(vty, " none\n"); | |
15299 | else | |
15300 | vty_out(vty, "\n"); | |
15301 | } | |
d62a17ae | 15302 | |
15303 | /* Display listen ranges (for dynamic neighbors), if any */ | |
15304 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
d62a17ae | 15305 | lr_count = listcount(group->listen_range[afi]); |
15306 | if (lr_count) { | |
6f4eacf3 DA |
15307 | if (json) { |
15308 | if (!json_peer_group_dynamic) | |
15309 | json_peer_group_dynamic = | |
15310 | json_object_new_object(); | |
15311 | ||
15312 | json_peer_group_dynamic_af = | |
15313 | json_object_new_object(); | |
15314 | json_peer_group_ranges = | |
15315 | json_object_new_array(); | |
15316 | json_object_int_add(json_peer_group_dynamic_af, | |
15317 | "count", lr_count); | |
15318 | } else { | |
15319 | vty_out(vty, " %d %s listen range(s)\n", | |
15320 | lr_count, afi2str(afi)); | |
15321 | } | |
d62a17ae | 15322 | |
15323 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
6f4eacf3 DA |
15324 | nnode, range)) { |
15325 | if (json) { | |
15326 | char buf[BUFSIZ]; | |
15327 | ||
15328 | snprintfrr(buf, sizeof(buf), "%pFX", | |
15329 | range); | |
15330 | ||
15331 | json_object_array_add( | |
15332 | json_peer_group_ranges, | |
15333 | json_object_new_string(buf)); | |
15334 | } else { | |
15335 | vty_out(vty, " %pFX\n", range); | |
15336 | } | |
15337 | } | |
15338 | ||
15339 | if (json) { | |
15340 | json_object_object_add( | |
15341 | json_peer_group_dynamic_af, "ranges", | |
15342 | json_peer_group_ranges); | |
15343 | ||
15344 | json_object_object_add( | |
15345 | json_peer_group_dynamic, afi2str(afi), | |
15346 | json_peer_group_dynamic_af); | |
15347 | } | |
d62a17ae | 15348 | } |
15349 | } | |
f14e6fdb | 15350 | |
6f4eacf3 DA |
15351 | if (json_peer_group_dynamic) |
15352 | json_object_object_add(json_peer_group, "dynamicRanges", | |
15353 | json_peer_group_dynamic); | |
15354 | ||
d62a17ae | 15355 | /* Display group members and their status */ |
15356 | if (listcount(group->peer)) { | |
6f4eacf3 DA |
15357 | if (json) |
15358 | json_peer_group_members = json_object_new_object(); | |
15359 | else | |
15360 | vty_out(vty, " Peer-group members:\n"); | |
d62a17ae | 15361 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { |
cb9196e7 DS |
15362 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
15363 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 15364 | peer_status = "Idle (Admin)"; |
15365 | else if (CHECK_FLAG(peer->sflags, | |
15366 | PEER_STATUS_PREFIX_OVERFLOW)) | |
15367 | peer_status = "Idle (PfxCt)"; | |
15368 | else | |
15369 | peer_status = lookup_msg(bgp_status_msg, | |
15370 | peer->status, NULL); | |
15371 | ||
15372 | dynamic = peer_dynamic_neighbor(peer); | |
6f4eacf3 DA |
15373 | |
15374 | if (json) { | |
15375 | json_object *json_peer_group_member = | |
15376 | json_object_new_object(); | |
15377 | ||
15378 | json_object_string_add(json_peer_group_member, | |
15379 | "status", peer_status); | |
15380 | ||
15381 | if (dynamic) | |
15382 | json_object_boolean_true_add( | |
15383 | json_peer_group_member, | |
15384 | "dynamic"); | |
15385 | ||
15386 | json_object_object_add(json_peer_group_members, | |
15387 | peer->host, | |
15388 | json_peer_group_member); | |
15389 | } else { | |
15390 | vty_out(vty, " %s %s %s \n", peer->host, | |
15391 | dynamic ? "(dynamic)" : "", | |
15392 | peer_status); | |
15393 | } | |
d62a17ae | 15394 | } |
6f4eacf3 DA |
15395 | if (json) |
15396 | json_object_object_add(json_peer_group, "members", | |
15397 | json_peer_group_members); | |
d62a17ae | 15398 | } |
f14e6fdb | 15399 | |
6f4eacf3 DA |
15400 | if (json) |
15401 | json_object_object_add(json, group->name, json_peer_group); | |
15402 | ||
d62a17ae | 15403 | return CMD_SUCCESS; |
15404 | } | |
15405 | ||
ff9959b0 | 15406 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
6f4eacf3 | 15407 | const char *group_name, bool uj) |
d62a17ae | 15408 | { |
ff9959b0 | 15409 | struct bgp *bgp; |
d62a17ae | 15410 | struct listnode *node, *nnode; |
15411 | struct peer_group *group; | |
ff9959b0 | 15412 | bool found = false; |
6f4eacf3 DA |
15413 | json_object *json = NULL; |
15414 | ||
15415 | if (uj) | |
15416 | json = json_object_new_object(); | |
ff9959b0 QY |
15417 | |
15418 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
15419 | ||
15420 | if (!bgp) { | |
c48349e3 | 15421 | if (uj) |
75eeda93 | 15422 | vty_json(vty, json); |
c48349e3 | 15423 | else |
6f4eacf3 | 15424 | vty_out(vty, "%% BGP instance not found\n"); |
6f4eacf3 | 15425 | |
ff9959b0 QY |
15426 | return CMD_WARNING; |
15427 | } | |
d62a17ae | 15428 | |
15429 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
15430 | if (group_name) { |
15431 | if (strmatch(group->name, group_name)) { | |
6f4eacf3 | 15432 | bgp_show_one_peer_group(vty, group, json); |
ff9959b0 QY |
15433 | found = true; |
15434 | break; | |
d62a17ae | 15435 | } |
ff9959b0 | 15436 | } else { |
6f4eacf3 | 15437 | bgp_show_one_peer_group(vty, group, json); |
d62a17ae | 15438 | } |
f14e6fdb | 15439 | } |
f14e6fdb | 15440 | |
6f4eacf3 | 15441 | if (group_name && !found && !uj) |
d62a17ae | 15442 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 15443 | |
c48349e3 | 15444 | if (uj) |
75eeda93 | 15445 | vty_json(vty, json); |
6f4eacf3 | 15446 | |
d62a17ae | 15447 | return CMD_SUCCESS; |
f14e6fdb DS |
15448 | } |
15449 | ||
6f4eacf3 DA |
15450 | DEFUN(show_ip_bgp_peer_groups, show_ip_bgp_peer_groups_cmd, |
15451 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]", | |
15452 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR | |
15453 | "Detailed information on BGP peer groups\n" | |
15454 | "Peer group name\n" JSON_STR) | |
f14e6fdb | 15455 | { |
d62a17ae | 15456 | char *vrf, *pg; |
d62a17ae | 15457 | int idx = 0; |
6f4eacf3 | 15458 | bool uj = use_json(argc, argv); |
f14e6fdb | 15459 | |
a4d82a8a PZ |
15460 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
15461 | : NULL; | |
d62a17ae | 15462 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 15463 | |
6f4eacf3 | 15464 | return bgp_show_peer_group_vty(vty, vrf, pg, uj); |
f14e6fdb | 15465 | } |
3f9c7369 | 15466 | |
d6e3c605 | 15467 | |
718e3744 | 15468 | /* Redistribute VTY commands. */ |
15469 | ||
585f1adc IR |
15470 | DEFUN (bgp_redistribute_ipv4, |
15471 | bgp_redistribute_ipv4_cmd, | |
15472 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15473 | "Redistribute information from another routing protocol\n" | |
15474 | FRR_IP_REDIST_HELP_STR_BGPD) | |
718e3744 | 15475 | { |
585f1adc | 15476 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15477 | int idx_protocol = 1; |
585f1adc | 15478 | int type; |
37a87b8f | 15479 | |
585f1adc IR |
15480 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15481 | if (type < 0) { | |
15482 | vty_out(vty, "%% Invalid route type\n"); | |
15483 | return CMD_WARNING_CONFIG_FAILED; | |
15484 | } | |
7f323236 | 15485 | |
585f1adc IR |
15486 | bgp_redist_add(bgp, AFI_IP, type, 0); |
15487 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); | |
718e3744 | 15488 | } |
15489 | ||
d62a17ae | 15490 | ALIAS_HIDDEN( |
15491 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
15492 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
15493 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 15494 | |
585f1adc IR |
15495 | DEFUN (bgp_redistribute_ipv4_rmap, |
15496 | bgp_redistribute_ipv4_rmap_cmd, | |
70dd370f | 15497 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
15498 | "Redistribute information from another routing protocol\n" |
15499 | FRR_IP_REDIST_HELP_STR_BGPD | |
15500 | "Route map reference\n" | |
15501 | "Pointer to route-map entries\n") | |
718e3744 | 15502 | { |
585f1adc | 15503 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15504 | int idx_protocol = 1; |
15505 | int idx_word = 3; | |
585f1adc IR |
15506 | int type; |
15507 | struct bgp_redist *red; | |
15508 | bool changed; | |
15509 | struct route_map *route_map = route_map_lookup_warn_noexist( | |
15510 | vty, argv[idx_word]->arg); | |
15511 | ||
15512 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15513 | if (type < 0) { | |
15514 | vty_out(vty, "%% Invalid route type\n"); | |
15515 | return CMD_WARNING_CONFIG_FAILED; | |
15516 | } | |
37a87b8f | 15517 | |
585f1adc IR |
15518 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15519 | changed = | |
15520 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15521 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
718e3744 | 15522 | } |
15523 | ||
d62a17ae | 15524 | ALIAS_HIDDEN( |
15525 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
70dd370f | 15526 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME", |
d62a17ae | 15527 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
15528 | "Route map reference\n" | |
15529 | "Pointer to route-map entries\n") | |
596c17ba | 15530 | |
585f1adc IR |
15531 | DEFUN (bgp_redistribute_ipv4_metric, |
15532 | bgp_redistribute_ipv4_metric_cmd, | |
15533 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15534 | "Redistribute information from another routing protocol\n" | |
15535 | FRR_IP_REDIST_HELP_STR_BGPD | |
15536 | "Metric for redistributed routes\n" | |
15537 | "Default metric\n") | |
718e3744 | 15538 | { |
585f1adc | 15539 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15540 | int idx_protocol = 1; |
15541 | int idx_number = 3; | |
585f1adc IR |
15542 | int type; |
15543 | uint32_t metric; | |
15544 | struct bgp_redist *red; | |
15545 | bool changed; | |
15546 | ||
15547 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15548 | if (type < 0) { | |
15549 | vty_out(vty, "%% Invalid route type\n"); | |
15550 | return CMD_WARNING_CONFIG_FAILED; | |
15551 | } | |
15552 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 15553 | |
585f1adc IR |
15554 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15555 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15556 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15557 | } |
15558 | ||
15559 | ALIAS_HIDDEN( | |
15560 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
15561 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
15562 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15563 | "Metric for redistributed routes\n" | |
15564 | "Default metric\n") | |
596c17ba | 15565 | |
585f1adc IR |
15566 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
15567 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
70dd370f | 15568 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
15569 | "Redistribute information from another routing protocol\n" |
15570 | FRR_IP_REDIST_HELP_STR_BGPD | |
15571 | "Route map reference\n" | |
15572 | "Pointer to route-map entries\n" | |
15573 | "Metric for redistributed routes\n" | |
15574 | "Default metric\n") | |
718e3744 | 15575 | { |
585f1adc | 15576 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15577 | int idx_protocol = 1; |
15578 | int idx_word = 3; | |
15579 | int idx_number = 5; | |
585f1adc IR |
15580 | int type; |
15581 | uint32_t metric; | |
15582 | struct bgp_redist *red; | |
15583 | bool changed; | |
15584 | struct route_map *route_map = | |
15585 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15586 | ||
15587 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15588 | if (type < 0) { | |
15589 | vty_out(vty, "%% Invalid route type\n"); | |
15590 | return CMD_WARNING_CONFIG_FAILED; | |
15591 | } | |
15592 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15593 | |
585f1adc IR |
15594 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15595 | changed = | |
15596 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15597 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15598 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15599 | } |
15600 | ||
15601 | ALIAS_HIDDEN( | |
15602 | bgp_redistribute_ipv4_rmap_metric, | |
15603 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
15604 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 15605 | " route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 15606 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
15607 | "Route map reference\n" | |
15608 | "Pointer to route-map entries\n" | |
15609 | "Metric for redistributed routes\n" | |
15610 | "Default metric\n") | |
596c17ba | 15611 | |
585f1adc IR |
15612 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
15613 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
70dd370f | 15614 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
15615 | "Redistribute information from another routing protocol\n" |
15616 | FRR_IP_REDIST_HELP_STR_BGPD | |
15617 | "Metric for redistributed routes\n" | |
15618 | "Default metric\n" | |
15619 | "Route map reference\n" | |
15620 | "Pointer to route-map entries\n") | |
718e3744 | 15621 | { |
585f1adc | 15622 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15623 | int idx_protocol = 1; |
37a87b8f | 15624 | int idx_number = 3; |
585f1adc IR |
15625 | int idx_word = 5; |
15626 | int type; | |
15627 | uint32_t metric; | |
15628 | struct bgp_redist *red; | |
15629 | bool changed; | |
15630 | struct route_map *route_map = | |
15631 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15632 | ||
15633 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
15634 | if (type < 0) { | |
15635 | vty_out(vty, "%% Invalid route type\n"); | |
15636 | return CMD_WARNING_CONFIG_FAILED; | |
15637 | } | |
15638 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
d62a17ae | 15639 | |
585f1adc IR |
15640 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
15641 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
15642 | changed |= | |
15643 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15644 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 15645 | } |
15646 | ||
15647 | ALIAS_HIDDEN( | |
15648 | bgp_redistribute_ipv4_metric_rmap, | |
15649 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
15650 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 15651 | " metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 15652 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD |
15653 | "Metric for redistributed routes\n" | |
15654 | "Default metric\n" | |
15655 | "Route map reference\n" | |
15656 | "Pointer to route-map entries\n") | |
596c17ba | 15657 | |
585f1adc IR |
15658 | DEFUN (bgp_redistribute_ipv4_ospf, |
15659 | bgp_redistribute_ipv4_ospf_cmd, | |
15660 | "redistribute <ospf|table> (1-65535)", | |
15661 | "Redistribute information from another routing protocol\n" | |
15662 | "Open Shortest Path First (OSPFv2)\n" | |
15663 | "Non-main Kernel Routing Table\n" | |
15664 | "Instance ID/Table ID\n") | |
7c8ff89e | 15665 | { |
585f1adc IR |
15666 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15667 | int idx_ospf_table = 1; | |
d62a17ae | 15668 | int idx_number = 2; |
585f1adc IR |
15669 | unsigned short instance; |
15670 | unsigned short protocol; | |
7c8ff89e | 15671 | |
585f1adc | 15672 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 15673 | |
585f1adc IR |
15674 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15675 | protocol = ZEBRA_ROUTE_OSPF; | |
15676 | else | |
15677 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 15678 | |
585f1adc IR |
15679 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15680 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); | |
7c8ff89e DS |
15681 | } |
15682 | ||
d62a17ae | 15683 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
15684 | "redistribute <ospf|table> (1-65535)", | |
15685 | "Redistribute information from another routing protocol\n" | |
15686 | "Open Shortest Path First (OSPFv2)\n" | |
15687 | "Non-main Kernel Routing Table\n" | |
15688 | "Instance ID/Table ID\n") | |
596c17ba | 15689 | |
585f1adc IR |
15690 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
15691 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
70dd370f | 15692 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
585f1adc IR |
15693 | "Redistribute information from another routing protocol\n" |
15694 | "Open Shortest Path First (OSPFv2)\n" | |
15695 | "Non-main Kernel Routing Table\n" | |
15696 | "Instance ID/Table ID\n" | |
15697 | "Route map reference\n" | |
15698 | "Pointer to route-map entries\n") | |
7c8ff89e | 15699 | { |
585f1adc IR |
15700 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15701 | int idx_ospf_table = 1; | |
d62a17ae | 15702 | int idx_number = 2; |
15703 | int idx_word = 4; | |
585f1adc IR |
15704 | struct bgp_redist *red; |
15705 | unsigned short instance; | |
15706 | int protocol; | |
15707 | bool changed; | |
15708 | struct route_map *route_map = | |
15709 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15710 | ||
15711 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15712 | protocol = ZEBRA_ROUTE_OSPF; | |
15713 | else | |
15714 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15715 | |
585f1adc IR |
15716 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15717 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
15718 | changed = | |
15719 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15720 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15721 | } |
15722 | ||
15723 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
15724 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
70dd370f | 15725 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME", |
d62a17ae | 15726 | "Redistribute information from another routing protocol\n" |
15727 | "Open Shortest Path First (OSPFv2)\n" | |
15728 | "Non-main Kernel Routing Table\n" | |
15729 | "Instance ID/Table ID\n" | |
15730 | "Route map reference\n" | |
15731 | "Pointer to route-map entries\n") | |
596c17ba | 15732 | |
585f1adc IR |
15733 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
15734 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
15735 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15736 | "Redistribute information from another routing protocol\n" | |
15737 | "Open Shortest Path First (OSPFv2)\n" | |
15738 | "Non-main Kernel Routing Table\n" | |
15739 | "Instance ID/Table ID\n" | |
15740 | "Metric for redistributed routes\n" | |
15741 | "Default metric\n") | |
7c8ff89e | 15742 | { |
585f1adc IR |
15743 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15744 | int idx_ospf_table = 1; | |
d62a17ae | 15745 | int idx_number = 2; |
15746 | int idx_number_2 = 4; | |
585f1adc IR |
15747 | uint32_t metric; |
15748 | struct bgp_redist *red; | |
15749 | unsigned short instance; | |
15750 | int protocol; | |
15751 | bool changed; | |
15752 | ||
15753 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15754 | protocol = ZEBRA_ROUTE_OSPF; | |
15755 | else | |
15756 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15757 | |
585f1adc IR |
15758 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15759 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15760 | |
585f1adc IR |
15761 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15762 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15763 | metric); | |
15764 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15765 | } |
15766 | ||
15767 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
15768 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
15769 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
15770 | "Redistribute information from another routing protocol\n" | |
15771 | "Open Shortest Path First (OSPFv2)\n" | |
15772 | "Non-main Kernel Routing Table\n" | |
15773 | "Instance ID/Table ID\n" | |
15774 | "Metric for redistributed routes\n" | |
15775 | "Default metric\n") | |
596c17ba | 15776 | |
585f1adc IR |
15777 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
15778 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
70dd370f | 15779 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
15780 | "Redistribute information from another routing protocol\n" |
15781 | "Open Shortest Path First (OSPFv2)\n" | |
15782 | "Non-main Kernel Routing Table\n" | |
15783 | "Instance ID/Table ID\n" | |
15784 | "Route map reference\n" | |
15785 | "Pointer to route-map entries\n" | |
15786 | "Metric for redistributed routes\n" | |
15787 | "Default metric\n") | |
7c8ff89e | 15788 | { |
585f1adc IR |
15789 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15790 | int idx_ospf_table = 1; | |
d62a17ae | 15791 | int idx_number = 2; |
15792 | int idx_word = 4; | |
15793 | int idx_number_2 = 6; | |
585f1adc IR |
15794 | uint32_t metric; |
15795 | struct bgp_redist *red; | |
15796 | unsigned short instance; | |
15797 | int protocol; | |
15798 | bool changed; | |
15799 | struct route_map *route_map = | |
15800 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15801 | ||
15802 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15803 | protocol = ZEBRA_ROUTE_OSPF; | |
15804 | else | |
15805 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15806 | |
585f1adc IR |
15807 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15808 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15809 | |
585f1adc IR |
15810 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15811 | changed = | |
15812 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15813 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15814 | metric); | |
15815 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15816 | } |
15817 | ||
15818 | ALIAS_HIDDEN( | |
15819 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
15820 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
70dd370f | 15821 | "redistribute <ospf|table> (1-65535) route-map RMAP_NAME metric (0-4294967295)", |
d62a17ae | 15822 | "Redistribute information from another routing protocol\n" |
15823 | "Open Shortest Path First (OSPFv2)\n" | |
15824 | "Non-main Kernel Routing Table\n" | |
15825 | "Instance ID/Table ID\n" | |
15826 | "Route map reference\n" | |
15827 | "Pointer to route-map entries\n" | |
15828 | "Metric for redistributed routes\n" | |
15829 | "Default metric\n") | |
596c17ba | 15830 | |
585f1adc IR |
15831 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
15832 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
70dd370f | 15833 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
15834 | "Redistribute information from another routing protocol\n" |
15835 | "Open Shortest Path First (OSPFv2)\n" | |
15836 | "Non-main Kernel Routing Table\n" | |
15837 | "Instance ID/Table ID\n" | |
15838 | "Metric for redistributed routes\n" | |
15839 | "Default metric\n" | |
15840 | "Route map reference\n" | |
15841 | "Pointer to route-map entries\n") | |
7c8ff89e | 15842 | { |
585f1adc IR |
15843 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15844 | int idx_ospf_table = 1; | |
d62a17ae | 15845 | int idx_number = 2; |
15846 | int idx_number_2 = 4; | |
15847 | int idx_word = 6; | |
585f1adc IR |
15848 | uint32_t metric; |
15849 | struct bgp_redist *red; | |
15850 | unsigned short instance; | |
15851 | int protocol; | |
15852 | bool changed; | |
15853 | struct route_map *route_map = | |
15854 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15855 | ||
15856 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
15857 | protocol = ZEBRA_ROUTE_OSPF; | |
15858 | else | |
15859 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15860 | |
585f1adc IR |
15861 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15862 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
d62a17ae | 15863 | |
585f1adc IR |
15864 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
15865 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, | |
15866 | metric); | |
15867 | changed |= | |
15868 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
15869 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 15870 | } |
15871 | ||
15872 | ALIAS_HIDDEN( | |
15873 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
15874 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
70dd370f | 15875 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map RMAP_NAME", |
d62a17ae | 15876 | "Redistribute information from another routing protocol\n" |
15877 | "Open Shortest Path First (OSPFv2)\n" | |
15878 | "Non-main Kernel Routing Table\n" | |
15879 | "Instance ID/Table ID\n" | |
15880 | "Metric for redistributed routes\n" | |
15881 | "Default metric\n" | |
15882 | "Route map reference\n" | |
15883 | "Pointer to route-map entries\n") | |
596c17ba | 15884 | |
585f1adc IR |
15885 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
15886 | no_bgp_redistribute_ipv4_ospf_cmd, | |
70dd370f | 15887 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
15888 | NO_STR |
15889 | "Redistribute information from another routing protocol\n" | |
15890 | "Open Shortest Path First (OSPFv2)\n" | |
15891 | "Non-main Kernel Routing Table\n" | |
15892 | "Instance ID/Table ID\n" | |
15893 | "Metric for redistributed routes\n" | |
15894 | "Default metric\n" | |
15895 | "Route map reference\n" | |
15896 | "Pointer to route-map entries\n") | |
7c8ff89e | 15897 | { |
585f1adc IR |
15898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15899 | int idx_ospf_table = 2; | |
d62a17ae | 15900 | int idx_number = 3; |
585f1adc IR |
15901 | unsigned short instance; |
15902 | int protocol; | |
37a87b8f | 15903 | |
585f1adc IR |
15904 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
15905 | protocol = ZEBRA_ROUTE_OSPF; | |
15906 | else | |
15907 | protocol = ZEBRA_ROUTE_TABLE; | |
d62a17ae | 15908 | |
585f1adc IR |
15909 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
15910 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
d62a17ae | 15911 | } |
15912 | ||
15913 | ALIAS_HIDDEN( | |
15914 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
70dd370f | 15915 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 15916 | NO_STR |
15917 | "Redistribute information from another routing protocol\n" | |
15918 | "Open Shortest Path First (OSPFv2)\n" | |
15919 | "Non-main Kernel Routing Table\n" | |
15920 | "Instance ID/Table ID\n" | |
15921 | "Metric for redistributed routes\n" | |
15922 | "Default metric\n" | |
15923 | "Route map reference\n" | |
15924 | "Pointer to route-map entries\n") | |
596c17ba | 15925 | |
585f1adc IR |
15926 | DEFUN (no_bgp_redistribute_ipv4, |
15927 | no_bgp_redistribute_ipv4_cmd, | |
70dd370f | 15928 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
15929 | NO_STR |
15930 | "Redistribute information from another routing protocol\n" | |
15931 | FRR_IP_REDIST_HELP_STR_BGPD | |
15932 | "Metric for redistributed routes\n" | |
15933 | "Default metric\n" | |
15934 | "Route map reference\n" | |
15935 | "Pointer to route-map entries\n") | |
718e3744 | 15936 | { |
585f1adc | 15937 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15938 | int idx_protocol = 2; |
585f1adc | 15939 | int type; |
d62a17ae | 15940 | |
585f1adc IR |
15941 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
15942 | if (type < 0) { | |
15943 | vty_out(vty, "%% Invalid route type\n"); | |
15944 | return CMD_WARNING_CONFIG_FAILED; | |
15945 | } | |
15946 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
d62a17ae | 15947 | } |
15948 | ||
15949 | ALIAS_HIDDEN( | |
15950 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
15951 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
70dd370f | 15952 | " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
d62a17ae | 15953 | NO_STR |
15954 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
15955 | "Metric for redistributed routes\n" | |
15956 | "Default metric\n" | |
15957 | "Route map reference\n" | |
15958 | "Pointer to route-map entries\n") | |
596c17ba | 15959 | |
585f1adc IR |
15960 | DEFUN (bgp_redistribute_ipv6, |
15961 | bgp_redistribute_ipv6_cmd, | |
15962 | "redistribute " FRR_IP6_REDIST_STR_BGPD, | |
15963 | "Redistribute information from another routing protocol\n" | |
15964 | FRR_IP6_REDIST_HELP_STR_BGPD) | |
718e3744 | 15965 | { |
585f1adc | 15966 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15967 | int idx_protocol = 1; |
585f1adc | 15968 | int type; |
718e3744 | 15969 | |
585f1adc IR |
15970 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15971 | if (type < 0) { | |
15972 | vty_out(vty, "%% Invalid route type\n"); | |
15973 | return CMD_WARNING_CONFIG_FAILED; | |
15974 | } | |
718e3744 | 15975 | |
585f1adc IR |
15976 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
15977 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); | |
718e3744 | 15978 | } |
15979 | ||
585f1adc IR |
15980 | DEFUN (bgp_redistribute_ipv6_rmap, |
15981 | bgp_redistribute_ipv6_rmap_cmd, | |
70dd370f | 15982 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME", |
585f1adc IR |
15983 | "Redistribute information from another routing protocol\n" |
15984 | FRR_IP6_REDIST_HELP_STR_BGPD | |
15985 | "Route map reference\n" | |
15986 | "Pointer to route-map entries\n") | |
718e3744 | 15987 | { |
585f1adc | 15988 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 15989 | int idx_protocol = 1; |
15990 | int idx_word = 3; | |
585f1adc IR |
15991 | int type; |
15992 | struct bgp_redist *red; | |
15993 | bool changed; | |
15994 | struct route_map *route_map = | |
15995 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
15996 | ||
15997 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15998 | if (type < 0) { | |
15999 | vty_out(vty, "%% Invalid route type\n"); | |
16000 | return CMD_WARNING_CONFIG_FAILED; | |
16001 | } | |
37a87b8f | 16002 | |
585f1adc IR |
16003 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16004 | changed = | |
16005 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16006 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16007 | } |
16008 | ||
585f1adc | 16009 | DEFUN (bgp_redistribute_ipv6_metric, |
718e3744 | 16010 | bgp_redistribute_ipv6_metric_cmd, |
40d1cbfb | 16011 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 16012 | "Redistribute information from another routing protocol\n" |
ab0181ee | 16013 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 16014 | "Metric for redistributed routes\n" |
16015 | "Default metric\n") | |
16016 | { | |
585f1adc | 16017 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16018 | int idx_protocol = 1; |
16019 | int idx_number = 3; | |
585f1adc IR |
16020 | int type; |
16021 | uint32_t metric; | |
16022 | struct bgp_redist *red; | |
16023 | bool changed; | |
16024 | ||
16025 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16026 | if (type < 0) { | |
16027 | vty_out(vty, "%% Invalid route type\n"); | |
16028 | return CMD_WARNING_CONFIG_FAILED; | |
16029 | } | |
16030 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16031 | |
585f1adc IR |
16032 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16033 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
16034 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16035 | } |
16036 | ||
585f1adc IR |
16037 | DEFUN (bgp_redistribute_ipv6_rmap_metric, |
16038 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
70dd370f | 16039 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map RMAP_NAME metric (0-4294967295)", |
585f1adc IR |
16040 | "Redistribute information from another routing protocol\n" |
16041 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16042 | "Route map reference\n" | |
16043 | "Pointer to route-map entries\n" | |
16044 | "Metric for redistributed routes\n" | |
16045 | "Default metric\n") | |
718e3744 | 16046 | { |
585f1adc | 16047 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16048 | int idx_protocol = 1; |
16049 | int idx_word = 3; | |
16050 | int idx_number = 5; | |
585f1adc IR |
16051 | int type; |
16052 | uint32_t metric; | |
16053 | struct bgp_redist *red; | |
16054 | bool changed; | |
16055 | struct route_map *route_map = | |
16056 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16057 | ||
16058 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16059 | if (type < 0) { | |
16060 | vty_out(vty, "%% Invalid route type\n"); | |
16061 | return CMD_WARNING_CONFIG_FAILED; | |
16062 | } | |
16063 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16064 | |
585f1adc IR |
16065 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16066 | changed = | |
16067 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16068 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, | |
16069 | metric); | |
16070 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16071 | } |
16072 | ||
585f1adc IR |
16073 | DEFUN (bgp_redistribute_ipv6_metric_rmap, |
16074 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
70dd370f | 16075 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map RMAP_NAME", |
585f1adc IR |
16076 | "Redistribute information from another routing protocol\n" |
16077 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16078 | "Metric for redistributed routes\n" | |
16079 | "Default metric\n" | |
16080 | "Route map reference\n" | |
16081 | "Pointer to route-map entries\n") | |
718e3744 | 16082 | { |
585f1adc | 16083 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16084 | int idx_protocol = 1; |
37a87b8f | 16085 | int idx_number = 3; |
585f1adc IR |
16086 | int idx_word = 5; |
16087 | int type; | |
16088 | uint32_t metric; | |
16089 | struct bgp_redist *red; | |
16090 | bool changed; | |
16091 | struct route_map *route_map = | |
16092 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
16093 | ||
16094 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
16095 | if (type < 0) { | |
16096 | vty_out(vty, "%% Invalid route type\n"); | |
16097 | return CMD_WARNING_CONFIG_FAILED; | |
16098 | } | |
16099 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
37a87b8f | 16100 | |
585f1adc IR |
16101 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
16102 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, | |
16103 | metric); | |
16104 | changed |= | |
16105 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
16106 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 16107 | } |
16108 | ||
585f1adc IR |
16109 | DEFUN (no_bgp_redistribute_ipv6, |
16110 | no_bgp_redistribute_ipv6_cmd, | |
70dd370f | 16111 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map RMAP_NAME}]", |
585f1adc IR |
16112 | NO_STR |
16113 | "Redistribute information from another routing protocol\n" | |
16114 | FRR_IP6_REDIST_HELP_STR_BGPD | |
16115 | "Metric for redistributed routes\n" | |
16116 | "Default metric\n" | |
16117 | "Route map reference\n" | |
16118 | "Pointer to route-map entries\n") | |
718e3744 | 16119 | { |
585f1adc | 16120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 16121 | int idx_protocol = 2; |
585f1adc | 16122 | int type; |
37a87b8f | 16123 | |
585f1adc IR |
16124 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
16125 | if (type < 0) { | |
16126 | vty_out(vty, "%% Invalid route type\n"); | |
16127 | return CMD_WARNING_CONFIG_FAILED; | |
16128 | } | |
718e3744 | 16129 | |
585f1adc | 16130 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
d62a17ae | 16131 | } |
16132 | ||
4ab46701 AR |
16133 | /* Neighbor update tcp-mss. */ |
16134 | static int peer_tcp_mss_vty(struct vty *vty, const char *peer_str, | |
16135 | const char *tcp_mss_str) | |
16136 | { | |
16137 | struct peer *peer; | |
16138 | uint32_t tcp_mss_val = 0; | |
16139 | ||
16140 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
16141 | if (!peer) | |
16142 | return CMD_WARNING_CONFIG_FAILED; | |
16143 | ||
16144 | if (tcp_mss_str) { | |
16145 | tcp_mss_val = strtoul(tcp_mss_str, NULL, 10); | |
16146 | peer_tcp_mss_set(peer, tcp_mss_val); | |
16147 | } else { | |
16148 | peer_tcp_mss_unset(peer); | |
16149 | } | |
16150 | ||
16151 | return CMD_SUCCESS; | |
16152 | } | |
16153 | ||
16154 | DEFUN(neighbor_tcp_mss, neighbor_tcp_mss_cmd, | |
16155 | "neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss (1-65535)", | |
16156 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16157 | "TCP max segment size\n" | |
16158 | "TCP MSS value\n") | |
16159 | { | |
16160 | int peer_index = 1; | |
16161 | int mss_index = 3; | |
16162 | ||
16163 | vty_out(vty, | |
16164 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16165 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, | |
16166 | argv[mss_index]->arg); | |
16167 | } | |
16168 | ||
16169 | DEFUN(no_neighbor_tcp_mss, no_neighbor_tcp_mss_cmd, | |
16170 | "no neighbor <A.B.C.D|X:X::X:X|WORD> tcp-mss [(1-65535)]", | |
16171 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
16172 | "TCP max segment size\n" | |
16173 | "TCP MSS value\n") | |
16174 | { | |
16175 | int peer_index = 2; | |
16176 | ||
16177 | vty_out(vty, | |
16178 | " Warning: Reset BGP session for tcp-mss value to take effect\n"); | |
16179 | return peer_tcp_mss_vty(vty, argv[peer_index]->arg, NULL); | |
16180 | } | |
16181 | ||
dd65f45e DL |
16182 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
16183 | afi_t afi, safi_t safi) | |
d62a17ae | 16184 | { |
16185 | int i; | |
16186 | ||
16187 | /* Unicast redistribution only. */ | |
16188 | if (safi != SAFI_UNICAST) | |
2b791107 | 16189 | return; |
d62a17ae | 16190 | |
16191 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
16192 | /* Redistribute BGP does not make sense. */ | |
16193 | if (i != ZEBRA_ROUTE_BGP) { | |
16194 | struct list *red_list; | |
16195 | struct listnode *node; | |
16196 | struct bgp_redist *red; | |
16197 | ||
16198 | red_list = bgp->redist[afi][i]; | |
16199 | if (!red_list) | |
16200 | continue; | |
16201 | ||
16202 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 16203 | /* "redistribute" configuration. */ |
16204 | vty_out(vty, " redistribute %s", | |
16205 | zebra_route_string(i)); | |
16206 | if (red->instance) | |
16207 | vty_out(vty, " %d", red->instance); | |
16208 | if (red->redist_metric_flag) | |
16209 | vty_out(vty, " metric %u", | |
16210 | red->redist_metric); | |
16211 | if (red->rmap.name) | |
16212 | vty_out(vty, " route-map %s", | |
16213 | red->rmap.name); | |
16214 | vty_out(vty, "\n"); | |
16215 | } | |
16216 | } | |
16217 | } | |
718e3744 | 16218 | } |
6b0655a2 | 16219 | |
dd65f45e DL |
16220 | /* peer-group helpers for config-write */ |
16221 | ||
16222 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
16223 | { | |
16224 | if (!peer_group_active(peer)) { | |
16225 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
16226 | return !CHECK_FLAG(peer->flags, flag); | |
16227 | else | |
16228 | return !!CHECK_FLAG(peer->flags, flag); | |
16229 | } | |
16230 | ||
16231 | return !!CHECK_FLAG(peer->flags_override, flag); | |
16232 | } | |
16233 | ||
16234 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
16235 | uint32_t flag) | |
16236 | { | |
16237 | if (!peer_group_active(peer)) { | |
16238 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
16239 | return !peer_af_flag_check(peer, afi, safi, flag); | |
16240 | else | |
16241 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
16242 | } | |
16243 | ||
16244 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
16245 | } | |
16246 | ||
16247 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
16248 | uint8_t type, int direct) | |
16249 | { | |
16250 | struct bgp_filter *filter; | |
16251 | ||
16252 | if (peer_group_active(peer)) | |
16253 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
16254 | type); | |
16255 | ||
16256 | filter = &peer->filter[afi][safi]; | |
16257 | switch (type) { | |
16258 | case PEER_FT_DISTRIBUTE_LIST: | |
16259 | return !!(filter->dlist[direct].name); | |
16260 | case PEER_FT_FILTER_LIST: | |
16261 | return !!(filter->aslist[direct].name); | |
16262 | case PEER_FT_PREFIX_LIST: | |
16263 | return !!(filter->plist[direct].name); | |
16264 | case PEER_FT_ROUTE_MAP: | |
16265 | return !!(filter->map[direct].name); | |
16266 | case PEER_FT_UNSUPPRESS_MAP: | |
16267 | return !!(filter->usmap.name); | |
7f7940e6 MK |
16268 | case PEER_FT_ADVERTISE_MAP: |
16269 | return !!(filter->advmap.aname | |
16270 | && ((filter->advmap.condition == direct) | |
16271 | && filter->advmap.cname)); | |
dd65f45e DL |
16272 | default: |
16273 | return false; | |
16274 | } | |
16275 | } | |
16276 | ||
16277 | /* Return true if the addpath type is set for peer and different from | |
16278 | * peer-group. | |
16279 | */ | |
3dc339cd DA |
16280 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
16281 | safi_t safi) | |
dd65f45e DL |
16282 | { |
16283 | enum bgp_addpath_strat type, g_type; | |
16284 | ||
16285 | type = peer->addpath_type[afi][safi]; | |
16286 | ||
16287 | if (type != BGP_ADDPATH_NONE) { | |
16288 | if (peer_group_active(peer)) { | |
16289 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
16290 | ||
16291 | if (type != g_type) | |
3dc339cd | 16292 | return true; |
dd65f45e | 16293 | else |
3dc339cd | 16294 | return false; |
dd65f45e DL |
16295 | } |
16296 | ||
3dc339cd | 16297 | return true; |
dd65f45e DL |
16298 | } |
16299 | ||
3dc339cd | 16300 | return false; |
dd65f45e DL |
16301 | } |
16302 | ||
b9c7bc5a | 16303 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 16304 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
16305 | afi_t afi) |
16306 | { | |
b9c7bc5a | 16307 | int indent = 2; |
53970de3 | 16308 | uint32_t tovpn_sid_index = 0; |
ddb5b488 | 16309 | |
8a066a70 | 16310 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
16311 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16312 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
16313 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
16314 | bgp->vpn_policy[afi] | |
bb4f6190 | 16315 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
16316 | else |
16317 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
16318 | bgp->vpn_policy[afi] | |
16319 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
16320 | } | |
12a844a5 DS |
16321 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
16322 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
16323 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
16324 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
16325 | return; | |
16326 | ||
e70e9f8e PZ |
16327 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16328 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
16329 | ||
16330 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
16331 | ||
16332 | } else { | |
16333 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
16334 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
16335 | bgp->vpn_policy[afi].tovpn_label); | |
16336 | } | |
ddb5b488 | 16337 | } |
53970de3 RS |
16338 | |
16339 | tovpn_sid_index = bgp->vpn_policy[afi].tovpn_sid_index; | |
16340 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16341 | BGP_VPN_POLICY_TOVPN_SID_AUTO)) { | |
16342 | vty_out(vty, "%*ssid vpn export %s\n", indent, "", "auto"); | |
16343 | } else if (tovpn_sid_index != 0) { | |
16344 | vty_out(vty, "%*ssid vpn export %d\n", indent, "", | |
16345 | tovpn_sid_index); | |
16346 | } | |
16347 | ||
ddb5b488 PZ |
16348 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
16349 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
16350 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 16351 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
16352 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
16353 | sizeof(buf))); | |
16354 | } | |
16355 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
16356 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
16357 | ||
16358 | char buf[PREFIX_STRLEN]; | |
16359 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
16360 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
16361 | sizeof(buf))) { | |
16362 | ||
b9c7bc5a PZ |
16363 | vty_out(vty, "%*snexthop vpn export %s\n", |
16364 | indent, "", buf); | |
ddb5b488 PZ |
16365 | } |
16366 | } | |
16367 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
16368 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
16369 | && ecommunity_cmp( | |
16370 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16371 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
16372 | ||
16373 | char *b = ecommunity_ecom2str( | |
16374 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16375 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16376 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
16377 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16378 | } else { | |
16379 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
16380 | char *b = ecommunity_ecom2str( | |
16381 | bgp->vpn_policy[afi] | |
16382 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
16383 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16384 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16385 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
16386 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16387 | } | |
16388 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
16389 | char *b = ecommunity_ecom2str( | |
16390 | bgp->vpn_policy[afi] | |
16391 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
16392 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16393 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 16394 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
16395 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16396 | } | |
16397 | } | |
bb4f6190 DS |
16398 | |
16399 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 16400 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
16401 | bgp->vpn_policy[afi] |
16402 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 16403 | |
301ad80a PG |
16404 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
16405 | char *b = ecommunity_ecom2str( | |
16406 | bgp->vpn_policy[afi] | |
16407 | .import_redirect_rtlist, | |
16408 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
16409 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 16410 | |
9a659715 PG |
16411 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
16412 | != ECOMMUNITY_SIZE) | |
c6423c31 | 16413 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
16414 | indent, "", b); |
16415 | else | |
16416 | vty_out(vty, "%*srt redirect import %s\n", | |
16417 | indent, "", b); | |
301ad80a PG |
16418 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
16419 | } | |
ddb5b488 PZ |
16420 | } |
16421 | ||
dd65f45e DL |
16422 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
16423 | afi_t afi, safi_t safi) | |
16424 | { | |
16425 | struct bgp_filter *filter; | |
16426 | char *addr; | |
16427 | ||
16428 | addr = peer->host; | |
16429 | filter = &peer->filter[afi][safi]; | |
16430 | ||
16431 | /* distribute-list. */ | |
16432 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16433 | FILTER_IN)) | |
16434 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
16435 | filter->dlist[FILTER_IN].name); | |
16436 | ||
16437 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
16438 | FILTER_OUT)) | |
16439 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
16440 | filter->dlist[FILTER_OUT].name); | |
16441 | ||
16442 | /* prefix-list. */ | |
16443 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16444 | FILTER_IN)) | |
16445 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
16446 | filter->plist[FILTER_IN].name); | |
16447 | ||
16448 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
16449 | FILTER_OUT)) | |
16450 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
16451 | filter->plist[FILTER_OUT].name); | |
16452 | ||
16453 | /* route-map. */ | |
16454 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
16455 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
16456 | filter->map[RMAP_IN].name); | |
16457 | ||
16458 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
16459 | RMAP_OUT)) | |
16460 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
16461 | filter->map[RMAP_OUT].name); | |
16462 | ||
16463 | /* unsuppress-map */ | |
16464 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
16465 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
16466 | filter->usmap.name); | |
16467 | ||
7f7940e6 MK |
16468 | /* advertise-map : always applied in OUT direction*/ |
16469 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16470 | CONDITION_NON_EXIST)) | |
16471 | vty_out(vty, | |
16472 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
16473 | addr, filter->advmap.aname, filter->advmap.cname); | |
16474 | ||
16475 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
16476 | CONDITION_EXIST)) | |
16477 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
16478 | addr, filter->advmap.aname, filter->advmap.cname); | |
16479 | ||
dd65f45e DL |
16480 | /* filter-list. */ |
16481 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16482 | FILTER_IN)) | |
16483 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
16484 | filter->aslist[FILTER_IN].name); | |
16485 | ||
16486 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
16487 | FILTER_OUT)) | |
16488 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
16489 | filter->aslist[FILTER_OUT].name); | |
16490 | } | |
16491 | ||
16492 | /* BGP peer configuration display function. */ | |
16493 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
16494 | struct peer *peer) | |
16495 | { | |
16496 | struct peer *g_peer = NULL; | |
16497 | char buf[SU_ADDRSTRLEN]; | |
16498 | char *addr; | |
16499 | int if_pg_printed = false; | |
16500 | int if_ras_printed = false; | |
16501 | ||
16502 | /* Skip dynamic neighbors. */ | |
16503 | if (peer_dynamic_neighbor(peer)) | |
16504 | return; | |
16505 | ||
16506 | if (peer->conf_if) | |
16507 | addr = peer->conf_if; | |
16508 | else | |
16509 | addr = peer->host; | |
16510 | ||
16511 | /************************************ | |
16512 | ****** Global to the neighbor ****** | |
16513 | ************************************/ | |
16514 | if (peer->conf_if) { | |
16515 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
16516 | vty_out(vty, " neighbor %s interface v6only", addr); | |
16517 | else | |
16518 | vty_out(vty, " neighbor %s interface", addr); | |
16519 | ||
16520 | if (peer_group_active(peer)) { | |
16521 | vty_out(vty, " peer-group %s", peer->group->name); | |
16522 | if_pg_printed = true; | |
16523 | } else if (peer->as_type == AS_SPECIFIED) { | |
16524 | vty_out(vty, " remote-as %u", peer->as); | |
16525 | if_ras_printed = true; | |
16526 | } else if (peer->as_type == AS_INTERNAL) { | |
16527 | vty_out(vty, " remote-as internal"); | |
16528 | if_ras_printed = true; | |
16529 | } else if (peer->as_type == AS_EXTERNAL) { | |
16530 | vty_out(vty, " remote-as external"); | |
16531 | if_ras_printed = true; | |
16532 | } | |
16533 | ||
16534 | vty_out(vty, "\n"); | |
16535 | } | |
16536 | ||
16537 | /* remote-as and peer-group */ | |
16538 | /* peer is a member of a peer-group */ | |
16539 | if (peer_group_active(peer)) { | |
16540 | g_peer = peer->group->conf; | |
16541 | ||
16542 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
16543 | if (peer->as_type == AS_SPECIFIED) { | |
16544 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16545 | addr, peer->as); | |
16546 | } else if (peer->as_type == AS_INTERNAL) { | |
16547 | vty_out(vty, | |
16548 | " neighbor %s remote-as internal\n", | |
16549 | addr); | |
16550 | } else if (peer->as_type == AS_EXTERNAL) { | |
16551 | vty_out(vty, | |
16552 | " neighbor %s remote-as external\n", | |
16553 | addr); | |
16554 | } | |
16555 | } | |
16556 | ||
16557 | /* For swpX peers we displayed the peer-group | |
16558 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
16559 | if (!if_pg_printed) | |
16560 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
16561 | peer->group->name); | |
16562 | } | |
16563 | ||
16564 | /* peer is NOT a member of a peer-group */ | |
16565 | else { | |
16566 | /* peer is a peer-group, declare the peer-group */ | |
16567 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
16568 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
16569 | } | |
16570 | ||
16571 | if (!if_ras_printed) { | |
16572 | if (peer->as_type == AS_SPECIFIED) { | |
16573 | vty_out(vty, " neighbor %s remote-as %u\n", | |
16574 | addr, peer->as); | |
16575 | } else if (peer->as_type == AS_INTERNAL) { | |
16576 | vty_out(vty, | |
16577 | " neighbor %s remote-as internal\n", | |
16578 | addr); | |
16579 | } else if (peer->as_type == AS_EXTERNAL) { | |
16580 | vty_out(vty, | |
16581 | " neighbor %s remote-as external\n", | |
16582 | addr); | |
16583 | } | |
16584 | } | |
16585 | } | |
16586 | ||
16587 | /* local-as */ | |
16588 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
16589 | vty_out(vty, " neighbor %s local-as %u", addr, | |
16590 | peer->change_local_as); | |
16591 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
16592 | vty_out(vty, " no-prepend"); | |
16593 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
16594 | vty_out(vty, " replace-as"); | |
16595 | vty_out(vty, "\n"); | |
16596 | } | |
16597 | ||
16598 | /* description */ | |
16599 | if (peer->desc) { | |
16600 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
16601 | } | |
16602 | ||
16603 | /* shutdown */ | |
16604 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
16605 | if (peer->tx_shutdown_message) | |
16606 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
16607 | peer->tx_shutdown_message); | |
16608 | else | |
16609 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
16610 | } | |
16611 | ||
8336c896 DA |
16612 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
16613 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
16614 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
16615 | ||
dd65f45e | 16616 | /* bfd */ |
21bfce98 RZ |
16617 | if (peer->bfd_config) |
16618 | bgp_bfd_peer_config_write(vty, peer, addr); | |
dd65f45e DL |
16619 | |
16620 | /* password */ | |
16621 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
16622 | vty_out(vty, " neighbor %s password %s\n", addr, | |
16623 | peer->password); | |
16624 | ||
16625 | /* neighbor solo */ | |
16626 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
16627 | if (!peer_group_active(peer)) { | |
16628 | vty_out(vty, " neighbor %s solo\n", addr); | |
16629 | } | |
16630 | } | |
16631 | ||
16632 | /* BGP port */ | |
16633 | if (peer->port != BGP_PORT_DEFAULT) { | |
16634 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
16635 | } | |
16636 | ||
16637 | /* Local interface name */ | |
16638 | if (peer->ifname) { | |
16639 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
16640 | } | |
16641 | ||
4ab46701 AR |
16642 | /* TCP max segment size */ |
16643 | if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS)) | |
16644 | vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss); | |
16645 | ||
dd65f45e DL |
16646 | /* passive */ |
16647 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
16648 | vty_out(vty, " neighbor %s passive\n", addr); | |
16649 | ||
16650 | /* ebgp-multihop */ | |
16651 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
16652 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
16653 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
16654 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
16655 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
16656 | peer->ttl); | |
16657 | } | |
16658 | } | |
16659 | ||
16660 | /* ttl-security hops */ | |
e2521429 | 16661 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
16662 | if (!peer_group_active(peer) |
16663 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
16664 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
16665 | addr, peer->gtsm_hops); | |
16666 | } | |
16667 | } | |
16668 | ||
16669 | /* disable-connected-check */ | |
16670 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
16671 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
16672 | ||
27aa23a4 DA |
16673 | /* link-bw-encoding-ieee */ |
16674 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_LINK_BW_ENCODING_IEEE)) | |
16675 | vty_out(vty, " neighbor %s disable-link-bw-encoding-ieee\n", | |
16676 | addr); | |
16677 | ||
d08c0c80 DA |
16678 | /* extended-optional-parameters */ |
16679 | if (peergroup_flag_check(peer, PEER_FLAG_EXTENDED_OPT_PARAMS)) | |
16680 | vty_out(vty, " neighbor %s extended-optional-parameters\n", | |
16681 | addr); | |
16682 | ||
dd65f45e DL |
16683 | /* enforce-first-as */ |
16684 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
16685 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
16686 | ||
16687 | /* update-source */ | |
16688 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
16689 | if (peer->update_source) | |
16690 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16691 | sockunion2str(peer->update_source, buf, | |
16692 | SU_ADDRSTRLEN)); | |
16693 | else if (peer->update_if) | |
16694 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
16695 | peer->update_if); | |
16696 | } | |
16697 | ||
16698 | /* advertisement-interval */ | |
16699 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
16700 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
16701 | peer->routeadv); | |
16702 | ||
16703 | /* timers */ | |
16704 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
16705 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
16706 | peer->keepalive, peer->holdtime); | |
16707 | ||
16708 | /* timers connect */ | |
16709 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
16710 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16711 | peer->connect); | |
5d5393b9 DL |
16712 | /* need special-case handling for changed default values due to |
16713 | * config profile / version (because there is no "timers bgp connect" | |
16714 | * command, we need to save this per-peer :/) | |
16715 | */ | |
16716 | else if (!peer_group_active(peer) && !peer->connect && | |
16717 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
16718 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
16719 | peer->bgp->default_connect_retry); | |
dd65f45e | 16720 | |
d43114f3 DS |
16721 | /* timers delayopen */ |
16722 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_DELAYOPEN)) | |
16723 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16724 | peer->delayopen); | |
16725 | /* Save config even though flag is not set if default values have been | |
16726 | * changed | |
16727 | */ | |
16728 | else if (!peer_group_active(peer) && !peer->delayopen | |
16729 | && peer->bgp->default_delayopen != BGP_DEFAULT_DELAYOPEN) | |
16730 | vty_out(vty, " neighbor %s timers delayopen %u\n", addr, | |
16731 | peer->bgp->default_delayopen); | |
16732 | ||
dd65f45e DL |
16733 | /* capability dynamic */ |
16734 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
16735 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
16736 | ||
16737 | /* capability extended-nexthop */ | |
16738 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
8e89adc1 DS |
16739 | if (CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE) && |
16740 | !peer->conf_if) | |
843770f6 DA |
16741 | vty_out(vty, |
16742 | " no neighbor %s capability extended-nexthop\n", | |
16743 | addr); | |
16744 | else if (!peer->conf_if) | |
16745 | vty_out(vty, | |
16746 | " neighbor %s capability extended-nexthop\n", | |
16747 | addr); | |
dd65f45e DL |
16748 | } |
16749 | ||
16750 | /* dont-capability-negotiation */ | |
16751 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
16752 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
16753 | ||
16754 | /* override-capability */ | |
16755 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
16756 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
16757 | ||
16758 | /* strict-capability-match */ | |
16759 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
16760 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
16761 | ||
16762 | /* Sender side AS path loop detection. */ | |
16763 | if (peer->as_path_loop_detection) | |
16764 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
16765 | addr); | |
cfd47646 | 16766 | |
16767 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16768 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 16769 | |
16770 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 16771 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 16772 | vty_out(vty, |
16773 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
16774 | } else if (CHECK_FLAG( |
16775 | peer->peer_gr_new_status_flag, | |
16776 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 16777 | vty_out(vty, |
16778 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
16779 | } else if ( |
16780 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
16781 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
16782 | && !(CHECK_FLAG( | |
16783 | peer->peer_gr_new_status_flag, | |
16784 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
16785 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
16786 | addr); | |
cfd47646 | 16787 | } |
16788 | } | |
dd65f45e DL |
16789 | } |
16790 | ||
16791 | /* BGP peer configuration display function. */ | |
16792 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
16793 | struct peer *peer, afi_t afi, safi_t safi) | |
16794 | { | |
16795 | struct peer *g_peer = NULL; | |
16796 | char *addr; | |
16797 | bool flag_scomm, flag_secomm, flag_slcomm; | |
16798 | ||
16799 | /* Skip dynamic neighbors. */ | |
16800 | if (peer_dynamic_neighbor(peer)) | |
16801 | return; | |
16802 | ||
16803 | if (peer->conf_if) | |
16804 | addr = peer->conf_if; | |
16805 | else | |
16806 | addr = peer->host; | |
16807 | ||
16808 | /************************************ | |
16809 | ****** Per AF to the neighbor ****** | |
16810 | ************************************/ | |
16811 | if (peer_group_active(peer)) { | |
16812 | g_peer = peer->group->conf; | |
16813 | ||
16814 | /* If the peer-group is active but peer is not, print a 'no | |
16815 | * activate' */ | |
16816 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
16817 | vty_out(vty, " no neighbor %s activate\n", addr); | |
16818 | } | |
16819 | ||
16820 | /* If the peer-group is not active but peer is, print an | |
16821 | 'activate' */ | |
16822 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
16823 | vty_out(vty, " neighbor %s activate\n", addr); | |
16824 | } | |
16825 | } else { | |
16826 | if (peer->afc[afi][safi]) { | |
38d11af5 TA |
16827 | if (safi == SAFI_ENCAP) |
16828 | vty_out(vty, " neighbor %s activate\n", addr); | |
16829 | else if (!bgp->default_af[afi][safi]) | |
dd65f45e DL |
16830 | vty_out(vty, " neighbor %s activate\n", addr); |
16831 | } else { | |
38d11af5 TA |
16832 | if (bgp->default_af[afi][safi]) |
16833 | vty_out(vty, " no neighbor %s activate\n", | |
16834 | addr); | |
dd65f45e DL |
16835 | } |
16836 | } | |
16837 | ||
16838 | /* addpath TX knobs */ | |
16839 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
16840 | switch (peer->addpath_type[afi][safi]) { | |
16841 | case BGP_ADDPATH_ALL: | |
16842 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
16843 | addr); | |
16844 | break; | |
16845 | case BGP_ADDPATH_BEST_PER_AS: | |
16846 | vty_out(vty, | |
16847 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
16848 | addr); | |
16849 | break; | |
16850 | case BGP_ADDPATH_MAX: | |
16851 | case BGP_ADDPATH_NONE: | |
16852 | break; | |
16853 | } | |
16854 | } | |
16855 | ||
7c0e4312 DA |
16856 | if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_DISABLE_ADDPATH_RX)) |
16857 | vty_out(vty, " neighbor %s disable-addpath-rx\n", addr); | |
16858 | ||
dd65f45e DL |
16859 | /* ORF capability. */ |
16860 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
16861 | || peergroup_af_flag_check(peer, afi, safi, | |
16862 | PEER_FLAG_ORF_PREFIX_RM)) { | |
16863 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
16864 | ||
16865 | if (peergroup_af_flag_check(peer, afi, safi, | |
16866 | PEER_FLAG_ORF_PREFIX_SM) | |
16867 | && peergroup_af_flag_check(peer, afi, safi, | |
16868 | PEER_FLAG_ORF_PREFIX_RM)) | |
16869 | vty_out(vty, " both"); | |
16870 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16871 | PEER_FLAG_ORF_PREFIX_SM)) | |
16872 | vty_out(vty, " send"); | |
16873 | else | |
16874 | vty_out(vty, " receive"); | |
16875 | vty_out(vty, "\n"); | |
16876 | } | |
16877 | ||
dd65f45e DL |
16878 | /* Route reflector client. */ |
16879 | if (peergroup_af_flag_check(peer, afi, safi, | |
16880 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
16881 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
16882 | } | |
16883 | ||
16884 | /* next-hop-self force */ | |
16885 | if (peergroup_af_flag_check(peer, afi, safi, | |
16886 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
16887 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
16888 | } | |
16889 | ||
16890 | /* next-hop-self */ | |
16891 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
16892 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
16893 | } | |
16894 | ||
16895 | /* remove-private-AS */ | |
16896 | if (peergroup_af_flag_check(peer, afi, safi, | |
16897 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
16898 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
16899 | addr); | |
16900 | } | |
16901 | ||
16902 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16903 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
16904 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
16905 | addr); | |
16906 | } | |
16907 | ||
16908 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16909 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
16910 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
16911 | } | |
16912 | ||
16913 | else if (peergroup_af_flag_check(peer, afi, safi, | |
16914 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
16915 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
16916 | } | |
16917 | ||
16918 | /* as-override */ | |
16919 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
16920 | vty_out(vty, " neighbor %s as-override\n", addr); | |
16921 | } | |
16922 | ||
16923 | /* send-community print. */ | |
16924 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
16925 | PEER_FLAG_SEND_COMMUNITY); | |
16926 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
16927 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
16928 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
16929 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
16930 | ||
16931 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
16932 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
16933 | } else { | |
16934 | if (flag_scomm) | |
16935 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
16936 | if (flag_secomm) | |
16937 | vty_out(vty, | |
16938 | " no neighbor %s send-community extended\n", | |
16939 | addr); | |
16940 | ||
16941 | if (flag_slcomm) | |
16942 | vty_out(vty, " no neighbor %s send-community large\n", | |
16943 | addr); | |
16944 | } | |
16945 | ||
16946 | /* Default information */ | |
16947 | if (peergroup_af_flag_check(peer, afi, safi, | |
16948 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
16949 | vty_out(vty, " neighbor %s default-originate", addr); | |
16950 | ||
16951 | if (peer->default_rmap[afi][safi].name) | |
16952 | vty_out(vty, " route-map %s", | |
16953 | peer->default_rmap[afi][safi].name); | |
16954 | ||
16955 | vty_out(vty, "\n"); | |
16956 | } | |
16957 | ||
16958 | /* Soft reconfiguration inbound. */ | |
16959 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
16960 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
16961 | addr); | |
16962 | } | |
16963 | ||
16964 | /* maximum-prefix. */ | |
16965 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 16966 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
16967 | peer->pmax[afi][safi]); |
16968 | ||
16969 | if (peer->pmax_threshold[afi][safi] | |
16970 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
16971 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
16972 | if (peer_af_flag_check(peer, afi, safi, | |
16973 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
16974 | vty_out(vty, " warning-only"); | |
16975 | if (peer->pmax_restart[afi][safi]) | |
16976 | vty_out(vty, " restart %u", | |
16977 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
16978 | if (peer_af_flag_check(peer, afi, safi, |
16979 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
16980 | vty_out(vty, " force"); | |
dd65f45e DL |
16981 | |
16982 | vty_out(vty, "\n"); | |
16983 | } | |
16984 | ||
fde246e8 DA |
16985 | /* maximum-prefix-out */ |
16986 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 16987 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
16988 | addr, peer->pmax_out[afi][safi]); |
16989 | ||
dd65f45e DL |
16990 | /* Route server client. */ |
16991 | if (peergroup_af_flag_check(peer, afi, safi, | |
16992 | PEER_FLAG_RSERVER_CLIENT)) { | |
16993 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
16994 | } | |
16995 | ||
16996 | /* Nexthop-local unchanged. */ | |
16997 | if (peergroup_af_flag_check(peer, afi, safi, | |
16998 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
16999 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
17000 | } | |
17001 | ||
17002 | /* allowas-in <1-10> */ | |
17003 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
17004 | if (peer_af_flag_check(peer, afi, safi, | |
17005 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
17006 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
17007 | } else if (peer->allowas_in[afi][safi] == 3) { | |
17008 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
17009 | } else { | |
17010 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
17011 | peer->allowas_in[afi][safi]); | |
17012 | } | |
17013 | } | |
17014 | ||
17015 | /* weight */ | |
17016 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
17017 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
17018 | peer->weight[afi][safi]); | |
17019 | ||
17020 | /* Filter. */ | |
17021 | bgp_config_write_filter(vty, peer, afi, safi); | |
17022 | ||
17023 | /* atribute-unchanged. */ | |
17024 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
17025 | || (safi != SAFI_EVPN | |
17026 | && peer_af_flag_check(peer, afi, safi, | |
17027 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
17028 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
17029 | ||
17030 | if (!peer_group_active(peer) | |
17031 | || peergroup_af_flag_check(peer, afi, safi, | |
17032 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17033 | || peergroup_af_flag_check(peer, afi, safi, | |
17034 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17035 | || peergroup_af_flag_check(peer, afi, safi, | |
17036 | PEER_FLAG_MED_UNCHANGED)) { | |
17037 | ||
17038 | vty_out(vty, | |
17039 | " neighbor %s attribute-unchanged%s%s%s\n", | |
17040 | addr, | |
17041 | peer_af_flag_check(peer, afi, safi, | |
17042 | PEER_FLAG_AS_PATH_UNCHANGED) | |
17043 | ? " as-path" | |
17044 | : "", | |
17045 | peer_af_flag_check(peer, afi, safi, | |
17046 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
17047 | ? " next-hop" | |
17048 | : "", | |
17049 | peer_af_flag_check(peer, afi, safi, | |
17050 | PEER_FLAG_MED_UNCHANGED) | |
17051 | ? " med" | |
17052 | : ""); | |
17053 | } | |
17054 | } | |
17055 | } | |
17056 | ||
17057 | /* Address family based peer configuration display. */ | |
17058 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
17059 | safi_t safi) | |
17060 | { | |
17061 | struct peer *peer; | |
17062 | struct peer_group *group; | |
17063 | struct listnode *node, *nnode; | |
17064 | ||
17065 | ||
17066 | vty_frame(vty, " !\n address-family "); | |
17067 | if (afi == AFI_IP) { | |
17068 | if (safi == SAFI_UNICAST) | |
17069 | vty_frame(vty, "ipv4 unicast"); | |
17070 | else if (safi == SAFI_LABELED_UNICAST) | |
17071 | vty_frame(vty, "ipv4 labeled-unicast"); | |
17072 | else if (safi == SAFI_MULTICAST) | |
17073 | vty_frame(vty, "ipv4 multicast"); | |
17074 | else if (safi == SAFI_MPLS_VPN) | |
17075 | vty_frame(vty, "ipv4 vpn"); | |
17076 | else if (safi == SAFI_ENCAP) | |
17077 | vty_frame(vty, "ipv4 encap"); | |
17078 | else if (safi == SAFI_FLOWSPEC) | |
17079 | vty_frame(vty, "ipv4 flowspec"); | |
17080 | } else if (afi == AFI_IP6) { | |
17081 | if (safi == SAFI_UNICAST) | |
17082 | vty_frame(vty, "ipv6 unicast"); | |
17083 | else if (safi == SAFI_LABELED_UNICAST) | |
17084 | vty_frame(vty, "ipv6 labeled-unicast"); | |
17085 | else if (safi == SAFI_MULTICAST) | |
17086 | vty_frame(vty, "ipv6 multicast"); | |
17087 | else if (safi == SAFI_MPLS_VPN) | |
17088 | vty_frame(vty, "ipv6 vpn"); | |
17089 | else if (safi == SAFI_ENCAP) | |
17090 | vty_frame(vty, "ipv6 encap"); | |
17091 | else if (safi == SAFI_FLOWSPEC) | |
17092 | vty_frame(vty, "ipv6 flowspec"); | |
17093 | } else if (afi == AFI_L2VPN) { | |
17094 | if (safi == SAFI_EVPN) | |
17095 | vty_frame(vty, "l2vpn evpn"); | |
17096 | } | |
17097 | vty_frame(vty, "\n"); | |
17098 | ||
17099 | bgp_config_write_distance(vty, bgp, afi, safi); | |
17100 | ||
17101 | bgp_config_write_network(vty, bgp, afi, safi); | |
17102 | ||
17103 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
17104 | ||
8a4e7fe6 DA |
17105 | /* BGP flag dampening. */ |
17106 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6c75f4b3 | 17107 | bgp_config_write_damp(vty, afi, safi); |
8a4e7fe6 | 17108 | |
dd65f45e DL |
17109 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
17110 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
17111 | ||
17112 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dd65f45e DL |
17113 | /* Do not display doppelganger peers */ |
17114 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17115 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
17116 | } | |
17117 | ||
17118 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
17119 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
17120 | ||
17121 | if (safi == SAFI_EVPN) | |
17122 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
17123 | ||
17124 | if (safi == SAFI_FLOWSPEC) | |
17125 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
17126 | ||
17127 | if (safi == SAFI_UNICAST) { | |
17128 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
17129 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17130 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
17131 | ||
17132 | vty_out(vty, " export vpn\n"); | |
17133 | } | |
17134 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17135 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
17136 | ||
17137 | vty_out(vty, " import vpn\n"); | |
17138 | } | |
17139 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
17140 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
17141 | char *name; | |
17142 | ||
17143 | for (ALL_LIST_ELEMENTS_RO( | |
17144 | bgp->vpn_policy[afi].import_vrf, node, | |
17145 | name)) | |
17146 | vty_out(vty, " import vrf %s\n", name); | |
17147 | } | |
17148 | } | |
17149 | ||
17150 | vty_endframe(vty, " exit-address-family\n"); | |
17151 | } | |
17152 | ||
17153 | int bgp_config_write(struct vty *vty) | |
17154 | { | |
17155 | struct bgp *bgp; | |
17156 | struct peer_group *group; | |
17157 | struct peer *peer; | |
17158 | struct listnode *node, *nnode; | |
17159 | struct listnode *mnode, *mnnode; | |
b16bcbba TA |
17160 | afi_t afi; |
17161 | safi_t safi; | |
dd65f45e DL |
17162 | |
17163 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
17164 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
17165 | bm->rmap_update_timer); | |
17166 | ||
d70583f7 D |
17167 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
17168 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
17169 | if (bm->v_update_delay != bm->v_establish_wait) | |
17170 | vty_out(vty, " %d", bm->v_establish_wait); | |
17171 | vty_out(vty, "\n"); | |
17172 | } | |
17173 | ||
9acb67cb DS |
17174 | if (bm->wait_for_fib) |
17175 | vty_out(vty, "bgp suppress-fib-pending\n"); | |
17176 | ||
05bd726c | 17177 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
17178 | vty_out(vty, "bgp graceful-shutdown\n"); | |
17179 | ||
c163f297 DS |
17180 | /* No-RIB (Zebra) option flag configuration */ |
17181 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
17182 | vty_out(vty, "bgp no-rib\n"); | |
17183 | ||
870791a3 IR |
17184 | if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) |
17185 | vty_out(vty, "bgp send-extra-data zebra\n"); | |
e46723a5 | 17186 | |
425bd64b PS |
17187 | /* BGP session DSCP value */ |
17188 | if (bm->tcp_dscp != IPTOS_PREC_INTERNETCONTROL) | |
17189 | vty_out(vty, "bgp session-dscp %u\n", bm->tcp_dscp >> 2); | |
17190 | ||
dd65f45e DL |
17191 | /* BGP configuration. */ |
17192 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
17193 | ||
17194 | /* skip all auto created vrf as they dont have user config */ | |
17195 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
17196 | continue; | |
17197 | ||
17198 | /* Router bgp ASN */ | |
17199 | vty_out(vty, "router bgp %u", bgp->as); | |
17200 | ||
17201 | if (bgp->name) | |
17202 | vty_out(vty, " %s %s", | |
17203 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
17204 | ? "view" : "vrf", bgp->name); | |
17205 | vty_out(vty, "\n"); | |
17206 | ||
17207 | /* BGP fast-external-failover. */ | |
17208 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
17209 | vty_out(vty, " no bgp fast-external-failover\n"); | |
17210 | ||
17211 | /* BGP router ID. */ | |
3a6290bd | 17212 | if (bgp->router_id_static.s_addr != INADDR_ANY) |
23d0a753 DA |
17213 | vty_out(vty, " bgp router-id %pI4\n", |
17214 | &bgp->router_id_static); | |
dd65f45e | 17215 | |
c208c586 S |
17216 | /* Suppress fib pending */ |
17217 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_FIB_PENDING)) | |
17218 | vty_out(vty, " bgp suppress-fib-pending\n"); | |
17219 | ||
dd65f45e | 17220 | /* BGP log-neighbor-changes. */ |
892fedb6 | 17221 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 17222 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 17223 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
17224 | CHECK_FLAG(bgp->flags, |
17225 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
17226 | ? "" |
17227 | : "no "); | |
17228 | ||
17229 | /* BGP configuration. */ | |
892fedb6 | 17230 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
17231 | vty_out(vty, " bgp always-compare-med\n"); |
17232 | ||
17233 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
17234 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
17235 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
17236 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
17237 | CHECK_FLAG(bgp->flags, | |
17238 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
17239 | ? "" | |
17240 | : "no "); | |
dd65f45e DL |
17241 | |
17242 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 17243 | if (bgp->reject_as_sets) |
dd65f45e DL |
17244 | vty_out(vty, " bgp reject-as-sets\n"); |
17245 | ||
2adac256 DA |
17246 | /* Suppress duplicate updates if the route actually not changed |
17247 | */ | |
17248 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) | |
17249 | != SAVE_BGP_SUPPRESS_DUPLICATES) | |
17250 | vty_out(vty, " %sbgp suppress-duplicates\n", | |
17251 | CHECK_FLAG(bgp->flags, | |
17252 | BGP_FLAG_SUPPRESS_DUPLICATES) | |
17253 | ? "" | |
17254 | : "no "); | |
17255 | ||
1ae314be DA |
17256 | /* Send Hard Reset CEASE Notification for 'Administrative Reset' |
17257 | */ | |
17258 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_HARD_ADMIN_RESET) != | |
17259 | SAVE_BGP_HARD_ADMIN_RESET) | |
17260 | vty_out(vty, " %sbgp hard-administrative-reset\n", | |
17261 | CHECK_FLAG(bgp->flags, | |
17262 | BGP_FLAG_HARD_ADMIN_RESET) | |
17263 | ? "" | |
17264 | : "no "); | |
17265 | ||
b16bcbba TA |
17266 | /* BGP default <afi>-<safi> */ |
17267 | FOREACH_AFI_SAFI (afi, safi) { | |
17268 | if (afi == AFI_IP && safi == SAFI_UNICAST) { | |
17269 | if (!bgp->default_af[afi][safi]) | |
17270 | vty_out(vty, " no bgp default %s\n", | |
17271 | get_bgp_default_af_flag(afi, | |
17272 | safi)); | |
17273 | } else if (bgp->default_af[afi][safi]) | |
17274 | vty_out(vty, " bgp default %s\n", | |
17275 | get_bgp_default_af_flag(afi, safi)); | |
17276 | } | |
e84c59af | 17277 | |
dd65f45e DL |
17278 | /* BGP default local-preference. */ |
17279 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
17280 | vty_out(vty, " bgp default local-preference %u\n", | |
17281 | bgp->default_local_pref); | |
17282 | ||
17283 | /* BGP default show-hostname */ | |
892fedb6 | 17284 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 17285 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 17286 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 17287 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
17288 | ? "" |
17289 | : "no "); | |
17290 | ||
aef999a2 DA |
17291 | /* BGP default show-nexthop-hostname */ |
17292 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17293 | != SAVE_BGP_SHOW_HOSTNAME) | |
17294 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
17295 | CHECK_FLAG(bgp->flags, | |
17296 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
17297 | ? "" | |
17298 | : "no "); | |
17299 | ||
dd65f45e DL |
17300 | /* BGP default subgroup-pkt-queue-max. */ |
17301 | if (bgp->default_subgroup_pkt_queue_max | |
17302 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
17303 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
17304 | bgp->default_subgroup_pkt_queue_max); | |
17305 | ||
17306 | /* BGP client-to-client reflection. */ | |
892fedb6 | 17307 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
17308 | vty_out(vty, " no bgp client-to-client reflection\n"); |
17309 | ||
17310 | /* BGP cluster ID. */ | |
17311 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
17312 | vty_out(vty, " bgp cluster-id %pI4\n", |
17313 | &bgp->cluster_id); | |
dd65f45e DL |
17314 | |
17315 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 17316 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
17317 | vty_out(vty, |
17318 | " bgp disable-ebgp-connected-route-check\n"); | |
17319 | ||
17320 | /* Confederation identifier*/ | |
17321 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
17322 | vty_out(vty, " bgp confederation identifier %u\n", | |
17323 | bgp->confed_id); | |
17324 | ||
17325 | /* Confederation peer */ | |
17326 | if (bgp->confed_peers_cnt > 0) { | |
17327 | int i; | |
17328 | ||
17329 | vty_out(vty, " bgp confederation peers"); | |
17330 | ||
17331 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
17332 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
17333 | ||
17334 | vty_out(vty, "\n"); | |
17335 | } | |
17336 | ||
17337 | /* BGP deterministic-med. */ | |
892fedb6 | 17338 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 17339 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 17340 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
17341 | CHECK_FLAG(bgp->flags, |
17342 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
17343 | ? "" |
17344 | : "no "); | |
17345 | ||
17346 | /* BGP update-delay. */ | |
17347 | bgp_config_write_update_delay(vty, bgp); | |
17348 | ||
17349 | if (bgp->v_maxmed_onstartup | |
17350 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
17351 | vty_out(vty, " bgp max-med on-startup %u", | |
17352 | bgp->v_maxmed_onstartup); | |
17353 | if (bgp->maxmed_onstartup_value | |
17354 | != BGP_MAXMED_VALUE_DEFAULT) | |
17355 | vty_out(vty, " %u", | |
17356 | bgp->maxmed_onstartup_value); | |
17357 | vty_out(vty, "\n"); | |
17358 | } | |
17359 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
17360 | vty_out(vty, " bgp max-med administrative"); | |
17361 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
17362 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
17363 | vty_out(vty, "\n"); | |
17364 | } | |
17365 | ||
17366 | /* write quanta */ | |
17367 | bgp_config_write_wpkt_quanta(vty, bgp); | |
17368 | /* read quanta */ | |
17369 | bgp_config_write_rpkt_quanta(vty, bgp); | |
17370 | ||
17371 | /* coalesce time */ | |
17372 | bgp_config_write_coalesce_time(vty, bgp); | |
17373 | ||
05bd726c | 17374 | /* BGP per-instance graceful-shutdown */ |
17375 | /* BGP-wide settings and per-instance settings are mutually | |
17376 | * exclusive. | |
17377 | */ | |
17378 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
17379 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
17380 | vty_out(vty, " bgp graceful-shutdown\n"); | |
17381 | ||
8606be87 DA |
17382 | /* Long-lived Graceful Restart */ |
17383 | if (bgp->llgr_stale_time != BGP_DEFAULT_LLGR_STALE_TIME) | |
17384 | vty_out(vty, | |
17385 | " bgp long-lived-graceful-restart stale-time %u\n", | |
17386 | bgp->llgr_stale_time); | |
17387 | ||
dd65f45e DL |
17388 | /* BGP graceful-restart. */ |
17389 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
17390 | vty_out(vty, | |
17391 | " bgp graceful-restart stalepath-time %u\n", | |
17392 | bgp->stalepath_time); | |
cfd47646 | 17393 | |
dd65f45e DL |
17394 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
17395 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
17396 | bgp->restart_time); | |
cfd47646 | 17397 | |
f2ca5c5b DA |
17398 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_NOTIFICATION) != |
17399 | SAVE_BGP_GRACEFUL_NOTIFICATION) | |
17400 | vty_out(vty, " %sbgp graceful-restart notification\n", | |
17401 | CHECK_FLAG(bgp->flags, | |
17402 | BGP_FLAG_GRACEFUL_NOTIFICATION) | |
17403 | ? "" | |
17404 | : "no "); | |
17405 | ||
cfd47646 | 17406 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) |
17407 | vty_out(vty, | |
17408 | " bgp graceful-restart select-defer-time %u\n", | |
17409 | bgp->select_defer_time); | |
17410 | ||
17411 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
17412 | vty_out(vty, " bgp graceful-restart\n"); |
17413 | ||
cfd47646 | 17414 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
17415 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
17416 | ||
dd65f45e | 17417 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 17418 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
17419 | vty_out(vty, |
17420 | " bgp graceful-restart preserve-fw-state\n"); | |
17421 | ||
dc95985f | 17422 | /* Stale timer for RIB */ |
17423 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
17424 | vty_out(vty, | |
17425 | " bgp graceful-restart rib-stale-time %u\n", | |
17426 | bgp->rib_stale_time); | |
17427 | ||
dd65f45e | 17428 | /* BGP bestpath method. */ |
892fedb6 | 17429 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 17430 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 17431 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
17432 | vty_out(vty, " bgp bestpath as-path confed\n"); |
17433 | ||
892fedb6 DA |
17434 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
17435 | if (CHECK_FLAG(bgp->flags, | |
17436 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
17437 | vty_out(vty, |
17438 | " bgp bestpath as-path multipath-relax as-set\n"); | |
17439 | } else { | |
17440 | vty_out(vty, | |
17441 | " bgp bestpath as-path multipath-relax\n"); | |
17442 | } | |
17443 | } | |
17444 | ||
892fedb6 | 17445 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
17446 | vty_out(vty, |
17447 | " bgp route-reflector allow-outbound-policy\n"); | |
17448 | } | |
892fedb6 | 17449 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 17450 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
17451 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
17452 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 17453 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 17454 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 17455 | vty_out(vty, " confed"); |
892fedb6 DA |
17456 | if (CHECK_FLAG(bgp->flags, |
17457 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
17458 | vty_out(vty, " missing-as-worst"); |
17459 | vty_out(vty, "\n"); | |
17460 | } | |
17461 | ||
ee88563a JM |
17462 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_PEERTYPE_MULTIPATH_RELAX)) |
17463 | vty_out(vty, | |
17464 | " bgp bestpath peer-type multipath-relax\n"); | |
17465 | ||
f7e1c681 | 17466 | /* Link bandwidth handling. */ |
17467 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
17468 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
17469 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
17470 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
17471 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
17472 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
17473 | ||
dd65f45e | 17474 | /* BGP network import check. */ |
892fedb6 | 17475 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 17476 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 17477 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 17478 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
17479 | ? "" |
17480 | : "no "); | |
17481 | ||
17482 | /* BGP timers configuration. */ | |
5d5393b9 | 17483 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
9800cfff | 17484 | || bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
dd65f45e DL |
17485 | vty_out(vty, " timers bgp %u %u\n", |
17486 | bgp->default_keepalive, bgp->default_holdtime); | |
17487 | ||
b042667a TI |
17488 | /* BGP minimum holdtime configuration. */ |
17489 | if (bgp->default_min_holdtime != SAVE_BGP_HOLDTIME | |
17490 | && bgp->default_min_holdtime != 0) | |
17491 | vty_out(vty, " bgp minimum-holdtime %u\n", | |
17492 | bgp->default_min_holdtime); | |
17493 | ||
389e4f92 QY |
17494 | /* Conditional advertisement timer configuration */ |
17495 | if (bgp->condition_check_period | |
17496 | != DEFAULT_CONDITIONAL_ROUTES_POLL_TIME) | |
17497 | vty_out(vty, | |
17498 | " bgp conditional-advertisement timer %u\n", | |
17499 | bgp->condition_check_period); | |
17500 | ||
dd65f45e DL |
17501 | /* peer-group */ |
17502 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
17503 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
17504 | } | |
17505 | ||
17506 | /* Normal neighbor configuration. */ | |
17507 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
17508 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
17509 | bgp_config_write_peer_global(vty, bgp, peer); | |
17510 | } | |
17511 | ||
17512 | /* listen range and limit for dynamic BGP neighbors */ | |
17513 | bgp_config_write_listen(vty, bgp); | |
17514 | ||
17515 | /* | |
17516 | * BGP default autoshutdown neighbors | |
17517 | * | |
17518 | * This must be placed after any peer and peer-group | |
17519 | * configuration, to avoid setting all peers to shutdown after | |
17520 | * a daemon restart, which is undesired behavior. (see #2286) | |
17521 | */ | |
17522 | if (bgp->autoshutdown) | |
17523 | vty_out(vty, " bgp default shutdown\n"); | |
17524 | ||
9cf59432 DS |
17525 | /* BGP instance administrative shutdown */ |
17526 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
17527 | vty_out(vty, " bgp shutdown\n"); | |
17528 | ||
f852eb98 PG |
17529 | if (bgp->fast_convergence) |
17530 | vty_out(vty, " bgp fast-convergence\n"); | |
17531 | ||
a0281b2e HS |
17532 | if (bgp->srv6_enabled) { |
17533 | vty_frame(vty, " !\n segment-routing srv6\n"); | |
96db4340 | 17534 | if (strlen(bgp->srv6_locator_name)) |
a0281b2e HS |
17535 | vty_out(vty, " locator %s\n", |
17536 | bgp->srv6_locator_name); | |
ff7c3ee1 | 17537 | vty_endframe(vty, " exit\n"); |
a0281b2e HS |
17538 | } |
17539 | ||
17540 | ||
dd65f45e DL |
17541 | /* IPv4 unicast configuration. */ |
17542 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
17543 | ||
17544 | /* IPv4 multicast configuration. */ | |
17545 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
17546 | ||
17547 | /* IPv4 labeled-unicast configuration. */ | |
17548 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
17549 | ||
17550 | /* IPv4 VPN configuration. */ | |
17551 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
17552 | ||
17553 | /* ENCAPv4 configuration. */ | |
17554 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
17555 | ||
17556 | /* FLOWSPEC v4 configuration. */ | |
17557 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
17558 | ||
17559 | /* IPv6 unicast configuration. */ | |
17560 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
17561 | ||
17562 | /* IPv6 multicast configuration. */ | |
17563 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
17564 | ||
17565 | /* IPv6 labeled-unicast configuration. */ | |
17566 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
17567 | SAFI_LABELED_UNICAST); | |
17568 | ||
17569 | /* IPv6 VPN configuration. */ | |
17570 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
17571 | ||
17572 | /* ENCAPv6 configuration. */ | |
17573 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
17574 | ||
17575 | /* FLOWSPEC v6 configuration. */ | |
17576 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
17577 | ||
17578 | /* EVPN configuration. */ | |
17579 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
17580 | ||
17581 | hook_call(bgp_inst_config_write, bgp, vty); | |
17582 | ||
49e5a4a0 | 17583 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
17584 | bgp_rfapi_cfg_write(vty, bgp); |
17585 | #endif | |
17586 | ||
07679ad9 | 17587 | vty_out(vty, "exit\n"); |
dd65f45e DL |
17588 | vty_out(vty, "!\n"); |
17589 | } | |
17590 | return 0; | |
17591 | } | |
17592 | ||
ddb5b488 | 17593 | |
718e3744 | 17594 | /* BGP node structure. */ |
d62a17ae | 17595 | static struct cmd_node bgp_node = { |
f4b8291f | 17596 | .name = "bgp", |
62b346ee | 17597 | .node = BGP_NODE, |
24389580 | 17598 | .parent_node = CONFIG_NODE, |
62b346ee | 17599 | .prompt = "%s(config-router)# ", |
612c2c15 | 17600 | .config_write = bgp_config_write, |
718e3744 | 17601 | }; |
17602 | ||
d62a17ae | 17603 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 17604 | .name = "bgp ipv4 unicast", |
62b346ee | 17605 | .node = BGP_IPV4_NODE, |
24389580 | 17606 | .parent_node = BGP_NODE, |
62b346ee | 17607 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17608 | .no_xpath = true, |
718e3744 | 17609 | }; |
17610 | ||
d62a17ae | 17611 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 17612 | .name = "bgp ipv4 multicast", |
62b346ee | 17613 | .node = BGP_IPV4M_NODE, |
24389580 | 17614 | .parent_node = BGP_NODE, |
62b346ee | 17615 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17616 | .no_xpath = true, |
718e3744 | 17617 | }; |
17618 | ||
d62a17ae | 17619 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 17620 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 17621 | .node = BGP_IPV4L_NODE, |
24389580 | 17622 | .parent_node = BGP_NODE, |
62b346ee | 17623 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17624 | .no_xpath = true, |
f51bae9c DS |
17625 | }; |
17626 | ||
d62a17ae | 17627 | static struct cmd_node bgp_ipv6_unicast_node = { |
a17cfb3f | 17628 | .name = "bgp ipv6 unicast", |
62b346ee | 17629 | .node = BGP_IPV6_NODE, |
24389580 | 17630 | .parent_node = BGP_NODE, |
62b346ee | 17631 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17632 | .no_xpath = true, |
718e3744 | 17633 | }; |
17634 | ||
d62a17ae | 17635 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 17636 | .name = "bgp ipv6 multicast", |
62b346ee | 17637 | .node = BGP_IPV6M_NODE, |
24389580 | 17638 | .parent_node = BGP_NODE, |
62b346ee | 17639 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17640 | .no_xpath = true, |
25ffbdc1 | 17641 | }; |
17642 | ||
d62a17ae | 17643 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 17644 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 17645 | .node = BGP_IPV6L_NODE, |
24389580 | 17646 | .parent_node = BGP_NODE, |
62b346ee | 17647 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17648 | .no_xpath = true, |
f51bae9c DS |
17649 | }; |
17650 | ||
62b346ee | 17651 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 17652 | .name = "bgp vpnv4", |
62b346ee | 17653 | .node = BGP_VPNV4_NODE, |
24389580 | 17654 | .parent_node = BGP_NODE, |
62b346ee | 17655 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17656 | .no_xpath = true, |
62b346ee | 17657 | }; |
6b0655a2 | 17658 | |
62b346ee | 17659 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 17660 | .name = "bgp vpnv6", |
62b346ee | 17661 | .node = BGP_VPNV6_NODE, |
24389580 | 17662 | .parent_node = BGP_NODE, |
62b346ee | 17663 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 17664 | .no_xpath = true, |
62b346ee | 17665 | }; |
8ecd3266 | 17666 | |
62b346ee | 17667 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 17668 | .name = "bgp evpn", |
62b346ee | 17669 | .node = BGP_EVPN_NODE, |
24389580 | 17670 | .parent_node = BGP_NODE, |
62b346ee | 17671 | .prompt = "%s(config-router-evpn)# ", |
dd2c81b8 | 17672 | .no_xpath = true, |
62b346ee | 17673 | }; |
4e0b7b6d | 17674 | |
62b346ee | 17675 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 17676 | .name = "bgp evpn vni", |
62b346ee | 17677 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 17678 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 17679 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 17680 | }; |
90e60aa7 | 17681 | |
62b346ee | 17682 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 17683 | .name = "bgp ipv4 flowspec", |
62b346ee | 17684 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 17685 | .parent_node = BGP_NODE, |
62b346ee | 17686 | .prompt = "%s(config-router-af)# ", |
dd2c81b8 | 17687 | .no_xpath = true, |
62b346ee | 17688 | }; |
7c40bf39 | 17689 | |
62b346ee | 17690 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 17691 | .name = "bgp ipv6 flowspec", |
62b346ee | 17692 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 17693 | .parent_node = BGP_NODE, |
62b346ee | 17694 | .prompt = "%s(config-router-af-vpnv6)# ", |
dd2c81b8 | 17695 | .no_xpath = true, |
62b346ee | 17696 | }; |
7c40bf39 | 17697 | |
bfaab44d HS |
17698 | static struct cmd_node bgp_srv6_node = { |
17699 | .name = "bgp srv6", | |
17700 | .node = BGP_SRV6_NODE, | |
17701 | .parent_node = BGP_NODE, | |
17702 | .prompt = "%s(config-router-srv6)# ", | |
17703 | }; | |
17704 | ||
d62a17ae | 17705 | static void community_list_vty(void); |
1f8ae70b | 17706 | |
8c20061f DA |
17707 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
17708 | { | |
17709 | struct bgp *bgp; | |
17710 | struct peer_group *group; | |
17711 | struct listnode *lnbgp, *lnpeer; | |
17712 | ||
17713 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
17714 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
17715 | vector_set(comps, | |
17716 | XSTRDUP(MTYPE_COMPLETION, group->name)); | |
17717 | } | |
17718 | } | |
17719 | ||
17720 | static void bgp_ac_peer(vector comps, struct cmd_token *token) | |
b8a815e5 | 17721 | { |
d62a17ae | 17722 | struct bgp *bgp; |
17723 | struct peer *peer; | |
d62a17ae | 17724 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 17725 | |
d62a17ae | 17726 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
17727 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
17728 | /* only provide suggestions on the appropriate input | |
17729 | * token type, | |
17730 | * they'll otherwise show up multiple times */ | |
17731 | enum cmd_token_type match_type; | |
17732 | char *name = peer->host; | |
d48ed3e0 | 17733 | |
d62a17ae | 17734 | if (peer->conf_if) { |
17735 | match_type = VARIABLE_TKN; | |
17736 | name = peer->conf_if; | |
17737 | } else if (strchr(peer->host, ':')) | |
17738 | match_type = IPV6_TKN; | |
17739 | else | |
17740 | match_type = IPV4_TKN; | |
d48ed3e0 | 17741 | |
d62a17ae | 17742 | if (token->type != match_type) |
17743 | continue; | |
d48ed3e0 | 17744 | |
d62a17ae | 17745 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
17746 | } | |
d62a17ae | 17747 | } |
b8a815e5 DL |
17748 | } |
17749 | ||
8c20061f DA |
17750 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
17751 | { | |
17752 | bgp_ac_peer(comps, token); | |
84de1483 DA |
17753 | |
17754 | if (token->type == VARIABLE_TKN) | |
17755 | bgp_ac_peergroup(comps, token); | |
8c20061f DA |
17756 | } |
17757 | ||
b8a815e5 | 17758 | static const struct cmd_variable_handler bgp_var_neighbor[] = { |
d62a17ae | 17759 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
17760 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 17761 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 17762 | {.completions = NULL}}; |
17763 | ||
47a306a0 DS |
17764 | static const struct cmd_variable_handler bgp_var_peergroup[] = { |
17765 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
17766 | {.completions = NULL} }; | |
17767 | ||
aa24a36a DA |
17768 | DEFINE_HOOK(bgp_config_end, (struct bgp *bgp), (bgp)); |
17769 | ||
17770 | static struct thread *t_bgp_cfg; | |
17771 | ||
17772 | bool bgp_config_inprocess(void) | |
17773 | { | |
17774 | return thread_is_scheduled(t_bgp_cfg); | |
17775 | } | |
17776 | ||
17777 | static void bgp_config_finish(struct thread *t) | |
17778 | { | |
17779 | struct listnode *node; | |
17780 | struct bgp *bgp; | |
17781 | ||
17782 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp)) | |
17783 | hook_call(bgp_config_end, bgp); | |
17784 | } | |
17785 | ||
17786 | static void bgp_config_start(void) | |
17787 | { | |
17788 | #define BGP_PRE_CONFIG_MAX_WAIT_SECONDS 600 | |
17789 | THREAD_OFF(t_bgp_cfg); | |
17790 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
17791 | BGP_PRE_CONFIG_MAX_WAIT_SECONDS, &t_bgp_cfg); | |
17792 | } | |
17793 | ||
17794 | /* When we receive a hook the configuration is read, | |
17795 | * we start a timer to make sure we postpone sending | |
17796 | * EoR before route-maps are processed. | |
17797 | * This is especially valid if using `bgp route-map delay-timer`. | |
17798 | */ | |
17799 | static void bgp_config_end(void) | |
17800 | { | |
17801 | #define BGP_POST_CONFIG_DELAY_SECONDS 1 | |
17802 | uint32_t bgp_post_config_delay = | |
17803 | thread_is_scheduled(bm->t_rmap_update) | |
17804 | ? thread_timer_remain_second(bm->t_rmap_update) | |
17805 | : BGP_POST_CONFIG_DELAY_SECONDS; | |
17806 | ||
17807 | /* If BGP config processing thread isn't running, then | |
17808 | * we can return and rely it's properly handled. | |
17809 | */ | |
17810 | if (!bgp_config_inprocess()) | |
17811 | return; | |
17812 | ||
17813 | THREAD_OFF(t_bgp_cfg); | |
17814 | ||
17815 | /* Start a new timer to make sure we don't send EoR | |
17816 | * before route-maps are processed. | |
17817 | */ | |
17818 | thread_add_timer(bm->master, bgp_config_finish, NULL, | |
17819 | bgp_post_config_delay, &t_bgp_cfg); | |
17820 | } | |
17821 | ||
d62a17ae | 17822 | void bgp_vty_init(void) |
17823 | { | |
17824 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 17825 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 17826 | |
aa24a36a DA |
17827 | cmd_init_config_callbacks(bgp_config_start, bgp_config_end); |
17828 | ||
d62a17ae | 17829 | /* Install bgp top node. */ |
612c2c15 DL |
17830 | install_node(&bgp_node); |
17831 | install_node(&bgp_ipv4_unicast_node); | |
17832 | install_node(&bgp_ipv4_multicast_node); | |
17833 | install_node(&bgp_ipv4_labeled_unicast_node); | |
17834 | install_node(&bgp_ipv6_unicast_node); | |
17835 | install_node(&bgp_ipv6_multicast_node); | |
17836 | install_node(&bgp_ipv6_labeled_unicast_node); | |
17837 | install_node(&bgp_vpnv4_node); | |
17838 | install_node(&bgp_vpnv6_node); | |
17839 | install_node(&bgp_evpn_node); | |
17840 | install_node(&bgp_evpn_vni_node); | |
17841 | install_node(&bgp_flowspecv4_node); | |
17842 | install_node(&bgp_flowspecv6_node); | |
bfaab44d | 17843 | install_node(&bgp_srv6_node); |
d62a17ae | 17844 | |
17845 | /* Install default VTY commands to new nodes. */ | |
17846 | install_default(BGP_NODE); | |
17847 | install_default(BGP_IPV4_NODE); | |
17848 | install_default(BGP_IPV4M_NODE); | |
17849 | install_default(BGP_IPV4L_NODE); | |
17850 | install_default(BGP_IPV6_NODE); | |
17851 | install_default(BGP_IPV6M_NODE); | |
17852 | install_default(BGP_IPV6L_NODE); | |
17853 | install_default(BGP_VPNV4_NODE); | |
17854 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 17855 | install_default(BGP_FLOWSPECV4_NODE); |
17856 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 17857 | install_default(BGP_EVPN_NODE); |
17858 | install_default(BGP_EVPN_VNI_NODE); | |
bfaab44d | 17859 | install_default(BGP_SRV6_NODE); |
d62a17ae | 17860 | |
8029b216 AK |
17861 | /* "bgp local-mac" hidden commands. */ |
17862 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
17863 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
17864 | ||
9acb67cb DS |
17865 | /* "bgp suppress-fib-pending" global */ |
17866 | install_element(CONFIG_NODE, &bgp_global_suppress_fib_pending_cmd); | |
17867 | ||
d62a17ae | 17868 | /* bgp route-map delay-timer commands. */ |
17869 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17870 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17871 | ||
f852eb98 PG |
17872 | /* bgp fast-convergence command */ |
17873 | install_element(BGP_NODE, &bgp_fast_convergence_cmd); | |
17874 | install_element(BGP_NODE, &no_bgp_fast_convergence_cmd); | |
17875 | ||
d70583f7 D |
17876 | /* global bgp update-delay command */ |
17877 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
17878 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
17879 | ||
05bd726c | 17880 | /* global bgp graceful-shutdown command */ |
17881 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
17882 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
17883 | ||
d62a17ae | 17884 | /* Dummy commands (Currently not supported) */ |
17885 | install_element(BGP_NODE, &no_synchronization_cmd); | |
17886 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
17887 | ||
17888 | /* "router bgp" commands. */ | |
17889 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
17890 | ||
17891 | /* "no router bgp" commands. */ | |
17892 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
17893 | ||
425bd64b PS |
17894 | /* "bgp session-dscp command */ |
17895 | install_element(CONFIG_NODE, &bgp_session_dscp_cmd); | |
17896 | install_element(CONFIG_NODE, &no_bgp_session_dscp_cmd); | |
17897 | ||
d62a17ae | 17898 | /* "bgp router-id" commands. */ |
17899 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
17900 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
17901 | ||
c208c586 S |
17902 | /* "bgp suppress-fib-pending" command */ |
17903 | install_element(BGP_NODE, &bgp_suppress_fib_pending_cmd); | |
17904 | ||
d62a17ae | 17905 | /* "bgp cluster-id" commands. */ |
17906 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
17907 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
17908 | ||
c163f297 DS |
17909 | /* "bgp no-rib" commands. */ |
17910 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
17911 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
17912 | ||
e46723a5 DS |
17913 | install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); |
17914 | ||
d62a17ae | 17915 | /* "bgp confederation" commands. */ |
17916 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
17917 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
17918 | ||
17919 | /* "bgp confederation peers" commands. */ | |
17920 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
17921 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
17922 | ||
17923 | /* bgp max-med command */ | |
17924 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
17925 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
17926 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
17927 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
17928 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
17929 | ||
17930 | /* bgp disable-ebgp-connected-nh-check */ | |
17931 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
17932 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
17933 | ||
17934 | /* bgp update-delay command */ | |
17935 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
17936 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 17937 | |
17938 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 17939 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 17940 | |
17941 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
17942 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
17943 | ||
17944 | /* "maximum-paths" commands. */ | |
17945 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
17946 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
17947 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
17948 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
17949 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
17950 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
17951 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
17952 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
17953 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
17954 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
17955 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17956 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17957 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
17958 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17959 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17960 | ||
39edabac PG |
17961 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
17962 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
17963 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17964 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17965 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 17966 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
17967 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
17968 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
17969 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
17970 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
17971 | ||
17972 | /* "timers bgp" commands. */ | |
17973 | install_element(BGP_NODE, &bgp_timers_cmd); | |
17974 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
17975 | ||
b042667a TI |
17976 | /* "minimum-holdtime" commands. */ |
17977 | install_element(BGP_NODE, &bgp_minimum_holdtime_cmd); | |
17978 | install_element(BGP_NODE, &no_bgp_minimum_holdtime_cmd); | |
17979 | ||
d62a17ae | 17980 | /* route-map delay-timer commands - per instance for backwards compat. |
17981 | */ | |
17982 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
17983 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
17984 | ||
17985 | /* "bgp client-to-client reflection" commands */ | |
17986 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
17987 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
17988 | ||
17989 | /* "bgp always-compare-med" commands */ | |
17990 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
17991 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
17992 | ||
9dac9fc8 DA |
17993 | /* bgp ebgp-requires-policy */ |
17994 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
17995 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
17996 | ||
2adac256 DA |
17997 | /* bgp suppress-duplicates */ |
17998 | install_element(BGP_NODE, &bgp_suppress_duplicates_cmd); | |
17999 | install_element(BGP_NODE, &no_bgp_suppress_duplicates_cmd); | |
18000 | ||
fb29348a DA |
18001 | /* bgp reject-as-sets */ |
18002 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
18003 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
18004 | ||
d62a17ae | 18005 | /* "bgp deterministic-med" commands */ |
18006 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
18007 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
18008 | ||
055679e9 | 18009 | /* "bgp graceful-restart" command */ |
36235319 QY |
18010 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
18011 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 18012 | |
18013 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
18014 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
18015 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 18016 | |
18017 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
18018 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
18019 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 18020 | |
18021 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
18022 | install_element(BGP_NODE, | |
18023 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
18024 | install_element(BGP_NODE, | |
18025 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
18026 | ||
18027 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
18028 | install_element(BGP_NODE, | |
18029 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
18030 | install_element(BGP_NODE, | |
18031 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
18032 | ||
d62a17ae | 18033 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
18034 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
18035 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
18036 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 18037 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 18038 | install_element(BGP_NODE, |
18039 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 18040 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
18041 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
f2ca5c5b | 18042 | install_element(BGP_NODE, &bgp_graceful_restart_notification_cmd); |
d62a17ae | 18043 | |
d6e3c15b | 18044 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
18045 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 18046 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
18047 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 18048 | |
7f323236 DW |
18049 | /* "bgp graceful-shutdown" commands */ |
18050 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
18051 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
18052 | ||
1ae314be DA |
18053 | /* "bgp hard-administrative-reset" commands */ |
18054 | install_element(BGP_NODE, &bgp_administrative_reset_cmd); | |
18055 | ||
8606be87 DA |
18056 | /* "bgp long-lived-graceful-restart" commands */ |
18057 | install_element(BGP_NODE, &bgp_llgr_stalepath_time_cmd); | |
18058 | install_element(BGP_NODE, &no_bgp_llgr_stalepath_time_cmd); | |
18059 | ||
d62a17ae | 18060 | /* "bgp fast-external-failover" commands */ |
18061 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
18062 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
18063 | ||
d62a17ae | 18064 | /* "bgp bestpath compare-routerid" commands */ |
18065 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
18066 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
18067 | ||
18068 | /* "bgp bestpath as-path ignore" commands */ | |
18069 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
18070 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
18071 | ||
18072 | /* "bgp bestpath as-path confed" commands */ | |
18073 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
18074 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
18075 | ||
18076 | /* "bgp bestpath as-path multipath-relax" commands */ | |
18077 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
18078 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
18079 | ||
ee88563a JM |
18080 | /* "bgp bestpath peer-type multipath-relax" commands */ |
18081 | install_element(BGP_NODE, &bgp_bestpath_peer_type_multipath_relax_cmd); | |
18082 | install_element(BGP_NODE, | |
18083 | &no_bgp_bestpath_peer_type_multipath_relax_cmd); | |
18084 | ||
d62a17ae | 18085 | /* "bgp log-neighbor-changes" commands */ |
18086 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
18087 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
18088 | ||
18089 | /* "bgp bestpath med" commands */ | |
18090 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
18091 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
18092 | ||
f7e1c681 | 18093 | /* "bgp bestpath bandwidth" commands */ |
18094 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 18095 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 18096 | |
b16bcbba TA |
18097 | /* "no bgp default <afi>-<safi>" commands. */ |
18098 | install_element(BGP_NODE, &bgp_default_afi_safi_cmd); | |
e84c59af | 18099 | |
d62a17ae | 18100 | /* "bgp network import-check" commands. */ |
18101 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
18102 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
18103 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
18104 | ||
18105 | /* "bgp default local-preference" commands. */ | |
18106 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
18107 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
18108 | ||
18109 | /* bgp default show-hostname */ | |
18110 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
18111 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
18112 | ||
aef999a2 DA |
18113 | /* bgp default show-nexthop-hostname */ |
18114 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
18115 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
18116 | ||
d62a17ae | 18117 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
18118 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
18119 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
18120 | ||
18121 | /* bgp ibgp-allow-policy-mods command */ | |
18122 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
18123 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
18124 | ||
18125 | /* "bgp listen limit" commands. */ | |
18126 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
18127 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
18128 | ||
18129 | /* "bgp listen range" commands. */ | |
18130 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
18131 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
18132 | ||
8175f54a | 18133 | /* "bgp default shutdown" command */ |
f26845f9 | 18134 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
18135 | |
18136 | /* "bgp shutdown" commands */ | |
18137 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 18138 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 18139 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 18140 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 18141 | |
d62a17ae | 18142 | /* "neighbor remote-as" commands. */ |
18143 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
18144 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
18145 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
18146 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
18147 | install_element(BGP_NODE, | |
18148 | &neighbor_interface_v6only_config_remote_as_cmd); | |
18149 | install_element(BGP_NODE, &no_neighbor_cmd); | |
18150 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
18151 | ||
18152 | /* "neighbor peer-group" commands. */ | |
18153 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
18154 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
18155 | install_element(BGP_NODE, | |
18156 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
18157 | ||
18158 | /* "neighbor local-as" commands. */ | |
18159 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
18160 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
18161 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
18162 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
18163 | ||
18164 | /* "neighbor solo" commands. */ | |
18165 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
18166 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
18167 | ||
18168 | /* "neighbor password" commands. */ | |
18169 | install_element(BGP_NODE, &neighbor_password_cmd); | |
18170 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
18171 | ||
18172 | /* "neighbor activate" commands. */ | |
18173 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
18174 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
18175 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
18176 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
18177 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
18178 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
18179 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
18180 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
18181 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 18182 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
18183 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 18184 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
18185 | ||
18186 | /* "no neighbor activate" commands. */ | |
18187 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
18188 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
18189 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
18190 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
18191 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
18192 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
18193 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
18194 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
18195 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 18196 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
18197 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 18198 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
18199 | ||
18200 | /* "neighbor peer-group" set commands. */ | |
18201 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
18202 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18203 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18204 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18205 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18206 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18207 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
18208 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18209 | install_element(BGP_FLOWSPECV4_NODE, |
18210 | &neighbor_set_peer_group_hidden_cmd); | |
18211 | install_element(BGP_FLOWSPECV6_NODE, | |
18212 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18213 | |
18214 | /* "no neighbor peer-group unset" commands. */ | |
18215 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
18216 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18217 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18218 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18219 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18220 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18221 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
18222 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 18223 | install_element(BGP_FLOWSPECV4_NODE, |
18224 | &no_neighbor_set_peer_group_hidden_cmd); | |
18225 | install_element(BGP_FLOWSPECV6_NODE, | |
18226 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 18227 | |
18228 | /* "neighbor softreconfiguration inbound" commands.*/ | |
18229 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
18230 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
18231 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18232 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18233 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18234 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18235 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18236 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18237 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18238 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18239 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
18240 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18241 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
18242 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18243 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
18244 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
18245 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
18246 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 18247 | install_element(BGP_FLOWSPECV4_NODE, |
18248 | &neighbor_soft_reconfiguration_cmd); | |
18249 | install_element(BGP_FLOWSPECV4_NODE, | |
18250 | &no_neighbor_soft_reconfiguration_cmd); | |
18251 | install_element(BGP_FLOWSPECV6_NODE, | |
18252 | &neighbor_soft_reconfiguration_cmd); | |
18253 | install_element(BGP_FLOWSPECV6_NODE, | |
18254 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
18255 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
18256 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 18257 | |
18258 | /* "neighbor attribute-unchanged" commands. */ | |
18259 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
18260 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
18261 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
18262 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18263 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
18264 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18265 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
18266 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18267 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
18268 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18269 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
18270 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
18271 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
18272 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
18273 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
18274 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18275 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
18276 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18277 | ||
18278 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
18279 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
18280 | ||
b8ad84d2 PG |
18281 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_attr_unchanged_cmd); |
18282 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
18283 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_attr_unchanged_cmd); | |
18284 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
18285 | ||
d62a17ae | 18286 | /* "nexthop-local unchanged" commands */ |
18287 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
18288 | install_element(BGP_IPV6_NODE, | |
18289 | &no_neighbor_nexthop_local_unchanged_cmd); | |
18290 | ||
18291 | /* "neighbor next-hop-self" commands. */ | |
18292 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
18293 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
18294 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
18295 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18296 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
18297 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
18298 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
18299 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
18300 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
18301 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
18302 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
18303 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
18304 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
18305 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
18306 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
18307 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
18308 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
18309 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
18310 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
18311 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 18312 | |
18313 | /* "neighbor next-hop-self force" commands. */ | |
18314 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
18315 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
18316 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18317 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18318 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
18319 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18320 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18321 | install_element(BGP_IPV4_NODE, | |
18322 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18323 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
18324 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18325 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18326 | install_element(BGP_IPV4M_NODE, | |
18327 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18328 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
18329 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18330 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18331 | install_element(BGP_IPV4L_NODE, | |
18332 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18333 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
18334 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18335 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18336 | install_element(BGP_IPV6_NODE, | |
18337 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18338 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
18339 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18340 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18341 | install_element(BGP_IPV6M_NODE, | |
18342 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18343 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
18344 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18345 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18346 | install_element(BGP_IPV6L_NODE, | |
18347 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18348 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
18349 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18350 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18351 | install_element(BGP_VPNV4_NODE, | |
18352 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 18353 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
18354 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
18355 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
18356 | install_element(BGP_VPNV6_NODE, | |
18357 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
18358 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
18359 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 18360 | |
18361 | /* "neighbor as-override" commands. */ | |
18362 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
18363 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
18364 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
18365 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
18366 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
18367 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
18368 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
18369 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
18370 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
18371 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
18372 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
18373 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
18374 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
18375 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
18376 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
18377 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
18378 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
18379 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
18380 | ||
18381 | /* "neighbor remove-private-AS" commands. */ | |
18382 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
18383 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
18384 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
18385 | install_element(BGP_NODE, | |
18386 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
18387 | install_element(BGP_NODE, | |
18388 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
18389 | install_element(BGP_NODE, | |
18390 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
18391 | install_element(BGP_NODE, | |
18392 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18393 | install_element( | |
18394 | BGP_NODE, | |
18395 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
18396 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
18397 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18398 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18399 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18400 | install_element(BGP_IPV4_NODE, | |
18401 | &neighbor_remove_private_as_replace_as_cmd); | |
18402 | install_element(BGP_IPV4_NODE, | |
18403 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18404 | install_element(BGP_IPV4_NODE, | |
18405 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18406 | install_element(BGP_IPV4_NODE, | |
18407 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18408 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
18409 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
18410 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
18411 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18412 | install_element(BGP_IPV4M_NODE, | |
18413 | &neighbor_remove_private_as_replace_as_cmd); | |
18414 | install_element(BGP_IPV4M_NODE, | |
18415 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18416 | install_element(BGP_IPV4M_NODE, | |
18417 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18418 | install_element(BGP_IPV4M_NODE, | |
18419 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18420 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
18421 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
18422 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
18423 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18424 | install_element(BGP_IPV4L_NODE, | |
18425 | &neighbor_remove_private_as_replace_as_cmd); | |
18426 | install_element(BGP_IPV4L_NODE, | |
18427 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18428 | install_element(BGP_IPV4L_NODE, | |
18429 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18430 | install_element(BGP_IPV4L_NODE, | |
18431 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18432 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
18433 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18434 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18435 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18436 | install_element(BGP_IPV6_NODE, | |
18437 | &neighbor_remove_private_as_replace_as_cmd); | |
18438 | install_element(BGP_IPV6_NODE, | |
18439 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18440 | install_element(BGP_IPV6_NODE, | |
18441 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18442 | install_element(BGP_IPV6_NODE, | |
18443 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18444 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
18445 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
18446 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
18447 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18448 | install_element(BGP_IPV6M_NODE, | |
18449 | &neighbor_remove_private_as_replace_as_cmd); | |
18450 | install_element(BGP_IPV6M_NODE, | |
18451 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18452 | install_element(BGP_IPV6M_NODE, | |
18453 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18454 | install_element(BGP_IPV6M_NODE, | |
18455 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18456 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
18457 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
18458 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
18459 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18460 | install_element(BGP_IPV6L_NODE, | |
18461 | &neighbor_remove_private_as_replace_as_cmd); | |
18462 | install_element(BGP_IPV6L_NODE, | |
18463 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18464 | install_element(BGP_IPV6L_NODE, | |
18465 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18466 | install_element(BGP_IPV6L_NODE, | |
18467 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18468 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
18469 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
18470 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
18471 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18472 | install_element(BGP_VPNV4_NODE, | |
18473 | &neighbor_remove_private_as_replace_as_cmd); | |
18474 | install_element(BGP_VPNV4_NODE, | |
18475 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18476 | install_element(BGP_VPNV4_NODE, | |
18477 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18478 | install_element(BGP_VPNV4_NODE, | |
18479 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18480 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
18481 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
18482 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
18483 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
18484 | install_element(BGP_VPNV6_NODE, | |
18485 | &neighbor_remove_private_as_replace_as_cmd); | |
18486 | install_element(BGP_VPNV6_NODE, | |
18487 | &no_neighbor_remove_private_as_replace_as_cmd); | |
18488 | install_element(BGP_VPNV6_NODE, | |
18489 | &neighbor_remove_private_as_all_replace_as_cmd); | |
18490 | install_element(BGP_VPNV6_NODE, | |
18491 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
18492 | ||
18493 | /* "neighbor send-community" commands.*/ | |
18494 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
18495 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
18496 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
18497 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
18498 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
18499 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
18500 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
18501 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
18502 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
18503 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
18504 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
18505 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
18506 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
18507 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
18508 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
18509 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
18510 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
18511 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
18512 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
18513 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
18514 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
18515 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
18516 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
18517 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
18518 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
18519 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
18520 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
18521 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
18522 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
18523 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
18524 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
18525 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
18526 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
18527 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
18528 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
18529 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
18530 | ||
18531 | /* "neighbor route-reflector" commands.*/ | |
18532 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
18533 | install_element(BGP_NODE, | |
18534 | &no_neighbor_route_reflector_client_hidden_cmd); | |
18535 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
18536 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
18537 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
18538 | install_element(BGP_IPV4M_NODE, | |
18539 | &no_neighbor_route_reflector_client_cmd); | |
18540 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
18541 | install_element(BGP_IPV4L_NODE, | |
18542 | &no_neighbor_route_reflector_client_cmd); | |
18543 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
18544 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
18545 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
18546 | install_element(BGP_IPV6M_NODE, | |
18547 | &no_neighbor_route_reflector_client_cmd); | |
18548 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
18549 | install_element(BGP_IPV6L_NODE, | |
18550 | &no_neighbor_route_reflector_client_cmd); | |
18551 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
18552 | install_element(BGP_VPNV4_NODE, | |
18553 | &no_neighbor_route_reflector_client_cmd); | |
18554 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
18555 | install_element(BGP_VPNV6_NODE, | |
18556 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 18557 | install_element(BGP_FLOWSPECV4_NODE, |
18558 | &neighbor_route_reflector_client_cmd); | |
18559 | install_element(BGP_FLOWSPECV4_NODE, | |
18560 | &no_neighbor_route_reflector_client_cmd); | |
18561 | install_element(BGP_FLOWSPECV6_NODE, | |
18562 | &neighbor_route_reflector_client_cmd); | |
18563 | install_element(BGP_FLOWSPECV6_NODE, | |
18564 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 18565 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
18566 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
18567 | ||
18568 | /* "neighbor route-server" commands.*/ | |
18569 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
18570 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
18571 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
18572 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
18573 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
18574 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
18575 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
18576 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
18577 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
18578 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
18579 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
18580 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
18581 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
18582 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
18583 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
18584 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
18585 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
18586 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
18587 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
18588 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 18589 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
18590 | install_element(BGP_FLOWSPECV4_NODE, | |
18591 | &no_neighbor_route_server_client_cmd); | |
18592 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
18593 | install_element(BGP_FLOWSPECV6_NODE, | |
18594 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 18595 | |
7c0e4312 DA |
18596 | /* "neighbor disable-addpath-rx" commands. */ |
18597 | install_element(BGP_IPV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18598 | install_element(BGP_IPV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18599 | install_element(BGP_IPV4M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18600 | install_element(BGP_IPV4M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18601 | install_element(BGP_IPV4L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18602 | install_element(BGP_IPV4L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18603 | install_element(BGP_IPV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18604 | install_element(BGP_IPV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18605 | install_element(BGP_IPV6M_NODE, &neighbor_disable_addpath_rx_cmd); | |
18606 | install_element(BGP_IPV6M_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18607 | install_element(BGP_IPV6L_NODE, &neighbor_disable_addpath_rx_cmd); | |
18608 | install_element(BGP_IPV6L_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18609 | install_element(BGP_VPNV4_NODE, &neighbor_disable_addpath_rx_cmd); | |
18610 | install_element(BGP_VPNV4_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18611 | install_element(BGP_VPNV6_NODE, &neighbor_disable_addpath_rx_cmd); | |
18612 | install_element(BGP_VPNV6_NODE, &no_neighbor_disable_addpath_rx_cmd); | |
18613 | ||
d62a17ae | 18614 | /* "neighbor addpath-tx-all-paths" commands.*/ |
18615 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
18616 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
18617 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18618 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18619 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18620 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18621 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18622 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18623 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18624 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18625 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18626 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18627 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18628 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18629 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18630 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18631 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
18632 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
18633 | ||
18634 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
18635 | install_element(BGP_NODE, | |
18636 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18637 | install_element(BGP_NODE, | |
18638 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
18639 | install_element(BGP_IPV4_NODE, | |
18640 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18641 | install_element(BGP_IPV4_NODE, | |
18642 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18643 | install_element(BGP_IPV4M_NODE, | |
18644 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18645 | install_element(BGP_IPV4M_NODE, | |
18646 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18647 | install_element(BGP_IPV4L_NODE, | |
18648 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18649 | install_element(BGP_IPV4L_NODE, | |
18650 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18651 | install_element(BGP_IPV6_NODE, | |
18652 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18653 | install_element(BGP_IPV6_NODE, | |
18654 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18655 | install_element(BGP_IPV6M_NODE, | |
18656 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18657 | install_element(BGP_IPV6M_NODE, | |
18658 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18659 | install_element(BGP_IPV6L_NODE, | |
18660 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18661 | install_element(BGP_IPV6L_NODE, | |
18662 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18663 | install_element(BGP_VPNV4_NODE, | |
18664 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18665 | install_element(BGP_VPNV4_NODE, | |
18666 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18667 | install_element(BGP_VPNV6_NODE, | |
18668 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
18669 | install_element(BGP_VPNV6_NODE, | |
18670 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
18671 | ||
2b31007c RZ |
18672 | /* "neighbor sender-as-path-loop-detection" commands. */ |
18673 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
18674 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
18675 | ||
d62a17ae | 18676 | /* "neighbor passive" commands. */ |
18677 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
18678 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
18679 | ||
18680 | ||
18681 | /* "neighbor shutdown" commands. */ | |
18682 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
18683 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
18684 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
18685 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
18686 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
18687 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 18688 | |
18689 | /* "neighbor capability extended-nexthop" commands.*/ | |
18690 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
18691 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
18692 | ||
18693 | /* "neighbor capability orf prefix-list" commands.*/ | |
18694 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
18695 | install_element(BGP_NODE, | |
18696 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
18697 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
18698 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18699 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18700 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18701 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18702 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18703 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
18704 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18705 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
18706 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18707 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
18708 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
18709 | ||
18710 | /* "neighbor capability dynamic" commands.*/ | |
18711 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
18712 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
18713 | ||
18714 | /* "neighbor dont-capability-negotiate" commands. */ | |
18715 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
18716 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
18717 | ||
18718 | /* "neighbor ebgp-multihop" commands. */ | |
18719 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
18720 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
18721 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
18722 | ||
18723 | /* "neighbor disable-connected-check" commands. */ | |
18724 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
18725 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
18726 | ||
7ab294ea DA |
18727 | /* "neighbor disable-link-bw-encoding-ieee" commands. */ |
18728 | install_element(BGP_NODE, &neighbor_disable_link_bw_encoding_ieee_cmd); | |
18729 | install_element(BGP_NODE, | |
18730 | &no_neighbor_disable_link_bw_encoding_ieee_cmd); | |
27aa23a4 | 18731 | |
d08c0c80 DA |
18732 | /* "neighbor extended-optional-parameters" commands. */ |
18733 | install_element(BGP_NODE, &neighbor_extended_optional_parameters_cmd); | |
18734 | install_element(BGP_NODE, | |
18735 | &no_neighbor_extended_optional_parameters_cmd); | |
18736 | ||
47cbc09b PM |
18737 | /* "neighbor enforce-first-as" commands. */ |
18738 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
18739 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
18740 | ||
d62a17ae | 18741 | /* "neighbor description" commands. */ |
18742 | install_element(BGP_NODE, &neighbor_description_cmd); | |
18743 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 18744 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 18745 | |
18746 | /* "neighbor update-source" commands. "*/ | |
18747 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
18748 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
18749 | ||
18750 | /* "neighbor default-originate" commands. */ | |
18751 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
18752 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
18753 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
18754 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
18755 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
18756 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
18757 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
18758 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
18759 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
18760 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
18761 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
18762 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
18763 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
18764 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
18765 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
18766 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
18767 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
18768 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
18769 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
18770 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
18771 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
18772 | ||
18773 | /* "neighbor port" commands. */ | |
18774 | install_element(BGP_NODE, &neighbor_port_cmd); | |
18775 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
18776 | ||
18777 | /* "neighbor weight" commands. */ | |
18778 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
18779 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
18780 | ||
18781 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
18782 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
18783 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
18784 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
18785 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
18786 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
18787 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
18788 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
18789 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
18790 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
18791 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
18792 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
18793 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
18794 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
18795 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
18796 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
18797 | ||
18798 | /* "neighbor override-capability" commands. */ | |
18799 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
18800 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
18801 | ||
18802 | /* "neighbor strict-capability-match" commands. */ | |
18803 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
18804 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
18805 | ||
18806 | /* "neighbor timers" commands. */ | |
18807 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
18808 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
18809 | ||
18810 | /* "neighbor timers connect" commands. */ | |
18811 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
18812 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
18813 | ||
d43114f3 DS |
18814 | /* "neighbor timers delayopen" commands. */ |
18815 | install_element(BGP_NODE, &neighbor_timers_delayopen_cmd); | |
18816 | install_element(BGP_NODE, &no_neighbor_timers_delayopen_cmd); | |
18817 | ||
d62a17ae | 18818 | /* "neighbor advertisement-interval" commands. */ |
18819 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
18820 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
18821 | ||
18822 | /* "neighbor interface" commands. */ | |
18823 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
18824 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
18825 | ||
18826 | /* "neighbor distribute" commands. */ | |
18827 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
18828 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
18829 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
18830 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
18831 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
18832 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
18833 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
18834 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
18835 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
18836 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
18837 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
18838 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
18839 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
18840 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
18841 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
18842 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
18843 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
18844 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
18845 | ||
18846 | /* "neighbor prefix-list" commands. */ | |
18847 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
642ef664 | 18848 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); |
d62a17ae | 18849 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18850 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18851 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18852 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18853 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18854 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18855 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18856 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18857 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18858 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18859 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18860 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18861 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18862 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18863 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18864 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18865 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18866 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); |
7c40bf39 | 18867 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); |
642ef664 | 18868 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); |
d62a17ae | 18869 | |
18870 | /* "neighbor filter-list" commands. */ | |
18871 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
18872 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
18873 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
18874 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
18875 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
18876 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
18877 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
18878 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
18879 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
18880 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
18881 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
18882 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
18883 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
18884 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
18885 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
18886 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
18887 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
18888 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 18889 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
18890 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
18891 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
18892 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 18893 | |
18894 | /* "neighbor route-map" commands. */ | |
d6d7ed37 IR |
18895 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); |
18896 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
d62a17ae | 18897 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18898 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18899 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18900 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18901 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18902 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18903 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18904 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18905 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18906 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18907 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18908 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18909 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18910 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18911 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18912 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18913 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18914 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); |
7c40bf39 | 18915 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18916 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); |
d37ba549 | 18917 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
0ea8d871 | 18918 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); |
d62a17ae | 18919 | |
18920 | /* "neighbor unsuppress-map" commands. */ | |
18921 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
18922 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
18923 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
18924 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18925 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
18926 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18927 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
18928 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18929 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
18930 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18931 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
18932 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
18933 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
18934 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
18935 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
18936 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
18937 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
18938 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
18939 | ||
7f7940e6 | 18940 | /* "neighbor advertise-map" commands. */ |
389e4f92 | 18941 | install_element(BGP_NODE, &bgp_condadv_period_cmd); |
7f7940e6 | 18942 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); |
7f7940e6 | 18943 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18944 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18945 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18946 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18947 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18948 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18949 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18950 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); |
7f7940e6 | 18951 | |
fde246e8 DA |
18952 | /* neighbor maximum-prefix-out commands. */ |
18953 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
18954 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18955 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18956 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18957 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18958 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18959 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18960 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18961 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18962 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18963 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
18964 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18965 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
18966 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18967 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
18968 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18969 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
18970 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
18971 | ||
d62a17ae | 18972 | /* "neighbor maximum-prefix" commands. */ |
18973 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
18974 | install_element(BGP_NODE, | |
18975 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
18976 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
18977 | install_element(BGP_NODE, | |
18978 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
18979 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
18980 | install_element(BGP_NODE, | |
18981 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
18982 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
18983 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
18984 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18985 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18986 | install_element(BGP_IPV4_NODE, | |
18987 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18988 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18989 | install_element(BGP_IPV4_NODE, | |
18990 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
18991 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
18992 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
18993 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
18994 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
18995 | install_element(BGP_IPV4M_NODE, | |
18996 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
18997 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
18998 | install_element(BGP_IPV4M_NODE, | |
18999 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19000 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19001 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
19002 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19003 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19004 | install_element(BGP_IPV4L_NODE, | |
19005 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19006 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19007 | install_element(BGP_IPV4L_NODE, | |
19008 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19009 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19010 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
19011 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19012 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19013 | install_element(BGP_IPV6_NODE, | |
19014 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19015 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19016 | install_element(BGP_IPV6_NODE, | |
19017 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19018 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19019 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
19020 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19021 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19022 | install_element(BGP_IPV6M_NODE, | |
19023 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19024 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19025 | install_element(BGP_IPV6M_NODE, | |
19026 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19027 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
19028 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
19029 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19030 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19031 | install_element(BGP_IPV6L_NODE, | |
19032 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19033 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19034 | install_element(BGP_IPV6L_NODE, | |
19035 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19036 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
19037 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
19038 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19039 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19040 | install_element(BGP_VPNV4_NODE, | |
19041 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19042 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19043 | install_element(BGP_VPNV4_NODE, | |
19044 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19045 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
19046 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
19047 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
19048 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
19049 | install_element(BGP_VPNV6_NODE, | |
19050 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
19051 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
19052 | install_element(BGP_VPNV6_NODE, | |
19053 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
19054 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
19055 | ||
19056 | /* "neighbor allowas-in" */ | |
19057 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
19058 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
19059 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
19060 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
19061 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
19062 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
19063 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
19064 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
19065 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
19066 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
19067 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
19068 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
19069 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
19070 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
19071 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
19072 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
19073 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
19074 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
19075 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
19076 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
19077 | ||
19078 | /* address-family commands. */ | |
19079 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
19080 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 19081 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 19082 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
19083 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 19084 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 19085 | |
d62a17ae | 19086 | install_element(BGP_NODE, &address_family_evpn_cmd); |
19087 | ||
19088 | /* "exit-address-family" command. */ | |
19089 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
19090 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
19091 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
19092 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
19093 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
19094 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
19095 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
19096 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 19097 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
19098 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 19099 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
19100 | ||
19101 | /* "clear ip bgp commands" */ | |
19102 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
19103 | ||
19104 | /* clear ip bgp prefix */ | |
19105 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
19106 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
19107 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
19108 | ||
19109 | /* "show [ip] bgp summary" commands. */ | |
19110 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 19111 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 19112 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 19113 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 19114 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
19115 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 19116 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
19117 | ||
19118 | /* "show [ip] bgp neighbors" commands. */ | |
19119 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
19120 | ||
36235319 | 19121 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 19122 | |
d62a17ae | 19123 | /* "show [ip] bgp peer-group" commands. */ |
19124 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
19125 | ||
19126 | /* "show [ip] bgp paths" commands. */ | |
19127 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
19128 | ||
19129 | /* "show [ip] bgp community" commands. */ | |
19130 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
19131 | ||
19132 | /* "show ip bgp large-community" commands. */ | |
19133 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
19134 | /* "show [ip] bgp attribute-info" commands. */ | |
19135 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 19136 | /* "show [ip] bgp route-leak" command */ |
19137 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 19138 | |
19139 | /* "redistribute" commands. */ | |
19140 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
19141 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
19142 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
19143 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
19144 | install_element(BGP_NODE, | |
19145 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
19146 | install_element(BGP_NODE, | |
19147 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
19148 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19149 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
19150 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
19151 | install_element(BGP_NODE, | |
19152 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
19153 | install_element(BGP_NODE, | |
19154 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
19155 | install_element(BGP_NODE, | |
19156 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
19157 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
19158 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
19159 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
19160 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
19161 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
19162 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
19163 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
19164 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
19165 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
19166 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
19167 | install_element(BGP_IPV4_NODE, | |
19168 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
19169 | install_element(BGP_IPV4_NODE, | |
19170 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
19171 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
19172 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
19173 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
19174 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
19175 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
19176 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
19177 | ||
70dd370f | 19178 | /* import|export vpn [route-map RMAP_NAME] */ |
b9c7bc5a PZ |
19179 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); |
19180 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 19181 | |
12a844a5 DS |
19182 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
19183 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
19184 | ||
d62a17ae | 19185 | /* ttl_security commands */ |
19186 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
19187 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
19188 | ||
19189 | /* "show [ip] bgp memory" commands. */ | |
19190 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
19191 | ||
acf71666 MK |
19192 | /* "show bgp martian next-hop" */ |
19193 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
19194 | ||
48ecf8f5 DS |
19195 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
19196 | ||
d62a17ae | 19197 | /* "show [ip] bgp views" commands. */ |
19198 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
19199 | ||
19200 | /* "show [ip] bgp vrfs" commands. */ | |
19201 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
19202 | ||
19203 | /* Community-list. */ | |
19204 | community_list_vty(); | |
ddb5b488 | 19205 | |
ed0e57e3 DA |
19206 | community_alias_vty(); |
19207 | ||
ddb5b488 | 19208 | /* vpn-policy commands */ |
b9c7bc5a PZ |
19209 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
19210 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
19211 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
19212 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
19213 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
19214 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
19215 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
19216 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
19217 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
19218 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19219 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
19220 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 19221 | |
301ad80a PG |
19222 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
19223 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
19224 | ||
b9c7bc5a PZ |
19225 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
19226 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
19227 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
19228 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
19229 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
19230 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
19231 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
19232 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
19233 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
19234 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
4ab46701 AR |
19235 | |
19236 | /* tcp-mss command */ | |
19237 | install_element(BGP_NODE, &neighbor_tcp_mss_cmd); | |
19238 | install_element(BGP_NODE, &no_neighbor_tcp_mss_cmd); | |
bfaab44d HS |
19239 | |
19240 | /* srv6 commands */ | |
ea372e81 | 19241 | install_element(VIEW_NODE, &show_bgp_srv6_cmd); |
bfaab44d | 19242 | install_element(BGP_NODE, &bgp_segment_routing_srv6_cmd); |
0249b8b6 | 19243 | install_element(BGP_NODE, &no_bgp_segment_routing_srv6_cmd); |
a0281b2e | 19244 | install_element(BGP_SRV6_NODE, &bgp_srv6_locator_cmd); |
0249b8b6 | 19245 | install_element(BGP_SRV6_NODE, &no_bgp_srv6_locator_cmd); |
b72c9e14 HS |
19246 | install_element(BGP_IPV4_NODE, &af_sid_vpn_export_cmd); |
19247 | install_element(BGP_IPV6_NODE, &af_sid_vpn_export_cmd); | |
718e3744 | 19248 | } |
6b0655a2 | 19249 | |
718e3744 | 19250 | #include "memory.h" |
19251 | #include "bgp_regex.h" | |
19252 | #include "bgp_clist.h" | |
19253 | #include "bgp_ecommunity.h" | |
19254 | ||
19255 | /* VTY functions. */ | |
19256 | ||
19257 | /* Direction value to string conversion. */ | |
d62a17ae | 19258 | static const char *community_direct_str(int direct) |
19259 | { | |
19260 | switch (direct) { | |
19261 | case COMMUNITY_DENY: | |
19262 | return "deny"; | |
19263 | case COMMUNITY_PERMIT: | |
19264 | return "permit"; | |
19265 | default: | |
19266 | return "unknown"; | |
19267 | } | |
718e3744 | 19268 | } |
19269 | ||
19270 | /* Display error string. */ | |
d62a17ae | 19271 | static void community_list_perror(struct vty *vty, int ret) |
19272 | { | |
19273 | switch (ret) { | |
19274 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
19275 | vty_out(vty, "%% Can't find community-list\n"); | |
19276 | break; | |
19277 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
19278 | vty_out(vty, "%% Malformed community-list value\n"); | |
19279 | break; | |
19280 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
19281 | vty_out(vty, | |
19282 | "%% Community name conflict, previously defined as standard community\n"); | |
19283 | break; | |
19284 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
19285 | vty_out(vty, | |
19286 | "%% Community name conflict, previously defined as expanded community\n"); | |
19287 | break; | |
19288 | } | |
718e3744 | 19289 | } |
19290 | ||
5bf15956 DW |
19291 | /* "community-list" keyword help string. */ |
19292 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
19293 | ||
7336e101 SP |
19294 | /*community-list standard */ |
19295 | DEFUN (community_list_standard, | |
19296 | bgp_community_list_standard_cmd, | |
a2099c1d | 19297 | "bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19298 | BGP_STR |
718e3744 | 19299 | COMMUNITY_LIST_STR |
19300 | "Community list number (standard)\n" | |
5bf15956 | 19301 | "Add an standard community-list entry\n" |
718e3744 | 19302 | "Community list name\n" |
2f8cc0e5 DA |
19303 | "Sequence number of an entry\n" |
19304 | "Sequence number\n" | |
718e3744 | 19305 | "Specify community to reject\n" |
19306 | "Specify community to accept\n" | |
19307 | COMMUNITY_VAL_STR) | |
19308 | { | |
d62a17ae | 19309 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19310 | char *seq = NULL; |
d62a17ae | 19311 | int direct = 0; |
19312 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 19313 | int idx = 0; |
7336e101 | 19314 | |
e34627f9 | 19315 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19316 | seq = argv[idx]->arg; |
19317 | ||
19318 | idx = 0; | |
d62a17ae | 19319 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19320 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19321 | cl_name_or_number = argv[idx]->arg; |
19322 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19323 | : COMMUNITY_DENY; | |
19324 | argv_find(argv, argc, "AA:NN", &idx); | |
19325 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19326 | |
2f8cc0e5 DA |
19327 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19328 | direct, style); | |
42f914d4 | 19329 | |
d62a17ae | 19330 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19331 | |
d62a17ae | 19332 | if (ret < 0) { |
19333 | /* Display error string. */ | |
19334 | community_list_perror(vty, ret); | |
19335 | return CMD_WARNING_CONFIG_FAILED; | |
19336 | } | |
42f914d4 | 19337 | |
d62a17ae | 19338 | return CMD_SUCCESS; |
718e3744 | 19339 | } |
19340 | ||
7336e101 SP |
19341 | DEFUN (no_community_list_standard_all, |
19342 | no_bgp_community_list_standard_all_cmd, | |
a2099c1d | 19343 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19344 | NO_STR |
19345 | BGP_STR | |
19346 | COMMUNITY_LIST_STR | |
19347 | "Community list number (standard)\n" | |
19348 | "Add an standard community-list entry\n" | |
19349 | "Community list name\n" | |
2f8cc0e5 DA |
19350 | "Sequence number of an entry\n" |
19351 | "Sequence number\n" | |
7336e101 SP |
19352 | "Specify community to reject\n" |
19353 | "Specify community to accept\n" | |
19354 | COMMUNITY_VAL_STR) | |
718e3744 | 19355 | { |
d62a17ae | 19356 | char *cl_name_or_number = NULL; |
174b5cb9 | 19357 | char *str = NULL; |
d62a17ae | 19358 | int direct = 0; |
19359 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 19360 | char *seq = NULL; |
d62a17ae | 19361 | int idx = 0; |
7336e101 | 19362 | |
e34627f9 | 19363 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19364 | seq = argv[idx]->arg; |
19365 | ||
19366 | idx = 0; | |
174b5cb9 DA |
19367 | argv_find(argv, argc, "permit", &idx); |
19368 | argv_find(argv, argc, "deny", &idx); | |
19369 | ||
19370 | if (idx) { | |
19371 | direct = argv_find(argv, argc, "permit", &idx) | |
19372 | ? COMMUNITY_PERMIT | |
19373 | : COMMUNITY_DENY; | |
19374 | ||
19375 | idx = 0; | |
19376 | argv_find(argv, argc, "AA:NN", &idx); | |
19377 | str = argv_concat(argv, argc, idx); | |
19378 | } | |
19379 | ||
19380 | idx = 0; | |
d62a17ae | 19381 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 19382 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19383 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 19384 | |
2f8cc0e5 | 19385 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19386 | direct, style); |
42f914d4 | 19387 | |
d62a17ae | 19388 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19389 | |
d62a17ae | 19390 | if (ret < 0) { |
19391 | community_list_perror(vty, ret); | |
19392 | return CMD_WARNING_CONFIG_FAILED; | |
19393 | } | |
42f914d4 | 19394 | |
d62a17ae | 19395 | return CMD_SUCCESS; |
718e3744 | 19396 | } |
7336e101 | 19397 | |
174b5cb9 | 19398 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
a2099c1d | 19399 | "no bgp community-list <(1-99)|standard COMMUNITY_LIST_NAME>", |
174b5cb9 DA |
19400 | NO_STR BGP_STR COMMUNITY_LIST_STR |
19401 | "Community list number (standard)\n" | |
19402 | "Add an standard community-list entry\n" | |
19403 | "Community list name\n") | |
19404 | ||
7336e101 SP |
19405 | /*community-list expanded */ |
19406 | DEFUN (community_list_expanded_all, | |
19407 | bgp_community_list_expanded_all_cmd, | |
a2099c1d | 19408 | "bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19409 | BGP_STR |
19410 | COMMUNITY_LIST_STR | |
718e3744 | 19411 | "Community list number (expanded)\n" |
5bf15956 | 19412 | "Add an expanded community-list entry\n" |
718e3744 | 19413 | "Community list name\n" |
2f8cc0e5 DA |
19414 | "Sequence number of an entry\n" |
19415 | "Sequence number\n" | |
718e3744 | 19416 | "Specify community to reject\n" |
19417 | "Specify community to accept\n" | |
19418 | COMMUNITY_VAL_STR) | |
19419 | { | |
d62a17ae | 19420 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19421 | char *seq = NULL; |
d62a17ae | 19422 | int direct = 0; |
19423 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19424 | int idx = 0; |
7b9a4750 | 19425 | |
e34627f9 | 19426 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19427 | seq = argv[idx]->arg; |
19428 | ||
19429 | idx = 0; | |
19430 | ||
d62a17ae | 19431 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19432 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19433 | cl_name_or_number = argv[idx]->arg; |
19434 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
19435 | : COMMUNITY_DENY; | |
19436 | argv_find(argv, argc, "AA:NN", &idx); | |
19437 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 19438 | |
2f8cc0e5 DA |
19439 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
19440 | direct, style); | |
42f914d4 | 19441 | |
d62a17ae | 19442 | XFREE(MTYPE_TMP, str); |
42f914d4 | 19443 | |
d62a17ae | 19444 | if (ret < 0) { |
19445 | /* Display error string. */ | |
19446 | community_list_perror(vty, ret); | |
19447 | return CMD_WARNING_CONFIG_FAILED; | |
19448 | } | |
42f914d4 | 19449 | |
d62a17ae | 19450 | return CMD_SUCCESS; |
718e3744 | 19451 | } |
19452 | ||
7336e101 SP |
19453 | DEFUN (no_community_list_expanded_all, |
19454 | no_bgp_community_list_expanded_all_cmd, | |
a2099c1d | 19455 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
19456 | NO_STR |
19457 | BGP_STR | |
19458 | COMMUNITY_LIST_STR | |
19459 | "Community list number (expanded)\n" | |
19460 | "Add an expanded community-list entry\n" | |
19461 | "Community list name\n" | |
2f8cc0e5 DA |
19462 | "Sequence number of an entry\n" |
19463 | "Sequence number\n" | |
7336e101 SP |
19464 | "Specify community to reject\n" |
19465 | "Specify community to accept\n" | |
19466 | COMMUNITY_VAL_STR) | |
718e3744 | 19467 | { |
d62a17ae | 19468 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 19469 | char *seq = NULL; |
174b5cb9 | 19470 | char *str = NULL; |
d62a17ae | 19471 | int direct = 0; |
19472 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 19473 | int idx = 0; |
174b5cb9 | 19474 | |
e34627f9 | 19475 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
19476 | seq = argv[idx]->arg; |
19477 | ||
19478 | idx = 0; | |
174b5cb9 DA |
19479 | argv_find(argv, argc, "permit", &idx); |
19480 | argv_find(argv, argc, "deny", &idx); | |
19481 | ||
19482 | if (idx) { | |
19483 | direct = argv_find(argv, argc, "permit", &idx) | |
19484 | ? COMMUNITY_PERMIT | |
19485 | : COMMUNITY_DENY; | |
19486 | ||
19487 | idx = 0; | |
19488 | argv_find(argv, argc, "AA:NN", &idx); | |
19489 | str = argv_concat(argv, argc, idx); | |
7336e101 | 19490 | } |
174b5cb9 DA |
19491 | |
19492 | idx = 0; | |
d62a17ae | 19493 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 19494 | argv_find(argv, argc, "COMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19495 | cl_name_or_number = argv[idx]->arg; |
42f914d4 | 19496 | |
2f8cc0e5 | 19497 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 19498 | direct, style); |
42f914d4 | 19499 | |
d62a17ae | 19500 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 19501 | |
d62a17ae | 19502 | if (ret < 0) { |
19503 | community_list_perror(vty, ret); | |
19504 | return CMD_WARNING_CONFIG_FAILED; | |
19505 | } | |
42f914d4 | 19506 | |
d62a17ae | 19507 | return CMD_SUCCESS; |
718e3744 | 19508 | } |
19509 | ||
36d4bb44 EB |
19510 | ALIAS(no_community_list_expanded_all, |
19511 | no_bgp_community_list_expanded_all_list_cmd, | |
a2099c1d | 19512 | "no bgp community-list <(100-500)|expanded COMMUNITY_LIST_NAME>", |
36d4bb44 | 19513 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
19514 | "Community list number (expanded)\n" |
19515 | "Add an expanded community-list entry\n" | |
19516 | "Community list name\n") | |
19517 | ||
8d9b8ed9 PM |
19518 | /* Return configuration string of community-list entry. */ |
19519 | static const char *community_list_config_str(struct community_entry *entry) | |
19520 | { | |
19521 | const char *str; | |
19522 | ||
19523 | if (entry->any) | |
19524 | str = ""; | |
19525 | else { | |
19526 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
c0945b78 | 19527 | str = community_str(entry->u.com, false, false); |
8d9b8ed9 | 19528 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) |
c0945b78 | 19529 | str = lcommunity_str(entry->u.lcom, false, false); |
8d9b8ed9 PM |
19530 | else |
19531 | str = entry->config; | |
19532 | } | |
19533 | return str; | |
19534 | } | |
19535 | ||
d62a17ae | 19536 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 19537 | { |
d62a17ae | 19538 | struct community_entry *entry; |
718e3744 | 19539 | |
d62a17ae | 19540 | for (entry = list->head; entry; entry = entry->next) { |
19541 | if (entry == list->head) { | |
19542 | if (all_digit(list->name)) | |
19543 | vty_out(vty, "Community %s list %s\n", | |
19544 | entry->style == COMMUNITY_LIST_STANDARD | |
19545 | ? "standard" | |
19546 | : "(expanded) access", | |
19547 | list->name); | |
19548 | else | |
19549 | vty_out(vty, "Named Community %s list %s\n", | |
19550 | entry->style == COMMUNITY_LIST_STANDARD | |
19551 | ? "standard" | |
19552 | : "expanded", | |
19553 | list->name); | |
19554 | } | |
19555 | if (entry->any) | |
19556 | vty_out(vty, " %s\n", | |
19557 | community_direct_str(entry->direct)); | |
19558 | else | |
19559 | vty_out(vty, " %s %s\n", | |
19560 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19561 | community_list_config_str(entry)); |
d62a17ae | 19562 | } |
718e3744 | 19563 | } |
19564 | ||
7336e101 SP |
19565 | DEFUN (show_community_list, |
19566 | show_bgp_community_list_cmd, | |
19567 | "show bgp community-list", | |
718e3744 | 19568 | SHOW_STR |
7336e101 | 19569 | BGP_STR |
718e3744 | 19570 | "List community-list\n") |
19571 | { | |
d62a17ae | 19572 | struct community_list *list; |
19573 | struct community_list_master *cm; | |
718e3744 | 19574 | |
d62a17ae | 19575 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
19576 | if (!cm) | |
19577 | return CMD_SUCCESS; | |
718e3744 | 19578 | |
d62a17ae | 19579 | for (list = cm->num.head; list; list = list->next) |
19580 | community_list_show(vty, list); | |
718e3744 | 19581 | |
d62a17ae | 19582 | for (list = cm->str.head; list; list = list->next) |
19583 | community_list_show(vty, list); | |
718e3744 | 19584 | |
d62a17ae | 19585 | return CMD_SUCCESS; |
718e3744 | 19586 | } |
19587 | ||
7336e101 SP |
19588 | DEFUN (show_community_list_arg, |
19589 | show_bgp_community_list_arg_cmd, | |
a2099c1d | 19590 | "show bgp community-list <(1-500)|COMMUNITY_LIST_NAME> detail", |
7336e101 SP |
19591 | SHOW_STR |
19592 | BGP_STR | |
718e3744 | 19593 | "List community-list\n" |
19594 | "Community-list number\n" | |
960b69b9 | 19595 | "Community-list name\n" |
19596 | "Detailed information on community-list\n") | |
718e3744 | 19597 | { |
d62a17ae | 19598 | int idx_comm_list = 3; |
19599 | struct community_list *list; | |
718e3744 | 19600 | |
e237b0d2 | 19601 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 19602 | COMMUNITY_LIST_MASTER); |
19603 | if (!list) { | |
19604 | vty_out(vty, "%% Can't find community-list\n"); | |
19605 | return CMD_WARNING; | |
19606 | } | |
718e3744 | 19607 | |
d62a17ae | 19608 | community_list_show(vty, list); |
718e3744 | 19609 | |
d62a17ae | 19610 | return CMD_SUCCESS; |
718e3744 | 19611 | } |
6b0655a2 | 19612 | |
57d187bc JS |
19613 | /* |
19614 | * Large Community code. | |
19615 | */ | |
d62a17ae | 19616 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
19617 | struct cmd_token **argv, int style, | |
19618 | int reject_all_digit_name) | |
19619 | { | |
19620 | int ret; | |
19621 | int direct; | |
19622 | char *str; | |
19623 | int idx = 0; | |
19624 | char *cl_name; | |
2f8cc0e5 DA |
19625 | char *seq = NULL; |
19626 | ||
a08032fe | 19627 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19628 | seq = argv[idx]->arg; |
d62a17ae | 19629 | |
2f8cc0e5 | 19630 | idx = 0; |
d62a17ae | 19631 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
19632 | : COMMUNITY_DENY; | |
19633 | ||
19634 | /* All digit name check. */ | |
19635 | idx = 0; | |
a2099c1d | 19636 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19637 | argv_find(argv, argc, "(1-99)", &idx); |
19638 | argv_find(argv, argc, "(100-500)", &idx); | |
19639 | cl_name = argv[idx]->arg; | |
19640 | if (reject_all_digit_name && all_digit(cl_name)) { | |
19641 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
19642 | return CMD_WARNING_CONFIG_FAILED; | |
19643 | } | |
19644 | ||
19645 | idx = 0; | |
19646 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
19647 | argv_find(argv, argc, "LINE", &idx); | |
19648 | /* Concat community string argument. */ | |
19649 | if (idx) | |
19650 | str = argv_concat(argv, argc, idx); | |
19651 | else | |
19652 | str = NULL; | |
19653 | ||
2f8cc0e5 | 19654 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 19655 | |
19656 | /* Free temporary community list string allocated by | |
19657 | argv_concat(). */ | |
0a22ddfb | 19658 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19659 | |
19660 | if (ret < 0) { | |
19661 | community_list_perror(vty, ret); | |
19662 | return CMD_WARNING_CONFIG_FAILED; | |
19663 | } | |
19664 | return CMD_SUCCESS; | |
19665 | } | |
19666 | ||
19667 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
19668 | struct cmd_token **argv, int style) | |
19669 | { | |
19670 | int ret; | |
19671 | int direct = 0; | |
19672 | char *str = NULL; | |
19673 | int idx = 0; | |
2f8cc0e5 | 19674 | char *seq = NULL; |
d62a17ae | 19675 | |
a08032fe | 19676 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 | 19677 | seq = argv[idx]->arg; |
d62a17ae | 19678 | |
2f8cc0e5 | 19679 | idx = 0; |
d62a17ae | 19680 | argv_find(argv, argc, "permit", &idx); |
19681 | argv_find(argv, argc, "deny", &idx); | |
19682 | ||
19683 | if (idx) { | |
19684 | /* Check the list direct. */ | |
19685 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
19686 | direct = COMMUNITY_PERMIT; | |
19687 | else | |
19688 | direct = COMMUNITY_DENY; | |
19689 | ||
19690 | idx = 0; | |
19691 | argv_find(argv, argc, "LINE", &idx); | |
19692 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
19693 | /* Concat community string argument. */ | |
19694 | str = argv_concat(argv, argc, idx); | |
19695 | } | |
19696 | ||
19697 | idx = 0; | |
19698 | argv_find(argv, argc, "(1-99)", &idx); | |
19699 | argv_find(argv, argc, "(100-500)", &idx); | |
a2099c1d | 19700 | argv_find(argv, argc, "LCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 19701 | |
19702 | /* Unset community list. */ | |
2f8cc0e5 | 19703 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 19704 | style); |
19705 | ||
19706 | /* Free temporary community list string allocated by | |
19707 | argv_concat(). */ | |
0a22ddfb | 19708 | XFREE(MTYPE_TMP, str); |
d62a17ae | 19709 | |
19710 | if (ret < 0) { | |
19711 | community_list_perror(vty, ret); | |
19712 | return CMD_WARNING_CONFIG_FAILED; | |
19713 | } | |
19714 | ||
19715 | return CMD_SUCCESS; | |
57d187bc JS |
19716 | } |
19717 | ||
19718 | /* "large-community-list" keyword help string. */ | |
19719 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
19720 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
19721 | ||
7336e101 SP |
19722 | DEFUN (lcommunity_list_standard, |
19723 | bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19724 | "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19725 | BGP_STR |
19726 | LCOMMUNITY_LIST_STR | |
19727 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19728 | "Sequence number of an entry\n" |
19729 | "Sequence number\n" | |
7336e101 SP |
19730 | "Specify large community to reject\n" |
19731 | "Specify large community to accept\n" | |
19732 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19733 | { |
d62a17ae | 19734 | return lcommunity_list_set_vty(vty, argc, argv, |
19735 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
19736 | } |
19737 | ||
7336e101 SP |
19738 | DEFUN (lcommunity_list_expanded, |
19739 | bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19740 | "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19741 | BGP_STR |
19742 | LCOMMUNITY_LIST_STR | |
19743 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19744 | "Sequence number of an entry\n" |
19745 | "Sequence number\n" | |
7336e101 SP |
19746 | "Specify large community to reject\n" |
19747 | "Specify large community to accept\n" | |
19748 | "An ordered list as a regular-expression\n") | |
57d187bc | 19749 | { |
d62a17ae | 19750 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19751 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
19752 | } |
19753 | ||
7336e101 SP |
19754 | DEFUN (lcommunity_list_name_standard, |
19755 | bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 19756 | "bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
19757 | BGP_STR |
19758 | LCOMMUNITY_LIST_STR | |
19759 | "Specify standard large-community-list\n" | |
19760 | "Large Community list name\n" | |
2f8cc0e5 DA |
19761 | "Sequence number of an entry\n" |
19762 | "Sequence number\n" | |
7336e101 SP |
19763 | "Specify large community to reject\n" |
19764 | "Specify large community to accept\n" | |
19765 | LCOMMUNITY_VAL_STR) | |
52951b63 | 19766 | { |
d62a17ae | 19767 | return lcommunity_list_set_vty(vty, argc, argv, |
19768 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
19769 | } |
19770 | ||
7336e101 SP |
19771 | DEFUN (lcommunity_list_name_expanded, |
19772 | bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 19773 | "bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19774 | BGP_STR |
19775 | LCOMMUNITY_LIST_STR | |
19776 | "Specify expanded large-community-list\n" | |
19777 | "Large Community list name\n" | |
2f8cc0e5 DA |
19778 | "Sequence number of an entry\n" |
19779 | "Sequence number\n" | |
7336e101 SP |
19780 | "Specify large community to reject\n" |
19781 | "Specify large community to accept\n" | |
19782 | "An ordered list as a regular-expression\n") | |
57d187bc | 19783 | { |
d62a17ae | 19784 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 19785 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
19786 | } |
19787 | ||
4378f57c DA |
19788 | DEFUN (no_lcommunity_list_all, |
19789 | no_bgp_lcommunity_list_all_cmd, | |
a2099c1d | 19790 | "no bgp large-community-list <(1-99)|(100-500)|LCOMMUNITY_LIST_NAME>", |
7336e101 SP |
19791 | NO_STR |
19792 | BGP_STR | |
19793 | LCOMMUNITY_LIST_STR | |
19794 | "Large Community list number (standard)\n" | |
19795 | "Large Community list number (expanded)\n" | |
19796 | "Large Community list name\n") | |
57d187bc | 19797 | { |
7336e101 SP |
19798 | return lcommunity_list_unset_vty(vty, argc, argv, |
19799 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
19800 | } |
19801 | ||
4378f57c DA |
19802 | DEFUN (no_lcommunity_list_name_standard_all, |
19803 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
a2099c1d | 19804 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME", |
4378f57c DA |
19805 | NO_STR |
19806 | BGP_STR | |
19807 | LCOMMUNITY_LIST_STR | |
19808 | "Specify standard large-community-list\n" | |
19809 | "Large Community list name\n") | |
19810 | { | |
19811 | return lcommunity_list_unset_vty(vty, argc, argv, | |
19812 | LARGE_COMMUNITY_LIST_STANDARD); | |
19813 | } | |
19814 | ||
7336e101 SP |
19815 | DEFUN (no_lcommunity_list_name_expanded_all, |
19816 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
a2099c1d | 19817 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME", |
7336e101 SP |
19818 | NO_STR |
19819 | BGP_STR | |
19820 | LCOMMUNITY_LIST_STR | |
19821 | "Specify expanded large-community-list\n" | |
19822 | "Large Community list name\n") | |
57d187bc | 19823 | { |
d62a17ae | 19824 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19825 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19826 | } |
19827 | ||
7336e101 SP |
19828 | DEFUN (no_lcommunity_list_standard, |
19829 | no_bgp_lcommunity_list_standard_cmd, | |
a08032fe | 19830 | "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19831 | NO_STR |
19832 | BGP_STR | |
19833 | LCOMMUNITY_LIST_STR | |
19834 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
19835 | "Sequence number of an entry\n" |
19836 | "Sequence number\n" | |
7336e101 SP |
19837 | "Specify large community to reject\n" |
19838 | "Specify large community to accept\n" | |
19839 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19840 | { |
d62a17ae | 19841 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19842 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19843 | } |
19844 | ||
7336e101 SP |
19845 | DEFUN (no_lcommunity_list_expanded, |
19846 | no_bgp_lcommunity_list_expanded_cmd, | |
a08032fe | 19847 | "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19848 | NO_STR |
19849 | BGP_STR | |
19850 | LCOMMUNITY_LIST_STR | |
19851 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
19852 | "Sequence number of an entry\n" |
19853 | "Sequence number\n" | |
7336e101 SP |
19854 | "Specify large community to reject\n" |
19855 | "Specify large community to accept\n" | |
19856 | "An ordered list as a regular-expression\n") | |
57d187bc | 19857 | { |
d62a17ae | 19858 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19859 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19860 | } |
19861 | ||
7336e101 SP |
19862 | DEFUN (no_lcommunity_list_name_standard, |
19863 | no_bgp_lcommunity_list_name_standard_cmd, | |
a2099c1d | 19864 | "no bgp large-community-list standard LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
19865 | NO_STR |
19866 | BGP_STR | |
19867 | LCOMMUNITY_LIST_STR | |
19868 | "Specify standard large-community-list\n" | |
19869 | "Large Community list name\n" | |
2f8cc0e5 DA |
19870 | "Sequence number of an entry\n" |
19871 | "Sequence number\n" | |
7336e101 SP |
19872 | "Specify large community to reject\n" |
19873 | "Specify large community to accept\n" | |
19874 | LCOMMUNITY_VAL_STR) | |
57d187bc | 19875 | { |
d62a17ae | 19876 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19877 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
19878 | } |
19879 | ||
7336e101 SP |
19880 | DEFUN (no_lcommunity_list_name_expanded, |
19881 | no_bgp_lcommunity_list_name_expanded_cmd, | |
a2099c1d | 19882 | "no bgp large-community-list expanded LCOMMUNITY_LIST_NAME [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
19883 | NO_STR |
19884 | BGP_STR | |
19885 | LCOMMUNITY_LIST_STR | |
19886 | "Specify expanded large-community-list\n" | |
19887 | "Large community list name\n" | |
2f8cc0e5 DA |
19888 | "Sequence number of an entry\n" |
19889 | "Sequence number\n" | |
7336e101 SP |
19890 | "Specify large community to reject\n" |
19891 | "Specify large community to accept\n" | |
19892 | "An ordered list as a regular-expression\n") | |
57d187bc | 19893 | { |
d62a17ae | 19894 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 19895 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
19896 | } |
19897 | ||
d62a17ae | 19898 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
19899 | { | |
19900 | struct community_entry *entry; | |
19901 | ||
19902 | for (entry = list->head; entry; entry = entry->next) { | |
19903 | if (entry == list->head) { | |
19904 | if (all_digit(list->name)) | |
19905 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 19906 | entry->style == |
19907 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19908 | ? "standard" |
19909 | : "(expanded) access", | |
19910 | list->name); | |
19911 | else | |
19912 | vty_out(vty, | |
19913 | "Named large community %s list %s\n", | |
169b72c8 | 19914 | entry->style == |
19915 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 19916 | ? "standard" |
19917 | : "expanded", | |
19918 | list->name); | |
19919 | } | |
19920 | if (entry->any) | |
19921 | vty_out(vty, " %s\n", | |
19922 | community_direct_str(entry->direct)); | |
19923 | else | |
19924 | vty_out(vty, " %s %s\n", | |
19925 | community_direct_str(entry->direct), | |
8d9b8ed9 | 19926 | community_list_config_str(entry)); |
d62a17ae | 19927 | } |
57d187bc JS |
19928 | } |
19929 | ||
7336e101 SP |
19930 | DEFUN (show_lcommunity_list, |
19931 | show_bgp_lcommunity_list_cmd, | |
19932 | "show bgp large-community-list", | |
57d187bc | 19933 | SHOW_STR |
7336e101 | 19934 | BGP_STR |
57d187bc JS |
19935 | "List large-community list\n") |
19936 | { | |
d62a17ae | 19937 | struct community_list *list; |
19938 | struct community_list_master *cm; | |
57d187bc | 19939 | |
d62a17ae | 19940 | cm = community_list_master_lookup(bgp_clist, |
19941 | LARGE_COMMUNITY_LIST_MASTER); | |
19942 | if (!cm) | |
19943 | return CMD_SUCCESS; | |
57d187bc | 19944 | |
d62a17ae | 19945 | for (list = cm->num.head; list; list = list->next) |
19946 | lcommunity_list_show(vty, list); | |
57d187bc | 19947 | |
d62a17ae | 19948 | for (list = cm->str.head; list; list = list->next) |
19949 | lcommunity_list_show(vty, list); | |
57d187bc | 19950 | |
d62a17ae | 19951 | return CMD_SUCCESS; |
57d187bc JS |
19952 | } |
19953 | ||
7336e101 SP |
19954 | DEFUN (show_lcommunity_list_arg, |
19955 | show_bgp_lcommunity_list_arg_cmd, | |
a2099c1d | 19956 | "show bgp large-community-list <(1-500)|LCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
19957 | SHOW_STR |
19958 | BGP_STR | |
57d187bc | 19959 | "List large-community list\n" |
960b69b9 | 19960 | "Large-community-list number\n" |
19961 | "Large-community-list name\n" | |
19962 | "Detailed information on large-community-list\n") | |
57d187bc | 19963 | { |
d62a17ae | 19964 | struct community_list *list; |
57d187bc | 19965 | |
e237b0d2 | 19966 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 19967 | LARGE_COMMUNITY_LIST_MASTER); |
19968 | if (!list) { | |
960b69b9 | 19969 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 19970 | return CMD_WARNING; |
19971 | } | |
57d187bc | 19972 | |
d62a17ae | 19973 | lcommunity_list_show(vty, list); |
57d187bc | 19974 | |
d62a17ae | 19975 | return CMD_SUCCESS; |
57d187bc JS |
19976 | } |
19977 | ||
718e3744 | 19978 | /* "extcommunity-list" keyword help string. */ |
19979 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
19980 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
19981 | ||
7336e101 SP |
19982 | DEFUN (extcommunity_list_standard, |
19983 | bgp_extcommunity_list_standard_cmd, | |
a2099c1d | 19984 | "bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 19985 | BGP_STR |
718e3744 | 19986 | EXTCOMMUNITY_LIST_STR |
19987 | "Extended Community list number (standard)\n" | |
718e3744 | 19988 | "Specify standard extcommunity-list\n" |
5bf15956 | 19989 | "Community list name\n" |
2f8cc0e5 DA |
19990 | "Sequence number of an entry\n" |
19991 | "Sequence number\n" | |
718e3744 | 19992 | "Specify community to reject\n" |
19993 | "Specify community to accept\n" | |
19994 | EXTCOMMUNITY_VAL_STR) | |
19995 | { | |
d62a17ae | 19996 | int style = EXTCOMMUNITY_LIST_STANDARD; |
19997 | int direct = 0; | |
19998 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 19999 | char *seq = NULL; |
42f914d4 | 20000 | |
d62a17ae | 20001 | int idx = 0; |
7b9a4750 | 20002 | |
d62a17ae | 20003 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20004 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20005 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20006 | |
a08032fe | 20007 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20008 | seq = argv[idx]->arg; |
20009 | ||
d62a17ae | 20010 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20011 | : COMMUNITY_DENY; | |
20012 | argv_find(argv, argc, "AA:NN", &idx); | |
20013 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20014 | |
2f8cc0e5 | 20015 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20016 | direct, style); |
42f914d4 | 20017 | |
d62a17ae | 20018 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20019 | |
d62a17ae | 20020 | if (ret < 0) { |
20021 | community_list_perror(vty, ret); | |
20022 | return CMD_WARNING_CONFIG_FAILED; | |
20023 | } | |
42f914d4 | 20024 | |
d62a17ae | 20025 | return CMD_SUCCESS; |
718e3744 | 20026 | } |
20027 | ||
7336e101 SP |
20028 | DEFUN (extcommunity_list_name_expanded, |
20029 | bgp_extcommunity_list_name_expanded_cmd, | |
a2099c1d | 20030 | "bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20031 | BGP_STR |
20032 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 20033 | "Extended Community list number (expanded)\n" |
718e3744 | 20034 | "Specify expanded extcommunity-list\n" |
20035 | "Extended Community list name\n" | |
2f8cc0e5 DA |
20036 | "Sequence number of an entry\n" |
20037 | "Sequence number\n" | |
718e3744 | 20038 | "Specify community to reject\n" |
20039 | "Specify community to accept\n" | |
20040 | "An ordered list as a regular-expression\n") | |
20041 | { | |
d62a17ae | 20042 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20043 | int direct = 0; | |
20044 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 20045 | char *seq = NULL; |
d62a17ae | 20046 | int idx = 0; |
7336e101 | 20047 | |
d62a17ae | 20048 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20049 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20050 | cl_number_or_name = argv[idx]->arg; |
2f8cc0e5 | 20051 | |
a08032fe | 20052 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20053 | seq = argv[idx]->arg; |
20054 | ||
d62a17ae | 20055 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
20056 | : COMMUNITY_DENY; | |
20057 | argv_find(argv, argc, "LINE", &idx); | |
20058 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 20059 | |
2f8cc0e5 | 20060 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 20061 | direct, style); |
42f914d4 | 20062 | |
d62a17ae | 20063 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20064 | |
d62a17ae | 20065 | if (ret < 0) { |
20066 | community_list_perror(vty, ret); | |
20067 | return CMD_WARNING_CONFIG_FAILED; | |
20068 | } | |
42f914d4 | 20069 | |
d62a17ae | 20070 | return CMD_SUCCESS; |
718e3744 | 20071 | } |
20072 | ||
7336e101 SP |
20073 | DEFUN (no_extcommunity_list_standard_all, |
20074 | no_bgp_extcommunity_list_standard_all_cmd, | |
a2099c1d | 20075 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
20076 | NO_STR |
20077 | BGP_STR | |
20078 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 20079 | "Extended Community list number (standard)\n" |
718e3744 | 20080 | "Specify standard extcommunity-list\n" |
5bf15956 | 20081 | "Community list name\n" |
2f8cc0e5 DA |
20082 | "Sequence number of an entry\n" |
20083 | "Sequence number\n" | |
718e3744 | 20084 | "Specify community to reject\n" |
20085 | "Specify community to accept\n" | |
20086 | EXTCOMMUNITY_VAL_STR) | |
20087 | { | |
d62a17ae | 20088 | int style = EXTCOMMUNITY_LIST_STANDARD; |
20089 | int direct = 0; | |
20090 | char *cl_number_or_name = NULL; | |
d4455c89 | 20091 | char *str = NULL; |
2f8cc0e5 | 20092 | char *seq = NULL; |
d62a17ae | 20093 | int idx = 0; |
d4455c89 | 20094 | |
a08032fe | 20095 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20096 | seq = argv[idx]->arg; |
20097 | ||
20098 | idx = 0; | |
d4455c89 DA |
20099 | argv_find(argv, argc, "permit", &idx); |
20100 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
20101 | if (idx) { |
20102 | direct = argv_find(argv, argc, "permit", &idx) | |
20103 | ? COMMUNITY_PERMIT | |
20104 | : COMMUNITY_DENY; | |
20105 | ||
20106 | idx = 0; | |
20107 | argv_find(argv, argc, "AA:NN", &idx); | |
20108 | str = argv_concat(argv, argc, idx); | |
20109 | } | |
20110 | ||
20111 | idx = 0; | |
d62a17ae | 20112 | argv_find(argv, argc, "(1-99)", &idx); |
a2099c1d | 20113 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20114 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 20115 | |
d62a17ae | 20116 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20117 | seq, direct, style); |
42f914d4 | 20118 | |
d62a17ae | 20119 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20120 | |
d62a17ae | 20121 | if (ret < 0) { |
20122 | community_list_perror(vty, ret); | |
20123 | return CMD_WARNING_CONFIG_FAILED; | |
20124 | } | |
42f914d4 | 20125 | |
d62a17ae | 20126 | return CMD_SUCCESS; |
718e3744 | 20127 | } |
20128 | ||
d4455c89 DA |
20129 | ALIAS(no_extcommunity_list_standard_all, |
20130 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
a2099c1d | 20131 | "no bgp extcommunity-list <(1-99)|standard EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 20132 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20133 | "Extended Community list number (standard)\n" |
20134 | "Specify standard extcommunity-list\n" | |
20135 | "Community list name\n") | |
20136 | ||
7336e101 SP |
20137 | DEFUN (no_extcommunity_list_expanded_all, |
20138 | no_bgp_extcommunity_list_expanded_all_cmd, | |
a2099c1d | 20139 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME> [seq (0-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
20140 | NO_STR |
20141 | BGP_STR | |
20142 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 20143 | "Extended Community list number (expanded)\n" |
718e3744 | 20144 | "Specify expanded extcommunity-list\n" |
5bf15956 | 20145 | "Extended Community list name\n" |
2f8cc0e5 DA |
20146 | "Sequence number of an entry\n" |
20147 | "Sequence number\n" | |
718e3744 | 20148 | "Specify community to reject\n" |
20149 | "Specify community to accept\n" | |
20150 | "An ordered list as a regular-expression\n") | |
20151 | { | |
d62a17ae | 20152 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
20153 | int direct = 0; | |
20154 | char *cl_number_or_name = NULL; | |
d4455c89 | 20155 | char *str = NULL; |
2f8cc0e5 | 20156 | char *seq = NULL; |
d62a17ae | 20157 | int idx = 0; |
d4455c89 | 20158 | |
a08032fe | 20159 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
2f8cc0e5 DA |
20160 | seq = argv[idx]->arg; |
20161 | ||
20162 | idx = 0; | |
d4455c89 DA |
20163 | argv_find(argv, argc, "permit", &idx); |
20164 | argv_find(argv, argc, "deny", &idx); | |
20165 | ||
20166 | if (idx) { | |
20167 | direct = argv_find(argv, argc, "permit", &idx) | |
20168 | ? COMMUNITY_PERMIT | |
20169 | : COMMUNITY_DENY; | |
20170 | ||
20171 | idx = 0; | |
20172 | argv_find(argv, argc, "LINE", &idx); | |
20173 | str = argv_concat(argv, argc, idx); | |
20174 | } | |
20175 | ||
20176 | idx = 0; | |
d62a17ae | 20177 | argv_find(argv, argc, "(100-500)", &idx); |
a2099c1d | 20178 | argv_find(argv, argc, "EXTCOMMUNITY_LIST_NAME", &idx); |
d62a17ae | 20179 | cl_number_or_name = argv[idx]->arg; |
42f914d4 | 20180 | |
d62a17ae | 20181 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 20182 | seq, direct, style); |
42f914d4 | 20183 | |
d62a17ae | 20184 | XFREE(MTYPE_TMP, str); |
42f914d4 | 20185 | |
d62a17ae | 20186 | if (ret < 0) { |
20187 | community_list_perror(vty, ret); | |
20188 | return CMD_WARNING_CONFIG_FAILED; | |
20189 | } | |
42f914d4 | 20190 | |
d62a17ae | 20191 | return CMD_SUCCESS; |
718e3744 | 20192 | } |
20193 | ||
d4455c89 DA |
20194 | ALIAS(no_extcommunity_list_expanded_all, |
20195 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
a2099c1d | 20196 | "no bgp extcommunity-list <(100-500)|expanded EXTCOMMUNITY_LIST_NAME>", |
36d4bb44 | 20197 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
20198 | "Extended Community list number (expanded)\n" |
20199 | "Specify expanded extcommunity-list\n" | |
20200 | "Extended Community list name\n") | |
20201 | ||
d62a17ae | 20202 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 20203 | { |
d62a17ae | 20204 | struct community_entry *entry; |
718e3744 | 20205 | |
d62a17ae | 20206 | for (entry = list->head; entry; entry = entry->next) { |
20207 | if (entry == list->head) { | |
20208 | if (all_digit(list->name)) | |
20209 | vty_out(vty, "Extended community %s list %s\n", | |
20210 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20211 | ? "standard" | |
20212 | : "(expanded) access", | |
20213 | list->name); | |
20214 | else | |
20215 | vty_out(vty, | |
20216 | "Named extended community %s list %s\n", | |
20217 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
20218 | ? "standard" | |
20219 | : "expanded", | |
20220 | list->name); | |
20221 | } | |
20222 | if (entry->any) | |
20223 | vty_out(vty, " %s\n", | |
20224 | community_direct_str(entry->direct)); | |
20225 | else | |
20226 | vty_out(vty, " %s %s\n", | |
20227 | community_direct_str(entry->direct), | |
8d9b8ed9 | 20228 | community_list_config_str(entry)); |
d62a17ae | 20229 | } |
718e3744 | 20230 | } |
20231 | ||
7336e101 SP |
20232 | DEFUN (show_extcommunity_list, |
20233 | show_bgp_extcommunity_list_cmd, | |
20234 | "show bgp extcommunity-list", | |
718e3744 | 20235 | SHOW_STR |
7336e101 | 20236 | BGP_STR |
718e3744 | 20237 | "List extended-community list\n") |
20238 | { | |
d62a17ae | 20239 | struct community_list *list; |
20240 | struct community_list_master *cm; | |
718e3744 | 20241 | |
d62a17ae | 20242 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
20243 | if (!cm) | |
20244 | return CMD_SUCCESS; | |
718e3744 | 20245 | |
d62a17ae | 20246 | for (list = cm->num.head; list; list = list->next) |
20247 | extcommunity_list_show(vty, list); | |
718e3744 | 20248 | |
d62a17ae | 20249 | for (list = cm->str.head; list; list = list->next) |
20250 | extcommunity_list_show(vty, list); | |
718e3744 | 20251 | |
d62a17ae | 20252 | return CMD_SUCCESS; |
718e3744 | 20253 | } |
20254 | ||
7336e101 SP |
20255 | DEFUN (show_extcommunity_list_arg, |
20256 | show_bgp_extcommunity_list_arg_cmd, | |
a2099c1d | 20257 | "show bgp extcommunity-list <(1-500)|EXTCOMMUNITY_LIST_NAME> detail", |
7336e101 SP |
20258 | SHOW_STR |
20259 | BGP_STR | |
718e3744 | 20260 | "List extended-community list\n" |
20261 | "Extcommunity-list number\n" | |
960b69b9 | 20262 | "Extcommunity-list name\n" |
20263 | "Detailed information on extcommunity-list\n") | |
718e3744 | 20264 | { |
d62a17ae | 20265 | int idx_comm_list = 3; |
20266 | struct community_list *list; | |
718e3744 | 20267 | |
e237b0d2 | 20268 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 20269 | EXTCOMMUNITY_LIST_MASTER); |
20270 | if (!list) { | |
20271 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
20272 | return CMD_WARNING; | |
20273 | } | |
718e3744 | 20274 | |
d62a17ae | 20275 | extcommunity_list_show(vty, list); |
718e3744 | 20276 | |
d62a17ae | 20277 | return CMD_SUCCESS; |
718e3744 | 20278 | } |
6b0655a2 | 20279 | |
718e3744 | 20280 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 20281 | static int community_list_config_write(struct vty *vty) |
20282 | { | |
20283 | struct community_list *list; | |
20284 | struct community_entry *entry; | |
20285 | struct community_list_master *cm; | |
20286 | int write = 0; | |
20287 | ||
20288 | /* Community-list. */ | |
20289 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
20290 | ||
20291 | for (list = cm->num.head; list; list = list->next) | |
20292 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20293 | vty_out(vty, |
20294 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
20295 | list->name, entry->seq, | |
d62a17ae | 20296 | community_direct_str(entry->direct), |
20297 | community_list_config_str(entry)); | |
20298 | write++; | |
20299 | } | |
20300 | for (list = cm->str.head; list; list = list->next) | |
20301 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20302 | vty_out(vty, |
20303 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 20304 | entry->style == COMMUNITY_LIST_STANDARD |
20305 | ? "standard" | |
20306 | : "expanded", | |
2f8cc0e5 DA |
20307 | list->name, entry->seq, |
20308 | community_direct_str(entry->direct), | |
d62a17ae | 20309 | community_list_config_str(entry)); |
20310 | write++; | |
20311 | } | |
20312 | ||
20313 | /* Extcommunity-list. */ | |
20314 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
20315 | ||
20316 | for (list = cm->num.head; list; list = list->next) | |
20317 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
20318 | vty_out(vty, |
20319 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
20320 | list->name, entry->seq, | |
20321 | community_direct_str(entry->direct), | |
d62a17ae | 20322 | community_list_config_str(entry)); |
20323 | write++; | |
20324 | } | |
20325 | for (list = cm->str.head; list; list = list->next) | |
20326 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20327 | vty_out(vty, |
6cde4b45 | 20328 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 20329 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
20330 | ? "standard" | |
20331 | : "expanded", | |
2f8cc0e5 DA |
20332 | list->name, entry->seq, |
20333 | community_direct_str(entry->direct), | |
d62a17ae | 20334 | community_list_config_str(entry)); |
20335 | write++; | |
20336 | } | |
20337 | ||
20338 | ||
20339 | /* lcommunity-list. */ | |
20340 | cm = community_list_master_lookup(bgp_clist, | |
20341 | LARGE_COMMUNITY_LIST_MASTER); | |
20342 | ||
20343 | for (list = cm->num.head; list; list = list->next) | |
20344 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20345 | vty_out(vty, |
6cde4b45 | 20346 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
20347 | list->name, entry->seq, |
20348 | community_direct_str(entry->direct), | |
d62a17ae | 20349 | community_list_config_str(entry)); |
20350 | write++; | |
20351 | } | |
20352 | for (list = cm->str.head; list; list = list->next) | |
20353 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 20354 | vty_out(vty, |
6cde4b45 | 20355 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 20356 | |
d62a17ae | 20357 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
20358 | ? "standard" | |
20359 | : "expanded", | |
2f8cc0e5 | 20360 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 20361 | community_list_config_str(entry)); |
20362 | write++; | |
20363 | } | |
20364 | ||
20365 | return write; | |
20366 | } | |
20367 | ||
612c2c15 | 20368 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 20369 | static struct cmd_node community_list_node = { |
f4b8291f | 20370 | .name = "community list", |
62b346ee DL |
20371 | .node = COMMUNITY_LIST_NODE, |
20372 | .prompt = "", | |
612c2c15 | 20373 | .config_write = community_list_config_write, |
718e3744 | 20374 | }; |
20375 | ||
d62a17ae | 20376 | static void community_list_vty(void) |
20377 | { | |
612c2c15 | 20378 | install_node(&community_list_node); |
d62a17ae | 20379 | |
20380 | /* Community-list. */ | |
7336e101 SP |
20381 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
20382 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
20383 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 20384 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 20385 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 20386 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
20387 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
20388 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 20389 | |
20390 | /* Extcommunity-list. */ | |
7336e101 SP |
20391 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
20392 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
20393 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
20394 | install_element(CONFIG_NODE, |
20395 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 20396 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
20397 | install_element(CONFIG_NODE, |
20398 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
20399 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
20400 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 20401 | |
20402 | /* Large Community List */ | |
7336e101 | 20403 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
20404 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
20405 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 20406 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
20407 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
20408 | install_element(CONFIG_NODE, | |
20409 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
20410 | install_element(CONFIG_NODE, |
20411 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
20412 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
20413 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
20414 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
20415 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
20416 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
20417 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
225096bc DA |
20418 | |
20419 | bgp_community_list_command_completion_setup(); | |
5bf15956 | 20420 | } |
ed0e57e3 DA |
20421 | |
20422 | static struct cmd_node community_alias_node = { | |
20423 | .name = "community alias", | |
20424 | .node = COMMUNITY_ALIAS_NODE, | |
20425 | .prompt = "", | |
20426 | .config_write = bgp_community_alias_write, | |
20427 | }; | |
20428 | ||
20429 | void community_alias_vty(void) | |
20430 | { | |
20431 | install_node(&community_alias_node); | |
20432 | ||
20433 | /* Community-list. */ | |
20434 | install_element(CONFIG_NODE, &bgp_community_alias_cmd); | |
b4ad2fae DS |
20435 | |
20436 | bgp_community_alias_command_completion_setup(); | |
ed0e57e3 | 20437 | } |