]>
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" |
5cb5f4d0 | 25 | #include "lib_errors.h" |
ec0ab544 | 26 | #include "lib/zclient.h" |
718e3744 | 27 | #include "prefix.h" |
28 | #include "plist.h" | |
29 | #include "buffer.h" | |
30 | #include "linklist.h" | |
31 | #include "stream.h" | |
32 | #include "thread.h" | |
33 | #include "log.h" | |
3b8b1855 | 34 | #include "memory.h" |
1c0d8808 | 35 | #include "lib_vty.h" |
4bf6a362 | 36 | #include "hash.h" |
3f9c7369 | 37 | #include "queue.h" |
039f3a34 | 38 | #include "filter.h" |
5d5ba018 | 39 | #include "frrstr.h" |
718e3744 | 40 | |
41 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 42 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 43 | #include "bgpd/bgp_advertise.h" |
718e3744 | 44 | #include "bgpd/bgp_attr.h" |
45 | #include "bgpd/bgp_aspath.h" | |
46 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 47 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 48 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 49 | #include "bgpd/bgp_damp.h" |
718e3744 | 50 | #include "bgpd/bgp_debug.h" |
14454c9f | 51 | #include "bgpd/bgp_errors.h" |
e0701b79 | 52 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 53 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 54 | #include "bgpd/bgp_open.h" |
4bf6a362 | 55 | #include "bgpd/bgp_regex.h" |
718e3744 | 56 | #include "bgpd/bgp_route.h" |
c016b6c7 | 57 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 58 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 59 | #include "bgpd/bgp_table.h" |
94f2b392 | 60 | #include "bgpd/bgp_vty.h" |
165b5fff | 61 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 62 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 63 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 64 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 65 | #include "bgpd/bgp_io.h" |
94c2f693 | 66 | #include "bgpd/bgp_evpn.h" |
dd65f45e | 67 | #include "bgpd/bgp_evpn_vty.h" |
b5e140c8 | 68 | #include "bgpd/bgp_evpn_mh.h" |
dcc68b5e | 69 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 70 | #include "bgpd/bgp_mac.h" |
dd65f45e | 71 | #include "bgpd/bgp_flowspec.h" |
49e5a4a0 | 72 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
73 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
74 | #endif | |
75 | ||
ff8a8a7a CS |
76 | #include "northbound.h" |
77 | #include "northbound_cli.h" | |
78 | #include "bgpd/bgp_nb.h" | |
79 | ||
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 }, | |
5d5393b9 DL |
88 | ) |
89 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
4c1458b5 DL |
90 | { .val_bool = true, .match_profile = "datacenter", }, |
91 | { .val_bool = false }, | |
5d5393b9 | 92 | ) |
aef999a2 DA |
93 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME, |
94 | { .val_bool = true, .match_profile = "datacenter", }, | |
95 | { .val_bool = false }, | |
96 | ) | |
5d5393b9 | 97 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, |
4c1458b5 DL |
98 | { .val_bool = true, .match_profile = "datacenter", }, |
99 | { .val_bool = false }, | |
5d5393b9 DL |
100 | ) |
101 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
4c1458b5 DL |
102 | { .val_bool = true, .match_profile = "datacenter", }, |
103 | { .val_bool = false }, | |
5d5393b9 DL |
104 | ) |
105 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
106 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
107 | { .val_ulong = 120 }, | |
108 | ) | |
109 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
110 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
111 | { .val_ulong = 180 }, | |
112 | ) | |
113 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
114 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
115 | { .val_ulong = 60 }, | |
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 }, | |
121 | ) | |
5d5393b9 | 122 | |
dd65f45e DL |
123 | DEFINE_HOOK(bgp_inst_config_write, |
124 | (struct bgp *bgp, struct vty *vty), | |
125 | (bgp, vty)) | |
718e3744 | 126 | |
36235319 QY |
127 | #define GR_NO_OPER \ |
128 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
129 | #define GR_INVALID \ | |
130 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 131 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
132 | struct prefix *range, int exact); | |
133 | ||
055679e9 | 134 | /* Show BGP peer's information. */ |
135 | enum show_type { | |
136 | show_all, | |
137 | show_peer, | |
138 | show_ipv4_all, | |
139 | show_ipv6_all, | |
140 | show_ipv4_peer, | |
141 | show_ipv6_peer | |
142 | }; | |
143 | ||
36235319 QY |
144 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
145 | struct prefix *range, int exact); | |
2986cac2 | 146 | |
36235319 QY |
147 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
148 | struct bgp *bgp, | |
149 | bool use_json, | |
150 | json_object *json); | |
2986cac2 | 151 | |
36235319 QY |
152 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
153 | enum show_type type, | |
154 | const char *ip_str, | |
155 | afi_t afi, bool use_json); | |
2986cac2 | 156 | |
d62a17ae | 157 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
158 | { | |
159 | switch (afi) { | |
160 | case AFI_IP: | |
161 | switch (safi) { | |
162 | case SAFI_UNICAST: | |
163 | return BGP_IPV4_NODE; | |
d62a17ae | 164 | case SAFI_MULTICAST: |
165 | return BGP_IPV4M_NODE; | |
d62a17ae | 166 | case SAFI_LABELED_UNICAST: |
167 | return BGP_IPV4L_NODE; | |
d62a17ae | 168 | case SAFI_MPLS_VPN: |
169 | return BGP_VPNV4_NODE; | |
7c40bf39 | 170 | case SAFI_FLOWSPEC: |
171 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
172 | default: |
173 | /* not expected */ | |
174 | return BGP_IPV4_NODE; | |
d62a17ae | 175 | } |
176 | break; | |
177 | case AFI_IP6: | |
178 | switch (safi) { | |
179 | case SAFI_UNICAST: | |
180 | return BGP_IPV6_NODE; | |
d62a17ae | 181 | case SAFI_MULTICAST: |
182 | return BGP_IPV6M_NODE; | |
d62a17ae | 183 | case SAFI_LABELED_UNICAST: |
184 | return BGP_IPV6L_NODE; | |
d62a17ae | 185 | case SAFI_MPLS_VPN: |
186 | return BGP_VPNV6_NODE; | |
7c40bf39 | 187 | case SAFI_FLOWSPEC: |
188 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
189 | default: |
190 | /* not expected */ | |
191 | return BGP_IPV4_NODE; | |
d62a17ae | 192 | } |
193 | break; | |
194 | case AFI_L2VPN: | |
195 | return BGP_EVPN_NODE; | |
b26f891d | 196 | case AFI_UNSPEC: |
d62a17ae | 197 | case AFI_MAX: |
198 | // We should never be here but to clarify the switch statement.. | |
199 | return BGP_IPV4_NODE; | |
d62a17ae | 200 | } |
201 | ||
202 | // Impossible to happen | |
203 | return BGP_IPV4_NODE; | |
f51bae9c | 204 | } |
20eb8864 | 205 | |
5cb5f4d0 DD |
206 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
207 | { | |
208 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
209 | return "IPv4 Unicast"; | |
210 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
211 | return "IPv4 Multicast"; | |
212 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
213 | return "IPv4 Labeled Unicast"; | |
214 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
215 | return "IPv4 VPN"; | |
216 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
217 | return "IPv4 Encap"; | |
218 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
219 | return "IPv4 Flowspec"; | |
220 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
221 | return "IPv6 Unicast"; | |
222 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
223 | return "IPv6 Multicast"; | |
224 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
225 | return "IPv6 Labeled Unicast"; | |
226 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
227 | return "IPv6 VPN"; | |
228 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
229 | return "IPv6 Encap"; | |
230 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
231 | return "IPv6 Flowspec"; | |
232 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
233 | return "L2VPN EVPN"; | |
8e5509b0 | 234 | else |
5cb5f4d0 | 235 | return "Unknown"; |
5cb5f4d0 DD |
236 | } |
237 | ||
238 | /* | |
239 | * Please note that we have intentionally camelCased | |
240 | * the return strings here. So if you want | |
241 | * to use this function, please ensure you | |
242 | * are doing this within json output | |
243 | */ | |
244 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
245 | { | |
246 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
247 | return "ipv4Unicast"; | |
248 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
249 | return "ipv4Multicast"; | |
250 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
251 | return "ipv4LabeledUnicast"; | |
252 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
253 | return "ipv4Vpn"; | |
254 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
255 | return "ipv4Encap"; | |
256 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
257 | return "ipv4Flowspec"; | |
258 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
259 | return "ipv6Unicast"; | |
260 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
261 | return "ipv6Multicast"; | |
262 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
263 | return "ipv6LabeledUnicast"; | |
264 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
265 | return "ipv6Vpn"; | |
266 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
267 | return "ipv6Encap"; | |
268 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
269 | return "ipv6Flowspec"; | |
270 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
271 | return "l2VpnEvpn"; | |
8e5509b0 | 272 | else |
5cb5f4d0 | 273 | return "Unknown"; |
5cb5f4d0 DD |
274 | } |
275 | ||
718e3744 | 276 | /* Utility function to get address family from current node. */ |
d62a17ae | 277 | afi_t bgp_node_afi(struct vty *vty) |
278 | { | |
279 | afi_t afi; | |
280 | switch (vty->node) { | |
281 | case BGP_IPV6_NODE: | |
282 | case BGP_IPV6M_NODE: | |
283 | case BGP_IPV6L_NODE: | |
284 | case BGP_VPNV6_NODE: | |
7c40bf39 | 285 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 286 | afi = AFI_IP6; |
287 | break; | |
288 | case BGP_EVPN_NODE: | |
289 | afi = AFI_L2VPN; | |
290 | break; | |
291 | default: | |
292 | afi = AFI_IP; | |
293 | break; | |
294 | } | |
295 | return afi; | |
718e3744 | 296 | } |
297 | ||
298 | /* Utility function to get subsequent address family from current | |
299 | node. */ | |
d62a17ae | 300 | safi_t bgp_node_safi(struct vty *vty) |
301 | { | |
302 | safi_t safi; | |
303 | switch (vty->node) { | |
304 | case BGP_VPNV4_NODE: | |
305 | case BGP_VPNV6_NODE: | |
306 | safi = SAFI_MPLS_VPN; | |
307 | break; | |
308 | case BGP_IPV4M_NODE: | |
309 | case BGP_IPV6M_NODE: | |
310 | safi = SAFI_MULTICAST; | |
311 | break; | |
312 | case BGP_EVPN_NODE: | |
313 | safi = SAFI_EVPN; | |
314 | break; | |
315 | case BGP_IPV4L_NODE: | |
316 | case BGP_IPV6L_NODE: | |
317 | safi = SAFI_LABELED_UNICAST; | |
318 | break; | |
7c40bf39 | 319 | case BGP_FLOWSPECV4_NODE: |
320 | case BGP_FLOWSPECV6_NODE: | |
321 | safi = SAFI_FLOWSPEC; | |
322 | break; | |
d62a17ae | 323 | default: |
324 | safi = SAFI_UNICAST; | |
325 | break; | |
326 | } | |
327 | return safi; | |
718e3744 | 328 | } |
329 | ||
55f91488 QY |
330 | /** |
331 | * Converts an AFI in string form to afi_t | |
332 | * | |
333 | * @param afi string, one of | |
334 | * - "ipv4" | |
335 | * - "ipv6" | |
81cf0de5 | 336 | * - "l2vpn" |
55f91488 QY |
337 | * @return the corresponding afi_t |
338 | */ | |
d62a17ae | 339 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
340 | { | |
341 | afi_t afi = AFI_MAX; /* unknown */ | |
342 | if (strmatch(afi_str, "ipv4")) | |
343 | afi = AFI_IP; | |
344 | else if (strmatch(afi_str, "ipv6")) | |
345 | afi = AFI_IP6; | |
81cf0de5 CS |
346 | else if (strmatch(afi_str, "l2vpn")) |
347 | afi = AFI_L2VPN; | |
d62a17ae | 348 | return afi; |
349 | } | |
350 | ||
351 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
352 | afi_t *afi) | |
353 | { | |
354 | int ret = 0; | |
355 | if (argv_find(argv, argc, "ipv4", index)) { | |
356 | ret = 1; | |
357 | if (afi) | |
358 | *afi = AFI_IP; | |
359 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
360 | ret = 1; | |
361 | if (afi) | |
362 | *afi = AFI_IP6; | |
8688b3e7 DS |
363 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
364 | ret = 1; | |
365 | if (afi) | |
366 | *afi = AFI_L2VPN; | |
d62a17ae | 367 | } |
368 | return ret; | |
46f296b4 LB |
369 | } |
370 | ||
375a2e67 | 371 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 372 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
373 | { | |
374 | safi_t safi = SAFI_MAX; /* unknown */ | |
375 | if (strmatch(safi_str, "multicast")) | |
376 | safi = SAFI_MULTICAST; | |
377 | else if (strmatch(safi_str, "unicast")) | |
378 | safi = SAFI_UNICAST; | |
379 | else if (strmatch(safi_str, "vpn")) | |
380 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
381 | else if (strmatch(safi_str, "evpn")) |
382 | safi = SAFI_EVPN; | |
d62a17ae | 383 | else if (strmatch(safi_str, "labeled-unicast")) |
384 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 385 | else if (strmatch(safi_str, "flowspec")) |
386 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 387 | return safi; |
388 | } | |
389 | ||
390 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
391 | safi_t *safi) | |
392 | { | |
393 | int ret = 0; | |
394 | if (argv_find(argv, argc, "unicast", index)) { | |
395 | ret = 1; | |
396 | if (safi) | |
397 | *safi = SAFI_UNICAST; | |
398 | } else if (argv_find(argv, argc, "multicast", index)) { | |
399 | ret = 1; | |
400 | if (safi) | |
401 | *safi = SAFI_MULTICAST; | |
402 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
403 | ret = 1; | |
404 | if (safi) | |
405 | *safi = SAFI_LABELED_UNICAST; | |
406 | } else if (argv_find(argv, argc, "vpn", index)) { | |
407 | ret = 1; | |
408 | if (safi) | |
409 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
410 | } else if (argv_find(argv, argc, "evpn", index)) { |
411 | ret = 1; | |
412 | if (safi) | |
413 | *safi = SAFI_EVPN; | |
7c40bf39 | 414 | } else if (argv_find(argv, argc, "flowspec", index)) { |
415 | ret = 1; | |
416 | if (safi) | |
417 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 418 | } |
419 | return ret; | |
46f296b4 LB |
420 | } |
421 | ||
5d5393b9 DL |
422 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
423 | enum bgp_instance_type inst_type) | |
424 | { | |
425 | int ret = bgp_get(bgp, as, name, inst_type); | |
426 | ||
427 | if (ret == BGP_CREATED) { | |
428 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
429 | DFLT_BGP_CONNECT_RETRY); | |
430 | ||
431 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 432 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 433 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 434 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
aef999a2 DA |
435 | if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME) |
436 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME); | |
5d5393b9 | 437 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 438 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 439 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 440 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
441 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
442 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
5d5393b9 DL |
443 | |
444 | ret = BGP_SUCCESS; | |
445 | } | |
446 | return ret; | |
447 | } | |
448 | ||
7eeee51e | 449 | /* |
f212a857 | 450 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 451 | * |
f212a857 DS |
452 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
453 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
454 | * to appropriate values for the calling function. This is to allow the |
455 | * calling function to make decisions appropriate for the show command | |
456 | * that is being parsed. | |
457 | * | |
458 | * The show commands are generally of the form: | |
d62a17ae | 459 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
460 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
461 | * |
462 | * Since we use argv_find if the show command in particular doesn't have: | |
463 | * [ip] | |
18c57037 | 464 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 465 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
466 | * The command parsing should still be ok. |
467 | * | |
468 | * vty -> The vty for the command so we can output some useful data in | |
469 | * the event of a parse error in the vrf. | |
470 | * argv -> The command tokens | |
471 | * argc -> How many command tokens we have | |
d62a17ae | 472 | * idx -> The current place in the command, generally should be 0 for this |
473 | * function | |
7eeee51e DS |
474 | * afi -> The parsed afi if it was included in the show command, returned here |
475 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 476 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 477 | * use_json -> json is configured or not |
7eeee51e DS |
478 | * |
479 | * The function returns the correct location in the parse tree for the | |
480 | * last token found. | |
0e37c258 DS |
481 | * |
482 | * Returns 0 for failure to parse correctly, else the idx position of where | |
483 | * it found the last token. | |
7eeee51e | 484 | */ |
d62a17ae | 485 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
486 | struct cmd_token **argv, int argc, | |
487 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 488 | struct bgp **bgp, bool use_json) |
d62a17ae | 489 | { |
490 | char *vrf_name = NULL; | |
491 | ||
492 | assert(afi); | |
493 | assert(safi); | |
494 | assert(bgp); | |
495 | ||
496 | if (argv_find(argv, argc, "ip", idx)) | |
497 | *afi = AFI_IP; | |
498 | ||
9a8bdf1c | 499 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 500 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
501 | else if (argv_find(argv, argc, "vrf", idx)) { |
502 | vrf_name = argv[*idx + 1]->arg; | |
503 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
504 | vrf_name = NULL; | |
505 | } | |
506 | if (vrf_name) { | |
d62a17ae | 507 | if (strmatch(vrf_name, "all")) |
508 | *bgp = NULL; | |
509 | else { | |
510 | *bgp = bgp_lookup_by_name(vrf_name); | |
511 | if (!*bgp) { | |
52e5b8c4 SP |
512 | if (use_json) { |
513 | json_object *json = NULL; | |
514 | json = json_object_new_object(); | |
515 | json_object_string_add( | |
516 | json, "warning", | |
517 | "View/Vrf is unknown"); | |
518 | vty_out(vty, "%s\n", | |
519 | json_object_to_json_string_ext(json, | |
520 | JSON_C_TO_STRING_PRETTY)); | |
521 | json_object_free(json); | |
522 | } | |
ca61fd25 DS |
523 | else |
524 | vty_out(vty, "View/Vrf %s is unknown\n", | |
525 | vrf_name); | |
d62a17ae | 526 | *idx = 0; |
527 | return 0; | |
528 | } | |
529 | } | |
530 | } else { | |
531 | *bgp = bgp_get_default(); | |
532 | if (!*bgp) { | |
52e5b8c4 SP |
533 | if (use_json) { |
534 | json_object *json = NULL; | |
535 | json = json_object_new_object(); | |
536 | json_object_string_add( | |
537 | json, "warning", | |
538 | "Default BGP instance not found"); | |
539 | vty_out(vty, "%s\n", | |
540 | json_object_to_json_string_ext(json, | |
541 | JSON_C_TO_STRING_PRETTY)); | |
542 | json_object_free(json); | |
543 | } | |
ca61fd25 DS |
544 | else |
545 | vty_out(vty, | |
546 | "Default BGP instance not found\n"); | |
d62a17ae | 547 | *idx = 0; |
548 | return 0; | |
549 | } | |
550 | } | |
551 | ||
552 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
553 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
554 | ||
555 | *idx += 1; | |
556 | return *idx; | |
557 | } | |
558 | ||
3dc339cd | 559 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 560 | { |
561 | struct interface *ifp = NULL; | |
562 | ||
563 | if (su->sa.sa_family == AF_INET) | |
564 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
565 | else if (su->sa.sa_family == AF_INET6) | |
566 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
567 | su->sin6.sin6_scope_id, | |
568 | bgp->vrf_id); | |
569 | ||
570 | if (ifp) | |
3dc339cd | 571 | return true; |
d62a17ae | 572 | |
3dc339cd | 573 | return false; |
718e3744 | 574 | } |
575 | ||
576 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
577 | /* This is used only for configuration, so disallow if attempted on |
578 | * a dynamic neighbor. | |
579 | */ | |
d62a17ae | 580 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
581 | { | |
582 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
583 | int ret; | |
584 | union sockunion su; | |
585 | struct peer *peer; | |
586 | ||
587 | if (!bgp) { | |
588 | return NULL; | |
589 | } | |
590 | ||
591 | ret = str2sockunion(ip_str, &su); | |
592 | if (ret < 0) { | |
593 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
594 | if (!peer) { | |
595 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
596 | == NULL) { | |
597 | vty_out(vty, | |
598 | "%% Malformed address or name: %s\n", | |
599 | ip_str); | |
600 | return NULL; | |
601 | } | |
602 | } | |
603 | } else { | |
604 | peer = peer_lookup(bgp, &su); | |
605 | if (!peer) { | |
606 | vty_out(vty, | |
607 | "%% Specify remote-as or peer-group commands first\n"); | |
608 | return NULL; | |
609 | } | |
610 | if (peer_dynamic_neighbor(peer)) { | |
611 | vty_out(vty, | |
612 | "%% Operation not allowed on a dynamic neighbor\n"); | |
613 | return NULL; | |
614 | } | |
615 | } | |
616 | return peer; | |
718e3744 | 617 | } |
618 | ||
619 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
620 | /* This is used only for configuration, so disallow if attempted on |
621 | * a dynamic neighbor. | |
622 | */ | |
d62a17ae | 623 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
624 | { | |
625 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
626 | int ret; | |
627 | union sockunion su; | |
628 | struct peer *peer = NULL; | |
629 | struct peer_group *group = NULL; | |
630 | ||
631 | if (!bgp) { | |
632 | return NULL; | |
633 | } | |
634 | ||
635 | ret = str2sockunion(peer_str, &su); | |
636 | if (ret == 0) { | |
637 | /* IP address, locate peer. */ | |
638 | peer = peer_lookup(bgp, &su); | |
639 | } else { | |
640 | /* Not IP, could match either peer configured on interface or a | |
641 | * group. */ | |
642 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
643 | if (!peer) | |
644 | group = peer_group_lookup(bgp, peer_str); | |
645 | } | |
646 | ||
647 | if (peer) { | |
648 | if (peer_dynamic_neighbor(peer)) { | |
649 | vty_out(vty, | |
650 | "%% Operation not allowed on a dynamic neighbor\n"); | |
651 | return NULL; | |
652 | } | |
653 | ||
654 | return peer; | |
655 | } | |
656 | ||
657 | if (group) | |
658 | return group->conf; | |
659 | ||
660 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
661 | ||
662 | return NULL; | |
663 | } | |
664 | ||
665 | int bgp_vty_return(struct vty *vty, int ret) | |
666 | { | |
667 | const char *str = NULL; | |
668 | ||
669 | switch (ret) { | |
670 | case BGP_ERR_INVALID_VALUE: | |
671 | str = "Invalid value"; | |
672 | break; | |
673 | case BGP_ERR_INVALID_FLAG: | |
674 | str = "Invalid flag"; | |
675 | break; | |
676 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
677 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
678 | break; | |
679 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
680 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
681 | break; | |
682 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
683 | str = "Specify remote-as or peer-group remote AS first"; | |
684 | break; | |
685 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
686 | str = "Cannot change the peer-group. Deconfigure first"; | |
687 | break; | |
688 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
689 | str = "Peer is not a member of this peer-group"; | |
690 | break; | |
691 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
692 | str = "Prefix/distribute list can not co-exist"; | |
693 | break; | |
694 | case BGP_ERR_NOT_INTERNAL_PEER: | |
695 | str = "Invalid command. Not an internal neighbor"; | |
696 | break; | |
697 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
698 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
699 | break; | |
700 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
701 | str = "Local-AS allowed only for EBGP peers"; | |
702 | break; | |
703 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
704 | str = "Cannot have local-as same as BGP AS number"; | |
705 | break; | |
706 | case BGP_ERR_TCPSIG_FAILED: | |
707 | str = "Error while applying TCP-Sig to session(s)"; | |
708 | break; | |
709 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
710 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
711 | break; | |
712 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
713 | str = "ttl-security only allowed for EBGP peers"; | |
714 | break; | |
715 | case BGP_ERR_AS_OVERRIDE: | |
716 | str = "as-override cannot be configured for IBGP peers"; | |
717 | break; | |
718 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
719 | str = "Invalid limit for number of dynamic neighbors"; | |
720 | break; | |
721 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
722 | str = "Dynamic neighbor listen range already exists"; | |
723 | break; | |
724 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
725 | str = "Operation not allowed on a dynamic neighbor"; | |
726 | break; | |
727 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
728 | str = "Operation not allowed on a directly connected neighbor"; | |
729 | break; | |
730 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 731 | str = GR_INVALID; |
732 | break; | |
733 | case BGP_ERR_GR_INVALID_CMD: | |
734 | str = "The Graceful Restart command used is not valid at this moment."; | |
735 | break; | |
736 | case BGP_ERR_GR_OPERATION_FAILED: | |
737 | str = "The Graceful Restart Operation failed due to an err."; | |
738 | break; | |
739 | case BGP_GR_NO_OPERATION: | |
740 | str = GR_NO_OPER; | |
d62a17ae | 741 | break; |
742 | } | |
743 | if (str) { | |
744 | vty_out(vty, "%% %s\n", str); | |
745 | return CMD_WARNING_CONFIG_FAILED; | |
746 | } | |
747 | return CMD_SUCCESS; | |
718e3744 | 748 | } |
749 | ||
7aafcaca | 750 | /* BGP clear sort. */ |
d62a17ae | 751 | enum clear_sort { |
752 | clear_all, | |
753 | clear_peer, | |
754 | clear_group, | |
755 | clear_external, | |
756 | clear_as | |
7aafcaca DS |
757 | }; |
758 | ||
ff8a8a7a CS |
759 | static void bgp_clear_vty_error(struct peer *peer, afi_t afi, safi_t safi, |
760 | int error, char *errmsg, size_t errmsg_len) | |
d62a17ae | 761 | { |
762 | switch (error) { | |
763 | case BGP_ERR_AF_UNCONFIGURED: | |
ff8a8a7a CS |
764 | snprintf(errmsg, errmsg_len, |
765 | "%%BGP: Enable %s address family for the neighbor %s", | |
766 | get_afi_safi_str(afi, safi, false), peer->host); | |
d62a17ae | 767 | break; |
768 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
ff8a8a7a CS |
769 | snprintf( |
770 | errmsg, errmsg_len, | |
771 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig", | |
d62a17ae | 772 | peer->host); |
773 | break; | |
774 | default: | |
775 | break; | |
776 | } | |
7aafcaca DS |
777 | } |
778 | ||
dc912615 | 779 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 780 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
781 | { |
782 | int ret = 0; | |
783 | ||
784 | /* if afi/.safi not specified, spin thru all of them */ | |
785 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
786 | afi_t tmp_afi; | |
787 | safi_t tmp_safi; | |
788 | ||
789 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
790 | if (!peer->afc[tmp_afi][tmp_safi]) | |
791 | continue; | |
792 | ||
793 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 794 | ret = peer_clear(peer, nnode); |
dc912615 DS |
795 | else |
796 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
797 | stype); | |
798 | } | |
799 | /* if afi specified and safi not, spin thru safis on this afi */ | |
800 | } else if (safi == SAFI_UNSPEC) { | |
801 | safi_t tmp_safi; | |
802 | ||
803 | for (tmp_safi = SAFI_UNICAST; | |
804 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
805 | if (!peer->afc[afi][tmp_safi]) | |
806 | continue; | |
807 | ||
808 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 809 | ret = peer_clear(peer, nnode); |
dc912615 DS |
810 | else |
811 | ret = peer_clear_soft(peer, afi, | |
812 | tmp_safi, stype); | |
813 | } | |
814 | /* both afi/safi specified, let the caller know if not defined */ | |
815 | } else { | |
816 | if (!peer->afc[afi][safi]) | |
817 | return 1; | |
818 | ||
819 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 820 | ret = peer_clear(peer, nnode); |
dc912615 DS |
821 | else |
822 | ret = peer_clear_soft(peer, afi, safi, stype); | |
823 | } | |
824 | ||
825 | return ret; | |
826 | } | |
827 | ||
7aafcaca | 828 | /* `clear ip bgp' functions. */ |
ff8a8a7a | 829 | static int bgp_clear(struct bgp *bgp, afi_t afi, safi_t safi, |
d62a17ae | 830 | enum clear_sort sort, enum bgp_clear_type stype, |
ff8a8a7a | 831 | const char *arg, char *errmsg, size_t errmsg_len) |
d62a17ae | 832 | { |
dc912615 | 833 | int ret = 0; |
3ae8bfa5 | 834 | bool found = false; |
d62a17ae | 835 | struct peer *peer; |
dc95985f | 836 | |
837 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 838 | |
839 | /* Clear all neighbors. */ | |
840 | /* | |
841 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
842 | * nodes on the BGP instance as that may get freed if it is a |
843 | * doppelganger | |
d62a17ae | 844 | */ |
845 | if (sort == clear_all) { | |
846 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 847 | |
848 | bgp_peer_gr_flags_update(peer); | |
849 | ||
36235319 | 850 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 851 | gr_router_detected = true; |
852 | ||
c368171c | 853 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 854 | stype); |
d62a17ae | 855 | |
856 | if (ret < 0) | |
ff8a8a7a CS |
857 | bgp_clear_vty_error(peer, afi, safi, ret, |
858 | errmsg, errmsg_len); | |
dc95985f | 859 | } |
860 | ||
36235319 QY |
861 | if (gr_router_detected |
862 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 863 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
864 | } else if (!gr_router_detected |
865 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 866 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 867 | } |
d62a17ae | 868 | |
869 | /* This is to apply read-only mode on this clear. */ | |
870 | if (stype == BGP_CLEAR_SOFT_NONE) | |
871 | bgp->update_delay_over = 0; | |
872 | ||
873 | return CMD_SUCCESS; | |
7aafcaca DS |
874 | } |
875 | ||
3ae8bfa5 | 876 | /* Clear specified neighbor. */ |
d62a17ae | 877 | if (sort == clear_peer) { |
878 | union sockunion su; | |
d62a17ae | 879 | |
880 | /* Make sockunion for lookup. */ | |
881 | ret = str2sockunion(arg, &su); | |
882 | if (ret < 0) { | |
883 | peer = peer_lookup_by_conf_if(bgp, arg); | |
884 | if (!peer) { | |
885 | peer = peer_lookup_by_hostname(bgp, arg); | |
886 | if (!peer) { | |
ff8a8a7a CS |
887 | snprintf( |
888 | errmsg, errmsg_len, | |
889 | "Malformed address or name: %s", | |
d62a17ae | 890 | arg); |
891 | return CMD_WARNING; | |
892 | } | |
893 | } | |
894 | } else { | |
895 | peer = peer_lookup(bgp, &su); | |
896 | if (!peer) { | |
ff8a8a7a CS |
897 | snprintf(errmsg, errmsg_len, |
898 | "%%BGP: Unknown neighbor - \"%s\"", | |
899 | arg); | |
d62a17ae | 900 | return CMD_WARNING; |
901 | } | |
902 | } | |
7aafcaca | 903 | |
dc95985f | 904 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
905 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
906 | ||
dc912615 DS |
907 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
908 | ||
909 | /* if afi/safi not defined for this peer, let caller know */ | |
910 | if (ret == 1) | |
3ae8bfa5 | 911 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 912 | |
d62a17ae | 913 | if (ret < 0) |
ff8a8a7a CS |
914 | bgp_clear_vty_error(peer, afi, safi, ret, errmsg, |
915 | errmsg_len); | |
7aafcaca | 916 | |
d62a17ae | 917 | return CMD_SUCCESS; |
7aafcaca | 918 | } |
7aafcaca | 919 | |
3ae8bfa5 | 920 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 921 | if (sort == clear_group) { |
922 | struct peer_group *group; | |
7aafcaca | 923 | |
d62a17ae | 924 | group = peer_group_lookup(bgp, arg); |
925 | if (!group) { | |
ff8a8a7a CS |
926 | snprintf(errmsg, errmsg_len, |
927 | "%%BGP: No such peer-group %s", arg); | |
d62a17ae | 928 | return CMD_WARNING; |
929 | } | |
930 | ||
931 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 932 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 933 | |
d62a17ae | 934 | if (ret < 0) |
ff8a8a7a CS |
935 | bgp_clear_vty_error(peer, afi, safi, ret, |
936 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
937 | else |
938 | found = true; | |
d62a17ae | 939 | } |
3ae8bfa5 PM |
940 | |
941 | if (!found) | |
ff8a8a7a CS |
942 | snprintf( |
943 | errmsg, errmsg_len, | |
944 | "%%BGP: No %s peer belonging to peer-group %s is configured", | |
5cb5f4d0 | 945 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 946 | |
d62a17ae | 947 | return CMD_SUCCESS; |
7aafcaca | 948 | } |
7aafcaca | 949 | |
3ae8bfa5 | 950 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 951 | if (sort == clear_external) { |
952 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
953 | if (peer->sort == BGP_PEER_IBGP) | |
954 | continue; | |
7aafcaca | 955 | |
dc95985f | 956 | bgp_peer_gr_flags_update(peer); |
957 | ||
36235319 | 958 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 959 | gr_router_detected = true; |
dc95985f | 960 | |
c368171c | 961 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 962 | |
d62a17ae | 963 | if (ret < 0) |
ff8a8a7a CS |
964 | bgp_clear_vty_error(peer, afi, safi, ret, |
965 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
966 | else |
967 | found = true; | |
d62a17ae | 968 | } |
3ae8bfa5 | 969 | |
36235319 QY |
970 | if (gr_router_detected |
971 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 972 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
973 | } else if (!gr_router_detected |
974 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 975 | bgp_zebra_send_capabilities(bgp, true); |
976 | } | |
977 | ||
3ae8bfa5 | 978 | if (!found) |
ff8a8a7a CS |
979 | snprintf(errmsg, errmsg_len, |
980 | "%%BGP: No external %s peer is configured", | |
981 | get_afi_safi_str(afi, safi, false)); | |
3ae8bfa5 | 982 | |
d62a17ae | 983 | return CMD_SUCCESS; |
984 | } | |
985 | ||
3ae8bfa5 | 986 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 987 | if (sort == clear_as) { |
3ae8bfa5 | 988 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 989 | |
990 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
991 | if (peer->as != as) | |
992 | continue; | |
993 | ||
dc95985f | 994 | bgp_peer_gr_flags_update(peer); |
995 | ||
36235319 | 996 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 997 | gr_router_detected = true; |
dc95985f | 998 | |
c368171c | 999 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 1000 | |
1001 | if (ret < 0) | |
ff8a8a7a CS |
1002 | bgp_clear_vty_error(peer, afi, safi, ret, |
1003 | errmsg, errmsg_len); | |
3ae8bfa5 PM |
1004 | else |
1005 | found = true; | |
d62a17ae | 1006 | } |
3ae8bfa5 | 1007 | |
36235319 QY |
1008 | if (gr_router_detected |
1009 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 1010 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
1011 | } else if (!gr_router_detected |
1012 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 1013 | bgp_zebra_send_capabilities(bgp, true); |
1014 | } | |
1015 | ||
3ae8bfa5 | 1016 | if (!found) |
ff8a8a7a CS |
1017 | snprintf(errmsg, errmsg_len, |
1018 | "%%BGP: No %s peer is configured with AS %s", | |
1019 | get_afi_safi_str(afi, safi, false), arg); | |
3ae8bfa5 | 1020 | |
d62a17ae | 1021 | return CMD_SUCCESS; |
1022 | } | |
1023 | ||
1024 | return CMD_SUCCESS; | |
1025 | } | |
1026 | ||
ff8a8a7a CS |
1027 | static int bgp_clear_vty(const char *name, afi_t afi, safi_t safi, |
1028 | enum clear_sort sort, enum bgp_clear_type stype, | |
1029 | const char *arg, char *errmsg, size_t errmsg_len) | |
d62a17ae | 1030 | { |
1031 | struct bgp *bgp; | |
1032 | ||
1033 | /* BGP structure lookup. */ | |
1034 | if (name) { | |
1035 | bgp = bgp_lookup_by_name(name); | |
1036 | if (bgp == NULL) { | |
ff8a8a7a CS |
1037 | snprintf(errmsg, errmsg_len, |
1038 | "Can't find BGP instance %s", name); | |
d62a17ae | 1039 | return CMD_WARNING; |
1040 | } | |
1041 | } else { | |
1042 | bgp = bgp_get_default(); | |
1043 | if (bgp == NULL) { | |
ff8a8a7a CS |
1044 | snprintf(errmsg, errmsg_len, |
1045 | "No BGP process is configured"); | |
d62a17ae | 1046 | return CMD_WARNING; |
1047 | } | |
1048 | } | |
1049 | ||
ff8a8a7a | 1050 | return bgp_clear(bgp, afi, safi, sort, stype, arg, errmsg, errmsg_len); |
7aafcaca DS |
1051 | } |
1052 | ||
1053 | /* clear soft inbound */ | |
ff8a8a7a | 1054 | int bgp_clear_star_soft_in(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1055 | { |
99b3ebd3 NS |
1056 | afi_t afi; |
1057 | safi_t safi; | |
ff8a8a7a CS |
1058 | int ret; |
1059 | ||
1060 | FOREACH_AFI_SAFI (afi, safi) { | |
1061 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1062 | BGP_CLEAR_SOFT_IN, NULL, errmsg, | |
1063 | errmsg_len); | |
1064 | if (ret != CMD_SUCCESS) | |
1065 | return -1; | |
1066 | } | |
99b3ebd3 | 1067 | |
ff8a8a7a | 1068 | return 0; |
7aafcaca DS |
1069 | } |
1070 | ||
1071 | /* clear soft outbound */ | |
ff8a8a7a | 1072 | int bgp_clear_star_soft_out(const char *name, char *errmsg, size_t errmsg_len) |
7aafcaca | 1073 | { |
99b3ebd3 NS |
1074 | afi_t afi; |
1075 | safi_t safi; | |
ff8a8a7a | 1076 | int ret; |
99b3ebd3 | 1077 | |
ff8a8a7a CS |
1078 | FOREACH_AFI_SAFI (afi, safi) { |
1079 | ret = bgp_clear_vty(name, afi, safi, clear_all, | |
1080 | BGP_CLEAR_SOFT_OUT, NULL, errmsg, | |
1081 | errmsg_len); | |
1082 | if (ret != CMD_SUCCESS) | |
1083 | return -1; | |
1084 | } | |
1085 | ||
1086 | return 0; | |
7aafcaca DS |
1087 | } |
1088 | ||
1089 | ||
f787d7a0 | 1090 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1091 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1092 | #endif |
1093 | ||
8029b216 AK |
1094 | DEFUN_HIDDEN (bgp_local_mac, |
1095 | bgp_local_mac_cmd, | |
093e3f23 | 1096 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1097 | BGP_STR |
1098 | "Local MAC config\n" | |
1099 | "VxLAN Network Identifier\n" | |
1100 | "VNI number\n" | |
1101 | "local mac\n" | |
1102 | "mac address\n" | |
1103 | "mac-mobility sequence\n" | |
1104 | "seq number\n") | |
1105 | { | |
1106 | int rv; | |
1107 | vni_t vni; | |
1108 | struct ethaddr mac; | |
1109 | struct ipaddr ip; | |
1110 | uint32_t seq; | |
1111 | struct bgp *bgp; | |
1112 | ||
1113 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1114 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1115 | vty_out(vty, "%% Malformed MAC address\n"); | |
1116 | return CMD_WARNING; | |
1117 | } | |
1118 | memset(&ip, 0, sizeof(ip)); | |
1119 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1120 | ||
1121 | bgp = bgp_get_default(); | |
1122 | if (!bgp) { | |
1123 | vty_out(vty, "Default BGP instance is not there\n"); | |
1124 | return CMD_WARNING; | |
1125 | } | |
1126 | ||
b5e140c8 AK |
1127 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq, |
1128 | zero_esi); | |
8029b216 AK |
1129 | if (rv < 0) { |
1130 | vty_out(vty, "Internal error\n"); | |
1131 | return CMD_WARNING; | |
1132 | } | |
1133 | ||
1134 | return CMD_SUCCESS; | |
1135 | } | |
1136 | ||
1137 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1138 | no_bgp_local_mac_cmd, | |
093e3f23 | 1139 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1140 | NO_STR |
1141 | BGP_STR | |
1142 | "Local MAC config\n" | |
1143 | "VxLAN Network Identifier\n" | |
1144 | "VNI number\n" | |
1145 | "local mac\n" | |
1146 | "mac address\n") | |
1147 | { | |
1148 | int rv; | |
1149 | vni_t vni; | |
1150 | struct ethaddr mac; | |
1151 | struct ipaddr ip; | |
1152 | struct bgp *bgp; | |
1153 | ||
1154 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1155 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1156 | vty_out(vty, "%% Malformed MAC address\n"); | |
1157 | return CMD_WARNING; | |
1158 | } | |
1159 | memset(&ip, 0, sizeof(ip)); | |
1160 | ||
1161 | bgp = bgp_get_default(); | |
1162 | if (!bgp) { | |
1163 | vty_out(vty, "Default BGP instance is not there\n"); | |
1164 | return CMD_WARNING; | |
1165 | } | |
1166 | ||
ec0ab544 | 1167 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1168 | if (rv < 0) { |
1169 | vty_out(vty, "Internal error\n"); | |
1170 | return CMD_WARNING; | |
1171 | } | |
1172 | ||
1173 | return CMD_SUCCESS; | |
1174 | } | |
1175 | ||
718e3744 | 1176 | DEFUN (no_synchronization, |
1177 | no_synchronization_cmd, | |
1178 | "no synchronization", | |
1179 | NO_STR | |
1180 | "Perform IGP synchronization\n") | |
1181 | { | |
d62a17ae | 1182 | return CMD_SUCCESS; |
718e3744 | 1183 | } |
1184 | ||
1185 | DEFUN (no_auto_summary, | |
1186 | no_auto_summary_cmd, | |
1187 | "no auto-summary", | |
1188 | NO_STR | |
1189 | "Enable automatic network number summarization\n") | |
1190 | { | |
d62a17ae | 1191 | return CMD_SUCCESS; |
718e3744 | 1192 | } |
3d515fd9 | 1193 | |
718e3744 | 1194 | /* "router bgp" commands. */ |
ff8a8a7a CS |
1195 | DEFUN_YANG_NOSH(router_bgp, |
1196 | router_bgp_cmd, | |
1197 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1198 | ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1199 | { |
d62a17ae | 1200 | int idx_asn = 2; |
1201 | int idx_view_vrf = 3; | |
1202 | int idx_vrf = 4; | |
ff8a8a7a | 1203 | int ret = CMD_SUCCESS; |
d62a17ae | 1204 | as_t as; |
1205 | struct bgp *bgp; | |
1206 | const char *name = NULL; | |
ff8a8a7a | 1207 | char as_str[12] = {'\0'}; |
d62a17ae | 1208 | enum bgp_instance_type inst_type; |
ff8a8a7a | 1209 | char base_xpath[XPATH_MAXLEN]; |
d62a17ae | 1210 | |
1211 | // "router bgp" without an ASN | |
1212 | if (argc == 2) { | |
1213 | // Pending: Make VRF option available for ASN less config | |
1214 | bgp = bgp_get_default(); | |
1215 | ||
1216 | if (bgp == NULL) { | |
1217 | vty_out(vty, "%% No BGP process is configured\n"); | |
1218 | return CMD_WARNING_CONFIG_FAILED; | |
1219 | } | |
1220 | ||
1221 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1222 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1223 | return CMD_WARNING_CONFIG_FAILED; |
1224 | } | |
ff8a8a7a CS |
1225 | |
1226 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, | |
5ce106b7 | 1227 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); |
ff8a8a7a CS |
1228 | |
1229 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
1230 | snprintf(as_str, 12, "%d", bgp->as); | |
87ce2564 CS |
1231 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
1232 | as_str); | |
ff8a8a7a | 1233 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) { |
87ce2564 CS |
1234 | nb_cli_enqueue_change(vty, |
1235 | "./global/instance-type-view", | |
ff8a8a7a CS |
1236 | NB_OP_MODIFY, "true"); |
1237 | } | |
1238 | ||
a5ab756f | 1239 | nb_cli_pending_commit_check(vty); |
ff8a8a7a CS |
1240 | ret = nb_cli_apply_changes(vty, base_xpath); |
1241 | if (ret == CMD_SUCCESS) { | |
1242 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
1243 | ||
1244 | /* | |
1245 | * For backward compatibility with old commands we still | |
1246 | * need to use the qobj infrastructure. | |
1247 | */ | |
1248 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1249 | } | |
1250 | return ret; | |
d62a17ae | 1251 | } |
1252 | ||
1253 | // "router bgp X" | |
1254 | else { | |
d62a17ae | 1255 | |
ff8a8a7a | 1256 | as = strtoul(argv[idx_asn]->arg, NULL, 10); |
d62a17ae | 1257 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
1258 | if (argc > 3) { | |
1259 | name = argv[idx_vrf]->arg; | |
1260 | ||
9a8bdf1c PG |
1261 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1262 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1263 | name = NULL; | |
1264 | else | |
1265 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
ff8a8a7a | 1266 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) { |
d62a17ae | 1267 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
ff8a8a7a | 1268 | } |
d62a17ae | 1269 | } |
ff8a8a7a CS |
1270 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1271 | "frr-bgp:bgp", "bgp", name ? name : VRF_DEFAULT_NAME); | |
1272 | ||
1273 | nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); | |
87ce2564 | 1274 | nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY, |
ff8a8a7a CS |
1275 | argv[idx_asn]->arg); |
1276 | if (inst_type == BGP_INSTANCE_TYPE_VIEW) { | |
87ce2564 CS |
1277 | nb_cli_enqueue_change(vty, |
1278 | "./global/instance-type-view", | |
ff8a8a7a | 1279 | NB_OP_MODIFY, "true"); |
d62a17ae | 1280 | } |
1281 | ||
ff8a8a7a CS |
1282 | nb_cli_pending_commit_check(vty); |
1283 | ret = nb_cli_apply_changes(vty, base_xpath); | |
1284 | if (ret == CMD_SUCCESS) { | |
1285 | VTY_PUSH_XPATH(BGP_NODE, base_xpath); | |
3bd70bf8 | 1286 | |
ff8a8a7a CS |
1287 | /* |
1288 | * For backward compatibility with old commands we still | |
1289 | * need to use the qobj infrastructure. | |
1290 | */ | |
1291 | bgp = bgp_lookup(as, name); | |
1292 | if (bgp) | |
1293 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
1294 | } | |
d62a17ae | 1295 | } |
1296 | ||
ff8a8a7a | 1297 | return ret; |
718e3744 | 1298 | } |
1299 | ||
718e3744 | 1300 | /* "no router bgp" commands. */ |
ff8a8a7a CS |
1301 | DEFUN_YANG(no_router_bgp, |
1302 | no_router_bgp_cmd, | |
1303 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", | |
1304 | NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR) | |
718e3744 | 1305 | { |
d62a17ae | 1306 | int idx_asn = 3; |
1307 | int idx_vrf = 5; | |
ff8a8a7a | 1308 | as_t as = 0; |
d62a17ae | 1309 | struct bgp *bgp; |
1310 | const char *name = NULL; | |
ff8a8a7a | 1311 | char base_xpath[XPATH_MAXLEN]; |
4b63e358 | 1312 | const struct lyd_node *bgp_glb_dnode; |
718e3744 | 1313 | |
d62a17ae | 1314 | // "no router bgp" without an ASN |
1315 | if (argc == 3) { | |
1316 | // Pending: Make VRF option available for ASN less config | |
4b63e358 CS |
1317 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1318 | "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); | |
718e3744 | 1319 | |
4b63e358 CS |
1320 | bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, |
1321 | base_xpath); | |
1322 | if (!bgp_glb_dnode) { | |
d62a17ae | 1323 | vty_out(vty, "%% No BGP process is configured\n"); |
1324 | return CMD_WARNING_CONFIG_FAILED; | |
1325 | } | |
7fb21a9f | 1326 | |
d62a17ae | 1327 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1328 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1329 | return CMD_WARNING_CONFIG_FAILED; |
1330 | } | |
0b5131c9 | 1331 | |
4b63e358 CS |
1332 | /* tcli mode bgp would not be set until apply stage. */ |
1333 | bgp = nb_running_get_entry(bgp_glb_dnode, NULL, false); | |
1334 | if (!bgp) | |
1335 | return CMD_SUCCESS; | |
1336 | ||
0b5131c9 MK |
1337 | if (bgp->l3vni) { |
1338 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1339 | bgp->l3vni); | |
1340 | return CMD_WARNING_CONFIG_FAILED; | |
1341 | } | |
d62a17ae | 1342 | } else { |
1343 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1344 | |
d62a17ae | 1345 | if (argc > 4) |
1346 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1347 | |
d62a17ae | 1348 | /* Lookup bgp structure. */ |
1349 | bgp = bgp_lookup(as, name); | |
1350 | if (!bgp) { | |
1351 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1352 | return CMD_WARNING_CONFIG_FAILED; | |
1353 | } | |
0b5131c9 MK |
1354 | |
1355 | if (bgp->l3vni) { | |
dd5868c2 | 1356 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1357 | bgp->l3vni); |
1358 | return CMD_WARNING_CONFIG_FAILED; | |
1359 | } | |
dd5868c2 DS |
1360 | |
1361 | /* Cannot delete default instance if vrf instances exist */ | |
1362 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1363 | struct listnode *node; | |
1364 | struct bgp *tmp_bgp; | |
1365 | ||
1366 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1367 | if (tmp_bgp->inst_type | |
1368 | == BGP_INSTANCE_TYPE_VRF) { | |
1369 | vty_out(vty, | |
1370 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1371 | return CMD_WARNING_CONFIG_FAILED; | |
1372 | } | |
1373 | } | |
1374 | } | |
d62a17ae | 1375 | } |
ff8a8a7a CS |
1376 | snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, |
1377 | "frr-bgp:bgp", "bgp", | |
1378 | bgp->name ? bgp->name : VRF_DEFAULT_NAME); | |
718e3744 | 1379 | |
ff8a8a7a | 1380 | nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); |
718e3744 | 1381 | |
ff8a8a7a | 1382 | return nb_cli_apply_changes(vty, base_xpath); |
718e3744 | 1383 | } |
1384 | ||
ff8a8a7a CS |
1385 | void cli_show_router_bgp(struct vty *vty, struct lyd_node *dnode, |
1386 | bool show_defaults) | |
1387 | { | |
1388 | const struct lyd_node *vrf_dnode; | |
1389 | const char *vrf_name; | |
1390 | as_t as; | |
6b0655a2 | 1391 | |
ff8a8a7a CS |
1392 | vrf_dnode = yang_dnode_get_parent(dnode, "control-plane-protocol"); |
1393 | vrf_name = yang_dnode_get_string(vrf_dnode, "./vrf"); | |
5e42cb2f | 1394 | as = yang_dnode_get_uint32(dnode, "./global/local-as"); |
718e3744 | 1395 | |
ff8a8a7a CS |
1396 | vty_out(vty, "!\n"); |
1397 | vty_out(vty, "router bgp %u", as); | |
1398 | if (!strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
1399 | vty_out(vty, " vrf %s", vrf_name); | |
1400 | vty_out(vty, "\n"); | |
718e3744 | 1401 | } |
1402 | ||
ff8a8a7a CS |
1403 | /* BGP router-id. */ |
1404 | ||
1405 | DEFPY_YANG(bgp_router_id, bgp_router_id_cmd, "bgp router-id A.B.C.D", | |
1406 | BGP_STR | |
1407 | "Override configured router identifier\n" | |
1408 | "Manually configured router identifier\n") | |
718e3744 | 1409 | { |
87ce2564 CS |
1410 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_MODIFY, |
1411 | router_id_str); | |
718e3744 | 1412 | |
ff8a8a7a CS |
1413 | return nb_cli_apply_changes(vty, NULL); |
1414 | } | |
718e3744 | 1415 | |
ff8a8a7a CS |
1416 | DEFPY_YANG(no_bgp_router_id, no_bgp_router_id_cmd, "no bgp router-id [A.B.C.D]", |
1417 | NO_STR BGP_STR | |
1418 | "Override configured router identifier\n" | |
1419 | "Manually configured router identifier\n") | |
1420 | { | |
87ce2564 | 1421 | nb_cli_enqueue_change(vty, "./global/router-id", NB_OP_DESTROY, |
ff8a8a7a | 1422 | router_id_str ? router_id_str : NULL); |
718e3744 | 1423 | |
ff8a8a7a | 1424 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1425 | } |
1426 | ||
ff8a8a7a CS |
1427 | void cli_show_router_bgp_router_id(struct vty *vty, struct lyd_node *dnode, |
1428 | bool show_defaults) | |
1429 | { | |
1430 | vty_out(vty, " bgp router-id %s\n", yang_dnode_get_string(dnode, NULL)); | |
1431 | } | |
6b0655a2 | 1432 | |
718e3744 | 1433 | /* BGP Cluster ID. */ |
ff8a8a7a CS |
1434 | DEFUN_YANG(bgp_cluster_id, |
1435 | bgp_cluster_id_cmd, | |
1436 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", | |
1437 | BGP_STR | |
1438 | "Configure Route-Reflector Cluster-id\n" | |
1439 | "Route-Reflector Cluster-id in IP address format\n" | |
1440 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1441 | { |
d62a17ae | 1442 | int idx_ipv4 = 2; |
718e3744 | 1443 | |
87ce2564 CS |
1444 | nb_cli_enqueue_change( |
1445 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1446 | NB_OP_MODIFY, argv[idx_ipv4]->arg); | |
718e3744 | 1447 | |
ff8a8a7a | 1448 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1449 | } |
1450 | ||
ff8a8a7a CS |
1451 | DEFUN_YANG(no_bgp_cluster_id, |
1452 | no_bgp_cluster_id_cmd, | |
1453 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", | |
1454 | NO_STR BGP_STR | |
1455 | "Configure Route-Reflector Cluster-id\n" | |
1456 | "Route-Reflector Cluster-id in IP address format\n" | |
1457 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1458 | { |
87ce2564 CS |
1459 | nb_cli_enqueue_change( |
1460 | vty, "./global/route-reflector/route-reflector-cluster-id", | |
1461 | NB_OP_DESTROY, NULL); | |
718e3744 | 1462 | |
ff8a8a7a | 1463 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1464 | } |
1465 | ||
c163f297 DS |
1466 | DEFPY (bgp_norib, |
1467 | bgp_norib_cmd, | |
1468 | "bgp no-rib", | |
1469 | BGP_STR | |
1470 | "Disable BGP route installation to RIB (Zebra)\n") | |
1471 | { | |
1472 | if (bgp_option_check(BGP_OPT_NO_FIB)) { | |
1473 | vty_out(vty, | |
1474 | "%% No-RIB option is already set, nothing to do here.\n"); | |
1475 | return CMD_SUCCESS; | |
1476 | } | |
1477 | ||
1478 | bgp_option_norib_set_runtime(); | |
1479 | ||
1480 | return CMD_SUCCESS; | |
1481 | } | |
1482 | ||
1483 | DEFPY (no_bgp_norib, | |
1484 | no_bgp_norib_cmd, | |
1485 | "no bgp no-rib", | |
1486 | NO_STR | |
1487 | BGP_STR | |
1488 | "Disable BGP route installation to RIB (Zebra)\n") | |
1489 | { | |
1490 | if (!bgp_option_check(BGP_OPT_NO_FIB)) { | |
1491 | vty_out(vty, | |
1492 | "%% No-RIB option is not set, nothing to do here.\n"); | |
1493 | return CMD_SUCCESS; | |
1494 | } | |
1495 | ||
1496 | bgp_option_norib_unset_runtime(); | |
1497 | ||
1498 | return CMD_SUCCESS; | |
1499 | } | |
1500 | ||
ff8a8a7a CS |
1501 | DEFUN_YANG(bgp_confederation_identifier, |
1502 | bgp_confederation_identifier_cmd, | |
1503 | "bgp confederation identifier (1-4294967295)", | |
1504 | "BGP specific commands\n" | |
1505 | "AS confederation parameters\n" | |
1506 | "AS number\n" | |
1507 | "Set routing domain confederation AS\n") | |
718e3744 | 1508 | { |
d62a17ae | 1509 | int idx_number = 3; |
718e3744 | 1510 | |
87ce2564 CS |
1511 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1512 | NB_OP_MODIFY, argv[idx_number]->arg); | |
718e3744 | 1513 | |
ff8a8a7a | 1514 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1515 | } |
1516 | ||
ff8a8a7a CS |
1517 | DEFUN_YANG(no_bgp_confederation_identifier, |
1518 | no_bgp_confederation_identifier_cmd, | |
1519 | "no bgp confederation identifier [(1-4294967295)]", | |
1520 | NO_STR | |
1521 | "BGP specific commands\n" | |
1522 | "AS confederation parameters\n" | |
1523 | "AS number\n" | |
1524 | "Set routing domain confederation AS\n") | |
718e3744 | 1525 | { |
87ce2564 CS |
1526 | nb_cli_enqueue_change(vty, "./global/confederation/identifier", |
1527 | NB_OP_DESTROY, NULL); | |
718e3744 | 1528 | |
ff8a8a7a | 1529 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1530 | } |
1531 | ||
ff8a8a7a CS |
1532 | void cli_show_router_bgp_confederation_identifier(struct vty *vty, |
1533 | struct lyd_node *dnode, | |
1534 | bool show_defaults) | |
1535 | { | |
1536 | vty_out(vty, " bgp confederation identifier %u\n", | |
1537 | yang_dnode_get_uint32(dnode, NULL)); | |
1538 | } | |
1539 | ||
1540 | DEFUN_YANG(bgp_confederation_peers, | |
1541 | bgp_confederation_peers_cmd, | |
1542 | "bgp confederation peers (1-4294967295)...", | |
1543 | "BGP specific commands\n" | |
1544 | "AS confederation parameters\n" | |
1545 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1546 | { |
d62a17ae | 1547 | int idx_asn = 3; |
d62a17ae | 1548 | int i; |
718e3744 | 1549 | |
ff8a8a7a | 1550 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1551 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1552 | NB_OP_CREATE, argv[i]->arg); |
718e3744 | 1553 | |
ff8a8a7a | 1554 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 1555 | } |
1556 | ||
ff8a8a7a CS |
1557 | DEFUN_YANG(no_bgp_confederation_peers, |
1558 | no_bgp_confederation_peers_cmd, | |
1559 | "no bgp confederation peers (1-4294967295)...", | |
1560 | NO_STR | |
1561 | "BGP specific commands\n" | |
1562 | "AS confederation parameters\n" | |
1563 | "Peer ASs in BGP confederation\n" AS_STR) | |
718e3744 | 1564 | { |
d62a17ae | 1565 | int idx_asn = 4; |
d62a17ae | 1566 | int i; |
718e3744 | 1567 | |
ff8a8a7a | 1568 | for (i = idx_asn; i < argc; i++) |
87ce2564 | 1569 | nb_cli_enqueue_change(vty, "./global/confederation/member-as", |
ff8a8a7a | 1570 | NB_OP_DESTROY, argv[i]->arg); |
0b2aa3a0 | 1571 | |
ff8a8a7a CS |
1572 | return nb_cli_apply_changes(vty, NULL); |
1573 | } | |
1574 | ||
1575 | void cli_show_router_bgp_confederation_member_as(struct vty *vty, | |
1576 | struct lyd_node *dnode, | |
1577 | bool show_defaults) | |
1578 | { | |
1579 | vty_out(vty, " bgp confederation peers %u \n", | |
1580 | yang_dnode_get_uint32(dnode, NULL)); | |
718e3744 | 1581 | } |
6b0655a2 | 1582 | |
5e242b0d DS |
1583 | /** |
1584 | * Central routine for maximum-paths configuration. | |
1585 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1586 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1587 | */ | |
d62a17ae | 1588 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1589 | const char *mpaths, uint16_t options, |
d62a17ae | 1590 | int set) |
1591 | { | |
1592 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1593 | uint16_t maxpaths = 0; |
d62a17ae | 1594 | int ret; |
1595 | afi_t afi; | |
1596 | safi_t safi; | |
1597 | ||
1598 | afi = bgp_node_afi(vty); | |
1599 | safi = bgp_node_safi(vty); | |
1600 | ||
1601 | if (set) { | |
1602 | maxpaths = strtol(mpaths, NULL, 10); | |
1603 | if (maxpaths > multipath_num) { | |
1604 | vty_out(vty, | |
1605 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1606 | maxpaths, multipath_num); | |
1607 | return CMD_WARNING_CONFIG_FAILED; | |
1608 | } | |
1609 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1610 | options); | |
1611 | } else | |
1612 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1613 | ||
1614 | if (ret < 0) { | |
1615 | vty_out(vty, | |
1616 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1617 | (set == 1) ? "" : "un", | |
1618 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1619 | maxpaths, afi, safi); | |
1620 | return CMD_WARNING_CONFIG_FAILED; | |
1621 | } | |
1622 | ||
1623 | bgp_recalculate_all_bestpaths(bgp); | |
1624 | ||
1625 | return CMD_SUCCESS; | |
165b5fff JB |
1626 | } |
1627 | ||
ff8a8a7a CS |
1628 | void cli_show_router_bgp_med_config(struct vty *vty, struct lyd_node *dnode, |
1629 | bool show_defaults) | |
abc920f8 | 1630 | { |
ff8a8a7a CS |
1631 | if (yang_dnode_get_bool(dnode, "./enable-med-admin")) { |
1632 | uint32_t med_admin_val; | |
abc920f8 | 1633 | |
ff8a8a7a CS |
1634 | vty_out(vty, " bgp max-med administrative"); |
1635 | if ((med_admin_val = | |
1636 | yang_dnode_get_uint32(dnode, "./max-med-admin")) | |
1637 | != BGP_MAXMED_VALUE_DEFAULT) | |
1638 | vty_out(vty, " %u", med_admin_val); | |
1639 | vty_out(vty, "\n"); | |
1640 | } | |
abc920f8 | 1641 | |
ff8a8a7a CS |
1642 | if (yang_dnode_exists(dnode, "./max-med-onstart-up-time")) { |
1643 | uint32_t onstartup_val; | |
abc920f8 | 1644 | |
ff8a8a7a CS |
1645 | vty_out(vty, " bgp max-med on-startup %u", |
1646 | yang_dnode_get_uint32(dnode, | |
1647 | "./max-med-onstart-up-time")); | |
1648 | onstartup_val = yang_dnode_get_uint32( | |
1649 | dnode, "./max-med-onstart-up-value"); | |
1650 | if (onstartup_val != BGP_MAXMED_VALUE_DEFAULT) | |
1651 | vty_out(vty, " %u", onstartup_val); | |
1652 | ||
1653 | vty_out(vty, "\n"); | |
1654 | } | |
abc920f8 DS |
1655 | } |
1656 | ||
ff8a8a7a CS |
1657 | DEFUN_YANG(bgp_maxmed_admin, |
1658 | bgp_maxmed_admin_cmd, | |
1659 | "bgp max-med administrative ", | |
1660 | BGP_STR | |
1661 | "Advertise routes with max-med\n" | |
1662 | "Administratively applied, for an indefinite period\n") | |
1663 | { | |
87ce2564 | 1664 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a CS |
1665 | NB_OP_MODIFY, "true"); |
1666 | ||
1667 | return nb_cli_apply_changes(vty, NULL); | |
1668 | } | |
1669 | ||
1670 | DEFUN_YANG(bgp_maxmed_admin_medv, | |
1671 | bgp_maxmed_admin_medv_cmd, | |
1672 | "bgp max-med administrative (0-4294967295)", | |
1673 | BGP_STR | |
1674 | "Advertise routes with max-med\n" | |
1675 | "Administratively applied, for an indefinite period\n" | |
1676 | "Max MED value to be used\n") | |
abc920f8 | 1677 | { |
d62a17ae | 1678 | int idx_number = 3; |
abc920f8 | 1679 | |
87ce2564 | 1680 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1681 | NB_OP_MODIFY, "true"); |
abc920f8 | 1682 | |
87ce2564 CS |
1683 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1684 | NB_OP_MODIFY, argv[idx_number]->arg); | |
abc920f8 | 1685 | |
ff8a8a7a | 1686 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1687 | } |
1688 | ||
ff8a8a7a CS |
1689 | DEFUN_YANG(no_bgp_maxmed_admin, |
1690 | no_bgp_maxmed_admin_cmd, | |
1691 | "no bgp max-med administrative [(0-4294967295)]", | |
1692 | NO_STR BGP_STR | |
1693 | "Advertise routes with max-med\n" | |
1694 | "Administratively applied, for an indefinite period\n" | |
1695 | "Max MED value to be used\n") | |
abc920f8 | 1696 | { |
87ce2564 | 1697 | nb_cli_enqueue_change(vty, "./global/med-config/enable-med-admin", |
ff8a8a7a | 1698 | NB_OP_MODIFY, "false"); |
abc920f8 | 1699 | |
87ce2564 CS |
1700 | nb_cli_enqueue_change(vty, "./global/med-config/max-med-admin", |
1701 | NB_OP_MODIFY, NULL); | |
ff8a8a7a CS |
1702 | |
1703 | return nb_cli_apply_changes(vty, NULL); | |
abc920f8 DS |
1704 | } |
1705 | ||
ff8a8a7a CS |
1706 | DEFUN_YANG(bgp_maxmed_onstartup, |
1707 | bgp_maxmed_onstartup_cmd, | |
1708 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", | |
1709 | BGP_STR | |
1710 | "Advertise routes with max-med\n" | |
1711 | "Effective on a startup\n" | |
1712 | "Time (seconds) period for max-med\n" | |
1713 | "Max MED value to be used\n") | |
abc920f8 | 1714 | { |
d62a17ae | 1715 | int idx = 0; |
4668a151 | 1716 | |
d62a17ae | 1717 | argv_find(argv, argc, "(5-86400)", &idx); |
87ce2564 CS |
1718 | nb_cli_enqueue_change(vty, |
1719 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a CS |
1720 | NB_OP_MODIFY, argv[idx]->arg); |
1721 | ||
d62a17ae | 1722 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) |
87ce2564 CS |
1723 | nb_cli_enqueue_change( |
1724 | vty, "./global/med-config/max-med-onstart-up-value", | |
1725 | NB_OP_MODIFY, argv[idx]->arg); | |
d62a17ae | 1726 | else |
87ce2564 CS |
1727 | nb_cli_enqueue_change( |
1728 | vty, "./global/med-config/max-med-onstart-up-value", | |
1729 | NB_OP_MODIFY, NULL); | |
abc920f8 | 1730 | |
ff8a8a7a | 1731 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1732 | } |
1733 | ||
ff8a8a7a CS |
1734 | DEFUN_YANG(no_bgp_maxmed_onstartup, |
1735 | no_bgp_maxmed_onstartup_cmd, | |
1736 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", | |
1737 | NO_STR BGP_STR | |
1738 | "Advertise routes with max-med\n" | |
1739 | "Effective on a startup\n" | |
1740 | "Time (seconds) period for max-med\n" | |
1741 | "Max MED value to be used\n") | |
abc920f8 | 1742 | { |
87ce2564 CS |
1743 | nb_cli_enqueue_change(vty, |
1744 | "./global/med-config/max-med-onstart-up-time", | |
ff8a8a7a | 1745 | NB_OP_DESTROY, NULL); |
abc920f8 | 1746 | |
87ce2564 CS |
1747 | nb_cli_enqueue_change(vty, |
1748 | "./global/med-config/max-med-onstart-up-value", | |
ff8a8a7a | 1749 | NB_OP_MODIFY, NULL); |
abc920f8 | 1750 | |
ff8a8a7a | 1751 | return nb_cli_apply_changes(vty, NULL); |
abc920f8 DS |
1752 | } |
1753 | ||
d70583f7 D |
1754 | static int bgp_global_update_delay_config_vty(struct vty *vty, |
1755 | uint16_t update_delay, | |
1756 | uint16_t establish_wait) | |
1757 | { | |
1758 | struct listnode *node, *nnode; | |
1759 | struct bgp *bgp; | |
1760 | bool vrf_cfg = false; | |
1761 | ||
1762 | /* | |
1763 | * See if update-delay is set per-vrf and warn user to delete it | |
1764 | * Note that we only need to check this if this is the first time | |
1765 | * setting the global config. | |
1766 | */ | |
1767 | if (bm->v_update_delay == BGP_UPDATE_DELAY_DEF) { | |
1768 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1769 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { | |
1770 | vty_out(vty, | |
1771 | "%% update-delay configuration found in vrf %s\n", | |
1772 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT | |
1773 | ? VRF_DEFAULT_NAME | |
1774 | : bgp->name); | |
1775 | vrf_cfg = true; | |
1776 | } | |
1777 | } | |
1778 | } | |
1779 | ||
1780 | if (vrf_cfg) { | |
1781 | vty_out(vty, | |
1782 | "%%Failed: global update-delay config not permitted\n"); | |
1783 | return CMD_WARNING; | |
1784 | } | |
1785 | ||
1786 | if (!establish_wait) { /* update-delay <delay> */ | |
1787 | bm->v_update_delay = update_delay; | |
1788 | bm->v_establish_wait = bm->v_update_delay; | |
1789 | } else { | |
1790 | /* update-delay <delay> <establish-wait> */ | |
1791 | if (update_delay < establish_wait) { | |
1792 | vty_out(vty, | |
1793 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1794 | return CMD_WARNING_CONFIG_FAILED; | |
1795 | } | |
1796 | ||
1797 | bm->v_update_delay = update_delay; | |
1798 | bm->v_establish_wait = establish_wait; | |
1799 | } | |
1800 | ||
1801 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1802 | bgp->v_update_delay = bm->v_update_delay; | |
1803 | bgp->v_establish_wait = bm->v_establish_wait; | |
1804 | } | |
1805 | ||
1806 | return CMD_SUCCESS; | |
1807 | } | |
1808 | ||
1809 | static int bgp_global_update_delay_deconfig_vty(struct vty *vty) | |
1810 | { | |
1811 | struct listnode *node, *nnode; | |
1812 | struct bgp *bgp; | |
1813 | ||
1814 | bm->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1815 | bm->v_establish_wait = bm->v_update_delay; | |
1816 | ||
1817 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
1818 | bgp->v_update_delay = bm->v_update_delay; | |
1819 | bgp->v_establish_wait = bm->v_establish_wait; | |
1820 | } | |
1821 | ||
1822 | return CMD_SUCCESS; | |
1823 | } | |
1824 | ||
1825 | static int bgp_update_delay_config_vty(struct vty *vty, uint16_t update_delay, | |
1826 | uint16_t establish_wait) | |
f188f2c4 | 1827 | { |
d62a17ae | 1828 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1829 | |
d70583f7 D |
1830 | /* if configured globally, per-instance config is not allowed */ |
1831 | if (bm->v_update_delay) { | |
1832 | vty_out(vty, | |
1833 | "%%Failed: per-vrf update-delay config not permitted with global update-delay\n"); | |
1834 | return CMD_WARNING_CONFIG_FAILED; | |
1835 | } | |
1836 | ||
f188f2c4 | 1837 | |
d70583f7 | 1838 | if (!establish_wait) /* update-delay <delay> */ |
d62a17ae | 1839 | { |
1840 | bgp->v_update_delay = update_delay; | |
1841 | bgp->v_establish_wait = bgp->v_update_delay; | |
1842 | return CMD_SUCCESS; | |
1843 | } | |
f188f2c4 | 1844 | |
d62a17ae | 1845 | /* update-delay <delay> <establish-wait> */ |
d62a17ae | 1846 | if (update_delay < establish_wait) { |
1847 | vty_out(vty, | |
1848 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1849 | return CMD_WARNING_CONFIG_FAILED; | |
1850 | } | |
f188f2c4 | 1851 | |
d62a17ae | 1852 | bgp->v_update_delay = update_delay; |
1853 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1854 | |
d62a17ae | 1855 | return CMD_SUCCESS; |
f188f2c4 DS |
1856 | } |
1857 | ||
d62a17ae | 1858 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1859 | { |
d62a17ae | 1860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1861 | |
d70583f7 D |
1862 | /* If configured globally, cannot remove from one bgp instance */ |
1863 | if (bm->v_update_delay) { | |
1864 | vty_out(vty, | |
1865 | "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n"); | |
1866 | return CMD_WARNING_CONFIG_FAILED; | |
1867 | } | |
d62a17ae | 1868 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1869 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1870 | |
d62a17ae | 1871 | return CMD_SUCCESS; |
f188f2c4 DS |
1872 | } |
1873 | ||
2b791107 | 1874 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1875 | { |
d70583f7 D |
1876 | /* If configured globally, no need to display per-instance value */ |
1877 | if (bgp->v_update_delay != bm->v_update_delay) { | |
d62a17ae | 1878 | vty_out(vty, " update-delay %d", bgp->v_update_delay); |
1879 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1880 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1881 | vty_out(vty, "\n"); | |
1882 | } | |
f188f2c4 DS |
1883 | } |
1884 | ||
d70583f7 D |
1885 | /* Global update-delay configuration */ |
1886 | DEFPY (bgp_global_update_delay, | |
1887 | bgp_global_update_delay_cmd, | |
1888 | "bgp update-delay (0-3600)$delay [(1-3600)$wait]", | |
1889 | BGP_STR | |
1890 | "Force initial delay for best-path and updates for all bgp instances\n" | |
1891 | "Max delay in seconds\n" | |
1892 | "Establish wait in seconds\n") | |
1893 | { | |
1894 | return bgp_global_update_delay_config_vty(vty, delay, wait); | |
1895 | } | |
f188f2c4 | 1896 | |
d70583f7 D |
1897 | /* Global update-delay deconfiguration */ |
1898 | DEFPY (no_bgp_global_update_delay, | |
1899 | no_bgp_global_update_delay_cmd, | |
1900 | "no bgp update-delay [(0-3600) [(1-3600)]]", | |
1901 | NO_STR | |
1902 | BGP_STR | |
f188f2c4 | 1903 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
1904 | "Max delay in seconds\n" |
1905 | "Establish wait in seconds\n") | |
f188f2c4 | 1906 | { |
d70583f7 | 1907 | return bgp_global_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1908 | } |
1909 | ||
d70583f7 D |
1910 | /* Update-delay configuration */ |
1911 | ||
1912 | DEFPY (bgp_update_delay, | |
1913 | bgp_update_delay_cmd, | |
1914 | "update-delay (0-3600)$delay [(1-3600)$wait]", | |
f188f2c4 | 1915 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
1916 | "Max delay in seconds\n" |
1917 | "Establish wait in seconds\n") | |
f188f2c4 | 1918 | { |
d70583f7 | 1919 | return bgp_update_delay_config_vty(vty, delay, wait); |
f188f2c4 DS |
1920 | } |
1921 | ||
1922 | /* Update-delay deconfiguration */ | |
d70583f7 | 1923 | DEFPY (no_bgp_update_delay, |
f188f2c4 | 1924 | no_bgp_update_delay_cmd, |
838758ac DW |
1925 | "no update-delay [(0-3600) [(1-3600)]]", |
1926 | NO_STR | |
f188f2c4 | 1927 | "Force initial delay for best-path and updates\n" |
d70583f7 D |
1928 | "Max delay in seconds\n" |
1929 | "Establish wait in seconds\n") | |
f188f2c4 | 1930 | { |
d62a17ae | 1931 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1932 | } |
1933 | ||
5e242b0d | 1934 | |
ff8a8a7a | 1935 | int bgp_wpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
cb1faec9 | 1936 | { |
8fa7732f QY |
1937 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1938 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1939 | |
1940 | return CMD_SUCCESS; | |
1941 | } | |
1942 | ||
ff8a8a7a | 1943 | int bgp_rpkt_quanta_config_vty(struct bgp *bgp, uint32_t quanta, bool set) |
555e09d4 | 1944 | { |
8fa7732f QY |
1945 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1946 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1947 | |
d62a17ae | 1948 | return CMD_SUCCESS; |
cb1faec9 DS |
1949 | } |
1950 | ||
2b791107 | 1951 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1952 | { |
555e09d4 QY |
1953 | uint32_t quanta = |
1954 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1955 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1956 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1957 | } |
1958 | ||
555e09d4 QY |
1959 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1960 | { | |
1961 | uint32_t quanta = | |
1962 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1963 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1964 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1965 | } |
cb1faec9 | 1966 | |
8fa7732f QY |
1967 | /* Packet quanta configuration |
1968 | * | |
1969 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1970 | * thread. When changing these limits be careful to prevent stack overflow. | |
1971 | * | |
1972 | * Furthermore, the maximums used here should correspond to | |
1973 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1974 | */ | |
ff8a8a7a CS |
1975 | DEFPY_YANG(bgp_wpkt_quanta, |
1976 | bgp_wpkt_quanta_cmd, | |
1977 | "[no] write-quanta (1-64)$quanta", | |
1978 | NO_STR | |
1979 | "How many packets to write to peer socket per run\n" | |
1980 | "Number of packets\n") | |
1981 | { | |
1982 | if (!no) | |
1983 | nb_cli_enqueue_change( | |
1984 | vty, | |
87ce2564 | 1985 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
1986 | NB_OP_MODIFY, quanta_str); |
1987 | else | |
1988 | nb_cli_enqueue_change( | |
1989 | vty, | |
87ce2564 | 1990 | "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta", |
ff8a8a7a CS |
1991 | NB_OP_MODIFY, NULL); |
1992 | ||
1993 | return nb_cli_apply_changes(vty, NULL); | |
1994 | } | |
1995 | ||
1996 | DEFPY_YANG(bgp_rpkt_quanta, | |
1997 | bgp_rpkt_quanta_cmd, | |
1998 | "[no] read-quanta (1-10)$quanta", | |
1999 | NO_STR | |
2000 | "How many packets to read from peer socket per I/O cycle\n" | |
2001 | "Number of packets\n") | |
2002 | { | |
2003 | if (!no) | |
2004 | nb_cli_enqueue_change( | |
2005 | vty, | |
87ce2564 | 2006 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a CS |
2007 | NB_OP_MODIFY, quanta_str); |
2008 | else | |
2009 | nb_cli_enqueue_change( | |
2010 | vty, | |
87ce2564 | 2011 | "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta", |
ff8a8a7a | 2012 | NB_OP_MODIFY, NULL); |
cb1faec9 | 2013 | |
ff8a8a7a | 2014 | return nb_cli_apply_changes(vty, NULL); |
555e09d4 QY |
2015 | } |
2016 | ||
2b791107 | 2017 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 2018 | { |
37a333fe | 2019 | if (!bgp->heuristic_coalesce) |
d62a17ae | 2020 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
2021 | } |
2022 | ||
ff8a8a7a CS |
2023 | void cli_show_router_global_update_group_config_coalesce_time( |
2024 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3f9c7369 | 2025 | { |
ff8a8a7a CS |
2026 | vty_out(vty, " coalesce-time %u\n", yang_dnode_get_uint32(dnode, NULL)); |
2027 | } | |
2028 | ||
4668a151 | 2029 | |
ff8a8a7a CS |
2030 | DEFUN_YANG(bgp_coalesce_time, |
2031 | bgp_coalesce_time_cmd, | |
2032 | "coalesce-time (0-4294967295)", | |
2033 | "Subgroup coalesce timer\n" | |
2034 | "Subgroup coalesce timer value (in ms)\n") | |
2035 | { | |
d62a17ae | 2036 | int idx = 0; |
ff8a8a7a | 2037 | |
d62a17ae | 2038 | argv_find(argv, argc, "(0-4294967295)", &idx); |
87ce2564 CS |
2039 | nb_cli_enqueue_change( |
2040 | vty, "./global/global-update-group-config/coalesce-time", | |
2041 | NB_OP_MODIFY, argv[idx]->arg); | |
ff8a8a7a CS |
2042 | |
2043 | return nb_cli_apply_changes(vty, NULL); | |
3f9c7369 DS |
2044 | } |
2045 | ||
ff8a8a7a CS |
2046 | DEFUN_YANG(no_bgp_coalesce_time, |
2047 | no_bgp_coalesce_time_cmd, | |
2048 | "no coalesce-time (0-4294967295)", | |
2049 | NO_STR | |
2050 | "Subgroup coalesce timer\n" | |
2051 | "Subgroup coalesce timer value (in ms)\n") | |
3f9c7369 | 2052 | { |
87ce2564 CS |
2053 | nb_cli_enqueue_change( |
2054 | vty, "./global/global-update-group-config/coalesce-time", | |
2055 | NB_OP_MODIFY, NULL); | |
4668a151 | 2056 | |
ff8a8a7a | 2057 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
2058 | } |
2059 | ||
5e242b0d DS |
2060 | /* Maximum-paths configuration */ |
2061 | DEFUN (bgp_maxpaths, | |
2062 | bgp_maxpaths_cmd, | |
6319fd63 | 2063 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
2064 | "Forward packets over multiple paths\n" |
2065 | "Number of paths\n") | |
2066 | { | |
d62a17ae | 2067 | int idx_number = 1; |
2068 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
2069 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
2070 | } |
2071 | ||
d62a17ae | 2072 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
2073 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2074 | "Forward packets over multiple paths\n" | |
2075 | "Number of paths\n") | |
596c17ba | 2076 | |
165b5fff JB |
2077 | DEFUN (bgp_maxpaths_ibgp, |
2078 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 2079 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
2080 | "Forward packets over multiple paths\n" |
2081 | "iBGP-multipath\n" | |
2082 | "Number of paths\n") | |
2083 | { | |
d62a17ae | 2084 | int idx_number = 2; |
2085 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
2086 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 2087 | } |
165b5fff | 2088 | |
d62a17ae | 2089 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
2090 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
2091 | "Forward packets over multiple paths\n" | |
2092 | "iBGP-multipath\n" | |
2093 | "Number of paths\n") | |
596c17ba | 2094 | |
5e242b0d DS |
2095 | DEFUN (bgp_maxpaths_ibgp_cluster, |
2096 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 2097 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
2098 | "Forward packets over multiple paths\n" |
2099 | "iBGP-multipath\n" | |
2100 | "Number of paths\n" | |
2101 | "Match the cluster length\n") | |
2102 | { | |
d62a17ae | 2103 | int idx_number = 2; |
2104 | return bgp_maxpaths_config_vty( | |
2105 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
2106 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
2107 | } |
2108 | ||
d62a17ae | 2109 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
2110 | "maximum-paths ibgp " CMD_RANGE_STR( | |
2111 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
2112 | "Forward packets over multiple paths\n" | |
2113 | "iBGP-multipath\n" | |
2114 | "Number of paths\n" | |
2115 | "Match the cluster length\n") | |
596c17ba | 2116 | |
165b5fff JB |
2117 | DEFUN (no_bgp_maxpaths, |
2118 | no_bgp_maxpaths_cmd, | |
6319fd63 | 2119 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
2120 | NO_STR |
2121 | "Forward packets over multiple paths\n" | |
2122 | "Number of paths\n") | |
2123 | { | |
d62a17ae | 2124 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
2125 | } |
2126 | ||
d62a17ae | 2127 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 2128 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 2129 | "Forward packets over multiple paths\n" |
2130 | "Number of paths\n") | |
596c17ba | 2131 | |
165b5fff JB |
2132 | DEFUN (no_bgp_maxpaths_ibgp, |
2133 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 2134 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
2135 | NO_STR |
2136 | "Forward packets over multiple paths\n" | |
2137 | "iBGP-multipath\n" | |
838758ac DW |
2138 | "Number of paths\n" |
2139 | "Match the cluster length\n") | |
165b5fff | 2140 | { |
d62a17ae | 2141 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
2142 | } |
2143 | ||
d62a17ae | 2144 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
2145 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
2146 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
2147 | NO_STR | |
2148 | "Forward packets over multiple paths\n" | |
2149 | "iBGP-multipath\n" | |
2150 | "Number of paths\n" | |
2151 | "Match the cluster length\n") | |
596c17ba | 2152 | |
dd65f45e DL |
2153 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
2154 | afi_t afi, safi_t safi) | |
165b5fff | 2155 | { |
d62a17ae | 2156 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 2157 | vty_out(vty, " maximum-paths %d\n", |
2158 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
2159 | } | |
165b5fff | 2160 | |
d62a17ae | 2161 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 2162 | vty_out(vty, " maximum-paths ibgp %d", |
2163 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
2164 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
2165 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
2166 | vty_out(vty, " equal-cluster-length"); | |
2167 | vty_out(vty, "\n"); | |
2168 | } | |
165b5fff | 2169 | } |
6b0655a2 | 2170 | |
718e3744 | 2171 | /* BGP timers. */ |
2172 | ||
ff8a8a7a CS |
2173 | DEFUN_YANG(bgp_timers, |
2174 | bgp_timers_cmd, | |
2175 | "timers bgp (0-65535) (0-65535)", | |
2176 | "Adjust routing timers\n" | |
2177 | "BGP timers\n" | |
2178 | "Keepalive interval\n" | |
2179 | "Holdtime\n") | |
718e3744 | 2180 | { |
d62a17ae | 2181 | int idx_number = 2; |
2182 | int idx_number_2 = 3; | |
718e3744 | 2183 | |
87ce2564 | 2184 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2185 | NB_OP_MODIFY, argv[idx_number]->arg); |
87ce2564 | 2186 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2187 | NB_OP_MODIFY, argv[idx_number_2]->arg); |
718e3744 | 2188 | |
ff8a8a7a CS |
2189 | return nb_cli_apply_changes(vty, NULL); |
2190 | } | |
718e3744 | 2191 | |
ff8a8a7a CS |
2192 | DEFUN_YANG(no_bgp_timers, |
2193 | no_bgp_timers_cmd, | |
2194 | "no timers bgp [(0-65535) (0-65535)]", | |
2195 | NO_STR | |
2196 | "Adjust routing timers\n" | |
2197 | "BGP timers\n" | |
2198 | "Keepalive interval\n" | |
2199 | "Holdtime\n") | |
2200 | { | |
87ce2564 | 2201 | nb_cli_enqueue_change(vty, "./global/global-config-timers/keepalive", |
ff8a8a7a | 2202 | NB_OP_DESTROY, NULL); |
87ce2564 | 2203 | nb_cli_enqueue_change(vty, "./global/global-config-timers/hold-time", |
ff8a8a7a | 2204 | NB_OP_DESTROY, NULL); |
718e3744 | 2205 | |
ff8a8a7a | 2206 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2207 | } |
2208 | ||
ff8a8a7a CS |
2209 | void cli_show_router_bgp_route_reflector(struct vty *vty, |
2210 | struct lyd_node *dnode, | |
2211 | bool show_defaults) | |
718e3744 | 2212 | { |
ff8a8a7a CS |
2213 | if (yang_dnode_get_bool(dnode, "./no-client-reflect")) |
2214 | vty_out(vty, " no bgp client-to-client reflection\n"); | |
718e3744 | 2215 | |
ff8a8a7a CS |
2216 | if (yang_dnode_get_bool(dnode, "./allow-outbound-policy")) |
2217 | vty_out(vty, " bgp route-reflector allow-outbound-policy\n"); | |
2218 | ||
2219 | if (yang_dnode_exists(dnode, "./route-reflector-cluster-id")) | |
2220 | vty_out(vty, " bgp cluster-id %s\n", | |
2221 | yang_dnode_get_string(dnode, | |
2222 | "./route-reflector-cluster-id")); | |
718e3744 | 2223 | } |
2224 | ||
ff8a8a7a CS |
2225 | DEFUN_YANG(bgp_client_to_client_reflection, |
2226 | bgp_client_to_client_reflection_cmd, | |
2227 | "bgp client-to-client reflection", | |
2228 | "BGP specific commands\n" | |
2229 | "Configure client to client route reflection\n" | |
2230 | "reflection of routes allowed\n") | |
2231 | { | |
87ce2564 | 2232 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2233 | NB_OP_MODIFY, "false"); |
6b0655a2 | 2234 | |
ff8a8a7a CS |
2235 | return nb_cli_apply_changes(vty, NULL); |
2236 | } | |
2237 | ||
2238 | DEFUN_YANG(no_bgp_client_to_client_reflection, | |
2239 | no_bgp_client_to_client_reflection_cmd, | |
2240 | "no bgp client-to-client reflection", | |
2241 | NO_STR | |
2242 | "BGP specific commands\n" | |
2243 | "Configure client to client route reflection\n" | |
2244 | "reflection of routes allowed\n") | |
718e3744 | 2245 | { |
87ce2564 | 2246 | nb_cli_enqueue_change(vty, "./global/route-reflector/no-client-reflect", |
ff8a8a7a | 2247 | NB_OP_MODIFY, "true"); |
7aafcaca | 2248 | |
ff8a8a7a | 2249 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2250 | } |
2251 | ||
ff8a8a7a CS |
2252 | void cli_show_router_bgp_route_selection(struct vty *vty, |
2253 | struct lyd_node *dnode, | |
2254 | bool show_defaults) | |
718e3744 | 2255 | { |
7aafcaca | 2256 | |
ff8a8a7a CS |
2257 | if (yang_dnode_get_bool(dnode, "./always-compare-med")) |
2258 | vty_out(vty, " bgp always-compare-med\n"); | |
2259 | ||
2260 | if (yang_dnode_get_bool(dnode, "./ignore-as-path-length")) | |
2261 | vty_out(vty, " bgp bestpath as-path ignore\n"); | |
2262 | ||
2263 | if (yang_dnode_get_bool(dnode, "./aspath-confed")) | |
2264 | vty_out(vty, " bgp bestpath as-path confed\n"); | |
2265 | ||
2266 | if (yang_dnode_get_bool(dnode, "./external-compare-router-id")) | |
2267 | vty_out(vty, " bgp bestpath compare-routerid\n"); | |
2268 | ||
2269 | if (yang_dnode_get_bool(dnode, "./allow-multiple-as")) { | |
2270 | if (yang_dnode_get_bool(dnode, "./multi-path-as-set")) | |
2271 | vty_out(vty, | |
2272 | " bgp bestpath as-path multipath-relax as-set\n"); | |
2273 | else | |
2274 | vty_out(vty, " bgp bestpath as-path multipath-relax\n"); | |
2275 | } | |
2276 | ||
2277 | if (yang_dnode_get_bool(dnode, "./deterministic-med")) | |
2278 | vty_out(vty, " bgp deterministic-med\n"); | |
2279 | ||
2280 | if (yang_dnode_get_bool(dnode, "./confed-med") | |
2281 | || yang_dnode_get_bool(dnode, "./missing-as-worst-med")) { | |
2282 | vty_out(vty, " bgp bestpath med"); | |
2283 | if (yang_dnode_get_bool(dnode, "./confed-med")) | |
2284 | vty_out(vty, " confed"); | |
2285 | if (yang_dnode_get_bool(dnode, "./missing-as-worst-med")) | |
2286 | vty_out(vty, " missing-as-worst"); | |
2287 | vty_out(vty, "\n"); | |
2288 | } | |
718e3744 | 2289 | } |
2290 | ||
2291 | /* "bgp always-compare-med" configuration. */ | |
ff8a8a7a CS |
2292 | DEFUN_YANG(bgp_always_compare_med, |
2293 | bgp_always_compare_med_cmd, | |
2294 | "bgp always-compare-med", | |
2295 | "BGP specific commands\n" | |
2296 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2297 | { |
87ce2564 CS |
2298 | nb_cli_enqueue_change( |
2299 | vty, "./global/route-selection-options/always-compare-med", | |
2300 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2301 | |
ff8a8a7a | 2302 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2303 | } |
2304 | ||
ff8a8a7a CS |
2305 | DEFUN_YANG(no_bgp_always_compare_med, |
2306 | no_bgp_always_compare_med_cmd, | |
2307 | "no bgp always-compare-med", | |
2308 | NO_STR | |
2309 | "BGP specific commands\n" | |
2310 | "Allow comparing MED from different neighbors\n") | |
718e3744 | 2311 | { |
87ce2564 CS |
2312 | nb_cli_enqueue_change( |
2313 | vty, "./global/route-selection-options/always-compare-med", | |
2314 | NB_OP_MODIFY, "false"); | |
7aafcaca | 2315 | |
ff8a8a7a | 2316 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2317 | } |
6b0655a2 | 2318 | |
ff8a8a7a CS |
2319 | DEFUN_YANG(bgp_ebgp_requires_policy, |
2320 | bgp_ebgp_requires_policy_cmd, | |
2321 | "bgp ebgp-requires-policy", | |
2322 | "BGP specific commands\n" | |
2323 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2324 | { | |
87ce2564 CS |
2325 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2326 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
2327 | return nb_cli_apply_changes(vty, NULL); |
2328 | } | |
9dac9fc8 | 2329 | |
ff8a8a7a CS |
2330 | DEFUN_YANG(no_bgp_ebgp_requires_policy, |
2331 | no_bgp_ebgp_requires_policy_cmd, | |
2332 | "no bgp ebgp-requires-policy", | |
2333 | NO_STR | |
2334 | "BGP specific commands\n" | |
2335 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
9dac9fc8 | 2336 | { |
87ce2564 CS |
2337 | nb_cli_enqueue_change(vty, "./global/ebgp-requires-policy", |
2338 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 2339 | return nb_cli_apply_changes(vty, NULL); |
9dac9fc8 DA |
2340 | } |
2341 | ||
ff8a8a7a CS |
2342 | void cli_show_router_bgp_ebgp_requires_policy(struct vty *vty, |
2343 | struct lyd_node *dnode, | |
2344 | bool show_defaults) | |
9dac9fc8 | 2345 | { |
ff8a8a7a CS |
2346 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_EBGP_REQUIRES_POLICY) |
2347 | vty_out(vty, " bgp ebgp-requires-policy\n"); | |
9dac9fc8 DA |
2348 | } |
2349 | ||
fb29348a DA |
2350 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2351 | "bgp reject-as-sets", | |
2352 | "BGP specific commands\n" | |
2353 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2354 | { | |
2355 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2356 | struct listnode *node, *nnode; | |
2357 | struct peer *peer; | |
2358 | ||
7f972cd8 | 2359 | bgp->reject_as_sets = true; |
fb29348a DA |
2360 | |
2361 | /* Reset existing BGP sessions to reject routes | |
2362 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2363 | */ | |
2364 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2365 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2366 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2367 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2368 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2369 | } | |
2370 | } | |
2371 | ||
2372 | return CMD_SUCCESS; | |
2373 | } | |
2374 | ||
2375 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2376 | "no bgp reject-as-sets", | |
2377 | NO_STR | |
2378 | "BGP specific commands\n" | |
2379 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2380 | { | |
2381 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2382 | struct listnode *node, *nnode; | |
2383 | struct peer *peer; | |
2384 | ||
7f972cd8 | 2385 | bgp->reject_as_sets = false; |
fb29348a DA |
2386 | |
2387 | /* Reset existing BGP sessions to reject routes | |
2388 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2389 | */ | |
2390 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2391 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2392 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2393 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2394 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2395 | } | |
2396 | } | |
2397 | ||
2398 | return CMD_SUCCESS; | |
2399 | } | |
9dac9fc8 | 2400 | |
718e3744 | 2401 | /* "bgp deterministic-med" configuration. */ |
ff8a8a7a | 2402 | DEFUN_YANG (bgp_deterministic_med, |
718e3744 | 2403 | bgp_deterministic_med_cmd, |
2404 | "bgp deterministic-med", | |
2405 | "BGP specific commands\n" | |
2406 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2407 | { | |
87ce2564 CS |
2408 | nb_cli_enqueue_change( |
2409 | vty, "./global/route-selection-options/deterministic-med", | |
2410 | NB_OP_MODIFY, "true"); | |
7aafcaca | 2411 | |
ff8a8a7a | 2412 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2413 | } |
2414 | ||
ff8a8a7a | 2415 | DEFUN_YANG (no_bgp_deterministic_med, |
718e3744 | 2416 | no_bgp_deterministic_med_cmd, |
2417 | "no bgp deterministic-med", | |
2418 | NO_STR | |
2419 | "BGP specific commands\n" | |
2420 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2421 | { | |
87ce2564 CS |
2422 | nb_cli_enqueue_change( |
2423 | vty, "./global/route-selection-options/deterministic-med", | |
2424 | NB_OP_MODIFY, "false"); | |
d62a17ae | 2425 | |
ff8a8a7a | 2426 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 2427 | } |
538621f2 | 2428 | |
055679e9 | 2429 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2430 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2431 | bgp_graceful_restart_cmd, |
2432 | "bgp graceful-restart", | |
2433 | "BGP specific commands\n" | |
2434 | GR_CMD | |
055679e9 | 2435 | ) |
538621f2 | 2436 | { |
055679e9 | 2437 | int ret = BGP_GR_FAILURE; |
2438 | ||
2439 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2440 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2441 | |
d62a17ae | 2442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2443 | |
2444 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2445 | ||
36235319 QY |
2446 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2447 | ret); | |
5cce3f05 | 2448 | |
055679e9 | 2449 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2450 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2451 | vty_out(vty, |
2452 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2453 | return bgp_vty_return(vty, ret); |
538621f2 | 2454 | } |
2455 | ||
2456 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2457 | no_bgp_graceful_restart_cmd, |
2458 | "no bgp graceful-restart", | |
2459 | NO_STR | |
2460 | "BGP specific commands\n" | |
2461 | NO_GR_CMD | |
055679e9 | 2462 | ) |
538621f2 | 2463 | { |
d62a17ae | 2464 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2465 | |
2466 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2467 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2468 | |
2469 | int ret = BGP_GR_FAILURE; | |
2470 | ||
2471 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2472 | ||
36235319 QY |
2473 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2474 | ret); | |
5cce3f05 | 2475 | |
055679e9 | 2476 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2477 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2478 | vty_out(vty, |
2479 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2480 | |
2481 | return bgp_vty_return(vty, ret); | |
538621f2 | 2482 | } |
2483 | ||
93406d87 | 2484 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2485 | bgp_graceful_restart_stalepath_time_cmd, |
2486 | "bgp graceful-restart stalepath-time (1-4095)", | |
2487 | "BGP specific commands\n" | |
2488 | "Graceful restart capability parameters\n" | |
2489 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2490 | "Delay value (seconds)\n") | |
93406d87 | 2491 | { |
d62a17ae | 2492 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2493 | int idx_number = 3; | |
d7c0a89a | 2494 | uint32_t stalepath; |
93406d87 | 2495 | |
d62a17ae | 2496 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2497 | bgp->stalepath_time = stalepath; | |
2498 | return CMD_SUCCESS; | |
93406d87 | 2499 | } |
2500 | ||
eb6f1b41 | 2501 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2502 | bgp_graceful_restart_restart_time_cmd, |
2503 | "bgp graceful-restart restart-time (1-4095)", | |
2504 | "BGP specific commands\n" | |
2505 | "Graceful restart capability parameters\n" | |
2506 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2507 | "Delay value (seconds)\n") | |
eb6f1b41 | 2508 | { |
d62a17ae | 2509 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2510 | int idx_number = 3; | |
d7c0a89a | 2511 | uint32_t restart; |
eb6f1b41 | 2512 | |
d62a17ae | 2513 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2514 | bgp->restart_time = restart; | |
2515 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2516 | } |
2517 | ||
cfd47646 | 2518 | DEFUN (bgp_graceful_restart_select_defer_time, |
2519 | bgp_graceful_restart_select_defer_time_cmd, | |
2520 | "bgp graceful-restart select-defer-time (0-3600)", | |
2521 | "BGP specific commands\n" | |
2522 | "Graceful restart capability parameters\n" | |
2523 | "Set the time to defer the BGP route selection after restart\n" | |
2524 | "Delay value (seconds, 0 - disable)\n") | |
2525 | { | |
2526 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2527 | int idx_number = 3; | |
2528 | uint32_t defer_time; | |
2529 | ||
2530 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2531 | bgp->select_defer_time = defer_time; | |
2532 | if (defer_time == 0) | |
892fedb6 | 2533 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2534 | else |
892fedb6 | 2535 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2536 | |
2537 | return CMD_SUCCESS; | |
2538 | } | |
2539 | ||
93406d87 | 2540 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2541 | no_bgp_graceful_restart_stalepath_time_cmd, |
2542 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2543 | NO_STR | |
2544 | "BGP specific commands\n" | |
2545 | "Graceful restart capability parameters\n" | |
2546 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2547 | "Delay value (seconds)\n") | |
93406d87 | 2548 | { |
d62a17ae | 2549 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2550 | |
d62a17ae | 2551 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2552 | return CMD_SUCCESS; | |
93406d87 | 2553 | } |
2554 | ||
eb6f1b41 | 2555 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2556 | no_bgp_graceful_restart_restart_time_cmd, |
2557 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2558 | NO_STR | |
2559 | "BGP specific commands\n" | |
2560 | "Graceful restart capability parameters\n" | |
2561 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2562 | "Delay value (seconds)\n") | |
eb6f1b41 | 2563 | { |
d62a17ae | 2564 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2565 | |
d62a17ae | 2566 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2567 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2568 | } |
2569 | ||
cfd47646 | 2570 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2571 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2572 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2573 | NO_STR | |
2574 | "BGP specific commands\n" | |
2575 | "Graceful restart capability parameters\n" | |
2576 | "Set the time to defer the BGP route selection after restart\n" | |
2577 | "Delay value (seconds)\n") | |
2578 | { | |
2579 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2580 | ||
2581 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2582 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2583 | |
2584 | return CMD_SUCCESS; | |
2585 | } | |
2586 | ||
43fc21b3 | 2587 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2588 | bgp_graceful_restart_preserve_fw_cmd, |
2589 | "bgp graceful-restart preserve-fw-state", | |
2590 | "BGP specific commands\n" | |
2591 | "Graceful restart capability parameters\n" | |
2592 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2593 | { |
d62a17ae | 2594 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2595 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2596 | return CMD_SUCCESS; |
43fc21b3 JC |
2597 | } |
2598 | ||
2599 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2600 | no_bgp_graceful_restart_preserve_fw_cmd, |
2601 | "no bgp graceful-restart preserve-fw-state", | |
2602 | NO_STR | |
2603 | "BGP specific commands\n" | |
2604 | "Graceful restart capability parameters\n" | |
2605 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2606 | { |
d62a17ae | 2607 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2608 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2609 | return CMD_SUCCESS; |
43fc21b3 JC |
2610 | } |
2611 | ||
055679e9 | 2612 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2613 | bgp_graceful_restart_disable_cmd, |
2614 | "bgp graceful-restart-disable", | |
2615 | "BGP specific commands\n" | |
2616 | GR_DISABLE) | |
055679e9 | 2617 | { |
2618 | int ret = BGP_GR_FAILURE; | |
2619 | ||
2620 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2621 | zlog_debug( | |
2ba1fe69 | 2622 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2623 | |
055679e9 | 2624 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2625 | ||
2626 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2627 | ||
dc95985f | 2628 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2629 | bgp->peer, ret); | |
5cce3f05 | 2630 | |
055679e9 | 2631 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2632 | zlog_debug( | |
2ba1fe69 | 2633 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2634 | vty_out(vty, |
2635 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2636 | ||
055679e9 | 2637 | return bgp_vty_return(vty, ret); |
2638 | } | |
2639 | ||
2640 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2641 | no_bgp_graceful_restart_disable_cmd, |
2642 | "no bgp graceful-restart-disable", | |
2643 | NO_STR | |
2644 | "BGP specific commands\n" | |
2645 | NO_GR_DISABLE | |
055679e9 | 2646 | ) |
2647 | { | |
2648 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2649 | ||
2650 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2651 | zlog_debug( | |
2ba1fe69 | 2652 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2653 | |
2654 | int ret = BGP_GR_FAILURE; | |
2655 | ||
2656 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2657 | ||
36235319 QY |
2658 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2659 | ret); | |
5cce3f05 | 2660 | |
055679e9 | 2661 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2662 | zlog_debug( | |
2ba1fe69 | 2663 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2664 | vty_out(vty, |
2665 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2666 | |
2667 | return bgp_vty_return(vty, ret); | |
2668 | } | |
2669 | ||
2670 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2671 | bgp_neighbor_graceful_restart_set_cmd, |
2672 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2673 | NEIGHBOR_STR | |
2674 | NEIGHBOR_ADDR_STR2 | |
2675 | GR_NEIGHBOR_CMD | |
055679e9 | 2676 | ) |
2677 | { | |
2678 | int idx_peer = 1; | |
2679 | struct peer *peer; | |
2680 | int ret = BGP_GR_FAILURE; | |
2681 | ||
dc95985f | 2682 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2683 | ||
055679e9 | 2684 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2685 | zlog_debug( | |
2ba1fe69 | 2686 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2687 | |
055679e9 | 2688 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2689 | if (!peer) | |
2690 | return CMD_WARNING_CONFIG_FAILED; | |
2691 | ||
2692 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2693 | ||
dc95985f | 2694 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2695 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2696 | |
2697 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2698 | zlog_debug( | |
2ba1fe69 | 2699 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2700 | vty_out(vty, |
2701 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2702 | |
2703 | return bgp_vty_return(vty, ret); | |
2704 | } | |
2705 | ||
2706 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2707 | no_bgp_neighbor_graceful_restart_set_cmd, |
2708 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2709 | NO_STR | |
2710 | NEIGHBOR_STR | |
2711 | NEIGHBOR_ADDR_STR2 | |
2712 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2713 | ) |
2714 | { | |
2715 | int idx_peer = 2; | |
2716 | int ret = BGP_GR_FAILURE; | |
2717 | struct peer *peer; | |
2718 | ||
dc95985f | 2719 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2720 | ||
055679e9 | 2721 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2722 | if (!peer) | |
2723 | return CMD_WARNING_CONFIG_FAILED; | |
2724 | ||
2725 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2726 | zlog_debug( | |
2ba1fe69 | 2727 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2728 | |
2729 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2730 | ||
dc95985f | 2731 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2732 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2733 | |
2734 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2735 | zlog_debug( | |
2ba1fe69 | 2736 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2737 | vty_out(vty, |
2738 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2739 | |
2740 | return bgp_vty_return(vty, ret); | |
2741 | } | |
2742 | ||
2743 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2744 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2745 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2746 | NEIGHBOR_STR | |
2747 | NEIGHBOR_ADDR_STR2 | |
2748 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2749 | ) |
2750 | { | |
2751 | int idx_peer = 1; | |
2752 | struct peer *peer; | |
2753 | int ret = BGP_GR_FAILURE; | |
2754 | ||
dc95985f | 2755 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2756 | ||
055679e9 | 2757 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2758 | zlog_debug( | |
2ba1fe69 | 2759 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2760 | |
055679e9 | 2761 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2762 | ||
055679e9 | 2763 | if (!peer) |
2764 | return CMD_WARNING_CONFIG_FAILED; | |
2765 | ||
2766 | ||
2767 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2768 | |
dc95985f | 2769 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2770 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2771 | |
055679e9 | 2772 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2773 | zlog_debug( | |
2ba1fe69 | 2774 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2775 | vty_out(vty, |
2776 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2777 | |
2778 | return bgp_vty_return(vty, ret); | |
2779 | } | |
2780 | ||
2781 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2782 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2783 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2784 | NO_STR | |
2785 | NEIGHBOR_STR | |
2786 | NEIGHBOR_ADDR_STR2 | |
2787 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2788 | ) |
2789 | { | |
2790 | int idx_peer = 2; | |
2791 | int ret = BGP_GR_FAILURE; | |
2792 | struct peer *peer; | |
2793 | ||
dc95985f | 2794 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2795 | ||
055679e9 | 2796 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2797 | if (!peer) | |
2798 | return CMD_WARNING_CONFIG_FAILED; | |
2799 | ||
2800 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2801 | zlog_debug( | |
2ba1fe69 | 2802 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2803 | |
36235319 | 2804 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2805 | |
dc95985f | 2806 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2807 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2808 | |
2809 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2810 | zlog_debug( | |
2ba1fe69 | 2811 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2812 | vty_out(vty, |
2813 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2814 | |
2815 | return bgp_vty_return(vty, ret); | |
2816 | } | |
2817 | ||
2818 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2819 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2820 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2821 | NEIGHBOR_STR | |
2822 | NEIGHBOR_ADDR_STR2 | |
2823 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2824 | ) |
2825 | { | |
2826 | int idx_peer = 1; | |
2827 | struct peer *peer; | |
2828 | int ret = BGP_GR_FAILURE; | |
2829 | ||
dc95985f | 2830 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2831 | ||
055679e9 | 2832 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2833 | zlog_debug( | |
2ba1fe69 | 2834 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2835 | |
2836 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2837 | if (!peer) | |
2838 | return CMD_WARNING_CONFIG_FAILED; | |
2839 | ||
36235319 | 2840 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2841 | |
2842 | if (peer->bgp->t_startup) | |
2843 | bgp_peer_gr_flags_update(peer); | |
2844 | ||
dc95985f | 2845 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2846 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2847 | ||
055679e9 | 2848 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2849 | zlog_debug( | |
2ba1fe69 | 2850 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2851 | vty_out(vty, |
2852 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2853 | |
2854 | return bgp_vty_return(vty, ret); | |
2855 | } | |
2856 | ||
2857 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2858 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2859 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2860 | NO_STR | |
2861 | NEIGHBOR_STR | |
2862 | NEIGHBOR_ADDR_STR2 | |
2863 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2864 | ) |
2865 | { | |
2866 | int idx_peer = 2; | |
2867 | int ret = BGP_GR_FAILURE; | |
2868 | struct peer *peer; | |
2869 | ||
dc95985f | 2870 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2871 | ||
055679e9 | 2872 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2873 | if (!peer) | |
2874 | return CMD_WARNING_CONFIG_FAILED; | |
2875 | ||
2876 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2877 | zlog_debug( | |
2ba1fe69 | 2878 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2879 | |
2880 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2881 | ||
dc95985f | 2882 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2883 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2884 | |
2885 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2886 | zlog_debug( | |
2ba1fe69 | 2887 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2888 | vty_out(vty, |
2889 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2890 | |
2891 | return bgp_vty_return(vty, ret); | |
2892 | } | |
2893 | ||
d6e3c15b | 2894 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2895 | bgp_graceful_restart_disable_eor_cmd, | |
2896 | "bgp graceful-restart disable-eor", | |
2897 | "BGP specific commands\n" | |
2898 | "Graceful restart configuration parameters\n" | |
2899 | "Disable EOR Check\n") | |
2900 | { | |
2901 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2902 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2903 | |
d6e3c15b | 2904 | return CMD_SUCCESS; |
2905 | } | |
2906 | ||
2907 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2908 | no_bgp_graceful_restart_disable_eor_cmd, | |
2909 | "no bgp graceful-restart disable-eor", | |
2910 | NO_STR | |
2911 | "BGP specific commands\n" | |
2912 | "Graceful restart configuration parameters\n" | |
2913 | "Disable EOR Check\n") | |
2914 | { | |
2915 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2916 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2917 | |
2918 | return CMD_SUCCESS; | |
2919 | } | |
2920 | ||
2921 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2922 | bgp_graceful_restart_rib_stale_time_cmd, | |
2923 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2924 | "BGP specific commands\n" | |
2925 | "Graceful restart configuration parameters\n" | |
2926 | "Specify the stale route removal timer in rib\n" | |
2927 | "Delay value (seconds)\n") | |
2928 | { | |
2929 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2930 | int idx_number = 3; | |
2931 | uint32_t stale_time; | |
2932 | ||
2933 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2934 | bgp->rib_stale_time = stale_time; | |
2935 | /* Send the stale timer update message to RIB */ | |
2936 | if (bgp_zebra_stale_timer_update(bgp)) | |
2937 | return CMD_WARNING; | |
2938 | ||
2939 | return CMD_SUCCESS; | |
2940 | } | |
2941 | ||
2942 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2943 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2944 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2945 | NO_STR | |
2946 | "BGP specific commands\n" | |
2947 | "Graceful restart configuration parameters\n" | |
2948 | "Specify the stale route removal timer in rib\n" | |
2949 | "Delay value (seconds)\n") | |
2950 | { | |
2951 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2952 | ||
2953 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2954 | /* Send the stale timer update message to RIB */ | |
2955 | if (bgp_zebra_stale_timer_update(bgp)) | |
2956 | return CMD_WARNING; | |
2957 | ||
d6e3c15b | 2958 | return CMD_SUCCESS; |
2959 | } | |
2960 | ||
ff8a8a7a CS |
2961 | static inline int bgp_initiate_graceful_shut_unshut(struct bgp *bgp, |
2962 | char *errmsg, | |
2963 | size_t errmsg_len) | |
05bd726c | 2964 | { |
2965 | bgp_static_redo_import_check(bgp); | |
2966 | bgp_redistribute_redo(bgp); | |
ff8a8a7a CS |
2967 | if (bgp_clear_star_soft_out(bgp->name, errmsg, errmsg_len) < 0) |
2968 | return -1; | |
2969 | if (bgp_clear_star_soft_in(bgp->name, errmsg, errmsg_len) < 0) | |
2970 | return -1; | |
2971 | ||
2972 | return 0; | |
05bd726c | 2973 | } |
2974 | ||
2975 | static int bgp_global_graceful_shutdown_config_vty(struct vty *vty) | |
2976 | { | |
2977 | struct listnode *node, *nnode; | |
2978 | struct bgp *bgp; | |
2979 | bool vrf_cfg = false; | |
ff8a8a7a | 2980 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 2981 | |
2982 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
2983 | return CMD_SUCCESS; | |
2984 | ||
2985 | /* See if graceful-shutdown is set per-vrf and warn user to delete */ | |
2986 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
2987 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2988 | vty_out(vty, | |
2989 | "%% graceful-shutdown configuration found in vrf %s\n", | |
2990 | bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? | |
2991 | VRF_DEFAULT_NAME : bgp->name); | |
2992 | vrf_cfg = true; | |
2993 | } | |
2994 | } | |
2995 | ||
2996 | if (vrf_cfg) { | |
2997 | vty_out(vty, | |
2998 | "%%Failed: global graceful-shutdown not permitted\n"); | |
2999 | return CMD_WARNING; | |
3000 | } | |
3001 | ||
3002 | /* Set flag globally */ | |
3003 | SET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3004 | ||
3005 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3006 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3007 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3008 | sizeof(errmsg)) | |
3009 | < 0) | |
3010 | if (strlen(errmsg)) | |
3011 | vty_out(vty, "%s\n", errmsg); | |
3012 | } | |
05bd726c | 3013 | |
3014 | return CMD_SUCCESS; | |
3015 | } | |
3016 | ||
3017 | static int bgp_global_graceful_shutdown_deconfig_vty(struct vty *vty) | |
3018 | { | |
3019 | struct listnode *node, *nnode; | |
3020 | struct bgp *bgp; | |
ff8a8a7a | 3021 | char errmsg[BUFSIZ] = {'\0'}; |
05bd726c | 3022 | |
3023 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
3024 | return CMD_SUCCESS; | |
3025 | ||
3026 | /* Unset flag globally */ | |
3027 | UNSET_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN); | |
3028 | ||
3029 | /* Initiate processing for all BGP instances. */ | |
ff8a8a7a CS |
3030 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
3031 | if (bgp_initiate_graceful_shut_unshut(bgp, errmsg, | |
3032 | sizeof(errmsg)) | |
3033 | < 0) | |
3034 | if (strlen(errmsg)) | |
3035 | vty_out(vty, "%s\n", errmsg); | |
3036 | } | |
05bd726c | 3037 | |
3038 | return CMD_SUCCESS; | |
3039 | } | |
3040 | ||
7f323236 DW |
3041 | /* "bgp graceful-shutdown" configuration */ |
3042 | DEFUN (bgp_graceful_shutdown, | |
3043 | bgp_graceful_shutdown_cmd, | |
3044 | "bgp graceful-shutdown", | |
3045 | BGP_STR | |
3046 | "Graceful shutdown parameters\n") | |
3047 | { | |
05bd726c | 3048 | if (vty->node == CONFIG_NODE) |
3049 | return bgp_global_graceful_shutdown_config_vty(vty); | |
3050 | ||
87ce2564 CS |
3051 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3052 | NB_OP_MODIFY, "true"); | |
7f323236 | 3053 | |
ff8a8a7a | 3054 | return nb_cli_apply_changes(vty, NULL); |
7f323236 DW |
3055 | } |
3056 | ||
ff8a8a7a | 3057 | DEFUN_YANG (no_bgp_graceful_shutdown, |
7f323236 DW |
3058 | no_bgp_graceful_shutdown_cmd, |
3059 | "no bgp graceful-shutdown", | |
3060 | NO_STR | |
3061 | BGP_STR | |
3062 | "Graceful shutdown parameters\n") | |
3063 | { | |
05bd726c | 3064 | if (vty->node == CONFIG_NODE) |
3065 | return bgp_global_graceful_shutdown_deconfig_vty(vty); | |
3066 | ||
87ce2564 CS |
3067 | nb_cli_enqueue_change(vty, "./global/graceful-shutdown/enable", |
3068 | NB_OP_MODIFY, "false"); | |
05bd726c | 3069 | |
ff8a8a7a CS |
3070 | return nb_cli_apply_changes(vty, NULL); |
3071 | } | |
7f323236 | 3072 | |
ff8a8a7a CS |
3073 | void cli_show_router_bgp_graceful_shutdown(struct vty *vty, |
3074 | struct lyd_node *dnode, | |
3075 | bool show_defaults) | |
3076 | { | |
3077 | if (yang_dnode_get_bool(dnode, NULL)) | |
3078 | vty_out(vty, " bgp graceful-shutdown\n"); | |
7f323236 DW |
3079 | } |
3080 | ||
718e3744 | 3081 | /* "bgp fast-external-failover" configuration. */ |
ff8a8a7a | 3082 | DEFUN_YANG (bgp_fast_external_failover, |
718e3744 | 3083 | bgp_fast_external_failover_cmd, |
3084 | "bgp fast-external-failover", | |
3085 | BGP_STR | |
3086 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3087 | { | |
87ce2564 CS |
3088 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3089 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3090 | |
3091 | return nb_cli_apply_changes(vty, NULL); | |
718e3744 | 3092 | } |
3093 | ||
ff8a8a7a | 3094 | DEFUN_YANG (no_bgp_fast_external_failover, |
718e3744 | 3095 | no_bgp_fast_external_failover_cmd, |
3096 | "no bgp fast-external-failover", | |
3097 | NO_STR | |
3098 | BGP_STR | |
3099 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
3100 | { | |
87ce2564 CS |
3101 | nb_cli_enqueue_change(vty, "./global/fast-external-failover", |
3102 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3103 | |
3104 | return nb_cli_apply_changes(vty, NULL); | |
3105 | } | |
3106 | ||
3107 | void cli_show_router_bgp_fast_external_failover(struct vty *vty, | |
3108 | struct lyd_node *dnode, | |
3109 | bool show_defaults) | |
3110 | { | |
3111 | if (!yang_dnode_get_bool(dnode, NULL)) | |
3112 | vty_out(vty, " no bgp fast-external-failover\n"); | |
718e3744 | 3113 | } |
6b0655a2 | 3114 | |
718e3744 | 3115 | /* "bgp bestpath compare-routerid" configuration. */ |
ff8a8a7a CS |
3116 | DEFUN_YANG(bgp_bestpath_compare_router_id, |
3117 | bgp_bestpath_compare_router_id_cmd, | |
3118 | "bgp bestpath compare-routerid", | |
3119 | "BGP specific commands\n" | |
3120 | "Change the default bestpath selection\n" | |
3121 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3122 | { |
ff8a8a7a | 3123 | nb_cli_enqueue_change( |
87ce2564 CS |
3124 | vty, |
3125 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3126 | NB_OP_MODIFY, "true"); |
7aafcaca | 3127 | |
ff8a8a7a | 3128 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3129 | } |
3130 | ||
ff8a8a7a CS |
3131 | DEFUN_YANG(no_bgp_bestpath_compare_router_id, |
3132 | no_bgp_bestpath_compare_router_id_cmd, | |
3133 | "no bgp bestpath compare-routerid", | |
3134 | NO_STR | |
3135 | "BGP specific commands\n" | |
3136 | "Change the default bestpath selection\n" | |
3137 | "Compare router-id for identical EBGP paths\n") | |
718e3744 | 3138 | { |
ff8a8a7a | 3139 | nb_cli_enqueue_change( |
87ce2564 CS |
3140 | vty, |
3141 | "./global/route-selection-options/external-compare-router-id", | |
ff8a8a7a | 3142 | NB_OP_MODIFY, "false"); |
7aafcaca | 3143 | |
ff8a8a7a | 3144 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3145 | } |
6b0655a2 | 3146 | |
718e3744 | 3147 | /* "bgp bestpath as-path ignore" configuration. */ |
ff8a8a7a CS |
3148 | DEFUN_YANG(bgp_bestpath_aspath_ignore, |
3149 | bgp_bestpath_aspath_ignore_cmd, | |
3150 | "bgp bestpath as-path ignore", | |
3151 | "BGP specific commands\n" | |
3152 | "Change the default bestpath selection\n" | |
3153 | "AS-path attribute\n" | |
3154 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3155 | { |
87ce2564 CS |
3156 | nb_cli_enqueue_change( |
3157 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3158 | NB_OP_MODIFY, "true"); | |
7aafcaca | 3159 | |
ff8a8a7a | 3160 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3161 | } |
3162 | ||
ff8a8a7a CS |
3163 | DEFUN_YANG(no_bgp_bestpath_aspath_ignore, |
3164 | no_bgp_bestpath_aspath_ignore_cmd, | |
3165 | "no bgp bestpath as-path ignore", | |
3166 | NO_STR | |
3167 | "BGP specific commands\n" | |
3168 | "Change the default bestpath selection\n" | |
3169 | "AS-path attribute\n" | |
3170 | "Ignore as-path length in selecting a route\n") | |
718e3744 | 3171 | { |
87ce2564 CS |
3172 | nb_cli_enqueue_change( |
3173 | vty, "./global/route-selection-options/ignore-as-path-length", | |
3174 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3175 | |
ff8a8a7a | 3176 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3177 | } |
6b0655a2 | 3178 | |
6811845b | 3179 | /* "bgp bestpath as-path confed" configuration. */ |
ff8a8a7a | 3180 | DEFUN_YANG (bgp_bestpath_aspath_confed, |
6811845b | 3181 | bgp_bestpath_aspath_confed_cmd, |
3182 | "bgp bestpath as-path confed", | |
3183 | "BGP specific commands\n" | |
3184 | "Change the default bestpath selection\n" | |
3185 | "AS-path attribute\n" | |
3186 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3187 | { | |
87ce2564 CS |
3188 | nb_cli_enqueue_change(vty, |
3189 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3190 | NB_OP_MODIFY, "true"); |
7aafcaca | 3191 | |
ff8a8a7a | 3192 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3193 | } |
3194 | ||
ff8a8a7a | 3195 | DEFUN_YANG (no_bgp_bestpath_aspath_confed, |
6811845b | 3196 | no_bgp_bestpath_aspath_confed_cmd, |
3197 | "no bgp bestpath as-path confed", | |
3198 | NO_STR | |
3199 | "BGP specific commands\n" | |
3200 | "Change the default bestpath selection\n" | |
3201 | "AS-path attribute\n" | |
3202 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
3203 | { | |
87ce2564 CS |
3204 | nb_cli_enqueue_change(vty, |
3205 | "./global/route-selection-options/aspath-confed", | |
ff8a8a7a | 3206 | NB_OP_MODIFY, "false"); |
7aafcaca | 3207 | |
ff8a8a7a | 3208 | return nb_cli_apply_changes(vty, NULL); |
6811845b | 3209 | } |
6b0655a2 | 3210 | |
2fdd455c | 3211 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
ff8a8a7a | 3212 | DEFUN_YANG (bgp_bestpath_aspath_multipath_relax, |
2fdd455c | 3213 | bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3214 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3215 | "BGP specific commands\n" |
3216 | "Change the default bestpath selection\n" | |
3217 | "AS-path attribute\n" | |
3218 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3219 | "Generate an AS_SET\n" |
16fc1eec DS |
3220 | "Do not generate an AS_SET\n") |
3221 | { | |
d62a17ae | 3222 | int idx = 0; |
219178b6 | 3223 | |
87ce2564 CS |
3224 | nb_cli_enqueue_change( |
3225 | vty, "./global/route-selection-options/allow-multiple-as", | |
3226 | NB_OP_MODIFY, "true"); | |
d62a17ae | 3227 | if (argv_find(argv, argc, "as-set", &idx)) |
ff8a8a7a | 3228 | nb_cli_enqueue_change( |
87ce2564 CS |
3229 | vty, |
3230 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3231 | NB_OP_MODIFY, "true"); |
d62a17ae | 3232 | else |
ff8a8a7a | 3233 | nb_cli_enqueue_change( |
87ce2564 CS |
3234 | vty, |
3235 | "./global/route-selection-options/multi-path-as-set", | |
ff8a8a7a | 3236 | NB_OP_MODIFY, "false"); |
7aafcaca | 3237 | |
ff8a8a7a | 3238 | return nb_cli_apply_changes(vty, NULL); |
16fc1eec DS |
3239 | } |
3240 | ||
ff8a8a7a | 3241 | DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax, |
219178b6 | 3242 | no_bgp_bestpath_aspath_multipath_relax_cmd, |
c7178fe7 | 3243 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
3244 | NO_STR |
3245 | "BGP specific commands\n" | |
3246 | "Change the default bestpath selection\n" | |
3247 | "AS-path attribute\n" | |
3248 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 3249 | "Generate an AS_SET\n" |
16fc1eec DS |
3250 | "Do not generate an AS_SET\n") |
3251 | { | |
87ce2564 CS |
3252 | nb_cli_enqueue_change( |
3253 | vty, "./global/route-selection-options/allow-multiple-as", | |
3254 | NB_OP_MODIFY, "false"); | |
3255 | nb_cli_enqueue_change( | |
3256 | vty, "./global/route-selection-options/multi-path-as-set", | |
3257 | NB_OP_MODIFY, "false"); | |
7aafcaca | 3258 | |
ff8a8a7a | 3259 | return nb_cli_apply_changes(vty, NULL); |
2fdd455c | 3260 | } |
6b0655a2 | 3261 | |
848973c7 | 3262 | /* "bgp log-neighbor-changes" configuration. */ |
ff8a8a7a CS |
3263 | DEFUN_YANG(bgp_log_neighbor_changes, |
3264 | bgp_log_neighbor_changes_cmd, | |
3265 | "bgp log-neighbor-changes", | |
3266 | "BGP specific commands\n" | |
3267 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3268 | { |
87ce2564 CS |
3269 | nb_cli_enqueue_change( |
3270 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3271 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3272 | |
3273 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3274 | } |
3275 | ||
ff8a8a7a CS |
3276 | DEFUN_YANG(no_bgp_log_neighbor_changes, |
3277 | no_bgp_log_neighbor_changes_cmd, | |
3278 | "no bgp log-neighbor-changes", | |
3279 | NO_STR | |
3280 | "BGP specific commands\n" | |
3281 | "Log neighbor up/down and reset reason\n") | |
848973c7 | 3282 | { |
87ce2564 CS |
3283 | nb_cli_enqueue_change( |
3284 | vty, "./global/global-neighbor-config/log-neighbor-changes", | |
3285 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3286 | |
3287 | return nb_cli_apply_changes(vty, NULL); | |
848973c7 | 3288 | } |
6b0655a2 | 3289 | |
718e3744 | 3290 | /* "bgp bestpath med" configuration. */ |
ff8a8a7a | 3291 | DEFUN_YANG (bgp_bestpath_med, |
718e3744 | 3292 | bgp_bestpath_med_cmd, |
2d8c1a4d | 3293 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3294 | "BGP specific commands\n" |
3295 | "Change the default bestpath selection\n" | |
3296 | "MED attribute\n" | |
3297 | "Compare MED among confederation paths\n" | |
838758ac DW |
3298 | "Treat missing MED as the least preferred one\n" |
3299 | "Treat missing MED as the least preferred one\n" | |
3300 | "Compare MED among confederation paths\n") | |
718e3744 | 3301 | { |
d62a17ae | 3302 | int idx = 0; |
ff8a8a7a CS |
3303 | bool confed = false; |
3304 | bool worst_med = false; | |
3305 | ||
3306 | ||
d62a17ae | 3307 | if (argv_find(argv, argc, "confed", &idx)) |
ff8a8a7a CS |
3308 | confed = true; |
3309 | ||
87ce2564 CS |
3310 | nb_cli_enqueue_change(vty, |
3311 | "./global/route-selection-options/confed-med", | |
ff8a8a7a CS |
3312 | NB_OP_MODIFY, confed ? "true" : "false"); |
3313 | ||
d62a17ae | 3314 | idx = 0; |
3315 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3316 | worst_med = true; |
e52702f2 | 3317 | |
87ce2564 CS |
3318 | nb_cli_enqueue_change( |
3319 | vty, "./global/route-selection-options/missing-as-worst-med", | |
3320 | NB_OP_MODIFY, worst_med ? "true" : "false"); | |
7aafcaca | 3321 | |
ff8a8a7a | 3322 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3323 | } |
3324 | ||
ff8a8a7a | 3325 | DEFUN_YANG (no_bgp_bestpath_med, |
718e3744 | 3326 | no_bgp_bestpath_med_cmd, |
2d8c1a4d | 3327 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 3328 | NO_STR |
3329 | "BGP specific commands\n" | |
3330 | "Change the default bestpath selection\n" | |
3331 | "MED attribute\n" | |
3332 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
3333 | "Treat missing MED as the least preferred one\n" |
3334 | "Treat missing MED as the least preferred one\n" | |
3335 | "Compare MED among confederation paths\n") | |
718e3744 | 3336 | { |
d62a17ae | 3337 | int idx = 0; |
ff8a8a7a | 3338 | |
d62a17ae | 3339 | if (argv_find(argv, argc, "confed", &idx)) |
87ce2564 CS |
3340 | nb_cli_enqueue_change( |
3341 | vty, "./global/route-selection-options/confed-med", | |
3342 | NB_OP_MODIFY, "false"); | |
ff8a8a7a | 3343 | |
d62a17ae | 3344 | idx = 0; |
3345 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
ff8a8a7a | 3346 | nb_cli_enqueue_change( |
87ce2564 CS |
3347 | vty, |
3348 | "./global/route-selection-options/missing-as-worst-med", | |
ff8a8a7a | 3349 | NB_OP_MODIFY, "false"); |
718e3744 | 3350 | |
ff8a8a7a | 3351 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3352 | } |
3353 | ||
f7e1c681 | 3354 | /* "bgp bestpath bandwidth" configuration. */ |
3355 | DEFPY (bgp_bestpath_bw, | |
3356 | bgp_bestpath_bw_cmd, | |
ad36d216 | 3357 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
f7e1c681 | 3358 | "BGP specific commands\n" |
3359 | "Change the default bestpath selection\n" | |
3360 | "Link Bandwidth attribute\n" | |
3361 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3362 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3363 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3364 | { | |
3365 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3366 | afi_t afi; | |
3367 | safi_t safi; | |
3368 | ||
ad36d216 DS |
3369 | if (!bw_cfg) { |
3370 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3371 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3372 | } |
ad36d216 DS |
3373 | if (!strcmp(bw_cfg, "ignore")) |
3374 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3375 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3376 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3377 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3378 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3379 | else | |
3380 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3381 | |
3382 | /* This config is used in route install, so redo that. */ | |
3383 | FOREACH_AFI_SAFI (afi, safi) { | |
3384 | if (!bgp_fibupd_safi(safi)) | |
3385 | continue; | |
3386 | bgp_zebra_announce_table(bgp, afi, safi); | |
3387 | } | |
3388 | ||
3389 | return CMD_SUCCESS; | |
3390 | } | |
3391 | ||
ad36d216 DS |
3392 | DEFPY (no_bgp_bestpath_bw, |
3393 | no_bgp_bestpath_bw_cmd, | |
3394 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3395 | NO_STR | |
3396 | "BGP specific commands\n" | |
3397 | "Change the default bestpath selection\n" | |
3398 | "Link Bandwidth attribute\n" | |
3399 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3400 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3401 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3402 | { | |
3403 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3404 | afi_t afi; | |
3405 | safi_t safi; | |
3406 | ||
3407 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3408 | ||
3409 | /* This config is used in route install, so redo that. */ | |
3410 | FOREACH_AFI_SAFI (afi, safi) { | |
3411 | if (!bgp_fibupd_safi(safi)) | |
3412 | continue; | |
3413 | bgp_zebra_announce_table(bgp, afi, safi); | |
3414 | } | |
3415 | return CMD_SUCCESS; | |
3416 | } | |
3417 | ||
718e3744 | 3418 | /* "no bgp default ipv4-unicast". */ |
3419 | DEFUN (no_bgp_default_ipv4_unicast, | |
3420 | no_bgp_default_ipv4_unicast_cmd, | |
3421 | "no bgp default ipv4-unicast", | |
3422 | NO_STR | |
3423 | "BGP specific commands\n" | |
3424 | "Configure BGP defaults\n" | |
3425 | "Activate ipv4-unicast for a peer by default\n") | |
3426 | { | |
d62a17ae | 3427 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3428 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3429 | return CMD_SUCCESS; |
718e3744 | 3430 | } |
3431 | ||
3432 | DEFUN (bgp_default_ipv4_unicast, | |
3433 | bgp_default_ipv4_unicast_cmd, | |
3434 | "bgp default ipv4-unicast", | |
3435 | "BGP specific commands\n" | |
3436 | "Configure BGP defaults\n" | |
3437 | "Activate ipv4-unicast for a peer by default\n") | |
3438 | { | |
d62a17ae | 3439 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3440 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3441 | return CMD_SUCCESS; |
718e3744 | 3442 | } |
6b0655a2 | 3443 | |
04b6bdc0 | 3444 | /* Display hostname in certain command outputs */ |
ff8a8a7a | 3445 | DEFUN_YANG (bgp_default_show_hostname, |
04b6bdc0 DW |
3446 | bgp_default_show_hostname_cmd, |
3447 | "bgp default show-hostname", | |
3448 | "BGP specific commands\n" | |
3449 | "Configure BGP defaults\n" | |
0437e105 | 3450 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3451 | { |
87ce2564 CS |
3452 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3453 | "true"); | |
ff8a8a7a CS |
3454 | |
3455 | return nb_cli_apply_changes(vty, NULL); | |
04b6bdc0 DW |
3456 | } |
3457 | ||
ff8a8a7a CS |
3458 | DEFUN_YANG(no_bgp_default_show_hostname, |
3459 | no_bgp_default_show_hostname_cmd, | |
3460 | "no bgp default show-hostname", | |
3461 | NO_STR | |
3462 | "BGP specific commands\n" | |
3463 | "Configure BGP defaults\n" | |
3464 | "Show hostname in certain command outputs\n") | |
04b6bdc0 | 3465 | { |
87ce2564 CS |
3466 | nb_cli_enqueue_change(vty, "./global/show-hostname", NB_OP_MODIFY, |
3467 | "false"); | |
ff8a8a7a CS |
3468 | |
3469 | return nb_cli_apply_changes(vty, NULL); | |
3470 | } | |
3471 | ||
3472 | void cli_show_router_bgp_show_hostname(struct vty *vty, struct lyd_node *dnode, | |
3473 | bool show_defaults) | |
3474 | { | |
3475 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3476 | vty_out(vty, " bgp default show-hostname\n"); | |
04b6bdc0 DW |
3477 | } |
3478 | ||
aef999a2 DA |
3479 | /* Display hostname in certain command outputs */ |
3480 | DEFUN (bgp_default_show_nexthop_hostname, | |
3481 | bgp_default_show_nexthop_hostname_cmd, | |
3482 | "bgp default show-nexthop-hostname", | |
3483 | "BGP specific commands\n" | |
3484 | "Configure BGP defaults\n" | |
3485 | "Show hostname for nexthop in certain command outputs\n") | |
3486 | { | |
87ce2564 CS |
3487 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3488 | NB_OP_MODIFY, "true"); | |
ff8a8a7a CS |
3489 | |
3490 | return nb_cli_apply_changes(vty, NULL); | |
aef999a2 DA |
3491 | } |
3492 | ||
3493 | DEFUN (no_bgp_default_show_nexthop_hostname, | |
3494 | no_bgp_default_show_nexthop_hostname_cmd, | |
3495 | "no bgp default show-nexthop-hostname", | |
3496 | NO_STR | |
3497 | "BGP specific commands\n" | |
3498 | "Configure BGP defaults\n" | |
3499 | "Show hostname for nexthop in certain command outputs\n") | |
3500 | { | |
87ce2564 CS |
3501 | nb_cli_enqueue_change(vty, "./global/show-nexthop-hostname", |
3502 | NB_OP_MODIFY, "false"); | |
ff8a8a7a CS |
3503 | |
3504 | return nb_cli_apply_changes(vty, NULL); | |
3505 | } | |
3506 | ||
3507 | void cli_show_router_bgp_show_nexthop_hostname(struct vty *vty, | |
3508 | struct lyd_node *dnode, | |
3509 | bool show_defaults) | |
3510 | { | |
3511 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_SHOW_HOSTNAME) | |
3512 | vty_out(vty, " bgp default show-nexthop-hostname\n"); | |
aef999a2 DA |
3513 | } |
3514 | ||
8233ef81 | 3515 | /* "bgp network import-check" configuration. */ |
ff8a8a7a CS |
3516 | DEFUN_YANG(bgp_network_import_check, |
3517 | bgp_network_import_check_cmd, | |
3518 | "bgp network import-check", | |
3519 | "BGP specific commands\n" | |
3520 | "BGP network command\n" | |
3521 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3522 | { |
87ce2564 CS |
3523 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3524 | "true"); | |
078430f6 | 3525 | |
ff8a8a7a | 3526 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3527 | } |
3528 | ||
d62a17ae | 3529 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3530 | "bgp network import-check exact", | |
3531 | "BGP specific commands\n" | |
3532 | "BGP network command\n" | |
3533 | "Check BGP network route exists in IGP\n" | |
3534 | "Match route precisely\n") | |
8233ef81 | 3535 | |
ff8a8a7a CS |
3536 | DEFUN_YANG(no_bgp_network_import_check, |
3537 | no_bgp_network_import_check_cmd, | |
3538 | "no bgp network import-check", | |
3539 | NO_STR | |
3540 | "BGP specific commands\n" | |
3541 | "BGP network command\n" | |
3542 | "Check BGP network route exists in IGP\n") | |
718e3744 | 3543 | { |
87ce2564 CS |
3544 | nb_cli_enqueue_change(vty, "./global/import-check", NB_OP_MODIFY, |
3545 | "false"); | |
5623e905 | 3546 | |
ff8a8a7a | 3547 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3548 | } |
6b0655a2 | 3549 | |
ff8a8a7a CS |
3550 | void cli_show_router_bgp_import_check(struct vty *vty, struct lyd_node *dnode, |
3551 | bool show_defaults) | |
718e3744 | 3552 | { |
ff8a8a7a CS |
3553 | if (yang_dnode_get_bool(dnode, NULL) != SAVE_BGP_IMPORT_CHECK) |
3554 | vty_out(vty, " bgp network import-check\n"); | |
3555 | } | |
718e3744 | 3556 | |
ff8a8a7a CS |
3557 | DEFUN_YANG(bgp_default_local_preference, |
3558 | bgp_default_local_preference_cmd, | |
3559 | "bgp default local-preference (0-4294967295)", | |
3560 | "BGP specific commands\n" | |
3561 | "Configure BGP defaults\n" | |
3562 | "local preference (higher=more preferred)\n" | |
3563 | "Configure default local preference value\n") | |
3564 | { | |
3565 | int idx_number = 3; | |
718e3744 | 3566 | |
87ce2564 | 3567 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, |
ff8a8a7a | 3568 | argv[idx_number]->arg); |
718e3744 | 3569 | |
ff8a8a7a | 3570 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3571 | } |
3572 | ||
ff8a8a7a CS |
3573 | DEFUN_YANG(no_bgp_default_local_preference, |
3574 | no_bgp_default_local_preference_cmd, | |
3575 | "no bgp default local-preference [(0-4294967295)]", | |
3576 | NO_STR | |
3577 | "BGP specific commands\n" | |
3578 | "Configure BGP defaults\n" | |
3579 | "local preference (higher=more preferred)\n" | |
3580 | "Configure default local preference value\n") | |
718e3744 | 3581 | { |
87ce2564 | 3582 | nb_cli_enqueue_change(vty, "./global/local-pref", NB_OP_MODIFY, NULL); |
7aafcaca | 3583 | |
ff8a8a7a | 3584 | return nb_cli_apply_changes(vty, NULL); |
718e3744 | 3585 | } |
3586 | ||
ff8a8a7a CS |
3587 | void cli_show_router_bgp_local_pref(struct vty *vty, struct lyd_node *dnode, |
3588 | bool show_defaults) | |
3589 | { | |
3590 | vty_out(vty, " bgp default local-preference %u\n", | |
3591 | yang_dnode_get_uint32(dnode, NULL)); | |
3592 | } | |
6b0655a2 | 3593 | |
ff8a8a7a CS |
3594 | |
3595 | DEFUN_YANG(bgp_default_subgroup_pkt_queue_max, | |
3596 | bgp_default_subgroup_pkt_queue_max_cmd, | |
3597 | "bgp default subgroup-pkt-queue-max (20-100)", | |
3598 | "BGP specific commands\n" | |
3599 | "Configure BGP defaults\n" | |
3600 | "subgroup-pkt-queue-max\n" | |
3601 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3602 | { |
d62a17ae | 3603 | int idx_number = 3; |
3f9c7369 | 3604 | |
ff8a8a7a | 3605 | nb_cli_enqueue_change( |
87ce2564 CS |
3606 | vty, |
3607 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a | 3608 | NB_OP_MODIFY, argv[idx_number]->arg); |
3f9c7369 | 3609 | |
ff8a8a7a | 3610 | return nb_cli_apply_changes(vty, NULL); |
3f9c7369 DS |
3611 | } |
3612 | ||
ff8a8a7a CS |
3613 | DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max, |
3614 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
3615 | "no bgp default subgroup-pkt-queue-max [(20-100)]", | |
3616 | NO_STR | |
3617 | "BGP specific commands\n" | |
3618 | "Configure BGP defaults\n" | |
3619 | "subgroup-pkt-queue-max\n" | |
3620 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3621 | { |
ff8a8a7a | 3622 | nb_cli_enqueue_change( |
87ce2564 CS |
3623 | vty, |
3624 | "./global/global-update-group-config/subgroup-pkt-queue-size", | |
ff8a8a7a CS |
3625 | NB_OP_MODIFY, NULL); |
3626 | ||
3627 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3628 | } |
3629 | ||
ff8a8a7a CS |
3630 | void cli_show_router_global_update_group_config_subgroup_pkt_queue_size( |
3631 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3632 | { | |
3633 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
3634 | yang_dnode_get_uint32(dnode, NULL)); | |
3635 | } | |
813d4307 | 3636 | |
ff8a8a7a CS |
3637 | DEFUN_YANG(bgp_rr_allow_outbound_policy, |
3638 | bgp_rr_allow_outbound_policy_cmd, | |
3639 | "bgp route-reflector allow-outbound-policy", | |
3640 | "BGP specific commands\n" | |
3641 | "Allow modifications made by out route-map\n" | |
3642 | "on ibgp neighbors\n") | |
8bd9d948 | 3643 | { |
87ce2564 CS |
3644 | nb_cli_enqueue_change(vty, |
3645 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a | 3646 | NB_OP_MODIFY, "true"); |
8bd9d948 | 3647 | |
ff8a8a7a CS |
3648 | return nb_cli_apply_changes(vty, NULL); |
3649 | } | |
8bd9d948 | 3650 | |
ff8a8a7a CS |
3651 | DEFUN_YANG(no_bgp_rr_allow_outbound_policy, |
3652 | no_bgp_rr_allow_outbound_policy_cmd, | |
3653 | "no bgp route-reflector allow-outbound-policy", | |
3654 | NO_STR | |
3655 | "BGP specific commands\n" | |
3656 | "Allow modifications made by out route-map\n" | |
3657 | "on ibgp neighbors\n") | |
3658 | { | |
87ce2564 CS |
3659 | nb_cli_enqueue_change(vty, |
3660 | "./global/route-reflector/allow-outbound-policy", | |
ff8a8a7a CS |
3661 | NB_OP_MODIFY, "false"); |
3662 | ||
3663 | return nb_cli_apply_changes(vty, NULL); | |
8bd9d948 DS |
3664 | } |
3665 | ||
ff8a8a7a CS |
3666 | |
3667 | void cli_show_router_global_neighbor_config(struct vty *vty, | |
3668 | struct lyd_node *dnode, | |
3669 | bool show_defaults) | |
8bd9d948 | 3670 | { |
ff8a8a7a CS |
3671 | uint32_t write_quanta, read_quanta; |
3672 | ||
3673 | if (yang_dnode_get_bool(dnode, "./log-neighbor-changes")) | |
3674 | vty_out(vty, " bgp log-neighbor-changes\n"); | |
8bd9d948 | 3675 | |
ff8a8a7a CS |
3676 | if (yang_dnode_exists(dnode, "./dynamic-neighbors-limit")) { |
3677 | uint32_t listen_limit = yang_dnode_get_uint32( | |
3678 | dnode, "./dynamic-neighbors-limit"); | |
3679 | vty_out(vty, " bgp listen limit %u\n", listen_limit); | |
d62a17ae | 3680 | } |
8bd9d948 | 3681 | |
ff8a8a7a CS |
3682 | write_quanta = yang_dnode_get_uint32( |
3683 | dnode, "./packet-quanta-config/wpkt-quanta"); | |
3684 | if (write_quanta != BGP_WRITE_PACKET_MAX) | |
3685 | vty_out(vty, " write-quanta %d\n", write_quanta); | |
3686 | ||
3687 | read_quanta = yang_dnode_get_uint32( | |
3688 | dnode, "./packet-quanta-config/rpkt-quanta"); | |
3689 | ||
3690 | if (read_quanta != BGP_READ_PACKET_MAX) | |
3691 | vty_out(vty, " read-quanta %d\n", read_quanta); | |
8bd9d948 DS |
3692 | } |
3693 | ||
ff8a8a7a CS |
3694 | DEFUN_YANG(bgp_listen_limit, |
3695 | bgp_listen_limit_cmd, | |
3696 | "bgp listen limit (1-5000)", | |
3697 | "BGP specific commands\n" | |
3698 | "BGP Dynamic Neighbors listen commands\n" | |
3699 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3700 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3701 | { |
d62a17ae | 3702 | int idx_number = 3; |
f14e6fdb | 3703 | |
ff8a8a7a | 3704 | nb_cli_enqueue_change( |
87ce2564 | 3705 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a | 3706 | NB_OP_MODIFY, argv[idx_number]->arg); |
f14e6fdb | 3707 | |
ff8a8a7a | 3708 | return nb_cli_apply_changes(vty, NULL); |
f14e6fdb DS |
3709 | } |
3710 | ||
ff8a8a7a CS |
3711 | DEFUN_YANG(no_bgp_listen_limit, |
3712 | no_bgp_listen_limit_cmd, | |
3713 | "no bgp listen limit [(1-5000)]", | |
3714 | NO_STR | |
3715 | "BGP specific commands\n" | |
3716 | "BGP Dynamic Neighbors listen commands\n" | |
3717 | "Maximum number of BGP Dynamic Neighbors that can be created\n" | |
3718 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 3719 | { |
ff8a8a7a | 3720 | nb_cli_enqueue_change( |
87ce2564 | 3721 | vty, "./global/global-neighbor-config/dynamic-neighbors-limit", |
ff8a8a7a CS |
3722 | NB_OP_DESTROY, NULL); |
3723 | ||
3724 | return nb_cli_apply_changes(vty, NULL); | |
f14e6fdb DS |
3725 | } |
3726 | ||
3727 | ||
20eb8864 | 3728 | /* |
3729 | * Check if this listen range is already configured. Check for exact | |
3730 | * match or overlap based on input. | |
3731 | */ | |
d62a17ae | 3732 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3733 | struct prefix *range, int exact) | |
3734 | { | |
3735 | struct listnode *node, *nnode; | |
3736 | struct listnode *node1, *nnode1; | |
3737 | struct peer_group *group; | |
3738 | struct prefix *lr; | |
3739 | afi_t afi; | |
3740 | int match; | |
3741 | ||
3742 | afi = family2afi(range->family); | |
3743 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3744 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3745 | lr)) { | |
3746 | if (exact) | |
3747 | match = prefix_same(range, lr); | |
3748 | else | |
3749 | match = (prefix_match(range, lr) | |
3750 | || prefix_match(lr, range)); | |
3751 | if (match) | |
3752 | return group; | |
3753 | } | |
3754 | } | |
3755 | ||
3756 | return NULL; | |
20eb8864 | 3757 | } |
3758 | ||
f14e6fdb DS |
3759 | DEFUN (bgp_listen_range, |
3760 | bgp_listen_range_cmd, | |
d7b9898c | 3761 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3762 | "BGP specific commands\n" |
d7fa34c1 QY |
3763 | "Configure BGP dynamic neighbors listen range\n" |
3764 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3765 | NEIGHBOR_ADDR_STR |
3766 | "Member of the peer-group\n" | |
3767 | "Peer-group name\n") | |
f14e6fdb | 3768 | { |
d62a17ae | 3769 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3770 | struct prefix range; | |
3771 | struct peer_group *group, *existing_group; | |
3772 | afi_t afi; | |
3773 | int ret; | |
3774 | int idx = 0; | |
3775 | ||
3776 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3777 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3778 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3779 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3780 | char *peergroup = argv[idx]->arg; |
3781 | ||
3782 | /* Convert IP prefix string to struct prefix. */ | |
3783 | ret = str2prefix(prefix, &range); | |
3784 | if (!ret) { | |
3785 | vty_out(vty, "%% Malformed listen range\n"); | |
3786 | return CMD_WARNING_CONFIG_FAILED; | |
3787 | } | |
3788 | ||
3789 | afi = family2afi(range.family); | |
3790 | ||
3791 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3792 | vty_out(vty, | |
3793 | "%% Malformed listen range (link-local address)\n"); | |
3794 | return CMD_WARNING_CONFIG_FAILED; | |
3795 | } | |
3796 | ||
3797 | apply_mask(&range); | |
3798 | ||
3799 | /* Check if same listen range is already configured. */ | |
3800 | existing_group = listen_range_exists(bgp, &range, 1); | |
3801 | if (existing_group) { | |
3802 | if (strcmp(existing_group->name, peergroup) == 0) | |
3803 | return CMD_SUCCESS; | |
3804 | else { | |
3805 | vty_out(vty, | |
3806 | "%% Same listen range is attached to peer-group %s\n", | |
3807 | existing_group->name); | |
3808 | return CMD_WARNING_CONFIG_FAILED; | |
3809 | } | |
3810 | } | |
3811 | ||
3812 | /* Check if an overlapping listen range exists. */ | |
3813 | if (listen_range_exists(bgp, &range, 0)) { | |
3814 | vty_out(vty, | |
3815 | "%% Listen range overlaps with existing listen range\n"); | |
3816 | return CMD_WARNING_CONFIG_FAILED; | |
3817 | } | |
3818 | ||
3819 | group = peer_group_lookup(bgp, peergroup); | |
3820 | if (!group) { | |
3821 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3822 | return CMD_WARNING_CONFIG_FAILED; | |
3823 | } | |
3824 | ||
3825 | ret = peer_group_listen_range_add(group, &range); | |
3826 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3827 | } |
3828 | ||
3829 | DEFUN (no_bgp_listen_range, | |
3830 | no_bgp_listen_range_cmd, | |
d7b9898c | 3831 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3832 | NO_STR |
f14e6fdb | 3833 | "BGP specific commands\n" |
d7fa34c1 QY |
3834 | "Unconfigure BGP dynamic neighbors listen range\n" |
3835 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3836 | NEIGHBOR_ADDR_STR | |
3837 | "Member of the peer-group\n" | |
3838 | "Peer-group name\n") | |
f14e6fdb | 3839 | { |
d62a17ae | 3840 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3841 | struct prefix range; | |
3842 | struct peer_group *group; | |
3843 | afi_t afi; | |
3844 | int ret; | |
3845 | int idx = 0; | |
3846 | ||
3847 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3848 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3849 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3850 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3851 | char *peergroup = argv[idx]->arg; |
3852 | ||
3853 | /* Convert IP prefix string to struct prefix. */ | |
3854 | ret = str2prefix(prefix, &range); | |
3855 | if (!ret) { | |
3856 | vty_out(vty, "%% Malformed listen range\n"); | |
3857 | return CMD_WARNING_CONFIG_FAILED; | |
3858 | } | |
3859 | ||
3860 | afi = family2afi(range.family); | |
3861 | ||
3862 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3863 | vty_out(vty, | |
3864 | "%% Malformed listen range (link-local address)\n"); | |
3865 | return CMD_WARNING_CONFIG_FAILED; | |
3866 | } | |
3867 | ||
3868 | apply_mask(&range); | |
3869 | ||
3870 | group = peer_group_lookup(bgp, peergroup); | |
3871 | if (!group) { | |
3872 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3873 | return CMD_WARNING_CONFIG_FAILED; | |
3874 | } | |
3875 | ||
3876 | ret = peer_group_listen_range_del(group, &range); | |
3877 | return bgp_vty_return(vty, ret); | |
3878 | } | |
3879 | ||
2b791107 | 3880 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3881 | { |
3882 | struct peer_group *group; | |
3883 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3884 | struct prefix *range; | |
3885 | afi_t afi; | |
d62a17ae | 3886 | |
3887 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3888 | vty_out(vty, " bgp listen limit %d\n", | |
3889 | bgp->dynamic_neighbors_limit); | |
3890 | ||
3891 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3892 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3893 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3894 | nrnode, range)) { | |
d62a17ae | 3895 | vty_out(vty, |
2dbe669b DA |
3896 | " bgp listen range %pFX peer-group %s\n", |
3897 | range, group->name); | |
d62a17ae | 3898 | } |
3899 | } | |
3900 | } | |
f14e6fdb DS |
3901 | } |
3902 | ||
3903 | ||
ff8a8a7a CS |
3904 | DEFUN_YANG(bgp_disable_connected_route_check, |
3905 | bgp_disable_connected_route_check_cmd, | |
3906 | "bgp disable-ebgp-connected-route-check", | |
3907 | "BGP specific commands\n" | |
3908 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 3909 | { |
87ce2564 CS |
3910 | nb_cli_enqueue_change(vty, |
3911 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 3912 | NB_OP_MODIFY, "true"); |
7aafcaca | 3913 | |
ff8a8a7a | 3914 | return nb_cli_apply_changes(vty, NULL); |
907f92c8 DS |
3915 | } |
3916 | ||
ff8a8a7a CS |
3917 | DEFUN_YANG(no_bgp_disable_connected_route_check, |
3918 | no_bgp_disable_connected_route_check_cmd, | |
3919 | "no bgp disable-ebgp-connected-route-check", | |
3920 | NO_STR | |
3921 | "BGP specific commands\n" | |
3922 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
907f92c8 | 3923 | { |
87ce2564 CS |
3924 | nb_cli_enqueue_change(vty, |
3925 | "./global/ebgp-multihop-connected-route-check", | |
ff8a8a7a | 3926 | NB_OP_MODIFY, "false"); |
d62a17ae | 3927 | |
ff8a8a7a | 3928 | return nb_cli_apply_changes(vty, NULL); |
d62a17ae | 3929 | } |
3930 | ||
ff8a8a7a CS |
3931 | void cli_show_router_global_ebgp_multihop_connected_route_check( |
3932 | struct vty *vty, struct lyd_node *dnode, bool show_defaults) | |
3933 | { | |
3934 | if (yang_dnode_get_bool(dnode, NULL)) | |
3935 | vty_out(vty, " bgp disable-ebgp-connected-route-check\n"); | |
3936 | } | |
d62a17ae | 3937 | |
3938 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3939 | const char *as_str, afi_t afi, safi_t safi) | |
3940 | { | |
3941 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3942 | int ret; | |
3943 | as_t as; | |
3944 | int as_type = AS_SPECIFIED; | |
3945 | union sockunion su; | |
3946 | ||
3947 | if (as_str[0] == 'i') { | |
3948 | as = 0; | |
3949 | as_type = AS_INTERNAL; | |
3950 | } else if (as_str[0] == 'e') { | |
3951 | as = 0; | |
3952 | as_type = AS_EXTERNAL; | |
3953 | } else { | |
3954 | /* Get AS number. */ | |
3955 | as = strtoul(as_str, NULL, 10); | |
3956 | } | |
3957 | ||
390485fd | 3958 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3959 | ret = str2sockunion(peer_str, &su); |
3960 | if (ret < 0) { | |
390485fd DS |
3961 | struct peer *peer; |
3962 | ||
3963 | /* Check if existing interface peer */ | |
3964 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3965 | ||
d62a17ae | 3966 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3967 | safi); | |
390485fd DS |
3968 | |
3969 | /* if not interface peer, check peer-group settings */ | |
3970 | if (ret < 0 && !peer) { | |
d62a17ae | 3971 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3972 | if (ret < 0) { | |
3973 | vty_out(vty, | |
390485fd | 3974 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3975 | return CMD_WARNING_CONFIG_FAILED; |
3976 | } | |
3977 | return CMD_SUCCESS; | |
3978 | } | |
3979 | } else { | |
3980 | if (peer_address_self_check(bgp, &su)) { | |
3981 | vty_out(vty, | |
3982 | "%% Can not configure the local system as neighbor\n"); | |
3983 | return CMD_WARNING_CONFIG_FAILED; | |
3984 | } | |
3985 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3986 | } | |
3987 | ||
3988 | /* This peer belongs to peer group. */ | |
3989 | switch (ret) { | |
3990 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3991 | vty_out(vty, | |
faa16034 | 3992 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3993 | return CMD_WARNING_CONFIG_FAILED; |
3994 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3995 | vty_out(vty, | |
faa16034 | 3996 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3997 | return CMD_WARNING_CONFIG_FAILED; |
3998 | } | |
3999 | return bgp_vty_return(vty, ret); | |
718e3744 | 4000 | } |
4001 | ||
ff8a8a7a CS |
4002 | DEFUN_YANG(bgp_default_shutdown, |
4003 | bgp_default_shutdown_cmd, | |
4004 | "[no] bgp default shutdown", | |
4005 | NO_STR BGP_STR | |
4006 | "Configure BGP defaults\n" | |
4007 | "Apply administrative shutdown to newly configured peers\n") | |
f26845f9 | 4008 | { |
87ce2564 | 4009 | nb_cli_enqueue_change(vty, "./global/default-shutdown", NB_OP_MODIFY, |
ff8a8a7a CS |
4010 | strmatch(argv[0]->text, "no") ? "false" : "true"); |
4011 | ||
4012 | return nb_cli_apply_changes(vty, NULL); | |
4013 | } | |
4014 | ||
4015 | void cli_show_router_bgp_default_shutdown(struct vty *vty, | |
4016 | struct lyd_node *dnode, | |
4017 | bool show_defaults) | |
4018 | { | |
4019 | if (yang_dnode_get_bool(dnode, NULL)) | |
4020 | vty_out(vty, " bgp default shutdown\n"); | |
f26845f9 QY |
4021 | } |
4022 | ||
736b68f3 DS |
4023 | DEFPY(bgp_shutdown_msg, bgp_shutdown_msg_cmd, "bgp shutdown message MSG...", |
4024 | BGP_STR | |
9ddf4b81 | 4025 | "Administrative shutdown of the BGP instance\n" |
736b68f3 DS |
4026 | "Add a shutdown message (RFC 8203)\n" |
4027 | "Shutdown message\n") | |
9cf59432 | 4028 | { |
736b68f3 | 4029 | char *msgstr = NULL; |
8389c83a | 4030 | |
9cf59432 DS |
4031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4032 | ||
8389c83a | 4033 | if (argc > 3) |
f80e35b6 | 4034 | msgstr = argv_concat(argv, argc, 3); |
8389c83a DS |
4035 | |
4036 | bgp_shutdown_enable(bgp, msgstr); | |
4037 | XFREE(MTYPE_TMP, msgstr); | |
9cf59432 DS |
4038 | |
4039 | return CMD_SUCCESS; | |
4040 | } | |
4041 | ||
736b68f3 | 4042 | DEFPY(bgp_shutdown, bgp_shutdown_cmd, "bgp shutdown", |
9ddf4b81 | 4043 | BGP_STR "Administrative shutdown of the BGP instance\n") |
1e12ebbc DS |
4044 | { |
4045 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4046 | ||
4047 | bgp_shutdown_enable(bgp, NULL); | |
4048 | ||
4049 | return CMD_SUCCESS; | |
4050 | } | |
8389c83a | 4051 | |
736b68f3 | 4052 | DEFPY(no_bgp_shutdown, no_bgp_shutdown_cmd, "no bgp shutdown", |
9ddf4b81 | 4053 | NO_STR BGP_STR "Administrative shutdown of the BGP instance\n") |
9cf59432 DS |
4054 | { |
4055 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4056 | ||
4057 | bgp_shutdown_disable(bgp); | |
4058 | ||
4059 | return CMD_SUCCESS; | |
4060 | } | |
4061 | ||
9ddf4b81 | 4062 | ALIAS(no_bgp_shutdown, no_bgp_shutdown_msg_cmd, |
1b6e7a88 | 4063 | "no bgp shutdown message MSG...", NO_STR BGP_STR |
9ddf4b81 | 4064 | "Administrative shutdown of the BGP instance\n" |
1b6e7a88 | 4065 | "Add a shutdown message (RFC 8203)\n" "Shutdown message\n") |
1b6e7a88 | 4066 | |
718e3744 | 4067 | DEFUN (neighbor_remote_as, |
4068 | neighbor_remote_as_cmd, | |
3a2d747c | 4069 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 4070 | NEIGHBOR_STR |
4071 | NEIGHBOR_ADDR_STR2 | |
4072 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 4073 | AS_STR |
3a2d747c QY |
4074 | "Internal BGP peer\n" |
4075 | "External BGP peer\n") | |
718e3744 | 4076 | { |
d62a17ae | 4077 | int idx_peer = 1; |
4078 | int idx_remote_as = 3; | |
4079 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
4080 | argv[idx_remote_as]->arg, AFI_IP, | |
4081 | SAFI_UNICAST); | |
4082 | } | |
4083 | ||
4084 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
4085 | afi_t afi, safi_t safi, int v6only, | |
4086 | const char *peer_group_name, | |
4087 | const char *as_str) | |
4088 | { | |
4089 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
4090 | as_t as = 0; | |
4091 | int as_type = AS_UNSPECIFIED; | |
4092 | struct peer *peer; | |
4093 | struct peer_group *group; | |
4094 | int ret = 0; | |
4095 | union sockunion su; | |
4096 | ||
4097 | group = peer_group_lookup(bgp, conf_if); | |
4098 | ||
4099 | if (group) { | |
4100 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
4101 | return CMD_WARNING_CONFIG_FAILED; | |
4102 | } | |
4103 | ||
4104 | if (as_str) { | |
4105 | if (as_str[0] == 'i') { | |
4106 | as_type = AS_INTERNAL; | |
4107 | } else if (as_str[0] == 'e') { | |
4108 | as_type = AS_EXTERNAL; | |
4109 | } else { | |
4110 | /* Get AS number. */ | |
4111 | as = strtoul(as_str, NULL, 10); | |
4112 | as_type = AS_SPECIFIED; | |
4113 | } | |
4114 | } | |
4115 | ||
4116 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
4117 | if (peer) { | |
4118 | if (as_str) | |
cc4d4ce8 | 4119 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 4120 | afi, safi); |
4121 | } else { | |
892fedb6 | 4122 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 4123 | && afi == AFI_IP && safi == SAFI_UNICAST) |
4124 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4125 | as_type, 0, 0, NULL); | |
4126 | else | |
4127 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
4128 | as_type, afi, safi, NULL); | |
4129 | ||
4130 | if (!peer) { | |
4131 | vty_out(vty, "%% BGP failed to create peer\n"); | |
4132 | return CMD_WARNING_CONFIG_FAILED; | |
4133 | } | |
4134 | ||
4135 | if (v6only) | |
527de3dc | 4136 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4137 | |
4138 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
4139 | * this | |
4140 | * any unnumbered peer in order to not worry about run-time | |
4141 | * transitions | |
4142 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
4143 | * address | |
4144 | * gets deleted later etc.) | |
4145 | */ | |
4146 | if (peer->ifp) | |
4147 | bgp_zebra_initiate_radv(bgp, peer); | |
4148 | } | |
4149 | ||
4150 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
4151 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
4152 | if (v6only) | |
527de3dc | 4153 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4154 | else |
527de3dc | 4155 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 4156 | |
4157 | /* v6only flag changed. Reset bgp seesion */ | |
4158 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
4159 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
4160 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
4161 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
4162 | } else | |
4163 | bgp_session_reset(peer); | |
4164 | } | |
4165 | ||
9fb964de PM |
4166 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
4167 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
4168 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 4169 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 4170 | } |
d62a17ae | 4171 | |
4172 | if (peer_group_name) { | |
4173 | group = peer_group_lookup(bgp, peer_group_name); | |
4174 | if (!group) { | |
4175 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4176 | return CMD_WARNING_CONFIG_FAILED; | |
4177 | } | |
4178 | ||
4179 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4180 | } | |
4181 | ||
4182 | return bgp_vty_return(vty, ret); | |
a80beece DS |
4183 | } |
4184 | ||
4c48cf63 DW |
4185 | DEFUN (neighbor_interface_config, |
4186 | neighbor_interface_config_cmd, | |
d7b9898c | 4187 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
4188 | NEIGHBOR_STR |
4189 | "Interface name or neighbor tag\n" | |
31500417 DW |
4190 | "Enable BGP on interface\n" |
4191 | "Member of the peer-group\n" | |
16cedbb0 | 4192 | "Peer-group name\n") |
4c48cf63 | 4193 | { |
d62a17ae | 4194 | int idx_word = 1; |
4195 | int idx_peer_group_word = 4; | |
31500417 | 4196 | |
d62a17ae | 4197 | if (argc > idx_peer_group_word) |
4198 | return peer_conf_interface_get( | |
4199 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
4200 | argv[idx_peer_group_word]->arg, NULL); | |
4201 | else | |
4202 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
4203 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
4204 | } |
4205 | ||
4c48cf63 DW |
4206 | DEFUN (neighbor_interface_config_v6only, |
4207 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 4208 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
4209 | NEIGHBOR_STR |
4210 | "Interface name or neighbor tag\n" | |
4211 | "Enable BGP on interface\n" | |
31500417 DW |
4212 | "Enable BGP with v6 link-local only\n" |
4213 | "Member of the peer-group\n" | |
16cedbb0 | 4214 | "Peer-group name\n") |
4c48cf63 | 4215 | { |
d62a17ae | 4216 | int idx_word = 1; |
4217 | int idx_peer_group_word = 5; | |
31500417 | 4218 | |
d62a17ae | 4219 | if (argc > idx_peer_group_word) |
4220 | return peer_conf_interface_get( | |
4221 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
4222 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 4223 | |
d62a17ae | 4224 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
4225 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
4226 | } |
4227 | ||
a80beece | 4228 | |
b3a39dc5 DD |
4229 | DEFUN (neighbor_interface_config_remote_as, |
4230 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 4231 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
4232 | NEIGHBOR_STR |
4233 | "Interface name or neighbor tag\n" | |
4234 | "Enable BGP on interface\n" | |
3a2d747c | 4235 | "Specify a BGP neighbor\n" |
d7fa34c1 | 4236 | AS_STR |
3a2d747c QY |
4237 | "Internal BGP peer\n" |
4238 | "External BGP peer\n") | |
b3a39dc5 | 4239 | { |
d62a17ae | 4240 | int idx_word = 1; |
4241 | int idx_remote_as = 4; | |
4242 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
4243 | SAFI_UNICAST, 0, NULL, | |
4244 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4245 | } |
4246 | ||
4247 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
4248 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 4249 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
4250 | NEIGHBOR_STR |
4251 | "Interface name or neighbor tag\n" | |
3a2d747c | 4252 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 4253 | "Enable BGP on interface\n" |
3a2d747c | 4254 | "Specify a BGP neighbor\n" |
d7fa34c1 | 4255 | AS_STR |
3a2d747c QY |
4256 | "Internal BGP peer\n" |
4257 | "External BGP peer\n") | |
b3a39dc5 | 4258 | { |
d62a17ae | 4259 | int idx_word = 1; |
4260 | int idx_remote_as = 5; | |
4261 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
4262 | SAFI_UNICAST, 1, NULL, | |
4263 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
4264 | } |
4265 | ||
718e3744 | 4266 | DEFUN (neighbor_peer_group, |
4267 | neighbor_peer_group_cmd, | |
4268 | "neighbor WORD peer-group", | |
4269 | NEIGHBOR_STR | |
a80beece | 4270 | "Interface name or neighbor tag\n" |
718e3744 | 4271 | "Configure peer-group\n") |
4272 | { | |
d62a17ae | 4273 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4274 | int idx_word = 1; | |
4275 | struct peer *peer; | |
4276 | struct peer_group *group; | |
718e3744 | 4277 | |
d62a17ae | 4278 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
4279 | if (peer) { | |
4280 | vty_out(vty, "%% Name conflict with interface: \n"); | |
4281 | return CMD_WARNING_CONFIG_FAILED; | |
4282 | } | |
718e3744 | 4283 | |
d62a17ae | 4284 | group = peer_group_get(bgp, argv[idx_word]->arg); |
4285 | if (!group) { | |
4286 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
4287 | return CMD_WARNING_CONFIG_FAILED; | |
4288 | } | |
718e3744 | 4289 | |
d62a17ae | 4290 | return CMD_SUCCESS; |
718e3744 | 4291 | } |
4292 | ||
4293 | DEFUN (no_neighbor, | |
4294 | no_neighbor_cmd, | |
dab8cd00 | 4295 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 4296 | NO_STR |
4297 | NEIGHBOR_STR | |
3a2d747c QY |
4298 | NEIGHBOR_ADDR_STR2 |
4299 | "Specify a BGP neighbor\n" | |
4300 | AS_STR | |
4301 | "Internal BGP peer\n" | |
4302 | "External BGP peer\n") | |
718e3744 | 4303 | { |
d62a17ae | 4304 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4305 | int idx_peer = 2; | |
4306 | int ret; | |
4307 | union sockunion su; | |
4308 | struct peer_group *group; | |
4309 | struct peer *peer; | |
4310 | struct peer *other; | |
4311 | ||
4312 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
4313 | if (ret < 0) { | |
4314 | /* look up for neighbor by interface name config. */ | |
4315 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4316 | if (peer) { | |
4317 | /* Request zebra to terminate IPv6 RAs on this | |
4318 | * interface. */ | |
4319 | if (peer->ifp) | |
4320 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 4321 | peer_notify_unconfig(peer); |
d62a17ae | 4322 | peer_delete(peer); |
4323 | return CMD_SUCCESS; | |
4324 | } | |
f14e6fdb | 4325 | |
d62a17ae | 4326 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
4327 | if (group) { |
4328 | peer_group_notify_unconfig(group); | |
d62a17ae | 4329 | peer_group_delete(group); |
4e2786df | 4330 | } else { |
d62a17ae | 4331 | vty_out(vty, "%% Create the peer-group first\n"); |
4332 | return CMD_WARNING_CONFIG_FAILED; | |
4333 | } | |
4334 | } else { | |
4335 | peer = peer_lookup(bgp, &su); | |
4336 | if (peer) { | |
4337 | if (peer_dynamic_neighbor(peer)) { | |
4338 | vty_out(vty, | |
4339 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4340 | return CMD_WARNING_CONFIG_FAILED; | |
4341 | } | |
4342 | ||
4343 | other = peer->doppelganger; | |
b3a3290e DS |
4344 | |
4345 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
4346 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4347 | ||
4e2786df | 4348 | peer_notify_unconfig(peer); |
d62a17ae | 4349 | peer_delete(peer); |
4e2786df DA |
4350 | if (other && other->status != Deleted) { |
4351 | peer_notify_unconfig(other); | |
d62a17ae | 4352 | peer_delete(other); |
4e2786df | 4353 | } |
d62a17ae | 4354 | } |
1ff9a340 | 4355 | } |
718e3744 | 4356 | |
d62a17ae | 4357 | return CMD_SUCCESS; |
718e3744 | 4358 | } |
4359 | ||
a80beece DS |
4360 | DEFUN (no_neighbor_interface_config, |
4361 | no_neighbor_interface_config_cmd, | |
d7b9898c | 4362 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
4363 | NO_STR |
4364 | NEIGHBOR_STR | |
4365 | "Interface name\n" | |
31500417 DW |
4366 | "Configure BGP on interface\n" |
4367 | "Enable BGP with v6 link-local only\n" | |
4368 | "Member of the peer-group\n" | |
16cedbb0 | 4369 | "Peer-group name\n" |
3a2d747c QY |
4370 | "Specify a BGP neighbor\n" |
4371 | AS_STR | |
4372 | "Internal BGP peer\n" | |
4373 | "External BGP peer\n") | |
a80beece | 4374 | { |
d62a17ae | 4375 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4376 | int idx_word = 2; | |
4377 | struct peer *peer; | |
4378 | ||
4379 | /* look up for neighbor by interface name config. */ | |
4380 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4381 | if (peer) { | |
4382 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
4383 | if (peer->ifp) | |
4384 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 4385 | peer_notify_unconfig(peer); |
d62a17ae | 4386 | peer_delete(peer); |
4387 | } else { | |
4388 | vty_out(vty, "%% Create the bgp interface first\n"); | |
4389 | return CMD_WARNING_CONFIG_FAILED; | |
4390 | } | |
4391 | return CMD_SUCCESS; | |
a80beece DS |
4392 | } |
4393 | ||
718e3744 | 4394 | DEFUN (no_neighbor_peer_group, |
4395 | no_neighbor_peer_group_cmd, | |
4396 | "no neighbor WORD peer-group", | |
4397 | NO_STR | |
4398 | NEIGHBOR_STR | |
4399 | "Neighbor tag\n" | |
4400 | "Configure peer-group\n") | |
4401 | { | |
d62a17ae | 4402 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4403 | int idx_word = 2; | |
4404 | struct peer_group *group; | |
718e3744 | 4405 | |
d62a17ae | 4406 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
4407 | if (group) { |
4408 | peer_group_notify_unconfig(group); | |
d62a17ae | 4409 | peer_group_delete(group); |
4e2786df | 4410 | } else { |
d62a17ae | 4411 | vty_out(vty, "%% Create the peer-group first\n"); |
4412 | return CMD_WARNING_CONFIG_FAILED; | |
4413 | } | |
4414 | return CMD_SUCCESS; | |
718e3744 | 4415 | } |
4416 | ||
a80beece DS |
4417 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
4418 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 4419 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 4420 | NO_STR |
4421 | NEIGHBOR_STR | |
a80beece | 4422 | "Interface name or neighbor tag\n" |
718e3744 | 4423 | "Specify a BGP neighbor\n" |
3a2d747c QY |
4424 | AS_STR |
4425 | "Internal BGP peer\n" | |
4426 | "External BGP peer\n") | |
718e3744 | 4427 | { |
d62a17ae | 4428 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4429 | int idx_word = 2; | |
4430 | struct peer_group *group; | |
4431 | struct peer *peer; | |
4432 | ||
4433 | /* look up for neighbor by interface name config. */ | |
4434 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
4435 | if (peer) { | |
390485fd | 4436 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 4437 | return CMD_SUCCESS; |
4438 | } | |
4439 | ||
4440 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4441 | if (group) | |
4442 | peer_group_remote_as_delete(group); | |
4443 | else { | |
4444 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
4445 | return CMD_WARNING_CONFIG_FAILED; | |
4446 | } | |
4447 | return CMD_SUCCESS; | |
718e3744 | 4448 | } |
6b0655a2 | 4449 | |
718e3744 | 4450 | DEFUN (neighbor_local_as, |
4451 | neighbor_local_as_cmd, | |
9ccf14f7 | 4452 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 4453 | NEIGHBOR_STR |
4454 | NEIGHBOR_ADDR_STR2 | |
4455 | "Specify a local-as number\n" | |
4456 | "AS number used as local AS\n") | |
4457 | { | |
d62a17ae | 4458 | int idx_peer = 1; |
4459 | int idx_number = 3; | |
4460 | struct peer *peer; | |
4461 | int ret; | |
4462 | as_t as; | |
718e3744 | 4463 | |
d62a17ae | 4464 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4465 | if (!peer) | |
4466 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4467 | |
d62a17ae | 4468 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4469 | ret = peer_local_as_set(peer, as, 0, 0); | |
4470 | return bgp_vty_return(vty, ret); | |
718e3744 | 4471 | } |
4472 | ||
4473 | DEFUN (neighbor_local_as_no_prepend, | |
4474 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 4475 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 4476 | NEIGHBOR_STR |
4477 | NEIGHBOR_ADDR_STR2 | |
4478 | "Specify a local-as number\n" | |
4479 | "AS number used as local AS\n" | |
4480 | "Do not prepend local-as to updates from ebgp peers\n") | |
4481 | { | |
d62a17ae | 4482 | int idx_peer = 1; |
4483 | int idx_number = 3; | |
4484 | struct peer *peer; | |
4485 | int ret; | |
4486 | as_t as; | |
718e3744 | 4487 | |
d62a17ae | 4488 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4489 | if (!peer) | |
4490 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4491 | |
d62a17ae | 4492 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4493 | ret = peer_local_as_set(peer, as, 1, 0); | |
4494 | return bgp_vty_return(vty, ret); | |
718e3744 | 4495 | } |
4496 | ||
9d3f9705 AC |
4497 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4498 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 4499 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
4500 | NEIGHBOR_STR |
4501 | NEIGHBOR_ADDR_STR2 | |
4502 | "Specify a local-as number\n" | |
4503 | "AS number used as local AS\n" | |
4504 | "Do not prepend local-as to updates from ebgp peers\n" | |
4505 | "Do not prepend local-as to updates from ibgp peers\n") | |
4506 | { | |
d62a17ae | 4507 | int idx_peer = 1; |
4508 | int idx_number = 3; | |
4509 | struct peer *peer; | |
4510 | int ret; | |
4511 | as_t as; | |
9d3f9705 | 4512 | |
d62a17ae | 4513 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4514 | if (!peer) | |
4515 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 4516 | |
d62a17ae | 4517 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4518 | ret = peer_local_as_set(peer, as, 1, 1); | |
4519 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4520 | } |
4521 | ||
718e3744 | 4522 | DEFUN (no_neighbor_local_as, |
4523 | no_neighbor_local_as_cmd, | |
a636c635 | 4524 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 4525 | NO_STR |
4526 | NEIGHBOR_STR | |
4527 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4528 | "Specify a local-as number\n" |
4529 | "AS number used as local AS\n" | |
4530 | "Do not prepend local-as to updates from ebgp peers\n" | |
4531 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4532 | { |
d62a17ae | 4533 | int idx_peer = 2; |
4534 | struct peer *peer; | |
4535 | int ret; | |
718e3744 | 4536 | |
d62a17ae | 4537 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4538 | if (!peer) | |
4539 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4540 | |
d62a17ae | 4541 | ret = peer_local_as_unset(peer); |
4542 | return bgp_vty_return(vty, ret); | |
718e3744 | 4543 | } |
4544 | ||
718e3744 | 4545 | |
3f9c7369 DS |
4546 | DEFUN (neighbor_solo, |
4547 | neighbor_solo_cmd, | |
9ccf14f7 | 4548 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4549 | NEIGHBOR_STR |
4550 | NEIGHBOR_ADDR_STR2 | |
4551 | "Solo peer - part of its own update group\n") | |
4552 | { | |
d62a17ae | 4553 | int idx_peer = 1; |
4554 | struct peer *peer; | |
4555 | int ret; | |
3f9c7369 | 4556 | |
d62a17ae | 4557 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4558 | if (!peer) | |
4559 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4560 | |
d62a17ae | 4561 | ret = update_group_adjust_soloness(peer, 1); |
4562 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4563 | } |
4564 | ||
4565 | DEFUN (no_neighbor_solo, | |
4566 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4567 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4568 | NO_STR |
4569 | NEIGHBOR_STR | |
4570 | NEIGHBOR_ADDR_STR2 | |
4571 | "Solo peer - part of its own update group\n") | |
4572 | { | |
d62a17ae | 4573 | int idx_peer = 2; |
4574 | struct peer *peer; | |
4575 | int ret; | |
3f9c7369 | 4576 | |
d62a17ae | 4577 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4578 | if (!peer) | |
4579 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4580 | |
d62a17ae | 4581 | ret = update_group_adjust_soloness(peer, 0); |
4582 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4583 | } |
4584 | ||
0df7c91f PJ |
4585 | DEFUN (neighbor_password, |
4586 | neighbor_password_cmd, | |
9ccf14f7 | 4587 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4588 | NEIGHBOR_STR |
4589 | NEIGHBOR_ADDR_STR2 | |
4590 | "Set a password\n" | |
4591 | "The password\n") | |
4592 | { | |
d62a17ae | 4593 | int idx_peer = 1; |
4594 | int idx_line = 3; | |
4595 | struct peer *peer; | |
4596 | int ret; | |
0df7c91f | 4597 | |
d62a17ae | 4598 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4599 | if (!peer) | |
4600 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4601 | |
d62a17ae | 4602 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4603 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4604 | } |
4605 | ||
4606 | DEFUN (no_neighbor_password, | |
4607 | no_neighbor_password_cmd, | |
a636c635 | 4608 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4609 | NO_STR |
4610 | NEIGHBOR_STR | |
4611 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4612 | "Set a password\n" |
4613 | "The password\n") | |
0df7c91f | 4614 | { |
d62a17ae | 4615 | int idx_peer = 2; |
4616 | struct peer *peer; | |
4617 | int ret; | |
0df7c91f | 4618 | |
d62a17ae | 4619 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4620 | if (!peer) | |
4621 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4622 | |
d62a17ae | 4623 | ret = peer_password_unset(peer); |
4624 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4625 | } |
6b0655a2 | 4626 | |
718e3744 | 4627 | DEFUN (neighbor_activate, |
4628 | neighbor_activate_cmd, | |
9ccf14f7 | 4629 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4630 | NEIGHBOR_STR |
4631 | NEIGHBOR_ADDR_STR2 | |
4632 | "Enable the Address Family for this Neighbor\n") | |
4633 | { | |
d62a17ae | 4634 | int idx_peer = 1; |
4635 | int ret; | |
4636 | struct peer *peer; | |
718e3744 | 4637 | |
d62a17ae | 4638 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4639 | if (!peer) | |
4640 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4641 | |
d62a17ae | 4642 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4643 | return bgp_vty_return(vty, ret); | |
718e3744 | 4644 | } |
4645 | ||
d62a17ae | 4646 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4647 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4648 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4649 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4650 | |
718e3744 | 4651 | DEFUN (no_neighbor_activate, |
4652 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4653 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4654 | NO_STR |
4655 | NEIGHBOR_STR | |
4656 | NEIGHBOR_ADDR_STR2 | |
4657 | "Enable the Address Family for this Neighbor\n") | |
4658 | { | |
d62a17ae | 4659 | int idx_peer = 2; |
4660 | int ret; | |
4661 | struct peer *peer; | |
718e3744 | 4662 | |
d62a17ae | 4663 | /* Lookup peer. */ |
4664 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4665 | if (!peer) | |
4666 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4667 | |
d62a17ae | 4668 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4669 | return bgp_vty_return(vty, ret); | |
718e3744 | 4670 | } |
6b0655a2 | 4671 | |
d62a17ae | 4672 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4673 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4674 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4675 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4676 | |
718e3744 | 4677 | DEFUN (neighbor_set_peer_group, |
4678 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4679 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4680 | NEIGHBOR_STR |
a80beece | 4681 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4682 | "Member of the peer-group\n" |
16cedbb0 | 4683 | "Peer-group name\n") |
718e3744 | 4684 | { |
d62a17ae | 4685 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4686 | int idx_peer = 1; | |
4687 | int idx_word = 3; | |
4688 | int ret; | |
4689 | as_t as; | |
4690 | union sockunion su; | |
4691 | struct peer *peer; | |
4692 | struct peer_group *group; | |
4693 | ||
d62a17ae | 4694 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4695 | if (ret < 0) { | |
4696 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4697 | if (!peer) { | |
4698 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4699 | argv[idx_peer]->arg); | |
4700 | return CMD_WARNING_CONFIG_FAILED; | |
4701 | } | |
4702 | } else { | |
4703 | if (peer_address_self_check(bgp, &su)) { | |
4704 | vty_out(vty, | |
4705 | "%% Can not configure the local system as neighbor\n"); | |
4706 | return CMD_WARNING_CONFIG_FAILED; | |
4707 | } | |
4708 | ||
4709 | /* Disallow for dynamic neighbor. */ | |
4710 | peer = peer_lookup(bgp, &su); | |
4711 | if (peer && peer_dynamic_neighbor(peer)) { | |
4712 | vty_out(vty, | |
4713 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4714 | return CMD_WARNING_CONFIG_FAILED; | |
4715 | } | |
4716 | } | |
4717 | ||
4718 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4719 | if (!group) { | |
4720 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4721 | return CMD_WARNING_CONFIG_FAILED; | |
4722 | } | |
4723 | ||
4724 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4725 | ||
4726 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4727 | vty_out(vty, | |
4728 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4729 | as); | |
4730 | return CMD_WARNING_CONFIG_FAILED; | |
4731 | } | |
4732 | ||
4733 | return bgp_vty_return(vty, ret); | |
4734 | } | |
4735 | ||
4736 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4737 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4738 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4739 | "Member of the peer-group\n" | |
4740 | "Peer-group name\n") | |
596c17ba | 4741 | |
718e3744 | 4742 | DEFUN (no_neighbor_set_peer_group, |
4743 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4744 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4745 | NO_STR |
4746 | NEIGHBOR_STR | |
a80beece | 4747 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4748 | "Member of the peer-group\n" |
16cedbb0 | 4749 | "Peer-group name\n") |
718e3744 | 4750 | { |
d62a17ae | 4751 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4752 | int idx_peer = 2; | |
4753 | int idx_word = 4; | |
4754 | int ret; | |
4755 | struct peer *peer; | |
4756 | struct peer_group *group; | |
4757 | ||
4758 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4759 | if (!peer) | |
4760 | return CMD_WARNING_CONFIG_FAILED; | |
4761 | ||
4762 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4763 | if (!group) { | |
4764 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4765 | return CMD_WARNING_CONFIG_FAILED; | |
4766 | } | |
718e3744 | 4767 | |
b3a3290e DS |
4768 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4769 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4770 | ||
4e2786df | 4771 | peer_notify_unconfig(peer); |
827ed707 | 4772 | ret = peer_delete(peer); |
718e3744 | 4773 | |
d62a17ae | 4774 | return bgp_vty_return(vty, ret); |
718e3744 | 4775 | } |
6b0655a2 | 4776 | |
d62a17ae | 4777 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4778 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4779 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4780 | "Member of the peer-group\n" | |
4781 | "Peer-group name\n") | |
596c17ba | 4782 | |
d62a17ae | 4783 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4784 | uint32_t flag, int set) |
718e3744 | 4785 | { |
d62a17ae | 4786 | int ret; |
4787 | struct peer *peer; | |
718e3744 | 4788 | |
d62a17ae | 4789 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4790 | if (!peer) | |
4791 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4792 | |
7ebe625c QY |
4793 | /* |
4794 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4795 | * we should not accept disable-connected-check. | |
4796 | */ | |
4797 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4798 | vty_out(vty, | |
3efd0893 | 4799 | "%s is directly connected peer, cannot accept disable-connected-check\n", |
7ebe625c QY |
4800 | ip_str); |
4801 | return CMD_WARNING_CONFIG_FAILED; | |
4802 | } | |
4803 | ||
d62a17ae | 4804 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4805 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4806 | |
d62a17ae | 4807 | if (set) |
4808 | ret = peer_flag_set(peer, flag); | |
4809 | else | |
4810 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4811 | |
d62a17ae | 4812 | return bgp_vty_return(vty, ret); |
718e3744 | 4813 | } |
4814 | ||
47cbc09b | 4815 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4816 | { |
d62a17ae | 4817 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4818 | } |
4819 | ||
d62a17ae | 4820 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4821 | uint32_t flag) |
718e3744 | 4822 | { |
d62a17ae | 4823 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4824 | } |
4825 | ||
4826 | /* neighbor passive. */ | |
4827 | DEFUN (neighbor_passive, | |
4828 | neighbor_passive_cmd, | |
9ccf14f7 | 4829 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4830 | NEIGHBOR_STR |
4831 | NEIGHBOR_ADDR_STR2 | |
4832 | "Don't send open messages to this neighbor\n") | |
4833 | { | |
d62a17ae | 4834 | int idx_peer = 1; |
4835 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4836 | } |
4837 | ||
4838 | DEFUN (no_neighbor_passive, | |
4839 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4841 | NO_STR |
4842 | NEIGHBOR_STR | |
4843 | NEIGHBOR_ADDR_STR2 | |
4844 | "Don't send open messages to this neighbor\n") | |
4845 | { | |
d62a17ae | 4846 | int idx_peer = 2; |
4847 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4848 | } |
6b0655a2 | 4849 | |
718e3744 | 4850 | /* neighbor shutdown. */ |
73d70fa6 DL |
4851 | DEFUN (neighbor_shutdown_msg, |
4852 | neighbor_shutdown_msg_cmd, | |
4853 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4854 | NEIGHBOR_STR |
4855 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 | 4856 | "Administratively shut down this neighbor\n" |
70335e0a | 4857 | "Add a shutdown message (RFC 8203)\n" |
73d70fa6 | 4858 | "Shutdown message\n") |
718e3744 | 4859 | { |
d62a17ae | 4860 | int idx_peer = 1; |
73d70fa6 | 4861 | |
d62a17ae | 4862 | if (argc >= 5) { |
4863 | struct peer *peer = | |
4864 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4865 | char *message; | |
73d70fa6 | 4866 | |
d62a17ae | 4867 | if (!peer) |
4868 | return CMD_WARNING_CONFIG_FAILED; | |
4869 | message = argv_concat(argv, argc, 4); | |
4870 | peer_tx_shutdown_message_set(peer, message); | |
4871 | XFREE(MTYPE_TMP, message); | |
4872 | } | |
73d70fa6 | 4873 | |
d62a17ae | 4874 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4875 | } |
4876 | ||
d62a17ae | 4877 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4878 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4879 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4880 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4881 | |
4882 | DEFUN (no_neighbor_shutdown_msg, | |
4883 | no_neighbor_shutdown_msg_cmd, | |
4884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4885 | NO_STR | |
4886 | NEIGHBOR_STR | |
4887 | NEIGHBOR_ADDR_STR2 | |
4888 | "Administratively shut down this neighbor\n" | |
70335e0a | 4889 | "Remove a shutdown message (RFC 8203)\n" |
73d70fa6 | 4890 | "Shutdown message\n") |
718e3744 | 4891 | { |
d62a17ae | 4892 | int idx_peer = 2; |
73d70fa6 | 4893 | |
d62a17ae | 4894 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4895 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4896 | } |
6b0655a2 | 4897 | |
d62a17ae | 4898 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4899 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4900 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4901 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4902 | |
8336c896 DA |
4903 | DEFUN(neighbor_shutdown_rtt, |
4904 | neighbor_shutdown_rtt_cmd, | |
4905 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]", | |
4906 | NEIGHBOR_STR | |
4907 | NEIGHBOR_ADDR_STR2 | |
4908 | "Administratively shut down this neighbor\n" | |
4909 | "Shutdown if round-trip-time is higher than expected\n" | |
4910 | "Round-trip-time in milliseconds\n" | |
4911 | "Specify the number of keepalives before shutdown\n" | |
4912 | "The number of keepalives with higher RTT to shutdown\n") | |
4913 | { | |
4914 | int idx_peer = 1; | |
4915 | int idx_rtt = 4; | |
4916 | int idx_count = 0; | |
4917 | struct peer *peer; | |
4918 | ||
4919 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4920 | ||
4921 | if (!peer) | |
4922 | return CMD_WARNING_CONFIG_FAILED; | |
4923 | ||
4924 | peer->rtt_expected = strtol(argv[idx_rtt]->arg, NULL, 10); | |
4925 | ||
4926 | if (argv_find(argv, argc, "count", &idx_count)) | |
4927 | peer->rtt_keepalive_conf = | |
4928 | strtol(argv[idx_count + 1]->arg, NULL, 10); | |
4929 | ||
4930 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4931 | PEER_FLAG_RTT_SHUTDOWN); | |
4932 | } | |
4933 | ||
4934 | DEFUN(no_neighbor_shutdown_rtt, | |
4935 | no_neighbor_shutdown_rtt_cmd, | |
4936 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]", | |
4937 | NO_STR | |
4938 | NEIGHBOR_STR | |
4939 | NEIGHBOR_ADDR_STR2 | |
4940 | "Administratively shut down this neighbor\n" | |
4941 | "Shutdown if round-trip-time is higher than expected\n" | |
4942 | "Round-trip-time in milliseconds\n" | |
4943 | "Specify the number of keepalives before shutdown\n" | |
4944 | "The number of keepalives with higher RTT to shutdown\n") | |
4945 | { | |
4946 | int idx_peer = 2; | |
4947 | struct peer *peer; | |
4948 | ||
4949 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4950 | ||
4951 | if (!peer) | |
4952 | return CMD_WARNING_CONFIG_FAILED; | |
4953 | ||
4954 | peer->rtt_expected = 0; | |
4955 | peer->rtt_keepalive_conf = 1; | |
4956 | ||
4957 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4958 | PEER_FLAG_RTT_SHUTDOWN); | |
4959 | } | |
4960 | ||
718e3744 | 4961 | /* neighbor capability dynamic. */ |
4962 | DEFUN (neighbor_capability_dynamic, | |
4963 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4964 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4965 | NEIGHBOR_STR |
4966 | NEIGHBOR_ADDR_STR2 | |
4967 | "Advertise capability to the peer\n" | |
4968 | "Advertise dynamic capability to this neighbor\n") | |
4969 | { | |
d62a17ae | 4970 | int idx_peer = 1; |
4971 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4972 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4973 | } |
4974 | ||
4975 | DEFUN (no_neighbor_capability_dynamic, | |
4976 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4977 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4978 | NO_STR |
4979 | NEIGHBOR_STR | |
4980 | NEIGHBOR_ADDR_STR2 | |
4981 | "Advertise capability to the peer\n" | |
4982 | "Advertise dynamic capability to this neighbor\n") | |
4983 | { | |
d62a17ae | 4984 | int idx_peer = 2; |
4985 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4986 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4987 | } |
6b0655a2 | 4988 | |
718e3744 | 4989 | /* neighbor dont-capability-negotiate */ |
4990 | DEFUN (neighbor_dont_capability_negotiate, | |
4991 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4992 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4993 | NEIGHBOR_STR |
4994 | NEIGHBOR_ADDR_STR2 | |
4995 | "Do not perform capability negotiation\n") | |
4996 | { | |
d62a17ae | 4997 | int idx_peer = 1; |
4998 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4999 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5000 | } |
5001 | ||
5002 | DEFUN (no_neighbor_dont_capability_negotiate, | |
5003 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 5004 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 5005 | NO_STR |
5006 | NEIGHBOR_STR | |
5007 | NEIGHBOR_ADDR_STR2 | |
5008 | "Do not perform capability negotiation\n") | |
5009 | { | |
d62a17ae | 5010 | int idx_peer = 2; |
5011 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5012 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 5013 | } |
6b0655a2 | 5014 | |
8a92a8a0 DS |
5015 | /* neighbor capability extended next hop encoding */ |
5016 | DEFUN (neighbor_capability_enhe, | |
5017 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 5018 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
5019 | NEIGHBOR_STR |
5020 | NEIGHBOR_ADDR_STR2 | |
5021 | "Advertise capability to the peer\n" | |
5022 | "Advertise extended next-hop capability to the peer\n") | |
5023 | { | |
d62a17ae | 5024 | int idx_peer = 1; |
5025 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5026 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5027 | } |
5028 | ||
5029 | DEFUN (no_neighbor_capability_enhe, | |
5030 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 5031 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
5032 | NO_STR |
5033 | NEIGHBOR_STR | |
5034 | NEIGHBOR_ADDR_STR2 | |
5035 | "Advertise capability to the peer\n" | |
5036 | "Advertise extended next-hop capability to the peer\n") | |
5037 | { | |
d62a17ae | 5038 | int idx_peer = 2; |
5039 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5040 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
5041 | } |
5042 | ||
d62a17ae | 5043 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5044 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 5045 | int set) |
718e3744 | 5046 | { |
d62a17ae | 5047 | int ret; |
5048 | struct peer *peer; | |
718e3744 | 5049 | |
d62a17ae | 5050 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5051 | if (!peer) | |
5052 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5053 | |
d62a17ae | 5054 | if (set) |
5055 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
5056 | else | |
5057 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 5058 | |
d62a17ae | 5059 | return bgp_vty_return(vty, ret); |
718e3744 | 5060 | } |
5061 | ||
d62a17ae | 5062 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5063 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5064 | { |
d62a17ae | 5065 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 5066 | } |
5067 | ||
d62a17ae | 5068 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 5069 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 5070 | { |
d62a17ae | 5071 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 5072 | } |
6b0655a2 | 5073 | |
718e3744 | 5074 | /* neighbor capability orf prefix-list. */ |
5075 | DEFUN (neighbor_capability_orf_prefix, | |
5076 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5077 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5078 | NEIGHBOR_STR |
5079 | NEIGHBOR_ADDR_STR2 | |
5080 | "Advertise capability to the peer\n" | |
5081 | "Advertise ORF capability to the peer\n" | |
5082 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5083 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5084 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5085 | "Capability to SEND the ORF to this neighbor\n") | |
5086 | { | |
d62a17ae | 5087 | int idx_send_recv = 5; |
db45f64d DS |
5088 | char *peer_str = argv[1]->arg; |
5089 | struct peer *peer; | |
5090 | afi_t afi = bgp_node_afi(vty); | |
5091 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5092 | |
db45f64d DS |
5093 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5094 | if (!peer) | |
d62a17ae | 5095 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5096 | |
db45f64d DS |
5097 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5098 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5099 | PEER_FLAG_ORF_PREFIX_SM); | |
5100 | ||
5101 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5102 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5103 | PEER_FLAG_ORF_PREFIX_RM); | |
5104 | ||
5105 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5106 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5107 | PEER_FLAG_ORF_PREFIX_SM) | |
5108 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5109 | PEER_FLAG_ORF_PREFIX_RM); | |
5110 | ||
5111 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5112 | } |
5113 | ||
5114 | ALIAS_HIDDEN( | |
5115 | neighbor_capability_orf_prefix, | |
5116 | neighbor_capability_orf_prefix_hidden_cmd, | |
5117 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5118 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5119 | "Advertise capability to the peer\n" | |
5120 | "Advertise ORF capability to the peer\n" | |
5121 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5122 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5123 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5124 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5125 | |
718e3744 | 5126 | DEFUN (no_neighbor_capability_orf_prefix, |
5127 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 5128 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 5129 | NO_STR |
5130 | NEIGHBOR_STR | |
5131 | NEIGHBOR_ADDR_STR2 | |
5132 | "Advertise capability to the peer\n" | |
5133 | "Advertise ORF capability to the peer\n" | |
5134 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5135 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5136 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5137 | "Capability to SEND the ORF to this neighbor\n") | |
5138 | { | |
d62a17ae | 5139 | int idx_send_recv = 6; |
db45f64d DS |
5140 | char *peer_str = argv[2]->arg; |
5141 | struct peer *peer; | |
5142 | afi_t afi = bgp_node_afi(vty); | |
5143 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5144 | |
db45f64d DS |
5145 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5146 | if (!peer) | |
d62a17ae | 5147 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 5148 | |
db45f64d DS |
5149 | if (strmatch(argv[idx_send_recv]->text, "send")) |
5150 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5151 | PEER_FLAG_ORF_PREFIX_SM); | |
5152 | ||
5153 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
5154 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5155 | PEER_FLAG_ORF_PREFIX_RM); | |
5156 | ||
5157 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
5158 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5159 | PEER_FLAG_ORF_PREFIX_SM) | |
5160 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5161 | PEER_FLAG_ORF_PREFIX_RM); | |
5162 | ||
5163 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5164 | } |
5165 | ||
5166 | ALIAS_HIDDEN( | |
5167 | no_neighbor_capability_orf_prefix, | |
5168 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
5169 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
5170 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5171 | "Advertise capability to the peer\n" | |
5172 | "Advertise ORF capability to the peer\n" | |
5173 | "Advertise prefixlist ORF capability to this neighbor\n" | |
5174 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
5175 | "Capability to RECEIVE the ORF from this neighbor\n" | |
5176 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 5177 | |
718e3744 | 5178 | /* neighbor next-hop-self. */ |
5179 | DEFUN (neighbor_nexthop_self, | |
5180 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 5181 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 5182 | NEIGHBOR_STR |
5183 | NEIGHBOR_ADDR_STR2 | |
a538debe | 5184 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 5185 | { |
d62a17ae | 5186 | int idx_peer = 1; |
5187 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5188 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 5189 | } |
9e7a53c1 | 5190 | |
d62a17ae | 5191 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
5192 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5193 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5194 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5195 | |
a538debe DS |
5196 | /* neighbor next-hop-self. */ |
5197 | DEFUN (neighbor_nexthop_self_force, | |
5198 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 5199 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
5200 | NEIGHBOR_STR |
5201 | NEIGHBOR_ADDR_STR2 | |
5202 | "Disable the next hop calculation for this neighbor\n" | |
5203 | "Set the next hop to self for reflected routes\n") | |
5204 | { | |
d62a17ae | 5205 | int idx_peer = 1; |
5206 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5207 | bgp_node_safi(vty), | |
5208 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 5209 | } |
5210 | ||
d62a17ae | 5211 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5212 | neighbor_nexthop_self_force_hidden_cmd, | |
5213 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5214 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5215 | "Disable the next hop calculation for this neighbor\n" | |
5216 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5217 | |
1bc4e531 DA |
5218 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
5219 | neighbor_nexthop_self_all_hidden_cmd, | |
5220 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5221 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5222 | "Disable the next hop calculation for this neighbor\n" | |
5223 | "Set the next hop to self for reflected routes\n") | |
5224 | ||
718e3744 | 5225 | DEFUN (no_neighbor_nexthop_self, |
5226 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 5227 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 5228 | NO_STR |
5229 | NEIGHBOR_STR | |
5230 | NEIGHBOR_ADDR_STR2 | |
a538debe | 5231 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 5232 | { |
d62a17ae | 5233 | int idx_peer = 2; |
5234 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5235 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5236 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 5237 | } |
6b0655a2 | 5238 | |
d62a17ae | 5239 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
5240 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
5241 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5242 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 5243 | |
88b8ed8d | 5244 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 5245 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 5246 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
5247 | NO_STR |
5248 | NEIGHBOR_STR | |
5249 | NEIGHBOR_ADDR_STR2 | |
5250 | "Disable the next hop calculation for this neighbor\n" | |
5251 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 5252 | { |
d62a17ae | 5253 | int idx_peer = 2; |
5254 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5255 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5256 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 5257 | } |
a538debe | 5258 | |
d62a17ae | 5259 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5260 | no_neighbor_nexthop_self_force_hidden_cmd, | |
5261 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
5262 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5263 | "Disable the next hop calculation for this neighbor\n" | |
5264 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 5265 | |
1bc4e531 DA |
5266 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
5267 | no_neighbor_nexthop_self_all_hidden_cmd, | |
5268 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
5269 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5270 | "Disable the next hop calculation for this neighbor\n" | |
5271 | "Set the next hop to self for reflected routes\n") | |
5272 | ||
c7122e14 DS |
5273 | /* neighbor as-override */ |
5274 | DEFUN (neighbor_as_override, | |
5275 | neighbor_as_override_cmd, | |
9ccf14f7 | 5276 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
5277 | NEIGHBOR_STR |
5278 | NEIGHBOR_ADDR_STR2 | |
5279 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5280 | { | |
d62a17ae | 5281 | int idx_peer = 1; |
5282 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5283 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5284 | } |
5285 | ||
d62a17ae | 5286 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
5287 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5288 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5289 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5290 | |
c7122e14 DS |
5291 | DEFUN (no_neighbor_as_override, |
5292 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 5293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
5294 | NO_STR |
5295 | NEIGHBOR_STR | |
5296 | NEIGHBOR_ADDR_STR2 | |
5297 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
5298 | { | |
d62a17ae | 5299 | int idx_peer = 2; |
5300 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5301 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5302 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
5303 | } |
5304 | ||
d62a17ae | 5305 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
5306 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
5307 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5308 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 5309 | |
718e3744 | 5310 | /* neighbor remove-private-AS. */ |
5311 | DEFUN (neighbor_remove_private_as, | |
5312 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 5313 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 5314 | NEIGHBOR_STR |
5315 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 5316 | "Remove private ASNs in outbound updates\n") |
718e3744 | 5317 | { |
d62a17ae | 5318 | int idx_peer = 1; |
5319 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5320 | bgp_node_safi(vty), | |
5321 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5322 | } |
5323 | ||
d62a17ae | 5324 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
5325 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5326 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5327 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5328 | |
5000f21c DS |
5329 | DEFUN (neighbor_remove_private_as_all, |
5330 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 5331 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
5332 | NEIGHBOR_STR |
5333 | NEIGHBOR_ADDR_STR2 | |
5334 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 5335 | "Apply to all AS numbers\n") |
5000f21c | 5336 | { |
d62a17ae | 5337 | int idx_peer = 1; |
5338 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5339 | bgp_node_safi(vty), | |
5340 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
5341 | } |
5342 | ||
d62a17ae | 5343 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
5344 | neighbor_remove_private_as_all_hidden_cmd, | |
5345 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5346 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5347 | "Remove private ASNs in outbound updates\n" | |
5348 | "Apply to all AS numbers") | |
596c17ba | 5349 | |
5000f21c DS |
5350 | DEFUN (neighbor_remove_private_as_replace_as, |
5351 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 5352 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
5353 | NEIGHBOR_STR |
5354 | NEIGHBOR_ADDR_STR2 | |
5355 | "Remove private ASNs in outbound updates\n" | |
5356 | "Replace private ASNs with our ASN in outbound updates\n") | |
5357 | { | |
d62a17ae | 5358 | int idx_peer = 1; |
5359 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5360 | bgp_node_safi(vty), | |
5361 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
5362 | } |
5363 | ||
d62a17ae | 5364 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
5365 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
5366 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5367 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5368 | "Remove private ASNs in outbound updates\n" | |
5369 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5370 | |
5000f21c DS |
5371 | DEFUN (neighbor_remove_private_as_all_replace_as, |
5372 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 5373 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
5374 | NEIGHBOR_STR |
5375 | NEIGHBOR_ADDR_STR2 | |
5376 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 5377 | "Apply to all AS numbers\n" |
5000f21c DS |
5378 | "Replace private ASNs with our ASN in outbound updates\n") |
5379 | { | |
d62a17ae | 5380 | int idx_peer = 1; |
5381 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5382 | bgp_node_safi(vty), | |
5383 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
5384 | } |
5385 | ||
d62a17ae | 5386 | ALIAS_HIDDEN( |
5387 | neighbor_remove_private_as_all_replace_as, | |
5388 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5389 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5390 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5391 | "Remove private ASNs in outbound updates\n" | |
5392 | "Apply to all AS numbers\n" | |
5393 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5394 | |
718e3744 | 5395 | DEFUN (no_neighbor_remove_private_as, |
5396 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 5397 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 5398 | NO_STR |
5399 | NEIGHBOR_STR | |
5400 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 5401 | "Remove private ASNs in outbound updates\n") |
718e3744 | 5402 | { |
d62a17ae | 5403 | int idx_peer = 2; |
5404 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5405 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5406 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 5407 | } |
6b0655a2 | 5408 | |
d62a17ae | 5409 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
5410 | no_neighbor_remove_private_as_hidden_cmd, | |
5411 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
5412 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5413 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 5414 | |
88b8ed8d | 5415 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 5416 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 5417 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
5418 | NO_STR |
5419 | NEIGHBOR_STR | |
5420 | NEIGHBOR_ADDR_STR2 | |
5421 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 5422 | "Apply to all AS numbers\n") |
88b8ed8d | 5423 | { |
d62a17ae | 5424 | int idx_peer = 2; |
5425 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5426 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5427 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 5428 | } |
5000f21c | 5429 | |
d62a17ae | 5430 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
5431 | no_neighbor_remove_private_as_all_hidden_cmd, | |
5432 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
5433 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5434 | "Remove private ASNs in outbound updates\n" | |
5435 | "Apply to all AS numbers\n") | |
596c17ba | 5436 | |
88b8ed8d | 5437 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 5438 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 5439 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
5440 | NO_STR |
5441 | NEIGHBOR_STR | |
5442 | NEIGHBOR_ADDR_STR2 | |
5443 | "Remove private ASNs in outbound updates\n" | |
5444 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 5445 | { |
d62a17ae | 5446 | int idx_peer = 2; |
5447 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5448 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5449 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 5450 | } |
5000f21c | 5451 | |
d62a17ae | 5452 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
5453 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
5454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
5455 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5456 | "Remove private ASNs in outbound updates\n" | |
5457 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5458 | |
88b8ed8d | 5459 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 5460 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 5461 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
5462 | NO_STR |
5463 | NEIGHBOR_STR | |
5464 | NEIGHBOR_ADDR_STR2 | |
5465 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 5466 | "Apply to all AS numbers\n" |
5000f21c | 5467 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 5468 | { |
d62a17ae | 5469 | int idx_peer = 2; |
5470 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5471 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5472 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 5473 | } |
5000f21c | 5474 | |
d62a17ae | 5475 | ALIAS_HIDDEN( |
5476 | no_neighbor_remove_private_as_all_replace_as, | |
5477 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
5478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
5479 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5480 | "Remove private ASNs in outbound updates\n" | |
5481 | "Apply to all AS numbers\n" | |
5482 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 5483 | |
5000f21c | 5484 | |
718e3744 | 5485 | /* neighbor send-community. */ |
5486 | DEFUN (neighbor_send_community, | |
5487 | neighbor_send_community_cmd, | |
9ccf14f7 | 5488 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 5489 | NEIGHBOR_STR |
5490 | NEIGHBOR_ADDR_STR2 | |
5491 | "Send Community attribute to this neighbor\n") | |
5492 | { | |
d62a17ae | 5493 | int idx_peer = 1; |
27c05d4d | 5494 | |
d62a17ae | 5495 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5496 | bgp_node_safi(vty), | |
5497 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5498 | } |
5499 | ||
d62a17ae | 5500 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
5501 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5502 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5503 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5504 | |
718e3744 | 5505 | DEFUN (no_neighbor_send_community, |
5506 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 5507 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 5508 | NO_STR |
5509 | NEIGHBOR_STR | |
5510 | NEIGHBOR_ADDR_STR2 | |
5511 | "Send Community attribute to this neighbor\n") | |
5512 | { | |
d62a17ae | 5513 | int idx_peer = 2; |
27c05d4d | 5514 | |
d62a17ae | 5515 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
5516 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5517 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 5518 | } |
6b0655a2 | 5519 | |
d62a17ae | 5520 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
5521 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
5522 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5523 | "Send Community attribute to this neighbor\n") | |
596c17ba | 5524 | |
718e3744 | 5525 | /* neighbor send-community extended. */ |
5526 | DEFUN (neighbor_send_community_type, | |
5527 | neighbor_send_community_type_cmd, | |
57d187bc | 5528 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5529 | NEIGHBOR_STR |
5530 | NEIGHBOR_ADDR_STR2 | |
5531 | "Send Community attribute to this neighbor\n" | |
5532 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5533 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5534 | "Send Extended Community attributes\n" |
57d187bc JS |
5535 | "Send Standard Community attributes\n" |
5536 | "Send Large Community attributes\n") | |
718e3744 | 5537 | { |
27c05d4d | 5538 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5539 | char *peer_str = argv[1]->arg; |
5540 | struct peer *peer; | |
5541 | afi_t afi = bgp_node_afi(vty); | |
5542 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 5543 | |
db45f64d DS |
5544 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5545 | if (!peer) | |
5546 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5547 | |
db45f64d DS |
5548 | if (strmatch(type, "standard")) |
5549 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5550 | PEER_FLAG_SEND_COMMUNITY); | |
5551 | ||
5552 | if (strmatch(type, "extended")) | |
5553 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5554 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5555 | ||
5556 | if (strmatch(type, "large")) | |
5557 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5558 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5559 | ||
5560 | if (strmatch(type, "both")) { | |
5561 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5562 | PEER_FLAG_SEND_COMMUNITY) | |
5563 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5564 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5565 | } | |
5566 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5567 | PEER_FLAG_SEND_COMMUNITY) | |
5568 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5569 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5570 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5571 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5572 | } |
5573 | ||
5574 | ALIAS_HIDDEN( | |
5575 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5576 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5577 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5578 | "Send Community attribute to this neighbor\n" | |
5579 | "Send Standard and Extended Community attributes\n" | |
5580 | "Send Standard, Large and Extended Community attributes\n" | |
5581 | "Send Extended Community attributes\n" | |
5582 | "Send Standard Community attributes\n" | |
5583 | "Send Large Community attributes\n") | |
596c17ba | 5584 | |
718e3744 | 5585 | DEFUN (no_neighbor_send_community_type, |
5586 | no_neighbor_send_community_type_cmd, | |
57d187bc | 5587 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5588 | NO_STR |
5589 | NEIGHBOR_STR | |
5590 | NEIGHBOR_ADDR_STR2 | |
5591 | "Send Community attribute to this neighbor\n" | |
5592 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5593 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5594 | "Send Extended Community attributes\n" |
57d187bc JS |
5595 | "Send Standard Community attributes\n" |
5596 | "Send Large Community attributes\n") | |
718e3744 | 5597 | { |
d62a17ae | 5598 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5599 | char *peer_str = argv[2]->arg; |
5600 | struct peer *peer; | |
5601 | afi_t afi = bgp_node_afi(vty); | |
5602 | safi_t safi = bgp_node_safi(vty); | |
5603 | ||
5604 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5605 | if (!peer) | |
5606 | return CMD_WARNING_CONFIG_FAILED; | |
5607 | ||
5608 | if (strmatch(type, "standard")) | |
5609 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5610 | PEER_FLAG_SEND_COMMUNITY); | |
5611 | ||
5612 | if (strmatch(type, "extended")) | |
5613 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5614 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5615 | ||
5616 | if (strmatch(type, "large")) | |
5617 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5618 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5619 | ||
5620 | if (strmatch(type, "both")) { | |
d62a17ae | 5621 | |
db45f64d DS |
5622 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5623 | PEER_FLAG_SEND_COMMUNITY) | |
5624 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5625 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5626 | } |
5627 | ||
db45f64d DS |
5628 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5629 | PEER_FLAG_SEND_COMMUNITY) | |
5630 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5631 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5632 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5633 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5634 | } |
5635 | ||
5636 | ALIAS_HIDDEN( | |
5637 | no_neighbor_send_community_type, | |
5638 | no_neighbor_send_community_type_hidden_cmd, | |
5639 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5640 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5641 | "Send Community attribute to this neighbor\n" | |
5642 | "Send Standard and Extended Community attributes\n" | |
5643 | "Send Standard, Large and Extended Community attributes\n" | |
5644 | "Send Extended Community attributes\n" | |
5645 | "Send Standard Community attributes\n" | |
5646 | "Send Large Community attributes\n") | |
596c17ba | 5647 | |
718e3744 | 5648 | /* neighbor soft-reconfig. */ |
5649 | DEFUN (neighbor_soft_reconfiguration, | |
5650 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5651 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5652 | NEIGHBOR_STR |
5653 | NEIGHBOR_ADDR_STR2 | |
5654 | "Per neighbor soft reconfiguration\n" | |
5655 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5656 | { | |
d62a17ae | 5657 | int idx_peer = 1; |
5658 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5659 | bgp_node_safi(vty), | |
5660 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5661 | } |
5662 | ||
d62a17ae | 5663 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5664 | neighbor_soft_reconfiguration_hidden_cmd, | |
5665 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5666 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5667 | "Per neighbor soft reconfiguration\n" | |
5668 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5669 | |
718e3744 | 5670 | DEFUN (no_neighbor_soft_reconfiguration, |
5671 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5672 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5673 | NO_STR |
5674 | NEIGHBOR_STR | |
5675 | NEIGHBOR_ADDR_STR2 | |
5676 | "Per neighbor soft reconfiguration\n" | |
5677 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5678 | { | |
d62a17ae | 5679 | int idx_peer = 2; |
5680 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5681 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5682 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5683 | } |
6b0655a2 | 5684 | |
d62a17ae | 5685 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5686 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5687 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5688 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5689 | "Per neighbor soft reconfiguration\n" | |
5690 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5691 | |
718e3744 | 5692 | DEFUN (neighbor_route_reflector_client, |
5693 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5694 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5695 | NEIGHBOR_STR |
5696 | NEIGHBOR_ADDR_STR2 | |
5697 | "Configure a neighbor as Route Reflector client\n") | |
5698 | { | |
d62a17ae | 5699 | int idx_peer = 1; |
5700 | struct peer *peer; | |
718e3744 | 5701 | |
5702 | ||
d62a17ae | 5703 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5704 | if (!peer) | |
5705 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5706 | |
d62a17ae | 5707 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5708 | bgp_node_safi(vty), | |
5709 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5710 | } |
5711 | ||
d62a17ae | 5712 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5713 | neighbor_route_reflector_client_hidden_cmd, | |
5714 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5715 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5716 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5717 | |
718e3744 | 5718 | DEFUN (no_neighbor_route_reflector_client, |
5719 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5720 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5721 | NO_STR |
5722 | NEIGHBOR_STR | |
5723 | NEIGHBOR_ADDR_STR2 | |
5724 | "Configure a neighbor as Route Reflector client\n") | |
5725 | { | |
d62a17ae | 5726 | int idx_peer = 2; |
5727 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5728 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5729 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5730 | } |
6b0655a2 | 5731 | |
d62a17ae | 5732 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5733 | no_neighbor_route_reflector_client_hidden_cmd, | |
5734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5735 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5736 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5737 | |
718e3744 | 5738 | /* neighbor route-server-client. */ |
5739 | DEFUN (neighbor_route_server_client, | |
5740 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5741 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5742 | NEIGHBOR_STR |
5743 | NEIGHBOR_ADDR_STR2 | |
5744 | "Configure a neighbor as Route Server client\n") | |
5745 | { | |
d62a17ae | 5746 | int idx_peer = 1; |
5747 | struct peer *peer; | |
2a3d5731 | 5748 | |
d62a17ae | 5749 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5750 | if (!peer) | |
5751 | return CMD_WARNING_CONFIG_FAILED; | |
5752 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5753 | bgp_node_safi(vty), | |
5754 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5755 | } |
5756 | ||
d62a17ae | 5757 | ALIAS_HIDDEN(neighbor_route_server_client, |
5758 | neighbor_route_server_client_hidden_cmd, | |
5759 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5760 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5761 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5762 | |
718e3744 | 5763 | DEFUN (no_neighbor_route_server_client, |
5764 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5765 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5766 | NO_STR |
5767 | NEIGHBOR_STR | |
5768 | NEIGHBOR_ADDR_STR2 | |
5769 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5770 | { |
d62a17ae | 5771 | int idx_peer = 2; |
5772 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5773 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5774 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5775 | } |
6b0655a2 | 5776 | |
d62a17ae | 5777 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5778 | no_neighbor_route_server_client_hidden_cmd, | |
5779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5780 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5781 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5782 | |
fee0f4c6 | 5783 | DEFUN (neighbor_nexthop_local_unchanged, |
5784 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5785 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5786 | NEIGHBOR_STR |
5787 | NEIGHBOR_ADDR_STR2 | |
5788 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5789 | "Leave link-local nexthop unchanged for this peer\n") | |
5790 | { | |
d62a17ae | 5791 | int idx_peer = 1; |
5792 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5793 | bgp_node_safi(vty), | |
5794 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5795 | } |
6b0655a2 | 5796 | |
fee0f4c6 | 5797 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5798 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5799 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5800 | NO_STR |
5801 | NEIGHBOR_STR | |
5802 | NEIGHBOR_ADDR_STR2 | |
5803 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5804 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5805 | { |
d62a17ae | 5806 | int idx_peer = 2; |
5807 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5808 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5809 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5810 | } |
6b0655a2 | 5811 | |
718e3744 | 5812 | DEFUN (neighbor_attr_unchanged, |
5813 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5814 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5815 | NEIGHBOR_STR |
5816 | NEIGHBOR_ADDR_STR2 | |
5817 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5818 | "As-path attribute\n" | |
5819 | "Nexthop attribute\n" | |
a8206004 | 5820 | "Med attribute\n") |
718e3744 | 5821 | { |
d62a17ae | 5822 | int idx = 0; |
8eeb0335 DW |
5823 | char *peer_str = argv[1]->arg; |
5824 | struct peer *peer; | |
db45f64d DS |
5825 | bool aspath = false; |
5826 | bool nexthop = false; | |
5827 | bool med = false; | |
8eeb0335 DW |
5828 | afi_t afi = bgp_node_afi(vty); |
5829 | safi_t safi = bgp_node_safi(vty); | |
db45f64d | 5830 | int ret = 0; |
8eeb0335 DW |
5831 | |
5832 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5833 | if (!peer) | |
5834 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5835 | |
5836 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5837 | aspath = true; |
5838 | ||
d62a17ae | 5839 | idx = 0; |
5840 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5841 | nexthop = true; |
5842 | ||
d62a17ae | 5843 | idx = 0; |
5844 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5845 | med = true; |
d62a17ae | 5846 | |
8eeb0335 | 5847 | /* no flags means all of them! */ |
db45f64d DS |
5848 | if (!aspath && !nexthop && !med) { |
5849 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5850 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5851 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5852 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5853 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5854 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5855 | } else { |
db45f64d DS |
5856 | if (!aspath) { |
5857 | if (peer_af_flag_check(peer, afi, safi, | |
5858 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
5859 | ret |= peer_af_flag_unset_vty( | |
5860 | vty, peer_str, afi, safi, | |
5861 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5862 | } | |
5863 | } else | |
5864 | ret |= peer_af_flag_set_vty( | |
5865 | vty, peer_str, afi, safi, | |
5866 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5867 | ||
5868 | if (!nexthop) { | |
5869 | if (peer_af_flag_check(peer, afi, safi, | |
5870 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
5871 | ret |= peer_af_flag_unset_vty( | |
5872 | vty, peer_str, afi, safi, | |
5873 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5874 | } | |
5875 | } else | |
5876 | ret |= peer_af_flag_set_vty( | |
5877 | vty, peer_str, afi, safi, | |
5878 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5879 | ||
5880 | if (!med) { | |
5881 | if (peer_af_flag_check(peer, afi, safi, | |
5882 | PEER_FLAG_MED_UNCHANGED)) { | |
5883 | ret |= peer_af_flag_unset_vty( | |
5884 | vty, peer_str, afi, safi, | |
5885 | PEER_FLAG_MED_UNCHANGED); | |
5886 | } | |
5887 | } else | |
5888 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5889 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 5890 | } |
5891 | ||
db45f64d | 5892 | return ret; |
d62a17ae | 5893 | } |
5894 | ||
5895 | ALIAS_HIDDEN( | |
5896 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5897 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5898 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5899 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5900 | "As-path attribute\n" | |
5901 | "Nexthop attribute\n" | |
5902 | "Med attribute\n") | |
596c17ba | 5903 | |
718e3744 | 5904 | DEFUN (no_neighbor_attr_unchanged, |
5905 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5907 | NO_STR |
718e3744 | 5908 | NEIGHBOR_STR |
5909 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5910 | "BGP attribute is propagated unchanged to this neighbor\n" |
5911 | "As-path attribute\n" | |
40e718b5 | 5912 | "Nexthop attribute\n" |
a8206004 | 5913 | "Med attribute\n") |
718e3744 | 5914 | { |
d62a17ae | 5915 | int idx = 0; |
db45f64d DS |
5916 | char *peer_str = argv[2]->arg; |
5917 | struct peer *peer; | |
5918 | bool aspath = false; | |
5919 | bool nexthop = false; | |
5920 | bool med = false; | |
5921 | afi_t afi = bgp_node_afi(vty); | |
5922 | safi_t safi = bgp_node_safi(vty); | |
5923 | int ret = 0; | |
5924 | ||
5925 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5926 | if (!peer) | |
5927 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5928 | |
5929 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5930 | aspath = true; |
5931 | ||
d62a17ae | 5932 | idx = 0; |
5933 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5934 | nexthop = true; |
5935 | ||
d62a17ae | 5936 | idx = 0; |
5937 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5938 | med = true; |
d62a17ae | 5939 | |
db45f64d DS |
5940 | if (!aspath && !nexthop && !med) // no flags means all of them! |
5941 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5942 | PEER_FLAG_AS_PATH_UNCHANGED) | |
5943 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5944 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
5945 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5946 | PEER_FLAG_MED_UNCHANGED); | |
5947 | ||
5948 | if (aspath) | |
5949 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5950 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5951 | ||
5952 | if (nexthop) | |
5953 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5954 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 5955 | |
db45f64d DS |
5956 | if (med) |
5957 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5958 | PEER_FLAG_MED_UNCHANGED); | |
5959 | ||
5960 | return ret; | |
d62a17ae | 5961 | } |
5962 | ||
5963 | ALIAS_HIDDEN( | |
5964 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5965 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5966 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5967 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5968 | "As-path attribute\n" | |
5969 | "Nexthop attribute\n" | |
5970 | "Med attribute\n") | |
718e3744 | 5971 | |
718e3744 | 5972 | /* EBGP multihop configuration. */ |
d62a17ae | 5973 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5974 | const char *ttl_str) | |
718e3744 | 5975 | { |
d62a17ae | 5976 | struct peer *peer; |
5977 | unsigned int ttl; | |
718e3744 | 5978 | |
d62a17ae | 5979 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5980 | if (!peer) | |
5981 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5982 | |
d62a17ae | 5983 | if (peer->conf_if) |
5984 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5985 | |
d62a17ae | 5986 | if (!ttl_str) |
5987 | ttl = MAXTTL; | |
5988 | else | |
5989 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5990 | |
d62a17ae | 5991 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5992 | } |
5993 | ||
d62a17ae | 5994 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5995 | { |
d62a17ae | 5996 | struct peer *peer; |
718e3744 | 5997 | |
d62a17ae | 5998 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5999 | if (!peer) | |
6000 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6001 | |
d62a17ae | 6002 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 6003 | } |
6004 | ||
6005 | /* neighbor ebgp-multihop. */ | |
6006 | DEFUN (neighbor_ebgp_multihop, | |
6007 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 6008 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 6009 | NEIGHBOR_STR |
6010 | NEIGHBOR_ADDR_STR2 | |
6011 | "Allow EBGP neighbors not on directly connected networks\n") | |
6012 | { | |
d62a17ae | 6013 | int idx_peer = 1; |
6014 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6015 | } |
6016 | ||
6017 | DEFUN (neighbor_ebgp_multihop_ttl, | |
6018 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 6019 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 6020 | NEIGHBOR_STR |
6021 | NEIGHBOR_ADDR_STR2 | |
6022 | "Allow EBGP neighbors not on directly connected networks\n" | |
6023 | "maximum hop count\n") | |
6024 | { | |
d62a17ae | 6025 | int idx_peer = 1; |
6026 | int idx_number = 3; | |
6027 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
6028 | argv[idx_number]->arg); | |
718e3744 | 6029 | } |
6030 | ||
6031 | DEFUN (no_neighbor_ebgp_multihop, | |
6032 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 6033 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 6034 | NO_STR |
6035 | NEIGHBOR_STR | |
6036 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6037 | "Allow EBGP neighbors not on directly connected networks\n" |
6038 | "maximum hop count\n") | |
718e3744 | 6039 | { |
d62a17ae | 6040 | int idx_peer = 2; |
6041 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6042 | } |
6043 | ||
6b0655a2 | 6044 | |
6ffd2079 | 6045 | /* disable-connected-check */ |
6046 | DEFUN (neighbor_disable_connected_check, | |
6047 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 6048 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 6049 | NEIGHBOR_STR |
7ebe625c | 6050 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
6051 | "one-hop away EBGP peer using loopback address\n" |
6052 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6053 | { |
d62a17ae | 6054 | int idx_peer = 1; |
6055 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6056 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6057 | } |
6058 | ||
6059 | DEFUN (no_neighbor_disable_connected_check, | |
6060 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 6061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 6062 | NO_STR |
6063 | NEIGHBOR_STR | |
7ebe625c | 6064 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
6065 | "one-hop away EBGP peer using loopback address\n" |
6066 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 6067 | { |
d62a17ae | 6068 | int idx_peer = 2; |
6069 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6070 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 6071 | } |
6072 | ||
47cbc09b PM |
6073 | |
6074 | /* enforce-first-as */ | |
6075 | DEFUN (neighbor_enforce_first_as, | |
6076 | neighbor_enforce_first_as_cmd, | |
6077 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6078 | NEIGHBOR_STR | |
6079 | NEIGHBOR_ADDR_STR2 | |
6080 | "Enforce the first AS for EBGP routes\n") | |
6081 | { | |
6082 | int idx_peer = 1; | |
6083 | ||
6084 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6085 | PEER_FLAG_ENFORCE_FIRST_AS); | |
6086 | } | |
6087 | ||
6088 | DEFUN (no_neighbor_enforce_first_as, | |
6089 | no_neighbor_enforce_first_as_cmd, | |
6090 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
6091 | NO_STR | |
6092 | NEIGHBOR_STR | |
6093 | NEIGHBOR_ADDR_STR2 | |
6094 | "Enforce the first AS for EBGP routes\n") | |
6095 | { | |
6096 | int idx_peer = 2; | |
6097 | ||
6098 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6099 | PEER_FLAG_ENFORCE_FIRST_AS); | |
6100 | } | |
6101 | ||
6102 | ||
718e3744 | 6103 | DEFUN (neighbor_description, |
6104 | neighbor_description_cmd, | |
e961923c | 6105 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 6106 | NEIGHBOR_STR |
6107 | NEIGHBOR_ADDR_STR2 | |
6108 | "Neighbor specific description\n" | |
6109 | "Up to 80 characters describing this neighbor\n") | |
6110 | { | |
d62a17ae | 6111 | int idx_peer = 1; |
6112 | int idx_line = 3; | |
6113 | struct peer *peer; | |
6114 | char *str; | |
718e3744 | 6115 | |
d62a17ae | 6116 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6117 | if (!peer) | |
6118 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6119 | |
d62a17ae | 6120 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 6121 | |
d62a17ae | 6122 | peer_description_set(peer, str); |
718e3744 | 6123 | |
d62a17ae | 6124 | XFREE(MTYPE_TMP, str); |
718e3744 | 6125 | |
d62a17ae | 6126 | return CMD_SUCCESS; |
718e3744 | 6127 | } |
6128 | ||
6129 | DEFUN (no_neighbor_description, | |
6130 | no_neighbor_description_cmd, | |
a14810f4 | 6131 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 6132 | NO_STR |
6133 | NEIGHBOR_STR | |
6134 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 6135 | "Neighbor specific description\n") |
718e3744 | 6136 | { |
d62a17ae | 6137 | int idx_peer = 2; |
6138 | struct peer *peer; | |
718e3744 | 6139 | |
d62a17ae | 6140 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6141 | if (!peer) | |
6142 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6143 | |
d62a17ae | 6144 | peer_description_unset(peer); |
718e3744 | 6145 | |
d62a17ae | 6146 | return CMD_SUCCESS; |
718e3744 | 6147 | } |
6148 | ||
a14810f4 PM |
6149 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
6150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
6151 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6152 | "Neighbor specific description\n" | |
6153 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 6154 | |
718e3744 | 6155 | /* Neighbor update-source. */ |
d62a17ae | 6156 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
6157 | const char *source_str) | |
6158 | { | |
6159 | struct peer *peer; | |
6160 | struct prefix p; | |
a14810f4 | 6161 | union sockunion su; |
d62a17ae | 6162 | |
6163 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
6164 | if (!peer) | |
6165 | return CMD_WARNING_CONFIG_FAILED; | |
6166 | ||
6167 | if (peer->conf_if) | |
6168 | return CMD_WARNING; | |
6169 | ||
6170 | if (source_str) { | |
a14810f4 | 6171 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 6172 | peer_update_source_addr_set(peer, &su); |
6173 | else { | |
6174 | if (str2prefix(source_str, &p)) { | |
6175 | vty_out(vty, | |
6176 | "%% Invalid update-source, remove prefix length \n"); | |
6177 | return CMD_WARNING_CONFIG_FAILED; | |
6178 | } else | |
6179 | peer_update_source_if_set(peer, source_str); | |
6180 | } | |
6181 | } else | |
6182 | peer_update_source_unset(peer); | |
6183 | ||
6184 | return CMD_SUCCESS; | |
6185 | } | |
6186 | ||
6187 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
6188 | "IPv4 address\n" \ | |
6189 | "IPv6 address\n" \ | |
6190 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 6191 | |
718e3744 | 6192 | DEFUN (neighbor_update_source, |
6193 | neighbor_update_source_cmd, | |
9ccf14f7 | 6194 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 6195 | NEIGHBOR_STR |
6196 | NEIGHBOR_ADDR_STR2 | |
6197 | "Source of routing updates\n" | |
369688c0 | 6198 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 6199 | { |
d62a17ae | 6200 | int idx_peer = 1; |
6201 | int idx_peer_2 = 3; | |
6202 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
6203 | argv[idx_peer_2]->arg); | |
718e3744 | 6204 | } |
6205 | ||
6206 | DEFUN (no_neighbor_update_source, | |
6207 | no_neighbor_update_source_cmd, | |
c7178fe7 | 6208 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 6209 | NO_STR |
6210 | NEIGHBOR_STR | |
6211 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
6212 | "Source of routing updates\n" |
6213 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 6214 | { |
d62a17ae | 6215 | int idx_peer = 2; |
6216 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6217 | } |
6b0655a2 | 6218 | |
d62a17ae | 6219 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
6220 | afi_t afi, safi_t safi, | |
6221 | const char *rmap, int set) | |
718e3744 | 6222 | { |
d62a17ae | 6223 | int ret; |
6224 | struct peer *peer; | |
80912664 | 6225 | struct route_map *route_map = NULL; |
718e3744 | 6226 | |
d62a17ae | 6227 | peer = peer_and_group_lookup_vty(vty, peer_str); |
6228 | if (!peer) | |
6229 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6230 | |
1de27621 | 6231 | if (set) { |
80912664 DS |
6232 | if (rmap) |
6233 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
6234 | ret = peer_default_originate_set(peer, afi, safi, |
6235 | rmap, route_map); | |
6236 | } else | |
d62a17ae | 6237 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 6238 | |
d62a17ae | 6239 | return bgp_vty_return(vty, ret); |
718e3744 | 6240 | } |
6241 | ||
6242 | /* neighbor default-originate. */ | |
6243 | DEFUN (neighbor_default_originate, | |
6244 | neighbor_default_originate_cmd, | |
9ccf14f7 | 6245 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 6246 | NEIGHBOR_STR |
6247 | NEIGHBOR_ADDR_STR2 | |
6248 | "Originate default route to this neighbor\n") | |
6249 | { | |
d62a17ae | 6250 | int idx_peer = 1; |
6251 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6252 | bgp_node_afi(vty), | |
6253 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 6254 | } |
6255 | ||
d62a17ae | 6256 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
6257 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
6258 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6259 | "Originate default route to this neighbor\n") | |
596c17ba | 6260 | |
718e3744 | 6261 | DEFUN (neighbor_default_originate_rmap, |
6262 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 6263 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 6264 | NEIGHBOR_STR |
6265 | NEIGHBOR_ADDR_STR2 | |
6266 | "Originate default route to this neighbor\n" | |
6267 | "Route-map to specify criteria to originate default\n" | |
6268 | "route-map name\n") | |
6269 | { | |
d62a17ae | 6270 | int idx_peer = 1; |
6271 | int idx_word = 4; | |
6272 | return peer_default_originate_set_vty( | |
6273 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6274 | argv[idx_word]->arg, 1); | |
718e3744 | 6275 | } |
6276 | ||
d62a17ae | 6277 | ALIAS_HIDDEN( |
6278 | neighbor_default_originate_rmap, | |
6279 | neighbor_default_originate_rmap_hidden_cmd, | |
6280 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
6281 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6282 | "Originate default route to this neighbor\n" | |
6283 | "Route-map to specify criteria to originate default\n" | |
6284 | "route-map name\n") | |
596c17ba | 6285 | |
718e3744 | 6286 | DEFUN (no_neighbor_default_originate, |
6287 | no_neighbor_default_originate_cmd, | |
a636c635 | 6288 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 6289 | NO_STR |
6290 | NEIGHBOR_STR | |
6291 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
6292 | "Originate default route to this neighbor\n" |
6293 | "Route-map to specify criteria to originate default\n" | |
6294 | "route-map name\n") | |
718e3744 | 6295 | { |
d62a17ae | 6296 | int idx_peer = 2; |
6297 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
6298 | bgp_node_afi(vty), | |
6299 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 6300 | } |
6301 | ||
d62a17ae | 6302 | ALIAS_HIDDEN( |
6303 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
6304 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
6305 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6306 | "Originate default route to this neighbor\n" | |
6307 | "Route-map to specify criteria to originate default\n" | |
6308 | "route-map name\n") | |
596c17ba | 6309 | |
6b0655a2 | 6310 | |
718e3744 | 6311 | /* Set neighbor's BGP port. */ |
d62a17ae | 6312 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
6313 | const char *port_str) | |
6314 | { | |
6315 | struct peer *peer; | |
d7c0a89a | 6316 | uint16_t port; |
d62a17ae | 6317 | struct servent *sp; |
6318 | ||
6319 | peer = peer_lookup_vty(vty, ip_str); | |
6320 | if (!peer) | |
6321 | return CMD_WARNING_CONFIG_FAILED; | |
6322 | ||
6323 | if (!port_str) { | |
6324 | sp = getservbyname("bgp", "tcp"); | |
6325 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
6326 | } else { | |
6327 | port = strtoul(port_str, NULL, 10); | |
6328 | } | |
718e3744 | 6329 | |
d62a17ae | 6330 | peer_port_set(peer, port); |
718e3744 | 6331 | |
d62a17ae | 6332 | return CMD_SUCCESS; |
718e3744 | 6333 | } |
6334 | ||
f418446b | 6335 | /* Set specified peer's BGP port. */ |
718e3744 | 6336 | DEFUN (neighbor_port, |
6337 | neighbor_port_cmd, | |
9ccf14f7 | 6338 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 6339 | NEIGHBOR_STR |
6340 | NEIGHBOR_ADDR_STR | |
6341 | "Neighbor's BGP port\n" | |
6342 | "TCP port number\n") | |
6343 | { | |
d62a17ae | 6344 | int idx_ip = 1; |
6345 | int idx_number = 3; | |
6346 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
6347 | argv[idx_number]->arg); | |
718e3744 | 6348 | } |
6349 | ||
6350 | DEFUN (no_neighbor_port, | |
6351 | no_neighbor_port_cmd, | |
9ccf14f7 | 6352 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 6353 | NO_STR |
6354 | NEIGHBOR_STR | |
6355 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
6356 | "Neighbor's BGP port\n" |
6357 | "TCP port number\n") | |
718e3744 | 6358 | { |
d62a17ae | 6359 | int idx_ip = 2; |
6360 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 6361 | } |
6362 | ||
6b0655a2 | 6363 | |
718e3744 | 6364 | /* neighbor weight. */ |
d62a17ae | 6365 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6366 | safi_t safi, const char *weight_str) | |
718e3744 | 6367 | { |
d62a17ae | 6368 | int ret; |
6369 | struct peer *peer; | |
6370 | unsigned long weight; | |
718e3744 | 6371 | |
d62a17ae | 6372 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6373 | if (!peer) | |
6374 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6375 | |
d62a17ae | 6376 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 6377 | |
d62a17ae | 6378 | ret = peer_weight_set(peer, afi, safi, weight); |
6379 | return bgp_vty_return(vty, ret); | |
718e3744 | 6380 | } |
6381 | ||
d62a17ae | 6382 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6383 | safi_t safi) | |
718e3744 | 6384 | { |
d62a17ae | 6385 | int ret; |
6386 | struct peer *peer; | |
718e3744 | 6387 | |
d62a17ae | 6388 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6389 | if (!peer) | |
6390 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6391 | |
d62a17ae | 6392 | ret = peer_weight_unset(peer, afi, safi); |
6393 | return bgp_vty_return(vty, ret); | |
718e3744 | 6394 | } |
6395 | ||
6396 | DEFUN (neighbor_weight, | |
6397 | neighbor_weight_cmd, | |
9ccf14f7 | 6398 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 6399 | NEIGHBOR_STR |
6400 | NEIGHBOR_ADDR_STR2 | |
6401 | "Set default weight for routes from this neighbor\n" | |
6402 | "default weight\n") | |
6403 | { | |
d62a17ae | 6404 | int idx_peer = 1; |
6405 | int idx_number = 3; | |
6406 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6407 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 6408 | } |
6409 | ||
d62a17ae | 6410 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
6411 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
6412 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6413 | "Set default weight for routes from this neighbor\n" | |
6414 | "default weight\n") | |
596c17ba | 6415 | |
718e3744 | 6416 | DEFUN (no_neighbor_weight, |
6417 | no_neighbor_weight_cmd, | |
9ccf14f7 | 6418 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 6419 | NO_STR |
6420 | NEIGHBOR_STR | |
6421 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
6422 | "Set default weight for routes from this neighbor\n" |
6423 | "default weight\n") | |
718e3744 | 6424 | { |
d62a17ae | 6425 | int idx_peer = 2; |
6426 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
6427 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 6428 | } |
6429 | ||
d62a17ae | 6430 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
6431 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
6432 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6433 | "Set default weight for routes from this neighbor\n" | |
6434 | "default weight\n") | |
596c17ba | 6435 | |
6b0655a2 | 6436 | |
718e3744 | 6437 | /* Override capability negotiation. */ |
6438 | DEFUN (neighbor_override_capability, | |
6439 | neighbor_override_capability_cmd, | |
9ccf14f7 | 6440 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 6441 | NEIGHBOR_STR |
6442 | NEIGHBOR_ADDR_STR2 | |
6443 | "Override capability negotiation result\n") | |
6444 | { | |
d62a17ae | 6445 | int idx_peer = 1; |
6446 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
6447 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6448 | } |
6449 | ||
6450 | DEFUN (no_neighbor_override_capability, | |
6451 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 6452 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 6453 | NO_STR |
6454 | NEIGHBOR_STR | |
6455 | NEIGHBOR_ADDR_STR2 | |
6456 | "Override capability negotiation result\n") | |
6457 | { | |
d62a17ae | 6458 | int idx_peer = 2; |
6459 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6460 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 6461 | } |
6b0655a2 | 6462 | |
718e3744 | 6463 | DEFUN (neighbor_strict_capability, |
6464 | neighbor_strict_capability_cmd, | |
9fb964de | 6465 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 6466 | NEIGHBOR_STR |
9fb964de | 6467 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6468 | "Strict capability negotiation match\n") |
6469 | { | |
9fb964de PM |
6470 | int idx_peer = 1; |
6471 | ||
6472 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 6473 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 6474 | } |
6475 | ||
6476 | DEFUN (no_neighbor_strict_capability, | |
6477 | no_neighbor_strict_capability_cmd, | |
9fb964de | 6478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 6479 | NO_STR |
6480 | NEIGHBOR_STR | |
9fb964de | 6481 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6482 | "Strict capability negotiation match\n") |
6483 | { | |
9fb964de PM |
6484 | int idx_peer = 2; |
6485 | ||
6486 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 6487 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 6488 | } |
6b0655a2 | 6489 | |
d62a17ae | 6490 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
6491 | const char *keep_str, const char *hold_str) | |
718e3744 | 6492 | { |
d62a17ae | 6493 | int ret; |
6494 | struct peer *peer; | |
d7c0a89a QY |
6495 | uint32_t keepalive; |
6496 | uint32_t holdtime; | |
718e3744 | 6497 | |
d62a17ae | 6498 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6499 | if (!peer) | |
6500 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6501 | |
d62a17ae | 6502 | keepalive = strtoul(keep_str, NULL, 10); |
6503 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 6504 | |
d62a17ae | 6505 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 6506 | |
d62a17ae | 6507 | return bgp_vty_return(vty, ret); |
718e3744 | 6508 | } |
6b0655a2 | 6509 | |
d62a17ae | 6510 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6511 | { |
d62a17ae | 6512 | int ret; |
6513 | struct peer *peer; | |
718e3744 | 6514 | |
d62a17ae | 6515 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6516 | if (!peer) | |
6517 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6518 | |
d62a17ae | 6519 | ret = peer_timers_unset(peer); |
718e3744 | 6520 | |
d62a17ae | 6521 | return bgp_vty_return(vty, ret); |
718e3744 | 6522 | } |
6523 | ||
6524 | DEFUN (neighbor_timers, | |
6525 | neighbor_timers_cmd, | |
9ccf14f7 | 6526 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 6527 | NEIGHBOR_STR |
6528 | NEIGHBOR_ADDR_STR2 | |
6529 | "BGP per neighbor timers\n" | |
6530 | "Keepalive interval\n" | |
6531 | "Holdtime\n") | |
6532 | { | |
d62a17ae | 6533 | int idx_peer = 1; |
6534 | int idx_number = 3; | |
6535 | int idx_number_2 = 4; | |
6536 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
6537 | argv[idx_number]->arg, | |
6538 | argv[idx_number_2]->arg); | |
718e3744 | 6539 | } |
6540 | ||
6541 | DEFUN (no_neighbor_timers, | |
6542 | no_neighbor_timers_cmd, | |
9ccf14f7 | 6543 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 6544 | NO_STR |
6545 | NEIGHBOR_STR | |
6546 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
6547 | "BGP per neighbor timers\n" |
6548 | "Keepalive interval\n" | |
6549 | "Holdtime\n") | |
718e3744 | 6550 | { |
d62a17ae | 6551 | int idx_peer = 2; |
6552 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6553 | } |
6b0655a2 | 6554 | |
813d4307 | 6555 | |
d62a17ae | 6556 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
6557 | const char *time_str) | |
718e3744 | 6558 | { |
d62a17ae | 6559 | int ret; |
6560 | struct peer *peer; | |
d7c0a89a | 6561 | uint32_t connect; |
718e3744 | 6562 | |
d62a17ae | 6563 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6564 | if (!peer) | |
6565 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6566 | |
d62a17ae | 6567 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 6568 | |
d62a17ae | 6569 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 6570 | |
d62a17ae | 6571 | return bgp_vty_return(vty, ret); |
718e3744 | 6572 | } |
6573 | ||
d62a17ae | 6574 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6575 | { |
d62a17ae | 6576 | int ret; |
6577 | struct peer *peer; | |
718e3744 | 6578 | |
d62a17ae | 6579 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6580 | if (!peer) | |
6581 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6582 | |
d62a17ae | 6583 | ret = peer_timers_connect_unset(peer); |
718e3744 | 6584 | |
d62a17ae | 6585 | return bgp_vty_return(vty, ret); |
718e3744 | 6586 | } |
6587 | ||
6588 | DEFUN (neighbor_timers_connect, | |
6589 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 6590 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 6591 | NEIGHBOR_STR |
966f821c | 6592 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6593 | "BGP per neighbor timers\n" |
6594 | "BGP connect timer\n" | |
6595 | "Connect timer\n") | |
6596 | { | |
d62a17ae | 6597 | int idx_peer = 1; |
6598 | int idx_number = 4; | |
6599 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6600 | argv[idx_number]->arg); | |
718e3744 | 6601 | } |
6602 | ||
6603 | DEFUN (no_neighbor_timers_connect, | |
6604 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 6605 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 6606 | NO_STR |
6607 | NEIGHBOR_STR | |
966f821c | 6608 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6609 | "BGP per neighbor timers\n" |
8334fd5a DW |
6610 | "BGP connect timer\n" |
6611 | "Connect timer\n") | |
718e3744 | 6612 | { |
d62a17ae | 6613 | int idx_peer = 2; |
6614 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6615 | } |
6616 | ||
6b0655a2 | 6617 | |
d62a17ae | 6618 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6619 | const char *time_str, int set) | |
718e3744 | 6620 | { |
d62a17ae | 6621 | int ret; |
6622 | struct peer *peer; | |
d7c0a89a | 6623 | uint32_t routeadv = 0; |
718e3744 | 6624 | |
d62a17ae | 6625 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6626 | if (!peer) | |
6627 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6628 | |
d62a17ae | 6629 | if (time_str) |
6630 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 6631 | |
d62a17ae | 6632 | if (set) |
6633 | ret = peer_advertise_interval_set(peer, routeadv); | |
6634 | else | |
6635 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6636 | |
d62a17ae | 6637 | return bgp_vty_return(vty, ret); |
718e3744 | 6638 | } |
6639 | ||
6640 | DEFUN (neighbor_advertise_interval, | |
6641 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6642 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 6643 | NEIGHBOR_STR |
966f821c | 6644 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6645 | "Minimum interval between sending BGP routing updates\n" |
6646 | "time in seconds\n") | |
6647 | { | |
d62a17ae | 6648 | int idx_peer = 1; |
6649 | int idx_number = 3; | |
6650 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6651 | argv[idx_number]->arg, 1); | |
718e3744 | 6652 | } |
6653 | ||
6654 | DEFUN (no_neighbor_advertise_interval, | |
6655 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 6657 | NO_STR |
6658 | NEIGHBOR_STR | |
966f821c | 6659 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
6660 | "Minimum interval between sending BGP routing updates\n" |
6661 | "time in seconds\n") | |
718e3744 | 6662 | { |
d62a17ae | 6663 | int idx_peer = 2; |
6664 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6665 | } |
6666 | ||
6b0655a2 | 6667 | |
518f0eb1 DS |
6668 | /* Time to wait before processing route-map updates */ |
6669 | DEFUN (bgp_set_route_map_delay_timer, | |
6670 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6671 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6672 | SET_STR |
6673 | "BGP route-map delay timer\n" | |
6674 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6675 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6676 | { |
d62a17ae | 6677 | int idx_number = 3; |
d7c0a89a | 6678 | uint32_t rmap_delay_timer; |
d62a17ae | 6679 | |
6680 | if (argv[idx_number]->arg) { | |
6681 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6682 | bm->rmap_update_timer = rmap_delay_timer; | |
6683 | ||
6684 | /* if the dynamic update handling is being disabled, and a timer | |
6685 | * is | |
6686 | * running, stop the timer and act as if the timer has already | |
6687 | * fired. | |
6688 | */ | |
6689 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6690 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6691 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6692 | NULL, 0); | |
6693 | } | |
6694 | return CMD_SUCCESS; | |
6695 | } else { | |
6696 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6697 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6698 | } |
518f0eb1 DS |
6699 | } |
6700 | ||
6701 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6702 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6703 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6704 | NO_STR |
3a2d747c | 6705 | BGP_STR |
518f0eb1 | 6706 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6707 | "Reset to default time to wait for processing route-map changes\n" |
6708 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6709 | { |
518f0eb1 | 6710 | |
d62a17ae | 6711 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6712 | |
d62a17ae | 6713 | return CMD_SUCCESS; |
518f0eb1 DS |
6714 | } |
6715 | ||
718e3744 | 6716 | /* neighbor interface */ |
d62a17ae | 6717 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6718 | const char *str) | |
718e3744 | 6719 | { |
d62a17ae | 6720 | struct peer *peer; |
718e3744 | 6721 | |
d62a17ae | 6722 | peer = peer_lookup_vty(vty, ip_str); |
6723 | if (!peer || peer->conf_if) { | |
6724 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6725 | return CMD_WARNING_CONFIG_FAILED; | |
6726 | } | |
718e3744 | 6727 | |
d62a17ae | 6728 | if (str) |
6729 | peer_interface_set(peer, str); | |
6730 | else | |
6731 | peer_interface_unset(peer); | |
718e3744 | 6732 | |
d62a17ae | 6733 | return CMD_SUCCESS; |
718e3744 | 6734 | } |
6735 | ||
6736 | DEFUN (neighbor_interface, | |
6737 | neighbor_interface_cmd, | |
9ccf14f7 | 6738 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6739 | NEIGHBOR_STR |
6740 | NEIGHBOR_ADDR_STR | |
6741 | "Interface\n" | |
6742 | "Interface name\n") | |
6743 | { | |
d62a17ae | 6744 | int idx_ip = 1; |
6745 | int idx_word = 3; | |
6746 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6747 | } |
6748 | ||
6749 | DEFUN (no_neighbor_interface, | |
6750 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6751 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6752 | NO_STR |
6753 | NEIGHBOR_STR | |
16cedbb0 | 6754 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6755 | "Interface\n" |
6756 | "Interface name\n") | |
6757 | { | |
d62a17ae | 6758 | int idx_peer = 2; |
6759 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6760 | } |
6b0655a2 | 6761 | |
718e3744 | 6762 | DEFUN (neighbor_distribute_list, |
6763 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6764 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6765 | NEIGHBOR_STR |
6766 | NEIGHBOR_ADDR_STR2 | |
6767 | "Filter updates to/from this neighbor\n" | |
6768 | "IP access-list number\n" | |
6769 | "IP access-list number (expanded range)\n" | |
6770 | "IP Access-list name\n" | |
6771 | "Filter incoming updates\n" | |
6772 | "Filter outgoing updates\n") | |
6773 | { | |
d62a17ae | 6774 | int idx_peer = 1; |
6775 | int idx_acl = 3; | |
6776 | int direct, ret; | |
6777 | struct peer *peer; | |
a8206004 | 6778 | |
d62a17ae | 6779 | const char *pstr = argv[idx_peer]->arg; |
6780 | const char *acl = argv[idx_acl]->arg; | |
6781 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6782 | |
d62a17ae | 6783 | peer = peer_and_group_lookup_vty(vty, pstr); |
6784 | if (!peer) | |
6785 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6786 | |
d62a17ae | 6787 | /* Check filter direction. */ |
6788 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6789 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6790 | direct, acl); | |
a8206004 | 6791 | |
d62a17ae | 6792 | return bgp_vty_return(vty, ret); |
718e3744 | 6793 | } |
6794 | ||
d62a17ae | 6795 | ALIAS_HIDDEN( |
6796 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6797 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6798 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6799 | "Filter updates to/from this neighbor\n" | |
6800 | "IP access-list number\n" | |
6801 | "IP access-list number (expanded range)\n" | |
6802 | "IP Access-list name\n" | |
6803 | "Filter incoming updates\n" | |
6804 | "Filter outgoing updates\n") | |
596c17ba | 6805 | |
718e3744 | 6806 | DEFUN (no_neighbor_distribute_list, |
6807 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6808 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6809 | NO_STR |
6810 | NEIGHBOR_STR | |
6811 | NEIGHBOR_ADDR_STR2 | |
6812 | "Filter updates to/from this neighbor\n" | |
6813 | "IP access-list number\n" | |
6814 | "IP access-list number (expanded range)\n" | |
6815 | "IP Access-list name\n" | |
6816 | "Filter incoming updates\n" | |
6817 | "Filter outgoing updates\n") | |
6818 | { | |
d62a17ae | 6819 | int idx_peer = 2; |
6820 | int direct, ret; | |
6821 | struct peer *peer; | |
a8206004 | 6822 | |
d62a17ae | 6823 | const char *pstr = argv[idx_peer]->arg; |
6824 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6825 | |
d62a17ae | 6826 | peer = peer_and_group_lookup_vty(vty, pstr); |
6827 | if (!peer) | |
6828 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6829 | |
d62a17ae | 6830 | /* Check filter direction. */ |
6831 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6832 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6833 | direct); | |
a8206004 | 6834 | |
d62a17ae | 6835 | return bgp_vty_return(vty, ret); |
718e3744 | 6836 | } |
6b0655a2 | 6837 | |
d62a17ae | 6838 | ALIAS_HIDDEN( |
6839 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6841 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6842 | "Filter updates to/from this neighbor\n" | |
6843 | "IP access-list number\n" | |
6844 | "IP access-list number (expanded range)\n" | |
6845 | "IP Access-list name\n" | |
6846 | "Filter incoming updates\n" | |
6847 | "Filter outgoing updates\n") | |
596c17ba | 6848 | |
718e3744 | 6849 | /* Set prefix list to the peer. */ |
d62a17ae | 6850 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6851 | afi_t afi, safi_t safi, | |
6852 | const char *name_str, | |
6853 | const char *direct_str) | |
718e3744 | 6854 | { |
d62a17ae | 6855 | int ret; |
d62a17ae | 6856 | int direct = FILTER_IN; |
cf9ac8bf | 6857 | struct peer *peer; |
718e3744 | 6858 | |
d62a17ae | 6859 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6860 | if (!peer) | |
6861 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6862 | |
d62a17ae | 6863 | /* Check filter direction. */ |
6864 | if (strncmp(direct_str, "i", 1) == 0) | |
6865 | direct = FILTER_IN; | |
6866 | else if (strncmp(direct_str, "o", 1) == 0) | |
6867 | direct = FILTER_OUT; | |
718e3744 | 6868 | |
d62a17ae | 6869 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6870 | |
d62a17ae | 6871 | return bgp_vty_return(vty, ret); |
718e3744 | 6872 | } |
6873 | ||
d62a17ae | 6874 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6875 | afi_t afi, safi_t safi, | |
6876 | const char *direct_str) | |
718e3744 | 6877 | { |
d62a17ae | 6878 | int ret; |
6879 | struct peer *peer; | |
6880 | int direct = FILTER_IN; | |
718e3744 | 6881 | |
d62a17ae | 6882 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6883 | if (!peer) | |
6884 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6885 | |
d62a17ae | 6886 | /* Check filter direction. */ |
6887 | if (strncmp(direct_str, "i", 1) == 0) | |
6888 | direct = FILTER_IN; | |
6889 | else if (strncmp(direct_str, "o", 1) == 0) | |
6890 | direct = FILTER_OUT; | |
718e3744 | 6891 | |
d62a17ae | 6892 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6893 | |
d62a17ae | 6894 | return bgp_vty_return(vty, ret); |
718e3744 | 6895 | } |
6896 | ||
6897 | DEFUN (neighbor_prefix_list, | |
6898 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6899 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6900 | NEIGHBOR_STR |
6901 | NEIGHBOR_ADDR_STR2 | |
6902 | "Filter updates to/from this neighbor\n" | |
6903 | "Name of a prefix list\n" | |
6904 | "Filter incoming updates\n" | |
6905 | "Filter outgoing updates\n") | |
6906 | { | |
d62a17ae | 6907 | int idx_peer = 1; |
6908 | int idx_word = 3; | |
6909 | int idx_in_out = 4; | |
6910 | return peer_prefix_list_set_vty( | |
6911 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6912 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6913 | } |
6914 | ||
d62a17ae | 6915 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6916 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6917 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6918 | "Filter updates to/from this neighbor\n" | |
6919 | "Name of a prefix list\n" | |
6920 | "Filter incoming updates\n" | |
6921 | "Filter outgoing updates\n") | |
596c17ba | 6922 | |
718e3744 | 6923 | DEFUN (no_neighbor_prefix_list, |
6924 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6926 | NO_STR |
6927 | NEIGHBOR_STR | |
6928 | NEIGHBOR_ADDR_STR2 | |
6929 | "Filter updates to/from this neighbor\n" | |
6930 | "Name of a prefix list\n" | |
6931 | "Filter incoming updates\n" | |
6932 | "Filter outgoing updates\n") | |
6933 | { | |
d62a17ae | 6934 | int idx_peer = 2; |
6935 | int idx_in_out = 5; | |
6936 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6937 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6938 | argv[idx_in_out]->arg); | |
718e3744 | 6939 | } |
6b0655a2 | 6940 | |
d62a17ae | 6941 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6942 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6943 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6944 | "Filter updates to/from this neighbor\n" | |
6945 | "Name of a prefix list\n" | |
6946 | "Filter incoming updates\n" | |
6947 | "Filter outgoing updates\n") | |
596c17ba | 6948 | |
d62a17ae | 6949 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6950 | safi_t safi, const char *name_str, | |
6951 | const char *direct_str) | |
718e3744 | 6952 | { |
d62a17ae | 6953 | int ret; |
6954 | struct peer *peer; | |
6955 | int direct = FILTER_IN; | |
718e3744 | 6956 | |
d62a17ae | 6957 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6958 | if (!peer) | |
6959 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6960 | |
d62a17ae | 6961 | /* Check filter direction. */ |
6962 | if (strncmp(direct_str, "i", 1) == 0) | |
6963 | direct = FILTER_IN; | |
6964 | else if (strncmp(direct_str, "o", 1) == 0) | |
6965 | direct = FILTER_OUT; | |
718e3744 | 6966 | |
d62a17ae | 6967 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6968 | |
d62a17ae | 6969 | return bgp_vty_return(vty, ret); |
718e3744 | 6970 | } |
6971 | ||
d62a17ae | 6972 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6973 | safi_t safi, const char *direct_str) | |
718e3744 | 6974 | { |
d62a17ae | 6975 | int ret; |
6976 | struct peer *peer; | |
6977 | int direct = FILTER_IN; | |
718e3744 | 6978 | |
d62a17ae | 6979 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6980 | if (!peer) | |
6981 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6982 | |
d62a17ae | 6983 | /* Check filter direction. */ |
6984 | if (strncmp(direct_str, "i", 1) == 0) | |
6985 | direct = FILTER_IN; | |
6986 | else if (strncmp(direct_str, "o", 1) == 0) | |
6987 | direct = FILTER_OUT; | |
718e3744 | 6988 | |
d62a17ae | 6989 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6990 | |
d62a17ae | 6991 | return bgp_vty_return(vty, ret); |
718e3744 | 6992 | } |
6993 | ||
6994 | DEFUN (neighbor_filter_list, | |
6995 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6996 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6997 | NEIGHBOR_STR |
6998 | NEIGHBOR_ADDR_STR2 | |
6999 | "Establish BGP filters\n" | |
7000 | "AS path access-list name\n" | |
7001 | "Filter incoming routes\n" | |
7002 | "Filter outgoing routes\n") | |
7003 | { | |
d62a17ae | 7004 | int idx_peer = 1; |
7005 | int idx_word = 3; | |
7006 | int idx_in_out = 4; | |
7007 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
7008 | bgp_node_safi(vty), argv[idx_word]->arg, | |
7009 | argv[idx_in_out]->arg); | |
718e3744 | 7010 | } |
7011 | ||
d62a17ae | 7012 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
7013 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7014 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7015 | "Establish BGP filters\n" | |
7016 | "AS path access-list name\n" | |
7017 | "Filter incoming routes\n" | |
7018 | "Filter outgoing routes\n") | |
596c17ba | 7019 | |
718e3744 | 7020 | DEFUN (no_neighbor_filter_list, |
7021 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 7022 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 7023 | NO_STR |
7024 | NEIGHBOR_STR | |
7025 | NEIGHBOR_ADDR_STR2 | |
7026 | "Establish BGP filters\n" | |
7027 | "AS path access-list name\n" | |
7028 | "Filter incoming routes\n" | |
7029 | "Filter outgoing routes\n") | |
7030 | { | |
d62a17ae | 7031 | int idx_peer = 2; |
7032 | int idx_in_out = 5; | |
7033 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
7034 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7035 | argv[idx_in_out]->arg); | |
718e3744 | 7036 | } |
6b0655a2 | 7037 | |
d62a17ae | 7038 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
7039 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
7040 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7041 | "Establish BGP filters\n" | |
7042 | "AS path access-list name\n" | |
7043 | "Filter incoming routes\n" | |
7044 | "Filter outgoing routes\n") | |
596c17ba | 7045 | |
7f7940e6 MK |
7046 | /* Set advertise-map to the peer. */ |
7047 | static int peer_advertise_map_set_vty(struct vty *vty, const char *ip_str, | |
7048 | afi_t afi, safi_t safi, | |
7049 | const char *advertise_str, bool condition, | |
7050 | const char *condition_str) | |
7051 | { | |
7052 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7053 | struct peer *peer; | |
7054 | struct route_map *advertise_map; | |
7055 | struct route_map *condition_map; | |
7056 | ||
7057 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7058 | if (!peer) | |
7059 | return ret; | |
7060 | ||
7061 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7062 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7063 | ||
7064 | ret = peer_advertise_map_set(peer, afi, safi, advertise_str, | |
7065 | advertise_map, condition, condition_str, | |
7066 | condition_map); | |
7067 | ||
7068 | return bgp_vty_return(vty, ret); | |
7069 | } | |
7070 | ||
7071 | static int peer_advertise_map_unset_vty(struct vty *vty, const char *ip_str, | |
7072 | afi_t afi, safi_t safi, | |
7073 | const char *advertise_str, | |
7074 | bool condition, | |
7075 | const char *condition_str) | |
7076 | { | |
7077 | int ret = CMD_WARNING_CONFIG_FAILED; | |
7078 | struct peer *peer; | |
7079 | struct route_map *advertise_map; | |
7080 | struct route_map *condition_map; | |
7081 | ||
7082 | ||
7083 | peer = peer_and_group_lookup_vty(vty, ip_str); | |
7084 | if (!peer) | |
7085 | return ret; | |
7086 | ||
7087 | condition_map = route_map_lookup_warn_noexist(vty, condition_str); | |
7088 | advertise_map = route_map_lookup_warn_noexist(vty, advertise_str); | |
7089 | ||
7090 | ret = peer_advertise_map_unset(peer, afi, safi, advertise_str, | |
7091 | advertise_map, condition, condition_str, | |
7092 | condition_map); | |
7093 | ||
7094 | return bgp_vty_return(vty, ret); | |
7095 | } | |
7096 | ||
7097 | DEFUN (neighbor_advertise_map, | |
7098 | neighbor_advertise_map_cmd, | |
7099 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertise-map WORD <exist-map WORD|non-exist-map WORD>", | |
7100 | NEIGHBOR_STR | |
7101 | NEIGHBOR_ADDR_STR2 | |
7102 | "Route-map to conditionally advertise routes\n" | |
7103 | "Name of advertise map\n" | |
7104 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7105 | "Name of the exist map\n" | |
7106 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7107 | "Name of the non exist map\n") | |
7108 | { | |
7109 | int idx = 0; | |
7110 | int idx_peer = 1; | |
7111 | int idx_advertise_word = 3; | |
7112 | int idx_condition_word = 5; | |
7113 | bool condition = CONDITION_EXIST; | |
7114 | ||
7115 | if (argv_find(argv, argc, "non-exist-map", &idx)) | |
7116 | condition = CONDITION_NON_EXIST; | |
7117 | ||
7118 | return peer_advertise_map_set_vty( | |
7119 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7120 | argv[idx_advertise_word]->arg, condition, | |
7121 | argv[idx_condition_word]->arg); | |
7122 | } | |
7123 | ||
7124 | ALIAS_HIDDEN(neighbor_advertise_map, neighbor_advertise_map_hidden_cmd, | |
7125 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertise-map WORD <exist-map WORD|non-exist-map WORD>", | |
7126 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7127 | "Route-map to conditionally advertise routes\n" | |
7128 | "Name of advertise map\n" | |
7129 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7130 | "Name of the exist map\n" | |
7131 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7132 | "Name of the non exist map\n") | |
7133 | ||
7134 | DEFUN (no_neighbor_advertise_map, | |
7135 | no_neighbor_advertise_map_cmd, | |
7136 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertise-map WORD <exist-map WORD|non-exist-map WORD>", | |
7137 | NO_STR | |
7138 | NEIGHBOR_STR | |
7139 | NEIGHBOR_ADDR_STR2 | |
7140 | "Route-map to conditionally advertise routes\n" | |
7141 | "Name of advertise map\n" | |
7142 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7143 | "Name of the exist map\n" | |
7144 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7145 | "Name of the non exist map\n") | |
7146 | { | |
7147 | int idx = 0; | |
7148 | int idx_peer = 2; | |
7149 | int idx_advertise_word = 4; | |
7150 | int idx_condition_word = 6; | |
7151 | bool condition = CONDITION_EXIST; | |
7152 | ||
7153 | if (argv_find(argv, argc, "non-exist-map", &idx)) | |
7154 | condition = CONDITION_NON_EXIST; | |
7155 | ||
7156 | return peer_advertise_map_unset_vty( | |
7157 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7158 | argv[idx_advertise_word]->arg, condition, | |
7159 | argv[idx_condition_word]->arg); | |
7160 | } | |
7161 | ||
7162 | ALIAS_HIDDEN(no_neighbor_advertise_map, no_neighbor_advertise_map_hidden_cmd, | |
7163 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertise-map WORD <exist-map WORD|non-exist-map WORD>", | |
7164 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7165 | "Route-map to conditionally advertise routes\n" | |
7166 | "Name of advertise map\n" | |
7167 | "Advertise routes only if prefixes in exist-map are installed in BGP table\n" | |
7168 | "Name of the exist map\n" | |
7169 | "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n" | |
7170 | "Name of the non exist map\n") | |
7171 | ||
718e3744 | 7172 | /* Set route-map to the peer. */ |
d62a17ae | 7173 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
7174 | afi_t afi, safi_t safi, const char *name_str, | |
7175 | const char *direct_str) | |
718e3744 | 7176 | { |
d62a17ae | 7177 | int ret; |
7178 | struct peer *peer; | |
7179 | int direct = RMAP_IN; | |
1de27621 | 7180 | struct route_map *route_map; |
718e3744 | 7181 | |
d62a17ae | 7182 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7183 | if (!peer) | |
7184 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7185 | |
d62a17ae | 7186 | /* Check filter direction. */ |
7187 | if (strncmp(direct_str, "in", 2) == 0) | |
7188 | direct = RMAP_IN; | |
7189 | else if (strncmp(direct_str, "o", 1) == 0) | |
7190 | direct = RMAP_OUT; | |
718e3744 | 7191 | |
1de27621 DA |
7192 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7193 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 7194 | |
d62a17ae | 7195 | return bgp_vty_return(vty, ret); |
718e3744 | 7196 | } |
7197 | ||
d62a17ae | 7198 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
7199 | afi_t afi, safi_t safi, | |
7200 | const char *direct_str) | |
718e3744 | 7201 | { |
d62a17ae | 7202 | int ret; |
7203 | struct peer *peer; | |
7204 | int direct = RMAP_IN; | |
718e3744 | 7205 | |
d62a17ae | 7206 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7207 | if (!peer) | |
7208 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7209 | |
d62a17ae | 7210 | /* Check filter direction. */ |
7211 | if (strncmp(direct_str, "in", 2) == 0) | |
7212 | direct = RMAP_IN; | |
7213 | else if (strncmp(direct_str, "o", 1) == 0) | |
7214 | direct = RMAP_OUT; | |
718e3744 | 7215 | |
d62a17ae | 7216 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 7217 | |
d62a17ae | 7218 | return bgp_vty_return(vty, ret); |
718e3744 | 7219 | } |
7220 | ||
7221 | DEFUN (neighbor_route_map, | |
7222 | neighbor_route_map_cmd, | |
9ccf14f7 | 7223 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7224 | NEIGHBOR_STR |
7225 | NEIGHBOR_ADDR_STR2 | |
7226 | "Apply route map to neighbor\n" | |
7227 | "Name of route map\n" | |
7228 | "Apply map to incoming routes\n" | |
2a3d5731 | 7229 | "Apply map to outbound routes\n") |
718e3744 | 7230 | { |
d62a17ae | 7231 | int idx_peer = 1; |
7232 | int idx_word = 3; | |
7233 | int idx_in_out = 4; | |
7234 | return peer_route_map_set_vty( | |
7235 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7236 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 7237 | } |
7238 | ||
d62a17ae | 7239 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
7240 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7241 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7242 | "Apply route map to neighbor\n" | |
7243 | "Name of route map\n" | |
7244 | "Apply map to incoming routes\n" | |
7245 | "Apply map to outbound routes\n") | |
596c17ba | 7246 | |
718e3744 | 7247 | DEFUN (no_neighbor_route_map, |
7248 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 7249 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 7250 | NO_STR |
7251 | NEIGHBOR_STR | |
7252 | NEIGHBOR_ADDR_STR2 | |
7253 | "Apply route map to neighbor\n" | |
7254 | "Name of route map\n" | |
7255 | "Apply map to incoming routes\n" | |
2a3d5731 | 7256 | "Apply map to outbound routes\n") |
718e3744 | 7257 | { |
d62a17ae | 7258 | int idx_peer = 2; |
7259 | int idx_in_out = 5; | |
7260 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
7261 | bgp_node_afi(vty), bgp_node_safi(vty), | |
7262 | argv[idx_in_out]->arg); | |
718e3744 | 7263 | } |
6b0655a2 | 7264 | |
d62a17ae | 7265 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
7266 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
7267 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7268 | "Apply route map to neighbor\n" | |
7269 | "Name of route map\n" | |
7270 | "Apply map to incoming routes\n" | |
7271 | "Apply map to outbound routes\n") | |
596c17ba | 7272 | |
718e3744 | 7273 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 7274 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
7275 | afi_t afi, safi_t safi, | |
7276 | const char *name_str) | |
718e3744 | 7277 | { |
d62a17ae | 7278 | int ret; |
7279 | struct peer *peer; | |
1de27621 | 7280 | struct route_map *route_map; |
718e3744 | 7281 | |
d62a17ae | 7282 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7283 | if (!peer) | |
7284 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7285 | |
1de27621 DA |
7286 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
7287 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 7288 | |
d62a17ae | 7289 | return bgp_vty_return(vty, ret); |
718e3744 | 7290 | } |
7291 | ||
7292 | /* Unset route-map from the peer. */ | |
d62a17ae | 7293 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
7294 | afi_t afi, safi_t safi) | |
718e3744 | 7295 | { |
d62a17ae | 7296 | int ret; |
7297 | struct peer *peer; | |
718e3744 | 7298 | |
d62a17ae | 7299 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7300 | if (!peer) | |
7301 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7302 | |
d62a17ae | 7303 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 7304 | |
d62a17ae | 7305 | return bgp_vty_return(vty, ret); |
718e3744 | 7306 | } |
7307 | ||
7308 | DEFUN (neighbor_unsuppress_map, | |
7309 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7310 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7311 | NEIGHBOR_STR |
7312 | NEIGHBOR_ADDR_STR2 | |
7313 | "Route-map to selectively unsuppress suppressed routes\n" | |
7314 | "Name of route map\n") | |
7315 | { | |
d62a17ae | 7316 | int idx_peer = 1; |
7317 | int idx_word = 3; | |
7318 | return peer_unsuppress_map_set_vty( | |
7319 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7320 | argv[idx_word]->arg); | |
718e3744 | 7321 | } |
7322 | ||
d62a17ae | 7323 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
7324 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7325 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7326 | "Route-map to selectively unsuppress suppressed routes\n" | |
7327 | "Name of route map\n") | |
596c17ba | 7328 | |
718e3744 | 7329 | DEFUN (no_neighbor_unsuppress_map, |
7330 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 7331 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 7332 | NO_STR |
7333 | NEIGHBOR_STR | |
7334 | NEIGHBOR_ADDR_STR2 | |
7335 | "Route-map to selectively unsuppress suppressed routes\n" | |
7336 | "Name of route map\n") | |
7337 | { | |
d62a17ae | 7338 | int idx_peer = 2; |
7339 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
7340 | bgp_node_afi(vty), | |
7341 | bgp_node_safi(vty)); | |
718e3744 | 7342 | } |
6b0655a2 | 7343 | |
d62a17ae | 7344 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
7345 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
7346 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7347 | "Route-map to selectively unsuppress suppressed routes\n" | |
7348 | "Name of route map\n") | |
596c17ba | 7349 | |
d62a17ae | 7350 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
7351 | afi_t afi, safi_t safi, | |
7352 | const char *num_str, | |
7353 | const char *threshold_str, int warning, | |
9cbd06e0 DA |
7354 | const char *restart_str, |
7355 | const char *force_str) | |
718e3744 | 7356 | { |
d62a17ae | 7357 | int ret; |
7358 | struct peer *peer; | |
d7c0a89a QY |
7359 | uint32_t max; |
7360 | uint8_t threshold; | |
7361 | uint16_t restart; | |
718e3744 | 7362 | |
d62a17ae | 7363 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7364 | if (!peer) | |
7365 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7366 | |
d62a17ae | 7367 | max = strtoul(num_str, NULL, 10); |
7368 | if (threshold_str) | |
7369 | threshold = atoi(threshold_str); | |
7370 | else | |
7371 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 7372 | |
d62a17ae | 7373 | if (restart_str) |
7374 | restart = atoi(restart_str); | |
7375 | else | |
7376 | restart = 0; | |
0a486e5f | 7377 | |
d62a17ae | 7378 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
9cbd06e0 | 7379 | restart, force_str ? true : false); |
718e3744 | 7380 | |
d62a17ae | 7381 | return bgp_vty_return(vty, ret); |
718e3744 | 7382 | } |
7383 | ||
d62a17ae | 7384 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
7385 | afi_t afi, safi_t safi) | |
718e3744 | 7386 | { |
d62a17ae | 7387 | int ret; |
7388 | struct peer *peer; | |
718e3744 | 7389 | |
d62a17ae | 7390 | peer = peer_and_group_lookup_vty(vty, ip_str); |
7391 | if (!peer) | |
7392 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7393 | |
d62a17ae | 7394 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 7395 | |
d62a17ae | 7396 | return bgp_vty_return(vty, ret); |
718e3744 | 7397 | } |
7398 | ||
fde246e8 DA |
7399 | /* Maximum number of prefix to be sent to the neighbor. */ |
7400 | DEFUN(neighbor_maximum_prefix_out, | |
7401 | neighbor_maximum_prefix_out_cmd, | |
7402 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
7403 | NEIGHBOR_STR | |
7404 | NEIGHBOR_ADDR_STR2 | |
7405 | "Maximum number of prefixes to be sent to this peer\n" | |
7406 | "Maximum no. of prefix limit\n") | |
7407 | { | |
7408 | int idx_peer = 1; | |
7409 | int idx_number = 3; | |
7410 | struct peer *peer; | |
7411 | uint32_t max; | |
7412 | afi_t afi = bgp_node_afi(vty); | |
7413 | safi_t safi = bgp_node_safi(vty); | |
7414 | ||
7415 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7416 | if (!peer) | |
7417 | return CMD_WARNING_CONFIG_FAILED; | |
7418 | ||
7419 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
7420 | ||
7421 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
7422 | peer->pmax_out[afi][safi] = max; | |
7423 | ||
7424 | return CMD_SUCCESS; | |
7425 | } | |
7426 | ||
7427 | DEFUN(no_neighbor_maximum_prefix_out, | |
7428 | no_neighbor_maximum_prefix_out_cmd, | |
7429 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
7430 | NO_STR | |
7431 | NEIGHBOR_STR | |
7432 | NEIGHBOR_ADDR_STR2 | |
7433 | "Maximum number of prefixes to be sent to this peer\n") | |
7434 | { | |
7435 | int idx_peer = 2; | |
7436 | struct peer *peer; | |
7437 | afi_t afi = bgp_node_afi(vty); | |
7438 | safi_t safi = bgp_node_safi(vty); | |
7439 | ||
7440 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7441 | if (!peer) | |
7442 | return CMD_WARNING_CONFIG_FAILED; | |
7443 | ||
ae00326a | 7444 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
7445 | peer->pmax_out[afi][safi] = 0; |
7446 | ||
7447 | return CMD_SUCCESS; | |
7448 | } | |
7449 | ||
9cbd06e0 DA |
7450 | /* Maximum number of prefix configuration. Prefix count is different |
7451 | for each peer configuration. So this configuration can be set for | |
718e3744 | 7452 | each peer configuration. */ |
7453 | DEFUN (neighbor_maximum_prefix, | |
7454 | neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 7455 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
718e3744 | 7456 | NEIGHBOR_STR |
7457 | NEIGHBOR_ADDR_STR2 | |
7458 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7459 | "maximum no. of prefix limit\n" |
7460 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7461 | { |
d62a17ae | 7462 | int idx_peer = 1; |
7463 | int idx_number = 3; | |
9cbd06e0 DA |
7464 | int idx_force = 0; |
7465 | char *force = NULL; | |
7466 | ||
7467 | if (argv_find(argv, argc, "force", &idx_force)) | |
7468 | force = argv[idx_force]->arg; | |
7469 | ||
d62a17ae | 7470 | return peer_maximum_prefix_set_vty( |
7471 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7472 | argv[idx_number]->arg, NULL, 0, NULL, force); |
718e3744 | 7473 | } |
7474 | ||
d62a17ae | 7475 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
9cbd06e0 | 7476 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]", |
d62a17ae | 7477 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7478 | "Maximum number of prefix accept from this peer\n" | |
9cbd06e0 DA |
7479 | "maximum no. of prefix limit\n" |
7480 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7481 | |
e0701b79 | 7482 | DEFUN (neighbor_maximum_prefix_threshold, |
7483 | neighbor_maximum_prefix_threshold_cmd, | |
9cbd06e0 | 7484 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
e0701b79 | 7485 | NEIGHBOR_STR |
7486 | NEIGHBOR_ADDR_STR2 | |
7487 | "Maximum number of prefix accept from this peer\n" | |
7488 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7489 | "Threshold value (%) at which to generate a warning msg\n" |
7490 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7491 | { |
d62a17ae | 7492 | int idx_peer = 1; |
7493 | int idx_number = 3; | |
7494 | int idx_number_2 = 4; | |
9cbd06e0 DA |
7495 | int idx_force = 0; |
7496 | char *force = NULL; | |
7497 | ||
7498 | if (argv_find(argv, argc, "force", &idx_force)) | |
7499 | force = argv[idx_force]->arg; | |
7500 | ||
d62a17ae | 7501 | return peer_maximum_prefix_set_vty( |
7502 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7503 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL, force); |
0a486e5f | 7504 | } |
e0701b79 | 7505 | |
d62a17ae | 7506 | ALIAS_HIDDEN( |
7507 | neighbor_maximum_prefix_threshold, | |
7508 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
9cbd06e0 | 7509 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]", |
d62a17ae | 7510 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7511 | "Maximum number of prefix accept from this peer\n" | |
7512 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7513 | "Threshold value (%) at which to generate a warning msg\n" |
7514 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7515 | |
718e3744 | 7516 | DEFUN (neighbor_maximum_prefix_warning, |
7517 | neighbor_maximum_prefix_warning_cmd, | |
9cbd06e0 | 7518 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
718e3744 | 7519 | NEIGHBOR_STR |
7520 | NEIGHBOR_ADDR_STR2 | |
7521 | "Maximum number of prefix accept from this peer\n" | |
7522 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7523 | "Only give warning message when limit is exceeded\n" |
7524 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7525 | { |
d62a17ae | 7526 | int idx_peer = 1; |
7527 | int idx_number = 3; | |
9cbd06e0 DA |
7528 | int idx_force = 0; |
7529 | char *force = NULL; | |
7530 | ||
7531 | if (argv_find(argv, argc, "force", &idx_force)) | |
7532 | force = argv[idx_force]->arg; | |
7533 | ||
d62a17ae | 7534 | return peer_maximum_prefix_set_vty( |
7535 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7536 | argv[idx_number]->arg, NULL, 1, NULL, force); |
718e3744 | 7537 | } |
7538 | ||
d62a17ae | 7539 | ALIAS_HIDDEN( |
7540 | neighbor_maximum_prefix_warning, | |
7541 | neighbor_maximum_prefix_warning_hidden_cmd, | |
9cbd06e0 | 7542 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]", |
d62a17ae | 7543 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7544 | "Maximum number of prefix accept from this peer\n" | |
7545 | "maximum no. of prefix limit\n" | |
9cbd06e0 DA |
7546 | "Only give warning message when limit is exceeded\n" |
7547 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7548 | |
e0701b79 | 7549 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
7550 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9cbd06e0 | 7551 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
e0701b79 | 7552 | NEIGHBOR_STR |
7553 | NEIGHBOR_ADDR_STR2 | |
7554 | "Maximum number of prefix accept from this peer\n" | |
7555 | "maximum no. of prefix limit\n" | |
7556 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7557 | "Only give warning message when limit is exceeded\n" |
7558 | "Force checking all received routes not only accepted\n") | |
e0701b79 | 7559 | { |
d62a17ae | 7560 | int idx_peer = 1; |
7561 | int idx_number = 3; | |
7562 | int idx_number_2 = 4; | |
9cbd06e0 DA |
7563 | int idx_force = 0; |
7564 | char *force = NULL; | |
7565 | ||
7566 | if (argv_find(argv, argc, "force", &idx_force)) | |
7567 | force = argv[idx_force]->arg; | |
7568 | ||
d62a17ae | 7569 | return peer_maximum_prefix_set_vty( |
7570 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7571 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL, force); |
0a486e5f | 7572 | } |
7573 | ||
d62a17ae | 7574 | ALIAS_HIDDEN( |
7575 | neighbor_maximum_prefix_threshold_warning, | |
7576 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
9cbd06e0 | 7577 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]", |
d62a17ae | 7578 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7579 | "Maximum number of prefix accept from this peer\n" | |
7580 | "maximum no. of prefix limit\n" | |
7581 | "Threshold value (%) at which to generate a warning msg\n" | |
9cbd06e0 DA |
7582 | "Only give warning message when limit is exceeded\n" |
7583 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7584 | |
0a486e5f | 7585 | DEFUN (neighbor_maximum_prefix_restart, |
7586 | neighbor_maximum_prefix_restart_cmd, | |
9cbd06e0 | 7587 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
0a486e5f | 7588 | NEIGHBOR_STR |
7589 | NEIGHBOR_ADDR_STR2 | |
7590 | "Maximum number of prefix accept from this peer\n" | |
7591 | "maximum no. of prefix limit\n" | |
7592 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7593 | "Restart interval in minutes\n" |
7594 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7595 | { |
d62a17ae | 7596 | int idx_peer = 1; |
7597 | int idx_number = 3; | |
7598 | int idx_number_2 = 5; | |
9cbd06e0 DA |
7599 | int idx_force = 0; |
7600 | char *force = NULL; | |
7601 | ||
7602 | if (argv_find(argv, argc, "force", &idx_force)) | |
7603 | force = argv[idx_force]->arg; | |
7604 | ||
d62a17ae | 7605 | return peer_maximum_prefix_set_vty( |
7606 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
9cbd06e0 | 7607 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg, force); |
0a486e5f | 7608 | } |
7609 | ||
d62a17ae | 7610 | ALIAS_HIDDEN( |
7611 | neighbor_maximum_prefix_restart, | |
7612 | neighbor_maximum_prefix_restart_hidden_cmd, | |
9cbd06e0 | 7613 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]", |
d62a17ae | 7614 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7615 | "Maximum number of prefix accept from this peer\n" | |
7616 | "maximum no. of prefix limit\n" | |
7617 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7618 | "Restart interval in minutes\n" |
7619 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7620 | |
0a486e5f | 7621 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
7622 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9cbd06e0 | 7623 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
0a486e5f | 7624 | NEIGHBOR_STR |
7625 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 7626 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 7627 | "maximum no. of prefix limit\n" |
7628 | "Threshold value (%) at which to generate a warning msg\n" | |
7629 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7630 | "Restart interval in minutes\n" |
7631 | "Force checking all received routes not only accepted\n") | |
0a486e5f | 7632 | { |
d62a17ae | 7633 | int idx_peer = 1; |
7634 | int idx_number = 3; | |
7635 | int idx_number_2 = 4; | |
7636 | int idx_number_3 = 6; | |
9cbd06e0 DA |
7637 | int idx_force = 0; |
7638 | char *force = NULL; | |
7639 | ||
7640 | if (argv_find(argv, argc, "force", &idx_force)) | |
7641 | force = argv[idx_force]->arg; | |
7642 | ||
d62a17ae | 7643 | return peer_maximum_prefix_set_vty( |
7644 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
7645 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
9cbd06e0 | 7646 | argv[idx_number_3]->arg, force); |
d62a17ae | 7647 | } |
7648 | ||
7649 | ALIAS_HIDDEN( | |
7650 | neighbor_maximum_prefix_threshold_restart, | |
7651 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
9cbd06e0 | 7652 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]", |
d62a17ae | 7653 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7654 | "Maximum number of prefixes to accept from this peer\n" | |
7655 | "maximum no. of prefix limit\n" | |
7656 | "Threshold value (%) at which to generate a warning msg\n" | |
7657 | "Restart bgp connection after limit is exceeded\n" | |
9cbd06e0 DA |
7658 | "Restart interval in minutes\n" |
7659 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7660 | |
718e3744 | 7661 | DEFUN (no_neighbor_maximum_prefix, |
7662 | no_neighbor_maximum_prefix_cmd, | |
9cbd06e0 | 7663 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
718e3744 | 7664 | NO_STR |
7665 | NEIGHBOR_STR | |
7666 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 7667 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
7668 | "maximum no. of prefix limit\n" |
7669 | "Threshold value (%) at which to generate a warning msg\n" | |
7670 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 7671 | "Restart interval in minutes\n" |
9cbd06e0 DA |
7672 | "Only give warning message when limit is exceeded\n" |
7673 | "Force checking all received routes not only accepted\n") | |
718e3744 | 7674 | { |
d62a17ae | 7675 | int idx_peer = 2; |
7676 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
7677 | bgp_node_afi(vty), | |
7678 | bgp_node_safi(vty)); | |
718e3744 | 7679 | } |
e52702f2 | 7680 | |
d62a17ae | 7681 | ALIAS_HIDDEN( |
7682 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
9cbd06e0 | 7683 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]", |
d62a17ae | 7684 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
7685 | "Maximum number of prefixes to accept from this peer\n" | |
7686 | "maximum no. of prefix limit\n" | |
7687 | "Threshold value (%) at which to generate a warning msg\n" | |
7688 | "Restart bgp connection after limit is exceeded\n" | |
7689 | "Restart interval in minutes\n" | |
9cbd06e0 DA |
7690 | "Only give warning message when limit is exceeded\n" |
7691 | "Force checking all received routes not only accepted\n") | |
596c17ba | 7692 | |
718e3744 | 7693 | |
718e3744 | 7694 | /* "neighbor allowas-in" */ |
7695 | DEFUN (neighbor_allowas_in, | |
7696 | neighbor_allowas_in_cmd, | |
fd8503f5 | 7697 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7698 | NEIGHBOR_STR |
7699 | NEIGHBOR_ADDR_STR2 | |
31500417 | 7700 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 7701 | "Number of occurrences of AS number\n" |
fd8503f5 | 7702 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7703 | { |
d62a17ae | 7704 | int idx_peer = 1; |
7705 | int idx_number_origin = 3; | |
7706 | int ret; | |
7707 | int origin = 0; | |
7708 | struct peer *peer; | |
7709 | int allow_num = 0; | |
7710 | ||
7711 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7712 | if (!peer) | |
7713 | return CMD_WARNING_CONFIG_FAILED; | |
7714 | ||
7715 | if (argc <= idx_number_origin) | |
7716 | allow_num = 3; | |
7717 | else { | |
7718 | if (argv[idx_number_origin]->type == WORD_TKN) | |
7719 | origin = 1; | |
7720 | else | |
7721 | allow_num = atoi(argv[idx_number_origin]->arg); | |
7722 | } | |
7723 | ||
7724 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7725 | allow_num, origin); | |
7726 | ||
7727 | return bgp_vty_return(vty, ret); | |
7728 | } | |
7729 | ||
7730 | ALIAS_HIDDEN( | |
7731 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7732 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7733 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7734 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7735 | "Number of occurrences of AS number\n" |
d62a17ae | 7736 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7737 | |
718e3744 | 7738 | DEFUN (no_neighbor_allowas_in, |
7739 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7740 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7741 | NO_STR |
7742 | NEIGHBOR_STR | |
7743 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7744 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7745 | "Number of occurrences of AS number\n" |
fd8503f5 | 7746 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7747 | { |
d62a17ae | 7748 | int idx_peer = 2; |
7749 | int ret; | |
7750 | struct peer *peer; | |
718e3744 | 7751 | |
d62a17ae | 7752 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7753 | if (!peer) | |
7754 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7755 | |
d62a17ae | 7756 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7757 | bgp_node_safi(vty)); | |
718e3744 | 7758 | |
d62a17ae | 7759 | return bgp_vty_return(vty, ret); |
718e3744 | 7760 | } |
6b0655a2 | 7761 | |
d62a17ae | 7762 | ALIAS_HIDDEN( |
7763 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7765 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7766 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7767 | "Number of occurrences of AS number\n" |
d62a17ae | 7768 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7769 | |
fa411a21 NH |
7770 | DEFUN (neighbor_ttl_security, |
7771 | neighbor_ttl_security_cmd, | |
7ebe625c | 7772 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 7773 | NEIGHBOR_STR |
7ebe625c | 7774 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7775 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
7776 | "Specify the maximum number of hops to the BGP peer\n" |
7777 | "Number of hops to BGP peer\n") | |
fa411a21 | 7778 | { |
d62a17ae | 7779 | int idx_peer = 1; |
7780 | int idx_number = 4; | |
7781 | struct peer *peer; | |
7782 | int gtsm_hops; | |
7783 | ||
7784 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7785 | if (!peer) | |
7786 | return CMD_WARNING_CONFIG_FAILED; | |
7787 | ||
7788 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
7789 | ||
7ebe625c QY |
7790 | /* |
7791 | * If 'neighbor swpX', then this is for directly connected peers, | |
7792 | * we should not accept a ttl-security hops value greater than 1. | |
7793 | */ | |
e2521429 | 7794 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
7795 | vty_out(vty, |
7796 | "%s is directly connected peer, hops cannot exceed 1\n", | |
7797 | argv[idx_peer]->arg); | |
7798 | return CMD_WARNING_CONFIG_FAILED; | |
7799 | } | |
7800 | ||
d62a17ae | 7801 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
7802 | } |
7803 | ||
7804 | DEFUN (no_neighbor_ttl_security, | |
7805 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 7806 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
7807 | NO_STR |
7808 | NEIGHBOR_STR | |
7ebe625c | 7809 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7810 | "BGP ttl-security parameters\n" |
3a2d747c QY |
7811 | "Specify the maximum number of hops to the BGP peer\n" |
7812 | "Number of hops to BGP peer\n") | |
fa411a21 | 7813 | { |
d62a17ae | 7814 | int idx_peer = 2; |
7815 | struct peer *peer; | |
fa411a21 | 7816 | |
d62a17ae | 7817 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7818 | if (!peer) | |
7819 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 7820 | |
d62a17ae | 7821 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 7822 | } |
6b0655a2 | 7823 | |
adbac85e DW |
7824 | DEFUN (neighbor_addpath_tx_all_paths, |
7825 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7826 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7827 | NEIGHBOR_STR |
7828 | NEIGHBOR_ADDR_STR2 | |
7829 | "Use addpath to advertise all paths to a neighbor\n") | |
7830 | { | |
d62a17ae | 7831 | int idx_peer = 1; |
7832 | struct peer *peer; | |
adbac85e | 7833 | |
d62a17ae | 7834 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7835 | if (!peer) | |
7836 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 7837 | |
dcc68b5e MS |
7838 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7839 | BGP_ADDPATH_ALL); | |
7840 | return CMD_SUCCESS; | |
adbac85e DW |
7841 | } |
7842 | ||
d62a17ae | 7843 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
7844 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
7845 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7846 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7847 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7848 | |
adbac85e DW |
7849 | DEFUN (no_neighbor_addpath_tx_all_paths, |
7850 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7851 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7852 | NO_STR |
7853 | NEIGHBOR_STR | |
7854 | NEIGHBOR_ADDR_STR2 | |
7855 | "Use addpath to advertise all paths to a neighbor\n") | |
7856 | { | |
d62a17ae | 7857 | int idx_peer = 2; |
dcc68b5e MS |
7858 | struct peer *peer; |
7859 | ||
7860 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7861 | if (!peer) | |
7862 | return CMD_WARNING_CONFIG_FAILED; | |
7863 | ||
7864 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7865 | != BGP_ADDPATH_ALL) { | |
7866 | vty_out(vty, | |
7867 | "%% Peer not currently configured to transmit all paths."); | |
7868 | return CMD_WARNING_CONFIG_FAILED; | |
7869 | } | |
7870 | ||
7871 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7872 | BGP_ADDPATH_NONE); | |
7873 | ||
7874 | return CMD_SUCCESS; | |
adbac85e DW |
7875 | } |
7876 | ||
d62a17ae | 7877 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
7878 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
7879 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7880 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7881 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7882 | |
06370dac DW |
7883 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7884 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7885 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7886 | NEIGHBOR_STR |
7887 | NEIGHBOR_ADDR_STR2 | |
7888 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7889 | { | |
d62a17ae | 7890 | int idx_peer = 1; |
7891 | struct peer *peer; | |
06370dac | 7892 | |
d62a17ae | 7893 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7894 | if (!peer) | |
7895 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7896 | |
dcc68b5e MS |
7897 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7898 | BGP_ADDPATH_BEST_PER_AS); | |
7899 | ||
7900 | return CMD_SUCCESS; | |
06370dac DW |
7901 | } |
7902 | ||
d62a17ae | 7903 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7904 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7905 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7906 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7907 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7908 | |
06370dac DW |
7909 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7910 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7911 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7912 | NO_STR |
7913 | NEIGHBOR_STR | |
7914 | NEIGHBOR_ADDR_STR2 | |
7915 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7916 | { | |
d62a17ae | 7917 | int idx_peer = 2; |
dcc68b5e MS |
7918 | struct peer *peer; |
7919 | ||
7920 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7921 | if (!peer) | |
7922 | return CMD_WARNING_CONFIG_FAILED; | |
7923 | ||
7924 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7925 | != BGP_ADDPATH_BEST_PER_AS) { | |
7926 | vty_out(vty, | |
7927 | "%% Peer not currently configured to transmit all best path per as."); | |
7928 | return CMD_WARNING_CONFIG_FAILED; | |
7929 | } | |
7930 | ||
7931 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7932 | BGP_ADDPATH_NONE); | |
7933 | ||
7934 | return CMD_SUCCESS; | |
06370dac DW |
7935 | } |
7936 | ||
d62a17ae | 7937 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7938 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7939 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7940 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7941 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7942 | |
2b31007c RZ |
7943 | DEFPY( |
7944 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7945 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7946 | NEIGHBOR_STR | |
7947 | NEIGHBOR_ADDR_STR2 | |
7948 | "Detect AS loops before sending to neighbor\n") | |
7949 | { | |
7950 | struct peer *peer; | |
7951 | ||
7952 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7953 | if (!peer) | |
7954 | return CMD_WARNING_CONFIG_FAILED; | |
7955 | ||
7956 | peer->as_path_loop_detection = true; | |
7957 | ||
7958 | return CMD_SUCCESS; | |
7959 | } | |
7960 | ||
7961 | DEFPY( | |
7962 | no_neighbor_aspath_loop_detection, | |
7963 | no_neighbor_aspath_loop_detection_cmd, | |
7964 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7965 | NO_STR | |
7966 | NEIGHBOR_STR | |
7967 | NEIGHBOR_ADDR_STR2 | |
7968 | "Detect AS loops before sending to neighbor\n") | |
7969 | { | |
7970 | struct peer *peer; | |
7971 | ||
7972 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7973 | if (!peer) | |
7974 | return CMD_WARNING_CONFIG_FAILED; | |
7975 | ||
7976 | peer->as_path_loop_detection = false; | |
7977 | ||
7978 | return CMD_SUCCESS; | |
7979 | } | |
7980 | ||
b9c7bc5a | 7981 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
c6423c31 | 7982 | struct ecommunity **list, bool is_rt6) |
ddb5b488 | 7983 | { |
b9c7bc5a PZ |
7984 | struct ecommunity *ecom = NULL; |
7985 | struct ecommunity *ecomadd; | |
ddb5b488 | 7986 | |
b9c7bc5a | 7987 | for (; argc; --argc, ++argv) { |
9a659715 PG |
7988 | if (is_rt6) |
7989 | ecomadd = ecommunity_str2com_ipv6(argv[0]->arg, | |
7990 | ECOMMUNITY_ROUTE_TARGET, | |
7991 | 0); | |
7992 | else | |
7993 | ecomadd = ecommunity_str2com(argv[0]->arg, | |
7994 | ECOMMUNITY_ROUTE_TARGET, | |
7995 | 0); | |
b9c7bc5a PZ |
7996 | if (!ecomadd) { |
7997 | vty_out(vty, "Malformed community-list value\n"); | |
7998 | if (ecom) | |
7999 | ecommunity_free(&ecom); | |
8000 | return CMD_WARNING_CONFIG_FAILED; | |
8001 | } | |
ddb5b488 | 8002 | |
b9c7bc5a PZ |
8003 | if (ecom) { |
8004 | ecommunity_merge(ecom, ecomadd); | |
8005 | ecommunity_free(&ecomadd); | |
8006 | } else { | |
8007 | ecom = ecomadd; | |
8008 | } | |
8009 | } | |
8010 | ||
8011 | if (*list) { | |
8012 | ecommunity_free(&*list); | |
ddb5b488 | 8013 | } |
b9c7bc5a PZ |
8014 | *list = ecom; |
8015 | ||
8016 | return CMD_SUCCESS; | |
ddb5b488 PZ |
8017 | } |
8018 | ||
0ca70ba5 DS |
8019 | /* |
8020 | * v2vimport is true if we are handling a `import vrf ...` command | |
8021 | */ | |
8022 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 8023 | { |
0ca70ba5 DS |
8024 | afi_t afi; |
8025 | ||
ddb5b488 | 8026 | switch (vty->node) { |
b9c7bc5a | 8027 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
8028 | afi = AFI_IP; |
8029 | break; | |
b9c7bc5a | 8030 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
8031 | afi = AFI_IP6; |
8032 | break; | |
ddb5b488 PZ |
8033 | default: |
8034 | vty_out(vty, | |
b9c7bc5a | 8035 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 8036 | return AFI_MAX; |
ddb5b488 | 8037 | } |
69b07479 | 8038 | |
0ca70ba5 DS |
8039 | if (!v2vimport) { |
8040 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8041 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
8042 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8043 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
8044 | vty_out(vty, | |
8045 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
8046 | return AFI_MAX; | |
8047 | } | |
8048 | } else { | |
8049 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8050 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
8051 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8052 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
8053 | vty_out(vty, | |
8054 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
8055 | return AFI_MAX; | |
8056 | } | |
8057 | } | |
8058 | return afi; | |
ddb5b488 PZ |
8059 | } |
8060 | ||
b9c7bc5a PZ |
8061 | DEFPY (af_rd_vpn_export, |
8062 | af_rd_vpn_export_cmd, | |
8063 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
8064 | NO_STR | |
ddb5b488 | 8065 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
8066 | "Between current address-family and vpn\n" |
8067 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8068 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
8069 | { | |
8070 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8071 | struct prefix_rd prd; | |
8072 | int ret; | |
ddb5b488 | 8073 | afi_t afi; |
b9c7bc5a | 8074 | int idx = 0; |
c6423c31 | 8075 | bool yes = true; |
ddb5b488 | 8076 | |
b9c7bc5a | 8077 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8078 | yes = false; |
b9c7bc5a PZ |
8079 | |
8080 | if (yes) { | |
8081 | ret = str2prefix_rd(rd_str, &prd); | |
8082 | if (!ret) { | |
8083 | vty_out(vty, "%% Malformed rd\n"); | |
8084 | return CMD_WARNING_CONFIG_FAILED; | |
8085 | } | |
ddb5b488 PZ |
8086 | } |
8087 | ||
0ca70ba5 | 8088 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8089 | if (afi == AFI_MAX) |
8090 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8091 | |
69b07479 DS |
8092 | /* |
8093 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8094 | */ | |
8095 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8096 | bgp_get_default(), bgp); | |
ddb5b488 | 8097 | |
69b07479 DS |
8098 | if (yes) { |
8099 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
8100 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8101 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
8102 | } else { | |
8103 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8104 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
8105 | } |
8106 | ||
69b07479 DS |
8107 | /* post-change: re-export vpn routes */ |
8108 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8109 | bgp_get_default(), bgp); | |
8110 | ||
ddb5b488 PZ |
8111 | return CMD_SUCCESS; |
8112 | } | |
8113 | ||
b9c7bc5a PZ |
8114 | ALIAS (af_rd_vpn_export, |
8115 | af_no_rd_vpn_export_cmd, | |
8116 | "no rd vpn export", | |
ddb5b488 | 8117 | NO_STR |
b9c7bc5a PZ |
8118 | "Specify route distinguisher\n" |
8119 | "Between current address-family and vpn\n" | |
8120 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8121 | |
b9c7bc5a PZ |
8122 | DEFPY (af_label_vpn_export, |
8123 | af_label_vpn_export_cmd, | |
e70e9f8e | 8124 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 8125 | NO_STR |
ddb5b488 | 8126 | "label value for VRF\n" |
b9c7bc5a PZ |
8127 | "Between current address-family and vpn\n" |
8128 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
8129 | "Label Value <0-1048575>\n" |
8130 | "Automatically assign a label\n") | |
ddb5b488 PZ |
8131 | { |
8132 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8133 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 8134 | afi_t afi; |
b9c7bc5a | 8135 | int idx = 0; |
c6423c31 | 8136 | bool yes = true; |
b9c7bc5a PZ |
8137 | |
8138 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8139 | yes = false; |
ddb5b488 | 8140 | |
21a16cc2 PZ |
8141 | /* If "no ...", squash trailing parameter */ |
8142 | if (!yes) | |
8143 | label_auto = NULL; | |
8144 | ||
e70e9f8e PZ |
8145 | if (yes) { |
8146 | if (!label_auto) | |
8147 | label = label_val; /* parser should force unsigned */ | |
8148 | } | |
ddb5b488 | 8149 | |
0ca70ba5 | 8150 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8151 | if (afi == AFI_MAX) |
8152 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 8153 | |
e70e9f8e | 8154 | |
69b07479 DS |
8155 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
8156 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
8157 | /* no change */ | |
8158 | return CMD_SUCCESS; | |
e70e9f8e | 8159 | |
69b07479 DS |
8160 | /* |
8161 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8162 | */ | |
8163 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8164 | bgp_get_default(), bgp); | |
8165 | ||
8166 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
8167 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
8168 | ||
8169 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
8170 | ||
8171 | /* | |
8172 | * label has previously been automatically | |
8173 | * assigned by labelpool: release it | |
8174 | * | |
8175 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
8176 | * means the automatic assignment is in flight | |
8177 | * and therefore the labelpool callback must | |
8178 | * detect that the auto label is not needed. | |
8179 | */ | |
8180 | ||
8181 | bgp_lp_release(LP_TYPE_VRF, | |
8182 | &bgp->vpn_policy[afi], | |
8183 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 8184 | } |
69b07479 DS |
8185 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
8186 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8187 | } | |
ddb5b488 | 8188 | |
69b07479 DS |
8189 | bgp->vpn_policy[afi].tovpn_label = label; |
8190 | if (label_auto) { | |
8191 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8192 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
8193 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
8194 | vpn_leak_label_callback); | |
ddb5b488 PZ |
8195 | } |
8196 | ||
69b07479 DS |
8197 | /* post-change: re-export vpn routes */ |
8198 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8199 | bgp_get_default(), bgp); | |
8200 | ||
ddb5b488 PZ |
8201 | return CMD_SUCCESS; |
8202 | } | |
8203 | ||
b9c7bc5a PZ |
8204 | ALIAS (af_label_vpn_export, |
8205 | af_no_label_vpn_export_cmd, | |
8206 | "no label vpn export", | |
8207 | NO_STR | |
8208 | "label value for VRF\n" | |
8209 | "Between current address-family and vpn\n" | |
8210 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 8211 | |
b9c7bc5a PZ |
8212 | DEFPY (af_nexthop_vpn_export, |
8213 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 8214 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 8215 | NO_STR |
ddb5b488 | 8216 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
8217 | "Between current address-family and vpn\n" |
8218 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8219 | "IPv4 prefix\n" |
8220 | "IPv6 prefix\n") | |
8221 | { | |
8222 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 8223 | afi_t afi; |
ddb5b488 PZ |
8224 | struct prefix p; |
8225 | ||
8c85ca28 QY |
8226 | if (!no) { |
8227 | if (!nexthop_su) { | |
8228 | vty_out(vty, "%% Nexthop required\n"); | |
8229 | return CMD_WARNING_CONFIG_FAILED; | |
8230 | } | |
8c85ca28 | 8231 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
8232 | return CMD_WARNING_CONFIG_FAILED; |
8233 | } | |
ddb5b488 | 8234 | |
0ca70ba5 | 8235 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8236 | if (afi == AFI_MAX) |
8237 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8238 | |
69b07479 DS |
8239 | /* |
8240 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
8241 | */ | |
8242 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8243 | bgp_get_default(), bgp); | |
ddb5b488 | 8244 | |
8c85ca28 | 8245 | if (!no) { |
69b07479 DS |
8246 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
8247 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
8248 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
8249 | } else { | |
8250 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
8251 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
8252 | } |
8253 | ||
69b07479 DS |
8254 | /* post-change: re-export vpn routes */ |
8255 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
8256 | bgp_get_default(), bgp); | |
8257 | ||
ddb5b488 PZ |
8258 | return CMD_SUCCESS; |
8259 | } | |
8260 | ||
b9c7bc5a | 8261 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 8262 | { |
b9c7bc5a PZ |
8263 | if (!strcmp(dstr, "import")) { |
8264 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8265 | } else if (!strcmp(dstr, "export")) { | |
8266 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8267 | } else if (!strcmp(dstr, "both")) { | |
8268 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
8269 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
8270 | } else { | |
8271 | vty_out(vty, "%% direction parse error\n"); | |
8272 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8273 | } |
ddb5b488 PZ |
8274 | return CMD_SUCCESS; |
8275 | } | |
8276 | ||
b9c7bc5a PZ |
8277 | DEFPY (af_rt_vpn_imexport, |
8278 | af_rt_vpn_imexport_cmd, | |
8279 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
8280 | NO_STR | |
8281 | "Specify route target list\n" | |
ddb5b488 | 8282 | "Specify route target list\n" |
b9c7bc5a PZ |
8283 | "Between current address-family and vpn\n" |
8284 | "For routes leaked from vpn to current address-family: match any\n" | |
8285 | "For routes leaked from current address-family to vpn: set\n" | |
8286 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
8287 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
8288 | { | |
8289 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8290 | int ret; | |
8291 | struct ecommunity *ecom = NULL; | |
8292 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8293 | vpn_policy_direction_t dir; |
8294 | afi_t afi; | |
8295 | int idx = 0; | |
c6423c31 | 8296 | bool yes = true; |
ddb5b488 | 8297 | |
b9c7bc5a | 8298 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8299 | yes = false; |
b9c7bc5a | 8300 | |
0ca70ba5 | 8301 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8302 | if (afi == AFI_MAX) |
8303 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8304 | |
b9c7bc5a | 8305 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8306 | if (ret != CMD_SUCCESS) |
8307 | return ret; | |
8308 | ||
b9c7bc5a PZ |
8309 | if (yes) { |
8310 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8311 | vty_out(vty, "%% Missing RTLIST\n"); | |
8312 | return CMD_WARNING_CONFIG_FAILED; | |
8313 | } | |
c6423c31 | 8314 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, false); |
b9c7bc5a PZ |
8315 | if (ret != CMD_SUCCESS) { |
8316 | return ret; | |
8317 | } | |
ddb5b488 PZ |
8318 | } |
8319 | ||
69b07479 DS |
8320 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8321 | if (!dodir[dir]) | |
ddb5b488 | 8322 | continue; |
ddb5b488 | 8323 | |
69b07479 | 8324 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8325 | |
69b07479 DS |
8326 | if (yes) { |
8327 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8328 | ecommunity_free( | |
8329 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8330 | bgp->vpn_policy[afi].rtlist[dir] = | |
8331 | ecommunity_dup(ecom); | |
8332 | } else { | |
8333 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
8334 | ecommunity_free( | |
8335 | &bgp->vpn_policy[afi].rtlist[dir]); | |
8336 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 8337 | } |
69b07479 DS |
8338 | |
8339 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 8340 | } |
69b07479 | 8341 | |
d555f3e9 PZ |
8342 | if (ecom) |
8343 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
8344 | |
8345 | return CMD_SUCCESS; | |
8346 | } | |
8347 | ||
b9c7bc5a PZ |
8348 | ALIAS (af_rt_vpn_imexport, |
8349 | af_no_rt_vpn_imexport_cmd, | |
8350 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
8351 | NO_STR |
8352 | "Specify route target list\n" | |
b9c7bc5a PZ |
8353 | "Specify route target list\n" |
8354 | "Between current address-family and vpn\n" | |
8355 | "For routes leaked from vpn to current address-family\n" | |
8356 | "For routes leaked from current address-family to vpn\n" | |
8357 | "both import and export\n") | |
8358 | ||
8359 | DEFPY (af_route_map_vpn_imexport, | |
8360 | af_route_map_vpn_imexport_cmd, | |
8361 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
8362 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
8363 | NO_STR | |
ddb5b488 | 8364 | "Specify route map\n" |
b9c7bc5a PZ |
8365 | "Between current address-family and vpn\n" |
8366 | "For routes leaked from vpn to current address-family\n" | |
8367 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
8368 | "name of route-map\n") |
8369 | { | |
8370 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8371 | int ret; | |
8372 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
8373 | vpn_policy_direction_t dir; |
8374 | afi_t afi; | |
ddb5b488 | 8375 | int idx = 0; |
c6423c31 | 8376 | bool yes = true; |
ddb5b488 | 8377 | |
b9c7bc5a | 8378 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8379 | yes = false; |
b9c7bc5a | 8380 | |
0ca70ba5 | 8381 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8382 | if (afi == AFI_MAX) |
8383 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 8384 | |
b9c7bc5a | 8385 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
8386 | if (ret != CMD_SUCCESS) |
8387 | return ret; | |
8388 | ||
69b07479 DS |
8389 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
8390 | if (!dodir[dir]) | |
ddb5b488 | 8391 | continue; |
ddb5b488 | 8392 | |
69b07479 | 8393 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 8394 | |
69b07479 DS |
8395 | if (yes) { |
8396 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8397 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8398 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8399 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
8400 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8401 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 8402 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
8403 | if (!bgp->vpn_policy[afi].rmap[dir]) |
8404 | return CMD_SUCCESS; | |
8405 | } else { | |
8406 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8407 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8408 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8409 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8410 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 8411 | } |
69b07479 DS |
8412 | |
8413 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
8414 | } |
8415 | ||
8416 | return CMD_SUCCESS; | |
8417 | } | |
8418 | ||
b9c7bc5a PZ |
8419 | ALIAS (af_route_map_vpn_imexport, |
8420 | af_no_route_map_vpn_imexport_cmd, | |
8421 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
8422 | NO_STR |
8423 | "Specify route map\n" | |
b9c7bc5a PZ |
8424 | "Between current address-family and vpn\n" |
8425 | "For routes leaked from vpn to current address-family\n" | |
8426 | "For routes leaked from current address-family to vpn\n") | |
8427 | ||
bb4f6190 | 8428 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 8429 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
8430 | "Import routes from another VRF\n" |
8431 | "Vrf routes being filtered\n" | |
8432 | "Specify route map\n" | |
8433 | "name of route-map\n") | |
8434 | { | |
8435 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
8436 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
8437 | afi_t afi; | |
bb4f6190 DS |
8438 | struct bgp *bgp_default; |
8439 | ||
0ca70ba5 | 8440 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
8441 | if (afi == AFI_MAX) |
8442 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
8443 | |
8444 | bgp_default = bgp_get_default(); | |
8445 | if (!bgp_default) { | |
8446 | int32_t ret; | |
8447 | as_t as = bgp->as; | |
8448 | ||
8449 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8450 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8451 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
8452 | |
8453 | if (ret) { | |
8454 | vty_out(vty, | |
8455 | "VRF default is not configured as a bgp instance\n"); | |
8456 | return CMD_WARNING; | |
8457 | } | |
8458 | } | |
8459 | ||
69b07479 | 8460 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 8461 | |
ae6a6fb4 DS |
8462 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
8463 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8464 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8465 | bgp->vpn_policy[afi].rmap_name[dir] = | |
8466 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
8467 | bgp->vpn_policy[afi].rmap[dir] = | |
8468 | route_map_lookup_warn_noexist(vty, rmap_str); | |
8469 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
8470 | return CMD_SUCCESS; | |
8471 | ||
8472 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8473 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 8474 | |
69b07479 DS |
8475 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8476 | ||
bb4f6190 DS |
8477 | return CMD_SUCCESS; |
8478 | } | |
8479 | ||
ae6a6fb4 DS |
8480 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
8481 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
8482 | NO_STR |
8483 | "Import routes from another VRF\n" | |
8484 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
8485 | "Specify route map\n" |
8486 | "name of route-map\n") | |
8487 | { | |
8488 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8489 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8490 | afi_t afi; | |
8491 | ||
8492 | afi = vpn_policy_getafi(vty, bgp, true); | |
8493 | if (afi == AFI_MAX) | |
8494 | return CMD_WARNING_CONFIG_FAILED; | |
8495 | ||
8496 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8497 | ||
8498 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
8499 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
8500 | bgp->vpn_policy[afi].rmap_name[dir]); | |
8501 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
8502 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
8503 | ||
8504 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
8505 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
8506 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
8507 | ||
8508 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
8509 | ||
8510 | return CMD_SUCCESS; | |
8511 | } | |
bb4f6190 | 8512 | |
4d1b335c DA |
8513 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
8514 | "[no] import vrf VIEWVRFNAME$import_name", | |
8515 | NO_STR | |
8516 | "Import routes from another VRF\n" | |
8517 | "VRF to import from\n" | |
8518 | "The name of the VRF\n") | |
12a844a5 DS |
8519 | { |
8520 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8521 | struct listnode *node; | |
79ef8664 DS |
8522 | struct bgp *vrf_bgp, *bgp_default; |
8523 | int32_t ret = 0; | |
8524 | as_t as = bgp->as; | |
12a844a5 DS |
8525 | bool remove = false; |
8526 | int32_t idx = 0; | |
8527 | char *vname; | |
a8dadcf6 | 8528 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
8529 | safi_t safi; |
8530 | afi_t afi; | |
8531 | ||
867f0cca | 8532 | if (import_name == NULL) { |
8533 | vty_out(vty, "%% Missing import name\n"); | |
8534 | return CMD_WARNING; | |
8535 | } | |
8536 | ||
ae6a6fb4 DS |
8537 | if (strcmp(import_name, "route-map") == 0) { |
8538 | vty_out(vty, "%% Must include route-map name\n"); | |
8539 | return CMD_WARNING; | |
8540 | } | |
8541 | ||
12a844a5 DS |
8542 | if (argv_find(argv, argc, "no", &idx)) |
8543 | remove = true; | |
8544 | ||
0ca70ba5 DS |
8545 | afi = vpn_policy_getafi(vty, bgp, true); |
8546 | if (afi == AFI_MAX) | |
8547 | return CMD_WARNING_CONFIG_FAILED; | |
8548 | ||
12a844a5 DS |
8549 | safi = bgp_node_safi(vty); |
8550 | ||
25679caa | 8551 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 8552 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
8553 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
8554 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
8555 | remove ? "unimport" : "import", import_name); | |
8556 | return CMD_WARNING; | |
8557 | } | |
8558 | ||
79ef8664 DS |
8559 | bgp_default = bgp_get_default(); |
8560 | if (!bgp_default) { | |
8561 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
8562 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
8563 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
8564 | |
8565 | if (ret) { | |
8566 | vty_out(vty, | |
8567 | "VRF default is not configured as a bgp instance\n"); | |
8568 | return CMD_WARNING; | |
8569 | } | |
8570 | } | |
8571 | ||
12a844a5 DS |
8572 | vrf_bgp = bgp_lookup_by_name(import_name); |
8573 | if (!vrf_bgp) { | |
5742e42b | 8574 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
8575 | vrf_bgp = bgp_default; |
8576 | else | |
0fb8d6e6 | 8577 | /* Auto-create assuming the same AS */ |
5d5393b9 | 8578 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 8579 | |
6e2c7fe6 | 8580 | if (ret) { |
020a3f60 DS |
8581 | vty_out(vty, |
8582 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
8583 | import_name); |
8584 | return CMD_WARNING; | |
8585 | } | |
12a844a5 DS |
8586 | } |
8587 | ||
12a844a5 | 8588 | if (remove) { |
44338987 | 8589 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 8590 | } else { |
44338987 | 8591 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
8592 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
8593 | vname)) { | |
8594 | if (strcmp(vname, import_name) == 0) | |
8595 | return CMD_WARNING; | |
8596 | } | |
8597 | ||
44338987 | 8598 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
8599 | } |
8600 | ||
8601 | return CMD_SUCCESS; | |
8602 | } | |
8603 | ||
b9c7bc5a PZ |
8604 | /* This command is valid only in a bgp vrf instance or the default instance */ |
8605 | DEFPY (bgp_imexport_vpn, | |
8606 | bgp_imexport_vpn_cmd, | |
8607 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
8608 | NO_STR |
8609 | "Import routes to this address-family\n" | |
8610 | "Export routes from this address-family\n" | |
8611 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
8612 | { |
8613 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 8614 | int previous_state; |
ddb5b488 | 8615 | afi_t afi; |
b9c7bc5a | 8616 | safi_t safi; |
ddb5b488 | 8617 | int idx = 0; |
c6423c31 | 8618 | bool yes = true; |
b9c7bc5a PZ |
8619 | int flag; |
8620 | vpn_policy_direction_t dir; | |
ddb5b488 | 8621 | |
b9c7bc5a | 8622 | if (argv_find(argv, argc, "no", &idx)) |
c6423c31 | 8623 | yes = false; |
ddb5b488 | 8624 | |
b9c7bc5a PZ |
8625 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
8626 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 8627 | |
b9c7bc5a PZ |
8628 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
8629 | return CMD_WARNING_CONFIG_FAILED; | |
8630 | } | |
ddb5b488 | 8631 | |
b9c7bc5a PZ |
8632 | afi = bgp_node_afi(vty); |
8633 | safi = bgp_node_safi(vty); | |
8634 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
8635 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
8636 | return CMD_WARNING_CONFIG_FAILED; | |
8637 | } | |
ddb5b488 | 8638 | |
b9c7bc5a PZ |
8639 | if (!strcmp(direction_str, "import")) { |
8640 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
8641 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
8642 | } else if (!strcmp(direction_str, "export")) { | |
8643 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
8644 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
8645 | } else { | |
8646 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
8647 | return CMD_WARNING_CONFIG_FAILED; | |
8648 | } | |
8649 | ||
8650 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 8651 | |
b9c7bc5a PZ |
8652 | if (yes) { |
8653 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
8654 | if (!previous_state) { | |
8655 | /* trigger export current vrf */ | |
ddb5b488 PZ |
8656 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
8657 | } | |
b9c7bc5a PZ |
8658 | } else { |
8659 | if (previous_state) { | |
8660 | /* trigger un-export current vrf */ | |
8661 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
8662 | } | |
8663 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
8664 | } |
8665 | ||
8666 | return CMD_SUCCESS; | |
8667 | } | |
8668 | ||
301ad80a PG |
8669 | DEFPY (af_routetarget_import, |
8670 | af_routetarget_import_cmd, | |
9a659715 | 8671 | "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...", |
301ad80a PG |
8672 | NO_STR |
8673 | "Specify route target list\n" | |
8674 | "Specify route target list\n" | |
9a659715 PG |
8675 | "Specify route target list\n" |
8676 | "Specify route target list\n" | |
301ad80a PG |
8677 | "Flow-spec redirect type route target\n" |
8678 | "Import routes to this address-family\n" | |
9a659715 | 8679 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n") |
301ad80a PG |
8680 | { |
8681 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
8682 | int ret; | |
8683 | struct ecommunity *ecom = NULL; | |
301ad80a | 8684 | afi_t afi; |
9a659715 | 8685 | int idx = 0, idx_unused = 0; |
c6423c31 PG |
8686 | bool yes = true; |
8687 | bool rt6 = false; | |
301ad80a PG |
8688 | |
8689 | if (argv_find(argv, argc, "no", &idx)) | |
c6423c31 | 8690 | yes = false; |
301ad80a | 8691 | |
9a659715 PG |
8692 | if (argv_find(argv, argc, "rt6", &idx_unused) || |
8693 | argv_find(argv, argc, "route-target6", &idx_unused)) | |
c6423c31 | 8694 | rt6 = true; |
301ad80a | 8695 | |
0ca70ba5 | 8696 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
8697 | if (afi == AFI_MAX) |
8698 | return CMD_WARNING_CONFIG_FAILED; | |
8699 | ||
9a659715 PG |
8700 | if (rt6 && afi != AFI_IP6) |
8701 | return CMD_WARNING_CONFIG_FAILED; | |
8702 | ||
301ad80a PG |
8703 | if (yes) { |
8704 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
8705 | vty_out(vty, "%% Missing RTLIST\n"); | |
8706 | return CMD_WARNING_CONFIG_FAILED; | |
8707 | } | |
9a659715 | 8708 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom, rt6); |
301ad80a PG |
8709 | if (ret != CMD_SUCCESS) |
8710 | return ret; | |
8711 | } | |
69b07479 DS |
8712 | |
8713 | if (yes) { | |
8714 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8715 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8716 | .import_redirect_rtlist); |
69b07479 DS |
8717 | bgp->vpn_policy[afi].import_redirect_rtlist = |
8718 | ecommunity_dup(ecom); | |
8719 | } else { | |
8720 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
8721 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 8722 | .import_redirect_rtlist); |
69b07479 | 8723 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 8724 | } |
69b07479 | 8725 | |
301ad80a PG |
8726 | if (ecom) |
8727 | ecommunity_free(&ecom); | |
8728 | ||
8729 | return CMD_SUCCESS; | |
8730 | } | |
8731 | ||
505e5056 | 8732 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 8733 | address_family_ipv4_safi_cmd, |
8734 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8735 | "Enter Address Family command mode\n" | |
8736 | "Address Family\n" | |
8737 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 8738 | { |
f51bae9c | 8739 | |
d62a17ae | 8740 | if (argc == 3) { |
2131d5cf | 8741 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8742 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8743 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8744 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8745 | && safi != SAFI_EVPN) { |
31947174 MK |
8746 | vty_out(vty, |
8747 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8748 | return CMD_WARNING_CONFIG_FAILED; |
8749 | } | |
d62a17ae | 8750 | vty->node = bgp_node_type(AFI_IP, safi); |
8751 | } else | |
8752 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 8753 | |
d62a17ae | 8754 | return CMD_SUCCESS; |
718e3744 | 8755 | } |
8756 | ||
505e5056 | 8757 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 8758 | address_family_ipv6_safi_cmd, |
8759 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8760 | "Enter Address Family command mode\n" | |
8761 | "Address Family\n" | |
8762 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 8763 | { |
d62a17ae | 8764 | if (argc == 3) { |
2131d5cf | 8765 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8766 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8767 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8768 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8769 | && safi != SAFI_EVPN) { |
31947174 MK |
8770 | vty_out(vty, |
8771 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8772 | return CMD_WARNING_CONFIG_FAILED; |
8773 | } | |
d62a17ae | 8774 | vty->node = bgp_node_type(AFI_IP6, safi); |
8775 | } else | |
8776 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 8777 | |
d62a17ae | 8778 | return CMD_SUCCESS; |
25ffbdc1 | 8779 | } |
718e3744 | 8780 | |
d6902373 | 8781 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 8782 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 8783 | address_family_vpnv4_cmd, |
8334fd5a | 8784 | "address-family vpnv4 [unicast]", |
718e3744 | 8785 | "Enter Address Family command mode\n" |
8c3deaae | 8786 | "Address Family\n" |
3a2d747c | 8787 | "Address Family modifier\n") |
718e3744 | 8788 | { |
d62a17ae | 8789 | vty->node = BGP_VPNV4_NODE; |
8790 | return CMD_SUCCESS; | |
718e3744 | 8791 | } |
8792 | ||
505e5056 | 8793 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 8794 | address_family_vpnv6_cmd, |
8334fd5a | 8795 | "address-family vpnv6 [unicast]", |
8ecd3266 | 8796 | "Enter Address Family command mode\n" |
8c3deaae | 8797 | "Address Family\n" |
3a2d747c | 8798 | "Address Family modifier\n") |
8ecd3266 | 8799 | { |
d62a17ae | 8800 | vty->node = BGP_VPNV6_NODE; |
8801 | return CMD_SUCCESS; | |
8ecd3266 | 8802 | } |
64e4a6c5 | 8803 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 8804 | |
505e5056 | 8805 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 8806 | address_family_evpn_cmd, |
7111c1a0 | 8807 | "address-family l2vpn evpn", |
4e0b7b6d | 8808 | "Enter Address Family command mode\n" |
7111c1a0 QY |
8809 | "Address Family\n" |
8810 | "Address Family modifier\n") | |
4e0b7b6d | 8811 | { |
2131d5cf | 8812 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8813 | vty->node = BGP_EVPN_NODE; |
8814 | return CMD_SUCCESS; | |
4e0b7b6d PG |
8815 | } |
8816 | ||
505e5056 | 8817 | DEFUN_NOSH (exit_address_family, |
718e3744 | 8818 | exit_address_family_cmd, |
8819 | "exit-address-family", | |
8820 | "Exit from Address Family configuration mode\n") | |
8821 | { | |
d62a17ae | 8822 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
8823 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
8824 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
8825 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
8826 | || vty->node == BGP_EVPN_NODE |
8827 | || vty->node == BGP_FLOWSPECV4_NODE | |
8828 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 8829 | vty->node = BGP_NODE; |
8830 | return CMD_SUCCESS; | |
718e3744 | 8831 | } |
6b0655a2 | 8832 | |
8ad7271d | 8833 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 8834 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
8835 | const char *ip_str, afi_t afi, safi_t safi, | |
8836 | struct prefix_rd *prd) | |
8837 | { | |
8838 | int ret; | |
8839 | struct prefix match; | |
9bcb3eef DS |
8840 | struct bgp_dest *dest; |
8841 | struct bgp_dest *rm; | |
d62a17ae | 8842 | struct bgp *bgp; |
8843 | struct bgp_table *table; | |
8844 | struct bgp_table *rib; | |
8845 | ||
8846 | /* BGP structure lookup. */ | |
8847 | if (view_name) { | |
8848 | bgp = bgp_lookup_by_name(view_name); | |
8849 | if (bgp == NULL) { | |
8850 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
8851 | view_name); | |
8852 | return CMD_WARNING; | |
8853 | } | |
8854 | } else { | |
8855 | bgp = bgp_get_default(); | |
8856 | if (bgp == NULL) { | |
8857 | vty_out(vty, "%% No BGP process is configured\n"); | |
8858 | return CMD_WARNING; | |
8859 | } | |
8860 | } | |
8861 | ||
8862 | /* Check IP address argument. */ | |
8863 | ret = str2prefix(ip_str, &match); | |
8864 | if (!ret) { | |
8865 | vty_out(vty, "%% address is malformed\n"); | |
8866 | return CMD_WARNING; | |
8867 | } | |
8868 | ||
8869 | match.family = afi2family(afi); | |
8870 | rib = bgp->rib[afi][safi]; | |
8871 | ||
8872 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
8873 | for (dest = bgp_table_top(rib); dest; |
8874 | dest = bgp_route_next(dest)) { | |
8875 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8876 | |
9bcb3eef | 8877 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 8878 | continue; |
8879 | ||
9bcb3eef | 8880 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
8881 | if (table == NULL) |
8882 | continue; | |
8883 | ||
8884 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
8885 | const struct prefix *rm_p = | |
9bcb3eef | 8886 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
8887 | |
8888 | if (rm_p->prefixlen == match.prefixlen) { | |
8889 | SET_FLAG(rm->flags, | |
8890 | BGP_NODE_USER_CLEAR); | |
8891 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 8892 | } |
9bcb3eef | 8893 | bgp_dest_unlock_node(rm); |
d62a17ae | 8894 | } |
8895 | } | |
8896 | } else { | |
9bcb3eef DS |
8897 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
8898 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8899 | |
9bcb3eef DS |
8900 | if (dest_p->prefixlen == match.prefixlen) { |
8901 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
8902 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 8903 | } |
9bcb3eef | 8904 | bgp_dest_unlock_node(dest); |
d62a17ae | 8905 | } |
8906 | } | |
8907 | ||
8908 | return CMD_SUCCESS; | |
8ad7271d DS |
8909 | } |
8910 | ||
b09b5ae0 | 8911 | /* one clear bgp command to rule them all */ |
718e3744 | 8912 | DEFUN (clear_ip_bgp_all, |
8913 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8914 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 8915 | CLEAR_STR |
8916 | IP_STR | |
8917 | BGP_STR | |
838758ac | 8918 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8919 | BGP_AFI_HELP_STR |
fd5e7b70 | 8920 | "Address Family\n" |
510afcd6 | 8921 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8922 | "Address Family modifier\n" |
b09b5ae0 | 8923 | "Clear all peers\n" |
453c92f6 | 8924 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8925 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8926 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8927 | "Clear peers with the AS number\n" |
8928 | "Clear all external peers\n" | |
718e3744 | 8929 | "Clear all members of peer-group\n" |
b09b5ae0 | 8930 | "BGP peer-group name\n" |
b09b5ae0 DW |
8931 | BGP_SOFT_STR |
8932 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8933 | BGP_SOFT_OUT_STR |
8934 | BGP_SOFT_IN_STR | |
8935 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8936 | BGP_SOFT_OUT_STR) |
718e3744 | 8937 | { |
d62a17ae | 8938 | char *vrf = NULL; |
8939 | ||
dc912615 DS |
8940 | afi_t afi = AFI_UNSPEC; |
8941 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8942 | enum clear_sort clr_sort = clear_peer; |
8943 | enum bgp_clear_type clr_type; | |
8944 | char *clr_arg = NULL; | |
8945 | ||
8946 | int idx = 0; | |
ff8a8a7a CS |
8947 | char errmsg[BUFSIZ] = {'\0'}; |
8948 | int ret; | |
d62a17ae | 8949 | |
8950 | /* clear [ip] bgp */ | |
8951 | if (argv_find(argv, argc, "ip", &idx)) | |
8952 | afi = AFI_IP; | |
8953 | ||
9a8bdf1c PG |
8954 | /* [<vrf> VIEWVRFNAME] */ |
8955 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8956 | vrf = argv[idx + 1]->arg; | |
8957 | idx += 2; | |
8958 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8959 | vrf = NULL; | |
8960 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8961 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8962 | vrf = argv[idx + 1]->arg; |
8963 | idx += 2; | |
8964 | } | |
d62a17ae | 8965 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8966 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8967 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8968 | ||
d7b9898c | 8969 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8970 | if (argv_find(argv, argc, "*", &idx)) { |
8971 | clr_sort = clear_all; | |
8972 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8973 | clr_sort = clear_peer; | |
8974 | clr_arg = argv[idx]->arg; | |
8975 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8976 | clr_sort = clear_peer; | |
8977 | clr_arg = argv[idx]->arg; | |
8978 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8979 | clr_sort = clear_group; | |
8980 | idx++; | |
8981 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8982 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8983 | clr_sort = clear_peer; |
8984 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8985 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8986 | clr_sort = clear_peer; | |
8987 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8988 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8989 | clr_sort = clear_as; | |
8990 | clr_arg = argv[idx]->arg; | |
8991 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8992 | clr_sort = clear_external; | |
8993 | } | |
8994 | ||
8995 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8996 | if (argv_find(argv, argc, "soft", &idx)) { | |
8997 | if (argv_find(argv, argc, "in", &idx) | |
8998 | || argv_find(argv, argc, "out", &idx)) | |
8999 | clr_type = strmatch(argv[idx]->text, "in") | |
9000 | ? BGP_CLEAR_SOFT_IN | |
9001 | : BGP_CLEAR_SOFT_OUT; | |
9002 | else | |
9003 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
9004 | } else if (argv_find(argv, argc, "in", &idx)) { | |
9005 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
9006 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
9007 | : BGP_CLEAR_SOFT_IN; | |
9008 | } else if (argv_find(argv, argc, "out", &idx)) { | |
9009 | clr_type = BGP_CLEAR_SOFT_OUT; | |
9010 | } else | |
9011 | clr_type = BGP_CLEAR_SOFT_NONE; | |
9012 | ||
ff8a8a7a CS |
9013 | ret = bgp_clear_vty(vrf, afi, safi, clr_sort, clr_type, clr_arg, errmsg, |
9014 | sizeof(errmsg)); | |
9015 | if (ret != NB_OK) | |
9016 | vty_out(vty, "Error description: %s\n", errmsg); | |
9017 | ||
9018 | return ret; | |
838758ac | 9019 | } |
01080f7c | 9020 | |
8ad7271d DS |
9021 | DEFUN (clear_ip_bgp_prefix, |
9022 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 9023 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
9024 | CLEAR_STR |
9025 | IP_STR | |
9026 | BGP_STR | |
838758ac | 9027 | BGP_INSTANCE_HELP_STR |
8ad7271d | 9028 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9029 | "IPv4 prefix\n") |
8ad7271d | 9030 | { |
d62a17ae | 9031 | char *vrf = NULL; |
9032 | char *prefix = NULL; | |
8ad7271d | 9033 | |
d62a17ae | 9034 | int idx = 0; |
01080f7c | 9035 | |
d62a17ae | 9036 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
9037 | if (argv_find(argv, argc, "vrf", &idx)) { |
9038 | vrf = argv[idx + 1]->arg; | |
9039 | idx += 2; | |
9040 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9041 | vrf = NULL; | |
9042 | } else if (argv_find(argv, argc, "view", &idx)) { | |
9043 | /* [<view> VIEWVRFNAME] */ | |
9044 | vrf = argv[idx + 1]->arg; | |
9045 | idx += 2; | |
9046 | } | |
0c7b1b01 | 9047 | |
d62a17ae | 9048 | prefix = argv[argc - 1]->arg; |
8ad7271d | 9049 | |
d62a17ae | 9050 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 9051 | } |
8ad7271d | 9052 | |
b09b5ae0 DW |
9053 | DEFUN (clear_bgp_ipv6_safi_prefix, |
9054 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 9055 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9056 | CLEAR_STR |
3a2d747c | 9057 | IP_STR |
718e3744 | 9058 | BGP_STR |
8c3deaae | 9059 | "Address Family\n" |
46f296b4 | 9060 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9061 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9062 | "IPv6 prefix\n") |
718e3744 | 9063 | { |
9b475e76 PG |
9064 | int idx_safi = 0; |
9065 | int idx_ipv6_prefix = 0; | |
9066 | safi_t safi = SAFI_UNICAST; | |
9067 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9068 | argv[idx_ipv6_prefix]->arg : NULL; | |
9069 | ||
9070 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 9071 | return bgp_clear_prefix( |
9b475e76 PG |
9072 | vty, NULL, prefix, AFI_IP6, |
9073 | safi, NULL); | |
838758ac | 9074 | } |
01080f7c | 9075 | |
b09b5ae0 DW |
9076 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
9077 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 9078 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 9079 | CLEAR_STR |
3a2d747c | 9080 | IP_STR |
718e3744 | 9081 | BGP_STR |
838758ac | 9082 | BGP_INSTANCE_HELP_STR |
8c3deaae | 9083 | "Address Family\n" |
46f296b4 | 9084 | BGP_SAFI_HELP_STR |
b09b5ae0 | 9085 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 9086 | "IPv6 prefix\n") |
718e3744 | 9087 | { |
9b475e76 | 9088 | int idx_safi = 0; |
9a8bdf1c | 9089 | int idx_vrfview = 0; |
9b475e76 PG |
9090 | int idx_ipv6_prefix = 0; |
9091 | safi_t safi = SAFI_UNICAST; | |
9092 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
9093 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 9094 | char *vrfview = NULL; |
9b475e76 | 9095 | |
9a8bdf1c PG |
9096 | /* [<view|vrf> VIEWVRFNAME] */ |
9097 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
9098 | vrfview = argv[idx_vrfview + 1]->arg; | |
9099 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
9100 | vrfview = NULL; | |
9101 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
9102 | /* [<view> VIEWVRFNAME] */ | |
9103 | vrfview = argv[idx_vrfview + 1]->arg; | |
9104 | } | |
9b475e76 PG |
9105 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
9106 | ||
d62a17ae | 9107 | return bgp_clear_prefix( |
9b475e76 PG |
9108 | vty, vrfview, prefix, |
9109 | AFI_IP6, safi, NULL); | |
718e3744 | 9110 | } |
9111 | ||
b09b5ae0 DW |
9112 | DEFUN (show_bgp_views, |
9113 | show_bgp_views_cmd, | |
d6e3c605 | 9114 | "show [ip] bgp views", |
b09b5ae0 | 9115 | SHOW_STR |
d6e3c605 | 9116 | IP_STR |
01080f7c | 9117 | BGP_STR |
b09b5ae0 | 9118 | "Show the defined BGP views\n") |
01080f7c | 9119 | { |
d62a17ae | 9120 | struct list *inst = bm->bgp; |
9121 | struct listnode *node; | |
9122 | struct bgp *bgp; | |
01080f7c | 9123 | |
d62a17ae | 9124 | vty_out(vty, "Defined BGP views:\n"); |
9125 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9126 | /* Skip VRFs. */ | |
9127 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
9128 | continue; | |
9129 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
9130 | bgp->as); | |
9131 | } | |
e52702f2 | 9132 | |
d62a17ae | 9133 | return CMD_SUCCESS; |
e0081f70 ML |
9134 | } |
9135 | ||
8386ac43 | 9136 | DEFUN (show_bgp_vrfs, |
9137 | show_bgp_vrfs_cmd, | |
d6e3c605 | 9138 | "show [ip] bgp vrfs [json]", |
8386ac43 | 9139 | SHOW_STR |
d6e3c605 | 9140 | IP_STR |
8386ac43 | 9141 | BGP_STR |
9142 | "Show BGP VRFs\n" | |
9973d184 | 9143 | JSON_STR) |
8386ac43 | 9144 | { |
fe1dc5a3 | 9145 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 9146 | struct list *inst = bm->bgp; |
9147 | struct listnode *node; | |
9148 | struct bgp *bgp; | |
9f049418 | 9149 | bool uj = use_json(argc, argv); |
d62a17ae | 9150 | json_object *json = NULL; |
9151 | json_object *json_vrfs = NULL; | |
9152 | int count = 0; | |
d62a17ae | 9153 | |
d62a17ae | 9154 | if (uj) { |
9155 | json = json_object_new_object(); | |
9156 | json_vrfs = json_object_new_object(); | |
9157 | } | |
9158 | ||
9159 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
9160 | const char *name, *type; | |
9161 | struct peer *peer; | |
7fe96307 | 9162 | struct listnode *node2, *nnode2; |
d62a17ae | 9163 | int peers_cfg, peers_estb; |
9164 | json_object *json_vrf = NULL; | |
d62a17ae | 9165 | |
9166 | /* Skip Views. */ | |
9167 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
9168 | continue; | |
9169 | ||
9170 | count++; | |
efb4077a | 9171 | if (!uj && count == 1) { |
fe1dc5a3 | 9172 | vty_out(vty, |
efb4077a | 9173 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 9174 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
9175 | "#PeersEstb", "Name"); |
9176 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
9177 | "L3-VNI", "RouterMAC", "Interface"); | |
9178 | } | |
d62a17ae | 9179 | |
9180 | peers_cfg = peers_estb = 0; | |
9181 | if (uj) | |
9182 | json_vrf = json_object_new_object(); | |
9183 | ||
9184 | ||
7fe96307 | 9185 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 9186 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
9187 | continue; | |
9188 | peers_cfg++; | |
9189 | if (peer->status == Established) | |
9190 | peers_estb++; | |
9191 | } | |
9192 | ||
9193 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 9194 | name = VRF_DEFAULT_NAME; |
d62a17ae | 9195 | type = "DFLT"; |
9196 | } else { | |
9197 | name = bgp->name; | |
9198 | type = "VRF"; | |
9199 | } | |
9200 | ||
a8bf7d9c | 9201 | |
d62a17ae | 9202 | if (uj) { |
a4d82a8a PZ |
9203 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9204 | ? -1 | |
9205 | : (int64_t)bgp->vrf_id; | |
23d0a753 DA |
9206 | char buf[BUFSIZ] = {0}; |
9207 | ||
d62a17ae | 9208 | json_object_string_add(json_vrf, "type", type); |
9209 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
9210 | json_object_string_add(json_vrf, "routerId", | |
23d0a753 DA |
9211 | inet_ntop(AF_INET, |
9212 | &bgp->router_id, buf, | |
9213 | sizeof(buf))); | |
d62a17ae | 9214 | json_object_int_add(json_vrf, "numConfiguredPeers", |
9215 | peers_cfg); | |
9216 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
9217 | peers_estb); | |
9218 | ||
fe1dc5a3 | 9219 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
9220 | json_object_string_add( |
9221 | json_vrf, "rmac", | |
9222 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
9223 | json_object_string_add(json_vrf, "interface", |
9224 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9225 | bgp->vrf_id)); | |
d62a17ae | 9226 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 9227 | } else { |
23d0a753 | 9228 | vty_out(vty, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n", |
a4d82a8a PZ |
9229 | type, |
9230 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
9231 | : (int)bgp->vrf_id, | |
23d0a753 | 9232 | &bgp->router_id, peers_cfg, peers_estb, name); |
efb4077a CS |
9233 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", |
9234 | bgp->l3vni, | |
9235 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
9236 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
9237 | bgp->vrf_id)); | |
9238 | } | |
d62a17ae | 9239 | } |
9240 | ||
9241 | if (uj) { | |
9242 | json_object_object_add(json, "vrfs", json_vrfs); | |
9243 | ||
9244 | json_object_int_add(json, "totalVrfs", count); | |
9245 | ||
996c9314 LB |
9246 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9247 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9248 | json_object_free(json); |
9249 | } else { | |
9250 | if (count) | |
9251 | vty_out(vty, | |
9252 | "\nTotal number of VRFs (including default): %d\n", | |
9253 | count); | |
9254 | } | |
9255 | ||
9256 | return CMD_SUCCESS; | |
8386ac43 | 9257 | } |
9258 | ||
48ecf8f5 DS |
9259 | DEFUN (show_bgp_mac_hash, |
9260 | show_bgp_mac_hash_cmd, | |
9261 | "show bgp mac hash", | |
9262 | SHOW_STR | |
9263 | BGP_STR | |
9264 | "Mac Address\n" | |
9265 | "Mac Address database\n") | |
9266 | { | |
9267 | bgp_mac_dump_table(vty); | |
9268 | ||
9269 | return CMD_SUCCESS; | |
9270 | } | |
acf71666 | 9271 | |
e3b78da8 | 9272 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 9273 | { |
0291c246 | 9274 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 9275 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 9276 | |
23d0a753 | 9277 | vty_out(vty, "addr: %pI4, count: %d\n", &tip->addr, tip->refcnt); |
acf71666 MK |
9278 | } |
9279 | ||
9280 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
9281 | { | |
9282 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 9283 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
9284 | |
9285 | vty_out(vty, "Tunnel-ip database:\n"); | |
9286 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 9287 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
9288 | vty); |
9289 | } | |
9290 | ||
15c81ca4 DS |
9291 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
9292 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
9293 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
9294 | "martian next-hops\n" |
9295 | "martian next-hop database\n") | |
acf71666 | 9296 | { |
0291c246 | 9297 | struct bgp *bgp = NULL; |
15c81ca4 | 9298 | int idx = 0; |
9a8bdf1c PG |
9299 | char *name = NULL; |
9300 | ||
9301 | /* [<vrf> VIEWVRFNAME] */ | |
9302 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9303 | name = argv[idx + 1]->arg; | |
9304 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
9305 | name = NULL; | |
9306 | } else if (argv_find(argv, argc, "view", &idx)) | |
9307 | /* [<view> VIEWVRFNAME] */ | |
9308 | name = argv[idx + 1]->arg; | |
9309 | if (name) | |
9310 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
9311 | else |
9312 | bgp = bgp_get_default(); | |
acf71666 | 9313 | |
acf71666 MK |
9314 | if (!bgp) { |
9315 | vty_out(vty, "%% No BGP process is configured\n"); | |
9316 | return CMD_WARNING; | |
9317 | } | |
9318 | bgp_show_martian_nexthops(vty, bgp); | |
9319 | ||
9320 | return CMD_SUCCESS; | |
9321 | } | |
9322 | ||
f412b39a | 9323 | DEFUN (show_bgp_memory, |
4bf6a362 | 9324 | show_bgp_memory_cmd, |
7fa12b13 | 9325 | "show [ip] bgp memory", |
4bf6a362 | 9326 | SHOW_STR |
3a2d747c | 9327 | IP_STR |
4bf6a362 PJ |
9328 | BGP_STR |
9329 | "Global BGP memory statistics\n") | |
9330 | { | |
d62a17ae | 9331 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
9332 | unsigned long count; | |
9333 | ||
9334 | /* RIB related usage stats */ | |
9335 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
9336 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
9337 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 9338 | count * sizeof(struct bgp_dest))); |
d62a17ae | 9339 | |
9340 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
9341 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
9342 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 9343 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 9344 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
9345 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
9346 | count, | |
4b7e6066 DS |
9347 | mtype_memstr( |
9348 | memstrbuf, sizeof(memstrbuf), | |
9349 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 9350 | |
9351 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
9352 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
9353 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9354 | count * sizeof(struct bgp_static))); | |
9355 | ||
9356 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
9357 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
9358 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9359 | count * sizeof(struct bpacket))); | |
9360 | ||
9361 | /* Adj-In/Out */ | |
9362 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
9363 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
9364 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9365 | count * sizeof(struct bgp_adj_in))); | |
9366 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
9367 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
9368 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9369 | count * sizeof(struct bgp_adj_out))); | |
9370 | ||
9371 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
9372 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
9373 | count, | |
9374 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9375 | count * sizeof(struct bgp_nexthop_cache))); | |
9376 | ||
9377 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
9378 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
9379 | count, | |
9380 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9381 | count * sizeof(struct bgp_damp_info))); | |
9382 | ||
9383 | /* Attributes */ | |
9384 | count = attr_count(); | |
9385 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
9386 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9387 | count * sizeof(struct attr))); | |
9388 | ||
9389 | if ((count = attr_unknown_count())) | |
9390 | vty_out(vty, "%ld unknown attributes\n", count); | |
9391 | ||
9392 | /* AS_PATH attributes */ | |
9393 | count = aspath_count(); | |
9394 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
9395 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9396 | count * sizeof(struct aspath))); | |
9397 | ||
9398 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
9399 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
9400 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9401 | count * sizeof(struct assegment))); | |
9402 | ||
9403 | /* Other attributes */ | |
9404 | if ((count = community_count())) | |
9405 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9406 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9407 | count * sizeof(struct community))); | |
d62a17ae | 9408 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
9409 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
9410 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9411 | count * sizeof(struct ecommunity))); | |
d62a17ae | 9412 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
9413 | vty_out(vty, | |
9414 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
9415 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9416 | count * sizeof(struct lcommunity))); | |
d62a17ae | 9417 | |
9418 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
9419 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
9420 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9421 | count * sizeof(struct cluster_list))); | |
9422 | ||
9423 | /* Peer related usage */ | |
9424 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
9425 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
9426 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9427 | count * sizeof(struct peer))); | |
9428 | ||
9429 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
9430 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
9431 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9432 | count * sizeof(struct peer_group))); | |
9433 | ||
9434 | /* Other */ | |
d62a17ae | 9435 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
9436 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
9437 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
9438 | count * sizeof(regex_t))); | |
d62a17ae | 9439 | return CMD_SUCCESS; |
4bf6a362 | 9440 | } |
fee0f4c6 | 9441 | |
57a9c8a8 DS |
9442 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
9443 | { | |
9444 | json_object *bestpath = json_object_new_object(); | |
9445 | ||
892fedb6 | 9446 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
9447 | json_object_string_add(bestpath, "asPath", "ignore"); |
9448 | ||
892fedb6 | 9449 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
9450 | json_object_string_add(bestpath, "asPath", "confed"); |
9451 | ||
892fedb6 DA |
9452 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
9453 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 9454 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9455 | "as-set"); |
9456 | else | |
a4d82a8a | 9457 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
9458 | "true"); |
9459 | } else | |
a4d82a8a | 9460 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 9461 | |
892fedb6 | 9462 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 9463 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
9464 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
9465 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
9466 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 9467 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 9468 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
9469 | json_object_string_add(bestpath, "med", |
9470 | "missing-as-worst"); | |
9471 | else | |
9472 | json_object_string_add(bestpath, "med", "true"); | |
9473 | } | |
9474 | ||
9475 | json_object_object_add(json, "bestPath", bestpath); | |
9476 | } | |
9477 | ||
3577f1c5 DD |
9478 | /* Print the error code/subcode for why the peer is down */ |
9479 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
9480 | json_object *json_peer, bool use_json) | |
9481 | { | |
9482 | const char *code_str; | |
9483 | const char *subcode_str; | |
9484 | ||
9485 | if (use_json) { | |
9486 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9487 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9488 | char errorcodesubcode_hexstr[5]; | |
9489 | char errorcodesubcode_str[256]; | |
9490 | ||
9491 | code_str = bgp_notify_code_str(peer->notify.code); | |
9492 | subcode_str = bgp_notify_subcode_str( | |
9493 | peer->notify.code, | |
9494 | peer->notify.subcode); | |
9495 | ||
772270f3 QY |
9496 | snprintf(errorcodesubcode_hexstr, |
9497 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
9498 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
9499 | json_object_string_add(json_peer, |
9500 | "lastErrorCodeSubcode", | |
9501 | errorcodesubcode_hexstr); | |
9502 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9503 | code_str, subcode_str); | |
9504 | json_object_string_add(json_peer, | |
9505 | "lastNotificationReason", | |
9506 | errorcodesubcode_str); | |
9507 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9508 | && peer->notify.code == BGP_NOTIFY_CEASE | |
9509 | && (peer->notify.subcode | |
9510 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9511 | || peer->notify.subcode | |
9512 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9513 | && peer->notify.length) { | |
9514 | char msgbuf[1024]; | |
9515 | const char *msg_str; | |
9516 | ||
9517 | msg_str = bgp_notify_admin_message( | |
9518 | msgbuf, sizeof(msgbuf), | |
9519 | (uint8_t *)peer->notify.data, | |
9520 | peer->notify.length); | |
9521 | if (msg_str) | |
9522 | json_object_string_add( | |
9523 | json_peer, | |
9524 | "lastShutdownDescription", | |
9525 | msg_str); | |
9526 | } | |
9527 | ||
c258527b | 9528 | } |
3577f1c5 DD |
9529 | json_object_string_add(json_peer, "lastResetDueTo", |
9530 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
9531 | json_object_int_add(json_peer, "lastResetCode", |
9532 | peer->last_reset); | |
3577f1c5 DD |
9533 | } else { |
9534 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9535 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9536 | code_str = bgp_notify_code_str(peer->notify.code); | |
9537 | subcode_str = | |
9538 | bgp_notify_subcode_str(peer->notify.code, | |
9539 | peer->notify.subcode); | |
9540 | vty_out(vty, " Notification %s (%s%s)\n", | |
9541 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
9542 | ? "sent" | |
9543 | : "received", | |
9544 | code_str, subcode_str); | |
9545 | } else { | |
e91c24c8 | 9546 | vty_out(vty, " %s\n", |
3577f1c5 DD |
9547 | peer_down_str[(int)peer->last_reset]); |
9548 | } | |
9549 | } | |
9550 | } | |
9551 | ||
9552 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
9553 | safi_t safi) | |
9554 | { | |
9555 | return ((peer->status != Established) || | |
9556 | !peer->afc_recv[afi][safi]); | |
9557 | } | |
9558 | ||
9559 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
9560 | struct peer *peer, json_object *json_peer, | |
9561 | int max_neighbor_width, bool use_json) | |
9562 | { | |
9563 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
9564 | int len; | |
9565 | ||
9566 | if (use_json) { | |
9567 | if (peer_dynamic_neighbor(peer)) | |
9568 | json_object_boolean_true_add(json_peer, | |
9569 | "dynamicPeer"); | |
9570 | if (peer->hostname) | |
9571 | json_object_string_add(json_peer, "hostname", | |
9572 | peer->hostname); | |
9573 | ||
9574 | if (peer->domainname) | |
9575 | json_object_string_add(json_peer, "domainname", | |
9576 | peer->domainname); | |
9577 | json_object_int_add(json_peer, "connectionsEstablished", | |
9578 | peer->established); | |
9579 | json_object_int_add(json_peer, "connectionsDropped", | |
9580 | peer->dropped); | |
9581 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
9582 | use_json, json_peer); | |
9583 | if (peer->status == Established) | |
9584 | json_object_string_add(json_peer, "lastResetDueTo", | |
9585 | "AFI/SAFI Not Negotiated"); | |
9586 | else | |
9587 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
9588 | } else { | |
9589 | dn_flag[1] = '\0'; | |
9590 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
9591 | if (peer->hostname | |
892fedb6 | 9592 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
9593 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
9594 | peer->hostname, peer->host); | |
9595 | else | |
9596 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
9597 | ||
9598 | /* pad the neighbor column with spaces */ | |
9599 | if (len < max_neighbor_width) | |
9600 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9601 | " "); | |
e91c24c8 | 9602 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
9603 | peer->dropped, |
9604 | peer_uptime(peer->uptime, timebuf, | |
9605 | BGP_UPTIME_LEN, 0, NULL)); | |
9606 | if (peer->status == Established) | |
9607 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
9608 | else | |
9609 | bgp_show_peer_reset(vty, peer, NULL, | |
9610 | false); | |
9611 | } | |
9612 | } | |
c258527b | 9613 | |
3577f1c5 | 9614 | |
718e3744 | 9615 | /* Show BGP peer's summary information. */ |
d62a17ae | 9616 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
10b49f14 DA |
9617 | bool show_failed, bool show_established, |
9618 | bool use_json) | |
d62a17ae | 9619 | { |
9620 | struct peer *peer; | |
9621 | struct listnode *node, *nnode; | |
9622 | unsigned int count = 0, dn_count = 0; | |
9623 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
9624 | char neighbor_buf[VTY_BUFSIZ]; | |
9625 | int neighbor_col_default_width = 16; | |
3577f1c5 | 9626 | int len, failed_count = 0; |
d62a17ae | 9627 | int max_neighbor_width = 0; |
9628 | int pfx_rcd_safi; | |
3c13337d | 9629 | json_object *json = NULL; |
d62a17ae | 9630 | json_object *json_peer = NULL; |
9631 | json_object *json_peers = NULL; | |
50e05855 | 9632 | struct peer_af *paf; |
d3ada366 | 9633 | struct bgp_filter *filter; |
d62a17ae | 9634 | |
9635 | /* labeled-unicast routes are installed in the unicast table so in order | |
9636 | * to | |
9637 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
9638 | */ | |
3577f1c5 | 9639 | |
d62a17ae | 9640 | if (safi == SAFI_LABELED_UNICAST) |
9641 | pfx_rcd_safi = SAFI_UNICAST; | |
9642 | else | |
9643 | pfx_rcd_safi = safi; | |
9644 | ||
9645 | if (use_json) { | |
3c13337d | 9646 | json = json_object_new_object(); |
d62a17ae | 9647 | json_peers = json_object_new_object(); |
3577f1c5 DD |
9648 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
9649 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9650 | continue; | |
9651 | ||
9652 | if (peer->afc[afi][safi]) { | |
9653 | /* See if we have at least a single failed peer */ | |
9654 | if (bgp_has_peer_failed(peer, afi, safi)) | |
9655 | failed_count++; | |
9656 | count++; | |
9657 | } | |
9658 | if (peer_dynamic_neighbor(peer)) | |
9659 | dn_count++; | |
9660 | } | |
c258527b | 9661 | |
d62a17ae | 9662 | } else { |
9663 | /* Loop over all neighbors that will be displayed to determine | |
9664 | * how many | |
9665 | * characters are needed for the Neighbor column | |
9666 | */ | |
9667 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9668 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9669 | continue; | |
9670 | ||
9671 | if (peer->afc[afi][safi]) { | |
9672 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9673 | if (peer_dynamic_neighbor(peer)) | |
9674 | dn_flag[0] = '*'; | |
9675 | ||
9676 | if (peer->hostname | |
892fedb6 DA |
9677 | && CHECK_FLAG(bgp->flags, |
9678 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
9679 | snprintf(neighbor_buf, |
9680 | sizeof(neighbor_buf), | |
9681 | "%s%s(%s) ", dn_flag, | |
9682 | peer->hostname, peer->host); | |
d62a17ae | 9683 | else |
772270f3 QY |
9684 | snprintf(neighbor_buf, |
9685 | sizeof(neighbor_buf), "%s%s ", | |
9686 | dn_flag, peer->host); | |
d62a17ae | 9687 | |
9688 | len = strlen(neighbor_buf); | |
9689 | ||
9690 | if (len > max_neighbor_width) | |
9691 | max_neighbor_width = len; | |
c258527b | 9692 | |
3577f1c5 DD |
9693 | /* See if we have at least a single failed peer */ |
9694 | if (bgp_has_peer_failed(peer, afi, safi)) | |
9695 | failed_count++; | |
9696 | count++; | |
d62a17ae | 9697 | } |
9698 | } | |
f933309e | 9699 | |
d62a17ae | 9700 | /* Originally we displayed the Neighbor column as 16 |
9701 | * characters wide so make that the default | |
9702 | */ | |
9703 | if (max_neighbor_width < neighbor_col_default_width) | |
9704 | max_neighbor_width = neighbor_col_default_width; | |
9705 | } | |
f933309e | 9706 | |
3577f1c5 DD |
9707 | if (show_failed && !failed_count) { |
9708 | if (use_json) { | |
9709 | json_object_int_add(json, "failedPeersCount", 0); | |
9710 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 9711 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
9712 | |
9713 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
9714 | json, JSON_C_TO_STRING_PRETTY)); | |
9715 | json_object_free(json); | |
9716 | } else { | |
9717 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
9718 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9719 | } | |
9720 | return CMD_SUCCESS; | |
9721 | } | |
c258527b | 9722 | |
3577f1c5 | 9723 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 9724 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
9725 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9726 | continue; | |
9727 | ||
ea47320b DL |
9728 | if (!peer->afc[afi][safi]) |
9729 | continue; | |
d62a17ae | 9730 | |
ea47320b DL |
9731 | if (!count) { |
9732 | unsigned long ents; | |
9733 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 9734 | int64_t vrf_id_ui; |
d62a17ae | 9735 | |
a4d82a8a PZ |
9736 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
9737 | ? -1 | |
9738 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
9739 | |
9740 | /* Usage summary and header */ | |
9741 | if (use_json) { | |
23d0a753 DA |
9742 | char buf[BUFSIZ] = {0}; |
9743 | ||
ea47320b DL |
9744 | json_object_string_add( |
9745 | json, "routerId", | |
23d0a753 DA |
9746 | inet_ntop(AF_INET, &bgp->router_id, buf, |
9747 | sizeof(buf))); | |
60466a63 QY |
9748 | json_object_int_add(json, "as", bgp->as); |
9749 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
9750 | json_object_string_add( |
9751 | json, "vrfName", | |
9752 | (bgp->inst_type | |
9753 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9754 | ? VRF_DEFAULT_NAME |
ea47320b DL |
9755 | : bgp->name); |
9756 | } else { | |
9757 | vty_out(vty, | |
23d0a753 DA |
9758 | "BGP router identifier %pI4, local AS number %u vrf-id %d", |
9759 | &bgp->router_id, bgp->as, | |
a4d82a8a PZ |
9760 | bgp->vrf_id == VRF_UNKNOWN |
9761 | ? -1 | |
9762 | : (int)bgp->vrf_id); | |
ea47320b DL |
9763 | vty_out(vty, "\n"); |
9764 | } | |
d62a17ae | 9765 | |
ea47320b | 9766 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 9767 | if (use_json) { |
ea47320b | 9768 | json_object_int_add( |
60466a63 | 9769 | json, "updateDelayLimit", |
ea47320b | 9770 | bgp->v_update_delay); |
d62a17ae | 9771 | |
ea47320b DL |
9772 | if (bgp->v_update_delay |
9773 | != bgp->v_establish_wait) | |
d62a17ae | 9774 | json_object_int_add( |
9775 | json, | |
ea47320b DL |
9776 | "updateDelayEstablishWait", |
9777 | bgp->v_establish_wait); | |
d62a17ae | 9778 | |
60466a63 | 9779 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9780 | json_object_string_add( |
9781 | json, | |
9782 | "updateDelayFirstNeighbor", | |
9783 | bgp->update_delay_begin_time); | |
9784 | json_object_boolean_true_add( | |
9785 | json, | |
9786 | "updateDelayInProgress"); | |
9787 | } else { | |
9788 | if (bgp->update_delay_over) { | |
d62a17ae | 9789 | json_object_string_add( |
9790 | json, | |
9791 | "updateDelayFirstNeighbor", | |
9792 | bgp->update_delay_begin_time); | |
ea47320b | 9793 | json_object_string_add( |
d62a17ae | 9794 | json, |
ea47320b DL |
9795 | "updateDelayBestpathResumed", |
9796 | bgp->update_delay_end_time); | |
9797 | json_object_string_add( | |
d62a17ae | 9798 | json, |
ea47320b DL |
9799 | "updateDelayZebraUpdateResume", |
9800 | bgp->update_delay_zebra_resume_time); | |
9801 | json_object_string_add( | |
9802 | json, | |
9803 | "updateDelayPeerUpdateResume", | |
9804 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9805 | } |
ea47320b DL |
9806 | } |
9807 | } else { | |
9808 | vty_out(vty, | |
9809 | "Read-only mode update-delay limit: %d seconds\n", | |
9810 | bgp->v_update_delay); | |
9811 | if (bgp->v_update_delay | |
9812 | != bgp->v_establish_wait) | |
d62a17ae | 9813 | vty_out(vty, |
ea47320b DL |
9814 | " Establish wait: %d seconds\n", |
9815 | bgp->v_establish_wait); | |
d62a17ae | 9816 | |
60466a63 | 9817 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9818 | vty_out(vty, |
9819 | " First neighbor established: %s\n", | |
9820 | bgp->update_delay_begin_time); | |
9821 | vty_out(vty, | |
9822 | " Delay in progress\n"); | |
9823 | } else { | |
9824 | if (bgp->update_delay_over) { | |
d62a17ae | 9825 | vty_out(vty, |
9826 | " First neighbor established: %s\n", | |
9827 | bgp->update_delay_begin_time); | |
9828 | vty_out(vty, | |
ea47320b DL |
9829 | " Best-paths resumed: %s\n", |
9830 | bgp->update_delay_end_time); | |
9831 | vty_out(vty, | |
9832 | " zebra update resumed: %s\n", | |
9833 | bgp->update_delay_zebra_resume_time); | |
9834 | vty_out(vty, | |
9835 | " peers update resumed: %s\n", | |
9836 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9837 | } |
9838 | } | |
9839 | } | |
ea47320b | 9840 | } |
d62a17ae | 9841 | |
ea47320b DL |
9842 | if (use_json) { |
9843 | if (bgp_maxmed_onstartup_configured(bgp) | |
9844 | && bgp->maxmed_active) | |
9845 | json_object_boolean_true_add( | |
60466a63 | 9846 | json, "maxMedOnStartup"); |
ea47320b DL |
9847 | if (bgp->v_maxmed_admin) |
9848 | json_object_boolean_true_add( | |
60466a63 | 9849 | json, "maxMedAdministrative"); |
d62a17ae | 9850 | |
ea47320b DL |
9851 | json_object_int_add( |
9852 | json, "tableVersion", | |
60466a63 | 9853 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 9854 | |
60466a63 QY |
9855 | ents = bgp_table_count(bgp->rib[afi][safi]); |
9856 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
9857 | json_object_int_add( |
9858 | json, "ribMemory", | |
9bcb3eef | 9859 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 9860 | |
210ec2a0 | 9861 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
9862 | json_object_int_add(json, "peerCount", ents); |
9863 | json_object_int_add(json, "peerMemory", | |
9864 | ents * sizeof(struct peer)); | |
d62a17ae | 9865 | |
ea47320b DL |
9866 | if ((ents = listcount(bgp->group))) { |
9867 | json_object_int_add( | |
60466a63 | 9868 | json, "peerGroupCount", ents); |
ea47320b DL |
9869 | json_object_int_add( |
9870 | json, "peerGroupMemory", | |
996c9314 LB |
9871 | ents * sizeof(struct |
9872 | peer_group)); | |
ea47320b | 9873 | } |
d62a17ae | 9874 | |
ea47320b DL |
9875 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9876 | BGP_CONFIG_DAMPENING)) | |
9877 | json_object_boolean_true_add( | |
60466a63 | 9878 | json, "dampeningEnabled"); |
ea47320b DL |
9879 | } else { |
9880 | if (bgp_maxmed_onstartup_configured(bgp) | |
9881 | && bgp->maxmed_active) | |
d62a17ae | 9882 | vty_out(vty, |
ea47320b DL |
9883 | "Max-med on-startup active\n"); |
9884 | if (bgp->v_maxmed_admin) | |
d62a17ae | 9885 | vty_out(vty, |
ea47320b | 9886 | "Max-med administrative active\n"); |
d62a17ae | 9887 | |
60466a63 QY |
9888 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
9889 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 9890 | |
60466a63 | 9891 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
9892 | vty_out(vty, |
9893 | "RIB entries %ld, using %s of memory\n", | |
9894 | ents, | |
9bcb3eef DS |
9895 | mtype_memstr( |
9896 | memstrbuf, sizeof(memstrbuf), | |
9897 | ents | |
9898 | * sizeof(struct | |
9899 | bgp_dest))); | |
ea47320b DL |
9900 | |
9901 | /* Peer related usage */ | |
210ec2a0 | 9902 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 9903 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
9904 | ents, |
9905 | mtype_memstr( | |
60466a63 QY |
9906 | memstrbuf, sizeof(memstrbuf), |
9907 | ents * sizeof(struct peer))); | |
ea47320b DL |
9908 | |
9909 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 9910 | vty_out(vty, |
ea47320b | 9911 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 9912 | ents, |
9913 | mtype_memstr( | |
9914 | memstrbuf, | |
9915 | sizeof(memstrbuf), | |
996c9314 LB |
9916 | ents * sizeof(struct |
9917 | peer_group))); | |
d62a17ae | 9918 | |
ea47320b DL |
9919 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9920 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 9921 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 9922 | vty_out(vty, "\n"); |
d62a17ae | 9923 | |
ea47320b DL |
9924 | /* Subtract 8 here because 'Neighbor' is |
9925 | * 8 characters */ | |
9926 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
9927 | vty_out(vty, "%*s", max_neighbor_width - 8, |
9928 | " "); | |
3577f1c5 DD |
9929 | if (show_failed) |
9930 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9931 | else | |
9932 | vty_out(vty, | |
db92d226 | 9933 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 9934 | } |
ea47320b | 9935 | } |
d62a17ae | 9936 | |
d55811cc | 9937 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 9938 | filter = &peer->filter[afi][safi]; |
db92d226 | 9939 | |
ea47320b | 9940 | count++; |
3577f1c5 DD |
9941 | /* Works for both failed & successful cases */ |
9942 | if (peer_dynamic_neighbor(peer)) | |
9943 | dn_count++; | |
d62a17ae | 9944 | |
ea47320b | 9945 | if (use_json) { |
3577f1c5 DD |
9946 | json_peer = NULL; |
9947 | ||
9948 | if (show_failed && | |
9949 | bgp_has_peer_failed(peer, afi, safi)) { | |
9950 | json_peer = json_object_new_object(); | |
9951 | bgp_show_failed_summary(vty, bgp, peer, | |
9952 | json_peer, 0, use_json); | |
9953 | } else if (!show_failed) { | |
10b49f14 DA |
9954 | if (show_established |
9955 | && bgp_has_peer_failed(peer, afi, safi)) | |
9956 | continue; | |
9957 | ||
3577f1c5 DD |
9958 | json_peer = json_object_new_object(); |
9959 | if (peer_dynamic_neighbor(peer)) { | |
9960 | json_object_boolean_true_add(json_peer, | |
9961 | "dynamicPeer"); | |
9962 | } | |
d62a17ae | 9963 | |
3577f1c5 DD |
9964 | if (peer->hostname) |
9965 | json_object_string_add(json_peer, "hostname", | |
9966 | peer->hostname); | |
9967 | ||
9968 | if (peer->domainname) | |
9969 | json_object_string_add(json_peer, "domainname", | |
9970 | peer->domainname); | |
9971 | ||
9972 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9973 | json_object_int_add(json_peer, "version", 4); | |
9974 | json_object_int_add(json_peer, "msgRcvd", | |
9975 | PEER_TOTAL_RX(peer)); | |
9976 | json_object_int_add(json_peer, "msgSent", | |
9977 | PEER_TOTAL_TX(peer)); | |
9978 | ||
43aa5965 QY |
9979 | atomic_size_t outq_count, inq_count; |
9980 | outq_count = atomic_load_explicit( | |
9981 | &peer->obuf->count, | |
9982 | memory_order_relaxed); | |
9983 | inq_count = atomic_load_explicit( | |
9984 | &peer->ibuf->count, | |
9985 | memory_order_relaxed); | |
9986 | ||
3577f1c5 DD |
9987 | json_object_int_add(json_peer, "tableVersion", |
9988 | peer->version[afi][safi]); | |
9989 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
9990 | outq_count); |
9991 | json_object_int_add(json_peer, "inq", | |
9992 | inq_count); | |
3577f1c5 DD |
9993 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
9994 | use_json, json_peer); | |
9995 | ||
3577f1c5 DD |
9996 | json_object_int_add(json_peer, "pfxRcd", |
9997 | peer->pcount[afi][pfx_rcd_safi]); | |
9998 | ||
3577f1c5 DD |
9999 | if (paf && PAF_SUBGRP(paf)) |
10000 | json_object_int_add(json_peer, | |
10001 | "pfxSnt", | |
10002 | (PAF_SUBGRP(paf))->scount); | |
cb9196e7 | 10003 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
736b68f3 DS |
10004 | || CHECK_FLAG(peer->bgp->flags, |
10005 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10006 | json_object_string_add(json_peer, "state", |
10007 | "Idle (Admin)"); | |
10008 | else if (peer->afc_recv[afi][safi]) | |
10009 | json_object_string_add( | |
10010 | json_peer, "state", | |
10011 | lookup_msg(bgp_status_msg, peer->status, | |
10012 | NULL)); | |
10013 | else if (CHECK_FLAG(peer->sflags, | |
10014 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10015 | json_object_string_add(json_peer, "state", | |
10016 | "Idle (PfxCt)"); | |
10017 | else | |
10018 | json_object_string_add( | |
10019 | json_peer, "state", | |
10020 | lookup_msg(bgp_status_msg, peer->status, | |
10021 | NULL)); | |
200116db DD |
10022 | json_object_int_add(json_peer, "connectionsEstablished", |
10023 | peer->established); | |
10024 | json_object_int_add(json_peer, "connectionsDropped", | |
10025 | peer->dropped); | |
b4e9dcba | 10026 | } |
3577f1c5 DD |
10027 | /* Avoid creating empty peer dicts in JSON */ |
10028 | if (json_peer == NULL) | |
10029 | continue; | |
ea47320b DL |
10030 | |
10031 | if (peer->conf_if) | |
60466a63 | 10032 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
10033 | "interface"); |
10034 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
10035 | json_object_string_add(json_peer, "idType", |
10036 | "ipv4"); | |
ea47320b | 10037 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
10038 | json_object_string_add(json_peer, "idType", |
10039 | "ipv6"); | |
ea47320b DL |
10040 | json_object_object_add(json_peers, peer->host, |
10041 | json_peer); | |
10042 | } else { | |
3577f1c5 DD |
10043 | if (show_failed && |
10044 | bgp_has_peer_failed(peer, afi, safi)) { | |
10045 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
10046 | max_neighbor_width, | |
10047 | use_json); | |
10048 | } else if (!show_failed) { | |
10b49f14 DA |
10049 | if (show_established |
10050 | && bgp_has_peer_failed(peer, afi, safi)) | |
10051 | continue; | |
10052 | ||
3577f1c5 DD |
10053 | memset(dn_flag, '\0', sizeof(dn_flag)); |
10054 | if (peer_dynamic_neighbor(peer)) { | |
10055 | dn_flag[0] = '*'; | |
10056 | } | |
d62a17ae | 10057 | |
3577f1c5 | 10058 | if (peer->hostname |
892fedb6 DA |
10059 | && CHECK_FLAG(bgp->flags, |
10060 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 10061 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
10062 | peer->hostname, |
10063 | peer->host); | |
d62a17ae | 10064 | else |
3577f1c5 DD |
10065 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
10066 | ||
10067 | /* pad the neighbor column with spaces */ | |
10068 | if (len < max_neighbor_width) | |
10069 | vty_out(vty, "%*s", max_neighbor_width - len, | |
10070 | " "); | |
10071 | ||
43aa5965 QY |
10072 | atomic_size_t outq_count, inq_count; |
10073 | outq_count = atomic_load_explicit( | |
10074 | &peer->obuf->count, | |
10075 | memory_order_relaxed); | |
10076 | inq_count = atomic_load_explicit( | |
10077 | &peer->ibuf->count, | |
10078 | memory_order_relaxed); | |
10079 | ||
566bdaf6 | 10080 | vty_out(vty, |
6cde4b45 | 10081 | "4 %10u %9u %9u %8" PRIu64" %4zu %4zu %8s", |
3577f1c5 | 10082 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 10083 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
10084 | peer->version[afi][safi], inq_count, |
10085 | outq_count, | |
3577f1c5 DD |
10086 | peer_uptime(peer->uptime, timebuf, |
10087 | BGP_UPTIME_LEN, 0, NULL)); | |
10088 | ||
db92d226 | 10089 | if (peer->status == Established) { |
d3ada366 DA |
10090 | if (peer->afc_recv[afi][safi]) { |
10091 | if (CHECK_FLAG( | |
10092 | bgp->flags, | |
10093 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10094 | && !bgp_inbound_policy_exists( | |
10095 | peer, filter)) | |
10096 | vty_out(vty, " %12s", | |
10097 | "(Policy)"); | |
10098 | else | |
10099 | vty_out(vty, | |
6cde4b45 | 10100 | " %12u", |
d3ada366 DA |
10101 | peer->pcount |
10102 | [afi] | |
10103 | [pfx_rcd_safi]); | |
10104 | } else { | |
3577f1c5 | 10105 | vty_out(vty, " NoNeg"); |
d3ada366 | 10106 | } |
db92d226 | 10107 | |
d3ada366 DA |
10108 | if (paf && PAF_SUBGRP(paf)) { |
10109 | if (CHECK_FLAG( | |
10110 | bgp->flags, | |
10111 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
10112 | && !bgp_outbound_policy_exists( | |
10113 | peer, filter)) | |
10114 | vty_out(vty, " %8s", | |
10115 | "(Policy)"); | |
10116 | else | |
10117 | vty_out(vty, | |
6cde4b45 | 10118 | " %8u", |
d3ada366 DA |
10119 | (PAF_SUBGRP( |
10120 | paf)) | |
10121 | ->scount); | |
10122 | } | |
db92d226 | 10123 | } else { |
736b68f3 DS |
10124 | if (CHECK_FLAG(peer->flags, |
10125 | PEER_FLAG_SHUTDOWN) | |
10126 | || CHECK_FLAG(peer->bgp->flags, | |
10127 | BGP_FLAG_SHUTDOWN)) | |
3577f1c5 DD |
10128 | vty_out(vty, " Idle (Admin)"); |
10129 | else if (CHECK_FLAG( | |
10130 | peer->sflags, | |
10131 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10132 | vty_out(vty, " Idle (PfxCt)"); | |
10133 | else | |
10134 | vty_out(vty, " %12s", | |
10135 | lookup_msg(bgp_status_msg, | |
10136 | peer->status, NULL)); | |
db92d226 | 10137 | |
6cde4b45 | 10138 | vty_out(vty, " %8u", 0); |
3577f1c5 DD |
10139 | } |
10140 | vty_out(vty, "\n"); | |
d62a17ae | 10141 | } |
3577f1c5 | 10142 | |
d62a17ae | 10143 | } |
10144 | } | |
f933309e | 10145 | |
d62a17ae | 10146 | if (use_json) { |
10147 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 10148 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 10149 | json_object_int_add(json, "totalPeers", count); |
10150 | json_object_int_add(json, "dynamicPeers", dn_count); | |
10151 | ||
3577f1c5 DD |
10152 | if (!show_failed) |
10153 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 10154 | |
996c9314 LB |
10155 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10156 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10157 | json_object_free(json); |
10158 | } else { | |
10159 | if (count) | |
10160 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
10161 | else { | |
d6ceaca3 | 10162 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 10163 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10164 | } |
b05a1c8b | 10165 | |
d6ceaca3 | 10166 | if (dn_count) { |
d62a17ae | 10167 | vty_out(vty, "* - dynamic neighbor\n"); |
10168 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
10169 | dn_count, bgp->dynamic_neighbors_limit); | |
10170 | } | |
10171 | } | |
1ff9a340 | 10172 | |
d62a17ae | 10173 | return CMD_SUCCESS; |
718e3744 | 10174 | } |
10175 | ||
d62a17ae | 10176 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
10177 | int safi, bool show_failed, |
10178 | bool show_established, bool use_json) | |
d62a17ae | 10179 | { |
10180 | int is_first = 1; | |
10181 | int afi_wildcard = (afi == AFI_MAX); | |
10182 | int safi_wildcard = (safi == SAFI_MAX); | |
10183 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 10184 | bool nbr_output = false; |
d62a17ae | 10185 | |
10186 | if (use_json && is_wildcard) | |
10187 | vty_out(vty, "{\n"); | |
10188 | if (afi_wildcard) | |
10189 | afi = 1; /* AFI_IP */ | |
10190 | while (afi < AFI_MAX) { | |
10191 | if (safi_wildcard) | |
10192 | safi = 1; /* SAFI_UNICAST */ | |
10193 | while (safi < SAFI_MAX) { | |
318cac96 | 10194 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 10195 | nbr_output = true; |
f86897b9 | 10196 | |
d62a17ae | 10197 | if (is_wildcard) { |
10198 | /* | |
10199 | * So limit output to those afi/safi | |
10200 | * pairs that | |
10201 | * actualy have something interesting in | |
10202 | * them | |
10203 | */ | |
10204 | if (use_json) { | |
d62a17ae | 10205 | if (!is_first) |
10206 | vty_out(vty, ",\n"); | |
10207 | else | |
10208 | is_first = 0; | |
10209 | ||
10210 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
10211 | get_afi_safi_str(afi, |
10212 | safi, | |
10213 | true)); | |
d62a17ae | 10214 | } else { |
10215 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
10216 | get_afi_safi_str(afi, |
10217 | safi, | |
10218 | false)); | |
d62a17ae | 10219 | } |
10220 | } | |
10b49f14 DA |
10221 | bgp_show_summary(vty, bgp, afi, safi, |
10222 | show_failed, show_established, | |
3577f1c5 | 10223 | use_json); |
d62a17ae | 10224 | } |
10225 | safi++; | |
d62a17ae | 10226 | if (!safi_wildcard) |
10227 | safi = SAFI_MAX; | |
10228 | } | |
10229 | afi++; | |
ee851c8c | 10230 | if (!afi_wildcard) |
d62a17ae | 10231 | afi = AFI_MAX; |
10232 | } | |
10233 | ||
10234 | if (use_json && is_wildcard) | |
10235 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
10236 | else if (!nbr_output) { |
10237 | if (use_json) | |
10238 | vty_out(vty, "{}\n"); | |
10239 | else | |
10240 | vty_out(vty, "%% No BGP neighbors found\n"); | |
10241 | } | |
d62a17ae | 10242 | } |
10243 | ||
10244 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 10245 | safi_t safi, bool show_failed, |
10b49f14 | 10246 | bool show_established, |
3577f1c5 | 10247 | bool use_json) |
d62a17ae | 10248 | { |
10249 | struct listnode *node, *nnode; | |
10250 | struct bgp *bgp; | |
d62a17ae | 10251 | int is_first = 1; |
9f049418 | 10252 | bool nbr_output = false; |
d62a17ae | 10253 | |
10254 | if (use_json) | |
10255 | vty_out(vty, "{\n"); | |
10256 | ||
10257 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 10258 | nbr_output = true; |
d62a17ae | 10259 | if (use_json) { |
d62a17ae | 10260 | if (!is_first) |
10261 | vty_out(vty, ",\n"); | |
10262 | else | |
10263 | is_first = 0; | |
10264 | ||
10265 | vty_out(vty, "\"%s\":", | |
10266 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10267 | ? VRF_DEFAULT_NAME |
d62a17ae | 10268 | : bgp->name); |
10269 | } else { | |
10270 | vty_out(vty, "\nInstance %s:\n", | |
10271 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 10272 | ? VRF_DEFAULT_NAME |
d62a17ae | 10273 | : bgp->name); |
10274 | } | |
3577f1c5 | 10275 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 10276 | show_established, use_json); |
d62a17ae | 10277 | } |
10278 | ||
10279 | if (use_json) | |
10280 | vty_out(vty, "}\n"); | |
9f049418 DS |
10281 | else if (!nbr_output) |
10282 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 10283 | } |
10284 | ||
10285 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
10286 | safi_t safi, bool show_failed, bool show_established, |
10287 | bool use_json) | |
d62a17ae | 10288 | { |
10289 | struct bgp *bgp; | |
10290 | ||
10291 | if (name) { | |
10292 | if (strmatch(name, "all")) { | |
10b49f14 DA |
10293 | bgp_show_all_instances_summary_vty( |
10294 | vty, afi, safi, show_failed, show_established, | |
10295 | use_json); | |
d62a17ae | 10296 | return CMD_SUCCESS; |
10297 | } else { | |
10298 | bgp = bgp_lookup_by_name(name); | |
10299 | ||
10300 | if (!bgp) { | |
10301 | if (use_json) | |
10302 | vty_out(vty, "{}\n"); | |
10303 | else | |
10304 | vty_out(vty, | |
ca61fd25 | 10305 | "%% BGP instance not found\n"); |
d62a17ae | 10306 | return CMD_WARNING; |
10307 | } | |
10308 | ||
f86897b9 | 10309 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
10310 | show_failed, show_established, |
10311 | use_json); | |
d62a17ae | 10312 | return CMD_SUCCESS; |
10313 | } | |
10314 | } | |
10315 | ||
10316 | bgp = bgp_get_default(); | |
10317 | ||
10318 | if (bgp) | |
3577f1c5 | 10319 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 10320 | show_established, use_json); |
9f049418 | 10321 | else { |
ca61fd25 DS |
10322 | if (use_json) |
10323 | vty_out(vty, "{}\n"); | |
10324 | else | |
10325 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
10326 | return CMD_WARNING; |
10327 | } | |
d62a17ae | 10328 | |
10329 | return CMD_SUCCESS; | |
4fb25c53 DW |
10330 | } |
10331 | ||
716b2d8a | 10332 | /* `show [ip] bgp summary' commands. */ |
96f3485c | 10333 | DEFPY (show_ip_bgp_summary, |
718e3744 | 10334 | show_ip_bgp_summary_cmd, |
96f3485c | 10335 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] [all$all] summary [established|failed] [json$uj]", |
718e3744 | 10336 | SHOW_STR |
10337 | IP_STR | |
10338 | BGP_STR | |
8386ac43 | 10339 | BGP_INSTANCE_HELP_STR |
46f296b4 | 10340 | BGP_AFI_HELP_STR |
dd6bd0f1 | 10341 | BGP_SAFI_WITH_LABEL_HELP_STR |
96f3485c | 10342 | "Display the entries for all address families\n" |
b05a1c8b | 10343 | "Summary of BGP neighbor status\n" |
10b49f14 | 10344 | "Show only sessions in Established state\n" |
3577f1c5 | 10345 | "Show only sessions not in Established state\n" |
9973d184 | 10346 | JSON_STR) |
718e3744 | 10347 | { |
d62a17ae | 10348 | char *vrf = NULL; |
10349 | afi_t afi = AFI_MAX; | |
10350 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 10351 | bool show_failed = false; |
10b49f14 | 10352 | bool show_established = false; |
d62a17ae | 10353 | |
10354 | int idx = 0; | |
10355 | ||
10356 | /* show [ip] bgp */ | |
96f3485c | 10357 | if (!all && argv_find(argv, argc, "ip", &idx)) |
d62a17ae | 10358 | afi = AFI_IP; |
9a8bdf1c PG |
10359 | /* [<vrf> VIEWVRFNAME] */ |
10360 | if (argv_find(argv, argc, "vrf", &idx)) { | |
10361 | vrf = argv[idx + 1]->arg; | |
10362 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
10363 | vrf = NULL; | |
10364 | } else if (argv_find(argv, argc, "view", &idx)) | |
10365 | /* [<view> VIEWVRFNAME] */ | |
10366 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 10367 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
10368 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
10369 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10370 | } | |
10371 | ||
3577f1c5 DD |
10372 | if (argv_find(argv, argc, "failed", &idx)) |
10373 | show_failed = true; | |
10b49f14 DA |
10374 | if (argv_find(argv, argc, "established", &idx)) |
10375 | show_established = true; | |
3577f1c5 | 10376 | |
10b49f14 DA |
10377 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
10378 | show_established, uj); | |
d62a17ae | 10379 | } |
10380 | ||
5cb5f4d0 | 10381 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 10382 | { |
5cb5f4d0 DD |
10383 | if (for_json) |
10384 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 10385 | else |
5cb5f4d0 | 10386 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
10387 | } |
10388 | ||
d62a17ae | 10389 | |
10390 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
10391 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
10392 | uint16_t adv_smcap, uint16_t adv_rmcap, |
10393 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 10394 | bool use_json, json_object *json_pref) |
d62a17ae | 10395 | { |
10396 | /* Send-Mode */ | |
10397 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
10398 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
10399 | if (use_json) { | |
10400 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
10401 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
10402 | json_object_string_add(json_pref, "sendMode", | |
10403 | "advertisedAndReceived"); | |
10404 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
10405 | json_object_string_add(json_pref, "sendMode", | |
10406 | "advertised"); | |
10407 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
10408 | json_object_string_add(json_pref, "sendMode", | |
10409 | "received"); | |
10410 | } else { | |
10411 | vty_out(vty, " Send-mode: "); | |
10412 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
10413 | vty_out(vty, "advertised"); | |
10414 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
10415 | vty_out(vty, "%sreceived", | |
10416 | CHECK_FLAG(p->af_cap[afi][safi], | |
10417 | adv_smcap) | |
10418 | ? ", " | |
10419 | : ""); | |
10420 | vty_out(vty, "\n"); | |
10421 | } | |
10422 | } | |
10423 | ||
10424 | /* Receive-Mode */ | |
10425 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
10426 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
10427 | if (use_json) { | |
10428 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
10429 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
10430 | json_object_string_add(json_pref, "recvMode", | |
10431 | "advertisedAndReceived"); | |
10432 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
10433 | json_object_string_add(json_pref, "recvMode", | |
10434 | "advertised"); | |
10435 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
10436 | json_object_string_add(json_pref, "recvMode", | |
10437 | "received"); | |
10438 | } else { | |
10439 | vty_out(vty, " Receive-mode: "); | |
10440 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
10441 | vty_out(vty, "advertised"); | |
10442 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
10443 | vty_out(vty, "%sreceived", | |
10444 | CHECK_FLAG(p->af_cap[afi][safi], | |
10445 | adv_rmcap) | |
10446 | ? ", " | |
10447 | : ""); | |
10448 | vty_out(vty, "\n"); | |
10449 | } | |
10450 | } | |
10451 | } | |
10452 | ||
13909c4f DS |
10453 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
10454 | struct peer *p, | |
10455 | bool use_json, | |
10456 | json_object *json) | |
2986cac2 | 10457 | { |
08c2d52a | 10458 | bool rbit_status = false; |
2986cac2 | 10459 | |
10460 | if (!use_json) | |
a53ca37b | 10461 | vty_out(vty, "\n R bit: "); |
2986cac2 | 10462 | |
13909c4f DS |
10463 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
10464 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
10465 | && (p->status == Established)) { | |
2986cac2 | 10466 | |
10467 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 10468 | rbit_status = true; |
2986cac2 | 10469 | else |
08c2d52a | 10470 | rbit_status = false; |
2986cac2 | 10471 | } |
10472 | ||
10473 | if (rbit_status) { | |
10474 | if (use_json) | |
13909c4f | 10475 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 10476 | else |
10477 | vty_out(vty, "True\n"); | |
10478 | } else { | |
10479 | if (use_json) | |
13909c4f | 10480 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 10481 | else |
10482 | vty_out(vty, "False\n"); | |
10483 | } | |
10484 | } | |
10485 | ||
13909c4f DS |
10486 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
10487 | struct peer *peer, | |
10488 | bool use_json, | |
10489 | json_object *json) | |
2986cac2 | 10490 | { |
2bb5d39b | 10491 | const char *mode = "NotApplicable"; |
2986cac2 | 10492 | |
10493 | if (!use_json) | |
a53ca37b | 10494 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 10495 | |
13909c4f DS |
10496 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
10497 | && (peer->status == Established)) { | |
2986cac2 | 10498 | |
13909c4f DS |
10499 | if ((peer->nsf_af_count == 0) |
10500 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 10501 | |
2986cac2 | 10502 | mode = "Disable"; |
10503 | ||
13909c4f DS |
10504 | } else if (peer->nsf_af_count == 0 |
10505 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 10506 | |
2986cac2 | 10507 | mode = "Helper"; |
10508 | ||
13909c4f DS |
10509 | } else if (peer->nsf_af_count != 0 |
10510 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 10511 | |
2986cac2 | 10512 | mode = "Restart"; |
2986cac2 | 10513 | } |
10514 | } | |
10515 | ||
10516 | if (use_json) { | |
13909c4f | 10517 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 10518 | } else |
10519 | vty_out(vty, mode, "\n"); | |
10520 | } | |
10521 | ||
13909c4f DS |
10522 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
10523 | struct peer *p, | |
10524 | bool use_json, | |
10525 | json_object *json) | |
2986cac2 | 10526 | { |
10527 | const char *mode = "Invalid"; | |
10528 | ||
10529 | if (!use_json) | |
a53ca37b | 10530 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 10531 | |
10532 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
10533 | mode = "Helper"; | |
10534 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
10535 | mode = "Restart"; | |
10536 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
10537 | mode = "Disable"; | |
2ba1fe69 | 10538 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 10539 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
10540 | mode = "Helper*"; | |
10541 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
10542 | mode = "Restart*"; | |
10543 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
10544 | mode = "Disable*"; | |
10545 | else | |
10546 | mode = "Invalid*"; | |
2ba1fe69 | 10547 | } |
2986cac2 | 10548 | |
10549 | if (use_json) { | |
13909c4f | 10550 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 10551 | } else { |
10552 | vty_out(vty, mode, "\n"); | |
10553 | } | |
10554 | } | |
10555 | ||
13909c4f DS |
10556 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
10557 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 10558 | { |
2ba1fe69 | 10559 | afi_t afi; |
10560 | safi_t safi; | |
2986cac2 | 10561 | json_object *json_afi_safi = NULL; |
10562 | json_object *json_timer = NULL; | |
10563 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 10564 | bool eor_flag = false; |
2986cac2 | 10565 | |
10566 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
10567 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
10568 | if (!peer->afc[afi][safi]) |
10569 | continue; | |
2986cac2 | 10570 | |
13909c4f DS |
10571 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
10572 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
10573 | continue; | |
9e3b51a7 | 10574 | |
13909c4f DS |
10575 | if (use_json) { |
10576 | json_afi_safi = json_object_new_object(); | |
10577 | json_endofrib_status = json_object_new_object(); | |
10578 | json_timer = json_object_new_object(); | |
10579 | } | |
2986cac2 | 10580 | |
13909c4f DS |
10581 | if (peer->eor_stime[afi][safi] |
10582 | >= peer->pkt_stime[afi][safi]) | |
10583 | eor_flag = true; | |
10584 | else | |
10585 | eor_flag = false; | |
2986cac2 | 10586 | |
13909c4f | 10587 | if (!use_json) { |
a53ca37b | 10588 | vty_out(vty, " %s:\n", |
13909c4f | 10589 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 10590 | |
a53ca37b | 10591 | vty_out(vty, " F bit: "); |
698ba8d0 | 10592 | } |
2986cac2 | 10593 | |
13909c4f DS |
10594 | if (peer->nsf[afi][safi] |
10595 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
10596 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 10597 | |
13909c4f DS |
10598 | if (use_json) { |
10599 | json_object_boolean_true_add( | |
2986cac2 | 10600 | json_afi_safi, "fBit"); |
13909c4f DS |
10601 | } else |
10602 | vty_out(vty, "True\n"); | |
10603 | } else { | |
10604 | if (use_json) | |
10605 | json_object_boolean_false_add( | |
10606 | json_afi_safi, "fBit"); | |
10607 | else | |
10608 | vty_out(vty, "False\n"); | |
10609 | } | |
2986cac2 | 10610 | |
13909c4f | 10611 | if (!use_json) |
a53ca37b | 10612 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 10613 | |
13909c4f DS |
10614 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
10615 | PEER_STATUS_EOR_SEND)) { | |
10616 | if (use_json) { | |
10617 | json_object_boolean_true_add( | |
2986cac2 | 10618 | json_endofrib_status, |
13909c4f | 10619 | "endOfRibSend"); |
9e3b51a7 | 10620 | |
13909c4f DS |
10621 | PRINT_EOR_JSON(eor_flag); |
10622 | } else { | |
10623 | vty_out(vty, "Yes\n"); | |
10624 | vty_out(vty, | |
a53ca37b | 10625 | " End-of-RIB sent after update: "); |
2986cac2 | 10626 | |
13909c4f DS |
10627 | PRINT_EOR(eor_flag); |
10628 | } | |
10629 | } else { | |
10630 | if (use_json) { | |
10631 | json_object_boolean_false_add( | |
2986cac2 | 10632 | json_endofrib_status, |
13909c4f DS |
10633 | "endOfRibSend"); |
10634 | json_object_boolean_false_add( | |
9e3b51a7 | 10635 | json_endofrib_status, |
13909c4f DS |
10636 | "endOfRibSentAfterUpdate"); |
10637 | } else { | |
10638 | vty_out(vty, "No\n"); | |
10639 | vty_out(vty, | |
a53ca37b | 10640 | " End-of-RIB sent after update: "); |
13909c4f | 10641 | vty_out(vty, "No\n"); |
2986cac2 | 10642 | } |
13909c4f | 10643 | } |
2986cac2 | 10644 | |
a53ca37b DA |
10645 | if (!use_json) |
10646 | vty_out(vty, " End-of-RIB received: "); | |
10647 | ||
10648 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
10649 | PEER_STATUS_EOR_RECEIVED)) { | |
10650 | if (use_json) | |
10651 | json_object_boolean_true_add( | |
10652 | json_endofrib_status, | |
10653 | "endOfRibRecv"); | |
10654 | else | |
10655 | vty_out(vty, "Yes\n"); | |
10656 | } else { | |
10657 | if (use_json) | |
10658 | json_object_boolean_false_add( | |
10659 | json_endofrib_status, | |
10660 | "endOfRibRecv"); | |
10661 | else | |
10662 | vty_out(vty, "No\n"); | |
10663 | } | |
10664 | ||
13909c4f DS |
10665 | if (use_json) { |
10666 | json_object_int_add(json_timer, | |
10667 | "stalePathTimer", | |
10668 | peer->bgp->stalepath_time); | |
2986cac2 | 10669 | |
13909c4f DS |
10670 | if (peer->t_gr_stale != NULL) { |
10671 | json_object_int_add( | |
2986cac2 | 10672 | json_timer, |
10673 | "stalePathTimerRemaining", | |
10674 | thread_timer_remain_second( | |
13909c4f DS |
10675 | peer->t_gr_stale)); |
10676 | } | |
3a75afa4 | 10677 | |
13909c4f DS |
10678 | /* Display Configured Selection |
10679 | * Deferral only when when | |
10680 | * Gr mode is enabled. | |
10681 | */ | |
10682 | if (CHECK_FLAG(peer->flags, | |
10683 | PEER_FLAG_GRACEFUL_RESTART)) { | |
10684 | json_object_int_add( | |
3a75afa4 | 10685 | json_timer, |
2986cac2 | 10686 | "selectionDeferralTimer", |
10687 | peer->bgp->stalepath_time); | |
13909c4f | 10688 | } |
2986cac2 | 10689 | |
13909c4f DS |
10690 | if (peer->bgp->gr_info[afi][safi] |
10691 | .t_select_deferral | |
10692 | != NULL) { | |
2986cac2 | 10693 | |
13909c4f | 10694 | json_object_int_add( |
2986cac2 | 10695 | json_timer, |
10696 | "selectionDeferralTimerRemaining", | |
10697 | thread_timer_remain_second( | |
13909c4f DS |
10698 | peer->bgp |
10699 | ->gr_info[afi] | |
10700 | [safi] | |
10701 | .t_select_deferral)); | |
10702 | } | |
10703 | } else { | |
a53ca37b | 10704 | vty_out(vty, " Timers:\n"); |
13909c4f | 10705 | vty_out(vty, |
a53ca37b DA |
10706 | " Configured Stale Path Time(sec): %u\n", |
10707 | peer->bgp->stalepath_time); | |
2986cac2 | 10708 | |
a53ca37b | 10709 | if (peer->t_gr_stale != NULL) |
2986cac2 | 10710 | vty_out(vty, |
a53ca37b | 10711 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 10712 | thread_timer_remain_second( |
13909c4f | 10713 | peer->t_gr_stale)); |
13909c4f DS |
10714 | /* Display Configured Selection |
10715 | * Deferral only when when | |
10716 | * Gr mode is enabled. | |
10717 | */ | |
10718 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 10719 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 10720 | vty_out(vty, |
a53ca37b | 10721 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 10722 | peer->bgp->select_defer_time); |
2986cac2 | 10723 | |
13909c4f DS |
10724 | if (peer->bgp->gr_info[afi][safi] |
10725 | .t_select_deferral | |
a53ca37b | 10726 | != NULL) |
13909c4f | 10727 | vty_out(vty, |
a53ca37b | 10728 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 10729 | thread_timer_remain_second( |
13909c4f DS |
10730 | peer->bgp |
10731 | ->gr_info[afi] | |
10732 | [safi] | |
10733 | .t_select_deferral)); | |
2986cac2 | 10734 | } |
13909c4f DS |
10735 | if (use_json) { |
10736 | json_object_object_add(json_afi_safi, | |
10737 | "endOfRibStatus", | |
10738 | json_endofrib_status); | |
10739 | json_object_object_add(json_afi_safi, "timers", | |
10740 | json_timer); | |
10741 | json_object_object_add( | |
10742 | json, get_afi_safi_str(afi, safi, true), | |
10743 | json_afi_safi); | |
10744 | } | |
2986cac2 | 10745 | } |
10746 | } | |
10747 | } | |
10748 | ||
36235319 QY |
10749 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
10750 | struct peer *p, | |
10751 | bool use_json, | |
10752 | json_object *json) | |
2986cac2 | 10753 | { |
10754 | if (use_json) { | |
10755 | json_object *json_timer = NULL; | |
10756 | ||
10757 | json_timer = json_object_new_object(); | |
10758 | ||
13909c4f DS |
10759 | json_object_int_add(json_timer, "configuredRestartTimer", |
10760 | p->bgp->restart_time); | |
2986cac2 | 10761 | |
13909c4f DS |
10762 | json_object_int_add(json_timer, "receivedRestartTimer", |
10763 | p->v_gr_restart); | |
2986cac2 | 10764 | |
13909c4f DS |
10765 | if (p->t_gr_restart != NULL) |
10766 | json_object_int_add( | |
10767 | json_timer, "restartTimerRemaining", | |
10768 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 10769 | |
10770 | json_object_object_add(json, "timers", json_timer); | |
10771 | } else { | |
10772 | ||
a53ca37b DA |
10773 | vty_out(vty, " Timers:\n"); |
10774 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 10775 | p->bgp->restart_time); |
2986cac2 | 10776 | |
a53ca37b | 10777 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
10778 | p->v_gr_restart); |
10779 | if (p->t_gr_restart != NULL) | |
a53ca37b | 10780 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 10781 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 10782 | if (p->t_gr_restart != NULL) { |
a53ca37b | 10783 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
10784 | thread_timer_remain_second(p->t_gr_restart)); |
10785 | } | |
2986cac2 | 10786 | } |
10787 | } | |
10788 | ||
10789 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 10790 | bool use_json, json_object *json) |
2986cac2 | 10791 | { |
10792 | char buf[SU_ADDRSTRLEN] = {0}; | |
10793 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
10794 | /* '*' + v6 address of neighbor */ |
10795 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 10796 | |
2986cac2 | 10797 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
10798 | dn_flag[0] = '*'; | |
10799 | ||
10800 | if (p->conf_if) { | |
10801 | if (use_json) | |
13909c4f DS |
10802 | json_object_string_add( |
10803 | json, "neighborAddr", | |
2986cac2 | 10804 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
10805 | ? "none" |
10806 | : sockunion2str(&p->su, buf, | |
10807 | SU_ADDRSTRLEN)); | |
2986cac2 | 10808 | else |
13909c4f | 10809 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 10810 | BGP_PEER_SU_UNSPEC(p) |
10811 | ? "none" | |
10812 | : sockunion2str(&p->su, buf, | |
10813 | SU_ADDRSTRLEN)); | |
10814 | } else { | |
772270f3 QY |
10815 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
10816 | p->host); | |
2986cac2 | 10817 | |
10818 | if (use_json) | |
36235319 QY |
10819 | json_object_string_add(json, "neighborAddr", |
10820 | neighborAddr); | |
2986cac2 | 10821 | else |
36235319 | 10822 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 10823 | } |
10824 | ||
10825 | /* more gr info in new format */ | |
10826 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
10827 | } | |
10828 | ||
d62a17ae | 10829 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 10830 | safi_t safi, bool use_json, |
d62a17ae | 10831 | json_object *json_neigh) |
10832 | { | |
0291c246 MK |
10833 | struct bgp_filter *filter; |
10834 | struct peer_af *paf; | |
10835 | char orf_pfx_name[BUFSIZ]; | |
10836 | int orf_pfx_count; | |
10837 | json_object *json_af = NULL; | |
10838 | json_object *json_prefA = NULL; | |
10839 | json_object *json_prefB = NULL; | |
10840 | json_object *json_addr = NULL; | |
d62a17ae | 10841 | |
10842 | if (use_json) { | |
10843 | json_addr = json_object_new_object(); | |
10844 | json_af = json_object_new_object(); | |
10845 | filter = &p->filter[afi][safi]; | |
10846 | ||
10847 | if (peer_group_active(p)) | |
10848 | json_object_string_add(json_addr, "peerGroupMember", | |
10849 | p->group->name); | |
10850 | ||
10851 | paf = peer_af_find(p, afi, safi); | |
10852 | if (paf && PAF_SUBGRP(paf)) { | |
10853 | json_object_int_add(json_addr, "updateGroupId", | |
10854 | PAF_UPDGRP(paf)->id); | |
10855 | json_object_int_add(json_addr, "subGroupId", | |
10856 | PAF_SUBGRP(paf)->id); | |
10857 | json_object_int_add(json_addr, "packetQueueLength", | |
10858 | bpacket_queue_virtual_length(paf)); | |
10859 | } | |
10860 | ||
10861 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10862 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10863 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10864 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10865 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10866 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10867 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10868 | json_object_int_add(json_af, "orfType", | |
10869 | ORF_TYPE_PREFIX); | |
10870 | json_prefA = json_object_new_object(); | |
10871 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
10872 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
10873 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10874 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10875 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
10876 | use_json, json_prefA); | |
10877 | json_object_object_add(json_af, "orfPrefixList", | |
10878 | json_prefA); | |
10879 | } | |
10880 | ||
10881 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10882 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10883 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10884 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10885 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10886 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10887 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10888 | json_object_int_add(json_af, "orfOldType", | |
10889 | ORF_TYPE_PREFIX_OLD); | |
10890 | json_prefB = json_object_new_object(); | |
10891 | bgp_show_peer_afi_orf_cap( | |
10892 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10893 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10894 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10895 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
10896 | json_prefB); | |
10897 | json_object_object_add(json_af, "orfOldPrefixList", | |
10898 | json_prefB); | |
10899 | } | |
10900 | ||
10901 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10902 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10903 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10904 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10905 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10906 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10907 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10908 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10909 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10910 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10911 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10912 | json_object_object_add(json_addr, "afDependentCap", | |
10913 | json_af); | |
10914 | else | |
10915 | json_object_free(json_af); | |
10916 | ||
772270f3 QY |
10917 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10918 | p->host, afi, safi); | |
d62a17ae | 10919 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10920 | NULL, afi, orf_pfx_name, use_json); | |
10921 | ||
10922 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10923 | PEER_STATUS_ORF_PREFIX_SEND) | |
10924 | || orf_pfx_count) { | |
10925 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10926 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10927 | json_object_boolean_true_add(json_neigh, | |
10928 | "orfSent"); | |
10929 | if (orf_pfx_count) | |
10930 | json_object_int_add(json_addr, "orfRecvCounter", | |
10931 | orf_pfx_count); | |
10932 | } | |
10933 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10934 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10935 | json_object_string_add( | |
10936 | json_addr, "orfFirstUpdate", | |
10937 | "deferredUntilORFOrRouteRefreshRecvd"); | |
10938 | ||
10939 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10940 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10941 | json_object_boolean_true_add(json_addr, | |
10942 | "routeReflectorClient"); | |
10943 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10944 | PEER_FLAG_RSERVER_CLIENT)) | |
10945 | json_object_boolean_true_add(json_addr, | |
10946 | "routeServerClient"); | |
10947 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10948 | json_object_boolean_true_add(json_addr, | |
10949 | "inboundSoftConfigPermit"); | |
10950 | ||
10951 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10952 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10953 | json_object_boolean_true_add( | |
10954 | json_addr, | |
10955 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10956 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10957 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10958 | json_object_boolean_true_add( | |
10959 | json_addr, | |
10960 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10961 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10962 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10963 | json_object_boolean_true_add( | |
10964 | json_addr, | |
10965 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10966 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10967 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10968 | json_object_boolean_true_add( | |
10969 | json_addr, | |
10970 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10971 | ||
dcc68b5e MS |
10972 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10973 | json_object_boolean_true_add( | |
10974 | json_addr, | |
10975 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10976 | ->type_json_name); | |
d62a17ae | 10977 | |
10978 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10979 | json_object_string_add(json_addr, | |
10980 | "overrideASNsInOutboundUpdates", | |
10981 | "ifAspathEqualRemoteAs"); | |
10982 | ||
10983 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10984 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10985 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10986 | json_object_boolean_true_add(json_addr, | |
10987 | "routerAlwaysNextHop"); | |
10988 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10989 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10990 | json_object_boolean_true_add( | |
10991 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10992 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10993 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10994 | json_object_boolean_true_add( | |
10995 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10996 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10997 | json_object_boolean_true_add( | |
10998 | json_addr, "unchangedMedPropogatedToNbr"); | |
10999 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11000 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11001 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
11002 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11003 | PEER_FLAG_SEND_COMMUNITY) | |
11004 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11005 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11006 | json_object_string_add(json_addr, | |
11007 | "commAttriSentToNbr", | |
11008 | "extendedAndStandard"); | |
11009 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11010 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11011 | json_object_string_add(json_addr, | |
11012 | "commAttriSentToNbr", | |
11013 | "extended"); | |
11014 | else | |
11015 | json_object_string_add(json_addr, | |
11016 | "commAttriSentToNbr", | |
11017 | "standard"); | |
11018 | } | |
11019 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11020 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11021 | if (p->default_rmap[afi][safi].name) | |
11022 | json_object_string_add( | |
11023 | json_addr, "defaultRouteMap", | |
11024 | p->default_rmap[afi][safi].name); | |
11025 | ||
11026 | if (paf && PAF_SUBGRP(paf) | |
11027 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11028 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11029 | json_object_boolean_true_add(json_addr, | |
11030 | "defaultSent"); | |
11031 | else | |
11032 | json_object_boolean_true_add(json_addr, | |
11033 | "defaultNotSent"); | |
11034 | } | |
11035 | ||
dff8f48d | 11036 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 11037 | if (is_evpn_enabled()) |
60466a63 QY |
11038 | json_object_boolean_true_add( |
11039 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
11040 | } |
11041 | ||
d62a17ae | 11042 | if (filter->plist[FILTER_IN].name |
11043 | || filter->dlist[FILTER_IN].name | |
11044 | || filter->aslist[FILTER_IN].name | |
11045 | || filter->map[RMAP_IN].name) | |
11046 | json_object_boolean_true_add(json_addr, | |
11047 | "inboundPathPolicyConfig"); | |
11048 | if (filter->plist[FILTER_OUT].name | |
11049 | || filter->dlist[FILTER_OUT].name | |
11050 | || filter->aslist[FILTER_OUT].name | |
11051 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11052 | json_object_boolean_true_add( | |
11053 | json_addr, "outboundPathPolicyConfig"); | |
11054 | ||
11055 | /* prefix-list */ | |
11056 | if (filter->plist[FILTER_IN].name) | |
11057 | json_object_string_add(json_addr, | |
11058 | "incomingUpdatePrefixFilterList", | |
11059 | filter->plist[FILTER_IN].name); | |
11060 | if (filter->plist[FILTER_OUT].name) | |
11061 | json_object_string_add(json_addr, | |
11062 | "outgoingUpdatePrefixFilterList", | |
11063 | filter->plist[FILTER_OUT].name); | |
11064 | ||
11065 | /* distribute-list */ | |
11066 | if (filter->dlist[FILTER_IN].name) | |
11067 | json_object_string_add( | |
11068 | json_addr, "incomingUpdateNetworkFilterList", | |
11069 | filter->dlist[FILTER_IN].name); | |
11070 | if (filter->dlist[FILTER_OUT].name) | |
11071 | json_object_string_add( | |
11072 | json_addr, "outgoingUpdateNetworkFilterList", | |
11073 | filter->dlist[FILTER_OUT].name); | |
11074 | ||
11075 | /* filter-list. */ | |
11076 | if (filter->aslist[FILTER_IN].name) | |
11077 | json_object_string_add(json_addr, | |
11078 | "incomingUpdateAsPathFilterList", | |
11079 | filter->aslist[FILTER_IN].name); | |
11080 | if (filter->aslist[FILTER_OUT].name) | |
11081 | json_object_string_add(json_addr, | |
11082 | "outgoingUpdateAsPathFilterList", | |
11083 | filter->aslist[FILTER_OUT].name); | |
11084 | ||
11085 | /* route-map. */ | |
11086 | if (filter->map[RMAP_IN].name) | |
11087 | json_object_string_add( | |
11088 | json_addr, "routeMapForIncomingAdvertisements", | |
11089 | filter->map[RMAP_IN].name); | |
11090 | if (filter->map[RMAP_OUT].name) | |
11091 | json_object_string_add( | |
11092 | json_addr, "routeMapForOutgoingAdvertisements", | |
11093 | filter->map[RMAP_OUT].name); | |
11094 | ||
9dac9fc8 | 11095 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11096 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11097 | && !bgp_inbound_policy_exists(p, filter)) |
11098 | json_object_string_add( | |
11099 | json_addr, "inboundEbgpRequiresPolicy", | |
11100 | "Inbound updates discarded due to missing policy"); | |
11101 | ||
11102 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11103 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11104 | && (!bgp_outbound_policy_exists(p, filter))) |
11105 | json_object_string_add( | |
11106 | json_addr, "outboundEbgpRequiresPolicy", | |
11107 | "Outbound updates discarded due to missing policy"); | |
11108 | ||
d62a17ae | 11109 | /* unsuppress-map */ |
11110 | if (filter->usmap.name) | |
11111 | json_object_string_add(json_addr, | |
11112 | "selectiveUnsuppressRouteMap", | |
11113 | filter->usmap.name); | |
11114 | ||
11115 | /* Receive prefix count */ | |
11116 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
11117 | p->pcount[afi][safi]); | |
50e05855 AD |
11118 | if (paf && PAF_SUBGRP(paf)) |
11119 | json_object_int_add(json_addr, "sentPrefixCounter", | |
11120 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 11121 | |
fde246e8 DA |
11122 | /* Maximum prefix */ |
11123 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
11124 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
11125 | p->pmax_out[afi][safi]); | |
11126 | ||
d62a17ae | 11127 | /* Maximum prefix */ |
11128 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
11129 | json_object_int_add(json_addr, "prefixAllowedMax", | |
11130 | p->pmax[afi][safi]); | |
11131 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11132 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
11133 | json_object_boolean_true_add( | |
11134 | json_addr, "prefixAllowedMaxWarning"); | |
11135 | json_object_int_add(json_addr, | |
11136 | "prefixAllowedWarningThresh", | |
11137 | p->pmax_threshold[afi][safi]); | |
11138 | if (p->pmax_restart[afi][safi]) | |
11139 | json_object_int_add( | |
11140 | json_addr, | |
11141 | "prefixAllowedRestartIntervalMsecs", | |
11142 | p->pmax_restart[afi][safi] * 60000); | |
11143 | } | |
2986cac2 | 11144 | json_object_object_add(json_neigh, |
36235319 | 11145 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 11146 | json_addr); |
11147 | ||
11148 | } else { | |
11149 | filter = &p->filter[afi][safi]; | |
11150 | ||
11151 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 11152 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 11153 | |
11154 | if (peer_group_active(p)) | |
11155 | vty_out(vty, " %s peer-group member\n", | |
11156 | p->group->name); | |
11157 | ||
11158 | paf = peer_af_find(p, afi, safi); | |
11159 | if (paf && PAF_SUBGRP(paf)) { | |
6cde4b45 | 11160 | vty_out(vty, " Update group %" PRIu64", subgroup %" PRIu64 "\n", |
d62a17ae | 11161 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
11162 | vty_out(vty, " Packet Queue length %d\n", | |
11163 | bpacket_queue_virtual_length(paf)); | |
11164 | } else { | |
11165 | vty_out(vty, " Not part of any update group\n"); | |
11166 | } | |
11167 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11168 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11169 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11170 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11171 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11172 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11173 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11174 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11175 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
11176 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11177 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
11178 | vty_out(vty, " AF-dependant capabilities:\n"); | |
11179 | ||
11180 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11181 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11182 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
11183 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11184 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11185 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11186 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
11187 | vty_out(vty, | |
11188 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11189 | ORF_TYPE_PREFIX); | |
11190 | bgp_show_peer_afi_orf_cap( | |
11191 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11192 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11193 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
11194 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
11195 | } | |
11196 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
11197 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11198 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
11199 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11200 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
11201 | || CHECK_FLAG(p->af_cap[afi][safi], | |
11202 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
11203 | vty_out(vty, | |
11204 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
11205 | ORF_TYPE_PREFIX_OLD); | |
11206 | bgp_show_peer_afi_orf_cap( | |
11207 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
11208 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
11209 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
11210 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
11211 | } | |
11212 | ||
772270f3 QY |
11213 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
11214 | p->host, afi, safi); | |
d62a17ae | 11215 | orf_pfx_count = prefix_bgp_show_prefix_list( |
11216 | NULL, afi, orf_pfx_name, use_json); | |
11217 | ||
11218 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11219 | PEER_STATUS_ORF_PREFIX_SEND) | |
11220 | || orf_pfx_count) { | |
11221 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
11222 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11223 | PEER_STATUS_ORF_PREFIX_SEND)) | |
11224 | vty_out(vty, " sent;"); | |
11225 | if (orf_pfx_count) | |
11226 | vty_out(vty, " received (%d entries)", | |
11227 | orf_pfx_count); | |
11228 | vty_out(vty, "\n"); | |
11229 | } | |
11230 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11231 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
11232 | vty_out(vty, | |
11233 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
11234 | ||
11235 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11236 | PEER_FLAG_REFLECTOR_CLIENT)) | |
11237 | vty_out(vty, " Route-Reflector Client\n"); | |
11238 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11239 | PEER_FLAG_RSERVER_CLIENT)) | |
11240 | vty_out(vty, " Route-Server Client\n"); | |
11241 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
11242 | vty_out(vty, | |
11243 | " Inbound soft reconfiguration allowed\n"); | |
11244 | ||
11245 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11246 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
11247 | vty_out(vty, | |
11248 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
11249 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11250 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
11251 | vty_out(vty, | |
11252 | " Private AS numbers replaced in updates to this neighbor\n"); | |
11253 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11254 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
11255 | vty_out(vty, | |
11256 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
11257 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11258 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
11259 | vty_out(vty, | |
11260 | " Private AS numbers removed in updates to this neighbor\n"); | |
11261 | ||
dcc68b5e MS |
11262 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
11263 | vty_out(vty, " %s\n", | |
11264 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
11265 | ->human_description); | |
d62a17ae | 11266 | |
11267 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
11268 | vty_out(vty, | |
11269 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
11270 | ||
11271 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
11272 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11273 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
11274 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
11275 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11276 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
11277 | vty_out(vty, | |
11278 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
11279 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11280 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
11281 | vty_out(vty, | |
11282 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
11283 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
11284 | vty_out(vty, | |
11285 | " MED is propagated unchanged to this neighbor\n"); | |
11286 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
11287 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11288 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
11289 | || CHECK_FLAG(p->af_flags[afi][safi], | |
11290 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
11291 | vty_out(vty, | |
11292 | " Community attribute sent to this neighbor"); | |
11293 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11294 | PEER_FLAG_SEND_COMMUNITY) | |
11295 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11296 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
11297 | && CHECK_FLAG(p->af_flags[afi][safi], | |
11298 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
11299 | vty_out(vty, "(all)\n"); | |
11300 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11301 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
11302 | vty_out(vty, "(large)\n"); | |
11303 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
11304 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
11305 | vty_out(vty, "(extended)\n"); | |
11306 | else | |
11307 | vty_out(vty, "(standard)\n"); | |
11308 | } | |
11309 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11310 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
11311 | vty_out(vty, " Default information originate,"); | |
11312 | ||
11313 | if (p->default_rmap[afi][safi].name) | |
11314 | vty_out(vty, " default route-map %s%s,", | |
11315 | p->default_rmap[afi][safi].map ? "*" | |
11316 | : "", | |
11317 | p->default_rmap[afi][safi].name); | |
11318 | if (paf && PAF_SUBGRP(paf) | |
11319 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
11320 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
11321 | vty_out(vty, " default sent\n"); | |
11322 | else | |
11323 | vty_out(vty, " default not sent\n"); | |
11324 | } | |
11325 | ||
dff8f48d MK |
11326 | /* advertise-vni-all */ |
11327 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 11328 | if (is_evpn_enabled()) |
dff8f48d MK |
11329 | vty_out(vty, " advertise-all-vni\n"); |
11330 | } | |
11331 | ||
d62a17ae | 11332 | if (filter->plist[FILTER_IN].name |
11333 | || filter->dlist[FILTER_IN].name | |
11334 | || filter->aslist[FILTER_IN].name | |
11335 | || filter->map[RMAP_IN].name) | |
11336 | vty_out(vty, " Inbound path policy configured\n"); | |
11337 | if (filter->plist[FILTER_OUT].name | |
11338 | || filter->dlist[FILTER_OUT].name | |
11339 | || filter->aslist[FILTER_OUT].name | |
11340 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
11341 | vty_out(vty, " Outbound path policy configured\n"); | |
11342 | ||
11343 | /* prefix-list */ | |
11344 | if (filter->plist[FILTER_IN].name) | |
11345 | vty_out(vty, | |
11346 | " Incoming update prefix filter list is %s%s\n", | |
11347 | filter->plist[FILTER_IN].plist ? "*" : "", | |
11348 | filter->plist[FILTER_IN].name); | |
11349 | if (filter->plist[FILTER_OUT].name) | |
11350 | vty_out(vty, | |
11351 | " Outgoing update prefix filter list is %s%s\n", | |
11352 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
11353 | filter->plist[FILTER_OUT].name); | |
11354 | ||
11355 | /* distribute-list */ | |
11356 | if (filter->dlist[FILTER_IN].name) | |
11357 | vty_out(vty, | |
11358 | " Incoming update network filter list is %s%s\n", | |
11359 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
11360 | filter->dlist[FILTER_IN].name); | |
11361 | if (filter->dlist[FILTER_OUT].name) | |
11362 | vty_out(vty, | |
11363 | " Outgoing update network filter list is %s%s\n", | |
11364 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
11365 | filter->dlist[FILTER_OUT].name); | |
11366 | ||
11367 | /* filter-list. */ | |
11368 | if (filter->aslist[FILTER_IN].name) | |
11369 | vty_out(vty, | |
11370 | " Incoming update AS path filter list is %s%s\n", | |
11371 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
11372 | filter->aslist[FILTER_IN].name); | |
11373 | if (filter->aslist[FILTER_OUT].name) | |
11374 | vty_out(vty, | |
11375 | " Outgoing update AS path filter list is %s%s\n", | |
11376 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
11377 | filter->aslist[FILTER_OUT].name); | |
11378 | ||
11379 | /* route-map. */ | |
11380 | if (filter->map[RMAP_IN].name) | |
11381 | vty_out(vty, | |
11382 | " Route map for incoming advertisements is %s%s\n", | |
11383 | filter->map[RMAP_IN].map ? "*" : "", | |
11384 | filter->map[RMAP_IN].name); | |
11385 | if (filter->map[RMAP_OUT].name) | |
11386 | vty_out(vty, | |
11387 | " Route map for outgoing advertisements is %s%s\n", | |
11388 | filter->map[RMAP_OUT].map ? "*" : "", | |
11389 | filter->map[RMAP_OUT].name); | |
11390 | ||
9dac9fc8 | 11391 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 11392 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11393 | && !bgp_inbound_policy_exists(p, filter)) |
11394 | vty_out(vty, | |
11395 | " Inbound updates discarded due to missing policy\n"); | |
11396 | ||
11397 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 11398 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
11399 | && !bgp_outbound_policy_exists(p, filter)) |
11400 | vty_out(vty, | |
11401 | " Outbound updates discarded due to missing policy\n"); | |
11402 | ||
d62a17ae | 11403 | /* unsuppress-map */ |
11404 | if (filter->usmap.name) | |
11405 | vty_out(vty, | |
11406 | " Route map for selective unsuppress is %s%s\n", | |
11407 | filter->usmap.map ? "*" : "", | |
11408 | filter->usmap.name); | |
11409 | ||
7f7940e6 MK |
11410 | /* advertise-map */ |
11411 | if (filter->advmap.aname && filter->advmap.cname) | |
11412 | vty_out(vty, | |
11413 | " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n", | |
11414 | filter->advmap.condition ? "EXIST" | |
11415 | : "NON_EXIST", | |
11416 | filter->advmap.cmap ? "*" : "", | |
11417 | filter->advmap.cname, | |
11418 | filter->advmap.amap ? "*" : "", | |
11419 | filter->advmap.aname, | |
11420 | filter->advmap.status ? "Advertise" | |
11421 | : "Withdraw"); | |
11422 | ||
d62a17ae | 11423 | /* Receive prefix count */ |
6cde4b45 | 11424 | vty_out(vty, " %u accepted prefixes\n", |
a0a87037 | 11425 | p->pcount[afi][safi]); |
d62a17ae | 11426 | |
fde246e8 DA |
11427 | /* maximum-prefix-out */ |
11428 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
11429 | PEER_FLAG_MAX_PREFIX_OUT)) | |
11430 | vty_out(vty, | |
6cde4b45 | 11431 | " Maximum allowed prefixes sent %u\n", |
fde246e8 DA |
11432 | p->pmax_out[afi][safi]); |
11433 | ||
d62a17ae | 11434 | /* Maximum prefix */ |
11435 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 | 11436 | vty_out(vty, |
6cde4b45 | 11437 | " Maximum prefixes allowed %u%s\n", |
d62a17ae | 11438 | p->pmax[afi][safi], |
11439 | CHECK_FLAG(p->af_flags[afi][safi], | |
11440 | PEER_FLAG_MAX_PREFIX_WARNING) | |
11441 | ? " (warning-only)" | |
11442 | : ""); | |
11443 | vty_out(vty, " Threshold for warning message %d%%", | |
11444 | p->pmax_threshold[afi][safi]); | |
11445 | if (p->pmax_restart[afi][safi]) | |
11446 | vty_out(vty, ", restart interval %d min", | |
11447 | p->pmax_restart[afi][safi]); | |
11448 | vty_out(vty, "\n"); | |
11449 | } | |
11450 | ||
11451 | vty_out(vty, "\n"); | |
11452 | } | |
11453 | } | |
11454 | ||
9f049418 | 11455 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 11456 | json_object *json) |
718e3744 | 11457 | { |
d62a17ae | 11458 | struct bgp *bgp; |
11459 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
11460 | char timebuf[BGP_UPTIME_LEN]; | |
11461 | char dn_flag[2]; | |
d62a17ae | 11462 | afi_t afi; |
11463 | safi_t safi; | |
d7c0a89a QY |
11464 | uint16_t i; |
11465 | uint8_t *msg; | |
d62a17ae | 11466 | json_object *json_neigh = NULL; |
11467 | time_t epoch_tbuf; | |
718e3744 | 11468 | |
d62a17ae | 11469 | bgp = p->bgp; |
11470 | ||
11471 | if (use_json) | |
11472 | json_neigh = json_object_new_object(); | |
11473 | ||
11474 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
11475 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
11476 | dn_flag[0] = '*'; | |
11477 | ||
11478 | if (!use_json) { | |
11479 | if (p->conf_if) /* Configured interface name. */ | |
11480 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
11481 | BGP_PEER_SU_UNSPEC(p) | |
11482 | ? "None" | |
11483 | : sockunion2str(&p->su, buf, | |
11484 | SU_ADDRSTRLEN)); | |
11485 | else /* Configured IP address. */ | |
11486 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
11487 | p->host); | |
11488 | } | |
11489 | ||
11490 | if (use_json) { | |
11491 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
11492 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
11493 | "none"); | |
11494 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
11495 | json_object_string_add( | |
11496 | json_neigh, "bgpNeighborAddr", | |
11497 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
11498 | ||
11499 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
11500 | ||
11501 | if (p->change_local_as) | |
11502 | json_object_int_add(json_neigh, "localAs", | |
11503 | p->change_local_as); | |
11504 | else | |
11505 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
11506 | ||
11507 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
11508 | json_object_boolean_true_add(json_neigh, | |
11509 | "localAsNoPrepend"); | |
11510 | ||
11511 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
11512 | json_object_boolean_true_add(json_neigh, | |
11513 | "localAsReplaceAs"); | |
11514 | } else { | |
11515 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
11516 | || (p->as_type == AS_INTERNAL)) | |
11517 | vty_out(vty, "remote AS %u, ", p->as); | |
11518 | else | |
11519 | vty_out(vty, "remote AS Unspecified, "); | |
11520 | vty_out(vty, "local AS %u%s%s, ", | |
11521 | p->change_local_as ? p->change_local_as : p->local_as, | |
11522 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
11523 | ? " no-prepend" | |
11524 | : "", | |
11525 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
11526 | ? " replace-as" | |
11527 | : ""); | |
11528 | } | |
faa16034 DS |
11529 | /* peer type internal or confed-internal */ |
11530 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 11531 | if (use_json) { |
11532 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
11533 | json_object_boolean_true_add( | |
11534 | json_neigh, "nbrConfedInternalLink"); | |
11535 | else | |
11536 | json_object_boolean_true_add(json_neigh, | |
11537 | "nbrInternalLink"); | |
11538 | } else { | |
11539 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
11540 | vty_out(vty, "confed-internal link\n"); | |
11541 | else | |
11542 | vty_out(vty, "internal link\n"); | |
11543 | } | |
faa16034 DS |
11544 | /* peer type external or confed-external */ |
11545 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 11546 | if (use_json) { |
11547 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
11548 | json_object_boolean_true_add( | |
11549 | json_neigh, "nbrConfedExternalLink"); | |
11550 | else | |
11551 | json_object_boolean_true_add(json_neigh, | |
11552 | "nbrExternalLink"); | |
11553 | } else { | |
11554 | if (bgp_confederation_peers_check(bgp, p->as)) | |
11555 | vty_out(vty, "confed-external link\n"); | |
11556 | else | |
11557 | vty_out(vty, "external link\n"); | |
11558 | } | |
faa16034 DS |
11559 | } else { |
11560 | if (use_json) | |
11561 | json_object_boolean_true_add(json_neigh, | |
11562 | "nbrUnspecifiedLink"); | |
11563 | else | |
11564 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 11565 | } |
11566 | ||
11567 | /* Description. */ | |
11568 | if (p->desc) { | |
11569 | if (use_json) | |
11570 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
11571 | else | |
11572 | vty_out(vty, " Description: %s\n", p->desc); | |
11573 | } | |
11574 | ||
11575 | if (p->hostname) { | |
11576 | if (use_json) { | |
11577 | if (p->hostname) | |
11578 | json_object_string_add(json_neigh, "hostname", | |
11579 | p->hostname); | |
11580 | ||
11581 | if (p->domainname) | |
11582 | json_object_string_add(json_neigh, "domainname", | |
11583 | p->domainname); | |
11584 | } else { | |
11585 | if (p->domainname && (p->domainname[0] != '\0')) | |
11586 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
11587 | p->domainname); | |
11588 | else | |
11589 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
11590 | } | |
11591 | } | |
11592 | ||
11593 | /* Peer-group */ | |
11594 | if (p->group) { | |
11595 | if (use_json) { | |
11596 | json_object_string_add(json_neigh, "peerGroup", | |
11597 | p->group->name); | |
11598 | ||
11599 | if (dn_flag[0]) { | |
11600 | struct prefix prefix, *range = NULL; | |
11601 | ||
11602 | sockunion2hostprefix(&(p->su), &prefix); | |
11603 | range = peer_group_lookup_dynamic_neighbor_range( | |
11604 | p->group, &prefix); | |
11605 | ||
11606 | if (range) { | |
11607 | prefix2str(range, buf1, sizeof(buf1)); | |
11608 | json_object_string_add( | |
11609 | json_neigh, | |
11610 | "peerSubnetRangeGroup", buf1); | |
11611 | } | |
11612 | } | |
11613 | } else { | |
11614 | vty_out(vty, | |
11615 | " Member of peer-group %s for session parameters\n", | |
11616 | p->group->name); | |
11617 | ||
11618 | if (dn_flag[0]) { | |
11619 | struct prefix prefix, *range = NULL; | |
11620 | ||
11621 | sockunion2hostprefix(&(p->su), &prefix); | |
11622 | range = peer_group_lookup_dynamic_neighbor_range( | |
11623 | p->group, &prefix); | |
11624 | ||
11625 | if (range) { | |
d62a17ae | 11626 | vty_out(vty, |
1b78780b DL |
11627 | " Belongs to the subnet range group: %pFX\n", |
11628 | range); | |
d62a17ae | 11629 | } |
11630 | } | |
11631 | } | |
11632 | } | |
11633 | ||
11634 | if (use_json) { | |
11635 | /* Administrative shutdown. */ | |
cb9196e7 DS |
11636 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
11637 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 11638 | json_object_boolean_true_add(json_neigh, |
11639 | "adminShutDown"); | |
11640 | ||
11641 | /* BGP Version. */ | |
11642 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
11643 | json_object_string_add( | |
11644 | json_neigh, "remoteRouterId", | |
11645 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
11646 | json_object_string_add( |
11647 | json_neigh, "localRouterId", | |
11648 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
11649 | sizeof(buf1))); | |
d62a17ae | 11650 | |
11651 | /* Confederation */ | |
11652 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
11653 | && bgp_confederation_peers_check(bgp, p->as)) | |
11654 | json_object_boolean_true_add(json_neigh, | |
11655 | "nbrCommonAdmin"); | |
11656 | ||
11657 | /* Status. */ | |
11658 | json_object_string_add( | |
11659 | json_neigh, "bgpState", | |
11660 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
11661 | ||
11662 | if (p->status == Established) { | |
11663 | time_t uptime; | |
d62a17ae | 11664 | |
11665 | uptime = bgp_clock(); | |
11666 | uptime -= p->uptime; | |
d62a17ae | 11667 | epoch_tbuf = time(NULL) - uptime; |
11668 | ||
d3c7efed DS |
11669 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
11670 | uptime * 1000); | |
d62a17ae | 11671 | json_object_string_add(json_neigh, "bgpTimerUpString", |
11672 | peer_uptime(p->uptime, timebuf, | |
11673 | BGP_UPTIME_LEN, 0, | |
11674 | NULL)); | |
11675 | json_object_int_add(json_neigh, | |
11676 | "bgpTimerUpEstablishedEpoch", | |
11677 | epoch_tbuf); | |
11678 | } | |
11679 | ||
11680 | else if (p->status == Active) { | |
11681 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11682 | json_object_string_add(json_neigh, "bgpStateIs", | |
11683 | "passive"); | |
11684 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11685 | json_object_string_add(json_neigh, "bgpStateIs", | |
11686 | "passiveNSF"); | |
11687 | } | |
11688 | ||
11689 | /* read timer */ | |
11690 | time_t uptime; | |
a2700b50 | 11691 | struct tm tm; |
d62a17ae | 11692 | |
11693 | uptime = bgp_clock(); | |
11694 | uptime -= p->readtime; | |
a2700b50 MS |
11695 | gmtime_r(&uptime, &tm); |
11696 | ||
d62a17ae | 11697 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
11698 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11699 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11700 | |
11701 | uptime = bgp_clock(); | |
11702 | uptime -= p->last_write; | |
a2700b50 MS |
11703 | gmtime_r(&uptime, &tm); |
11704 | ||
d62a17ae | 11705 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
11706 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11707 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11708 | |
11709 | uptime = bgp_clock(); | |
11710 | uptime -= p->update_time; | |
a2700b50 MS |
11711 | gmtime_r(&uptime, &tm); |
11712 | ||
d62a17ae | 11713 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
11714 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
11715 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 11716 | |
11717 | /* Configured timer values. */ | |
11718 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
11719 | p->v_holdtime * 1000); | |
11720 | json_object_int_add(json_neigh, | |
11721 | "bgpTimerKeepAliveIntervalMsecs", | |
11722 | p->v_keepalive * 1000); | |
b90a8e13 | 11723 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11724 | json_object_int_add(json_neigh, |
11725 | "bgpTimerConfiguredHoldTimeMsecs", | |
11726 | p->holdtime * 1000); | |
11727 | json_object_int_add( | |
11728 | json_neigh, | |
11729 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11730 | p->keepalive * 1000); | |
5d5393b9 DL |
11731 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11732 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11733 | json_object_int_add(json_neigh, |
11734 | "bgpTimerConfiguredHoldTimeMsecs", | |
11735 | bgp->default_holdtime); | |
11736 | json_object_int_add( | |
11737 | json_neigh, | |
11738 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
11739 | bgp->default_keepalive); | |
d62a17ae | 11740 | } |
11741 | } else { | |
11742 | /* Administrative shutdown. */ | |
cb9196e7 DS |
11743 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN) |
11744 | || CHECK_FLAG(p->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 11745 | vty_out(vty, " Administratively shut down\n"); |
11746 | ||
11747 | /* BGP Version. */ | |
11748 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 11749 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 11750 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
11751 | vty_out(vty, ", local router ID %s\n", |
11752 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
11753 | sizeof(buf1))); | |
d62a17ae | 11754 | |
11755 | /* Confederation */ | |
11756 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
11757 | && bgp_confederation_peers_check(bgp, p->as)) | |
11758 | vty_out(vty, | |
11759 | " Neighbor under common administration\n"); | |
11760 | ||
11761 | /* Status. */ | |
11762 | vty_out(vty, " BGP state = %s", | |
11763 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
11764 | ||
11765 | if (p->status == Established) | |
11766 | vty_out(vty, ", up for %8s", | |
11767 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
11768 | 0, NULL)); | |
11769 | ||
11770 | else if (p->status == Active) { | |
11771 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11772 | vty_out(vty, " (passive)"); | |
11773 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11774 | vty_out(vty, " (NSF passive)"); | |
11775 | } | |
11776 | vty_out(vty, "\n"); | |
11777 | ||
11778 | /* read timer */ | |
11779 | vty_out(vty, " Last read %s", | |
11780 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
11781 | NULL)); | |
11782 | vty_out(vty, ", Last write %s\n", | |
11783 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
11784 | NULL)); | |
11785 | ||
11786 | /* Configured timer values. */ | |
11787 | vty_out(vty, | |
11788 | " Hold time is %d, keepalive interval is %d seconds\n", | |
11789 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 11790 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11791 | vty_out(vty, " Configured hold time is %d", |
11792 | p->holdtime); | |
11793 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11794 | p->keepalive); | |
5d5393b9 DL |
11795 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11796 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11797 | vty_out(vty, " Configured hold time is %d", |
11798 | bgp->default_holdtime); | |
11799 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11800 | bgp->default_keepalive); | |
d62a17ae | 11801 | } |
11802 | } | |
11803 | /* Capability. */ | |
11804 | if (p->status == Established) { | |
11805 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
11806 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
11807 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
11808 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
11809 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
11810 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
11811 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
11812 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
11813 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
11814 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
11815 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
11816 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 11817 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
11818 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 11819 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
11820 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 11821 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
11822 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 11823 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
11824 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
11825 | if (use_json) { | |
11826 | json_object *json_cap = NULL; | |
11827 | ||
11828 | json_cap = json_object_new_object(); | |
11829 | ||
11830 | /* AS4 */ | |
11831 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11832 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11833 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
11834 | && CHECK_FLAG(p->cap, | |
11835 | PEER_CAP_AS4_RCV)) | |
11836 | json_object_string_add( | |
11837 | json_cap, "4byteAs", | |
11838 | "advertisedAndReceived"); | |
11839 | else if (CHECK_FLAG(p->cap, | |
11840 | PEER_CAP_AS4_ADV)) | |
11841 | json_object_string_add( | |
11842 | json_cap, "4byteAs", | |
11843 | "advertised"); | |
11844 | else if (CHECK_FLAG(p->cap, | |
11845 | PEER_CAP_AS4_RCV)) | |
11846 | json_object_string_add( | |
11847 | json_cap, "4byteAs", | |
11848 | "received"); | |
11849 | } | |
11850 | ||
11851 | /* AddPath */ | |
11852 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11853 | || CHECK_FLAG(p->cap, | |
11854 | PEER_CAP_ADDPATH_ADV)) { | |
11855 | json_object *json_add = NULL; | |
11856 | const char *print_store; | |
11857 | ||
11858 | json_add = json_object_new_object(); | |
11859 | ||
05c7a1cc QY |
11860 | FOREACH_AFI_SAFI (afi, safi) { |
11861 | json_object *json_sub = NULL; | |
11862 | json_sub = | |
11863 | json_object_new_object(); | |
5cb5f4d0 DD |
11864 | print_store = get_afi_safi_str( |
11865 | afi, safi, true); | |
d62a17ae | 11866 | |
05c7a1cc QY |
11867 | if (CHECK_FLAG( |
11868 | p->af_cap[afi] | |
11869 | [safi], | |
11870 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11871 | || CHECK_FLAG( | |
11872 | p->af_cap[afi] | |
11873 | [safi], | |
11874 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 11875 | if (CHECK_FLAG( |
11876 | p->af_cap | |
11877 | [afi] | |
11878 | [safi], | |
11879 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 11880 | && CHECK_FLAG( |
d62a17ae | 11881 | p->af_cap |
11882 | [afi] | |
11883 | [safi], | |
05c7a1cc QY |
11884 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
11885 | json_object_boolean_true_add( | |
11886 | json_sub, | |
11887 | "txAdvertisedAndReceived"); | |
11888 | else if ( | |
11889 | CHECK_FLAG( | |
11890 | p->af_cap | |
11891 | [afi] | |
11892 | [safi], | |
11893 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
11894 | json_object_boolean_true_add( | |
11895 | json_sub, | |
11896 | "txAdvertised"); | |
11897 | else if ( | |
11898 | CHECK_FLAG( | |
11899 | p->af_cap | |
11900 | [afi] | |
11901 | [safi], | |
11902 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11903 | json_object_boolean_true_add( | |
11904 | json_sub, | |
11905 | "txReceived"); | |
11906 | } | |
d62a17ae | 11907 | |
05c7a1cc QY |
11908 | if (CHECK_FLAG( |
11909 | p->af_cap[afi] | |
11910 | [safi], | |
11911 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11912 | || CHECK_FLAG( | |
11913 | p->af_cap[afi] | |
11914 | [safi], | |
11915 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 11916 | if (CHECK_FLAG( |
11917 | p->af_cap | |
11918 | [afi] | |
11919 | [safi], | |
11920 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 11921 | && CHECK_FLAG( |
d62a17ae | 11922 | p->af_cap |
11923 | [afi] | |
11924 | [safi], | |
11925 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
11926 | json_object_boolean_true_add( |
11927 | json_sub, | |
11928 | "rxAdvertisedAndReceived"); | |
11929 | else if ( | |
11930 | CHECK_FLAG( | |
11931 | p->af_cap | |
11932 | [afi] | |
11933 | [safi], | |
11934 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
11935 | json_object_boolean_true_add( | |
11936 | json_sub, | |
11937 | "rxAdvertised"); | |
11938 | else if ( | |
11939 | CHECK_FLAG( | |
11940 | p->af_cap | |
11941 | [afi] | |
11942 | [safi], | |
11943 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11944 | json_object_boolean_true_add( | |
11945 | json_sub, | |
11946 | "rxReceived"); | |
d62a17ae | 11947 | } |
11948 | ||
05c7a1cc QY |
11949 | if (CHECK_FLAG( |
11950 | p->af_cap[afi] | |
11951 | [safi], | |
11952 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11953 | || CHECK_FLAG( | |
11954 | p->af_cap[afi] | |
11955 | [safi], | |
11956 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
11957 | || CHECK_FLAG( | |
11958 | p->af_cap[afi] | |
11959 | [safi], | |
11960 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11961 | || CHECK_FLAG( | |
11962 | p->af_cap[afi] | |
11963 | [safi], | |
11964 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11965 | json_object_object_add( | |
11966 | json_add, | |
11967 | print_store, | |
11968 | json_sub); | |
11969 | else | |
11970 | json_object_free( | |
11971 | json_sub); | |
11972 | } | |
11973 | ||
d62a17ae | 11974 | json_object_object_add( |
11975 | json_cap, "addPath", json_add); | |
11976 | } | |
11977 | ||
11978 | /* Dynamic */ | |
11979 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11980 | || CHECK_FLAG(p->cap, | |
11981 | PEER_CAP_DYNAMIC_ADV)) { | |
11982 | if (CHECK_FLAG(p->cap, | |
11983 | PEER_CAP_DYNAMIC_ADV) | |
11984 | && CHECK_FLAG(p->cap, | |
11985 | PEER_CAP_DYNAMIC_RCV)) | |
11986 | json_object_string_add( | |
11987 | json_cap, "dynamic", | |
11988 | "advertisedAndReceived"); | |
11989 | else if (CHECK_FLAG( | |
11990 | p->cap, | |
11991 | PEER_CAP_DYNAMIC_ADV)) | |
11992 | json_object_string_add( | |
11993 | json_cap, "dynamic", | |
11994 | "advertised"); | |
11995 | else if (CHECK_FLAG( | |
11996 | p->cap, | |
11997 | PEER_CAP_DYNAMIC_RCV)) | |
11998 | json_object_string_add( | |
11999 | json_cap, "dynamic", | |
12000 | "received"); | |
12001 | } | |
12002 | ||
12003 | /* Extended nexthop */ | |
12004 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12005 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12006 | json_object *json_nxt = NULL; | |
12007 | const char *print_store; | |
12008 | ||
12009 | ||
12010 | if (CHECK_FLAG(p->cap, | |
12011 | PEER_CAP_ENHE_ADV) | |
12012 | && CHECK_FLAG(p->cap, | |
12013 | PEER_CAP_ENHE_RCV)) | |
12014 | json_object_string_add( | |
12015 | json_cap, | |
12016 | "extendedNexthop", | |
12017 | "advertisedAndReceived"); | |
12018 | else if (CHECK_FLAG(p->cap, | |
12019 | PEER_CAP_ENHE_ADV)) | |
12020 | json_object_string_add( | |
12021 | json_cap, | |
12022 | "extendedNexthop", | |
12023 | "advertised"); | |
12024 | else if (CHECK_FLAG(p->cap, | |
12025 | PEER_CAP_ENHE_RCV)) | |
12026 | json_object_string_add( | |
12027 | json_cap, | |
12028 | "extendedNexthop", | |
12029 | "received"); | |
12030 | ||
12031 | if (CHECK_FLAG(p->cap, | |
12032 | PEER_CAP_ENHE_RCV)) { | |
12033 | json_nxt = | |
12034 | json_object_new_object(); | |
12035 | ||
12036 | for (safi = SAFI_UNICAST; | |
12037 | safi < SAFI_MAX; safi++) { | |
12038 | if (CHECK_FLAG( | |
12039 | p->af_cap | |
12040 | [AFI_IP] | |
12041 | [safi], | |
12042 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 12043 | print_store = get_afi_safi_str( |
d62a17ae | 12044 | AFI_IP, |
5cb5f4d0 | 12045 | safi, true); |
d62a17ae | 12046 | json_object_string_add( |
12047 | json_nxt, | |
12048 | print_store, | |
54f29523 | 12049 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 12050 | } |
12051 | } | |
12052 | json_object_object_add( | |
12053 | json_cap, | |
12054 | "extendedNexthopFamililesByPeer", | |
12055 | json_nxt); | |
12056 | } | |
12057 | } | |
12058 | ||
12059 | /* Route Refresh */ | |
12060 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12061 | || CHECK_FLAG(p->cap, | |
12062 | PEER_CAP_REFRESH_NEW_RCV) | |
12063 | || CHECK_FLAG(p->cap, | |
12064 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12065 | if (CHECK_FLAG(p->cap, | |
12066 | PEER_CAP_REFRESH_ADV) | |
12067 | && (CHECK_FLAG( | |
12068 | p->cap, | |
12069 | PEER_CAP_REFRESH_NEW_RCV) | |
12070 | || CHECK_FLAG( | |
12071 | p->cap, | |
12072 | PEER_CAP_REFRESH_OLD_RCV))) { | |
12073 | if (CHECK_FLAG( | |
12074 | p->cap, | |
12075 | PEER_CAP_REFRESH_OLD_RCV) | |
12076 | && CHECK_FLAG( | |
12077 | p->cap, | |
12078 | PEER_CAP_REFRESH_NEW_RCV)) | |
12079 | json_object_string_add( | |
12080 | json_cap, | |
12081 | "routeRefresh", | |
12082 | "advertisedAndReceivedOldNew"); | |
12083 | else { | |
12084 | if (CHECK_FLAG( | |
12085 | p->cap, | |
12086 | PEER_CAP_REFRESH_OLD_RCV)) | |
12087 | json_object_string_add( | |
12088 | json_cap, | |
12089 | "routeRefresh", | |
12090 | "advertisedAndReceivedOld"); | |
12091 | else | |
12092 | json_object_string_add( | |
12093 | json_cap, | |
12094 | "routeRefresh", | |
12095 | "advertisedAndReceivedNew"); | |
12096 | } | |
12097 | } else if ( | |
12098 | CHECK_FLAG( | |
12099 | p->cap, | |
12100 | PEER_CAP_REFRESH_ADV)) | |
12101 | json_object_string_add( | |
12102 | json_cap, | |
12103 | "routeRefresh", | |
12104 | "advertised"); | |
12105 | else if ( | |
12106 | CHECK_FLAG( | |
12107 | p->cap, | |
12108 | PEER_CAP_REFRESH_NEW_RCV) | |
12109 | || CHECK_FLAG( | |
12110 | p->cap, | |
12111 | PEER_CAP_REFRESH_OLD_RCV)) | |
12112 | json_object_string_add( | |
12113 | json_cap, | |
12114 | "routeRefresh", | |
12115 | "received"); | |
12116 | } | |
12117 | ||
12118 | /* Multiprotocol Extensions */ | |
12119 | json_object *json_multi = NULL; | |
12120 | json_multi = json_object_new_object(); | |
12121 | ||
05c7a1cc QY |
12122 | FOREACH_AFI_SAFI (afi, safi) { |
12123 | if (p->afc_adv[afi][safi] | |
12124 | || p->afc_recv[afi][safi]) { | |
12125 | json_object *json_exten = NULL; | |
12126 | json_exten = | |
12127 | json_object_new_object(); | |
12128 | ||
d62a17ae | 12129 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
12130 | && p->afc_recv[afi][safi]) |
12131 | json_object_boolean_true_add( | |
12132 | json_exten, | |
12133 | "advertisedAndReceived"); | |
12134 | else if (p->afc_adv[afi][safi]) | |
12135 | json_object_boolean_true_add( | |
12136 | json_exten, | |
12137 | "advertised"); | |
12138 | else if (p->afc_recv[afi][safi]) | |
12139 | json_object_boolean_true_add( | |
12140 | json_exten, | |
12141 | "received"); | |
d62a17ae | 12142 | |
05c7a1cc QY |
12143 | json_object_object_add( |
12144 | json_multi, | |
5cb5f4d0 DD |
12145 | get_afi_safi_str(afi, |
12146 | safi, | |
12147 | true), | |
05c7a1cc | 12148 | json_exten); |
d62a17ae | 12149 | } |
12150 | } | |
12151 | json_object_object_add( | |
12152 | json_cap, "multiprotocolExtensions", | |
12153 | json_multi); | |
12154 | ||
d77114b7 | 12155 | /* Hostname capabilities */ |
60466a63 | 12156 | json_object *json_hname = NULL; |
d77114b7 MK |
12157 | |
12158 | json_hname = json_object_new_object(); | |
12159 | ||
12160 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
12161 | json_object_string_add( | |
60466a63 QY |
12162 | json_hname, "advHostName", |
12163 | bgp->peer_self->hostname | |
12164 | ? bgp->peer_self | |
12165 | ->hostname | |
d77114b7 MK |
12166 | : "n/a"); |
12167 | json_object_string_add( | |
60466a63 QY |
12168 | json_hname, "advDomainName", |
12169 | bgp->peer_self->domainname | |
12170 | ? bgp->peer_self | |
12171 | ->domainname | |
d77114b7 MK |
12172 | : "n/a"); |
12173 | } | |
12174 | ||
12175 | ||
12176 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
12177 | json_object_string_add( | |
60466a63 QY |
12178 | json_hname, "rcvHostName", |
12179 | p->hostname ? p->hostname | |
12180 | : "n/a"); | |
d77114b7 | 12181 | json_object_string_add( |
60466a63 QY |
12182 | json_hname, "rcvDomainName", |
12183 | p->domainname ? p->domainname | |
12184 | : "n/a"); | |
d77114b7 MK |
12185 | } |
12186 | ||
60466a63 | 12187 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
12188 | json_hname); |
12189 | ||
d62a17ae | 12190 | /* Gracefull Restart */ |
12191 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
12192 | || CHECK_FLAG(p->cap, | |
12193 | PEER_CAP_RESTART_ADV)) { | |
12194 | if (CHECK_FLAG(p->cap, | |
12195 | PEER_CAP_RESTART_ADV) | |
12196 | && CHECK_FLAG(p->cap, | |
12197 | PEER_CAP_RESTART_RCV)) | |
12198 | json_object_string_add( | |
12199 | json_cap, | |
12200 | "gracefulRestart", | |
12201 | "advertisedAndReceived"); | |
12202 | else if (CHECK_FLAG( | |
12203 | p->cap, | |
12204 | PEER_CAP_RESTART_ADV)) | |
12205 | json_object_string_add( | |
12206 | json_cap, | |
12207 | "gracefulRestartCapability", | |
12208 | "advertised"); | |
12209 | else if (CHECK_FLAG( | |
12210 | p->cap, | |
12211 | PEER_CAP_RESTART_RCV)) | |
12212 | json_object_string_add( | |
12213 | json_cap, | |
12214 | "gracefulRestartCapability", | |
12215 | "received"); | |
12216 | ||
12217 | if (CHECK_FLAG(p->cap, | |
12218 | PEER_CAP_RESTART_RCV)) { | |
12219 | int restart_af_count = 0; | |
12220 | json_object *json_restart = | |
12221 | NULL; | |
12222 | json_restart = | |
12223 | json_object_new_object(); | |
12224 | ||
12225 | json_object_int_add( | |
12226 | json_cap, | |
12227 | "gracefulRestartRemoteTimerMsecs", | |
12228 | p->v_gr_restart * 1000); | |
12229 | ||
05c7a1cc QY |
12230 | FOREACH_AFI_SAFI (afi, safi) { |
12231 | if (CHECK_FLAG( | |
12232 | p->af_cap | |
12233 | [afi] | |
12234 | [safi], | |
12235 | PEER_CAP_RESTART_AF_RCV)) { | |
12236 | json_object * | |
12237 | json_sub = | |
12238 | NULL; | |
12239 | json_sub = | |
12240 | json_object_new_object(); | |
12241 | ||
d62a17ae | 12242 | if (CHECK_FLAG( |
12243 | p->af_cap | |
12244 | [afi] | |
12245 | [safi], | |
05c7a1cc QY |
12246 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
12247 | json_object_boolean_true_add( | |
12248 | json_sub, | |
12249 | "preserved"); | |
12250 | restart_af_count++; | |
12251 | json_object_object_add( | |
12252 | json_restart, | |
5cb5f4d0 | 12253 | get_afi_safi_str( |
05c7a1cc | 12254 | afi, |
5cb5f4d0 DD |
12255 | safi, |
12256 | true), | |
05c7a1cc | 12257 | json_sub); |
d62a17ae | 12258 | } |
12259 | } | |
12260 | if (!restart_af_count) { | |
12261 | json_object_string_add( | |
12262 | json_cap, | |
12263 | "addressFamiliesByPeer", | |
12264 | "none"); | |
12265 | json_object_free( | |
12266 | json_restart); | |
12267 | } else | |
12268 | json_object_object_add( | |
12269 | json_cap, | |
12270 | "addressFamiliesByPeer", | |
12271 | json_restart); | |
12272 | } | |
12273 | } | |
12274 | json_object_object_add(json_neigh, | |
12275 | "neighborCapabilities", | |
12276 | json_cap); | |
12277 | } else { | |
12278 | vty_out(vty, " Neighbor capabilities:\n"); | |
12279 | ||
12280 | /* AS4 */ | |
12281 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
12282 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
12283 | vty_out(vty, " 4 Byte AS:"); | |
12284 | if (CHECK_FLAG(p->cap, | |
12285 | PEER_CAP_AS4_ADV)) | |
12286 | vty_out(vty, " advertised"); | |
12287 | if (CHECK_FLAG(p->cap, | |
12288 | PEER_CAP_AS4_RCV)) | |
12289 | vty_out(vty, " %sreceived", | |
12290 | CHECK_FLAG( | |
12291 | p->cap, | |
12292 | PEER_CAP_AS4_ADV) | |
12293 | ? "and " | |
12294 | : ""); | |
12295 | vty_out(vty, "\n"); | |
12296 | } | |
12297 | ||
12298 | /* AddPath */ | |
12299 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
12300 | || CHECK_FLAG(p->cap, | |
12301 | PEER_CAP_ADDPATH_ADV)) { | |
12302 | vty_out(vty, " AddPath:\n"); | |
12303 | ||
05c7a1cc QY |
12304 | FOREACH_AFI_SAFI (afi, safi) { |
12305 | if (CHECK_FLAG( | |
12306 | p->af_cap[afi] | |
12307 | [safi], | |
12308 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12309 | || CHECK_FLAG( | |
12310 | p->af_cap[afi] | |
12311 | [safi], | |
12312 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
12313 | vty_out(vty, | |
12314 | " %s: TX ", | |
5cb5f4d0 | 12315 | get_afi_safi_str( |
05c7a1cc | 12316 | afi, |
5cb5f4d0 DD |
12317 | safi, |
12318 | false)); | |
05c7a1cc | 12319 | |
d62a17ae | 12320 | if (CHECK_FLAG( |
12321 | p->af_cap | |
12322 | [afi] | |
12323 | [safi], | |
05c7a1cc | 12324 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 12325 | vty_out(vty, |
05c7a1cc | 12326 | "advertised %s", |
5cb5f4d0 | 12327 | get_afi_safi_str( |
d62a17ae | 12328 | afi, |
5cb5f4d0 DD |
12329 | safi, |
12330 | false)); | |
d62a17ae | 12331 | |
05c7a1cc QY |
12332 | if (CHECK_FLAG( |
12333 | p->af_cap | |
12334 | [afi] | |
12335 | [safi], | |
12336 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
12337 | vty_out(vty, | |
12338 | "%sreceived", | |
12339 | CHECK_FLAG( | |
12340 | p->af_cap | |
12341 | [afi] | |
12342 | [safi], | |
12343 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
12344 | ? " and " | |
12345 | : ""); | |
d62a17ae | 12346 | |
05c7a1cc QY |
12347 | vty_out(vty, "\n"); |
12348 | } | |
d62a17ae | 12349 | |
05c7a1cc QY |
12350 | if (CHECK_FLAG( |
12351 | p->af_cap[afi] | |
12352 | [safi], | |
12353 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12354 | || CHECK_FLAG( | |
12355 | p->af_cap[afi] | |
12356 | [safi], | |
12357 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
12358 | vty_out(vty, | |
12359 | " %s: RX ", | |
5cb5f4d0 | 12360 | get_afi_safi_str( |
05c7a1cc | 12361 | afi, |
5cb5f4d0 DD |
12362 | safi, |
12363 | false)); | |
d62a17ae | 12364 | |
12365 | if (CHECK_FLAG( | |
12366 | p->af_cap | |
12367 | [afi] | |
12368 | [safi], | |
05c7a1cc | 12369 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 12370 | vty_out(vty, |
05c7a1cc | 12371 | "advertised %s", |
5cb5f4d0 | 12372 | get_afi_safi_str( |
d62a17ae | 12373 | afi, |
5cb5f4d0 DD |
12374 | safi, |
12375 | false)); | |
d62a17ae | 12376 | |
05c7a1cc QY |
12377 | if (CHECK_FLAG( |
12378 | p->af_cap | |
12379 | [afi] | |
12380 | [safi], | |
12381 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 12382 | vty_out(vty, |
05c7a1cc QY |
12383 | "%sreceived", |
12384 | CHECK_FLAG( | |
12385 | p->af_cap | |
12386 | [afi] | |
12387 | [safi], | |
12388 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
12389 | ? " and " | |
12390 | : ""); | |
12391 | ||
12392 | vty_out(vty, "\n"); | |
d62a17ae | 12393 | } |
05c7a1cc | 12394 | } |
d62a17ae | 12395 | } |
12396 | ||
12397 | /* Dynamic */ | |
12398 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
12399 | || CHECK_FLAG(p->cap, | |
12400 | PEER_CAP_DYNAMIC_ADV)) { | |
12401 | vty_out(vty, " Dynamic:"); | |
12402 | if (CHECK_FLAG(p->cap, | |
12403 | PEER_CAP_DYNAMIC_ADV)) | |
12404 | vty_out(vty, " advertised"); | |
12405 | if (CHECK_FLAG(p->cap, | |
12406 | PEER_CAP_DYNAMIC_RCV)) | |
12407 | vty_out(vty, " %sreceived", | |
12408 | CHECK_FLAG( | |
12409 | p->cap, | |
12410 | PEER_CAP_DYNAMIC_ADV) | |
12411 | ? "and " | |
12412 | : ""); | |
12413 | vty_out(vty, "\n"); | |
12414 | } | |
12415 | ||
12416 | /* Extended nexthop */ | |
12417 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
12418 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
12419 | vty_out(vty, " Extended nexthop:"); | |
12420 | if (CHECK_FLAG(p->cap, | |
12421 | PEER_CAP_ENHE_ADV)) | |
12422 | vty_out(vty, " advertised"); | |
12423 | if (CHECK_FLAG(p->cap, | |
12424 | PEER_CAP_ENHE_RCV)) | |
12425 | vty_out(vty, " %sreceived", | |
12426 | CHECK_FLAG( | |
12427 | p->cap, | |
12428 | PEER_CAP_ENHE_ADV) | |
12429 | ? "and " | |
12430 | : ""); | |
12431 | vty_out(vty, "\n"); | |
12432 | ||
12433 | if (CHECK_FLAG(p->cap, | |
12434 | PEER_CAP_ENHE_RCV)) { | |
12435 | vty_out(vty, | |
12436 | " Address families by peer:\n "); | |
12437 | for (safi = SAFI_UNICAST; | |
12438 | safi < SAFI_MAX; safi++) | |
12439 | if (CHECK_FLAG( | |
12440 | p->af_cap | |
12441 | [AFI_IP] | |
12442 | [safi], | |
12443 | PEER_CAP_ENHE_AF_RCV)) | |
12444 | vty_out(vty, | |
12445 | " %s\n", | |
5cb5f4d0 | 12446 | get_afi_safi_str( |
d62a17ae | 12447 | AFI_IP, |
5cb5f4d0 DD |
12448 | safi, |
12449 | false)); | |
d62a17ae | 12450 | } |
12451 | } | |
12452 | ||
12453 | /* Route Refresh */ | |
12454 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
12455 | || CHECK_FLAG(p->cap, | |
12456 | PEER_CAP_REFRESH_NEW_RCV) | |
12457 | || CHECK_FLAG(p->cap, | |
12458 | PEER_CAP_REFRESH_OLD_RCV)) { | |
12459 | vty_out(vty, " Route refresh:"); | |
12460 | if (CHECK_FLAG(p->cap, | |
12461 | PEER_CAP_REFRESH_ADV)) | |
12462 | vty_out(vty, " advertised"); | |
12463 | if (CHECK_FLAG(p->cap, | |
12464 | PEER_CAP_REFRESH_NEW_RCV) | |
12465 | || CHECK_FLAG( | |
12466 | p->cap, | |
12467 | PEER_CAP_REFRESH_OLD_RCV)) | |
12468 | vty_out(vty, " %sreceived(%s)", | |
12469 | CHECK_FLAG( | |
12470 | p->cap, | |
12471 | PEER_CAP_REFRESH_ADV) | |
12472 | ? "and " | |
12473 | : "", | |
12474 | (CHECK_FLAG( | |
12475 | p->cap, | |
12476 | PEER_CAP_REFRESH_OLD_RCV) | |
12477 | && CHECK_FLAG( | |
12478 | p->cap, | |
12479 | PEER_CAP_REFRESH_NEW_RCV)) | |
12480 | ? "old & new" | |
12481 | : CHECK_FLAG( | |
12482 | p->cap, | |
12483 | PEER_CAP_REFRESH_OLD_RCV) | |
12484 | ? "old" | |
12485 | : "new"); | |
12486 | ||
12487 | vty_out(vty, "\n"); | |
12488 | } | |
12489 | ||
12490 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
12491 | FOREACH_AFI_SAFI (afi, safi) |
12492 | if (p->afc_adv[afi][safi] | |
12493 | || p->afc_recv[afi][safi]) { | |
12494 | vty_out(vty, | |
12495 | " Address Family %s:", | |
5cb5f4d0 DD |
12496 | get_afi_safi_str( |
12497 | afi, | |
12498 | safi, | |
12499 | false)); | |
05c7a1cc | 12500 | if (p->afc_adv[afi][safi]) |
d62a17ae | 12501 | vty_out(vty, |
05c7a1cc QY |
12502 | " advertised"); |
12503 | if (p->afc_recv[afi][safi]) | |
12504 | vty_out(vty, | |
12505 | " %sreceived", | |
12506 | p->afc_adv[afi] | |
12507 | [safi] | |
12508 | ? "and " | |
12509 | : ""); | |
12510 | vty_out(vty, "\n"); | |
12511 | } | |
d62a17ae | 12512 | |
12513 | /* Hostname capability */ | |
60466a63 | 12514 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
12515 | |
12516 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
12517 | vty_out(vty, |
12518 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
12519 | bgp->peer_self->hostname |
12520 | ? bgp->peer_self | |
12521 | ->hostname | |
d77114b7 | 12522 | : "n/a", |
60466a63 QY |
12523 | bgp->peer_self->domainname |
12524 | ? bgp->peer_self | |
12525 | ->domainname | |
d77114b7 MK |
12526 | : "n/a"); |
12527 | } else { | |
12528 | vty_out(vty, " not advertised"); | |
d62a17ae | 12529 | } |
12530 | ||
d77114b7 | 12531 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
12532 | vty_out(vty, |
12533 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
12534 | p->hostname ? p->hostname |
12535 | : "n/a", | |
12536 | p->domainname ? p->domainname | |
12537 | : "n/a"); | |
d77114b7 MK |
12538 | } else { |
12539 | vty_out(vty, " not received"); | |
12540 | } | |
12541 | ||
12542 | vty_out(vty, "\n"); | |
12543 | ||
61bfbd51 | 12544 | /* Graceful Restart */ |
d62a17ae | 12545 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
12546 | || CHECK_FLAG(p->cap, | |
12547 | PEER_CAP_RESTART_ADV)) { | |
12548 | vty_out(vty, | |
61bfbd51 | 12549 | " Graceful Restart Capability:"); |
d62a17ae | 12550 | if (CHECK_FLAG(p->cap, |
12551 | PEER_CAP_RESTART_ADV)) | |
12552 | vty_out(vty, " advertised"); | |
12553 | if (CHECK_FLAG(p->cap, | |
12554 | PEER_CAP_RESTART_RCV)) | |
12555 | vty_out(vty, " %sreceived", | |
12556 | CHECK_FLAG( | |
12557 | p->cap, | |
12558 | PEER_CAP_RESTART_ADV) | |
12559 | ? "and " | |
12560 | : ""); | |
12561 | vty_out(vty, "\n"); | |
12562 | ||
12563 | if (CHECK_FLAG(p->cap, | |
12564 | PEER_CAP_RESTART_RCV)) { | |
12565 | int restart_af_count = 0; | |
12566 | ||
12567 | vty_out(vty, | |
12568 | " Remote Restart timer is %d seconds\n", | |
12569 | p->v_gr_restart); | |
12570 | vty_out(vty, | |
12571 | " Address families by peer:\n "); | |
12572 | ||
05c7a1cc QY |
12573 | FOREACH_AFI_SAFI (afi, safi) |
12574 | if (CHECK_FLAG( | |
12575 | p->af_cap | |
12576 | [afi] | |
12577 | [safi], | |
12578 | PEER_CAP_RESTART_AF_RCV)) { | |
12579 | vty_out(vty, | |
12580 | "%s%s(%s)", | |
12581 | restart_af_count | |
12582 | ? ", " | |
12583 | : "", | |
5cb5f4d0 | 12584 | get_afi_safi_str( |
05c7a1cc | 12585 | afi, |
5cb5f4d0 DD |
12586 | safi, |
12587 | false), | |
05c7a1cc QY |
12588 | CHECK_FLAG( |
12589 | p->af_cap | |
12590 | [afi] | |
12591 | [safi], | |
12592 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
12593 | ? "preserved" | |
12594 | : "not preserved"); | |
12595 | restart_af_count++; | |
12596 | } | |
d62a17ae | 12597 | if (!restart_af_count) |
12598 | vty_out(vty, "none"); | |
12599 | vty_out(vty, "\n"); | |
12600 | } | |
2986cac2 | 12601 | } /* Gracefull Restart */ |
d62a17ae | 12602 | } |
12603 | } | |
12604 | } | |
12605 | ||
12606 | /* graceful restart information */ | |
d62a17ae | 12607 | json_object *json_grace = NULL; |
12608 | json_object *json_grace_send = NULL; | |
12609 | json_object *json_grace_recv = NULL; | |
12610 | int eor_send_af_count = 0; | |
12611 | int eor_receive_af_count = 0; | |
12612 | ||
12613 | if (use_json) { | |
12614 | json_grace = json_object_new_object(); | |
12615 | json_grace_send = json_object_new_object(); | |
12616 | json_grace_recv = json_object_new_object(); | |
12617 | ||
36235319 QY |
12618 | if ((p->status == Established) |
12619 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
12620 | FOREACH_AFI_SAFI (afi, safi) { |
12621 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 12622 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
12623 | json_object_boolean_true_add( |
12624 | json_grace_send, | |
5cb5f4d0 DD |
12625 | get_afi_safi_str(afi, |
12626 | safi, | |
12627 | true)); | |
05c7a1cc | 12628 | eor_send_af_count++; |
d62a17ae | 12629 | } |
12630 | } | |
05c7a1cc QY |
12631 | FOREACH_AFI_SAFI (afi, safi) { |
12632 | if (CHECK_FLAG( | |
36235319 QY |
12633 | p->af_sflags[afi][safi], |
12634 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
12635 | json_object_boolean_true_add( |
12636 | json_grace_recv, | |
5cb5f4d0 DD |
12637 | get_afi_safi_str(afi, |
12638 | safi, | |
12639 | true)); | |
05c7a1cc | 12640 | eor_receive_af_count++; |
d62a17ae | 12641 | } |
12642 | } | |
12643 | } | |
36235319 QY |
12644 | json_object_object_add(json_grace, "endOfRibSend", |
12645 | json_grace_send); | |
12646 | json_object_object_add(json_grace, "endOfRibRecv", | |
12647 | json_grace_recv); | |
d62a17ae | 12648 | |
d62a17ae | 12649 | |
12650 | if (p->t_gr_restart) | |
12651 | json_object_int_add(json_grace, | |
12652 | "gracefulRestartTimerMsecs", | |
12653 | thread_timer_remain_second( | |
12654 | p->t_gr_restart) | |
12655 | * 1000); | |
12656 | ||
12657 | if (p->t_gr_stale) | |
12658 | json_object_int_add( | |
12659 | json_grace, | |
12660 | "gracefulStalepathTimerMsecs", | |
12661 | thread_timer_remain_second( | |
12662 | p->t_gr_stale) | |
12663 | * 1000); | |
2986cac2 | 12664 | /* more gr info in new format */ |
12665 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 12666 | json_grace); |
d62a17ae | 12667 | json_object_object_add( |
12668 | json_neigh, "gracefulRestartInfo", json_grace); | |
12669 | } else { | |
2089dd80 | 12670 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
12671 | if ((p->status == Established) |
12672 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 12673 | |
d62a17ae | 12674 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
12675 | FOREACH_AFI_SAFI (afi, safi) { |
12676 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
12677 | PEER_STATUS_EOR_SEND)) { | |
12678 | vty_out(vty, "%s%s", | |
12679 | eor_send_af_count ? ", " | |
12680 | : "", | |
36235319 QY |
12681 | get_afi_safi_str( |
12682 | afi, safi, | |
12683 | false)); | |
05c7a1cc | 12684 | eor_send_af_count++; |
d62a17ae | 12685 | } |
12686 | } | |
12687 | vty_out(vty, "\n"); | |
12688 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
12689 | FOREACH_AFI_SAFI (afi, safi) { |
12690 | if (CHECK_FLAG( | |
12691 | p->af_sflags[afi][safi], | |
12692 | PEER_STATUS_EOR_RECEIVED)) { | |
12693 | vty_out(vty, "%s%s", | |
12694 | eor_receive_af_count | |
12695 | ? ", " | |
12696 | : "", | |
5cb5f4d0 DD |
12697 | get_afi_safi_str(afi, |
12698 | safi, | |
12699 | false)); | |
05c7a1cc | 12700 | eor_receive_af_count++; |
d62a17ae | 12701 | } |
12702 | } | |
12703 | vty_out(vty, "\n"); | |
12704 | } | |
12705 | ||
12706 | if (p->t_gr_restart) | |
12707 | vty_out(vty, | |
12708 | " The remaining time of restart timer is %ld\n", | |
12709 | thread_timer_remain_second( | |
12710 | p->t_gr_restart)); | |
12711 | ||
12712 | if (p->t_gr_stale) | |
12713 | vty_out(vty, | |
12714 | " The remaining time of stalepath timer is %ld\n", | |
12715 | thread_timer_remain_second( | |
12716 | p->t_gr_stale)); | |
2986cac2 | 12717 | |
12718 | /* more gr info in new format */ | |
12719 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 12720 | } |
2986cac2 | 12721 | |
d62a17ae | 12722 | if (use_json) { |
12723 | json_object *json_stat = NULL; | |
12724 | json_stat = json_object_new_object(); | |
12725 | /* Packet counts. */ | |
43aa5965 QY |
12726 | |
12727 | atomic_size_t outq_count, inq_count; | |
12728 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12729 | memory_order_relaxed); | |
12730 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12731 | memory_order_relaxed); | |
12732 | ||
12733 | json_object_int_add(json_stat, "depthInq", | |
12734 | (unsigned long)inq_count); | |
d62a17ae | 12735 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 12736 | (unsigned long)outq_count); |
0112e9e0 QY |
12737 | json_object_int_add(json_stat, "opensSent", |
12738 | atomic_load_explicit(&p->open_out, | |
12739 | memory_order_relaxed)); | |
12740 | json_object_int_add(json_stat, "opensRecv", | |
12741 | atomic_load_explicit(&p->open_in, | |
12742 | memory_order_relaxed)); | |
d62a17ae | 12743 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
12744 | atomic_load_explicit(&p->notify_out, |
12745 | memory_order_relaxed)); | |
d62a17ae | 12746 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
12747 | atomic_load_explicit(&p->notify_in, |
12748 | memory_order_relaxed)); | |
12749 | json_object_int_add(json_stat, "updatesSent", | |
12750 | atomic_load_explicit(&p->update_out, | |
12751 | memory_order_relaxed)); | |
12752 | json_object_int_add(json_stat, "updatesRecv", | |
12753 | atomic_load_explicit(&p->update_in, | |
12754 | memory_order_relaxed)); | |
d62a17ae | 12755 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
12756 | atomic_load_explicit(&p->keepalive_out, |
12757 | memory_order_relaxed)); | |
d62a17ae | 12758 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
12759 | atomic_load_explicit(&p->keepalive_in, |
12760 | memory_order_relaxed)); | |
d62a17ae | 12761 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
12762 | atomic_load_explicit(&p->refresh_out, |
12763 | memory_order_relaxed)); | |
d62a17ae | 12764 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
12765 | atomic_load_explicit(&p->refresh_in, |
12766 | memory_order_relaxed)); | |
d62a17ae | 12767 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
12768 | atomic_load_explicit(&p->dynamic_cap_out, |
12769 | memory_order_relaxed)); | |
d62a17ae | 12770 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
12771 | atomic_load_explicit(&p->dynamic_cap_in, |
12772 | memory_order_relaxed)); | |
12773 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
12774 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 12775 | json_object_object_add(json_neigh, "messageStats", json_stat); |
12776 | } else { | |
43aa5965 QY |
12777 | atomic_size_t outq_count, inq_count; |
12778 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12779 | memory_order_relaxed); | |
12780 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12781 | memory_order_relaxed); | |
12782 | ||
d62a17ae | 12783 | /* Packet counts. */ |
12784 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
12785 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
12786 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 12787 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
12788 | vty_out(vty, " Opens: %10d %10d\n", |
12789 | atomic_load_explicit(&p->open_out, | |
12790 | memory_order_relaxed), | |
12791 | atomic_load_explicit(&p->open_in, | |
12792 | memory_order_relaxed)); | |
12793 | vty_out(vty, " Notifications: %10d %10d\n", | |
12794 | atomic_load_explicit(&p->notify_out, | |
12795 | memory_order_relaxed), | |
12796 | atomic_load_explicit(&p->notify_in, | |
12797 | memory_order_relaxed)); | |
12798 | vty_out(vty, " Updates: %10d %10d\n", | |
12799 | atomic_load_explicit(&p->update_out, | |
12800 | memory_order_relaxed), | |
12801 | atomic_load_explicit(&p->update_in, | |
12802 | memory_order_relaxed)); | |
12803 | vty_out(vty, " Keepalives: %10d %10d\n", | |
12804 | atomic_load_explicit(&p->keepalive_out, | |
12805 | memory_order_relaxed), | |
12806 | atomic_load_explicit(&p->keepalive_in, | |
12807 | memory_order_relaxed)); | |
12808 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
12809 | atomic_load_explicit(&p->refresh_out, | |
12810 | memory_order_relaxed), | |
12811 | atomic_load_explicit(&p->refresh_in, | |
12812 | memory_order_relaxed)); | |
d62a17ae | 12813 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
12814 | atomic_load_explicit(&p->dynamic_cap_out, |
12815 | memory_order_relaxed), | |
12816 | atomic_load_explicit(&p->dynamic_cap_in, | |
12817 | memory_order_relaxed)); | |
12818 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
12819 | PEER_TOTAL_RX(p)); | |
d62a17ae | 12820 | } |
12821 | ||
12822 | if (use_json) { | |
12823 | /* advertisement-interval */ | |
12824 | json_object_int_add(json_neigh, | |
12825 | "minBtwnAdvertisementRunsTimerMsecs", | |
12826 | p->v_routeadv * 1000); | |
12827 | ||
12828 | /* Update-source. */ | |
12829 | if (p->update_if || p->update_source) { | |
12830 | if (p->update_if) | |
12831 | json_object_string_add(json_neigh, | |
12832 | "updateSource", | |
12833 | p->update_if); | |
12834 | else if (p->update_source) | |
12835 | json_object_string_add( | |
12836 | json_neigh, "updateSource", | |
12837 | sockunion2str(p->update_source, buf1, | |
12838 | SU_ADDRSTRLEN)); | |
12839 | } | |
12840 | } else { | |
12841 | /* advertisement-interval */ | |
12842 | vty_out(vty, | |
12843 | " Minimum time between advertisement runs is %d seconds\n", | |
12844 | p->v_routeadv); | |
12845 | ||
12846 | /* Update-source. */ | |
12847 | if (p->update_if || p->update_source) { | |
12848 | vty_out(vty, " Update source is "); | |
12849 | if (p->update_if) | |
12850 | vty_out(vty, "%s", p->update_if); | |
12851 | else if (p->update_source) | |
12852 | vty_out(vty, "%s", | |
12853 | sockunion2str(p->update_source, buf1, | |
12854 | SU_ADDRSTRLEN)); | |
12855 | vty_out(vty, "\n"); | |
12856 | } | |
12857 | ||
12858 | vty_out(vty, "\n"); | |
12859 | } | |
12860 | ||
12861 | /* Address Family Information */ | |
12862 | json_object *json_hold = NULL; | |
12863 | ||
12864 | if (use_json) | |
12865 | json_hold = json_object_new_object(); | |
12866 | ||
05c7a1cc QY |
12867 | FOREACH_AFI_SAFI (afi, safi) |
12868 | if (p->afc[afi][safi]) | |
12869 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
12870 | json_hold); | |
d62a17ae | 12871 | |
12872 | if (use_json) { | |
12873 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
12874 | json_hold); | |
12875 | json_object_int_add(json_neigh, "connectionsEstablished", | |
12876 | p->established); | |
12877 | json_object_int_add(json_neigh, "connectionsDropped", | |
12878 | p->dropped); | |
12879 | } else | |
12880 | vty_out(vty, " Connections established %d; dropped %d\n", | |
12881 | p->established, p->dropped); | |
12882 | ||
12883 | if (!p->last_reset) { | |
12884 | if (use_json) | |
12885 | json_object_string_add(json_neigh, "lastReset", | |
12886 | "never"); | |
12887 | else | |
12888 | vty_out(vty, " Last reset never\n"); | |
12889 | } else { | |
12890 | if (use_json) { | |
12891 | time_t uptime; | |
a2700b50 | 12892 | struct tm tm; |
d62a17ae | 12893 | |
12894 | uptime = bgp_clock(); | |
12895 | uptime -= p->resettime; | |
a2700b50 MS |
12896 | gmtime_r(&uptime, &tm); |
12897 | ||
d62a17ae | 12898 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
12899 | (tm.tm_sec * 1000) |
12900 | + (tm.tm_min * 60000) | |
12901 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 12902 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 12903 | } else { |
12904 | vty_out(vty, " Last reset %s, ", | |
12905 | peer_uptime(p->resettime, timebuf, | |
12906 | BGP_UPTIME_LEN, 0, NULL)); | |
12907 | ||
3577f1c5 | 12908 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 12909 | if (p->last_reset_cause_size) { |
12910 | msg = p->last_reset_cause; | |
12911 | vty_out(vty, | |
12912 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
12913 | for (i = 1; i <= p->last_reset_cause_size; | |
12914 | i++) { | |
12915 | vty_out(vty, "%02X", *msg++); | |
12916 | ||
12917 | if (i != p->last_reset_cause_size) { | |
12918 | if (i % 16 == 0) { | |
12919 | vty_out(vty, "\n "); | |
12920 | } else if (i % 4 == 0) { | |
12921 | vty_out(vty, " "); | |
12922 | } | |
12923 | } | |
12924 | } | |
12925 | vty_out(vty, "\n"); | |
12926 | } | |
12927 | } | |
12928 | } | |
12929 | ||
12930 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
12931 | if (use_json) | |
12932 | json_object_boolean_true_add(json_neigh, | |
12933 | "prefixesConfigExceedMax"); | |
12934 | else | |
12935 | vty_out(vty, | |
12936 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
12937 | ||
12938 | if (p->t_pmax_restart) { | |
12939 | if (use_json) { | |
12940 | json_object_boolean_true_add( | |
12941 | json_neigh, "reducePrefixNumFrom"); | |
12942 | json_object_int_add(json_neigh, | |
12943 | "restartInTimerMsec", | |
12944 | thread_timer_remain_second( | |
12945 | p->t_pmax_restart) | |
12946 | * 1000); | |
12947 | } else | |
12948 | vty_out(vty, | |
12949 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
12950 | p->host, thread_timer_remain_second( |
12951 | p->t_pmax_restart)); | |
d62a17ae | 12952 | } else { |
12953 | if (use_json) | |
12954 | json_object_boolean_true_add( | |
12955 | json_neigh, | |
12956 | "reducePrefixNumAndClearIpBgp"); | |
12957 | else | |
12958 | vty_out(vty, | |
12959 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
12960 | p->host); | |
12961 | } | |
12962 | } | |
12963 | ||
12964 | /* EBGP Multihop and GTSM */ | |
12965 | if (p->sort != BGP_PEER_IBGP) { | |
12966 | if (use_json) { | |
e2521429 | 12967 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12968 | json_object_int_add(json_neigh, |
12969 | "externalBgpNbrMaxHopsAway", | |
12970 | p->gtsm_hops); | |
c8d6f0d6 | 12971 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12972 | json_object_int_add(json_neigh, |
12973 | "externalBgpNbrMaxHopsAway", | |
12974 | p->ttl); | |
12975 | } else { | |
e2521429 | 12976 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12977 | vty_out(vty, |
12978 | " External BGP neighbor may be up to %d hops away.\n", | |
12979 | p->gtsm_hops); | |
c8d6f0d6 | 12980 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12981 | vty_out(vty, |
12982 | " External BGP neighbor may be up to %d hops away.\n", | |
12983 | p->ttl); | |
12984 | } | |
12985 | } else { | |
e2521429 | 12986 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 12987 | if (use_json) |
12988 | json_object_int_add(json_neigh, | |
12989 | "internalBgpNbrMaxHopsAway", | |
12990 | p->gtsm_hops); | |
12991 | else | |
12992 | vty_out(vty, | |
12993 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12994 | p->gtsm_hops); | |
12995 | } | |
12996 | } | |
12997 | ||
12998 | /* Local address. */ | |
12999 | if (p->su_local) { | |
13000 | if (use_json) { | |
13001 | json_object_string_add(json_neigh, "hostLocal", | |
13002 | sockunion2str(p->su_local, buf1, | |
13003 | SU_ADDRSTRLEN)); | |
13004 | json_object_int_add(json_neigh, "portLocal", | |
13005 | ntohs(p->su_local->sin.sin_port)); | |
13006 | } else | |
13007 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
13008 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
13009 | ntohs(p->su_local->sin.sin_port)); | |
13010 | } | |
13011 | ||
13012 | /* Remote address. */ | |
13013 | if (p->su_remote) { | |
13014 | if (use_json) { | |
13015 | json_object_string_add(json_neigh, "hostForeign", | |
13016 | sockunion2str(p->su_remote, buf1, | |
13017 | SU_ADDRSTRLEN)); | |
13018 | json_object_int_add(json_neigh, "portForeign", | |
13019 | ntohs(p->su_remote->sin.sin_port)); | |
13020 | } else | |
13021 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
13022 | sockunion2str(p->su_remote, buf1, | |
13023 | SU_ADDRSTRLEN), | |
13024 | ntohs(p->su_remote->sin.sin_port)); | |
13025 | } | |
13026 | ||
13027 | /* Nexthop display. */ | |
13028 | if (p->su_local) { | |
13029 | if (use_json) { | |
13030 | json_object_string_add(json_neigh, "nexthop", | |
13031 | inet_ntop(AF_INET, | |
13032 | &p->nexthop.v4, buf1, | |
13033 | sizeof(buf1))); | |
13034 | json_object_string_add(json_neigh, "nexthopGlobal", | |
13035 | inet_ntop(AF_INET6, | |
13036 | &p->nexthop.v6_global, | |
13037 | buf1, sizeof(buf1))); | |
13038 | json_object_string_add(json_neigh, "nexthopLocal", | |
13039 | inet_ntop(AF_INET6, | |
13040 | &p->nexthop.v6_local, | |
13041 | buf1, sizeof(buf1))); | |
13042 | if (p->shared_network) | |
13043 | json_object_string_add(json_neigh, | |
13044 | "bgpConnection", | |
13045 | "sharedNetwork"); | |
13046 | else | |
13047 | json_object_string_add(json_neigh, | |
13048 | "bgpConnection", | |
13049 | "nonSharedNetwork"); | |
13050 | } else { | |
13051 | vty_out(vty, "Nexthop: %s\n", | |
13052 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
13053 | sizeof(buf1))); | |
13054 | vty_out(vty, "Nexthop global: %s\n", | |
13055 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
13056 | sizeof(buf1))); | |
13057 | vty_out(vty, "Nexthop local: %s\n", | |
13058 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
13059 | sizeof(buf1))); | |
13060 | vty_out(vty, "BGP connection: %s\n", | |
13061 | p->shared_network ? "shared network" | |
13062 | : "non shared network"); | |
13063 | } | |
13064 | } | |
13065 | ||
13066 | /* Timer information. */ | |
13067 | if (use_json) { | |
13068 | json_object_int_add(json_neigh, "connectRetryTimer", | |
13069 | p->v_connect); | |
13070 | if (p->status == Established && p->rtt) | |
13071 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
13072 | p->rtt); | |
13073 | if (p->t_start) | |
13074 | json_object_int_add( | |
13075 | json_neigh, "nextStartTimerDueInMsecs", | |
13076 | thread_timer_remain_second(p->t_start) * 1000); | |
13077 | if (p->t_connect) | |
13078 | json_object_int_add( | |
13079 | json_neigh, "nextConnectTimerDueInMsecs", | |
13080 | thread_timer_remain_second(p->t_connect) | |
13081 | * 1000); | |
13082 | if (p->t_routeadv) { | |
13083 | json_object_int_add(json_neigh, "mraiInterval", | |
13084 | p->v_routeadv); | |
13085 | json_object_int_add( | |
13086 | json_neigh, "mraiTimerExpireInMsecs", | |
13087 | thread_timer_remain_second(p->t_routeadv) | |
13088 | * 1000); | |
13089 | } | |
13090 | if (p->password) | |
13091 | json_object_int_add(json_neigh, "authenticationEnabled", | |
13092 | 1); | |
13093 | ||
13094 | if (p->t_read) | |
13095 | json_object_string_add(json_neigh, "readThread", "on"); | |
13096 | else | |
13097 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
13098 | |
13099 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 13100 | json_object_string_add(json_neigh, "writeThread", "on"); |
13101 | else | |
13102 | json_object_string_add(json_neigh, "writeThread", | |
13103 | "off"); | |
13104 | } else { | |
13105 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
13106 | p->v_connect); | |
13107 | if (p->status == Established && p->rtt) | |
13108 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
13109 | p->rtt); | |
13110 | if (p->t_start) | |
13111 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
13112 | thread_timer_remain_second(p->t_start)); | |
13113 | if (p->t_connect) | |
13114 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
13115 | thread_timer_remain_second(p->t_connect)); | |
13116 | if (p->t_routeadv) | |
13117 | vty_out(vty, | |
13118 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
13119 | p->v_routeadv, | |
13120 | thread_timer_remain_second(p->t_routeadv)); | |
13121 | if (p->password) | |
13122 | vty_out(vty, "Peer Authentication Enabled\n"); | |
13123 | ||
cac9e917 | 13124 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
13125 | p->t_read ? "on" : "off", |
13126 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
13127 | ? "on" | |
cac9e917 | 13128 | : "off", p->fd); |
d62a17ae | 13129 | } |
13130 | ||
13131 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
13132 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
13133 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
13134 | ||
13135 | if (!use_json) | |
13136 | vty_out(vty, "\n"); | |
13137 | ||
13138 | /* BFD information. */ | |
13139 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
13140 | ||
13141 | if (use_json) { | |
13142 | if (p->conf_if) /* Configured interface name. */ | |
13143 | json_object_object_add(json, p->conf_if, json_neigh); | |
13144 | else /* Configured IP address. */ | |
13145 | json_object_object_add(json, p->host, json_neigh); | |
13146 | } | |
13147 | } | |
13148 | ||
36235319 QY |
13149 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
13150 | enum show_type type, | |
13151 | union sockunion *su, | |
13152 | const char *conf_if, afi_t afi, | |
74a630b6 | 13153 | bool use_json) |
2986cac2 | 13154 | { |
13155 | struct listnode *node, *nnode; | |
13156 | struct peer *peer; | |
13157 | int find = 0; | |
13158 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 13159 | json_object *json = NULL; |
2986cac2 | 13160 | json_object *json_neighbor = NULL; |
13161 | ||
74a630b6 NT |
13162 | if (use_json) { |
13163 | json = json_object_new_object(); | |
13164 | json_neighbor = json_object_new_object(); | |
13165 | } | |
13166 | ||
2986cac2 | 13167 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
13168 | ||
13169 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
13170 | continue; | |
13171 | ||
13172 | if ((peer->afc[afi][safi]) == 0) | |
13173 | continue; | |
13174 | ||
2ba1fe69 | 13175 | if (type == show_all) { |
2986cac2 | 13176 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 13177 | json_neighbor); |
2986cac2 | 13178 | |
74a630b6 | 13179 | if (use_json) { |
13909c4f DS |
13180 | json_object_object_add(json, peer->host, |
13181 | json_neighbor); | |
74a630b6 NT |
13182 | json_neighbor = NULL; |
13183 | } | |
2986cac2 | 13184 | |
2ba1fe69 | 13185 | } else if (type == show_peer) { |
2986cac2 | 13186 | if (conf_if) { |
13187 | if ((peer->conf_if | |
13909c4f DS |
13188 | && !strcmp(peer->conf_if, conf_if)) |
13189 | || (peer->hostname | |
2986cac2 | 13190 | && !strcmp(peer->hostname, conf_if))) { |
13191 | find = 1; | |
13909c4f DS |
13192 | bgp_show_peer_gr_status(vty, peer, |
13193 | use_json, | |
13194 | json_neighbor); | |
2986cac2 | 13195 | } |
13196 | } else { | |
13197 | if (sockunion_same(&peer->su, su)) { | |
13198 | find = 1; | |
13909c4f DS |
13199 | bgp_show_peer_gr_status(vty, peer, |
13200 | use_json, | |
13201 | json_neighbor); | |
2986cac2 | 13202 | } |
13203 | } | |
13909c4f DS |
13204 | if (use_json && find) |
13205 | json_object_object_add(json, peer->host, | |
13206 | json_neighbor); | |
2986cac2 | 13207 | } |
13208 | ||
74a630b6 NT |
13209 | if (find) { |
13210 | json_neighbor = NULL; | |
2986cac2 | 13211 | break; |
74a630b6 | 13212 | } |
2986cac2 | 13213 | } |
13214 | ||
13215 | if (type == show_peer && !find) { | |
13216 | if (use_json) | |
13909c4f | 13217 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 13218 | else |
13219 | vty_out(vty, "%% No such neighbor\n"); | |
13220 | } | |
13221 | if (use_json) { | |
13909c4f DS |
13222 | vty_out(vty, "%s\n", |
13223 | json_object_to_json_string_ext( | |
13224 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
13225 | |
13226 | if (json_neighbor) | |
13227 | json_object_free(json_neighbor); | |
13228 | json_object_free(json); | |
2986cac2 | 13229 | } else { |
13230 | vty_out(vty, "\n"); | |
13231 | } | |
13232 | ||
13233 | return CMD_SUCCESS; | |
13234 | } | |
13235 | ||
d62a17ae | 13236 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
13237 | enum show_type type, union sockunion *su, | |
9f049418 | 13238 | const char *conf_if, bool use_json, |
d62a17ae | 13239 | json_object *json) |
13240 | { | |
13241 | struct listnode *node, *nnode; | |
13242 | struct peer *peer; | |
13243 | int find = 0; | |
9f049418 | 13244 | bool nbr_output = false; |
d1927ebe AS |
13245 | afi_t afi = AFI_MAX; |
13246 | safi_t safi = SAFI_MAX; | |
13247 | ||
13248 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
13249 | afi = AFI_IP; | |
13250 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
13251 | afi = AFI_IP6; | |
13252 | } | |
d62a17ae | 13253 | |
13254 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
13255 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
13256 | continue; | |
13257 | ||
13258 | switch (type) { | |
13259 | case show_all: | |
13260 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 13261 | nbr_output = true; |
d62a17ae | 13262 | break; |
13263 | case show_peer: | |
13264 | if (conf_if) { | |
13265 | if ((peer->conf_if | |
13266 | && !strcmp(peer->conf_if, conf_if)) | |
13267 | || (peer->hostname | |
13268 | && !strcmp(peer->hostname, conf_if))) { | |
13269 | find = 1; | |
13270 | bgp_show_peer(vty, peer, use_json, | |
13271 | json); | |
13272 | } | |
13273 | } else { | |
13274 | if (sockunion_same(&peer->su, su)) { | |
13275 | find = 1; | |
13276 | bgp_show_peer(vty, peer, use_json, | |
13277 | json); | |
13278 | } | |
13279 | } | |
13280 | break; | |
d1927ebe AS |
13281 | case show_ipv4_peer: |
13282 | case show_ipv6_peer: | |
13283 | FOREACH_SAFI (safi) { | |
13284 | if (peer->afc[afi][safi]) { | |
13285 | if (conf_if) { | |
13286 | if ((peer->conf_if | |
13287 | && !strcmp(peer->conf_if, conf_if)) | |
13288 | || (peer->hostname | |
13289 | && !strcmp(peer->hostname, conf_if))) { | |
13290 | find = 1; | |
13291 | bgp_show_peer(vty, peer, use_json, | |
13292 | json); | |
13293 | break; | |
13294 | } | |
13295 | } else { | |
13296 | if (sockunion_same(&peer->su, su)) { | |
13297 | find = 1; | |
13298 | bgp_show_peer(vty, peer, use_json, | |
13299 | json); | |
13300 | break; | |
13301 | } | |
13302 | } | |
13303 | } | |
13304 | } | |
13305 | break; | |
13306 | case show_ipv4_all: | |
13307 | case show_ipv6_all: | |
13308 | FOREACH_SAFI (safi) { | |
13309 | if (peer->afc[afi][safi]) { | |
13310 | bgp_show_peer(vty, peer, use_json, json); | |
13311 | nbr_output = true; | |
13312 | break; | |
13313 | } | |
13314 | } | |
13315 | break; | |
d62a17ae | 13316 | } |
13317 | } | |
13318 | ||
d1927ebe AS |
13319 | if ((type == show_peer || type == show_ipv4_peer || |
13320 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 13321 | if (use_json) |
13322 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
13323 | else | |
88b7d255 | 13324 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 13325 | } |
13326 | ||
d1927ebe AS |
13327 | if (type != show_peer && type != show_ipv4_peer && |
13328 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 13329 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 13330 | |
d62a17ae | 13331 | if (use_json) { |
996c9314 LB |
13332 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
13333 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 13334 | } else { |
13335 | vty_out(vty, "\n"); | |
13336 | } | |
13337 | ||
13338 | return CMD_SUCCESS; | |
13339 | } | |
13340 | ||
36235319 QY |
13341 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
13342 | enum show_type type, | |
13343 | const char *ip_str, | |
13344 | afi_t afi, bool use_json) | |
2986cac2 | 13345 | { |
13346 | ||
13347 | int ret; | |
13348 | struct bgp *bgp; | |
13349 | union sockunion su; | |
2986cac2 | 13350 | |
13351 | bgp = bgp_get_default(); | |
13352 | ||
13909c4f DS |
13353 | if (!bgp) |
13354 | return; | |
2986cac2 | 13355 | |
13909c4f DS |
13356 | if (!use_json) |
13357 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
13358 | NULL); | |
2986cac2 | 13359 | |
13909c4f DS |
13360 | if (ip_str) { |
13361 | ret = str2sockunion(ip_str, &su); | |
13362 | if (ret < 0) | |
13909c4f | 13363 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
13364 | vty, bgp, type, NULL, ip_str, afi, use_json); |
13365 | else | |
13366 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
13367 | NULL, afi, use_json); | |
13909c4f DS |
13368 | } else |
13369 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 13370 | afi, use_json); |
2986cac2 | 13371 | } |
13372 | ||
d62a17ae | 13373 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
13374 | enum show_type type, |
13375 | const char *ip_str, | |
9f049418 | 13376 | bool use_json) |
d62a17ae | 13377 | { |
0291c246 MK |
13378 | struct listnode *node, *nnode; |
13379 | struct bgp *bgp; | |
71aedaa3 | 13380 | union sockunion su; |
0291c246 | 13381 | json_object *json = NULL; |
71aedaa3 | 13382 | int ret, is_first = 1; |
9f049418 | 13383 | bool nbr_output = false; |
d62a17ae | 13384 | |
13385 | if (use_json) | |
13386 | vty_out(vty, "{\n"); | |
13387 | ||
13388 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 13389 | nbr_output = true; |
d62a17ae | 13390 | if (use_json) { |
13391 | if (!(json = json_object_new_object())) { | |
af4c2728 | 13392 | flog_err( |
e50f7cfd | 13393 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 13394 | "Unable to allocate memory for JSON object"); |
13395 | vty_out(vty, | |
13396 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
13397 | return; | |
13398 | } | |
13399 | ||
13400 | json_object_int_add(json, "vrfId", | |
13401 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
13402 | ? -1 |
13403 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 13404 | json_object_string_add( |
13405 | json, "vrfName", | |
13406 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13407 | ? VRF_DEFAULT_NAME |
d62a17ae | 13408 | : bgp->name); |
13409 | ||
13410 | if (!is_first) | |
13411 | vty_out(vty, ",\n"); | |
13412 | else | |
13413 | is_first = 0; | |
13414 | ||
13415 | vty_out(vty, "\"%s\":", | |
13416 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13417 | ? VRF_DEFAULT_NAME |
d62a17ae | 13418 | : bgp->name); |
13419 | } else { | |
13420 | vty_out(vty, "\nInstance %s:\n", | |
13421 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13422 | ? VRF_DEFAULT_NAME |
d62a17ae | 13423 | : bgp->name); |
13424 | } | |
71aedaa3 | 13425 | |
d1927ebe AS |
13426 | if (type == show_peer || type == show_ipv4_peer || |
13427 | type == show_ipv6_peer) { | |
71aedaa3 DS |
13428 | ret = str2sockunion(ip_str, &su); |
13429 | if (ret < 0) | |
13430 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
13431 | use_json, json); | |
13432 | else | |
13433 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
13434 | use_json, json); | |
13435 | } else { | |
d1927ebe | 13436 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
13437 | use_json, json); |
13438 | } | |
b77004d6 | 13439 | json_object_free(json); |
121067e9 | 13440 | json = NULL; |
d62a17ae | 13441 | } |
13442 | ||
3e78a6ce | 13443 | if (use_json) |
d62a17ae | 13444 | vty_out(vty, "}\n"); |
9f049418 DS |
13445 | else if (!nbr_output) |
13446 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 13447 | } |
13448 | ||
13449 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
13450 | enum show_type type, const char *ip_str, | |
9f049418 | 13451 | bool use_json) |
d62a17ae | 13452 | { |
13453 | int ret; | |
13454 | struct bgp *bgp; | |
13455 | union sockunion su; | |
13456 | json_object *json = NULL; | |
13457 | ||
13458 | if (name) { | |
13459 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
13460 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
13461 | use_json); | |
d62a17ae | 13462 | return CMD_SUCCESS; |
13463 | } else { | |
13464 | bgp = bgp_lookup_by_name(name); | |
13465 | if (!bgp) { | |
13466 | if (use_json) { | |
13467 | json = json_object_new_object(); | |
d62a17ae | 13468 | vty_out(vty, "%s\n", |
13469 | json_object_to_json_string_ext( | |
13470 | json, | |
13471 | JSON_C_TO_STRING_PRETTY)); | |
13472 | json_object_free(json); | |
13473 | } else | |
13474 | vty_out(vty, | |
9f049418 | 13475 | "%% BGP instance not found\n"); |
d62a17ae | 13476 | |
13477 | return CMD_WARNING; | |
13478 | } | |
13479 | } | |
13480 | } else { | |
13481 | bgp = bgp_get_default(); | |
13482 | } | |
13483 | ||
13484 | if (bgp) { | |
13485 | json = json_object_new_object(); | |
13486 | if (ip_str) { | |
13487 | ret = str2sockunion(ip_str, &su); | |
13488 | if (ret < 0) | |
13489 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
13490 | use_json, json); | |
13491 | else | |
13492 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
13493 | use_json, json); | |
13494 | } else { | |
13495 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
13496 | json); | |
13497 | } | |
13498 | json_object_free(json); | |
ca61fd25 DS |
13499 | } else { |
13500 | if (use_json) | |
13501 | vty_out(vty, "{}\n"); | |
13502 | else | |
13503 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 13504 | } |
13505 | ||
13506 | return CMD_SUCCESS; | |
4fb25c53 DW |
13507 | } |
13508 | ||
2986cac2 | 13509 | |
13510 | ||
13511 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
13512 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
13513 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
13514 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
13515 | SHOW_STR | |
13516 | BGP_STR | |
13517 | IP_STR | |
13518 | IPV6_STR | |
13519 | NEIGHBOR_STR | |
13520 | "Neighbor to display information about\n" | |
13521 | "Neighbor to display information about\n" | |
13522 | "Neighbor on BGP configured interface\n" | |
13523 | GR_SHOW | |
13524 | JSON_STR) | |
13525 | { | |
13526 | char *sh_arg = NULL; | |
13527 | enum show_type sh_type; | |
13528 | int idx = 0; | |
13529 | afi_t afi = AFI_MAX; | |
2986cac2 | 13530 | bool uj = use_json(argc, argv); |
13531 | ||
36235319 | 13532 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 13533 | afi = AFI_MAX; |
13534 | ||
13535 | idx++; | |
13536 | ||
13537 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
13538 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
13539 | || argv_find(argv, argc, "WORD", &idx)) { | |
13540 | sh_type = show_peer; | |
13541 | sh_arg = argv[idx]->arg; | |
13542 | } else | |
13543 | sh_type = show_all; | |
13544 | ||
13545 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
13546 | return CMD_SUCCESS; | |
13547 | ||
13548 | ||
36235319 QY |
13549 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
13550 | afi, uj); | |
2986cac2 | 13551 | } |
13552 | ||
716b2d8a | 13553 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 13554 | DEFUN (show_ip_bgp_neighbors, |
13555 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 13556 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 13557 | SHOW_STR |
13558 | IP_STR | |
13559 | BGP_STR | |
f2a8972b | 13560 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
13561 | "Address Family\n" |
13562 | "Address Family\n" | |
718e3744 | 13563 | "Detailed information on TCP and BGP neighbor connections\n" |
13564 | "Neighbor to display information about\n" | |
a80beece | 13565 | "Neighbor to display information about\n" |
91d37724 | 13566 | "Neighbor on BGP configured interface\n" |
9973d184 | 13567 | JSON_STR) |
718e3744 | 13568 | { |
d62a17ae | 13569 | char *vrf = NULL; |
13570 | char *sh_arg = NULL; | |
13571 | enum show_type sh_type; | |
d1927ebe | 13572 | afi_t afi = AFI_MAX; |
718e3744 | 13573 | |
9f049418 | 13574 | bool uj = use_json(argc, argv); |
718e3744 | 13575 | |
d62a17ae | 13576 | int idx = 0; |
718e3744 | 13577 | |
9a8bdf1c PG |
13578 | /* [<vrf> VIEWVRFNAME] */ |
13579 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13580 | vrf = argv[idx + 1]->arg; | |
13581 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13582 | vrf = NULL; | |
13583 | } else if (argv_find(argv, argc, "view", &idx)) | |
13584 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 13585 | vrf = argv[idx + 1]->arg; |
718e3744 | 13586 | |
d62a17ae | 13587 | idx++; |
d1927ebe AS |
13588 | |
13589 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
13590 | sh_type = show_ipv4_all; | |
13591 | afi = AFI_IP; | |
13592 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
13593 | sh_type = show_ipv6_all; | |
13594 | afi = AFI_IP6; | |
13595 | } else { | |
13596 | sh_type = show_all; | |
13597 | } | |
13598 | ||
d62a17ae | 13599 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
13600 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
13601 | || argv_find(argv, argc, "WORD", &idx)) { | |
13602 | sh_type = show_peer; | |
13603 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
13604 | } |
13605 | ||
13606 | if (sh_type == show_peer && afi == AFI_IP) { | |
13607 | sh_type = show_ipv4_peer; | |
13608 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
13609 | sh_type = show_ipv6_peer; | |
13610 | } | |
856ca177 | 13611 | |
d62a17ae | 13612 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 13613 | } |
13614 | ||
716b2d8a | 13615 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 13616 | paths' and `show ip mbgp paths'. Those functions results are the |
13617 | same.*/ | |
f412b39a | 13618 | DEFUN (show_ip_bgp_paths, |
718e3744 | 13619 | show_ip_bgp_paths_cmd, |
46f296b4 | 13620 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 13621 | SHOW_STR |
13622 | IP_STR | |
13623 | BGP_STR | |
46f296b4 | 13624 | BGP_SAFI_HELP_STR |
718e3744 | 13625 | "Path information\n") |
13626 | { | |
d62a17ae | 13627 | vty_out(vty, "Address Refcnt Path\n"); |
13628 | aspath_print_all_vty(vty); | |
13629 | return CMD_SUCCESS; | |
718e3744 | 13630 | } |
13631 | ||
718e3744 | 13632 | #include "hash.h" |
13633 | ||
e3b78da8 | 13634 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 13635 | struct vty *vty) |
718e3744 | 13636 | { |
d62a17ae | 13637 | struct community *com; |
718e3744 | 13638 | |
e3b78da8 | 13639 | com = (struct community *)bucket->data; |
3f65c5b1 | 13640 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 13641 | community_str(com, false)); |
718e3744 | 13642 | } |
13643 | ||
13644 | /* Show BGP's community internal data. */ | |
f412b39a | 13645 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 13646 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 13647 | "show [ip] bgp community-info", |
718e3744 | 13648 | SHOW_STR |
13649 | IP_STR | |
13650 | BGP_STR | |
13651 | "List all bgp community information\n") | |
13652 | { | |
d62a17ae | 13653 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 13654 | |
d62a17ae | 13655 | hash_iterate(community_hash(), |
e3b78da8 | 13656 | (void (*)(struct hash_bucket *, |
d62a17ae | 13657 | void *))community_show_all_iterator, |
13658 | vty); | |
718e3744 | 13659 | |
d62a17ae | 13660 | return CMD_SUCCESS; |
718e3744 | 13661 | } |
13662 | ||
e3b78da8 | 13663 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 13664 | struct vty *vty) |
57d187bc | 13665 | { |
d62a17ae | 13666 | struct lcommunity *lcom; |
57d187bc | 13667 | |
e3b78da8 | 13668 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 13669 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 13670 | lcommunity_str(lcom, false)); |
57d187bc JS |
13671 | } |
13672 | ||
13673 | /* Show BGP's community internal data. */ | |
13674 | DEFUN (show_ip_bgp_lcommunity_info, | |
13675 | show_ip_bgp_lcommunity_info_cmd, | |
13676 | "show ip bgp large-community-info", | |
13677 | SHOW_STR | |
13678 | IP_STR | |
13679 | BGP_STR | |
13680 | "List all bgp large-community information\n") | |
13681 | { | |
d62a17ae | 13682 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 13683 | |
d62a17ae | 13684 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 13685 | (void (*)(struct hash_bucket *, |
d62a17ae | 13686 | void *))lcommunity_show_all_iterator, |
13687 | vty); | |
57d187bc | 13688 | |
d62a17ae | 13689 | return CMD_SUCCESS; |
57d187bc | 13690 | } |
2986cac2 | 13691 | /* Graceful Restart */ |
13692 | ||
13693 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
13694 | struct bgp *bgp, |
13695 | bool use_json, | |
13696 | json_object *json) | |
2986cac2 | 13697 | { |
57d187bc JS |
13698 | |
13699 | ||
2986cac2 | 13700 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
13701 | ||
7318ae88 | 13702 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 13703 | |
13704 | switch (bgp_global_gr_mode) { | |
13705 | ||
13706 | case GLOBAL_HELPER: | |
13909c4f | 13707 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 13708 | break; |
13709 | ||
13710 | case GLOBAL_GR: | |
13909c4f | 13711 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 13712 | break; |
13713 | ||
13714 | case GLOBAL_DISABLE: | |
13909c4f | 13715 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 13716 | break; |
13717 | ||
13718 | case GLOBAL_INVALID: | |
2986cac2 | 13719 | vty_out(vty, |
2ba1fe69 | 13720 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 13721 | break; |
13722 | } | |
13723 | vty_out(vty, "\n"); | |
13724 | } | |
13725 | ||
36235319 QY |
13726 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
13727 | enum show_type type, | |
13728 | const char *ip_str, | |
13729 | afi_t afi, bool use_json) | |
2986cac2 | 13730 | { |
13731 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
13732 | afi = AFI_IP; | |
13733 | ||
13734 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
13735 | ||
36235319 QY |
13736 | bgp_show_neighbor_graceful_restart_vty( |
13737 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 13738 | afi++; |
13739 | } | |
13740 | } else if (afi != AFI_MAX) { | |
36235319 QY |
13741 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
13742 | use_json); | |
2986cac2 | 13743 | } else { |
13744 | return CMD_ERR_INCOMPLETE; | |
13745 | } | |
13746 | ||
13747 | return CMD_SUCCESS; | |
13748 | } | |
13749 | /* Graceful Restart */ | |
13750 | ||
f412b39a | 13751 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 13752 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 13753 | "show [ip] bgp attribute-info", |
718e3744 | 13754 | SHOW_STR |
13755 | IP_STR | |
13756 | BGP_STR | |
13757 | "List all bgp attribute information\n") | |
13758 | { | |
d62a17ae | 13759 | attr_show_all(vty); |
13760 | return CMD_SUCCESS; | |
718e3744 | 13761 | } |
6b0655a2 | 13762 | |
03915806 CS |
13763 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
13764 | afi_t afi, safi_t safi, | |
13765 | bool use_json, json_object *json) | |
53089bec | 13766 | { |
13767 | struct bgp *bgp; | |
13768 | struct listnode *node; | |
13769 | char *vname; | |
13770 | char buf1[INET6_ADDRSTRLEN]; | |
13771 | char *ecom_str; | |
13772 | vpn_policy_direction_t dir; | |
13773 | ||
03915806 | 13774 | if (json) { |
b46dfd20 DS |
13775 | json_object *json_import_vrfs = NULL; |
13776 | json_object *json_export_vrfs = NULL; | |
13777 | ||
b46dfd20 DS |
13778 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13779 | ||
53089bec | 13780 | if (!bgp) { |
b46dfd20 DS |
13781 | vty_out(vty, "%s\n", |
13782 | json_object_to_json_string_ext( | |
13783 | json, | |
13784 | JSON_C_TO_STRING_PRETTY)); | |
13785 | json_object_free(json); | |
13786 | ||
53089bec | 13787 | return CMD_WARNING; |
13788 | } | |
b46dfd20 | 13789 | |
94d4c685 DS |
13790 | /* Provide context for the block */ |
13791 | json_object_string_add(json, "vrf", name ? name : "default"); | |
13792 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 13793 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 13794 | |
b46dfd20 DS |
13795 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13796 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
13797 | json_object_string_add(json, "importFromVrfs", "none"); | |
13798 | json_object_string_add(json, "importRts", "none"); | |
13799 | } else { | |
6ce24e52 DS |
13800 | json_import_vrfs = json_object_new_array(); |
13801 | ||
b46dfd20 DS |
13802 | for (ALL_LIST_ELEMENTS_RO( |
13803 | bgp->vpn_policy[afi].import_vrf, | |
13804 | node, vname)) | |
13805 | json_object_array_add(json_import_vrfs, | |
13806 | json_object_new_string(vname)); | |
13807 | ||
b20875ea CS |
13808 | json_object_object_add(json, "importFromVrfs", |
13809 | json_import_vrfs); | |
b46dfd20 | 13810 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
13811 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13812 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13813 | bgp->vpn_policy[afi].rtlist[dir], |
13814 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13815 | json_object_string_add(json, "importRts", |
13816 | ecom_str); | |
13817 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13818 | } else | |
13819 | json_object_string_add(json, "importRts", | |
13820 | "none"); | |
b46dfd20 DS |
13821 | } |
13822 | ||
13823 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
13824 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
13825 | json_object_string_add(json, "exportToVrfs", "none"); | |
13826 | json_object_string_add(json, "routeDistinguisher", | |
13827 | "none"); | |
13828 | json_object_string_add(json, "exportRts", "none"); | |
13829 | } else { | |
6ce24e52 DS |
13830 | json_export_vrfs = json_object_new_array(); |
13831 | ||
b46dfd20 DS |
13832 | for (ALL_LIST_ELEMENTS_RO( |
13833 | bgp->vpn_policy[afi].export_vrf, | |
13834 | node, vname)) | |
13835 | json_object_array_add(json_export_vrfs, | |
13836 | json_object_new_string(vname)); | |
13837 | json_object_object_add(json, "exportToVrfs", | |
13838 | json_export_vrfs); | |
13839 | json_object_string_add(json, "routeDistinguisher", | |
13840 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13841 | buf1, RD_ADDRSTRLEN)); | |
13842 | ||
13843 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13844 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13845 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13846 | bgp->vpn_policy[afi].rtlist[dir], |
13847 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13848 | json_object_string_add(json, "exportRts", |
13849 | ecom_str); | |
13850 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13851 | } else | |
13852 | json_object_string_add(json, "exportRts", | |
13853 | "none"); | |
b46dfd20 DS |
13854 | } |
13855 | ||
03915806 CS |
13856 | if (use_json) { |
13857 | vty_out(vty, "%s\n", | |
13858 | json_object_to_json_string_ext(json, | |
b46dfd20 | 13859 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
13860 | json_object_free(json); |
13861 | } | |
53089bec | 13862 | } else { |
b46dfd20 DS |
13863 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13864 | ||
53089bec | 13865 | if (!bgp) { |
b46dfd20 | 13866 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 13867 | return CMD_WARNING; |
13868 | } | |
53089bec | 13869 | |
b46dfd20 DS |
13870 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13871 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
13872 | vty_out(vty, | |
13873 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 13874 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13875 | else { |
13876 | vty_out(vty, | |
13877 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 13878 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13879 | |
13880 | for (ALL_LIST_ELEMENTS_RO( | |
13881 | bgp->vpn_policy[afi].import_vrf, | |
13882 | node, vname)) | |
13883 | vty_out(vty, " %s\n", vname); | |
13884 | ||
13885 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
13886 | ecom_str = NULL; |
13887 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
13888 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13889 | bgp->vpn_policy[afi].rtlist[dir], |
13890 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 13891 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 13892 | |
b20875ea CS |
13893 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
13894 | } else | |
13895 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13896 | } |
53089bec | 13897 | |
b46dfd20 DS |
13898 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13899 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
13900 | vty_out(vty, | |
13901 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 13902 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13903 | else { |
13904 | vty_out(vty, | |
04c9077f | 13905 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 13906 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13907 | |
13908 | for (ALL_LIST_ELEMENTS_RO( | |
13909 | bgp->vpn_policy[afi].export_vrf, | |
13910 | node, vname)) | |
13911 | vty_out(vty, " %s\n", vname); | |
13912 | ||
13913 | vty_out(vty, "RD: %s\n", | |
13914 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13915 | buf1, RD_ADDRSTRLEN)); | |
13916 | ||
13917 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13918 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13919 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13920 | bgp->vpn_policy[afi].rtlist[dir], |
13921 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13922 | vty_out(vty, "Export RT: %s\n", ecom_str); |
13923 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13924 | } else | |
13925 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13926 | } |
53089bec | 13927 | } |
13928 | ||
13929 | return CMD_SUCCESS; | |
13930 | } | |
13931 | ||
03915806 CS |
13932 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
13933 | safi_t safi, bool use_json) | |
13934 | { | |
13935 | struct listnode *node, *nnode; | |
13936 | struct bgp *bgp; | |
13937 | char *vrf_name = NULL; | |
13938 | json_object *json = NULL; | |
13939 | json_object *json_vrf = NULL; | |
13940 | json_object *json_vrfs = NULL; | |
13941 | ||
13942 | if (use_json) { | |
13943 | json = json_object_new_object(); | |
13944 | json_vrfs = json_object_new_object(); | |
13945 | } | |
13946 | ||
13947 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
13948 | ||
13949 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
13950 | vrf_name = bgp->name; | |
13951 | ||
13952 | if (use_json) { | |
13953 | json_vrf = json_object_new_object(); | |
13954 | } else { | |
13955 | vty_out(vty, "\nInstance %s:\n", | |
13956 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13957 | ? VRF_DEFAULT_NAME : bgp->name); | |
13958 | } | |
13959 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
13960 | if (use_json) { | |
13961 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13962 | json_object_object_add(json_vrfs, | |
13963 | VRF_DEFAULT_NAME, json_vrf); | |
13964 | else | |
13965 | json_object_object_add(json_vrfs, vrf_name, | |
13966 | json_vrf); | |
13967 | } | |
13968 | } | |
13969 | ||
13970 | if (use_json) { | |
13971 | json_object_object_add(json, "vrfs", json_vrfs); | |
13972 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13973 | JSON_C_TO_STRING_PRETTY)); | |
13974 | json_object_free(json); | |
13975 | } | |
13976 | ||
13977 | return CMD_SUCCESS; | |
13978 | } | |
13979 | ||
53089bec | 13980 | /* "show [ip] bgp route-leak" command. */ |
13981 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13982 | show_ip_bgp_route_leak_cmd, |
13983 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13984 | SHOW_STR |
13985 | IP_STR | |
13986 | BGP_STR | |
13987 | BGP_INSTANCE_HELP_STR | |
13988 | BGP_AFI_HELP_STR | |
13989 | BGP_SAFI_HELP_STR | |
13990 | "Route leaking information\n" | |
13991 | JSON_STR) | |
53089bec | 13992 | { |
13993 | char *vrf = NULL; | |
13994 | afi_t afi = AFI_MAX; | |
13995 | safi_t safi = SAFI_MAX; | |
13996 | ||
9f049418 | 13997 | bool uj = use_json(argc, argv); |
53089bec | 13998 | int idx = 0; |
03915806 | 13999 | json_object *json = NULL; |
53089bec | 14000 | |
14001 | /* show [ip] bgp */ | |
14002 | if (argv_find(argv, argc, "ip", &idx)) { | |
14003 | afi = AFI_IP; | |
14004 | safi = SAFI_UNICAST; | |
14005 | } | |
14006 | /* [vrf VIEWVRFNAME] */ | |
14007 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
14008 | vty_out(vty, |
14009 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 14010 | return CMD_WARNING; |
14011 | } | |
14012 | ||
9a8bdf1c PG |
14013 | if (argv_find(argv, argc, "vrf", &idx)) { |
14014 | vrf = argv[idx + 1]->arg; | |
14015 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14016 | vrf = NULL; | |
14017 | } | |
53089bec | 14018 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14019 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14020 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14021 | } | |
14022 | ||
14023 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
14024 | vty_out(vty, |
14025 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 14026 | return CMD_WARNING; |
14027 | } | |
14028 | ||
03915806 CS |
14029 | if (vrf && strmatch(vrf, "all")) |
14030 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
14031 | ||
14032 | if (uj) | |
14033 | json = json_object_new_object(); | |
14034 | ||
14035 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 14036 | } |
14037 | ||
d62a17ae | 14038 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
14039 | safi_t safi) | |
f186de26 | 14040 | { |
d62a17ae | 14041 | struct listnode *node, *nnode; |
14042 | struct bgp *bgp; | |
f186de26 | 14043 | |
d62a17ae | 14044 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
14045 | vty_out(vty, "\nInstance %s:\n", | |
14046 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 14047 | ? VRF_DEFAULT_NAME |
d62a17ae | 14048 | : bgp->name); |
14049 | update_group_show(bgp, afi, safi, vty, 0); | |
14050 | } | |
f186de26 | 14051 | } |
14052 | ||
d62a17ae | 14053 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
14054 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 14055 | { |
d62a17ae | 14056 | struct bgp *bgp; |
4fb25c53 | 14057 | |
d62a17ae | 14058 | if (name) { |
14059 | if (strmatch(name, "all")) { | |
14060 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
14061 | return CMD_SUCCESS; | |
14062 | } else { | |
14063 | bgp = bgp_lookup_by_name(name); | |
14064 | } | |
14065 | } else { | |
14066 | bgp = bgp_get_default(); | |
14067 | } | |
4fb25c53 | 14068 | |
d62a17ae | 14069 | if (bgp) |
14070 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
14071 | return CMD_SUCCESS; | |
4fb25c53 DW |
14072 | } |
14073 | ||
8fe8a7f6 DS |
14074 | DEFUN (show_ip_bgp_updgrps, |
14075 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 14076 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 14077 | SHOW_STR |
14078 | IP_STR | |
14079 | BGP_STR | |
14080 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 14081 | BGP_AFI_HELP_STR |
9bedbb1e | 14082 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
14083 | "Detailed info about dynamic update groups\n" |
14084 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 14085 | { |
d62a17ae | 14086 | char *vrf = NULL; |
14087 | afi_t afi = AFI_IP6; | |
14088 | safi_t safi = SAFI_UNICAST; | |
14089 | uint64_t subgrp_id = 0; | |
14090 | ||
14091 | int idx = 0; | |
14092 | ||
14093 | /* show [ip] bgp */ | |
14094 | if (argv_find(argv, argc, "ip", &idx)) | |
14095 | afi = AFI_IP; | |
9a8bdf1c PG |
14096 | /* [<vrf> VIEWVRFNAME] */ |
14097 | if (argv_find(argv, argc, "vrf", &idx)) { | |
14098 | vrf = argv[idx + 1]->arg; | |
14099 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
14100 | vrf = NULL; | |
14101 | } else if (argv_find(argv, argc, "view", &idx)) | |
14102 | /* [<view> VIEWVRFNAME] */ | |
14103 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 14104 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
14105 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
14106 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
14107 | } | |
5bf15956 | 14108 | |
d62a17ae | 14109 | /* get subgroup id, if provided */ |
14110 | idx = argc - 1; | |
14111 | if (argv[idx]->type == VARIABLE_TKN) | |
14112 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 14113 | |
d62a17ae | 14114 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
14115 | } |
14116 | ||
f186de26 | 14117 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
14118 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 14119 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 14120 | SHOW_STR |
716b2d8a | 14121 | IP_STR |
f186de26 | 14122 | BGP_STR |
14123 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 14124 | "Detailed info about dynamic update groups\n") |
f186de26 | 14125 | { |
d62a17ae | 14126 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
14127 | return CMD_SUCCESS; | |
f186de26 | 14128 | } |
14129 | ||
43d3f4fc DS |
14130 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
14131 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
14132 | "show [ip] bgp l2vpn evpn update-groups", | |
14133 | SHOW_STR | |
14134 | IP_STR | |
14135 | BGP_STR | |
14136 | "l2vpn address family\n" | |
14137 | "evpn sub-address family\n" | |
14138 | "Detailed info about dynamic update groups\n") | |
14139 | { | |
14140 | char *vrf = NULL; | |
14141 | uint64_t subgrp_id = 0; | |
14142 | ||
14143 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
14144 | return CMD_SUCCESS; | |
14145 | } | |
14146 | ||
5bf15956 DW |
14147 | DEFUN (show_bgp_updgrps_stats, |
14148 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 14149 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 14150 | SHOW_STR |
716b2d8a | 14151 | IP_STR |
3f9c7369 | 14152 | BGP_STR |
0c7b1b01 | 14153 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
14154 | "Statistics\n") |
14155 | { | |
d62a17ae | 14156 | struct bgp *bgp; |
3f9c7369 | 14157 | |
d62a17ae | 14158 | bgp = bgp_get_default(); |
14159 | if (bgp) | |
14160 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 14161 | |
d62a17ae | 14162 | return CMD_SUCCESS; |
3f9c7369 DS |
14163 | } |
14164 | ||
8386ac43 | 14165 | DEFUN (show_bgp_instance_updgrps_stats, |
14166 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 14167 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 14168 | SHOW_STR |
716b2d8a | 14169 | IP_STR |
8386ac43 | 14170 | BGP_STR |
14171 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 14172 | "Detailed info about dynamic update groups\n" |
8386ac43 | 14173 | "Statistics\n") |
14174 | { | |
d62a17ae | 14175 | int idx_word = 3; |
14176 | struct bgp *bgp; | |
8386ac43 | 14177 | |
d62a17ae | 14178 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
14179 | if (bgp) | |
14180 | update_group_show_stats(bgp, vty); | |
8386ac43 | 14181 | |
d62a17ae | 14182 | return CMD_SUCCESS; |
8386ac43 | 14183 | } |
14184 | ||
d62a17ae | 14185 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
14186 | afi_t afi, safi_t safi, | |
14187 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 14188 | { |
d62a17ae | 14189 | struct bgp *bgp; |
8386ac43 | 14190 | |
d62a17ae | 14191 | if (name) |
14192 | bgp = bgp_lookup_by_name(name); | |
14193 | else | |
14194 | bgp = bgp_get_default(); | |
8386ac43 | 14195 | |
d62a17ae | 14196 | if (bgp) { |
14197 | if (!strcmp(what, "advertise-queue")) | |
14198 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
14199 | subgrp_id); | |
14200 | else if (!strcmp(what, "advertised-routes")) | |
14201 | update_group_show_advertised(bgp, afi, safi, vty, | |
14202 | subgrp_id); | |
14203 | else if (!strcmp(what, "packet-queue")) | |
14204 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
14205 | subgrp_id); | |
14206 | } | |
3f9c7369 DS |
14207 | } |
14208 | ||
dc64bdec QY |
14209 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
14210 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
14211 | "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", | |
14212 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
14213 | BGP_SAFI_HELP_STR | |
14214 | "Detailed info about dynamic update groups\n" | |
14215 | "Specific subgroup to display info for\n" | |
14216 | "Advertisement queue\n" | |
14217 | "Announced routes\n" | |
14218 | "Packet queue\n") | |
3f9c7369 | 14219 | { |
dc64bdec QY |
14220 | uint64_t subgrp_id = 0; |
14221 | afi_t afiz; | |
14222 | safi_t safiz; | |
14223 | if (sgid) | |
14224 | subgrp_id = strtoull(sgid, NULL, 10); | |
14225 | ||
14226 | if (!ip && !afi) | |
14227 | afiz = AFI_IP6; | |
14228 | if (!ip && afi) | |
14229 | afiz = bgp_vty_afi_from_str(afi); | |
14230 | if (ip && !afi) | |
14231 | afiz = AFI_IP; | |
14232 | if (ip && afi) { | |
14233 | afiz = bgp_vty_afi_from_str(afi); | |
14234 | if (afiz != AFI_IP) | |
14235 | vty_out(vty, | |
14236 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
14237 | return CMD_WARNING; | |
14238 | } | |
d62a17ae | 14239 | |
dc64bdec | 14240 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 14241 | |
dc64bdec | 14242 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 14243 | return CMD_SUCCESS; |
14244 | } | |
14245 | ||
d62a17ae | 14246 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
14247 | { | |
14248 | struct listnode *node, *nnode; | |
14249 | struct prefix *range; | |
14250 | struct peer *conf; | |
14251 | struct peer *peer; | |
d62a17ae | 14252 | afi_t afi; |
14253 | safi_t safi; | |
14254 | const char *peer_status; | |
14255 | const char *af_str; | |
14256 | int lr_count; | |
14257 | int dynamic; | |
14258 | int af_cfgd; | |
14259 | ||
14260 | conf = group->conf; | |
14261 | ||
14262 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
6cde4b45 | 14263 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 14264 | group->name, conf->as); |
d62a17ae | 14265 | } else if (conf->as_type == AS_INTERNAL) { |
6cde4b45 | 14266 | vty_out(vty, "\nBGP peer-group %s, remote AS %u\n", |
3b61f610 | 14267 | group->name, group->bgp->as); |
d62a17ae | 14268 | } else { |
14269 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
14270 | } | |
f14e6fdb | 14271 | |
d62a17ae | 14272 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
14273 | vty_out(vty, " Peer-group type is internal\n"); | |
14274 | else | |
14275 | vty_out(vty, " Peer-group type is external\n"); | |
14276 | ||
14277 | /* Display AFs configured. */ | |
14278 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
14279 | FOREACH_AFI_SAFI (afi, safi) { |
14280 | if (conf->afc[afi][safi]) { | |
14281 | af_cfgd = 1; | |
5cb5f4d0 | 14282 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 14283 | } |
05c7a1cc | 14284 | } |
d62a17ae | 14285 | if (!af_cfgd) |
14286 | vty_out(vty, " none\n"); | |
14287 | else | |
14288 | vty_out(vty, "\n"); | |
14289 | ||
14290 | /* Display listen ranges (for dynamic neighbors), if any */ | |
14291 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
14292 | if (afi == AFI_IP) | |
14293 | af_str = "IPv4"; | |
14294 | else if (afi == AFI_IP6) | |
14295 | af_str = "IPv6"; | |
14296 | else | |
14297 | af_str = "???"; | |
14298 | lr_count = listcount(group->listen_range[afi]); | |
14299 | if (lr_count) { | |
14300 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
14301 | af_str); | |
14302 | ||
14303 | ||
14304 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
2dbe669b DA |
14305 | nnode, range)) |
14306 | vty_out(vty, " %pFX\n", range); | |
d62a17ae | 14307 | } |
14308 | } | |
f14e6fdb | 14309 | |
d62a17ae | 14310 | /* Display group members and their status */ |
14311 | if (listcount(group->peer)) { | |
14312 | vty_out(vty, " Peer-group members:\n"); | |
14313 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
cb9196e7 DS |
14314 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN) |
14315 | || CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHUTDOWN)) | |
d62a17ae | 14316 | peer_status = "Idle (Admin)"; |
14317 | else if (CHECK_FLAG(peer->sflags, | |
14318 | PEER_STATUS_PREFIX_OVERFLOW)) | |
14319 | peer_status = "Idle (PfxCt)"; | |
14320 | else | |
14321 | peer_status = lookup_msg(bgp_status_msg, | |
14322 | peer->status, NULL); | |
14323 | ||
14324 | dynamic = peer_dynamic_neighbor(peer); | |
14325 | vty_out(vty, " %s %s %s \n", peer->host, | |
14326 | dynamic ? "(dynamic)" : "", peer_status); | |
14327 | } | |
14328 | } | |
f14e6fdb | 14329 | |
d62a17ae | 14330 | return CMD_SUCCESS; |
14331 | } | |
14332 | ||
ff9959b0 QY |
14333 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
14334 | const char *group_name) | |
d62a17ae | 14335 | { |
ff9959b0 | 14336 | struct bgp *bgp; |
d62a17ae | 14337 | struct listnode *node, *nnode; |
14338 | struct peer_group *group; | |
ff9959b0 QY |
14339 | bool found = false; |
14340 | ||
14341 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
14342 | ||
14343 | if (!bgp) { | |
9f049418 | 14344 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
14345 | return CMD_WARNING; |
14346 | } | |
d62a17ae | 14347 | |
14348 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
14349 | if (group_name) { |
14350 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 14351 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
14352 | found = true; |
14353 | break; | |
d62a17ae | 14354 | } |
ff9959b0 QY |
14355 | } else { |
14356 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 14357 | } |
f14e6fdb | 14358 | } |
f14e6fdb | 14359 | |
ff9959b0 | 14360 | if (group_name && !found) |
d62a17ae | 14361 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 14362 | |
d62a17ae | 14363 | return CMD_SUCCESS; |
f14e6fdb DS |
14364 | } |
14365 | ||
f14e6fdb DS |
14366 | DEFUN (show_ip_bgp_peer_groups, |
14367 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 14368 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
14369 | SHOW_STR |
14370 | IP_STR | |
14371 | BGP_STR | |
8386ac43 | 14372 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
14373 | "Detailed information on BGP peer groups\n" |
14374 | "Peer group name\n") | |
f14e6fdb | 14375 | { |
d62a17ae | 14376 | char *vrf, *pg; |
d62a17ae | 14377 | int idx = 0; |
f14e6fdb | 14378 | |
a4d82a8a PZ |
14379 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
14380 | : NULL; | |
d62a17ae | 14381 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 14382 | |
ff9959b0 | 14383 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 14384 | } |
3f9c7369 | 14385 | |
d6e3c605 | 14386 | |
718e3744 | 14387 | /* Redistribute VTY commands. */ |
14388 | ||
718e3744 | 14389 | DEFUN (bgp_redistribute_ipv4, |
14390 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 14391 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 14392 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14393 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 14394 | { |
d62a17ae | 14395 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14396 | int idx_protocol = 1; | |
14397 | int type; | |
718e3744 | 14398 | |
d62a17ae | 14399 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
14400 | if (type < 0) { | |
14401 | vty_out(vty, "%% Invalid route type\n"); | |
14402 | return CMD_WARNING_CONFIG_FAILED; | |
14403 | } | |
7f323236 | 14404 | |
d62a17ae | 14405 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 14406 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 14407 | } |
14408 | ||
d62a17ae | 14409 | ALIAS_HIDDEN( |
14410 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
14411 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
14412 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 14413 | |
718e3744 | 14414 | DEFUN (bgp_redistribute_ipv4_rmap, |
14415 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 14416 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14417 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14418 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14419 | "Route map reference\n" |
14420 | "Pointer to route-map entries\n") | |
14421 | { | |
d62a17ae | 14422 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14423 | int idx_protocol = 1; | |
14424 | int idx_word = 3; | |
14425 | int type; | |
14426 | struct bgp_redist *red; | |
e923dd62 | 14427 | bool changed; |
1de27621 DA |
14428 | struct route_map *route_map = route_map_lookup_warn_noexist( |
14429 | vty, argv[idx_word]->arg); | |
718e3744 | 14430 | |
d62a17ae | 14431 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
14432 | if (type < 0) { | |
14433 | vty_out(vty, "%% Invalid route type\n"); | |
14434 | return CMD_WARNING_CONFIG_FAILED; | |
14435 | } | |
718e3744 | 14436 | |
d62a17ae | 14437 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
14438 | changed = |
14439 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14440 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 14441 | } |
14442 | ||
d62a17ae | 14443 | ALIAS_HIDDEN( |
14444 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
14445 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
14446 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14447 | "Route map reference\n" | |
14448 | "Pointer to route-map entries\n") | |
596c17ba | 14449 | |
718e3744 | 14450 | DEFUN (bgp_redistribute_ipv4_metric, |
14451 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 14452 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14453 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14454 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14455 | "Metric for redistributed routes\n" |
14456 | "Default metric\n") | |
14457 | { | |
d62a17ae | 14458 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14459 | int idx_protocol = 1; | |
14460 | int idx_number = 3; | |
14461 | int type; | |
d7c0a89a | 14462 | uint32_t metric; |
d62a17ae | 14463 | struct bgp_redist *red; |
e923dd62 | 14464 | bool changed; |
d62a17ae | 14465 | |
14466 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14467 | if (type < 0) { | |
14468 | vty_out(vty, "%% Invalid route type\n"); | |
14469 | return CMD_WARNING_CONFIG_FAILED; | |
14470 | } | |
14471 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
14472 | ||
14473 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 14474 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
14475 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 14476 | } |
14477 | ||
14478 | ALIAS_HIDDEN( | |
14479 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
14480 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
14481 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14482 | "Metric for redistributed routes\n" | |
14483 | "Default metric\n") | |
596c17ba | 14484 | |
718e3744 | 14485 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
14486 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 14487 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14488 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14489 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14490 | "Route map reference\n" |
14491 | "Pointer to route-map entries\n" | |
14492 | "Metric for redistributed routes\n" | |
14493 | "Default metric\n") | |
14494 | { | |
d62a17ae | 14495 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14496 | int idx_protocol = 1; | |
14497 | int idx_word = 3; | |
14498 | int idx_number = 5; | |
14499 | int type; | |
d7c0a89a | 14500 | uint32_t metric; |
d62a17ae | 14501 | struct bgp_redist *red; |
e923dd62 | 14502 | bool changed; |
1de27621 DA |
14503 | struct route_map *route_map = |
14504 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14505 | |
14506 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14507 | if (type < 0) { | |
14508 | vty_out(vty, "%% Invalid route type\n"); | |
14509 | return CMD_WARNING_CONFIG_FAILED; | |
14510 | } | |
14511 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
14512 | ||
14513 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
14514 | changed = |
14515 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14516 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
14517 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 14518 | } |
14519 | ||
14520 | ALIAS_HIDDEN( | |
14521 | bgp_redistribute_ipv4_rmap_metric, | |
14522 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
14523 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
14524 | " route-map WORD metric (0-4294967295)", | |
14525 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14526 | "Route map reference\n" | |
14527 | "Pointer to route-map entries\n" | |
14528 | "Metric for redistributed routes\n" | |
14529 | "Default metric\n") | |
596c17ba | 14530 | |
718e3744 | 14531 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
14532 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 14533 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14534 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14535 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 14536 | "Metric for redistributed routes\n" |
14537 | "Default metric\n" | |
14538 | "Route map reference\n" | |
14539 | "Pointer to route-map entries\n") | |
14540 | { | |
d62a17ae | 14541 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14542 | int idx_protocol = 1; | |
14543 | int idx_number = 3; | |
14544 | int idx_word = 5; | |
14545 | int type; | |
d7c0a89a | 14546 | uint32_t metric; |
d62a17ae | 14547 | struct bgp_redist *red; |
e923dd62 | 14548 | bool changed; |
1de27621 DA |
14549 | struct route_map *route_map = |
14550 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14551 | |
14552 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14553 | if (type < 0) { | |
14554 | vty_out(vty, "%% Invalid route type\n"); | |
14555 | return CMD_WARNING_CONFIG_FAILED; | |
14556 | } | |
14557 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
14558 | ||
14559 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 14560 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
14561 | changed |= |
14562 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14563 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 14564 | } |
14565 | ||
14566 | ALIAS_HIDDEN( | |
14567 | bgp_redistribute_ipv4_metric_rmap, | |
14568 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
14569 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
14570 | " metric (0-4294967295) route-map WORD", | |
14571 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14572 | "Metric for redistributed routes\n" | |
14573 | "Default metric\n" | |
14574 | "Route map reference\n" | |
14575 | "Pointer to route-map entries\n") | |
596c17ba | 14576 | |
7c8ff89e DS |
14577 | DEFUN (bgp_redistribute_ipv4_ospf, |
14578 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 14579 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
14580 | "Redistribute information from another routing protocol\n" |
14581 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14582 | "Non-main Kernel Routing Table\n" |
14583 | "Instance ID/Table ID\n") | |
7c8ff89e | 14584 | { |
d62a17ae | 14585 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14586 | int idx_ospf_table = 1; | |
14587 | int idx_number = 2; | |
d7c0a89a QY |
14588 | unsigned short instance; |
14589 | unsigned short protocol; | |
7c8ff89e | 14590 | |
d62a17ae | 14591 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 14592 | |
d62a17ae | 14593 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
14594 | protocol = ZEBRA_ROUTE_OSPF; | |
14595 | else | |
14596 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 14597 | |
d62a17ae | 14598 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 14599 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
14600 | } |
14601 | ||
d62a17ae | 14602 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
14603 | "redistribute <ospf|table> (1-65535)", | |
14604 | "Redistribute information from another routing protocol\n" | |
14605 | "Open Shortest Path First (OSPFv2)\n" | |
14606 | "Non-main Kernel Routing Table\n" | |
14607 | "Instance ID/Table ID\n") | |
596c17ba | 14608 | |
7c8ff89e DS |
14609 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
14610 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 14611 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
14612 | "Redistribute information from another routing protocol\n" |
14613 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14614 | "Non-main Kernel Routing Table\n" |
14615 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14616 | "Route map reference\n" |
14617 | "Pointer to route-map entries\n") | |
14618 | { | |
d62a17ae | 14619 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14620 | int idx_ospf_table = 1; | |
14621 | int idx_number = 2; | |
14622 | int idx_word = 4; | |
14623 | struct bgp_redist *red; | |
d7c0a89a | 14624 | unsigned short instance; |
d62a17ae | 14625 | int protocol; |
e923dd62 | 14626 | bool changed; |
1de27621 DA |
14627 | struct route_map *route_map = |
14628 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14629 | |
14630 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14631 | protocol = ZEBRA_ROUTE_OSPF; | |
14632 | else | |
14633 | protocol = ZEBRA_ROUTE_TABLE; | |
14634 | ||
14635 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14636 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
14637 | changed = |
14638 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14639 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 14640 | } |
14641 | ||
14642 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
14643 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
14644 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
14645 | "Redistribute information from another routing protocol\n" | |
14646 | "Open Shortest Path First (OSPFv2)\n" | |
14647 | "Non-main Kernel Routing Table\n" | |
14648 | "Instance ID/Table ID\n" | |
14649 | "Route map reference\n" | |
14650 | "Pointer to route-map entries\n") | |
596c17ba | 14651 | |
7c8ff89e DS |
14652 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
14653 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 14654 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
14655 | "Redistribute information from another routing protocol\n" |
14656 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14657 | "Non-main Kernel Routing Table\n" |
14658 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14659 | "Metric for redistributed routes\n" |
14660 | "Default metric\n") | |
14661 | { | |
d62a17ae | 14662 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14663 | int idx_ospf_table = 1; | |
14664 | int idx_number = 2; | |
14665 | int idx_number_2 = 4; | |
d7c0a89a | 14666 | uint32_t metric; |
d62a17ae | 14667 | struct bgp_redist *red; |
d7c0a89a | 14668 | unsigned short instance; |
d62a17ae | 14669 | int protocol; |
e923dd62 | 14670 | bool changed; |
d62a17ae | 14671 | |
14672 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14673 | protocol = ZEBRA_ROUTE_OSPF; | |
14674 | else | |
14675 | protocol = ZEBRA_ROUTE_TABLE; | |
14676 | ||
14677 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14678 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14679 | ||
14680 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14681 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14682 | metric); | |
14683 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 14684 | } |
14685 | ||
14686 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
14687 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
14688 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
14689 | "Redistribute information from another routing protocol\n" | |
14690 | "Open Shortest Path First (OSPFv2)\n" | |
14691 | "Non-main Kernel Routing Table\n" | |
14692 | "Instance ID/Table ID\n" | |
14693 | "Metric for redistributed routes\n" | |
14694 | "Default metric\n") | |
596c17ba | 14695 | |
7c8ff89e DS |
14696 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
14697 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 14698 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
14699 | "Redistribute information from another routing protocol\n" |
14700 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14701 | "Non-main Kernel Routing Table\n" |
14702 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14703 | "Route map reference\n" |
14704 | "Pointer to route-map entries\n" | |
14705 | "Metric for redistributed routes\n" | |
14706 | "Default metric\n") | |
14707 | { | |
d62a17ae | 14708 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14709 | int idx_ospf_table = 1; | |
14710 | int idx_number = 2; | |
14711 | int idx_word = 4; | |
14712 | int idx_number_2 = 6; | |
d7c0a89a | 14713 | uint32_t metric; |
d62a17ae | 14714 | struct bgp_redist *red; |
d7c0a89a | 14715 | unsigned short instance; |
d62a17ae | 14716 | int protocol; |
e923dd62 | 14717 | bool changed; |
1de27621 DA |
14718 | struct route_map *route_map = |
14719 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14720 | |
14721 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14722 | protocol = ZEBRA_ROUTE_OSPF; | |
14723 | else | |
14724 | protocol = ZEBRA_ROUTE_TABLE; | |
14725 | ||
14726 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14727 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14728 | ||
14729 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
14730 | changed = |
14731 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14732 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14733 | metric); | |
14734 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 14735 | } |
14736 | ||
14737 | ALIAS_HIDDEN( | |
14738 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
14739 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
14740 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
14741 | "Redistribute information from another routing protocol\n" | |
14742 | "Open Shortest Path First (OSPFv2)\n" | |
14743 | "Non-main Kernel Routing Table\n" | |
14744 | "Instance ID/Table ID\n" | |
14745 | "Route map reference\n" | |
14746 | "Pointer to route-map entries\n" | |
14747 | "Metric for redistributed routes\n" | |
14748 | "Default metric\n") | |
596c17ba | 14749 | |
7c8ff89e DS |
14750 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
14751 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 14752 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
14753 | "Redistribute information from another routing protocol\n" |
14754 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
14755 | "Non-main Kernel Routing Table\n" |
14756 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
14757 | "Metric for redistributed routes\n" |
14758 | "Default metric\n" | |
14759 | "Route map reference\n" | |
14760 | "Pointer to route-map entries\n") | |
14761 | { | |
d62a17ae | 14762 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14763 | int idx_ospf_table = 1; | |
14764 | int idx_number = 2; | |
14765 | int idx_number_2 = 4; | |
14766 | int idx_word = 6; | |
d7c0a89a | 14767 | uint32_t metric; |
d62a17ae | 14768 | struct bgp_redist *red; |
d7c0a89a | 14769 | unsigned short instance; |
d62a17ae | 14770 | int protocol; |
e923dd62 | 14771 | bool changed; |
1de27621 DA |
14772 | struct route_map *route_map = |
14773 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14774 | |
14775 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14776 | protocol = ZEBRA_ROUTE_OSPF; | |
14777 | else | |
14778 | protocol = ZEBRA_ROUTE_TABLE; | |
14779 | ||
14780 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14781 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14782 | ||
14783 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14784 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14785 | metric); | |
1de27621 DA |
14786 | changed |= |
14787 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14788 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 14789 | } |
14790 | ||
14791 | ALIAS_HIDDEN( | |
14792 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
14793 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
14794 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
14795 | "Redistribute information from another routing protocol\n" | |
14796 | "Open Shortest Path First (OSPFv2)\n" | |
14797 | "Non-main Kernel Routing Table\n" | |
14798 | "Instance ID/Table ID\n" | |
14799 | "Metric for redistributed routes\n" | |
14800 | "Default metric\n" | |
14801 | "Route map reference\n" | |
14802 | "Pointer to route-map entries\n") | |
596c17ba | 14803 | |
7c8ff89e DS |
14804 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
14805 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 14806 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
14807 | NO_STR |
14808 | "Redistribute information from another routing protocol\n" | |
14809 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 14810 | "Non-main Kernel Routing Table\n" |
31500417 DW |
14811 | "Instance ID/Table ID\n" |
14812 | "Metric for redistributed routes\n" | |
14813 | "Default metric\n" | |
14814 | "Route map reference\n" | |
14815 | "Pointer to route-map entries\n") | |
7c8ff89e | 14816 | { |
d62a17ae | 14817 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14818 | int idx_ospf_table = 2; | |
14819 | int idx_number = 3; | |
d7c0a89a | 14820 | unsigned short instance; |
d62a17ae | 14821 | int protocol; |
14822 | ||
14823 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14824 | protocol = ZEBRA_ROUTE_OSPF; | |
14825 | else | |
14826 | protocol = ZEBRA_ROUTE_TABLE; | |
14827 | ||
14828 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14829 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
14830 | } | |
14831 | ||
14832 | ALIAS_HIDDEN( | |
14833 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 14834 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14835 | NO_STR |
14836 | "Redistribute information from another routing protocol\n" | |
14837 | "Open Shortest Path First (OSPFv2)\n" | |
14838 | "Non-main Kernel Routing Table\n" | |
14839 | "Instance ID/Table ID\n" | |
14840 | "Metric for redistributed routes\n" | |
14841 | "Default metric\n" | |
14842 | "Route map reference\n" | |
14843 | "Pointer to route-map entries\n") | |
596c17ba | 14844 | |
718e3744 | 14845 | DEFUN (no_bgp_redistribute_ipv4, |
14846 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 14847 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14848 | NO_STR |
14849 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14850 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
14851 | "Metric for redistributed routes\n" |
14852 | "Default metric\n" | |
14853 | "Route map reference\n" | |
14854 | "Pointer to route-map entries\n") | |
718e3744 | 14855 | { |
d62a17ae | 14856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14857 | int idx_protocol = 2; | |
14858 | int type; | |
14859 | ||
14860 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14861 | if (type < 0) { | |
14862 | vty_out(vty, "%% Invalid route type\n"); | |
14863 | return CMD_WARNING_CONFIG_FAILED; | |
14864 | } | |
14865 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
14866 | } | |
14867 | ||
14868 | ALIAS_HIDDEN( | |
14869 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
14870 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 14871 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14872 | NO_STR |
14873 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14874 | "Metric for redistributed routes\n" | |
14875 | "Default metric\n" | |
14876 | "Route map reference\n" | |
14877 | "Pointer to route-map entries\n") | |
596c17ba | 14878 | |
718e3744 | 14879 | DEFUN (bgp_redistribute_ipv6, |
14880 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 14881 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 14882 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14883 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 14884 | { |
d62a17ae | 14885 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14886 | int idx_protocol = 1; | |
14887 | int type; | |
718e3744 | 14888 | |
d62a17ae | 14889 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14890 | if (type < 0) { | |
14891 | vty_out(vty, "%% Invalid route type\n"); | |
14892 | return CMD_WARNING_CONFIG_FAILED; | |
14893 | } | |
718e3744 | 14894 | |
d62a17ae | 14895 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14896 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 14897 | } |
14898 | ||
14899 | DEFUN (bgp_redistribute_ipv6_rmap, | |
14900 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 14901 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14902 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14903 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14904 | "Route map reference\n" |
14905 | "Pointer to route-map entries\n") | |
14906 | { | |
d62a17ae | 14907 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14908 | int idx_protocol = 1; | |
14909 | int idx_word = 3; | |
14910 | int type; | |
14911 | struct bgp_redist *red; | |
e923dd62 | 14912 | bool changed; |
1de27621 DA |
14913 | struct route_map *route_map = |
14914 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 14915 | |
d62a17ae | 14916 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14917 | if (type < 0) { | |
14918 | vty_out(vty, "%% Invalid route type\n"); | |
14919 | return CMD_WARNING_CONFIG_FAILED; | |
14920 | } | |
718e3744 | 14921 | |
d62a17ae | 14922 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14923 | changed = |
14924 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14925 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14926 | } |
14927 | ||
14928 | DEFUN (bgp_redistribute_ipv6_metric, | |
14929 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 14930 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14931 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14932 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14933 | "Metric for redistributed routes\n" |
14934 | "Default metric\n") | |
14935 | { | |
d62a17ae | 14936 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14937 | int idx_protocol = 1; | |
14938 | int idx_number = 3; | |
14939 | int type; | |
d7c0a89a | 14940 | uint32_t metric; |
d62a17ae | 14941 | struct bgp_redist *red; |
e923dd62 | 14942 | bool changed; |
d62a17ae | 14943 | |
14944 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14945 | if (type < 0) { | |
14946 | vty_out(vty, "%% Invalid route type\n"); | |
14947 | return CMD_WARNING_CONFIG_FAILED; | |
14948 | } | |
14949 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14950 | |
d62a17ae | 14951 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14952 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
14953 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14954 | } |
14955 | ||
14956 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
14957 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 14958 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14959 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14960 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14961 | "Route map reference\n" |
14962 | "Pointer to route-map entries\n" | |
14963 | "Metric for redistributed routes\n" | |
14964 | "Default metric\n") | |
14965 | { | |
d62a17ae | 14966 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14967 | int idx_protocol = 1; | |
14968 | int idx_word = 3; | |
14969 | int idx_number = 5; | |
14970 | int type; | |
d7c0a89a | 14971 | uint32_t metric; |
d62a17ae | 14972 | struct bgp_redist *red; |
e923dd62 | 14973 | bool changed; |
1de27621 DA |
14974 | struct route_map *route_map = |
14975 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14976 | |
14977 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14978 | if (type < 0) { | |
14979 | vty_out(vty, "%% Invalid route type\n"); | |
14980 | return CMD_WARNING_CONFIG_FAILED; | |
14981 | } | |
14982 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14983 | |
d62a17ae | 14984 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14985 | changed = |
14986 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14987 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14988 | metric); | |
14989 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14990 | } |
14991 | ||
14992 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14993 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14994 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14995 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14996 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14997 | "Metric for redistributed routes\n" |
14998 | "Default metric\n" | |
14999 | "Route map reference\n" | |
15000 | "Pointer to route-map entries\n") | |
15001 | { | |
d62a17ae | 15002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15003 | int idx_protocol = 1; | |
15004 | int idx_number = 3; | |
15005 | int idx_word = 5; | |
15006 | int type; | |
d7c0a89a | 15007 | uint32_t metric; |
d62a17ae | 15008 | struct bgp_redist *red; |
e923dd62 | 15009 | bool changed; |
1de27621 DA |
15010 | struct route_map *route_map = |
15011 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 15012 | |
15013 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
15014 | if (type < 0) { | |
15015 | vty_out(vty, "%% Invalid route type\n"); | |
15016 | return CMD_WARNING_CONFIG_FAILED; | |
15017 | } | |
15018 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 15019 | |
d62a17ae | 15020 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 15021 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
15022 | metric); | |
1de27621 DA |
15023 | changed |= |
15024 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 15025 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 15026 | } |
15027 | ||
15028 | DEFUN (no_bgp_redistribute_ipv6, | |
15029 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 15030 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 15031 | NO_STR |
15032 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 15033 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
15034 | "Metric for redistributed routes\n" |
15035 | "Default metric\n" | |
15036 | "Route map reference\n" | |
15037 | "Pointer to route-map entries\n") | |
718e3744 | 15038 | { |
d62a17ae | 15039 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
15040 | int idx_protocol = 2; | |
15041 | int type; | |
718e3744 | 15042 | |
d62a17ae | 15043 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
15044 | if (type < 0) { | |
15045 | vty_out(vty, "%% Invalid route type\n"); | |
15046 | return CMD_WARNING_CONFIG_FAILED; | |
15047 | } | |
718e3744 | 15048 | |
d62a17ae | 15049 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
15050 | } | |
15051 | ||
dd65f45e DL |
15052 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
15053 | afi_t afi, safi_t safi) | |
d62a17ae | 15054 | { |
15055 | int i; | |
15056 | ||
15057 | /* Unicast redistribution only. */ | |
15058 | if (safi != SAFI_UNICAST) | |
2b791107 | 15059 | return; |
d62a17ae | 15060 | |
15061 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
15062 | /* Redistribute BGP does not make sense. */ | |
15063 | if (i != ZEBRA_ROUTE_BGP) { | |
15064 | struct list *red_list; | |
15065 | struct listnode *node; | |
15066 | struct bgp_redist *red; | |
15067 | ||
15068 | red_list = bgp->redist[afi][i]; | |
15069 | if (!red_list) | |
15070 | continue; | |
15071 | ||
15072 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 15073 | /* "redistribute" configuration. */ |
15074 | vty_out(vty, " redistribute %s", | |
15075 | zebra_route_string(i)); | |
15076 | if (red->instance) | |
15077 | vty_out(vty, " %d", red->instance); | |
15078 | if (red->redist_metric_flag) | |
15079 | vty_out(vty, " metric %u", | |
15080 | red->redist_metric); | |
15081 | if (red->rmap.name) | |
15082 | vty_out(vty, " route-map %s", | |
15083 | red->rmap.name); | |
15084 | vty_out(vty, "\n"); | |
15085 | } | |
15086 | } | |
15087 | } | |
718e3744 | 15088 | } |
6b0655a2 | 15089 | |
dd65f45e DL |
15090 | /* peer-group helpers for config-write */ |
15091 | ||
15092 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
15093 | { | |
15094 | if (!peer_group_active(peer)) { | |
15095 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
15096 | return !CHECK_FLAG(peer->flags, flag); | |
15097 | else | |
15098 | return !!CHECK_FLAG(peer->flags, flag); | |
15099 | } | |
15100 | ||
15101 | return !!CHECK_FLAG(peer->flags_override, flag); | |
15102 | } | |
15103 | ||
15104 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
15105 | uint32_t flag) | |
15106 | { | |
15107 | if (!peer_group_active(peer)) { | |
15108 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
15109 | return !peer_af_flag_check(peer, afi, safi, flag); | |
15110 | else | |
15111 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
15112 | } | |
15113 | ||
15114 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
15115 | } | |
15116 | ||
15117 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
15118 | uint8_t type, int direct) | |
15119 | { | |
15120 | struct bgp_filter *filter; | |
15121 | ||
15122 | if (peer_group_active(peer)) | |
15123 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
15124 | type); | |
15125 | ||
15126 | filter = &peer->filter[afi][safi]; | |
15127 | switch (type) { | |
15128 | case PEER_FT_DISTRIBUTE_LIST: | |
15129 | return !!(filter->dlist[direct].name); | |
15130 | case PEER_FT_FILTER_LIST: | |
15131 | return !!(filter->aslist[direct].name); | |
15132 | case PEER_FT_PREFIX_LIST: | |
15133 | return !!(filter->plist[direct].name); | |
15134 | case PEER_FT_ROUTE_MAP: | |
15135 | return !!(filter->map[direct].name); | |
15136 | case PEER_FT_UNSUPPRESS_MAP: | |
15137 | return !!(filter->usmap.name); | |
7f7940e6 MK |
15138 | case PEER_FT_ADVERTISE_MAP: |
15139 | return !!(filter->advmap.aname | |
15140 | && ((filter->advmap.condition == direct) | |
15141 | && filter->advmap.cname)); | |
dd65f45e DL |
15142 | default: |
15143 | return false; | |
15144 | } | |
15145 | } | |
15146 | ||
15147 | /* Return true if the addpath type is set for peer and different from | |
15148 | * peer-group. | |
15149 | */ | |
3dc339cd DA |
15150 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
15151 | safi_t safi) | |
dd65f45e DL |
15152 | { |
15153 | enum bgp_addpath_strat type, g_type; | |
15154 | ||
15155 | type = peer->addpath_type[afi][safi]; | |
15156 | ||
15157 | if (type != BGP_ADDPATH_NONE) { | |
15158 | if (peer_group_active(peer)) { | |
15159 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
15160 | ||
15161 | if (type != g_type) | |
3dc339cd | 15162 | return true; |
dd65f45e | 15163 | else |
3dc339cd | 15164 | return false; |
dd65f45e DL |
15165 | } |
15166 | ||
3dc339cd | 15167 | return true; |
dd65f45e DL |
15168 | } |
15169 | ||
3dc339cd | 15170 | return false; |
dd65f45e DL |
15171 | } |
15172 | ||
b9c7bc5a | 15173 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 15174 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
15175 | afi_t afi) |
15176 | { | |
b9c7bc5a | 15177 | int indent = 2; |
ddb5b488 | 15178 | |
8a066a70 | 15179 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
15180 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
15181 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
15182 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
15183 | bgp->vpn_policy[afi] | |
bb4f6190 | 15184 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
15185 | else |
15186 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
15187 | bgp->vpn_policy[afi] | |
15188 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
15189 | } | |
12a844a5 DS |
15190 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
15191 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
15192 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
15193 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
15194 | return; | |
15195 | ||
e70e9f8e PZ |
15196 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
15197 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
15198 | ||
15199 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
15200 | ||
15201 | } else { | |
15202 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
15203 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
15204 | bgp->vpn_policy[afi].tovpn_label); | |
15205 | } | |
ddb5b488 PZ |
15206 | } |
15207 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
15208 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
15209 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 15210 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
15211 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
15212 | sizeof(buf))); | |
15213 | } | |
15214 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
15215 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
15216 | ||
15217 | char buf[PREFIX_STRLEN]; | |
15218 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
15219 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
15220 | sizeof(buf))) { | |
15221 | ||
b9c7bc5a PZ |
15222 | vty_out(vty, "%*snexthop vpn export %s\n", |
15223 | indent, "", buf); | |
ddb5b488 PZ |
15224 | } |
15225 | } | |
15226 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
15227 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
15228 | && ecommunity_cmp( | |
15229 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
15230 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
15231 | ||
15232 | char *b = ecommunity_ecom2str( | |
15233 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
15234 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 15235 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
15236 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15237 | } else { | |
15238 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
15239 | char *b = ecommunity_ecom2str( | |
15240 | bgp->vpn_policy[afi] | |
15241 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
15242 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
15243 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 15244 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
15245 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15246 | } | |
15247 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
15248 | char *b = ecommunity_ecom2str( | |
15249 | bgp->vpn_policy[afi] | |
15250 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
15251 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
15252 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 15253 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
15254 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15255 | } | |
15256 | } | |
bb4f6190 DS |
15257 | |
15258 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 15259 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
15260 | bgp->vpn_policy[afi] |
15261 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 15262 | |
301ad80a PG |
15263 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
15264 | char *b = ecommunity_ecom2str( | |
15265 | bgp->vpn_policy[afi] | |
15266 | .import_redirect_rtlist, | |
15267 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
15268 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 15269 | |
9a659715 PG |
15270 | if (bgp->vpn_policy[afi].import_redirect_rtlist->unit_size |
15271 | != ECOMMUNITY_SIZE) | |
c6423c31 | 15272 | vty_out(vty, "%*srt6 redirect import %s\n", |
9a659715 PG |
15273 | indent, "", b); |
15274 | else | |
15275 | vty_out(vty, "%*srt redirect import %s\n", | |
15276 | indent, "", b); | |
301ad80a PG |
15277 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
15278 | } | |
ddb5b488 PZ |
15279 | } |
15280 | ||
dd65f45e DL |
15281 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
15282 | afi_t afi, safi_t safi) | |
15283 | { | |
15284 | struct bgp_filter *filter; | |
15285 | char *addr; | |
15286 | ||
15287 | addr = peer->host; | |
15288 | filter = &peer->filter[afi][safi]; | |
15289 | ||
15290 | /* distribute-list. */ | |
15291 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
15292 | FILTER_IN)) | |
15293 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
15294 | filter->dlist[FILTER_IN].name); | |
15295 | ||
15296 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
15297 | FILTER_OUT)) | |
15298 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
15299 | filter->dlist[FILTER_OUT].name); | |
15300 | ||
15301 | /* prefix-list. */ | |
15302 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
15303 | FILTER_IN)) | |
15304 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
15305 | filter->plist[FILTER_IN].name); | |
15306 | ||
15307 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
15308 | FILTER_OUT)) | |
15309 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
15310 | filter->plist[FILTER_OUT].name); | |
15311 | ||
15312 | /* route-map. */ | |
15313 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
15314 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
15315 | filter->map[RMAP_IN].name); | |
15316 | ||
15317 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
15318 | RMAP_OUT)) | |
15319 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
15320 | filter->map[RMAP_OUT].name); | |
15321 | ||
15322 | /* unsuppress-map */ | |
15323 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
15324 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
15325 | filter->usmap.name); | |
15326 | ||
7f7940e6 MK |
15327 | /* advertise-map : always applied in OUT direction*/ |
15328 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
15329 | CONDITION_NON_EXIST)) | |
15330 | vty_out(vty, | |
15331 | " neighbor %s advertise-map %s non-exist-map %s\n", | |
15332 | addr, filter->advmap.aname, filter->advmap.cname); | |
15333 | ||
15334 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ADVERTISE_MAP, | |
15335 | CONDITION_EXIST)) | |
15336 | vty_out(vty, " neighbor %s advertise-map %s exist-map %s\n", | |
15337 | addr, filter->advmap.aname, filter->advmap.cname); | |
15338 | ||
dd65f45e DL |
15339 | /* filter-list. */ |
15340 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
15341 | FILTER_IN)) | |
15342 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
15343 | filter->aslist[FILTER_IN].name); | |
15344 | ||
15345 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
15346 | FILTER_OUT)) | |
15347 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
15348 | filter->aslist[FILTER_OUT].name); | |
15349 | } | |
15350 | ||
15351 | /* BGP peer configuration display function. */ | |
15352 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
15353 | struct peer *peer) | |
15354 | { | |
15355 | struct peer *g_peer = NULL; | |
15356 | char buf[SU_ADDRSTRLEN]; | |
15357 | char *addr; | |
15358 | int if_pg_printed = false; | |
15359 | int if_ras_printed = false; | |
15360 | ||
15361 | /* Skip dynamic neighbors. */ | |
15362 | if (peer_dynamic_neighbor(peer)) | |
15363 | return; | |
15364 | ||
15365 | if (peer->conf_if) | |
15366 | addr = peer->conf_if; | |
15367 | else | |
15368 | addr = peer->host; | |
15369 | ||
15370 | /************************************ | |
15371 | ****** Global to the neighbor ****** | |
15372 | ************************************/ | |
15373 | if (peer->conf_if) { | |
15374 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
15375 | vty_out(vty, " neighbor %s interface v6only", addr); | |
15376 | else | |
15377 | vty_out(vty, " neighbor %s interface", addr); | |
15378 | ||
15379 | if (peer_group_active(peer)) { | |
15380 | vty_out(vty, " peer-group %s", peer->group->name); | |
15381 | if_pg_printed = true; | |
15382 | } else if (peer->as_type == AS_SPECIFIED) { | |
15383 | vty_out(vty, " remote-as %u", peer->as); | |
15384 | if_ras_printed = true; | |
15385 | } else if (peer->as_type == AS_INTERNAL) { | |
15386 | vty_out(vty, " remote-as internal"); | |
15387 | if_ras_printed = true; | |
15388 | } else if (peer->as_type == AS_EXTERNAL) { | |
15389 | vty_out(vty, " remote-as external"); | |
15390 | if_ras_printed = true; | |
15391 | } | |
15392 | ||
15393 | vty_out(vty, "\n"); | |
15394 | } | |
15395 | ||
15396 | /* remote-as and peer-group */ | |
15397 | /* peer is a member of a peer-group */ | |
15398 | if (peer_group_active(peer)) { | |
15399 | g_peer = peer->group->conf; | |
15400 | ||
15401 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
15402 | if (peer->as_type == AS_SPECIFIED) { | |
15403 | vty_out(vty, " neighbor %s remote-as %u\n", | |
15404 | addr, peer->as); | |
15405 | } else if (peer->as_type == AS_INTERNAL) { | |
15406 | vty_out(vty, | |
15407 | " neighbor %s remote-as internal\n", | |
15408 | addr); | |
15409 | } else if (peer->as_type == AS_EXTERNAL) { | |
15410 | vty_out(vty, | |
15411 | " neighbor %s remote-as external\n", | |
15412 | addr); | |
15413 | } | |
15414 | } | |
15415 | ||
15416 | /* For swpX peers we displayed the peer-group | |
15417 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
15418 | if (!if_pg_printed) | |
15419 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
15420 | peer->group->name); | |
15421 | } | |
15422 | ||
15423 | /* peer is NOT a member of a peer-group */ | |
15424 | else { | |
15425 | /* peer is a peer-group, declare the peer-group */ | |
15426 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
15427 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
15428 | } | |
15429 | ||
15430 | if (!if_ras_printed) { | |
15431 | if (peer->as_type == AS_SPECIFIED) { | |
15432 | vty_out(vty, " neighbor %s remote-as %u\n", | |
15433 | addr, peer->as); | |
15434 | } else if (peer->as_type == AS_INTERNAL) { | |
15435 | vty_out(vty, | |
15436 | " neighbor %s remote-as internal\n", | |
15437 | addr); | |
15438 | } else if (peer->as_type == AS_EXTERNAL) { | |
15439 | vty_out(vty, | |
15440 | " neighbor %s remote-as external\n", | |
15441 | addr); | |
15442 | } | |
15443 | } | |
15444 | } | |
15445 | ||
15446 | /* local-as */ | |
15447 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
15448 | vty_out(vty, " neighbor %s local-as %u", addr, | |
15449 | peer->change_local_as); | |
15450 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
15451 | vty_out(vty, " no-prepend"); | |
15452 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
15453 | vty_out(vty, " replace-as"); | |
15454 | vty_out(vty, "\n"); | |
15455 | } | |
15456 | ||
15457 | /* description */ | |
15458 | if (peer->desc) { | |
15459 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
15460 | } | |
15461 | ||
15462 | /* shutdown */ | |
15463 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
15464 | if (peer->tx_shutdown_message) | |
15465 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
15466 | peer->tx_shutdown_message); | |
15467 | else | |
15468 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
15469 | } | |
15470 | ||
8336c896 DA |
15471 | if (peergroup_flag_check(peer, PEER_FLAG_RTT_SHUTDOWN)) |
15472 | vty_out(vty, " neighbor %s shutdown rtt %u count %u\n", addr, | |
15473 | peer->rtt_expected, peer->rtt_keepalive_conf); | |
15474 | ||
dd65f45e DL |
15475 | /* bfd */ |
15476 | if (peer->bfd_info) { | |
15477 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
15478 | bgp_bfd_peer_config_write(vty, peer, addr); | |
15479 | } | |
15480 | } | |
15481 | ||
15482 | /* password */ | |
15483 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
15484 | vty_out(vty, " neighbor %s password %s\n", addr, | |
15485 | peer->password); | |
15486 | ||
15487 | /* neighbor solo */ | |
15488 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
15489 | if (!peer_group_active(peer)) { | |
15490 | vty_out(vty, " neighbor %s solo\n", addr); | |
15491 | } | |
15492 | } | |
15493 | ||
15494 | /* BGP port */ | |
15495 | if (peer->port != BGP_PORT_DEFAULT) { | |
15496 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
15497 | } | |
15498 | ||
15499 | /* Local interface name */ | |
15500 | if (peer->ifname) { | |
15501 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
15502 | } | |
15503 | ||
15504 | /* passive */ | |
15505 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
15506 | vty_out(vty, " neighbor %s passive\n", addr); | |
15507 | ||
15508 | /* ebgp-multihop */ | |
15509 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
15510 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
15511 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
15512 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
15513 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
15514 | peer->ttl); | |
15515 | } | |
15516 | } | |
15517 | ||
15518 | /* ttl-security hops */ | |
e2521429 | 15519 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
15520 | if (!peer_group_active(peer) |
15521 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
15522 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
15523 | addr, peer->gtsm_hops); | |
15524 | } | |
15525 | } | |
15526 | ||
15527 | /* disable-connected-check */ | |
15528 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
15529 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
15530 | ||
15531 | /* enforce-first-as */ | |
15532 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
15533 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
15534 | ||
15535 | /* update-source */ | |
15536 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
15537 | if (peer->update_source) | |
15538 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
15539 | sockunion2str(peer->update_source, buf, | |
15540 | SU_ADDRSTRLEN)); | |
15541 | else if (peer->update_if) | |
15542 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
15543 | peer->update_if); | |
15544 | } | |
15545 | ||
15546 | /* advertisement-interval */ | |
15547 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
15548 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
15549 | peer->routeadv); | |
15550 | ||
15551 | /* timers */ | |
15552 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
15553 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
15554 | peer->keepalive, peer->holdtime); | |
15555 | ||
15556 | /* timers connect */ | |
15557 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
15558 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
15559 | peer->connect); | |
5d5393b9 DL |
15560 | /* need special-case handling for changed default values due to |
15561 | * config profile / version (because there is no "timers bgp connect" | |
15562 | * command, we need to save this per-peer :/) | |
15563 | */ | |
15564 | else if (!peer_group_active(peer) && !peer->connect && | |
15565 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
15566 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
15567 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
15568 | |
15569 | /* capability dynamic */ | |
15570 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
15571 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
15572 | ||
15573 | /* capability extended-nexthop */ | |
15574 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
15575 | if (!peer->conf_if) { | |
15576 | if (CHECK_FLAG(peer->flags_invert, | |
15577 | PEER_FLAG_CAPABILITY_ENHE)) | |
15578 | vty_out(vty, | |
15579 | " no neighbor %s capability extended-nexthop\n", | |
15580 | addr); | |
15581 | else | |
15582 | vty_out(vty, | |
15583 | " neighbor %s capability extended-nexthop\n", | |
15584 | addr); | |
15585 | } | |
15586 | } | |
15587 | ||
15588 | /* dont-capability-negotiation */ | |
15589 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
15590 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
15591 | ||
15592 | /* override-capability */ | |
15593 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
15594 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
15595 | ||
15596 | /* strict-capability-match */ | |
15597 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
15598 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
15599 | ||
15600 | /* Sender side AS path loop detection. */ | |
15601 | if (peer->as_path_loop_detection) | |
15602 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
15603 | addr); | |
cfd47646 | 15604 | |
15605 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 15606 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 15607 | |
15608 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 15609 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 15610 | vty_out(vty, |
15611 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
15612 | } else if (CHECK_FLAG( |
15613 | peer->peer_gr_new_status_flag, | |
15614 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 15615 | vty_out(vty, |
15616 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
15617 | } else if ( |
15618 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
15619 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
15620 | && !(CHECK_FLAG( | |
15621 | peer->peer_gr_new_status_flag, | |
15622 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
15623 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
15624 | addr); | |
cfd47646 | 15625 | } |
15626 | } | |
dd65f45e DL |
15627 | } |
15628 | ||
15629 | /* BGP peer configuration display function. */ | |
15630 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
15631 | struct peer *peer, afi_t afi, safi_t safi) | |
15632 | { | |
15633 | struct peer *g_peer = NULL; | |
15634 | char *addr; | |
15635 | bool flag_scomm, flag_secomm, flag_slcomm; | |
15636 | ||
15637 | /* Skip dynamic neighbors. */ | |
15638 | if (peer_dynamic_neighbor(peer)) | |
15639 | return; | |
15640 | ||
15641 | if (peer->conf_if) | |
15642 | addr = peer->conf_if; | |
15643 | else | |
15644 | addr = peer->host; | |
15645 | ||
15646 | /************************************ | |
15647 | ****** Per AF to the neighbor ****** | |
15648 | ************************************/ | |
15649 | if (peer_group_active(peer)) { | |
15650 | g_peer = peer->group->conf; | |
15651 | ||
15652 | /* If the peer-group is active but peer is not, print a 'no | |
15653 | * activate' */ | |
15654 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
15655 | vty_out(vty, " no neighbor %s activate\n", addr); | |
15656 | } | |
15657 | ||
15658 | /* If the peer-group is not active but peer is, print an | |
15659 | 'activate' */ | |
15660 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
15661 | vty_out(vty, " neighbor %s activate\n", addr); | |
15662 | } | |
15663 | } else { | |
15664 | if (peer->afc[afi][safi]) { | |
15665 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
15666 | if (CHECK_FLAG(bgp->flags, |
15667 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
15668 | vty_out(vty, " neighbor %s activate\n", |
15669 | addr); | |
15670 | } | |
15671 | } else | |
15672 | vty_out(vty, " neighbor %s activate\n", addr); | |
15673 | } else { | |
15674 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
15675 | if (!CHECK_FLAG(bgp->flags, |
15676 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
15677 | vty_out(vty, |
15678 | " no neighbor %s activate\n", | |
15679 | addr); | |
15680 | } | |
15681 | } | |
15682 | } | |
15683 | } | |
15684 | ||
15685 | /* addpath TX knobs */ | |
15686 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
15687 | switch (peer->addpath_type[afi][safi]) { | |
15688 | case BGP_ADDPATH_ALL: | |
15689 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
15690 | addr); | |
15691 | break; | |
15692 | case BGP_ADDPATH_BEST_PER_AS: | |
15693 | vty_out(vty, | |
15694 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
15695 | addr); | |
15696 | break; | |
15697 | case BGP_ADDPATH_MAX: | |
15698 | case BGP_ADDPATH_NONE: | |
15699 | break; | |
15700 | } | |
15701 | } | |
15702 | ||
15703 | /* ORF capability. */ | |
15704 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
15705 | || peergroup_af_flag_check(peer, afi, safi, | |
15706 | PEER_FLAG_ORF_PREFIX_RM)) { | |
15707 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
15708 | ||
15709 | if (peergroup_af_flag_check(peer, afi, safi, | |
15710 | PEER_FLAG_ORF_PREFIX_SM) | |
15711 | && peergroup_af_flag_check(peer, afi, safi, | |
15712 | PEER_FLAG_ORF_PREFIX_RM)) | |
15713 | vty_out(vty, " both"); | |
15714 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15715 | PEER_FLAG_ORF_PREFIX_SM)) | |
15716 | vty_out(vty, " send"); | |
15717 | else | |
15718 | vty_out(vty, " receive"); | |
15719 | vty_out(vty, "\n"); | |
15720 | } | |
15721 | ||
dd65f45e DL |
15722 | /* Route reflector client. */ |
15723 | if (peergroup_af_flag_check(peer, afi, safi, | |
15724 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
15725 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
15726 | } | |
15727 | ||
15728 | /* next-hop-self force */ | |
15729 | if (peergroup_af_flag_check(peer, afi, safi, | |
15730 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
15731 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
15732 | } | |
15733 | ||
15734 | /* next-hop-self */ | |
15735 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
15736 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
15737 | } | |
15738 | ||
15739 | /* remove-private-AS */ | |
15740 | if (peergroup_af_flag_check(peer, afi, safi, | |
15741 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
15742 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
15743 | addr); | |
15744 | } | |
15745 | ||
15746 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15747 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
15748 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
15749 | addr); | |
15750 | } | |
15751 | ||
15752 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15753 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
15754 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
15755 | } | |
15756 | ||
15757 | else if (peergroup_af_flag_check(peer, afi, safi, | |
15758 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
15759 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
15760 | } | |
15761 | ||
15762 | /* as-override */ | |
15763 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
15764 | vty_out(vty, " neighbor %s as-override\n", addr); | |
15765 | } | |
15766 | ||
15767 | /* send-community print. */ | |
15768 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
15769 | PEER_FLAG_SEND_COMMUNITY); | |
15770 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
15771 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
15772 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
15773 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
15774 | ||
15775 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
15776 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
15777 | } else { | |
15778 | if (flag_scomm) | |
15779 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
15780 | if (flag_secomm) | |
15781 | vty_out(vty, | |
15782 | " no neighbor %s send-community extended\n", | |
15783 | addr); | |
15784 | ||
15785 | if (flag_slcomm) | |
15786 | vty_out(vty, " no neighbor %s send-community large\n", | |
15787 | addr); | |
15788 | } | |
15789 | ||
15790 | /* Default information */ | |
15791 | if (peergroup_af_flag_check(peer, afi, safi, | |
15792 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
15793 | vty_out(vty, " neighbor %s default-originate", addr); | |
15794 | ||
15795 | if (peer->default_rmap[afi][safi].name) | |
15796 | vty_out(vty, " route-map %s", | |
15797 | peer->default_rmap[afi][safi].name); | |
15798 | ||
15799 | vty_out(vty, "\n"); | |
15800 | } | |
15801 | ||
15802 | /* Soft reconfiguration inbound. */ | |
15803 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
15804 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
15805 | addr); | |
15806 | } | |
15807 | ||
15808 | /* maximum-prefix. */ | |
15809 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
6cde4b45 | 15810 | vty_out(vty, " neighbor %s maximum-prefix %u", addr, |
dd65f45e DL |
15811 | peer->pmax[afi][safi]); |
15812 | ||
15813 | if (peer->pmax_threshold[afi][safi] | |
15814 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
15815 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
15816 | if (peer_af_flag_check(peer, afi, safi, | |
15817 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
15818 | vty_out(vty, " warning-only"); | |
15819 | if (peer->pmax_restart[afi][safi]) | |
15820 | vty_out(vty, " restart %u", | |
15821 | peer->pmax_restart[afi][safi]); | |
9cbd06e0 DA |
15822 | if (peer_af_flag_check(peer, afi, safi, |
15823 | PEER_FLAG_MAX_PREFIX_FORCE)) | |
15824 | vty_out(vty, " force"); | |
dd65f45e DL |
15825 | |
15826 | vty_out(vty, "\n"); | |
15827 | } | |
15828 | ||
fde246e8 DA |
15829 | /* maximum-prefix-out */ |
15830 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
6cde4b45 | 15831 | vty_out(vty, " neighbor %s maximum-prefix-out %u\n", |
fde246e8 DA |
15832 | addr, peer->pmax_out[afi][safi]); |
15833 | ||
dd65f45e DL |
15834 | /* Route server client. */ |
15835 | if (peergroup_af_flag_check(peer, afi, safi, | |
15836 | PEER_FLAG_RSERVER_CLIENT)) { | |
15837 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
15838 | } | |
15839 | ||
15840 | /* Nexthop-local unchanged. */ | |
15841 | if (peergroup_af_flag_check(peer, afi, safi, | |
15842 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
15843 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
15844 | } | |
15845 | ||
15846 | /* allowas-in <1-10> */ | |
15847 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
15848 | if (peer_af_flag_check(peer, afi, safi, | |
15849 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
15850 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
15851 | } else if (peer->allowas_in[afi][safi] == 3) { | |
15852 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
15853 | } else { | |
15854 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
15855 | peer->allowas_in[afi][safi]); | |
15856 | } | |
15857 | } | |
15858 | ||
15859 | /* weight */ | |
15860 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
15861 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
15862 | peer->weight[afi][safi]); | |
15863 | ||
15864 | /* Filter. */ | |
15865 | bgp_config_write_filter(vty, peer, afi, safi); | |
15866 | ||
15867 | /* atribute-unchanged. */ | |
15868 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
15869 | || (safi != SAFI_EVPN | |
15870 | && peer_af_flag_check(peer, afi, safi, | |
15871 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
15872 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
15873 | ||
15874 | if (!peer_group_active(peer) | |
15875 | || peergroup_af_flag_check(peer, afi, safi, | |
15876 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15877 | || peergroup_af_flag_check(peer, afi, safi, | |
15878 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15879 | || peergroup_af_flag_check(peer, afi, safi, | |
15880 | PEER_FLAG_MED_UNCHANGED)) { | |
15881 | ||
15882 | vty_out(vty, | |
15883 | " neighbor %s attribute-unchanged%s%s%s\n", | |
15884 | addr, | |
15885 | peer_af_flag_check(peer, afi, safi, | |
15886 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15887 | ? " as-path" | |
15888 | : "", | |
15889 | peer_af_flag_check(peer, afi, safi, | |
15890 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15891 | ? " next-hop" | |
15892 | : "", | |
15893 | peer_af_flag_check(peer, afi, safi, | |
15894 | PEER_FLAG_MED_UNCHANGED) | |
15895 | ? " med" | |
15896 | : ""); | |
15897 | } | |
15898 | } | |
15899 | } | |
15900 | ||
15901 | /* Address family based peer configuration display. */ | |
15902 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
15903 | safi_t safi) | |
15904 | { | |
15905 | struct peer *peer; | |
15906 | struct peer_group *group; | |
15907 | struct listnode *node, *nnode; | |
15908 | ||
15909 | ||
15910 | vty_frame(vty, " !\n address-family "); | |
15911 | if (afi == AFI_IP) { | |
15912 | if (safi == SAFI_UNICAST) | |
15913 | vty_frame(vty, "ipv4 unicast"); | |
15914 | else if (safi == SAFI_LABELED_UNICAST) | |
15915 | vty_frame(vty, "ipv4 labeled-unicast"); | |
15916 | else if (safi == SAFI_MULTICAST) | |
15917 | vty_frame(vty, "ipv4 multicast"); | |
15918 | else if (safi == SAFI_MPLS_VPN) | |
15919 | vty_frame(vty, "ipv4 vpn"); | |
15920 | else if (safi == SAFI_ENCAP) | |
15921 | vty_frame(vty, "ipv4 encap"); | |
15922 | else if (safi == SAFI_FLOWSPEC) | |
15923 | vty_frame(vty, "ipv4 flowspec"); | |
15924 | } else if (afi == AFI_IP6) { | |
15925 | if (safi == SAFI_UNICAST) | |
15926 | vty_frame(vty, "ipv6 unicast"); | |
15927 | else if (safi == SAFI_LABELED_UNICAST) | |
15928 | vty_frame(vty, "ipv6 labeled-unicast"); | |
15929 | else if (safi == SAFI_MULTICAST) | |
15930 | vty_frame(vty, "ipv6 multicast"); | |
15931 | else if (safi == SAFI_MPLS_VPN) | |
15932 | vty_frame(vty, "ipv6 vpn"); | |
15933 | else if (safi == SAFI_ENCAP) | |
15934 | vty_frame(vty, "ipv6 encap"); | |
15935 | else if (safi == SAFI_FLOWSPEC) | |
15936 | vty_frame(vty, "ipv6 flowspec"); | |
15937 | } else if (afi == AFI_L2VPN) { | |
15938 | if (safi == SAFI_EVPN) | |
15939 | vty_frame(vty, "l2vpn evpn"); | |
15940 | } | |
15941 | vty_frame(vty, "\n"); | |
15942 | ||
15943 | bgp_config_write_distance(vty, bgp, afi, safi); | |
15944 | ||
15945 | bgp_config_write_network(vty, bgp, afi, safi); | |
15946 | ||
15947 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
15948 | ||
8a4e7fe6 DA |
15949 | /* BGP flag dampening. */ |
15950 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
15951 | bgp_config_write_damp(vty, afi, safi); | |
15952 | ||
dd65f45e DL |
15953 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
15954 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
15955 | ||
15956 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15957 | /* Skip dynamic neighbors. */ | |
15958 | if (peer_dynamic_neighbor(peer)) | |
15959 | continue; | |
15960 | ||
15961 | /* Do not display doppelganger peers */ | |
15962 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15963 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
15964 | } | |
15965 | ||
15966 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
15967 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
15968 | ||
15969 | if (safi == SAFI_EVPN) | |
15970 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
15971 | ||
15972 | if (safi == SAFI_FLOWSPEC) | |
15973 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
15974 | ||
15975 | if (safi == SAFI_UNICAST) { | |
15976 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
15977 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15978 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
15979 | ||
15980 | vty_out(vty, " export vpn\n"); | |
15981 | } | |
15982 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15983 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
15984 | ||
15985 | vty_out(vty, " import vpn\n"); | |
15986 | } | |
15987 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15988 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15989 | char *name; | |
15990 | ||
15991 | for (ALL_LIST_ELEMENTS_RO( | |
15992 | bgp->vpn_policy[afi].import_vrf, node, | |
15993 | name)) | |
15994 | vty_out(vty, " import vrf %s\n", name); | |
15995 | } | |
15996 | } | |
15997 | ||
15998 | vty_endframe(vty, " exit-address-family\n"); | |
15999 | } | |
16000 | ||
16001 | int bgp_config_write(struct vty *vty) | |
16002 | { | |
16003 | struct bgp *bgp; | |
16004 | struct peer_group *group; | |
16005 | struct peer *peer; | |
16006 | struct listnode *node, *nnode; | |
16007 | struct listnode *mnode, *mnnode; | |
16008 | ||
16009 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
16010 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
16011 | bm->rmap_update_timer); | |
16012 | ||
d70583f7 D |
16013 | if (bm->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
16014 | vty_out(vty, "bgp update-delay %d", bm->v_update_delay); | |
16015 | if (bm->v_update_delay != bm->v_establish_wait) | |
16016 | vty_out(vty, " %d", bm->v_establish_wait); | |
16017 | vty_out(vty, "\n"); | |
16018 | } | |
16019 | ||
05bd726c | 16020 | if (CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) |
16021 | vty_out(vty, "bgp graceful-shutdown\n"); | |
16022 | ||
c163f297 DS |
16023 | /* No-RIB (Zebra) option flag configuration */ |
16024 | if (bgp_option_check(BGP_OPT_NO_FIB)) | |
16025 | vty_out(vty, "bgp no-rib\n"); | |
16026 | ||
dd65f45e DL |
16027 | /* BGP configuration. */ |
16028 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
16029 | ||
16030 | /* skip all auto created vrf as they dont have user config */ | |
16031 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
16032 | continue; | |
16033 | ||
16034 | /* Router bgp ASN */ | |
16035 | vty_out(vty, "router bgp %u", bgp->as); | |
16036 | ||
16037 | if (bgp->name) | |
16038 | vty_out(vty, " %s %s", | |
16039 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
16040 | ? "view" : "vrf", bgp->name); | |
16041 | vty_out(vty, "\n"); | |
16042 | ||
16043 | /* BGP fast-external-failover. */ | |
16044 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
16045 | vty_out(vty, " no bgp fast-external-failover\n"); | |
16046 | ||
16047 | /* BGP router ID. */ | |
16048 | if (bgp->router_id_static.s_addr != 0) | |
23d0a753 DA |
16049 | vty_out(vty, " bgp router-id %pI4\n", |
16050 | &bgp->router_id_static); | |
dd65f45e DL |
16051 | |
16052 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 16053 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 16054 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 16055 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
16056 | CHECK_FLAG(bgp->flags, |
16057 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
16058 | ? "" |
16059 | : "no "); | |
16060 | ||
16061 | /* BGP configuration. */ | |
892fedb6 | 16062 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
16063 | vty_out(vty, " bgp always-compare-med\n"); |
16064 | ||
16065 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
16066 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
16067 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
16068 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
16069 | CHECK_FLAG(bgp->flags, | |
16070 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
16071 | ? "" | |
16072 | : "no "); | |
dd65f45e DL |
16073 | |
16074 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 16075 | if (bgp->reject_as_sets) |
dd65f45e DL |
16076 | vty_out(vty, " bgp reject-as-sets\n"); |
16077 | ||
16078 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 16079 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
16080 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
16081 | ||
16082 | /* BGP default local-preference. */ | |
16083 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
16084 | vty_out(vty, " bgp default local-preference %u\n", | |
16085 | bgp->default_local_pref); | |
16086 | ||
16087 | /* BGP default show-hostname */ | |
892fedb6 | 16088 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 16089 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 16090 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 16091 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
16092 | ? "" |
16093 | : "no "); | |
16094 | ||
aef999a2 DA |
16095 | /* BGP default show-nexthop-hostname */ |
16096 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16097 | != SAVE_BGP_SHOW_HOSTNAME) | |
16098 | vty_out(vty, " %sbgp default show-nexthop-hostname\n", | |
16099 | CHECK_FLAG(bgp->flags, | |
16100 | BGP_FLAG_SHOW_NEXTHOP_HOSTNAME) | |
16101 | ? "" | |
16102 | : "no "); | |
16103 | ||
dd65f45e DL |
16104 | /* BGP default subgroup-pkt-queue-max. */ |
16105 | if (bgp->default_subgroup_pkt_queue_max | |
16106 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
16107 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
16108 | bgp->default_subgroup_pkt_queue_max); | |
16109 | ||
16110 | /* BGP client-to-client reflection. */ | |
892fedb6 | 16111 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
16112 | vty_out(vty, " no bgp client-to-client reflection\n"); |
16113 | ||
16114 | /* BGP cluster ID. */ | |
16115 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
23d0a753 DA |
16116 | vty_out(vty, " bgp cluster-id %pI4\n", |
16117 | &bgp->cluster_id); | |
dd65f45e DL |
16118 | |
16119 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 16120 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
16121 | vty_out(vty, |
16122 | " bgp disable-ebgp-connected-route-check\n"); | |
16123 | ||
16124 | /* Confederation identifier*/ | |
16125 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
16126 | vty_out(vty, " bgp confederation identifier %u\n", | |
16127 | bgp->confed_id); | |
16128 | ||
16129 | /* Confederation peer */ | |
16130 | if (bgp->confed_peers_cnt > 0) { | |
16131 | int i; | |
16132 | ||
16133 | vty_out(vty, " bgp confederation peers"); | |
16134 | ||
16135 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
16136 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
16137 | ||
16138 | vty_out(vty, "\n"); | |
16139 | } | |
16140 | ||
16141 | /* BGP deterministic-med. */ | |
892fedb6 | 16142 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 16143 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 16144 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
16145 | CHECK_FLAG(bgp->flags, |
16146 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
16147 | ? "" |
16148 | : "no "); | |
16149 | ||
16150 | /* BGP update-delay. */ | |
16151 | bgp_config_write_update_delay(vty, bgp); | |
16152 | ||
16153 | if (bgp->v_maxmed_onstartup | |
16154 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
16155 | vty_out(vty, " bgp max-med on-startup %u", | |
16156 | bgp->v_maxmed_onstartup); | |
16157 | if (bgp->maxmed_onstartup_value | |
16158 | != BGP_MAXMED_VALUE_DEFAULT) | |
16159 | vty_out(vty, " %u", | |
16160 | bgp->maxmed_onstartup_value); | |
16161 | vty_out(vty, "\n"); | |
16162 | } | |
16163 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
16164 | vty_out(vty, " bgp max-med administrative"); | |
16165 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
16166 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
16167 | vty_out(vty, "\n"); | |
16168 | } | |
16169 | ||
16170 | /* write quanta */ | |
16171 | bgp_config_write_wpkt_quanta(vty, bgp); | |
16172 | /* read quanta */ | |
16173 | bgp_config_write_rpkt_quanta(vty, bgp); | |
16174 | ||
16175 | /* coalesce time */ | |
16176 | bgp_config_write_coalesce_time(vty, bgp); | |
16177 | ||
05bd726c | 16178 | /* BGP per-instance graceful-shutdown */ |
16179 | /* BGP-wide settings and per-instance settings are mutually | |
16180 | * exclusive. | |
16181 | */ | |
16182 | if (!CHECK_FLAG(bm->flags, BM_FLAG_GRACEFUL_SHUTDOWN)) | |
16183 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) | |
16184 | vty_out(vty, " bgp graceful-shutdown\n"); | |
16185 | ||
dd65f45e DL |
16186 | /* BGP graceful-restart. */ |
16187 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
16188 | vty_out(vty, | |
16189 | " bgp graceful-restart stalepath-time %u\n", | |
16190 | bgp->stalepath_time); | |
cfd47646 | 16191 | |
dd65f45e DL |
16192 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
16193 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
16194 | bgp->restart_time); | |
cfd47646 | 16195 | |
16196 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
16197 | vty_out(vty, | |
16198 | " bgp graceful-restart select-defer-time %u\n", | |
16199 | bgp->select_defer_time); | |
16200 | ||
16201 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
16202 | vty_out(vty, " bgp graceful-restart\n"); |
16203 | ||
cfd47646 | 16204 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
16205 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
16206 | ||
dd65f45e | 16207 | /* BGP graceful-restart Preserve State F bit. */ |
892fedb6 | 16208 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
16209 | vty_out(vty, |
16210 | " bgp graceful-restart preserve-fw-state\n"); | |
16211 | ||
dc95985f | 16212 | /* Stale timer for RIB */ |
16213 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
16214 | vty_out(vty, | |
16215 | " bgp graceful-restart rib-stale-time %u\n", | |
16216 | bgp->rib_stale_time); | |
16217 | ||
dd65f45e | 16218 | /* BGP bestpath method. */ |
892fedb6 | 16219 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 16220 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 16221 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
16222 | vty_out(vty, " bgp bestpath as-path confed\n"); |
16223 | ||
892fedb6 DA |
16224 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
16225 | if (CHECK_FLAG(bgp->flags, | |
16226 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
16227 | vty_out(vty, |
16228 | " bgp bestpath as-path multipath-relax as-set\n"); | |
16229 | } else { | |
16230 | vty_out(vty, | |
16231 | " bgp bestpath as-path multipath-relax\n"); | |
16232 | } | |
16233 | } | |
16234 | ||
892fedb6 | 16235 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
16236 | vty_out(vty, |
16237 | " bgp route-reflector allow-outbound-policy\n"); | |
16238 | } | |
892fedb6 | 16239 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 16240 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
16241 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
16242 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 16243 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 16244 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 16245 | vty_out(vty, " confed"); |
892fedb6 DA |
16246 | if (CHECK_FLAG(bgp->flags, |
16247 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
16248 | vty_out(vty, " missing-as-worst"); |
16249 | vty_out(vty, "\n"); | |
16250 | } | |
16251 | ||
f7e1c681 | 16252 | /* Link bandwidth handling. */ |
16253 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
16254 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
16255 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
16256 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
16257 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
16258 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
16259 | ||
dd65f45e | 16260 | /* BGP network import check. */ |
892fedb6 | 16261 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 16262 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 16263 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 16264 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
16265 | ? "" |
16266 | : "no "); | |
16267 | ||
16268 | /* BGP timers configuration. */ | |
5d5393b9 DL |
16269 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
16270 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
16271 | vty_out(vty, " timers bgp %u %u\n", |
16272 | bgp->default_keepalive, bgp->default_holdtime); | |
16273 | ||
16274 | /* peer-group */ | |
16275 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
16276 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
16277 | } | |
16278 | ||
16279 | /* Normal neighbor configuration. */ | |
16280 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
16281 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
16282 | bgp_config_write_peer_global(vty, bgp, peer); | |
16283 | } | |
16284 | ||
16285 | /* listen range and limit for dynamic BGP neighbors */ | |
16286 | bgp_config_write_listen(vty, bgp); | |
16287 | ||
16288 | /* | |
16289 | * BGP default autoshutdown neighbors | |
16290 | * | |
16291 | * This must be placed after any peer and peer-group | |
16292 | * configuration, to avoid setting all peers to shutdown after | |
16293 | * a daemon restart, which is undesired behavior. (see #2286) | |
16294 | */ | |
16295 | if (bgp->autoshutdown) | |
16296 | vty_out(vty, " bgp default shutdown\n"); | |
16297 | ||
9cf59432 DS |
16298 | /* BGP instance administrative shutdown */ |
16299 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN)) | |
16300 | vty_out(vty, " bgp shutdown\n"); | |
16301 | ||
dd65f45e DL |
16302 | /* IPv4 unicast configuration. */ |
16303 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
16304 | ||
16305 | /* IPv4 multicast configuration. */ | |
16306 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
16307 | ||
16308 | /* IPv4 labeled-unicast configuration. */ | |
16309 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
16310 | ||
16311 | /* IPv4 VPN configuration. */ | |
16312 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
16313 | ||
16314 | /* ENCAPv4 configuration. */ | |
16315 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
16316 | ||
16317 | /* FLOWSPEC v4 configuration. */ | |
16318 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
16319 | ||
16320 | /* IPv6 unicast configuration. */ | |
16321 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
16322 | ||
16323 | /* IPv6 multicast configuration. */ | |
16324 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
16325 | ||
16326 | /* IPv6 labeled-unicast configuration. */ | |
16327 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
16328 | SAFI_LABELED_UNICAST); | |
16329 | ||
16330 | /* IPv6 VPN configuration. */ | |
16331 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
16332 | ||
16333 | /* ENCAPv6 configuration. */ | |
16334 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
16335 | ||
16336 | /* FLOWSPEC v6 configuration. */ | |
16337 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
16338 | ||
16339 | /* EVPN configuration. */ | |
16340 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
16341 | ||
16342 | hook_call(bgp_inst_config_write, bgp, vty); | |
16343 | ||
49e5a4a0 | 16344 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
16345 | bgp_rfapi_cfg_write(vty, bgp); |
16346 | #endif | |
16347 | ||
16348 | vty_out(vty, "!\n"); | |
16349 | } | |
16350 | return 0; | |
16351 | } | |
16352 | ||
ddb5b488 | 16353 | |
718e3744 | 16354 | /* BGP node structure. */ |
d62a17ae | 16355 | static struct cmd_node bgp_node = { |
f4b8291f | 16356 | .name = "bgp", |
62b346ee | 16357 | .node = BGP_NODE, |
24389580 | 16358 | .parent_node = CONFIG_NODE, |
62b346ee | 16359 | .prompt = "%s(config-router)# ", |
612c2c15 | 16360 | .config_write = bgp_config_write, |
718e3744 | 16361 | }; |
16362 | ||
d62a17ae | 16363 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 16364 | .name = "bgp ipv4 unicast", |
62b346ee | 16365 | .node = BGP_IPV4_NODE, |
24389580 | 16366 | .parent_node = BGP_NODE, |
62b346ee | 16367 | .prompt = "%s(config-router-af)# ", |
718e3744 | 16368 | }; |
16369 | ||
d62a17ae | 16370 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 16371 | .name = "bgp ipv4 multicast", |
62b346ee | 16372 | .node = BGP_IPV4M_NODE, |
24389580 | 16373 | .parent_node = BGP_NODE, |
62b346ee | 16374 | .prompt = "%s(config-router-af)# ", |
718e3744 | 16375 | }; |
16376 | ||
d62a17ae | 16377 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 16378 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 16379 | .node = BGP_IPV4L_NODE, |
24389580 | 16380 | .parent_node = BGP_NODE, |
62b346ee | 16381 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
16382 | }; |
16383 | ||
d62a17ae | 16384 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 16385 | .name = "bgp ipv6", |
62b346ee | 16386 | .node = BGP_IPV6_NODE, |
24389580 | 16387 | .parent_node = BGP_NODE, |
62b346ee | 16388 | .prompt = "%s(config-router-af)# ", |
718e3744 | 16389 | }; |
16390 | ||
d62a17ae | 16391 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 16392 | .name = "bgp ipv6 multicast", |
62b346ee | 16393 | .node = BGP_IPV6M_NODE, |
24389580 | 16394 | .parent_node = BGP_NODE, |
62b346ee | 16395 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 16396 | }; |
16397 | ||
d62a17ae | 16398 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 16399 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 16400 | .node = BGP_IPV6L_NODE, |
24389580 | 16401 | .parent_node = BGP_NODE, |
62b346ee | 16402 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
16403 | }; |
16404 | ||
62b346ee | 16405 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 16406 | .name = "bgp vpnv4", |
62b346ee | 16407 | .node = BGP_VPNV4_NODE, |
24389580 | 16408 | .parent_node = BGP_NODE, |
62b346ee | 16409 | .prompt = "%s(config-router-af)# ", |
62b346ee | 16410 | }; |
6b0655a2 | 16411 | |
62b346ee | 16412 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 16413 | .name = "bgp vpnv6", |
62b346ee | 16414 | .node = BGP_VPNV6_NODE, |
24389580 | 16415 | .parent_node = BGP_NODE, |
62b346ee | 16416 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 16417 | }; |
8ecd3266 | 16418 | |
62b346ee | 16419 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 16420 | .name = "bgp evpn", |
62b346ee | 16421 | .node = BGP_EVPN_NODE, |
24389580 | 16422 | .parent_node = BGP_NODE, |
62b346ee | 16423 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 16424 | }; |
4e0b7b6d | 16425 | |
62b346ee | 16426 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 16427 | .name = "bgp evpn vni", |
62b346ee | 16428 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 16429 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 16430 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 16431 | }; |
90e60aa7 | 16432 | |
62b346ee | 16433 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 16434 | .name = "bgp ipv4 flowspec", |
62b346ee | 16435 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 16436 | .parent_node = BGP_NODE, |
62b346ee | 16437 | .prompt = "%s(config-router-af)# ", |
62b346ee | 16438 | }; |
7c40bf39 | 16439 | |
62b346ee | 16440 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 16441 | .name = "bgp ipv6 flowspec", |
62b346ee | 16442 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 16443 | .parent_node = BGP_NODE, |
62b346ee | 16444 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 16445 | }; |
7c40bf39 | 16446 | |
d62a17ae | 16447 | static void community_list_vty(void); |
1f8ae70b | 16448 | |
d62a17ae | 16449 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 16450 | { |
d62a17ae | 16451 | struct bgp *bgp; |
16452 | struct peer *peer; | |
d62a17ae | 16453 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 16454 | |
d62a17ae | 16455 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
16456 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
16457 | /* only provide suggestions on the appropriate input | |
16458 | * token type, | |
16459 | * they'll otherwise show up multiple times */ | |
16460 | enum cmd_token_type match_type; | |
16461 | char *name = peer->host; | |
d48ed3e0 | 16462 | |
d62a17ae | 16463 | if (peer->conf_if) { |
16464 | match_type = VARIABLE_TKN; | |
16465 | name = peer->conf_if; | |
16466 | } else if (strchr(peer->host, ':')) | |
16467 | match_type = IPV6_TKN; | |
16468 | else | |
16469 | match_type = IPV4_TKN; | |
d48ed3e0 | 16470 | |
d62a17ae | 16471 | if (token->type != match_type) |
16472 | continue; | |
d48ed3e0 | 16473 | |
d62a17ae | 16474 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
16475 | } | |
d62a17ae | 16476 | } |
b8a815e5 DL |
16477 | } |
16478 | ||
16479 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 16480 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
16481 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 16482 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 16483 | {.completions = NULL}}; |
16484 | ||
47a306a0 DS |
16485 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
16486 | { | |
16487 | struct bgp *bgp; | |
16488 | struct peer_group *group; | |
16489 | struct listnode *lnbgp, *lnpeer; | |
16490 | ||
16491 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
16492 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
16493 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
16494 | group->name)); | |
16495 | } | |
16496 | } | |
16497 | ||
16498 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
16499 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
16500 | {.completions = NULL} }; | |
16501 | ||
d62a17ae | 16502 | void bgp_vty_init(void) |
16503 | { | |
16504 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 16505 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 16506 | |
16507 | /* Install bgp top node. */ | |
612c2c15 DL |
16508 | install_node(&bgp_node); |
16509 | install_node(&bgp_ipv4_unicast_node); | |
16510 | install_node(&bgp_ipv4_multicast_node); | |
16511 | install_node(&bgp_ipv4_labeled_unicast_node); | |
16512 | install_node(&bgp_ipv6_unicast_node); | |
16513 | install_node(&bgp_ipv6_multicast_node); | |
16514 | install_node(&bgp_ipv6_labeled_unicast_node); | |
16515 | install_node(&bgp_vpnv4_node); | |
16516 | install_node(&bgp_vpnv6_node); | |
16517 | install_node(&bgp_evpn_node); | |
16518 | install_node(&bgp_evpn_vni_node); | |
16519 | install_node(&bgp_flowspecv4_node); | |
16520 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 16521 | |
16522 | /* Install default VTY commands to new nodes. */ | |
16523 | install_default(BGP_NODE); | |
16524 | install_default(BGP_IPV4_NODE); | |
16525 | install_default(BGP_IPV4M_NODE); | |
16526 | install_default(BGP_IPV4L_NODE); | |
16527 | install_default(BGP_IPV6_NODE); | |
16528 | install_default(BGP_IPV6M_NODE); | |
16529 | install_default(BGP_IPV6L_NODE); | |
16530 | install_default(BGP_VPNV4_NODE); | |
16531 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 16532 | install_default(BGP_FLOWSPECV4_NODE); |
16533 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 16534 | install_default(BGP_EVPN_NODE); |
16535 | install_default(BGP_EVPN_VNI_NODE); | |
16536 | ||
8029b216 AK |
16537 | /* "bgp local-mac" hidden commands. */ |
16538 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
16539 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
16540 | ||
d62a17ae | 16541 | /* bgp route-map delay-timer commands. */ |
16542 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
16543 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
16544 | ||
d70583f7 D |
16545 | /* global bgp update-delay command */ |
16546 | install_element(CONFIG_NODE, &bgp_global_update_delay_cmd); | |
16547 | install_element(CONFIG_NODE, &no_bgp_global_update_delay_cmd); | |
16548 | ||
05bd726c | 16549 | /* global bgp graceful-shutdown command */ |
16550 | install_element(CONFIG_NODE, &bgp_graceful_shutdown_cmd); | |
16551 | install_element(CONFIG_NODE, &no_bgp_graceful_shutdown_cmd); | |
16552 | ||
d62a17ae | 16553 | /* Dummy commands (Currently not supported) */ |
16554 | install_element(BGP_NODE, &no_synchronization_cmd); | |
16555 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
16556 | ||
16557 | /* "router bgp" commands. */ | |
16558 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
16559 | ||
16560 | /* "no router bgp" commands. */ | |
16561 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
16562 | ||
16563 | /* "bgp router-id" commands. */ | |
16564 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
16565 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
16566 | ||
16567 | /* "bgp cluster-id" commands. */ | |
16568 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
16569 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
16570 | ||
c163f297 DS |
16571 | /* "bgp no-rib" commands. */ |
16572 | install_element(CONFIG_NODE, &bgp_norib_cmd); | |
16573 | install_element(CONFIG_NODE, &no_bgp_norib_cmd); | |
16574 | ||
d62a17ae | 16575 | /* "bgp confederation" commands. */ |
16576 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
16577 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
16578 | ||
16579 | /* "bgp confederation peers" commands. */ | |
16580 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
16581 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
16582 | ||
16583 | /* bgp max-med command */ | |
16584 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
16585 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
16586 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
16587 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
16588 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
16589 | ||
16590 | /* bgp disable-ebgp-connected-nh-check */ | |
16591 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
16592 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
16593 | ||
16594 | /* bgp update-delay command */ | |
16595 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
16596 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
d62a17ae | 16597 | |
16598 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 16599 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 16600 | |
16601 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
16602 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
16603 | ||
16604 | /* "maximum-paths" commands. */ | |
16605 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
16606 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
16607 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
16608 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
16609 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
16610 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
16611 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
16612 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
16613 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
16614 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
16615 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16616 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
16617 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
16618 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16619 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
16620 | ||
39edabac PG |
16621 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
16622 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
16623 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
16624 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16625 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 16626 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
16627 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
16628 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
16629 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
16630 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
16631 | ||
16632 | /* "timers bgp" commands. */ | |
16633 | install_element(BGP_NODE, &bgp_timers_cmd); | |
16634 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
16635 | ||
16636 | /* route-map delay-timer commands - per instance for backwards compat. | |
16637 | */ | |
16638 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
16639 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
16640 | ||
16641 | /* "bgp client-to-client reflection" commands */ | |
16642 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
16643 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
16644 | ||
16645 | /* "bgp always-compare-med" commands */ | |
16646 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
16647 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
16648 | ||
9dac9fc8 DA |
16649 | /* bgp ebgp-requires-policy */ |
16650 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
16651 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
16652 | ||
fb29348a DA |
16653 | /* bgp reject-as-sets */ |
16654 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
16655 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
16656 | ||
d62a17ae | 16657 | /* "bgp deterministic-med" commands */ |
16658 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
16659 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
16660 | ||
055679e9 | 16661 | /* "bgp graceful-restart" command */ |
36235319 QY |
16662 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
16663 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 16664 | |
16665 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
16666 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
16667 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 16668 | |
16669 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
16670 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
16671 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 16672 | |
16673 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
16674 | install_element(BGP_NODE, | |
16675 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
16676 | install_element(BGP_NODE, | |
16677 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
16678 | ||
16679 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
16680 | install_element(BGP_NODE, | |
16681 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
16682 | install_element(BGP_NODE, | |
16683 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
16684 | ||
d62a17ae | 16685 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
16686 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
16687 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
16688 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 16689 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 16690 | install_element(BGP_NODE, |
16691 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 16692 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
16693 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
16694 | ||
d6e3c15b | 16695 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
16696 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 16697 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
16698 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 16699 | |
7f323236 DW |
16700 | /* "bgp graceful-shutdown" commands */ |
16701 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
16702 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
16703 | ||
d62a17ae | 16704 | /* "bgp fast-external-failover" commands */ |
16705 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
16706 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
16707 | ||
d62a17ae | 16708 | /* "bgp bestpath compare-routerid" commands */ |
16709 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
16710 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
16711 | ||
16712 | /* "bgp bestpath as-path ignore" commands */ | |
16713 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
16714 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
16715 | ||
16716 | /* "bgp bestpath as-path confed" commands */ | |
16717 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
16718 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
16719 | ||
16720 | /* "bgp bestpath as-path multipath-relax" commands */ | |
16721 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
16722 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
16723 | ||
16724 | /* "bgp log-neighbor-changes" commands */ | |
16725 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
16726 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
16727 | ||
16728 | /* "bgp bestpath med" commands */ | |
16729 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
16730 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
16731 | ||
f7e1c681 | 16732 | /* "bgp bestpath bandwidth" commands */ |
16733 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 16734 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 16735 | |
d62a17ae | 16736 | /* "no bgp default ipv4-unicast" commands. */ |
16737 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
16738 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
16739 | ||
16740 | /* "bgp network import-check" commands. */ | |
16741 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
16742 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
16743 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
16744 | ||
16745 | /* "bgp default local-preference" commands. */ | |
16746 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
16747 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
16748 | ||
16749 | /* bgp default show-hostname */ | |
16750 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
16751 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
16752 | ||
aef999a2 DA |
16753 | /* bgp default show-nexthop-hostname */ |
16754 | install_element(BGP_NODE, &bgp_default_show_nexthop_hostname_cmd); | |
16755 | install_element(BGP_NODE, &no_bgp_default_show_nexthop_hostname_cmd); | |
16756 | ||
d62a17ae | 16757 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
16758 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
16759 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
16760 | ||
16761 | /* bgp ibgp-allow-policy-mods command */ | |
16762 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
16763 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
16764 | ||
16765 | /* "bgp listen limit" commands. */ | |
16766 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
16767 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
16768 | ||
16769 | /* "bgp listen range" commands. */ | |
16770 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
16771 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
16772 | ||
8175f54a | 16773 | /* "bgp default shutdown" command */ |
f26845f9 | 16774 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
9cf59432 DS |
16775 | |
16776 | /* "bgp shutdown" commands */ | |
16777 | install_element(BGP_NODE, &bgp_shutdown_cmd); | |
8389c83a | 16778 | install_element(BGP_NODE, &bgp_shutdown_msg_cmd); |
9cf59432 | 16779 | install_element(BGP_NODE, &no_bgp_shutdown_cmd); |
1b6e7a88 | 16780 | install_element(BGP_NODE, &no_bgp_shutdown_msg_cmd); |
f26845f9 | 16781 | |
d62a17ae | 16782 | /* "neighbor remote-as" commands. */ |
16783 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
16784 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
16785 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
16786 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
16787 | install_element(BGP_NODE, | |
16788 | &neighbor_interface_v6only_config_remote_as_cmd); | |
16789 | install_element(BGP_NODE, &no_neighbor_cmd); | |
16790 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
16791 | ||
16792 | /* "neighbor peer-group" commands. */ | |
16793 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
16794 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
16795 | install_element(BGP_NODE, | |
16796 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
16797 | ||
16798 | /* "neighbor local-as" commands. */ | |
16799 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
16800 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
16801 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
16802 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
16803 | ||
16804 | /* "neighbor solo" commands. */ | |
16805 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
16806 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
16807 | ||
16808 | /* "neighbor password" commands. */ | |
16809 | install_element(BGP_NODE, &neighbor_password_cmd); | |
16810 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
16811 | ||
16812 | /* "neighbor activate" commands. */ | |
16813 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
16814 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
16815 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
16816 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
16817 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
16818 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
16819 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
16820 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
16821 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 16822 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
16823 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 16824 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
16825 | ||
16826 | /* "no neighbor activate" commands. */ | |
16827 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
16828 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
16829 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
16830 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
16831 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
16832 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
16833 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
16834 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
16835 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 16836 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
16837 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 16838 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
16839 | ||
16840 | /* "neighbor peer-group" set commands. */ | |
16841 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
16842 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16843 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16844 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16845 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16846 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16847 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
16848 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16849 | install_element(BGP_FLOWSPECV4_NODE, |
16850 | &neighbor_set_peer_group_hidden_cmd); | |
16851 | install_element(BGP_FLOWSPECV6_NODE, | |
16852 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16853 | |
16854 | /* "no neighbor peer-group unset" commands. */ | |
16855 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
16856 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16857 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16858 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16859 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16860 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16861 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16862 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16863 | install_element(BGP_FLOWSPECV4_NODE, |
16864 | &no_neighbor_set_peer_group_hidden_cmd); | |
16865 | install_element(BGP_FLOWSPECV6_NODE, | |
16866 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16867 | |
16868 | /* "neighbor softreconfiguration inbound" commands.*/ | |
16869 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
16870 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
16871 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16872 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16873 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16874 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16875 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16876 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16877 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16878 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16879 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16880 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16881 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16882 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16883 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16884 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16885 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16886 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 16887 | install_element(BGP_FLOWSPECV4_NODE, |
16888 | &neighbor_soft_reconfiguration_cmd); | |
16889 | install_element(BGP_FLOWSPECV4_NODE, | |
16890 | &no_neighbor_soft_reconfiguration_cmd); | |
16891 | install_element(BGP_FLOWSPECV6_NODE, | |
16892 | &neighbor_soft_reconfiguration_cmd); | |
16893 | install_element(BGP_FLOWSPECV6_NODE, | |
16894 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
16895 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
16896 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 16897 | |
16898 | /* "neighbor attribute-unchanged" commands. */ | |
16899 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
16900 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
16901 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
16902 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16903 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
16904 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16905 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
16906 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16907 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
16908 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16909 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
16910 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16911 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
16912 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16913 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
16914 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16915 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
16916 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16917 | ||
16918 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
16919 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
16920 | ||
16921 | /* "nexthop-local unchanged" commands */ | |
16922 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
16923 | install_element(BGP_IPV6_NODE, | |
16924 | &no_neighbor_nexthop_local_unchanged_cmd); | |
16925 | ||
16926 | /* "neighbor next-hop-self" commands. */ | |
16927 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
16928 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
16929 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
16930 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16931 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
16932 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
16933 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
16934 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
16935 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
16936 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
16937 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
16938 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
16939 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
16940 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
16941 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
16942 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16943 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
16944 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
16945 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
16946 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 16947 | |
16948 | /* "neighbor next-hop-self force" commands. */ | |
16949 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
16950 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
16951 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16952 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16953 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
16954 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16955 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16956 | install_element(BGP_IPV4_NODE, | |
16957 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16958 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
16959 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16960 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16961 | install_element(BGP_IPV4M_NODE, | |
16962 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16963 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
16964 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16965 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16966 | install_element(BGP_IPV4L_NODE, | |
16967 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16968 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
16969 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16970 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16971 | install_element(BGP_IPV6_NODE, | |
16972 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16973 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
16974 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16975 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16976 | install_element(BGP_IPV6M_NODE, | |
16977 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16978 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
16979 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16980 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16981 | install_element(BGP_IPV6L_NODE, | |
16982 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16983 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
16984 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16985 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16986 | install_element(BGP_VPNV4_NODE, | |
16987 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16988 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
16989 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16990 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16991 | install_element(BGP_VPNV6_NODE, | |
16992 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
16993 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
16994 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 16995 | |
16996 | /* "neighbor as-override" commands. */ | |
16997 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
16998 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
16999 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
17000 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
17001 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
17002 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
17003 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
17004 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
17005 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
17006 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
17007 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
17008 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
17009 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
17010 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
17011 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
17012 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
17013 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
17014 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
17015 | ||
17016 | /* "neighbor remove-private-AS" commands. */ | |
17017 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
17018 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
17019 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
17020 | install_element(BGP_NODE, | |
17021 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
17022 | install_element(BGP_NODE, | |
17023 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
17024 | install_element(BGP_NODE, | |
17025 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
17026 | install_element(BGP_NODE, | |
17027 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17028 | install_element( | |
17029 | BGP_NODE, | |
17030 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
17031 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
17032 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17033 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17034 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17035 | install_element(BGP_IPV4_NODE, | |
17036 | &neighbor_remove_private_as_replace_as_cmd); | |
17037 | install_element(BGP_IPV4_NODE, | |
17038 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17039 | install_element(BGP_IPV4_NODE, | |
17040 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17041 | install_element(BGP_IPV4_NODE, | |
17042 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17043 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
17044 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
17045 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
17046 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17047 | install_element(BGP_IPV4M_NODE, | |
17048 | &neighbor_remove_private_as_replace_as_cmd); | |
17049 | install_element(BGP_IPV4M_NODE, | |
17050 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17051 | install_element(BGP_IPV4M_NODE, | |
17052 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17053 | install_element(BGP_IPV4M_NODE, | |
17054 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17055 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
17056 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
17057 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
17058 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17059 | install_element(BGP_IPV4L_NODE, | |
17060 | &neighbor_remove_private_as_replace_as_cmd); | |
17061 | install_element(BGP_IPV4L_NODE, | |
17062 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17063 | install_element(BGP_IPV4L_NODE, | |
17064 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17065 | install_element(BGP_IPV4L_NODE, | |
17066 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17067 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
17068 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17069 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17070 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17071 | install_element(BGP_IPV6_NODE, | |
17072 | &neighbor_remove_private_as_replace_as_cmd); | |
17073 | install_element(BGP_IPV6_NODE, | |
17074 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17075 | install_element(BGP_IPV6_NODE, | |
17076 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17077 | install_element(BGP_IPV6_NODE, | |
17078 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17079 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
17080 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
17081 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
17082 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17083 | install_element(BGP_IPV6M_NODE, | |
17084 | &neighbor_remove_private_as_replace_as_cmd); | |
17085 | install_element(BGP_IPV6M_NODE, | |
17086 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17087 | install_element(BGP_IPV6M_NODE, | |
17088 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17089 | install_element(BGP_IPV6M_NODE, | |
17090 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17091 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
17092 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
17093 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
17094 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17095 | install_element(BGP_IPV6L_NODE, | |
17096 | &neighbor_remove_private_as_replace_as_cmd); | |
17097 | install_element(BGP_IPV6L_NODE, | |
17098 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17099 | install_element(BGP_IPV6L_NODE, | |
17100 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17101 | install_element(BGP_IPV6L_NODE, | |
17102 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17103 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
17104 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
17105 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
17106 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17107 | install_element(BGP_VPNV4_NODE, | |
17108 | &neighbor_remove_private_as_replace_as_cmd); | |
17109 | install_element(BGP_VPNV4_NODE, | |
17110 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17111 | install_element(BGP_VPNV4_NODE, | |
17112 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17113 | install_element(BGP_VPNV4_NODE, | |
17114 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17115 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
17116 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
17117 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
17118 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
17119 | install_element(BGP_VPNV6_NODE, | |
17120 | &neighbor_remove_private_as_replace_as_cmd); | |
17121 | install_element(BGP_VPNV6_NODE, | |
17122 | &no_neighbor_remove_private_as_replace_as_cmd); | |
17123 | install_element(BGP_VPNV6_NODE, | |
17124 | &neighbor_remove_private_as_all_replace_as_cmd); | |
17125 | install_element(BGP_VPNV6_NODE, | |
17126 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
17127 | ||
17128 | /* "neighbor send-community" commands.*/ | |
17129 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
17130 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
17131 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
17132 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
17133 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
17134 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
17135 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
17136 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
17137 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
17138 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
17139 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
17140 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
17141 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
17142 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
17143 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
17144 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
17145 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
17146 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
17147 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
17148 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
17149 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
17150 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
17151 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
17152 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
17153 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
17154 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
17155 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
17156 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
17157 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
17158 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
17159 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
17160 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
17161 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
17162 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
17163 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
17164 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
17165 | ||
17166 | /* "neighbor route-reflector" commands.*/ | |
17167 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
17168 | install_element(BGP_NODE, | |
17169 | &no_neighbor_route_reflector_client_hidden_cmd); | |
17170 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
17171 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
17172 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
17173 | install_element(BGP_IPV4M_NODE, | |
17174 | &no_neighbor_route_reflector_client_cmd); | |
17175 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
17176 | install_element(BGP_IPV4L_NODE, | |
17177 | &no_neighbor_route_reflector_client_cmd); | |
17178 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
17179 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
17180 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
17181 | install_element(BGP_IPV6M_NODE, | |
17182 | &no_neighbor_route_reflector_client_cmd); | |
17183 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
17184 | install_element(BGP_IPV6L_NODE, | |
17185 | &no_neighbor_route_reflector_client_cmd); | |
17186 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
17187 | install_element(BGP_VPNV4_NODE, | |
17188 | &no_neighbor_route_reflector_client_cmd); | |
17189 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
17190 | install_element(BGP_VPNV6_NODE, | |
17191 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 17192 | install_element(BGP_FLOWSPECV4_NODE, |
17193 | &neighbor_route_reflector_client_cmd); | |
17194 | install_element(BGP_FLOWSPECV4_NODE, | |
17195 | &no_neighbor_route_reflector_client_cmd); | |
17196 | install_element(BGP_FLOWSPECV6_NODE, | |
17197 | &neighbor_route_reflector_client_cmd); | |
17198 | install_element(BGP_FLOWSPECV6_NODE, | |
17199 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 17200 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
17201 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
17202 | ||
17203 | /* "neighbor route-server" commands.*/ | |
17204 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
17205 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
17206 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
17207 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
17208 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
17209 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
17210 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
17211 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
17212 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
17213 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
17214 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
17215 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
17216 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
17217 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
17218 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
17219 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
17220 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
17221 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
17222 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
17223 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 17224 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
17225 | install_element(BGP_FLOWSPECV4_NODE, | |
17226 | &no_neighbor_route_server_client_cmd); | |
17227 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
17228 | install_element(BGP_FLOWSPECV6_NODE, | |
17229 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 17230 | |
17231 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
17232 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
17233 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
17234 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17235 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17236 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17237 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17238 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17239 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17240 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17241 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17242 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17243 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17244 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17245 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17246 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17247 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17248 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
17249 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
17250 | ||
17251 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
17252 | install_element(BGP_NODE, | |
17253 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
17254 | install_element(BGP_NODE, | |
17255 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
17256 | install_element(BGP_IPV4_NODE, | |
17257 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17258 | install_element(BGP_IPV4_NODE, | |
17259 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17260 | install_element(BGP_IPV4M_NODE, | |
17261 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17262 | install_element(BGP_IPV4M_NODE, | |
17263 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17264 | install_element(BGP_IPV4L_NODE, | |
17265 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17266 | install_element(BGP_IPV4L_NODE, | |
17267 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17268 | install_element(BGP_IPV6_NODE, | |
17269 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17270 | install_element(BGP_IPV6_NODE, | |
17271 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17272 | install_element(BGP_IPV6M_NODE, | |
17273 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17274 | install_element(BGP_IPV6M_NODE, | |
17275 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17276 | install_element(BGP_IPV6L_NODE, | |
17277 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17278 | install_element(BGP_IPV6L_NODE, | |
17279 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17280 | install_element(BGP_VPNV4_NODE, | |
17281 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17282 | install_element(BGP_VPNV4_NODE, | |
17283 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17284 | install_element(BGP_VPNV6_NODE, | |
17285 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
17286 | install_element(BGP_VPNV6_NODE, | |
17287 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
17288 | ||
2b31007c RZ |
17289 | /* "neighbor sender-as-path-loop-detection" commands. */ |
17290 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
17291 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
17292 | ||
d62a17ae | 17293 | /* "neighbor passive" commands. */ |
17294 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
17295 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
17296 | ||
17297 | ||
17298 | /* "neighbor shutdown" commands. */ | |
17299 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
17300 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
17301 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
17302 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
8336c896 DA |
17303 | install_element(BGP_NODE, &neighbor_shutdown_rtt_cmd); |
17304 | install_element(BGP_NODE, &no_neighbor_shutdown_rtt_cmd); | |
d62a17ae | 17305 | |
17306 | /* "neighbor capability extended-nexthop" commands.*/ | |
17307 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
17308 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
17309 | ||
17310 | /* "neighbor capability orf prefix-list" commands.*/ | |
17311 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
17312 | install_element(BGP_NODE, | |
17313 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
17314 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
17315 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17316 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
17317 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17318 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
17319 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17320 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
17321 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17322 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
17323 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17324 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
17325 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
17326 | ||
17327 | /* "neighbor capability dynamic" commands.*/ | |
17328 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
17329 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
17330 | ||
17331 | /* "neighbor dont-capability-negotiate" commands. */ | |
17332 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
17333 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
17334 | ||
17335 | /* "neighbor ebgp-multihop" commands. */ | |
17336 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
17337 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
17338 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
17339 | ||
17340 | /* "neighbor disable-connected-check" commands. */ | |
17341 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
17342 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
17343 | ||
47cbc09b PM |
17344 | /* "neighbor enforce-first-as" commands. */ |
17345 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
17346 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
17347 | ||
d62a17ae | 17348 | /* "neighbor description" commands. */ |
17349 | install_element(BGP_NODE, &neighbor_description_cmd); | |
17350 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 17351 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 17352 | |
17353 | /* "neighbor update-source" commands. "*/ | |
17354 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
17355 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
17356 | ||
17357 | /* "neighbor default-originate" commands. */ | |
17358 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
17359 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
17360 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
17361 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
17362 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
17363 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
17364 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
17365 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
17366 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
17367 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
17368 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
17369 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
17370 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
17371 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
17372 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
17373 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
17374 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
17375 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
17376 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
17377 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
17378 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
17379 | ||
17380 | /* "neighbor port" commands. */ | |
17381 | install_element(BGP_NODE, &neighbor_port_cmd); | |
17382 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
17383 | ||
17384 | /* "neighbor weight" commands. */ | |
17385 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
17386 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
17387 | ||
17388 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
17389 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
17390 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
17391 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
17392 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
17393 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
17394 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
17395 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
17396 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
17397 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
17398 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
17399 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
17400 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
17401 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
17402 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
17403 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
17404 | ||
17405 | /* "neighbor override-capability" commands. */ | |
17406 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
17407 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
17408 | ||
17409 | /* "neighbor strict-capability-match" commands. */ | |
17410 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
17411 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
17412 | ||
17413 | /* "neighbor timers" commands. */ | |
17414 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
17415 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
17416 | ||
17417 | /* "neighbor timers connect" commands. */ | |
17418 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
17419 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
17420 | ||
17421 | /* "neighbor advertisement-interval" commands. */ | |
17422 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
17423 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
17424 | ||
17425 | /* "neighbor interface" commands. */ | |
17426 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
17427 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
17428 | ||
17429 | /* "neighbor distribute" commands. */ | |
17430 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
17431 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
17432 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
17433 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
17434 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
17435 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
17436 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
17437 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
17438 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
17439 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
17440 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
17441 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
17442 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
17443 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
17444 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
17445 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
17446 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
17447 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
17448 | ||
17449 | /* "neighbor prefix-list" commands. */ | |
17450 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
17451 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
17452 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
17453 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
17454 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
17455 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
17456 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
17457 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
17458 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
17459 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
17460 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
17461 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
17462 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
17463 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
17464 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
17465 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
17466 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
17467 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 17468 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
17469 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
17470 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
17471 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 17472 | |
17473 | /* "neighbor filter-list" commands. */ | |
17474 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
17475 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
17476 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
17477 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
17478 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
17479 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
17480 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
17481 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
17482 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
17483 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
17484 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
17485 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
17486 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
17487 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
17488 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
17489 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
17490 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
17491 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 17492 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
17493 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
17494 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
17495 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 17496 | |
17497 | /* "neighbor route-map" commands. */ | |
17498 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
17499 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
17500 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
17501 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
17502 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
17503 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
17504 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
17505 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
17506 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
17507 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
17508 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
17509 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
17510 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
17511 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
17512 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
17513 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
17514 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
17515 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 17516 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
17517 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
17518 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
17519 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
17520 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
17521 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 17522 | |
17523 | /* "neighbor unsuppress-map" commands. */ | |
17524 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
17525 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
17526 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
17527 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
17528 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
17529 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
17530 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
17531 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
17532 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
17533 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
17534 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
17535 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
17536 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
17537 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
17538 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
17539 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
17540 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
17541 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
17542 | ||
7f7940e6 MK |
17543 | /* "neighbor advertise-map" commands. */ |
17544 | install_element(BGP_NODE, &neighbor_advertise_map_hidden_cmd); | |
17545 | install_element(BGP_NODE, &no_neighbor_advertise_map_hidden_cmd); | |
17546 | install_element(BGP_IPV4_NODE, &neighbor_advertise_map_cmd); | |
17547 | install_element(BGP_IPV4_NODE, &no_neighbor_advertise_map_cmd); | |
17548 | install_element(BGP_IPV4M_NODE, &neighbor_advertise_map_cmd); | |
17549 | install_element(BGP_IPV4M_NODE, &no_neighbor_advertise_map_cmd); | |
17550 | install_element(BGP_IPV4L_NODE, &neighbor_advertise_map_cmd); | |
17551 | install_element(BGP_IPV4L_NODE, &no_neighbor_advertise_map_cmd); | |
17552 | install_element(BGP_IPV6_NODE, &neighbor_advertise_map_cmd); | |
17553 | install_element(BGP_IPV6_NODE, &no_neighbor_advertise_map_cmd); | |
17554 | install_element(BGP_IPV6M_NODE, &neighbor_advertise_map_cmd); | |
17555 | install_element(BGP_IPV6M_NODE, &no_neighbor_advertise_map_cmd); | |
17556 | install_element(BGP_IPV6L_NODE, &neighbor_advertise_map_cmd); | |
17557 | install_element(BGP_IPV6L_NODE, &no_neighbor_advertise_map_cmd); | |
17558 | install_element(BGP_VPNV4_NODE, &neighbor_advertise_map_cmd); | |
17559 | install_element(BGP_VPNV4_NODE, &no_neighbor_advertise_map_cmd); | |
17560 | install_element(BGP_VPNV6_NODE, &neighbor_advertise_map_cmd); | |
17561 | install_element(BGP_VPNV6_NODE, &no_neighbor_advertise_map_cmd); | |
17562 | ||
fde246e8 DA |
17563 | /* neighbor maximum-prefix-out commands. */ |
17564 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
17565 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17566 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
17567 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17568 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
17569 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17570 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
17571 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17572 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
17573 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17574 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
17575 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17576 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
17577 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17578 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
17579 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17580 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
17581 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
17582 | ||
d62a17ae | 17583 | /* "neighbor maximum-prefix" commands. */ |
17584 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
17585 | install_element(BGP_NODE, | |
17586 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
17587 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
17588 | install_element(BGP_NODE, | |
17589 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
17590 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
17591 | install_element(BGP_NODE, | |
17592 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
17593 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
17594 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
17595 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17596 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17597 | install_element(BGP_IPV4_NODE, | |
17598 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17599 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17600 | install_element(BGP_IPV4_NODE, | |
17601 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17602 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
17603 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
17604 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17605 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17606 | install_element(BGP_IPV4M_NODE, | |
17607 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17608 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17609 | install_element(BGP_IPV4M_NODE, | |
17610 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17611 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
17612 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
17613 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17614 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17615 | install_element(BGP_IPV4L_NODE, | |
17616 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17617 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17618 | install_element(BGP_IPV4L_NODE, | |
17619 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17620 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
17621 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
17622 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17623 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17624 | install_element(BGP_IPV6_NODE, | |
17625 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17626 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17627 | install_element(BGP_IPV6_NODE, | |
17628 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17629 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
17630 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
17631 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17632 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17633 | install_element(BGP_IPV6M_NODE, | |
17634 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17635 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17636 | install_element(BGP_IPV6M_NODE, | |
17637 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17638 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
17639 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
17640 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17641 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17642 | install_element(BGP_IPV6L_NODE, | |
17643 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17644 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17645 | install_element(BGP_IPV6L_NODE, | |
17646 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17647 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
17648 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
17649 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17650 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17651 | install_element(BGP_VPNV4_NODE, | |
17652 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17653 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17654 | install_element(BGP_VPNV4_NODE, | |
17655 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17656 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
17657 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
17658 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
17659 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
17660 | install_element(BGP_VPNV6_NODE, | |
17661 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
17662 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
17663 | install_element(BGP_VPNV6_NODE, | |
17664 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
17665 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
17666 | ||
17667 | /* "neighbor allowas-in" */ | |
17668 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
17669 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
17670 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
17671 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
17672 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
17673 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
17674 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
17675 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
17676 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
17677 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
17678 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
17679 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
17680 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
17681 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
17682 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
17683 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
17684 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
17685 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
17686 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
17687 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
17688 | ||
17689 | /* address-family commands. */ | |
17690 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
17691 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 17692 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 17693 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
17694 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 17695 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 17696 | |
d62a17ae | 17697 | install_element(BGP_NODE, &address_family_evpn_cmd); |
17698 | ||
17699 | /* "exit-address-family" command. */ | |
17700 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
17701 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
17702 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
17703 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
17704 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
17705 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
17706 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
17707 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 17708 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
17709 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 17710 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
17711 | ||
17712 | /* "clear ip bgp commands" */ | |
17713 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
17714 | ||
17715 | /* clear ip bgp prefix */ | |
17716 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
17717 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
17718 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
17719 | ||
17720 | /* "show [ip] bgp summary" commands. */ | |
17721 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 17722 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 17723 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 17724 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 17725 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
17726 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 17727 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
17728 | ||
17729 | /* "show [ip] bgp neighbors" commands. */ | |
17730 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
17731 | ||
36235319 | 17732 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 17733 | |
d62a17ae | 17734 | /* "show [ip] bgp peer-group" commands. */ |
17735 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
17736 | ||
17737 | /* "show [ip] bgp paths" commands. */ | |
17738 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
17739 | ||
17740 | /* "show [ip] bgp community" commands. */ | |
17741 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
17742 | ||
17743 | /* "show ip bgp large-community" commands. */ | |
17744 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
17745 | /* "show [ip] bgp attribute-info" commands. */ | |
17746 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 17747 | /* "show [ip] bgp route-leak" command */ |
17748 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 17749 | |
17750 | /* "redistribute" commands. */ | |
17751 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
17752 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
17753 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
17754 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
17755 | install_element(BGP_NODE, | |
17756 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
17757 | install_element(BGP_NODE, | |
17758 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
17759 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
17760 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
17761 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
17762 | install_element(BGP_NODE, | |
17763 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
17764 | install_element(BGP_NODE, | |
17765 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
17766 | install_element(BGP_NODE, | |
17767 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
17768 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
17769 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
17770 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
17771 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
17772 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
17773 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
17774 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
17775 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
17776 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
17777 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
17778 | install_element(BGP_IPV4_NODE, | |
17779 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
17780 | install_element(BGP_IPV4_NODE, | |
17781 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
17782 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
17783 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
17784 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
17785 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
17786 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
17787 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
17788 | ||
b9c7bc5a PZ |
17789 | /* import|export vpn [route-map WORD] */ |
17790 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
17791 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 17792 | |
12a844a5 DS |
17793 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
17794 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
17795 | ||
d62a17ae | 17796 | /* ttl_security commands */ |
17797 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
17798 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
17799 | ||
17800 | /* "show [ip] bgp memory" commands. */ | |
17801 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
17802 | ||
acf71666 MK |
17803 | /* "show bgp martian next-hop" */ |
17804 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
17805 | ||
48ecf8f5 DS |
17806 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
17807 | ||
d62a17ae | 17808 | /* "show [ip] bgp views" commands. */ |
17809 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
17810 | ||
17811 | /* "show [ip] bgp vrfs" commands. */ | |
17812 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
17813 | ||
17814 | /* Community-list. */ | |
17815 | community_list_vty(); | |
ddb5b488 PZ |
17816 | |
17817 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
17818 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
17819 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
17820 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
17821 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
17822 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
17823 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
17824 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
17825 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
17826 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
17827 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17828 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
17829 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 17830 | |
301ad80a PG |
17831 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
17832 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
17833 | ||
b9c7bc5a PZ |
17834 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
17835 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
17836 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
17837 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
17838 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
17839 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
17840 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
17841 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
17842 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
17843 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 17844 | } |
6b0655a2 | 17845 | |
718e3744 | 17846 | #include "memory.h" |
17847 | #include "bgp_regex.h" | |
17848 | #include "bgp_clist.h" | |
17849 | #include "bgp_ecommunity.h" | |
17850 | ||
17851 | /* VTY functions. */ | |
17852 | ||
17853 | /* Direction value to string conversion. */ | |
d62a17ae | 17854 | static const char *community_direct_str(int direct) |
17855 | { | |
17856 | switch (direct) { | |
17857 | case COMMUNITY_DENY: | |
17858 | return "deny"; | |
17859 | case COMMUNITY_PERMIT: | |
17860 | return "permit"; | |
17861 | default: | |
17862 | return "unknown"; | |
17863 | } | |
718e3744 | 17864 | } |
17865 | ||
17866 | /* Display error string. */ | |
d62a17ae | 17867 | static void community_list_perror(struct vty *vty, int ret) |
17868 | { | |
17869 | switch (ret) { | |
17870 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
17871 | vty_out(vty, "%% Can't find community-list\n"); | |
17872 | break; | |
17873 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
17874 | vty_out(vty, "%% Malformed community-list value\n"); | |
17875 | break; | |
17876 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
17877 | vty_out(vty, | |
17878 | "%% Community name conflict, previously defined as standard community\n"); | |
17879 | break; | |
17880 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
17881 | vty_out(vty, | |
17882 | "%% Community name conflict, previously defined as expanded community\n"); | |
17883 | break; | |
17884 | } | |
718e3744 | 17885 | } |
17886 | ||
5bf15956 DW |
17887 | /* "community-list" keyword help string. */ |
17888 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
17889 | ||
7336e101 SP |
17890 | /*community-list standard */ |
17891 | DEFUN (community_list_standard, | |
17892 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 17893 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17894 | BGP_STR |
718e3744 | 17895 | COMMUNITY_LIST_STR |
17896 | "Community list number (standard)\n" | |
5bf15956 | 17897 | "Add an standard community-list entry\n" |
718e3744 | 17898 | "Community list name\n" |
2f8cc0e5 DA |
17899 | "Sequence number of an entry\n" |
17900 | "Sequence number\n" | |
718e3744 | 17901 | "Specify community to reject\n" |
17902 | "Specify community to accept\n" | |
17903 | COMMUNITY_VAL_STR) | |
17904 | { | |
d62a17ae | 17905 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17906 | char *seq = NULL; |
d62a17ae | 17907 | int direct = 0; |
17908 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 17909 | int idx = 0; |
7336e101 | 17910 | |
2f8cc0e5 DA |
17911 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17912 | if (idx) | |
17913 | seq = argv[idx]->arg; | |
17914 | ||
17915 | idx = 0; | |
d62a17ae | 17916 | argv_find(argv, argc, "(1-99)", &idx); |
17917 | argv_find(argv, argc, "WORD", &idx); | |
17918 | cl_name_or_number = argv[idx]->arg; | |
17919 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17920 | : COMMUNITY_DENY; | |
17921 | argv_find(argv, argc, "AA:NN", &idx); | |
17922 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17923 | |
2f8cc0e5 DA |
17924 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17925 | direct, style); | |
42f914d4 | 17926 | |
d62a17ae | 17927 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17928 | |
d62a17ae | 17929 | if (ret < 0) { |
17930 | /* Display error string. */ | |
17931 | community_list_perror(vty, ret); | |
17932 | return CMD_WARNING_CONFIG_FAILED; | |
17933 | } | |
42f914d4 | 17934 | |
d62a17ae | 17935 | return CMD_SUCCESS; |
718e3744 | 17936 | } |
17937 | ||
7336e101 SP |
17938 | DEFUN (no_community_list_standard_all, |
17939 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 17940 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17941 | NO_STR |
17942 | BGP_STR | |
17943 | COMMUNITY_LIST_STR | |
17944 | "Community list number (standard)\n" | |
17945 | "Add an standard community-list entry\n" | |
17946 | "Community list name\n" | |
2f8cc0e5 DA |
17947 | "Sequence number of an entry\n" |
17948 | "Sequence number\n" | |
7336e101 SP |
17949 | "Specify community to reject\n" |
17950 | "Specify community to accept\n" | |
17951 | COMMUNITY_VAL_STR) | |
718e3744 | 17952 | { |
d62a17ae | 17953 | char *cl_name_or_number = NULL; |
174b5cb9 | 17954 | char *str = NULL; |
d62a17ae | 17955 | int direct = 0; |
17956 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 17957 | char *seq = NULL; |
d62a17ae | 17958 | int idx = 0; |
7336e101 | 17959 | |
2f8cc0e5 DA |
17960 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17961 | if (idx) | |
17962 | seq = argv[idx]->arg; | |
17963 | ||
17964 | idx = 0; | |
174b5cb9 DA |
17965 | argv_find(argv, argc, "permit", &idx); |
17966 | argv_find(argv, argc, "deny", &idx); | |
17967 | ||
17968 | if (idx) { | |
17969 | direct = argv_find(argv, argc, "permit", &idx) | |
17970 | ? COMMUNITY_PERMIT | |
17971 | : COMMUNITY_DENY; | |
17972 | ||
17973 | idx = 0; | |
17974 | argv_find(argv, argc, "AA:NN", &idx); | |
17975 | str = argv_concat(argv, argc, idx); | |
17976 | } | |
17977 | ||
17978 | idx = 0; | |
d62a17ae | 17979 | argv_find(argv, argc, "(1-99)", &idx); |
17980 | argv_find(argv, argc, "WORD", &idx); | |
17981 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17982 | |
2f8cc0e5 | 17983 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17984 | direct, style); |
42f914d4 | 17985 | |
d62a17ae | 17986 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17987 | |
d62a17ae | 17988 | if (ret < 0) { |
17989 | community_list_perror(vty, ret); | |
17990 | return CMD_WARNING_CONFIG_FAILED; | |
17991 | } | |
42f914d4 | 17992 | |
d62a17ae | 17993 | return CMD_SUCCESS; |
718e3744 | 17994 | } |
7336e101 | 17995 | |
174b5cb9 DA |
17996 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
17997 | "no bgp community-list <(1-99)|standard WORD>", | |
17998 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
17999 | "Community list number (standard)\n" | |
18000 | "Add an standard community-list entry\n" | |
18001 | "Community list name\n") | |
18002 | ||
7336e101 SP |
18003 | /*community-list expanded */ |
18004 | DEFUN (community_list_expanded_all, | |
18005 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18006 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18007 | BGP_STR |
18008 | COMMUNITY_LIST_STR | |
718e3744 | 18009 | "Community list number (expanded)\n" |
5bf15956 | 18010 | "Add an expanded community-list entry\n" |
718e3744 | 18011 | "Community list name\n" |
2f8cc0e5 DA |
18012 | "Sequence number of an entry\n" |
18013 | "Sequence number\n" | |
718e3744 | 18014 | "Specify community to reject\n" |
18015 | "Specify community to accept\n" | |
18016 | COMMUNITY_VAL_STR) | |
18017 | { | |
d62a17ae | 18018 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18019 | char *seq = NULL; |
d62a17ae | 18020 | int direct = 0; |
18021 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18022 | int idx = 0; |
7b9a4750 | 18023 | |
2f8cc0e5 DA |
18024 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18025 | if (idx) | |
18026 | seq = argv[idx]->arg; | |
18027 | ||
18028 | idx = 0; | |
18029 | ||
d62a17ae | 18030 | argv_find(argv, argc, "(100-500)", &idx); |
18031 | argv_find(argv, argc, "WORD", &idx); | |
18032 | cl_name_or_number = argv[idx]->arg; | |
18033 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
18034 | : COMMUNITY_DENY; | |
18035 | argv_find(argv, argc, "AA:NN", &idx); | |
18036 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18037 | |
2f8cc0e5 DA |
18038 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
18039 | direct, style); | |
42f914d4 | 18040 | |
d62a17ae | 18041 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18042 | |
d62a17ae | 18043 | if (ret < 0) { |
18044 | /* Display error string. */ | |
18045 | community_list_perror(vty, ret); | |
18046 | return CMD_WARNING_CONFIG_FAILED; | |
18047 | } | |
42f914d4 | 18048 | |
d62a17ae | 18049 | return CMD_SUCCESS; |
718e3744 | 18050 | } |
18051 | ||
7336e101 SP |
18052 | DEFUN (no_community_list_expanded_all, |
18053 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 18054 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18055 | NO_STR |
18056 | BGP_STR | |
18057 | COMMUNITY_LIST_STR | |
18058 | "Community list number (expanded)\n" | |
18059 | "Add an expanded community-list entry\n" | |
18060 | "Community list name\n" | |
2f8cc0e5 DA |
18061 | "Sequence number of an entry\n" |
18062 | "Sequence number\n" | |
7336e101 SP |
18063 | "Specify community to reject\n" |
18064 | "Specify community to accept\n" | |
18065 | COMMUNITY_VAL_STR) | |
718e3744 | 18066 | { |
d62a17ae | 18067 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 18068 | char *seq = NULL; |
174b5cb9 | 18069 | char *str = NULL; |
d62a17ae | 18070 | int direct = 0; |
18071 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 18072 | int idx = 0; |
174b5cb9 | 18073 | |
2f8cc0e5 DA |
18074 | argv_find(argv, argc, "(1-4294967295)", &idx); |
18075 | if (idx) | |
18076 | seq = argv[idx]->arg; | |
18077 | ||
18078 | idx = 0; | |
174b5cb9 DA |
18079 | argv_find(argv, argc, "permit", &idx); |
18080 | argv_find(argv, argc, "deny", &idx); | |
18081 | ||
18082 | if (idx) { | |
18083 | direct = argv_find(argv, argc, "permit", &idx) | |
18084 | ? COMMUNITY_PERMIT | |
18085 | : COMMUNITY_DENY; | |
18086 | ||
18087 | idx = 0; | |
18088 | argv_find(argv, argc, "AA:NN", &idx); | |
18089 | str = argv_concat(argv, argc, idx); | |
7336e101 | 18090 | } |
174b5cb9 DA |
18091 | |
18092 | idx = 0; | |
d62a17ae | 18093 | argv_find(argv, argc, "(100-500)", &idx); |
18094 | argv_find(argv, argc, "WORD", &idx); | |
18095 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 18096 | |
2f8cc0e5 | 18097 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 18098 | direct, style); |
42f914d4 | 18099 | |
d62a17ae | 18100 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 18101 | |
d62a17ae | 18102 | if (ret < 0) { |
18103 | community_list_perror(vty, ret); | |
18104 | return CMD_WARNING_CONFIG_FAILED; | |
18105 | } | |
42f914d4 | 18106 | |
d62a17ae | 18107 | return CMD_SUCCESS; |
718e3744 | 18108 | } |
18109 | ||
36d4bb44 EB |
18110 | ALIAS(no_community_list_expanded_all, |
18111 | no_bgp_community_list_expanded_all_list_cmd, | |
174b5cb9 | 18112 | "no bgp community-list <(100-500)|expanded WORD>", |
36d4bb44 | 18113 | NO_STR BGP_STR COMMUNITY_LIST_STR |
174b5cb9 DA |
18114 | "Community list number (expanded)\n" |
18115 | "Add an expanded community-list entry\n" | |
18116 | "Community list name\n") | |
18117 | ||
8d9b8ed9 PM |
18118 | /* Return configuration string of community-list entry. */ |
18119 | static const char *community_list_config_str(struct community_entry *entry) | |
18120 | { | |
18121 | const char *str; | |
18122 | ||
18123 | if (entry->any) | |
18124 | str = ""; | |
18125 | else { | |
18126 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
18127 | str = community_str(entry->u.com, false); | |
18128 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
18129 | str = lcommunity_str(entry->u.lcom, false); | |
18130 | else | |
18131 | str = entry->config; | |
18132 | } | |
18133 | return str; | |
18134 | } | |
18135 | ||
d62a17ae | 18136 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18137 | { |
d62a17ae | 18138 | struct community_entry *entry; |
718e3744 | 18139 | |
d62a17ae | 18140 | for (entry = list->head; entry; entry = entry->next) { |
18141 | if (entry == list->head) { | |
18142 | if (all_digit(list->name)) | |
18143 | vty_out(vty, "Community %s list %s\n", | |
18144 | entry->style == COMMUNITY_LIST_STANDARD | |
18145 | ? "standard" | |
18146 | : "(expanded) access", | |
18147 | list->name); | |
18148 | else | |
18149 | vty_out(vty, "Named Community %s list %s\n", | |
18150 | entry->style == COMMUNITY_LIST_STANDARD | |
18151 | ? "standard" | |
18152 | : "expanded", | |
18153 | list->name); | |
18154 | } | |
18155 | if (entry->any) | |
18156 | vty_out(vty, " %s\n", | |
18157 | community_direct_str(entry->direct)); | |
18158 | else | |
18159 | vty_out(vty, " %s %s\n", | |
18160 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18161 | community_list_config_str(entry)); |
d62a17ae | 18162 | } |
718e3744 | 18163 | } |
18164 | ||
7336e101 SP |
18165 | DEFUN (show_community_list, |
18166 | show_bgp_community_list_cmd, | |
18167 | "show bgp community-list", | |
718e3744 | 18168 | SHOW_STR |
7336e101 | 18169 | BGP_STR |
718e3744 | 18170 | "List community-list\n") |
18171 | { | |
d62a17ae | 18172 | struct community_list *list; |
18173 | struct community_list_master *cm; | |
718e3744 | 18174 | |
d62a17ae | 18175 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
18176 | if (!cm) | |
18177 | return CMD_SUCCESS; | |
718e3744 | 18178 | |
d62a17ae | 18179 | for (list = cm->num.head; list; list = list->next) |
18180 | community_list_show(vty, list); | |
718e3744 | 18181 | |
d62a17ae | 18182 | for (list = cm->str.head; list; list = list->next) |
18183 | community_list_show(vty, list); | |
718e3744 | 18184 | |
d62a17ae | 18185 | return CMD_SUCCESS; |
718e3744 | 18186 | } |
18187 | ||
7336e101 SP |
18188 | DEFUN (show_community_list_arg, |
18189 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 18190 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
18191 | SHOW_STR |
18192 | BGP_STR | |
718e3744 | 18193 | "List community-list\n" |
18194 | "Community-list number\n" | |
960b69b9 | 18195 | "Community-list name\n" |
18196 | "Detailed information on community-list\n") | |
718e3744 | 18197 | { |
d62a17ae | 18198 | int idx_comm_list = 3; |
18199 | struct community_list *list; | |
718e3744 | 18200 | |
e237b0d2 | 18201 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 18202 | COMMUNITY_LIST_MASTER); |
18203 | if (!list) { | |
18204 | vty_out(vty, "%% Can't find community-list\n"); | |
18205 | return CMD_WARNING; | |
18206 | } | |
718e3744 | 18207 | |
d62a17ae | 18208 | community_list_show(vty, list); |
718e3744 | 18209 | |
d62a17ae | 18210 | return CMD_SUCCESS; |
718e3744 | 18211 | } |
6b0655a2 | 18212 | |
57d187bc JS |
18213 | /* |
18214 | * Large Community code. | |
18215 | */ | |
d62a17ae | 18216 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
18217 | struct cmd_token **argv, int style, | |
18218 | int reject_all_digit_name) | |
18219 | { | |
18220 | int ret; | |
18221 | int direct; | |
18222 | char *str; | |
18223 | int idx = 0; | |
18224 | char *cl_name; | |
2f8cc0e5 DA |
18225 | char *seq = NULL; |
18226 | ||
947073e3 | 18227 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 18228 | seq = argv[idx]->arg; |
d62a17ae | 18229 | |
2f8cc0e5 | 18230 | idx = 0; |
d62a17ae | 18231 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
18232 | : COMMUNITY_DENY; | |
18233 | ||
18234 | /* All digit name check. */ | |
18235 | idx = 0; | |
18236 | argv_find(argv, argc, "WORD", &idx); | |
18237 | argv_find(argv, argc, "(1-99)", &idx); | |
18238 | argv_find(argv, argc, "(100-500)", &idx); | |
18239 | cl_name = argv[idx]->arg; | |
18240 | if (reject_all_digit_name && all_digit(cl_name)) { | |
18241 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
18242 | return CMD_WARNING_CONFIG_FAILED; | |
18243 | } | |
18244 | ||
18245 | idx = 0; | |
18246 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
18247 | argv_find(argv, argc, "LINE", &idx); | |
18248 | /* Concat community string argument. */ | |
18249 | if (idx) | |
18250 | str = argv_concat(argv, argc, idx); | |
18251 | else | |
18252 | str = NULL; | |
18253 | ||
2f8cc0e5 | 18254 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 18255 | |
18256 | /* Free temporary community list string allocated by | |
18257 | argv_concat(). */ | |
0a22ddfb | 18258 | XFREE(MTYPE_TMP, str); |
d62a17ae | 18259 | |
18260 | if (ret < 0) { | |
18261 | community_list_perror(vty, ret); | |
18262 | return CMD_WARNING_CONFIG_FAILED; | |
18263 | } | |
18264 | return CMD_SUCCESS; | |
18265 | } | |
18266 | ||
18267 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
18268 | struct cmd_token **argv, int style) | |
18269 | { | |
18270 | int ret; | |
18271 | int direct = 0; | |
18272 | char *str = NULL; | |
18273 | int idx = 0; | |
2f8cc0e5 | 18274 | char *seq = NULL; |
d62a17ae | 18275 | |
947073e3 | 18276 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 18277 | seq = argv[idx]->arg; |
d62a17ae | 18278 | |
2f8cc0e5 | 18279 | idx = 0; |
d62a17ae | 18280 | argv_find(argv, argc, "permit", &idx); |
18281 | argv_find(argv, argc, "deny", &idx); | |
18282 | ||
18283 | if (idx) { | |
18284 | /* Check the list direct. */ | |
18285 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
18286 | direct = COMMUNITY_PERMIT; | |
18287 | else | |
18288 | direct = COMMUNITY_DENY; | |
18289 | ||
18290 | idx = 0; | |
18291 | argv_find(argv, argc, "LINE", &idx); | |
18292 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
18293 | /* Concat community string argument. */ | |
18294 | str = argv_concat(argv, argc, idx); | |
18295 | } | |
18296 | ||
18297 | idx = 0; | |
18298 | argv_find(argv, argc, "(1-99)", &idx); | |
18299 | argv_find(argv, argc, "(100-500)", &idx); | |
18300 | argv_find(argv, argc, "WORD", &idx); | |
18301 | ||
18302 | /* Unset community list. */ | |
2f8cc0e5 | 18303 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 18304 | style); |
18305 | ||
18306 | /* Free temporary community list string allocated by | |
18307 | argv_concat(). */ | |
0a22ddfb | 18308 | XFREE(MTYPE_TMP, str); |
d62a17ae | 18309 | |
18310 | if (ret < 0) { | |
18311 | community_list_perror(vty, ret); | |
18312 | return CMD_WARNING_CONFIG_FAILED; | |
18313 | } | |
18314 | ||
18315 | return CMD_SUCCESS; | |
57d187bc JS |
18316 | } |
18317 | ||
18318 | /* "large-community-list" keyword help string. */ | |
18319 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
18320 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
18321 | ||
7336e101 SP |
18322 | DEFUN (lcommunity_list_standard, |
18323 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 18324 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
18325 | BGP_STR |
18326 | LCOMMUNITY_LIST_STR | |
18327 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
18328 | "Sequence number of an entry\n" |
18329 | "Sequence number\n" | |
7336e101 SP |
18330 | "Specify large community to reject\n" |
18331 | "Specify large community to accept\n" | |
18332 | LCOMMUNITY_VAL_STR) | |
52951b63 | 18333 | { |
d62a17ae | 18334 | return lcommunity_list_set_vty(vty, argc, argv, |
18335 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
18336 | } |
18337 | ||
7336e101 SP |
18338 | DEFUN (lcommunity_list_expanded, |
18339 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 18340 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18341 | BGP_STR |
18342 | LCOMMUNITY_LIST_STR | |
18343 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
18344 | "Sequence number of an entry\n" |
18345 | "Sequence number\n" | |
7336e101 SP |
18346 | "Specify large community to reject\n" |
18347 | "Specify large community to accept\n" | |
18348 | "An ordered list as a regular-expression\n") | |
57d187bc | 18349 | { |
d62a17ae | 18350 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 18351 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
18352 | } |
18353 | ||
7336e101 SP |
18354 | DEFUN (lcommunity_list_name_standard, |
18355 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 18356 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
18357 | BGP_STR |
18358 | LCOMMUNITY_LIST_STR | |
18359 | "Specify standard large-community-list\n" | |
18360 | "Large Community list name\n" | |
2f8cc0e5 DA |
18361 | "Sequence number of an entry\n" |
18362 | "Sequence number\n" | |
7336e101 SP |
18363 | "Specify large community to reject\n" |
18364 | "Specify large community to accept\n" | |
18365 | LCOMMUNITY_VAL_STR) | |
52951b63 | 18366 | { |
d62a17ae | 18367 | return lcommunity_list_set_vty(vty, argc, argv, |
18368 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
18369 | } |
18370 | ||
7336e101 SP |
18371 | DEFUN (lcommunity_list_name_expanded, |
18372 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 18373 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18374 | BGP_STR |
18375 | LCOMMUNITY_LIST_STR | |
18376 | "Specify expanded large-community-list\n" | |
18377 | "Large Community list name\n" | |
2f8cc0e5 DA |
18378 | "Sequence number of an entry\n" |
18379 | "Sequence number\n" | |
7336e101 SP |
18380 | "Specify large community to reject\n" |
18381 | "Specify large community to accept\n" | |
18382 | "An ordered list as a regular-expression\n") | |
57d187bc | 18383 | { |
d62a17ae | 18384 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 18385 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
18386 | } |
18387 | ||
4378f57c DA |
18388 | DEFUN (no_lcommunity_list_all, |
18389 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
18390 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
18391 | NO_STR | |
18392 | BGP_STR | |
18393 | LCOMMUNITY_LIST_STR | |
18394 | "Large Community list number (standard)\n" | |
18395 | "Large Community list number (expanded)\n" | |
18396 | "Large Community list name\n") | |
57d187bc | 18397 | { |
7336e101 SP |
18398 | return lcommunity_list_unset_vty(vty, argc, argv, |
18399 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
18400 | } |
18401 | ||
4378f57c DA |
18402 | DEFUN (no_lcommunity_list_name_standard_all, |
18403 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
18404 | "no bgp large-community-list standard WORD", | |
18405 | NO_STR | |
18406 | BGP_STR | |
18407 | LCOMMUNITY_LIST_STR | |
18408 | "Specify standard large-community-list\n" | |
18409 | "Large Community list name\n") | |
18410 | { | |
18411 | return lcommunity_list_unset_vty(vty, argc, argv, | |
18412 | LARGE_COMMUNITY_LIST_STANDARD); | |
18413 | } | |
18414 | ||
7336e101 SP |
18415 | DEFUN (no_lcommunity_list_name_expanded_all, |
18416 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
18417 | "no bgp large-community-list expanded WORD", | |
18418 | NO_STR | |
18419 | BGP_STR | |
18420 | LCOMMUNITY_LIST_STR | |
18421 | "Specify expanded large-community-list\n" | |
18422 | "Large Community list name\n") | |
57d187bc | 18423 | { |
d62a17ae | 18424 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18425 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
18426 | } |
18427 | ||
7336e101 SP |
18428 | DEFUN (no_lcommunity_list_standard, |
18429 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 18430 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
18431 | NO_STR |
18432 | BGP_STR | |
18433 | LCOMMUNITY_LIST_STR | |
18434 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
18435 | "Sequence number of an entry\n" |
18436 | "Sequence number\n" | |
7336e101 SP |
18437 | "Specify large community to reject\n" |
18438 | "Specify large community to accept\n" | |
18439 | LCOMMUNITY_VAL_STR) | |
57d187bc | 18440 | { |
d62a17ae | 18441 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18442 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
18443 | } |
18444 | ||
7336e101 SP |
18445 | DEFUN (no_lcommunity_list_expanded, |
18446 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 18447 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18448 | NO_STR |
18449 | BGP_STR | |
18450 | LCOMMUNITY_LIST_STR | |
18451 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
18452 | "Sequence number of an entry\n" |
18453 | "Sequence number\n" | |
7336e101 SP |
18454 | "Specify large community to reject\n" |
18455 | "Specify large community to accept\n" | |
18456 | "An ordered list as a regular-expression\n") | |
57d187bc | 18457 | { |
d62a17ae | 18458 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18459 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
18460 | } |
18461 | ||
7336e101 SP |
18462 | DEFUN (no_lcommunity_list_name_standard, |
18463 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 18464 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
18465 | NO_STR |
18466 | BGP_STR | |
18467 | LCOMMUNITY_LIST_STR | |
18468 | "Specify standard large-community-list\n" | |
18469 | "Large Community list name\n" | |
2f8cc0e5 DA |
18470 | "Sequence number of an entry\n" |
18471 | "Sequence number\n" | |
7336e101 SP |
18472 | "Specify large community to reject\n" |
18473 | "Specify large community to accept\n" | |
18474 | LCOMMUNITY_VAL_STR) | |
57d187bc | 18475 | { |
d62a17ae | 18476 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18477 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
18478 | } |
18479 | ||
7336e101 SP |
18480 | DEFUN (no_lcommunity_list_name_expanded, |
18481 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 18482 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18483 | NO_STR |
18484 | BGP_STR | |
18485 | LCOMMUNITY_LIST_STR | |
18486 | "Specify expanded large-community-list\n" | |
18487 | "Large community list name\n" | |
2f8cc0e5 DA |
18488 | "Sequence number of an entry\n" |
18489 | "Sequence number\n" | |
7336e101 SP |
18490 | "Specify large community to reject\n" |
18491 | "Specify large community to accept\n" | |
18492 | "An ordered list as a regular-expression\n") | |
57d187bc | 18493 | { |
d62a17ae | 18494 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 18495 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
18496 | } |
18497 | ||
d62a17ae | 18498 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
18499 | { | |
18500 | struct community_entry *entry; | |
18501 | ||
18502 | for (entry = list->head; entry; entry = entry->next) { | |
18503 | if (entry == list->head) { | |
18504 | if (all_digit(list->name)) | |
18505 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 18506 | entry->style == |
18507 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 18508 | ? "standard" |
18509 | : "(expanded) access", | |
18510 | list->name); | |
18511 | else | |
18512 | vty_out(vty, | |
18513 | "Named large community %s list %s\n", | |
169b72c8 | 18514 | entry->style == |
18515 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 18516 | ? "standard" |
18517 | : "expanded", | |
18518 | list->name); | |
18519 | } | |
18520 | if (entry->any) | |
18521 | vty_out(vty, " %s\n", | |
18522 | community_direct_str(entry->direct)); | |
18523 | else | |
18524 | vty_out(vty, " %s %s\n", | |
18525 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18526 | community_list_config_str(entry)); |
d62a17ae | 18527 | } |
57d187bc JS |
18528 | } |
18529 | ||
7336e101 SP |
18530 | DEFUN (show_lcommunity_list, |
18531 | show_bgp_lcommunity_list_cmd, | |
18532 | "show bgp large-community-list", | |
57d187bc | 18533 | SHOW_STR |
7336e101 | 18534 | BGP_STR |
57d187bc JS |
18535 | "List large-community list\n") |
18536 | { | |
d62a17ae | 18537 | struct community_list *list; |
18538 | struct community_list_master *cm; | |
57d187bc | 18539 | |
d62a17ae | 18540 | cm = community_list_master_lookup(bgp_clist, |
18541 | LARGE_COMMUNITY_LIST_MASTER); | |
18542 | if (!cm) | |
18543 | return CMD_SUCCESS; | |
57d187bc | 18544 | |
d62a17ae | 18545 | for (list = cm->num.head; list; list = list->next) |
18546 | lcommunity_list_show(vty, list); | |
57d187bc | 18547 | |
d62a17ae | 18548 | for (list = cm->str.head; list; list = list->next) |
18549 | lcommunity_list_show(vty, list); | |
57d187bc | 18550 | |
d62a17ae | 18551 | return CMD_SUCCESS; |
57d187bc JS |
18552 | } |
18553 | ||
7336e101 SP |
18554 | DEFUN (show_lcommunity_list_arg, |
18555 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 18556 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
18557 | SHOW_STR |
18558 | BGP_STR | |
57d187bc | 18559 | "List large-community list\n" |
960b69b9 | 18560 | "Large-community-list number\n" |
18561 | "Large-community-list name\n" | |
18562 | "Detailed information on large-community-list\n") | |
57d187bc | 18563 | { |
d62a17ae | 18564 | struct community_list *list; |
57d187bc | 18565 | |
e237b0d2 | 18566 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 18567 | LARGE_COMMUNITY_LIST_MASTER); |
18568 | if (!list) { | |
960b69b9 | 18569 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 18570 | return CMD_WARNING; |
18571 | } | |
57d187bc | 18572 | |
d62a17ae | 18573 | lcommunity_list_show(vty, list); |
57d187bc | 18574 | |
d62a17ae | 18575 | return CMD_SUCCESS; |
57d187bc JS |
18576 | } |
18577 | ||
718e3744 | 18578 | /* "extcommunity-list" keyword help string. */ |
18579 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
18580 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
18581 | ||
7336e101 SP |
18582 | DEFUN (extcommunity_list_standard, |
18583 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 18584 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 18585 | BGP_STR |
718e3744 | 18586 | EXTCOMMUNITY_LIST_STR |
18587 | "Extended Community list number (standard)\n" | |
718e3744 | 18588 | "Specify standard extcommunity-list\n" |
5bf15956 | 18589 | "Community list name\n" |
2f8cc0e5 DA |
18590 | "Sequence number of an entry\n" |
18591 | "Sequence number\n" | |
718e3744 | 18592 | "Specify community to reject\n" |
18593 | "Specify community to accept\n" | |
18594 | EXTCOMMUNITY_VAL_STR) | |
18595 | { | |
d62a17ae | 18596 | int style = EXTCOMMUNITY_LIST_STANDARD; |
18597 | int direct = 0; | |
18598 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 18599 | char *seq = NULL; |
42f914d4 | 18600 | |
d62a17ae | 18601 | int idx = 0; |
7b9a4750 | 18602 | |
d62a17ae | 18603 | argv_find(argv, argc, "(1-99)", &idx); |
18604 | argv_find(argv, argc, "WORD", &idx); | |
18605 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 18606 | |
409148f6 | 18607 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18608 | seq = argv[idx]->arg; |
18609 | ||
d62a17ae | 18610 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
18611 | : COMMUNITY_DENY; | |
18612 | argv_find(argv, argc, "AA:NN", &idx); | |
18613 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18614 | |
2f8cc0e5 | 18615 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 18616 | direct, style); |
42f914d4 | 18617 | |
d62a17ae | 18618 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18619 | |
d62a17ae | 18620 | if (ret < 0) { |
18621 | community_list_perror(vty, ret); | |
18622 | return CMD_WARNING_CONFIG_FAILED; | |
18623 | } | |
42f914d4 | 18624 | |
d62a17ae | 18625 | return CMD_SUCCESS; |
718e3744 | 18626 | } |
18627 | ||
7336e101 SP |
18628 | DEFUN (extcommunity_list_name_expanded, |
18629 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 18630 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18631 | BGP_STR |
18632 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 18633 | "Extended Community list number (expanded)\n" |
718e3744 | 18634 | "Specify expanded extcommunity-list\n" |
18635 | "Extended Community list name\n" | |
2f8cc0e5 DA |
18636 | "Sequence number of an entry\n" |
18637 | "Sequence number\n" | |
718e3744 | 18638 | "Specify community to reject\n" |
18639 | "Specify community to accept\n" | |
18640 | "An ordered list as a regular-expression\n") | |
18641 | { | |
d62a17ae | 18642 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
18643 | int direct = 0; | |
18644 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 18645 | char *seq = NULL; |
d62a17ae | 18646 | int idx = 0; |
7336e101 | 18647 | |
d62a17ae | 18648 | argv_find(argv, argc, "(100-500)", &idx); |
18649 | argv_find(argv, argc, "WORD", &idx); | |
18650 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 18651 | |
409148f6 | 18652 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18653 | seq = argv[idx]->arg; |
18654 | ||
d62a17ae | 18655 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
18656 | : COMMUNITY_DENY; | |
18657 | argv_find(argv, argc, "LINE", &idx); | |
18658 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 18659 | |
2f8cc0e5 | 18660 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 18661 | direct, style); |
42f914d4 | 18662 | |
d62a17ae | 18663 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18664 | |
d62a17ae | 18665 | if (ret < 0) { |
18666 | community_list_perror(vty, ret); | |
18667 | return CMD_WARNING_CONFIG_FAILED; | |
18668 | } | |
42f914d4 | 18669 | |
d62a17ae | 18670 | return CMD_SUCCESS; |
718e3744 | 18671 | } |
18672 | ||
7336e101 SP |
18673 | DEFUN (no_extcommunity_list_standard_all, |
18674 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 18675 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
18676 | NO_STR |
18677 | BGP_STR | |
18678 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 18679 | "Extended Community list number (standard)\n" |
718e3744 | 18680 | "Specify standard extcommunity-list\n" |
5bf15956 | 18681 | "Community list name\n" |
2f8cc0e5 DA |
18682 | "Sequence number of an entry\n" |
18683 | "Sequence number\n" | |
718e3744 | 18684 | "Specify community to reject\n" |
18685 | "Specify community to accept\n" | |
18686 | EXTCOMMUNITY_VAL_STR) | |
18687 | { | |
d62a17ae | 18688 | int style = EXTCOMMUNITY_LIST_STANDARD; |
18689 | int direct = 0; | |
18690 | char *cl_number_or_name = NULL; | |
d4455c89 | 18691 | char *str = NULL; |
2f8cc0e5 | 18692 | char *seq = NULL; |
d62a17ae | 18693 | int idx = 0; |
d4455c89 | 18694 | |
409148f6 | 18695 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18696 | seq = argv[idx]->arg; |
18697 | ||
18698 | idx = 0; | |
d4455c89 DA |
18699 | argv_find(argv, argc, "permit", &idx); |
18700 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
18701 | if (idx) { |
18702 | direct = argv_find(argv, argc, "permit", &idx) | |
18703 | ? COMMUNITY_PERMIT | |
18704 | : COMMUNITY_DENY; | |
18705 | ||
18706 | idx = 0; | |
18707 | argv_find(argv, argc, "AA:NN", &idx); | |
18708 | str = argv_concat(argv, argc, idx); | |
18709 | } | |
18710 | ||
18711 | idx = 0; | |
d62a17ae | 18712 | argv_find(argv, argc, "(1-99)", &idx); |
18713 | argv_find(argv, argc, "WORD", &idx); | |
18714 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 18715 | |
d62a17ae | 18716 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 18717 | seq, direct, style); |
42f914d4 | 18718 | |
d62a17ae | 18719 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18720 | |
d62a17ae | 18721 | if (ret < 0) { |
18722 | community_list_perror(vty, ret); | |
18723 | return CMD_WARNING_CONFIG_FAILED; | |
18724 | } | |
42f914d4 | 18725 | |
d62a17ae | 18726 | return CMD_SUCCESS; |
718e3744 | 18727 | } |
18728 | ||
d4455c89 DA |
18729 | ALIAS(no_extcommunity_list_standard_all, |
18730 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
18731 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
36d4bb44 | 18732 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
18733 | "Extended Community list number (standard)\n" |
18734 | "Specify standard extcommunity-list\n" | |
18735 | "Community list name\n") | |
18736 | ||
7336e101 SP |
18737 | DEFUN (no_extcommunity_list_expanded_all, |
18738 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 18739 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
18740 | NO_STR |
18741 | BGP_STR | |
18742 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 18743 | "Extended Community list number (expanded)\n" |
718e3744 | 18744 | "Specify expanded extcommunity-list\n" |
5bf15956 | 18745 | "Extended Community list name\n" |
2f8cc0e5 DA |
18746 | "Sequence number of an entry\n" |
18747 | "Sequence number\n" | |
718e3744 | 18748 | "Specify community to reject\n" |
18749 | "Specify community to accept\n" | |
18750 | "An ordered list as a regular-expression\n") | |
18751 | { | |
d62a17ae | 18752 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
18753 | int direct = 0; | |
18754 | char *cl_number_or_name = NULL; | |
d4455c89 | 18755 | char *str = NULL; |
2f8cc0e5 | 18756 | char *seq = NULL; |
d62a17ae | 18757 | int idx = 0; |
d4455c89 | 18758 | |
409148f6 | 18759 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
18760 | seq = argv[idx]->arg; |
18761 | ||
18762 | idx = 0; | |
d4455c89 DA |
18763 | argv_find(argv, argc, "permit", &idx); |
18764 | argv_find(argv, argc, "deny", &idx); | |
18765 | ||
18766 | if (idx) { | |
18767 | direct = argv_find(argv, argc, "permit", &idx) | |
18768 | ? COMMUNITY_PERMIT | |
18769 | : COMMUNITY_DENY; | |
18770 | ||
18771 | idx = 0; | |
18772 | argv_find(argv, argc, "LINE", &idx); | |
18773 | str = argv_concat(argv, argc, idx); | |
18774 | } | |
18775 | ||
18776 | idx = 0; | |
d62a17ae | 18777 | argv_find(argv, argc, "(100-500)", &idx); |
18778 | argv_find(argv, argc, "WORD", &idx); | |
18779 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 18780 | |
d62a17ae | 18781 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 18782 | seq, direct, style); |
42f914d4 | 18783 | |
d62a17ae | 18784 | XFREE(MTYPE_TMP, str); |
42f914d4 | 18785 | |
d62a17ae | 18786 | if (ret < 0) { |
18787 | community_list_perror(vty, ret); | |
18788 | return CMD_WARNING_CONFIG_FAILED; | |
18789 | } | |
42f914d4 | 18790 | |
d62a17ae | 18791 | return CMD_SUCCESS; |
718e3744 | 18792 | } |
18793 | ||
d4455c89 DA |
18794 | ALIAS(no_extcommunity_list_expanded_all, |
18795 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
18796 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
36d4bb44 | 18797 | NO_STR BGP_STR EXTCOMMUNITY_LIST_STR |
d4455c89 DA |
18798 | "Extended Community list number (expanded)\n" |
18799 | "Specify expanded extcommunity-list\n" | |
18800 | "Extended Community list name\n") | |
18801 | ||
d62a17ae | 18802 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 18803 | { |
d62a17ae | 18804 | struct community_entry *entry; |
718e3744 | 18805 | |
d62a17ae | 18806 | for (entry = list->head; entry; entry = entry->next) { |
18807 | if (entry == list->head) { | |
18808 | if (all_digit(list->name)) | |
18809 | vty_out(vty, "Extended community %s list %s\n", | |
18810 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18811 | ? "standard" | |
18812 | : "(expanded) access", | |
18813 | list->name); | |
18814 | else | |
18815 | vty_out(vty, | |
18816 | "Named extended community %s list %s\n", | |
18817 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
18818 | ? "standard" | |
18819 | : "expanded", | |
18820 | list->name); | |
18821 | } | |
18822 | if (entry->any) | |
18823 | vty_out(vty, " %s\n", | |
18824 | community_direct_str(entry->direct)); | |
18825 | else | |
18826 | vty_out(vty, " %s %s\n", | |
18827 | community_direct_str(entry->direct), | |
8d9b8ed9 | 18828 | community_list_config_str(entry)); |
d62a17ae | 18829 | } |
718e3744 | 18830 | } |
18831 | ||
7336e101 SP |
18832 | DEFUN (show_extcommunity_list, |
18833 | show_bgp_extcommunity_list_cmd, | |
18834 | "show bgp extcommunity-list", | |
718e3744 | 18835 | SHOW_STR |
7336e101 | 18836 | BGP_STR |
718e3744 | 18837 | "List extended-community list\n") |
18838 | { | |
d62a17ae | 18839 | struct community_list *list; |
18840 | struct community_list_master *cm; | |
718e3744 | 18841 | |
d62a17ae | 18842 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
18843 | if (!cm) | |
18844 | return CMD_SUCCESS; | |
718e3744 | 18845 | |
d62a17ae | 18846 | for (list = cm->num.head; list; list = list->next) |
18847 | extcommunity_list_show(vty, list); | |
718e3744 | 18848 | |
d62a17ae | 18849 | for (list = cm->str.head; list; list = list->next) |
18850 | extcommunity_list_show(vty, list); | |
718e3744 | 18851 | |
d62a17ae | 18852 | return CMD_SUCCESS; |
718e3744 | 18853 | } |
18854 | ||
7336e101 SP |
18855 | DEFUN (show_extcommunity_list_arg, |
18856 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 18857 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
18858 | SHOW_STR |
18859 | BGP_STR | |
718e3744 | 18860 | "List extended-community list\n" |
18861 | "Extcommunity-list number\n" | |
960b69b9 | 18862 | "Extcommunity-list name\n" |
18863 | "Detailed information on extcommunity-list\n") | |
718e3744 | 18864 | { |
d62a17ae | 18865 | int idx_comm_list = 3; |
18866 | struct community_list *list; | |
718e3744 | 18867 | |
e237b0d2 | 18868 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 18869 | EXTCOMMUNITY_LIST_MASTER); |
18870 | if (!list) { | |
18871 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
18872 | return CMD_WARNING; | |
18873 | } | |
718e3744 | 18874 | |
d62a17ae | 18875 | extcommunity_list_show(vty, list); |
718e3744 | 18876 | |
d62a17ae | 18877 | return CMD_SUCCESS; |
718e3744 | 18878 | } |
6b0655a2 | 18879 | |
718e3744 | 18880 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 18881 | static int community_list_config_write(struct vty *vty) |
18882 | { | |
18883 | struct community_list *list; | |
18884 | struct community_entry *entry; | |
18885 | struct community_list_master *cm; | |
18886 | int write = 0; | |
18887 | ||
18888 | /* Community-list. */ | |
18889 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
18890 | ||
18891 | for (list = cm->num.head; list; list = list->next) | |
18892 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18893 | vty_out(vty, |
18894 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
18895 | list->name, entry->seq, | |
d62a17ae | 18896 | community_direct_str(entry->direct), |
18897 | community_list_config_str(entry)); | |
18898 | write++; | |
18899 | } | |
18900 | for (list = cm->str.head; list; list = list->next) | |
18901 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18902 | vty_out(vty, |
18903 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 18904 | entry->style == COMMUNITY_LIST_STANDARD |
18905 | ? "standard" | |
18906 | : "expanded", | |
2f8cc0e5 DA |
18907 | list->name, entry->seq, |
18908 | community_direct_str(entry->direct), | |
d62a17ae | 18909 | community_list_config_str(entry)); |
18910 | write++; | |
18911 | } | |
18912 | ||
18913 | /* Extcommunity-list. */ | |
18914 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
18915 | ||
18916 | for (list = cm->num.head; list; list = list->next) | |
18917 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18918 | vty_out(vty, |
18919 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
18920 | list->name, entry->seq, | |
18921 | community_direct_str(entry->direct), | |
d62a17ae | 18922 | community_list_config_str(entry)); |
18923 | write++; | |
18924 | } | |
18925 | for (list = cm->str.head; list; list = list->next) | |
18926 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18927 | vty_out(vty, |
6cde4b45 | 18928 | "bgp extcommunity-list %s %s seq %" PRId64" %s %s\n", |
d62a17ae | 18929 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
18930 | ? "standard" | |
18931 | : "expanded", | |
2f8cc0e5 DA |
18932 | list->name, entry->seq, |
18933 | community_direct_str(entry->direct), | |
d62a17ae | 18934 | community_list_config_str(entry)); |
18935 | write++; | |
18936 | } | |
18937 | ||
18938 | ||
18939 | /* lcommunity-list. */ | |
18940 | cm = community_list_master_lookup(bgp_clist, | |
18941 | LARGE_COMMUNITY_LIST_MASTER); | |
18942 | ||
18943 | for (list = cm->num.head; list; list = list->next) | |
18944 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18945 | vty_out(vty, |
6cde4b45 | 18946 | "bgp large-community-list %s seq %" PRId64" %s %s\n", |
2f8cc0e5 DA |
18947 | list->name, entry->seq, |
18948 | community_direct_str(entry->direct), | |
d62a17ae | 18949 | community_list_config_str(entry)); |
18950 | write++; | |
18951 | } | |
18952 | for (list = cm->str.head; list; list = list->next) | |
18953 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 | 18954 | vty_out(vty, |
6cde4b45 | 18955 | "bgp large-community-list %s %s seq %" PRId64" %s %s\n", |
2f8cc0e5 | 18956 | |
d62a17ae | 18957 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
18958 | ? "standard" | |
18959 | : "expanded", | |
2f8cc0e5 | 18960 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 18961 | community_list_config_str(entry)); |
18962 | write++; | |
18963 | } | |
18964 | ||
18965 | return write; | |
18966 | } | |
18967 | ||
612c2c15 | 18968 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 18969 | static struct cmd_node community_list_node = { |
f4b8291f | 18970 | .name = "community list", |
62b346ee DL |
18971 | .node = COMMUNITY_LIST_NODE, |
18972 | .prompt = "", | |
612c2c15 | 18973 | .config_write = community_list_config_write, |
718e3744 | 18974 | }; |
18975 | ||
d62a17ae | 18976 | static void community_list_vty(void) |
18977 | { | |
612c2c15 | 18978 | install_node(&community_list_node); |
d62a17ae | 18979 | |
18980 | /* Community-list. */ | |
7336e101 SP |
18981 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
18982 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
18983 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 18984 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 18985 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 18986 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
18987 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
18988 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 18989 | |
18990 | /* Extcommunity-list. */ | |
7336e101 SP |
18991 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
18992 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
18993 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
18994 | install_element(CONFIG_NODE, |
18995 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 18996 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
18997 | install_element(CONFIG_NODE, |
18998 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
18999 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
19000 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 19001 | |
19002 | /* Large Community List */ | |
7336e101 | 19003 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
19004 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
19005 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 19006 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
19007 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
19008 | install_element(CONFIG_NODE, | |
19009 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
19010 | install_element(CONFIG_NODE, |
19011 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
19012 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
19013 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
19014 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
19015 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
19016 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
19017 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 19018 | } |