]>
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" |
dcc68b5e | 68 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 69 | #include "bgpd/bgp_mac.h" |
dd65f45e | 70 | #include "bgpd/bgp_flowspec.h" |
49e5a4a0 | 71 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
72 | #include "bgpd/rfapi/bgp_rfapi_cfg.h" |
73 | #endif | |
74 | ||
5d5393b9 | 75 | FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK, |
62282e83 DS |
76 | { |
77 | .val_bool = false, | |
78 | .match_profile = "traditional", | |
79 | .match_version = "< 7.4", | |
80 | }, | |
81 | { .val_bool = true }, | |
5d5393b9 DL |
82 | ) |
83 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
4c1458b5 DL |
84 | { .val_bool = true, .match_profile = "datacenter", }, |
85 | { .val_bool = false }, | |
5d5393b9 DL |
86 | ) |
87 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, | |
4c1458b5 DL |
88 | { .val_bool = true, .match_profile = "datacenter", }, |
89 | { .val_bool = false }, | |
5d5393b9 DL |
90 | ) |
91 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
4c1458b5 DL |
92 | { .val_bool = true, .match_profile = "datacenter", }, |
93 | { .val_bool = false }, | |
5d5393b9 DL |
94 | ) |
95 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
96 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
97 | { .val_ulong = 120 }, | |
98 | ) | |
99 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
100 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
101 | { .val_ulong = 180 }, | |
102 | ) | |
103 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
104 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
105 | { .val_ulong = 60 }, | |
106 | ) | |
1d3fdccf DA |
107 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
108 | { .val_bool = false, .match_profile = "datacenter", }, | |
109 | { .val_bool = false, .match_version = "< 7.4", }, | |
110 | { .val_bool = true }, | |
111 | ) | |
5d5393b9 | 112 | |
dd65f45e DL |
113 | DEFINE_HOOK(bgp_inst_config_write, |
114 | (struct bgp *bgp, struct vty *vty), | |
115 | (bgp, vty)) | |
718e3744 | 116 | |
36235319 QY |
117 | #define GR_NO_OPER \ |
118 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
119 | #define GR_INVALID \ | |
120 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 121 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
122 | struct prefix *range, int exact); | |
123 | ||
055679e9 | 124 | /* Show BGP peer's information. */ |
125 | enum show_type { | |
126 | show_all, | |
127 | show_peer, | |
128 | show_ipv4_all, | |
129 | show_ipv6_all, | |
130 | show_ipv4_peer, | |
131 | show_ipv6_peer | |
132 | }; | |
133 | ||
36235319 QY |
134 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
135 | struct prefix *range, int exact); | |
2986cac2 | 136 | |
36235319 QY |
137 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
138 | struct bgp *bgp, | |
139 | bool use_json, | |
140 | json_object *json); | |
2986cac2 | 141 | |
36235319 QY |
142 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
143 | enum show_type type, | |
144 | const char *ip_str, | |
145 | afi_t afi, bool use_json); | |
2986cac2 | 146 | |
d62a17ae | 147 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
148 | { | |
149 | switch (afi) { | |
150 | case AFI_IP: | |
151 | switch (safi) { | |
152 | case SAFI_UNICAST: | |
153 | return BGP_IPV4_NODE; | |
d62a17ae | 154 | case SAFI_MULTICAST: |
155 | return BGP_IPV4M_NODE; | |
d62a17ae | 156 | case SAFI_LABELED_UNICAST: |
157 | return BGP_IPV4L_NODE; | |
d62a17ae | 158 | case SAFI_MPLS_VPN: |
159 | return BGP_VPNV4_NODE; | |
7c40bf39 | 160 | case SAFI_FLOWSPEC: |
161 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
162 | default: |
163 | /* not expected */ | |
164 | return BGP_IPV4_NODE; | |
d62a17ae | 165 | } |
166 | break; | |
167 | case AFI_IP6: | |
168 | switch (safi) { | |
169 | case SAFI_UNICAST: | |
170 | return BGP_IPV6_NODE; | |
d62a17ae | 171 | case SAFI_MULTICAST: |
172 | return BGP_IPV6M_NODE; | |
d62a17ae | 173 | case SAFI_LABELED_UNICAST: |
174 | return BGP_IPV6L_NODE; | |
d62a17ae | 175 | case SAFI_MPLS_VPN: |
176 | return BGP_VPNV6_NODE; | |
7c40bf39 | 177 | case SAFI_FLOWSPEC: |
178 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
179 | default: |
180 | /* not expected */ | |
181 | return BGP_IPV4_NODE; | |
d62a17ae | 182 | } |
183 | break; | |
184 | case AFI_L2VPN: | |
185 | return BGP_EVPN_NODE; | |
b26f891d | 186 | case AFI_UNSPEC: |
d62a17ae | 187 | case AFI_MAX: |
188 | // We should never be here but to clarify the switch statement.. | |
189 | return BGP_IPV4_NODE; | |
d62a17ae | 190 | } |
191 | ||
192 | // Impossible to happen | |
193 | return BGP_IPV4_NODE; | |
f51bae9c | 194 | } |
20eb8864 | 195 | |
5cb5f4d0 DD |
196 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
197 | { | |
198 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
199 | return "IPv4 Unicast"; | |
200 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
201 | return "IPv4 Multicast"; | |
202 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
203 | return "IPv4 Labeled Unicast"; | |
204 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
205 | return "IPv4 VPN"; | |
206 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
207 | return "IPv4 Encap"; | |
208 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
209 | return "IPv4 Flowspec"; | |
210 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
211 | return "IPv6 Unicast"; | |
212 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
213 | return "IPv6 Multicast"; | |
214 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
215 | return "IPv6 Labeled Unicast"; | |
216 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
217 | return "IPv6 VPN"; | |
218 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
219 | return "IPv6 Encap"; | |
220 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
221 | return "IPv6 Flowspec"; | |
222 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
223 | return "L2VPN EVPN"; | |
8e5509b0 | 224 | else |
5cb5f4d0 | 225 | return "Unknown"; |
5cb5f4d0 DD |
226 | } |
227 | ||
228 | /* | |
229 | * Please note that we have intentionally camelCased | |
230 | * the return strings here. So if you want | |
231 | * to use this function, please ensure you | |
232 | * are doing this within json output | |
233 | */ | |
234 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
235 | { | |
236 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
237 | return "ipv4Unicast"; | |
238 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
239 | return "ipv4Multicast"; | |
240 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
241 | return "ipv4LabeledUnicast"; | |
242 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
243 | return "ipv4Vpn"; | |
244 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
245 | return "ipv4Encap"; | |
246 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
247 | return "ipv4Flowspec"; | |
248 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
249 | return "ipv6Unicast"; | |
250 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
251 | return "ipv6Multicast"; | |
252 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
253 | return "ipv6LabeledUnicast"; | |
254 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
255 | return "ipv6Vpn"; | |
256 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
257 | return "ipv6Encap"; | |
258 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
259 | return "ipv6Flowspec"; | |
260 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
261 | return "l2VpnEvpn"; | |
8e5509b0 | 262 | else |
5cb5f4d0 | 263 | return "Unknown"; |
5cb5f4d0 DD |
264 | } |
265 | ||
718e3744 | 266 | /* Utility function to get address family from current node. */ |
d62a17ae | 267 | afi_t bgp_node_afi(struct vty *vty) |
268 | { | |
269 | afi_t afi; | |
270 | switch (vty->node) { | |
271 | case BGP_IPV6_NODE: | |
272 | case BGP_IPV6M_NODE: | |
273 | case BGP_IPV6L_NODE: | |
274 | case BGP_VPNV6_NODE: | |
7c40bf39 | 275 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 276 | afi = AFI_IP6; |
277 | break; | |
278 | case BGP_EVPN_NODE: | |
279 | afi = AFI_L2VPN; | |
280 | break; | |
281 | default: | |
282 | afi = AFI_IP; | |
283 | break; | |
284 | } | |
285 | return afi; | |
718e3744 | 286 | } |
287 | ||
288 | /* Utility function to get subsequent address family from current | |
289 | node. */ | |
d62a17ae | 290 | safi_t bgp_node_safi(struct vty *vty) |
291 | { | |
292 | safi_t safi; | |
293 | switch (vty->node) { | |
294 | case BGP_VPNV4_NODE: | |
295 | case BGP_VPNV6_NODE: | |
296 | safi = SAFI_MPLS_VPN; | |
297 | break; | |
298 | case BGP_IPV4M_NODE: | |
299 | case BGP_IPV6M_NODE: | |
300 | safi = SAFI_MULTICAST; | |
301 | break; | |
302 | case BGP_EVPN_NODE: | |
303 | safi = SAFI_EVPN; | |
304 | break; | |
305 | case BGP_IPV4L_NODE: | |
306 | case BGP_IPV6L_NODE: | |
307 | safi = SAFI_LABELED_UNICAST; | |
308 | break; | |
7c40bf39 | 309 | case BGP_FLOWSPECV4_NODE: |
310 | case BGP_FLOWSPECV6_NODE: | |
311 | safi = SAFI_FLOWSPEC; | |
312 | break; | |
d62a17ae | 313 | default: |
314 | safi = SAFI_UNICAST; | |
315 | break; | |
316 | } | |
317 | return safi; | |
718e3744 | 318 | } |
319 | ||
55f91488 QY |
320 | /** |
321 | * Converts an AFI in string form to afi_t | |
322 | * | |
323 | * @param afi string, one of | |
324 | * - "ipv4" | |
325 | * - "ipv6" | |
81cf0de5 | 326 | * - "l2vpn" |
55f91488 QY |
327 | * @return the corresponding afi_t |
328 | */ | |
d62a17ae | 329 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
330 | { | |
331 | afi_t afi = AFI_MAX; /* unknown */ | |
332 | if (strmatch(afi_str, "ipv4")) | |
333 | afi = AFI_IP; | |
334 | else if (strmatch(afi_str, "ipv6")) | |
335 | afi = AFI_IP6; | |
81cf0de5 CS |
336 | else if (strmatch(afi_str, "l2vpn")) |
337 | afi = AFI_L2VPN; | |
d62a17ae | 338 | return afi; |
339 | } | |
340 | ||
341 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
342 | afi_t *afi) | |
343 | { | |
344 | int ret = 0; | |
345 | if (argv_find(argv, argc, "ipv4", index)) { | |
346 | ret = 1; | |
347 | if (afi) | |
348 | *afi = AFI_IP; | |
349 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
350 | ret = 1; | |
351 | if (afi) | |
352 | *afi = AFI_IP6; | |
8688b3e7 DS |
353 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
354 | ret = 1; | |
355 | if (afi) | |
356 | *afi = AFI_L2VPN; | |
d62a17ae | 357 | } |
358 | return ret; | |
46f296b4 LB |
359 | } |
360 | ||
375a2e67 | 361 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 362 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
363 | { | |
364 | safi_t safi = SAFI_MAX; /* unknown */ | |
365 | if (strmatch(safi_str, "multicast")) | |
366 | safi = SAFI_MULTICAST; | |
367 | else if (strmatch(safi_str, "unicast")) | |
368 | safi = SAFI_UNICAST; | |
369 | else if (strmatch(safi_str, "vpn")) | |
370 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
371 | else if (strmatch(safi_str, "evpn")) |
372 | safi = SAFI_EVPN; | |
d62a17ae | 373 | else if (strmatch(safi_str, "labeled-unicast")) |
374 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 375 | else if (strmatch(safi_str, "flowspec")) |
376 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 377 | return safi; |
378 | } | |
379 | ||
380 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
381 | safi_t *safi) | |
382 | { | |
383 | int ret = 0; | |
384 | if (argv_find(argv, argc, "unicast", index)) { | |
385 | ret = 1; | |
386 | if (safi) | |
387 | *safi = SAFI_UNICAST; | |
388 | } else if (argv_find(argv, argc, "multicast", index)) { | |
389 | ret = 1; | |
390 | if (safi) | |
391 | *safi = SAFI_MULTICAST; | |
392 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
393 | ret = 1; | |
394 | if (safi) | |
395 | *safi = SAFI_LABELED_UNICAST; | |
396 | } else if (argv_find(argv, argc, "vpn", index)) { | |
397 | ret = 1; | |
398 | if (safi) | |
399 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
400 | } else if (argv_find(argv, argc, "evpn", index)) { |
401 | ret = 1; | |
402 | if (safi) | |
403 | *safi = SAFI_EVPN; | |
7c40bf39 | 404 | } else if (argv_find(argv, argc, "flowspec", index)) { |
405 | ret = 1; | |
406 | if (safi) | |
407 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 408 | } |
409 | return ret; | |
46f296b4 LB |
410 | } |
411 | ||
5d5393b9 DL |
412 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
413 | enum bgp_instance_type inst_type) | |
414 | { | |
415 | int ret = bgp_get(bgp, as, name, inst_type); | |
416 | ||
417 | if (ret == BGP_CREATED) { | |
418 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
419 | DFLT_BGP_CONNECT_RETRY); | |
420 | ||
421 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 422 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 423 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 424 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
5d5393b9 | 425 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 426 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 427 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 428 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
429 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
430 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
5d5393b9 DL |
431 | |
432 | ret = BGP_SUCCESS; | |
433 | } | |
434 | return ret; | |
435 | } | |
436 | ||
7eeee51e | 437 | /* |
f212a857 | 438 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 439 | * |
f212a857 DS |
440 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
441 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
442 | * to appropriate values for the calling function. This is to allow the |
443 | * calling function to make decisions appropriate for the show command | |
444 | * that is being parsed. | |
445 | * | |
446 | * The show commands are generally of the form: | |
d62a17ae | 447 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
448 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
449 | * |
450 | * Since we use argv_find if the show command in particular doesn't have: | |
451 | * [ip] | |
18c57037 | 452 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 453 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
454 | * The command parsing should still be ok. |
455 | * | |
456 | * vty -> The vty for the command so we can output some useful data in | |
457 | * the event of a parse error in the vrf. | |
458 | * argv -> The command tokens | |
459 | * argc -> How many command tokens we have | |
d62a17ae | 460 | * idx -> The current place in the command, generally should be 0 for this |
461 | * function | |
7eeee51e DS |
462 | * afi -> The parsed afi if it was included in the show command, returned here |
463 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 464 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 465 | * use_json -> json is configured or not |
7eeee51e DS |
466 | * |
467 | * The function returns the correct location in the parse tree for the | |
468 | * last token found. | |
0e37c258 DS |
469 | * |
470 | * Returns 0 for failure to parse correctly, else the idx position of where | |
471 | * it found the last token. | |
7eeee51e | 472 | */ |
d62a17ae | 473 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
474 | struct cmd_token **argv, int argc, | |
475 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 476 | struct bgp **bgp, bool use_json) |
d62a17ae | 477 | { |
478 | char *vrf_name = NULL; | |
479 | ||
480 | assert(afi); | |
481 | assert(safi); | |
482 | assert(bgp); | |
483 | ||
484 | if (argv_find(argv, argc, "ip", idx)) | |
485 | *afi = AFI_IP; | |
486 | ||
9a8bdf1c | 487 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 488 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
489 | else if (argv_find(argv, argc, "vrf", idx)) { |
490 | vrf_name = argv[*idx + 1]->arg; | |
491 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
492 | vrf_name = NULL; | |
493 | } | |
494 | if (vrf_name) { | |
d62a17ae | 495 | if (strmatch(vrf_name, "all")) |
496 | *bgp = NULL; | |
497 | else { | |
498 | *bgp = bgp_lookup_by_name(vrf_name); | |
499 | if (!*bgp) { | |
52e5b8c4 SP |
500 | if (use_json) { |
501 | json_object *json = NULL; | |
502 | json = json_object_new_object(); | |
503 | json_object_string_add( | |
504 | json, "warning", | |
505 | "View/Vrf is unknown"); | |
506 | vty_out(vty, "%s\n", | |
507 | json_object_to_json_string_ext(json, | |
508 | JSON_C_TO_STRING_PRETTY)); | |
509 | json_object_free(json); | |
510 | } | |
ca61fd25 DS |
511 | else |
512 | vty_out(vty, "View/Vrf %s is unknown\n", | |
513 | vrf_name); | |
d62a17ae | 514 | *idx = 0; |
515 | return 0; | |
516 | } | |
517 | } | |
518 | } else { | |
519 | *bgp = bgp_get_default(); | |
520 | if (!*bgp) { | |
52e5b8c4 SP |
521 | if (use_json) { |
522 | json_object *json = NULL; | |
523 | json = json_object_new_object(); | |
524 | json_object_string_add( | |
525 | json, "warning", | |
526 | "Default BGP instance not found"); | |
527 | vty_out(vty, "%s\n", | |
528 | json_object_to_json_string_ext(json, | |
529 | JSON_C_TO_STRING_PRETTY)); | |
530 | json_object_free(json); | |
531 | } | |
ca61fd25 DS |
532 | else |
533 | vty_out(vty, | |
534 | "Default BGP instance not found\n"); | |
d62a17ae | 535 | *idx = 0; |
536 | return 0; | |
537 | } | |
538 | } | |
539 | ||
540 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
541 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
542 | ||
543 | *idx += 1; | |
544 | return *idx; | |
545 | } | |
546 | ||
3dc339cd | 547 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 548 | { |
549 | struct interface *ifp = NULL; | |
550 | ||
551 | if (su->sa.sa_family == AF_INET) | |
552 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
553 | else if (su->sa.sa_family == AF_INET6) | |
554 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
555 | su->sin6.sin6_scope_id, | |
556 | bgp->vrf_id); | |
557 | ||
558 | if (ifp) | |
3dc339cd | 559 | return true; |
d62a17ae | 560 | |
3dc339cd | 561 | return false; |
718e3744 | 562 | } |
563 | ||
564 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
565 | /* This is used only for configuration, so disallow if attempted on |
566 | * a dynamic neighbor. | |
567 | */ | |
d62a17ae | 568 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
569 | { | |
570 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
571 | int ret; | |
572 | union sockunion su; | |
573 | struct peer *peer; | |
574 | ||
575 | if (!bgp) { | |
576 | return NULL; | |
577 | } | |
578 | ||
579 | ret = str2sockunion(ip_str, &su); | |
580 | if (ret < 0) { | |
581 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
582 | if (!peer) { | |
583 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
584 | == NULL) { | |
585 | vty_out(vty, | |
586 | "%% Malformed address or name: %s\n", | |
587 | ip_str); | |
588 | return NULL; | |
589 | } | |
590 | } | |
591 | } else { | |
592 | peer = peer_lookup(bgp, &su); | |
593 | if (!peer) { | |
594 | vty_out(vty, | |
595 | "%% Specify remote-as or peer-group commands first\n"); | |
596 | return NULL; | |
597 | } | |
598 | if (peer_dynamic_neighbor(peer)) { | |
599 | vty_out(vty, | |
600 | "%% Operation not allowed on a dynamic neighbor\n"); | |
601 | return NULL; | |
602 | } | |
603 | } | |
604 | return peer; | |
718e3744 | 605 | } |
606 | ||
607 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
608 | /* This is used only for configuration, so disallow if attempted on |
609 | * a dynamic neighbor. | |
610 | */ | |
d62a17ae | 611 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
612 | { | |
613 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
614 | int ret; | |
615 | union sockunion su; | |
616 | struct peer *peer = NULL; | |
617 | struct peer_group *group = NULL; | |
618 | ||
619 | if (!bgp) { | |
620 | return NULL; | |
621 | } | |
622 | ||
623 | ret = str2sockunion(peer_str, &su); | |
624 | if (ret == 0) { | |
625 | /* IP address, locate peer. */ | |
626 | peer = peer_lookup(bgp, &su); | |
627 | } else { | |
628 | /* Not IP, could match either peer configured on interface or a | |
629 | * group. */ | |
630 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
631 | if (!peer) | |
632 | group = peer_group_lookup(bgp, peer_str); | |
633 | } | |
634 | ||
635 | if (peer) { | |
636 | if (peer_dynamic_neighbor(peer)) { | |
637 | vty_out(vty, | |
638 | "%% Operation not allowed on a dynamic neighbor\n"); | |
639 | return NULL; | |
640 | } | |
641 | ||
642 | return peer; | |
643 | } | |
644 | ||
645 | if (group) | |
646 | return group->conf; | |
647 | ||
648 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
649 | ||
650 | return NULL; | |
651 | } | |
652 | ||
653 | int bgp_vty_return(struct vty *vty, int ret) | |
654 | { | |
655 | const char *str = NULL; | |
656 | ||
657 | switch (ret) { | |
658 | case BGP_ERR_INVALID_VALUE: | |
659 | str = "Invalid value"; | |
660 | break; | |
661 | case BGP_ERR_INVALID_FLAG: | |
662 | str = "Invalid flag"; | |
663 | break; | |
664 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
665 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
666 | break; | |
667 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
668 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
669 | break; | |
670 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
671 | str = "Specify remote-as or peer-group remote AS first"; | |
672 | break; | |
673 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
674 | str = "Cannot change the peer-group. Deconfigure first"; | |
675 | break; | |
676 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
677 | str = "Peer is not a member of this peer-group"; | |
678 | break; | |
679 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
680 | str = "Prefix/distribute list can not co-exist"; | |
681 | break; | |
682 | case BGP_ERR_NOT_INTERNAL_PEER: | |
683 | str = "Invalid command. Not an internal neighbor"; | |
684 | break; | |
685 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
686 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
687 | break; | |
688 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
689 | str = "Local-AS allowed only for EBGP peers"; | |
690 | break; | |
691 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
692 | str = "Cannot have local-as same as BGP AS number"; | |
693 | break; | |
694 | case BGP_ERR_TCPSIG_FAILED: | |
695 | str = "Error while applying TCP-Sig to session(s)"; | |
696 | break; | |
697 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
698 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
699 | break; | |
700 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
701 | str = "ttl-security only allowed for EBGP peers"; | |
702 | break; | |
703 | case BGP_ERR_AS_OVERRIDE: | |
704 | str = "as-override cannot be configured for IBGP peers"; | |
705 | break; | |
706 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
707 | str = "Invalid limit for number of dynamic neighbors"; | |
708 | break; | |
709 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
710 | str = "Dynamic neighbor listen range already exists"; | |
711 | break; | |
712 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
713 | str = "Operation not allowed on a dynamic neighbor"; | |
714 | break; | |
715 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
716 | str = "Operation not allowed on a directly connected neighbor"; | |
717 | break; | |
718 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 719 | str = GR_INVALID; |
720 | break; | |
721 | case BGP_ERR_GR_INVALID_CMD: | |
722 | str = "The Graceful Restart command used is not valid at this moment."; | |
723 | break; | |
724 | case BGP_ERR_GR_OPERATION_FAILED: | |
725 | str = "The Graceful Restart Operation failed due to an err."; | |
726 | break; | |
727 | case BGP_GR_NO_OPERATION: | |
728 | str = GR_NO_OPER; | |
d62a17ae | 729 | break; |
730 | } | |
731 | if (str) { | |
732 | vty_out(vty, "%% %s\n", str); | |
733 | return CMD_WARNING_CONFIG_FAILED; | |
734 | } | |
735 | return CMD_SUCCESS; | |
718e3744 | 736 | } |
737 | ||
7aafcaca | 738 | /* BGP clear sort. */ |
d62a17ae | 739 | enum clear_sort { |
740 | clear_all, | |
741 | clear_peer, | |
742 | clear_group, | |
743 | clear_external, | |
744 | clear_as | |
7aafcaca DS |
745 | }; |
746 | ||
d62a17ae | 747 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
748 | safi_t safi, int error) | |
749 | { | |
750 | switch (error) { | |
751 | case BGP_ERR_AF_UNCONFIGURED: | |
752 | vty_out(vty, | |
753 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 754 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 755 | break; |
756 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
757 | vty_out(vty, | |
758 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
759 | peer->host); | |
760 | break; | |
761 | default: | |
762 | break; | |
763 | } | |
7aafcaca DS |
764 | } |
765 | ||
dc912615 | 766 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 767 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
768 | { |
769 | int ret = 0; | |
770 | ||
771 | /* if afi/.safi not specified, spin thru all of them */ | |
772 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
773 | afi_t tmp_afi; | |
774 | safi_t tmp_safi; | |
775 | ||
776 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
777 | if (!peer->afc[tmp_afi][tmp_safi]) | |
778 | continue; | |
779 | ||
780 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 781 | ret = peer_clear(peer, nnode); |
dc912615 DS |
782 | else |
783 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
784 | stype); | |
785 | } | |
786 | /* if afi specified and safi not, spin thru safis on this afi */ | |
787 | } else if (safi == SAFI_UNSPEC) { | |
788 | safi_t tmp_safi; | |
789 | ||
790 | for (tmp_safi = SAFI_UNICAST; | |
791 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
792 | if (!peer->afc[afi][tmp_safi]) | |
793 | continue; | |
794 | ||
795 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 796 | ret = peer_clear(peer, nnode); |
dc912615 DS |
797 | else |
798 | ret = peer_clear_soft(peer, afi, | |
799 | tmp_safi, stype); | |
800 | } | |
801 | /* both afi/safi specified, let the caller know if not defined */ | |
802 | } else { | |
803 | if (!peer->afc[afi][safi]) | |
804 | return 1; | |
805 | ||
806 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 807 | ret = peer_clear(peer, nnode); |
dc912615 DS |
808 | else |
809 | ret = peer_clear_soft(peer, afi, safi, stype); | |
810 | } | |
811 | ||
812 | return ret; | |
813 | } | |
814 | ||
7aafcaca | 815 | /* `clear ip bgp' functions. */ |
d62a17ae | 816 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
817 | enum clear_sort sort, enum bgp_clear_type stype, | |
818 | const char *arg) | |
819 | { | |
dc912615 | 820 | int ret = 0; |
3ae8bfa5 | 821 | bool found = false; |
d62a17ae | 822 | struct peer *peer; |
dc95985f | 823 | |
824 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 825 | |
826 | /* Clear all neighbors. */ | |
827 | /* | |
828 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
829 | * nodes on the BGP instance as that may get freed if it is a |
830 | * doppelganger | |
d62a17ae | 831 | */ |
832 | if (sort == clear_all) { | |
833 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 834 | |
835 | bgp_peer_gr_flags_update(peer); | |
836 | ||
36235319 | 837 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 838 | gr_router_detected = true; |
839 | ||
c368171c | 840 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 841 | stype); |
d62a17ae | 842 | |
843 | if (ret < 0) | |
844 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
dc95985f | 845 | } |
846 | ||
36235319 QY |
847 | if (gr_router_detected |
848 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 849 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
850 | } else if (!gr_router_detected |
851 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 852 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 853 | } |
d62a17ae | 854 | |
855 | /* This is to apply read-only mode on this clear. */ | |
856 | if (stype == BGP_CLEAR_SOFT_NONE) | |
857 | bgp->update_delay_over = 0; | |
858 | ||
859 | return CMD_SUCCESS; | |
7aafcaca DS |
860 | } |
861 | ||
3ae8bfa5 | 862 | /* Clear specified neighbor. */ |
d62a17ae | 863 | if (sort == clear_peer) { |
864 | union sockunion su; | |
d62a17ae | 865 | |
866 | /* Make sockunion for lookup. */ | |
867 | ret = str2sockunion(arg, &su); | |
868 | if (ret < 0) { | |
869 | peer = peer_lookup_by_conf_if(bgp, arg); | |
870 | if (!peer) { | |
871 | peer = peer_lookup_by_hostname(bgp, arg); | |
872 | if (!peer) { | |
873 | vty_out(vty, | |
874 | "Malformed address or name: %s\n", | |
875 | arg); | |
876 | return CMD_WARNING; | |
877 | } | |
878 | } | |
879 | } else { | |
880 | peer = peer_lookup(bgp, &su); | |
881 | if (!peer) { | |
882 | vty_out(vty, | |
883 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
884 | arg); | |
885 | return CMD_WARNING; | |
886 | } | |
887 | } | |
7aafcaca | 888 | |
dc95985f | 889 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
890 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
891 | ||
dc912615 DS |
892 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
893 | ||
894 | /* if afi/safi not defined for this peer, let caller know */ | |
895 | if (ret == 1) | |
3ae8bfa5 | 896 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 897 | |
d62a17ae | 898 | if (ret < 0) |
899 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 900 | |
d62a17ae | 901 | return CMD_SUCCESS; |
7aafcaca | 902 | } |
7aafcaca | 903 | |
3ae8bfa5 | 904 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 905 | if (sort == clear_group) { |
906 | struct peer_group *group; | |
7aafcaca | 907 | |
d62a17ae | 908 | group = peer_group_lookup(bgp, arg); |
909 | if (!group) { | |
910 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
911 | return CMD_WARNING; | |
912 | } | |
913 | ||
914 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 915 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 916 | |
d62a17ae | 917 | if (ret < 0) |
918 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
919 | else |
920 | found = true; | |
d62a17ae | 921 | } |
3ae8bfa5 PM |
922 | |
923 | if (!found) | |
924 | vty_out(vty, | |
925 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 926 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 927 | |
d62a17ae | 928 | return CMD_SUCCESS; |
7aafcaca | 929 | } |
7aafcaca | 930 | |
3ae8bfa5 | 931 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 932 | if (sort == clear_external) { |
933 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
934 | if (peer->sort == BGP_PEER_IBGP) | |
935 | continue; | |
7aafcaca | 936 | |
dc95985f | 937 | bgp_peer_gr_flags_update(peer); |
938 | ||
36235319 | 939 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 940 | gr_router_detected = true; |
dc95985f | 941 | |
c368171c | 942 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 943 | |
d62a17ae | 944 | if (ret < 0) |
945 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
946 | else |
947 | found = true; | |
d62a17ae | 948 | } |
3ae8bfa5 | 949 | |
36235319 QY |
950 | if (gr_router_detected |
951 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 952 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
953 | } else if (!gr_router_detected |
954 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 955 | bgp_zebra_send_capabilities(bgp, true); |
956 | } | |
957 | ||
3ae8bfa5 PM |
958 | if (!found) |
959 | vty_out(vty, | |
960 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 961 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 962 | |
d62a17ae | 963 | return CMD_SUCCESS; |
964 | } | |
965 | ||
3ae8bfa5 | 966 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 967 | if (sort == clear_as) { |
3ae8bfa5 | 968 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 969 | |
970 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
971 | if (peer->as != as) | |
972 | continue; | |
973 | ||
dc95985f | 974 | bgp_peer_gr_flags_update(peer); |
975 | ||
36235319 | 976 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 977 | gr_router_detected = true; |
dc95985f | 978 | |
c368171c | 979 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 980 | |
981 | if (ret < 0) | |
982 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
983 | else |
984 | found = true; | |
d62a17ae | 985 | } |
3ae8bfa5 | 986 | |
36235319 QY |
987 | if (gr_router_detected |
988 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 989 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
990 | } else if (!gr_router_detected |
991 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 992 | bgp_zebra_send_capabilities(bgp, true); |
993 | } | |
994 | ||
3ae8bfa5 | 995 | if (!found) |
d62a17ae | 996 | vty_out(vty, |
3ae8bfa5 | 997 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 998 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 999 | |
d62a17ae | 1000 | return CMD_SUCCESS; |
1001 | } | |
1002 | ||
1003 | return CMD_SUCCESS; | |
1004 | } | |
1005 | ||
1006 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
1007 | safi_t safi, enum clear_sort sort, | |
1008 | enum bgp_clear_type stype, const char *arg) | |
1009 | { | |
1010 | struct bgp *bgp; | |
1011 | ||
1012 | /* BGP structure lookup. */ | |
1013 | if (name) { | |
1014 | bgp = bgp_lookup_by_name(name); | |
1015 | if (bgp == NULL) { | |
1016 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
1017 | return CMD_WARNING; | |
1018 | } | |
1019 | } else { | |
1020 | bgp = bgp_get_default(); | |
1021 | if (bgp == NULL) { | |
1022 | vty_out(vty, "No BGP process is configured\n"); | |
1023 | return CMD_WARNING; | |
1024 | } | |
1025 | } | |
1026 | ||
1027 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
1028 | } |
1029 | ||
1030 | /* clear soft inbound */ | |
d62a17ae | 1031 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1032 | { |
99b3ebd3 NS |
1033 | afi_t afi; |
1034 | safi_t safi; | |
1035 | ||
1036 | FOREACH_AFI_SAFI (afi, safi) | |
1037 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1038 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1039 | } |
1040 | ||
1041 | /* clear soft outbound */ | |
d62a17ae | 1042 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1043 | { |
99b3ebd3 NS |
1044 | afi_t afi; |
1045 | safi_t safi; | |
1046 | ||
1047 | FOREACH_AFI_SAFI (afi, safi) | |
1048 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1049 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1050 | } |
1051 | ||
1052 | ||
f787d7a0 | 1053 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1054 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1055 | #endif |
1056 | ||
8029b216 AK |
1057 | DEFUN_HIDDEN (bgp_local_mac, |
1058 | bgp_local_mac_cmd, | |
093e3f23 | 1059 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1060 | BGP_STR |
1061 | "Local MAC config\n" | |
1062 | "VxLAN Network Identifier\n" | |
1063 | "VNI number\n" | |
1064 | "local mac\n" | |
1065 | "mac address\n" | |
1066 | "mac-mobility sequence\n" | |
1067 | "seq number\n") | |
1068 | { | |
1069 | int rv; | |
1070 | vni_t vni; | |
1071 | struct ethaddr mac; | |
1072 | struct ipaddr ip; | |
1073 | uint32_t seq; | |
1074 | struct bgp *bgp; | |
1075 | ||
1076 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1077 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1078 | vty_out(vty, "%% Malformed MAC address\n"); | |
1079 | return CMD_WARNING; | |
1080 | } | |
1081 | memset(&ip, 0, sizeof(ip)); | |
1082 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1083 | ||
1084 | bgp = bgp_get_default(); | |
1085 | if (!bgp) { | |
1086 | vty_out(vty, "Default BGP instance is not there\n"); | |
1087 | return CMD_WARNING; | |
1088 | } | |
1089 | ||
1090 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
1091 | if (rv < 0) { | |
1092 | vty_out(vty, "Internal error\n"); | |
1093 | return CMD_WARNING; | |
1094 | } | |
1095 | ||
1096 | return CMD_SUCCESS; | |
1097 | } | |
1098 | ||
1099 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1100 | no_bgp_local_mac_cmd, | |
093e3f23 | 1101 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1102 | NO_STR |
1103 | BGP_STR | |
1104 | "Local MAC config\n" | |
1105 | "VxLAN Network Identifier\n" | |
1106 | "VNI number\n" | |
1107 | "local mac\n" | |
1108 | "mac address\n") | |
1109 | { | |
1110 | int rv; | |
1111 | vni_t vni; | |
1112 | struct ethaddr mac; | |
1113 | struct ipaddr ip; | |
1114 | struct bgp *bgp; | |
1115 | ||
1116 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1117 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1118 | vty_out(vty, "%% Malformed MAC address\n"); | |
1119 | return CMD_WARNING; | |
1120 | } | |
1121 | memset(&ip, 0, sizeof(ip)); | |
1122 | ||
1123 | bgp = bgp_get_default(); | |
1124 | if (!bgp) { | |
1125 | vty_out(vty, "Default BGP instance is not there\n"); | |
1126 | return CMD_WARNING; | |
1127 | } | |
1128 | ||
ec0ab544 | 1129 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1130 | if (rv < 0) { |
1131 | vty_out(vty, "Internal error\n"); | |
1132 | return CMD_WARNING; | |
1133 | } | |
1134 | ||
1135 | return CMD_SUCCESS; | |
1136 | } | |
1137 | ||
718e3744 | 1138 | DEFUN (no_synchronization, |
1139 | no_synchronization_cmd, | |
1140 | "no synchronization", | |
1141 | NO_STR | |
1142 | "Perform IGP synchronization\n") | |
1143 | { | |
d62a17ae | 1144 | return CMD_SUCCESS; |
718e3744 | 1145 | } |
1146 | ||
1147 | DEFUN (no_auto_summary, | |
1148 | no_auto_summary_cmd, | |
1149 | "no auto-summary", | |
1150 | NO_STR | |
1151 | "Enable automatic network number summarization\n") | |
1152 | { | |
d62a17ae | 1153 | return CMD_SUCCESS; |
718e3744 | 1154 | } |
3d515fd9 | 1155 | |
718e3744 | 1156 | /* "router bgp" commands. */ |
505e5056 | 1157 | DEFUN_NOSH (router_bgp, |
f412b39a | 1158 | router_bgp_cmd, |
2ed9fe4a | 1159 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1160 | ROUTER_STR |
1161 | BGP_STR | |
31500417 DW |
1162 | AS_STR |
1163 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1164 | { |
d62a17ae | 1165 | int idx_asn = 2; |
1166 | int idx_view_vrf = 3; | |
1167 | int idx_vrf = 4; | |
ecec9495 | 1168 | int is_new_bgp = 0; |
d62a17ae | 1169 | int ret; |
1170 | as_t as; | |
1171 | struct bgp *bgp; | |
1172 | const char *name = NULL; | |
1173 | enum bgp_instance_type inst_type; | |
1174 | ||
1175 | // "router bgp" without an ASN | |
1176 | if (argc == 2) { | |
1177 | // Pending: Make VRF option available for ASN less config | |
1178 | bgp = bgp_get_default(); | |
1179 | ||
1180 | if (bgp == NULL) { | |
1181 | vty_out(vty, "%% No BGP process is configured\n"); | |
1182 | return CMD_WARNING_CONFIG_FAILED; | |
1183 | } | |
1184 | ||
1185 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1186 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1187 | return CMD_WARNING_CONFIG_FAILED; |
1188 | } | |
1189 | } | |
1190 | ||
1191 | // "router bgp X" | |
1192 | else { | |
1193 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1194 | ||
1195 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1196 | if (argc > 3) { | |
1197 | name = argv[idx_vrf]->arg; | |
1198 | ||
9a8bdf1c PG |
1199 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1200 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1201 | name = NULL; | |
1202 | else | |
1203 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1204 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1205 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1206 | } | |
1207 | ||
ecec9495 AD |
1208 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1209 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1210 | ||
5d5393b9 | 1211 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1212 | switch (ret) { |
d62a17ae | 1213 | case BGP_ERR_AS_MISMATCH: |
1214 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1215 | return CMD_WARNING_CONFIG_FAILED; | |
1216 | case BGP_ERR_INSTANCE_MISMATCH: | |
1217 | vty_out(vty, | |
1218 | "BGP instance name and AS number mismatch\n"); | |
1219 | vty_out(vty, | |
1220 | "BGP instance is already running; AS is %u\n", | |
1221 | as); | |
1222 | return CMD_WARNING_CONFIG_FAILED; | |
1223 | } | |
1224 | ||
3bd70bf8 PZ |
1225 | /* |
1226 | * If we just instantiated the default instance, complete | |
1227 | * any pending VRF-VPN leaking that was configured via | |
1228 | * earlier "router bgp X vrf FOO" blocks. | |
1229 | */ | |
ecec9495 | 1230 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1231 | vpn_leak_postchange_all(); |
1232 | ||
48381346 CS |
1233 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1234 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1235 | /* Pending: handle when user tries to change a view to vrf n vv. |
1236 | */ | |
1237 | } | |
1238 | ||
0b5131c9 MK |
1239 | /* unset the auto created flag as the user config is now present */ |
1240 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1241 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1242 | ||
1243 | return CMD_SUCCESS; | |
718e3744 | 1244 | } |
1245 | ||
718e3744 | 1246 | /* "no router bgp" commands. */ |
1247 | DEFUN (no_router_bgp, | |
1248 | no_router_bgp_cmd, | |
2ed9fe4a | 1249 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1250 | NO_STR |
1251 | ROUTER_STR | |
1252 | BGP_STR | |
31500417 DW |
1253 | AS_STR |
1254 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1255 | { |
d62a17ae | 1256 | int idx_asn = 3; |
1257 | int idx_vrf = 5; | |
1258 | as_t as; | |
1259 | struct bgp *bgp; | |
1260 | const char *name = NULL; | |
718e3744 | 1261 | |
d62a17ae | 1262 | // "no router bgp" without an ASN |
1263 | if (argc == 3) { | |
1264 | // Pending: Make VRF option available for ASN less config | |
1265 | bgp = bgp_get_default(); | |
718e3744 | 1266 | |
d62a17ae | 1267 | if (bgp == NULL) { |
1268 | vty_out(vty, "%% No BGP process is configured\n"); | |
1269 | return CMD_WARNING_CONFIG_FAILED; | |
1270 | } | |
7fb21a9f | 1271 | |
d62a17ae | 1272 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1273 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1274 | return CMD_WARNING_CONFIG_FAILED; |
1275 | } | |
0b5131c9 MK |
1276 | |
1277 | if (bgp->l3vni) { | |
1278 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1279 | bgp->l3vni); | |
1280 | return CMD_WARNING_CONFIG_FAILED; | |
1281 | } | |
d62a17ae | 1282 | } else { |
1283 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1284 | |
d62a17ae | 1285 | if (argc > 4) |
1286 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1287 | |
d62a17ae | 1288 | /* Lookup bgp structure. */ |
1289 | bgp = bgp_lookup(as, name); | |
1290 | if (!bgp) { | |
1291 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1292 | return CMD_WARNING_CONFIG_FAILED; | |
1293 | } | |
0b5131c9 MK |
1294 | |
1295 | if (bgp->l3vni) { | |
dd5868c2 | 1296 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1297 | bgp->l3vni); |
1298 | return CMD_WARNING_CONFIG_FAILED; | |
1299 | } | |
dd5868c2 DS |
1300 | |
1301 | /* Cannot delete default instance if vrf instances exist */ | |
1302 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1303 | struct listnode *node; | |
1304 | struct bgp *tmp_bgp; | |
1305 | ||
1306 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1307 | if (tmp_bgp->inst_type | |
1308 | == BGP_INSTANCE_TYPE_VRF) { | |
1309 | vty_out(vty, | |
1310 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1311 | return CMD_WARNING_CONFIG_FAILED; | |
1312 | } | |
1313 | } | |
1314 | } | |
d62a17ae | 1315 | } |
718e3744 | 1316 | |
9ecf931b CS |
1317 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1318 | return CMD_WARNING_CONFIG_FAILED; | |
1319 | ||
d62a17ae | 1320 | bgp_delete(bgp); |
718e3744 | 1321 | |
d62a17ae | 1322 | return CMD_SUCCESS; |
718e3744 | 1323 | } |
1324 | ||
6b0655a2 | 1325 | |
718e3744 | 1326 | /* BGP router-id. */ |
1327 | ||
f787d7a0 | 1328 | DEFPY (bgp_router_id, |
718e3744 | 1329 | bgp_router_id_cmd, |
1330 | "bgp router-id A.B.C.D", | |
1331 | BGP_STR | |
1332 | "Override configured router identifier\n" | |
1333 | "Manually configured router identifier\n") | |
1334 | { | |
d62a17ae | 1335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1336 | bgp_router_id_static_set(bgp, router_id); | |
1337 | return CMD_SUCCESS; | |
718e3744 | 1338 | } |
1339 | ||
f787d7a0 | 1340 | DEFPY (no_bgp_router_id, |
718e3744 | 1341 | no_bgp_router_id_cmd, |
31500417 | 1342 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1343 | NO_STR |
1344 | BGP_STR | |
31500417 DW |
1345 | "Override configured router identifier\n" |
1346 | "Manually configured router identifier\n") | |
718e3744 | 1347 | { |
d62a17ae | 1348 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1349 | |
d62a17ae | 1350 | if (router_id_str) { |
1351 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1352 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1353 | return CMD_WARNING_CONFIG_FAILED; | |
1354 | } | |
e018c7cc | 1355 | } |
718e3744 | 1356 | |
d62a17ae | 1357 | router_id.s_addr = 0; |
1358 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1359 | |
d62a17ae | 1360 | return CMD_SUCCESS; |
718e3744 | 1361 | } |
1362 | ||
6b0655a2 | 1363 | |
718e3744 | 1364 | /* BGP Cluster ID. */ |
718e3744 | 1365 | DEFUN (bgp_cluster_id, |
1366 | bgp_cluster_id_cmd, | |
838758ac | 1367 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1368 | BGP_STR |
1369 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1370 | "Route-Reflector Cluster-id in IP address format\n" |
1371 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1372 | { |
d62a17ae | 1373 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1374 | int idx_ipv4 = 2; | |
1375 | int ret; | |
1376 | struct in_addr cluster; | |
718e3744 | 1377 | |
d62a17ae | 1378 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1379 | if (!ret) { | |
1380 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1381 | return CMD_WARNING_CONFIG_FAILED; | |
1382 | } | |
718e3744 | 1383 | |
d62a17ae | 1384 | bgp_cluster_id_set(bgp, &cluster); |
1385 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1386 | |
d62a17ae | 1387 | return CMD_SUCCESS; |
718e3744 | 1388 | } |
1389 | ||
718e3744 | 1390 | DEFUN (no_bgp_cluster_id, |
1391 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1392 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1393 | NO_STR |
1394 | BGP_STR | |
838758ac DW |
1395 | "Configure Route-Reflector Cluster-id\n" |
1396 | "Route-Reflector Cluster-id in IP address format\n" | |
1397 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1398 | { |
d62a17ae | 1399 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1400 | bgp_cluster_id_unset(bgp); | |
1401 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1402 | |
d62a17ae | 1403 | return CMD_SUCCESS; |
718e3744 | 1404 | } |
1405 | ||
718e3744 | 1406 | DEFUN (bgp_confederation_identifier, |
1407 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1408 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1409 | "BGP specific commands\n" |
1410 | "AS confederation parameters\n" | |
1411 | "AS number\n" | |
1412 | "Set routing domain confederation AS\n") | |
1413 | { | |
d62a17ae | 1414 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1415 | int idx_number = 3; | |
1416 | as_t as; | |
718e3744 | 1417 | |
d62a17ae | 1418 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1419 | |
d62a17ae | 1420 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1421 | |
d62a17ae | 1422 | return CMD_SUCCESS; |
718e3744 | 1423 | } |
1424 | ||
1425 | DEFUN (no_bgp_confederation_identifier, | |
1426 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1427 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1428 | NO_STR |
1429 | "BGP specific commands\n" | |
1430 | "AS confederation parameters\n" | |
3a2d747c QY |
1431 | "AS number\n" |
1432 | "Set routing domain confederation AS\n") | |
718e3744 | 1433 | { |
d62a17ae | 1434 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1435 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1436 | |
d62a17ae | 1437 | return CMD_SUCCESS; |
718e3744 | 1438 | } |
1439 | ||
718e3744 | 1440 | DEFUN (bgp_confederation_peers, |
1441 | bgp_confederation_peers_cmd, | |
12dcf78e | 1442 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1443 | "BGP specific commands\n" |
1444 | "AS confederation parameters\n" | |
1445 | "Peer ASs in BGP confederation\n" | |
1446 | AS_STR) | |
1447 | { | |
d62a17ae | 1448 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1449 | int idx_asn = 3; | |
1450 | as_t as; | |
1451 | int i; | |
718e3744 | 1452 | |
d62a17ae | 1453 | for (i = idx_asn; i < argc; i++) { |
1454 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1455 | |
d62a17ae | 1456 | if (bgp->as == as) { |
1457 | vty_out(vty, | |
1458 | "%% Local member-AS not allowed in confed peer list\n"); | |
1459 | continue; | |
1460 | } | |
718e3744 | 1461 | |
d62a17ae | 1462 | bgp_confederation_peers_add(bgp, as); |
1463 | } | |
1464 | return CMD_SUCCESS; | |
718e3744 | 1465 | } |
1466 | ||
1467 | DEFUN (no_bgp_confederation_peers, | |
1468 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1469 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1470 | NO_STR |
1471 | "BGP specific commands\n" | |
1472 | "AS confederation parameters\n" | |
1473 | "Peer ASs in BGP confederation\n" | |
1474 | AS_STR) | |
1475 | { | |
d62a17ae | 1476 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1477 | int idx_asn = 4; | |
1478 | as_t as; | |
1479 | int i; | |
718e3744 | 1480 | |
d62a17ae | 1481 | for (i = idx_asn; i < argc; i++) { |
1482 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1483 | |
d62a17ae | 1484 | bgp_confederation_peers_remove(bgp, as); |
1485 | } | |
1486 | return CMD_SUCCESS; | |
718e3744 | 1487 | } |
6b0655a2 | 1488 | |
5e242b0d DS |
1489 | /** |
1490 | * Central routine for maximum-paths configuration. | |
1491 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1492 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1493 | */ | |
d62a17ae | 1494 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1495 | const char *mpaths, uint16_t options, |
d62a17ae | 1496 | int set) |
1497 | { | |
1498 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1499 | uint16_t maxpaths = 0; |
d62a17ae | 1500 | int ret; |
1501 | afi_t afi; | |
1502 | safi_t safi; | |
1503 | ||
1504 | afi = bgp_node_afi(vty); | |
1505 | safi = bgp_node_safi(vty); | |
1506 | ||
1507 | if (set) { | |
1508 | maxpaths = strtol(mpaths, NULL, 10); | |
1509 | if (maxpaths > multipath_num) { | |
1510 | vty_out(vty, | |
1511 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1512 | maxpaths, multipath_num); | |
1513 | return CMD_WARNING_CONFIG_FAILED; | |
1514 | } | |
1515 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1516 | options); | |
1517 | } else | |
1518 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1519 | ||
1520 | if (ret < 0) { | |
1521 | vty_out(vty, | |
1522 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1523 | (set == 1) ? "" : "un", | |
1524 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1525 | maxpaths, afi, safi); | |
1526 | return CMD_WARNING_CONFIG_FAILED; | |
1527 | } | |
1528 | ||
1529 | bgp_recalculate_all_bestpaths(bgp); | |
1530 | ||
1531 | return CMD_SUCCESS; | |
165b5fff JB |
1532 | } |
1533 | ||
abc920f8 DS |
1534 | DEFUN (bgp_maxmed_admin, |
1535 | bgp_maxmed_admin_cmd, | |
1536 | "bgp max-med administrative ", | |
1537 | BGP_STR | |
1538 | "Advertise routes with max-med\n" | |
1539 | "Administratively applied, for an indefinite period\n") | |
1540 | { | |
d62a17ae | 1541 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1542 | |
d62a17ae | 1543 | bgp->v_maxmed_admin = 1; |
1544 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1545 | |
d62a17ae | 1546 | bgp_maxmed_update(bgp); |
abc920f8 | 1547 | |
d62a17ae | 1548 | return CMD_SUCCESS; |
abc920f8 DS |
1549 | } |
1550 | ||
1551 | DEFUN (bgp_maxmed_admin_medv, | |
1552 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1553 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1554 | BGP_STR |
1555 | "Advertise routes with max-med\n" | |
1556 | "Administratively applied, for an indefinite period\n" | |
1557 | "Max MED value to be used\n") | |
1558 | { | |
d62a17ae | 1559 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1560 | int idx_number = 3; | |
abc920f8 | 1561 | |
d62a17ae | 1562 | bgp->v_maxmed_admin = 1; |
1563 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1564 | |
d62a17ae | 1565 | bgp_maxmed_update(bgp); |
abc920f8 | 1566 | |
d62a17ae | 1567 | return CMD_SUCCESS; |
abc920f8 DS |
1568 | } |
1569 | ||
1570 | DEFUN (no_bgp_maxmed_admin, | |
1571 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1572 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1573 | NO_STR |
1574 | BGP_STR | |
1575 | "Advertise routes with max-med\n" | |
838758ac DW |
1576 | "Administratively applied, for an indefinite period\n" |
1577 | "Max MED value to be used\n") | |
abc920f8 | 1578 | { |
d62a17ae | 1579 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1580 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1581 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1582 | bgp_maxmed_update(bgp); | |
abc920f8 | 1583 | |
d62a17ae | 1584 | return CMD_SUCCESS; |
abc920f8 DS |
1585 | } |
1586 | ||
abc920f8 DS |
1587 | DEFUN (bgp_maxmed_onstartup, |
1588 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1589 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1590 | BGP_STR |
1591 | "Advertise routes with max-med\n" | |
1592 | "Effective on a startup\n" | |
1593 | "Time (seconds) period for max-med\n" | |
1594 | "Max MED value to be used\n") | |
1595 | { | |
d62a17ae | 1596 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1597 | int idx = 0; | |
4668a151 | 1598 | |
d62a17ae | 1599 | argv_find(argv, argc, "(5-86400)", &idx); |
1600 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1601 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1602 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1603 | else | |
1604 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1605 | |
d62a17ae | 1606 | bgp_maxmed_update(bgp); |
abc920f8 | 1607 | |
d62a17ae | 1608 | return CMD_SUCCESS; |
abc920f8 DS |
1609 | } |
1610 | ||
1611 | DEFUN (no_bgp_maxmed_onstartup, | |
1612 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1613 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1614 | NO_STR |
1615 | BGP_STR | |
1616 | "Advertise routes with max-med\n" | |
838758ac DW |
1617 | "Effective on a startup\n" |
1618 | "Time (seconds) period for max-med\n" | |
1619 | "Max MED value to be used\n") | |
abc920f8 | 1620 | { |
d62a17ae | 1621 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1622 | |
d62a17ae | 1623 | /* Cancel max-med onstartup if its on */ |
1624 | if (bgp->t_maxmed_onstartup) { | |
1625 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1626 | bgp->maxmed_onstartup_over = 1; | |
1627 | } | |
abc920f8 | 1628 | |
d62a17ae | 1629 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1630 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1631 | |
d62a17ae | 1632 | bgp_maxmed_update(bgp); |
abc920f8 | 1633 | |
d62a17ae | 1634 | return CMD_SUCCESS; |
abc920f8 DS |
1635 | } |
1636 | ||
d62a17ae | 1637 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1638 | const char *wait) | |
f188f2c4 | 1639 | { |
d62a17ae | 1640 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1641 | uint16_t update_delay; |
1642 | uint16_t establish_wait; | |
f188f2c4 | 1643 | |
d62a17ae | 1644 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1645 | |
d62a17ae | 1646 | if (!wait) /* update-delay <delay> */ |
1647 | { | |
1648 | bgp->v_update_delay = update_delay; | |
1649 | bgp->v_establish_wait = bgp->v_update_delay; | |
1650 | return CMD_SUCCESS; | |
1651 | } | |
f188f2c4 | 1652 | |
d62a17ae | 1653 | /* update-delay <delay> <establish-wait> */ |
1654 | establish_wait = atoi(wait); | |
1655 | if (update_delay < establish_wait) { | |
1656 | vty_out(vty, | |
1657 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1658 | return CMD_WARNING_CONFIG_FAILED; | |
1659 | } | |
f188f2c4 | 1660 | |
d62a17ae | 1661 | bgp->v_update_delay = update_delay; |
1662 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1663 | |
d62a17ae | 1664 | return CMD_SUCCESS; |
f188f2c4 DS |
1665 | } |
1666 | ||
d62a17ae | 1667 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1668 | { |
d62a17ae | 1669 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1670 | |
d62a17ae | 1671 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1672 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1673 | |
d62a17ae | 1674 | return CMD_SUCCESS; |
f188f2c4 DS |
1675 | } |
1676 | ||
2b791107 | 1677 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1678 | { |
d62a17ae | 1679 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1680 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1681 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1682 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1683 | vty_out(vty, "\n"); | |
1684 | } | |
f188f2c4 DS |
1685 | } |
1686 | ||
1687 | ||
1688 | /* Update-delay configuration */ | |
1689 | DEFUN (bgp_update_delay, | |
1690 | bgp_update_delay_cmd, | |
6147e2c6 | 1691 | "update-delay (0-3600)", |
f188f2c4 DS |
1692 | "Force initial delay for best-path and updates\n" |
1693 | "Seconds\n") | |
1694 | { | |
d62a17ae | 1695 | int idx_number = 1; |
1696 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1697 | } |
1698 | ||
1699 | DEFUN (bgp_update_delay_establish_wait, | |
1700 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1701 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1702 | "Force initial delay for best-path and updates\n" |
1703 | "Seconds\n" | |
f188f2c4 DS |
1704 | "Seconds\n") |
1705 | { | |
d62a17ae | 1706 | int idx_number = 1; |
1707 | int idx_number_2 = 2; | |
1708 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1709 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1710 | } |
1711 | ||
1712 | /* Update-delay deconfiguration */ | |
1713 | DEFUN (no_bgp_update_delay, | |
1714 | no_bgp_update_delay_cmd, | |
838758ac DW |
1715 | "no update-delay [(0-3600) [(1-3600)]]", |
1716 | NO_STR | |
f188f2c4 | 1717 | "Force initial delay for best-path and updates\n" |
838758ac | 1718 | "Seconds\n" |
7111c1a0 | 1719 | "Seconds\n") |
f188f2c4 | 1720 | { |
d62a17ae | 1721 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1722 | } |
1723 | ||
5e242b0d | 1724 | |
8fa7732f QY |
1725 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1726 | bool set) | |
cb1faec9 | 1727 | { |
d62a17ae | 1728 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1729 | |
8fa7732f QY |
1730 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1731 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1732 | |
1733 | return CMD_SUCCESS; | |
1734 | } | |
1735 | ||
8fa7732f QY |
1736 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1737 | bool set) | |
555e09d4 QY |
1738 | { |
1739 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1740 | ||
8fa7732f QY |
1741 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1742 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1743 | |
d62a17ae | 1744 | return CMD_SUCCESS; |
cb1faec9 DS |
1745 | } |
1746 | ||
2b791107 | 1747 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1748 | { |
555e09d4 QY |
1749 | uint32_t quanta = |
1750 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1751 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1752 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1753 | } |
1754 | ||
555e09d4 QY |
1755 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1756 | { | |
1757 | uint32_t quanta = | |
1758 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1759 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1760 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1761 | } |
cb1faec9 | 1762 | |
8fa7732f QY |
1763 | /* Packet quanta configuration |
1764 | * | |
1765 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1766 | * thread. When changing these limits be careful to prevent stack overflow. | |
1767 | * | |
1768 | * Furthermore, the maximums used here should correspond to | |
1769 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1770 | */ | |
1771 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1772 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1773 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1774 | NO_STR |
8fa7732f | 1775 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1776 | "Number of packets\n") |
1777 | { | |
8fa7732f | 1778 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1779 | } |
1780 | ||
8fa7732f | 1781 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1782 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1783 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1784 | NO_STR |
1785 | "How many packets to read from peer socket per I/O cycle\n" | |
1786 | "Number of packets\n") | |
1787 | { | |
8fa7732f | 1788 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1789 | } |
1790 | ||
2b791107 | 1791 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1792 | { |
37a333fe | 1793 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1794 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1795 | } |
1796 | ||
1797 | ||
1798 | DEFUN (bgp_coalesce_time, | |
1799 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1800 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1801 | "Subgroup coalesce timer\n" |
1802 | "Subgroup coalesce timer value (in ms)\n") | |
1803 | { | |
d62a17ae | 1804 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1805 | |
d62a17ae | 1806 | int idx = 0; |
1807 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1808 | bgp->heuristic_coalesce = false; |
d62a17ae | 1809 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1810 | return CMD_SUCCESS; | |
3f9c7369 DS |
1811 | } |
1812 | ||
1813 | DEFUN (no_bgp_coalesce_time, | |
1814 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1815 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1816 | NO_STR |
3f9c7369 DS |
1817 | "Subgroup coalesce timer\n" |
1818 | "Subgroup coalesce timer value (in ms)\n") | |
1819 | { | |
d62a17ae | 1820 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1821 | |
37a333fe | 1822 | bgp->heuristic_coalesce = true; |
d62a17ae | 1823 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1824 | return CMD_SUCCESS; | |
3f9c7369 DS |
1825 | } |
1826 | ||
5e242b0d DS |
1827 | /* Maximum-paths configuration */ |
1828 | DEFUN (bgp_maxpaths, | |
1829 | bgp_maxpaths_cmd, | |
6319fd63 | 1830 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1831 | "Forward packets over multiple paths\n" |
1832 | "Number of paths\n") | |
1833 | { | |
d62a17ae | 1834 | int idx_number = 1; |
1835 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1836 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1837 | } |
1838 | ||
d62a17ae | 1839 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1840 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1841 | "Forward packets over multiple paths\n" | |
1842 | "Number of paths\n") | |
596c17ba | 1843 | |
165b5fff JB |
1844 | DEFUN (bgp_maxpaths_ibgp, |
1845 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1846 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1847 | "Forward packets over multiple paths\n" |
1848 | "iBGP-multipath\n" | |
1849 | "Number of paths\n") | |
1850 | { | |
d62a17ae | 1851 | int idx_number = 2; |
1852 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1853 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1854 | } |
165b5fff | 1855 | |
d62a17ae | 1856 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1857 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1858 | "Forward packets over multiple paths\n" | |
1859 | "iBGP-multipath\n" | |
1860 | "Number of paths\n") | |
596c17ba | 1861 | |
5e242b0d DS |
1862 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1863 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1864 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1865 | "Forward packets over multiple paths\n" |
1866 | "iBGP-multipath\n" | |
1867 | "Number of paths\n" | |
1868 | "Match the cluster length\n") | |
1869 | { | |
d62a17ae | 1870 | int idx_number = 2; |
1871 | return bgp_maxpaths_config_vty( | |
1872 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1873 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1874 | } |
1875 | ||
d62a17ae | 1876 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1877 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1878 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1879 | "Forward packets over multiple paths\n" | |
1880 | "iBGP-multipath\n" | |
1881 | "Number of paths\n" | |
1882 | "Match the cluster length\n") | |
596c17ba | 1883 | |
165b5fff JB |
1884 | DEFUN (no_bgp_maxpaths, |
1885 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1886 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1887 | NO_STR |
1888 | "Forward packets over multiple paths\n" | |
1889 | "Number of paths\n") | |
1890 | { | |
d62a17ae | 1891 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1892 | } |
1893 | ||
d62a17ae | 1894 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1895 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1896 | "Forward packets over multiple paths\n" |
1897 | "Number of paths\n") | |
596c17ba | 1898 | |
165b5fff JB |
1899 | DEFUN (no_bgp_maxpaths_ibgp, |
1900 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1901 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1902 | NO_STR |
1903 | "Forward packets over multiple paths\n" | |
1904 | "iBGP-multipath\n" | |
838758ac DW |
1905 | "Number of paths\n" |
1906 | "Match the cluster length\n") | |
165b5fff | 1907 | { |
d62a17ae | 1908 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1909 | } |
1910 | ||
d62a17ae | 1911 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1912 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1913 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1914 | NO_STR | |
1915 | "Forward packets over multiple paths\n" | |
1916 | "iBGP-multipath\n" | |
1917 | "Number of paths\n" | |
1918 | "Match the cluster length\n") | |
596c17ba | 1919 | |
dd65f45e DL |
1920 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1921 | afi_t afi, safi_t safi) | |
165b5fff | 1922 | { |
d62a17ae | 1923 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1924 | vty_out(vty, " maximum-paths %d\n", |
1925 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1926 | } | |
165b5fff | 1927 | |
d62a17ae | 1928 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1929 | vty_out(vty, " maximum-paths ibgp %d", |
1930 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1931 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1932 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1933 | vty_out(vty, " equal-cluster-length"); | |
1934 | vty_out(vty, "\n"); | |
1935 | } | |
165b5fff | 1936 | } |
6b0655a2 | 1937 | |
718e3744 | 1938 | /* BGP timers. */ |
1939 | ||
1940 | DEFUN (bgp_timers, | |
1941 | bgp_timers_cmd, | |
6147e2c6 | 1942 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1943 | "Adjust routing timers\n" |
1944 | "BGP timers\n" | |
1945 | "Keepalive interval\n" | |
1946 | "Holdtime\n") | |
1947 | { | |
d62a17ae | 1948 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1949 | int idx_number = 2; | |
1950 | int idx_number_2 = 3; | |
1951 | unsigned long keepalive = 0; | |
1952 | unsigned long holdtime = 0; | |
718e3744 | 1953 | |
d62a17ae | 1954 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1955 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1956 | |
d62a17ae | 1957 | /* Holdtime value check. */ |
1958 | if (holdtime < 3 && holdtime != 0) { | |
1959 | vty_out(vty, | |
1960 | "%% hold time value must be either 0 or greater than 3\n"); | |
1961 | return CMD_WARNING_CONFIG_FAILED; | |
1962 | } | |
718e3744 | 1963 | |
5d5393b9 | 1964 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1965 | |
d62a17ae | 1966 | return CMD_SUCCESS; |
718e3744 | 1967 | } |
1968 | ||
1969 | DEFUN (no_bgp_timers, | |
1970 | no_bgp_timers_cmd, | |
838758ac | 1971 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1972 | NO_STR |
1973 | "Adjust routing timers\n" | |
838758ac DW |
1974 | "BGP timers\n" |
1975 | "Keepalive interval\n" | |
1976 | "Holdtime\n") | |
718e3744 | 1977 | { |
d62a17ae | 1978 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1979 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1980 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1981 | |
d62a17ae | 1982 | return CMD_SUCCESS; |
718e3744 | 1983 | } |
1984 | ||
6b0655a2 | 1985 | |
718e3744 | 1986 | DEFUN (bgp_client_to_client_reflection, |
1987 | bgp_client_to_client_reflection_cmd, | |
1988 | "bgp client-to-client reflection", | |
1989 | "BGP specific commands\n" | |
1990 | "Configure client to client route reflection\n" | |
1991 | "reflection of routes allowed\n") | |
1992 | { | |
d62a17ae | 1993 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 1994 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 1995 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 1996 | |
d62a17ae | 1997 | return CMD_SUCCESS; |
718e3744 | 1998 | } |
1999 | ||
2000 | DEFUN (no_bgp_client_to_client_reflection, | |
2001 | no_bgp_client_to_client_reflection_cmd, | |
2002 | "no bgp client-to-client reflection", | |
2003 | NO_STR | |
2004 | "BGP specific commands\n" | |
2005 | "Configure client to client route reflection\n" | |
2006 | "reflection of routes allowed\n") | |
2007 | { | |
d62a17ae | 2008 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2009 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 2010 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 2011 | |
d62a17ae | 2012 | return CMD_SUCCESS; |
718e3744 | 2013 | } |
2014 | ||
2015 | /* "bgp always-compare-med" configuration. */ | |
2016 | DEFUN (bgp_always_compare_med, | |
2017 | bgp_always_compare_med_cmd, | |
2018 | "bgp always-compare-med", | |
2019 | "BGP specific commands\n" | |
2020 | "Allow comparing MED from different neighbors\n") | |
2021 | { | |
d62a17ae | 2022 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2023 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2024 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2025 | |
d62a17ae | 2026 | return CMD_SUCCESS; |
718e3744 | 2027 | } |
2028 | ||
2029 | DEFUN (no_bgp_always_compare_med, | |
2030 | no_bgp_always_compare_med_cmd, | |
2031 | "no bgp always-compare-med", | |
2032 | NO_STR | |
2033 | "BGP specific commands\n" | |
2034 | "Allow comparing MED from different neighbors\n") | |
2035 | { | |
d62a17ae | 2036 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2037 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2038 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2039 | |
d62a17ae | 2040 | return CMD_SUCCESS; |
718e3744 | 2041 | } |
6b0655a2 | 2042 | |
9dac9fc8 DA |
2043 | |
2044 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2045 | "bgp ebgp-requires-policy", | |
2046 | "BGP specific commands\n" | |
2047 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2048 | { | |
2049 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1d3fdccf | 2050 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); |
9dac9fc8 DA |
2051 | return CMD_SUCCESS; |
2052 | } | |
2053 | ||
2054 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2055 | "no bgp ebgp-requires-policy", | |
2056 | NO_STR | |
2057 | "BGP specific commands\n" | |
2058 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2059 | { | |
2060 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1d3fdccf | 2061 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); |
9dac9fc8 DA |
2062 | return CMD_SUCCESS; |
2063 | } | |
2064 | ||
fb29348a DA |
2065 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2066 | "bgp reject-as-sets", | |
2067 | "BGP specific commands\n" | |
2068 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2069 | { | |
2070 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2071 | struct listnode *node, *nnode; | |
2072 | struct peer *peer; | |
2073 | ||
7f972cd8 | 2074 | bgp->reject_as_sets = true; |
fb29348a DA |
2075 | |
2076 | /* Reset existing BGP sessions to reject routes | |
2077 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2078 | */ | |
2079 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2080 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2081 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2082 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2083 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2084 | } | |
2085 | } | |
2086 | ||
2087 | return CMD_SUCCESS; | |
2088 | } | |
2089 | ||
2090 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2091 | "no bgp reject-as-sets", | |
2092 | NO_STR | |
2093 | "BGP specific commands\n" | |
2094 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2095 | { | |
2096 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2097 | struct listnode *node, *nnode; | |
2098 | struct peer *peer; | |
2099 | ||
7f972cd8 | 2100 | bgp->reject_as_sets = false; |
fb29348a DA |
2101 | |
2102 | /* Reset existing BGP sessions to reject routes | |
2103 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2104 | */ | |
2105 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2106 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2107 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2108 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2109 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2110 | } | |
2111 | } | |
2112 | ||
2113 | return CMD_SUCCESS; | |
2114 | } | |
9dac9fc8 | 2115 | |
718e3744 | 2116 | /* "bgp deterministic-med" configuration. */ |
2117 | DEFUN (bgp_deterministic_med, | |
2118 | bgp_deterministic_med_cmd, | |
2119 | "bgp deterministic-med", | |
2120 | "BGP specific commands\n" | |
2121 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2122 | { | |
d62a17ae | 2123 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2124 | |
892fedb6 DA |
2125 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
2126 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
d62a17ae | 2127 | bgp_recalculate_all_bestpaths(bgp); |
2128 | } | |
7aafcaca | 2129 | |
d62a17ae | 2130 | return CMD_SUCCESS; |
718e3744 | 2131 | } |
2132 | ||
2133 | DEFUN (no_bgp_deterministic_med, | |
2134 | no_bgp_deterministic_med_cmd, | |
2135 | "no bgp deterministic-med", | |
2136 | NO_STR | |
2137 | "BGP specific commands\n" | |
2138 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2139 | { | |
d62a17ae | 2140 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2141 | int bestpath_per_as_used; | |
2142 | afi_t afi; | |
2143 | safi_t safi; | |
2144 | struct peer *peer; | |
2145 | struct listnode *node, *nnode; | |
2146 | ||
892fedb6 | 2147 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
d62a17ae | 2148 | bestpath_per_as_used = 0; |
2149 | ||
2150 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2151 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2152 | if (bgp_addpath_dmed_required( |
2153 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2154 | bestpath_per_as_used = 1; |
2155 | break; | |
2156 | } | |
d62a17ae | 2157 | |
2158 | if (bestpath_per_as_used) | |
2159 | break; | |
2160 | } | |
2161 | ||
2162 | if (bestpath_per_as_used) { | |
2163 | vty_out(vty, | |
2164 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2165 | return CMD_WARNING_CONFIG_FAILED; | |
2166 | } else { | |
892fedb6 | 2167 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); |
d62a17ae | 2168 | bgp_recalculate_all_bestpaths(bgp); |
2169 | } | |
2170 | } | |
2171 | ||
2172 | return CMD_SUCCESS; | |
718e3744 | 2173 | } |
538621f2 | 2174 | |
055679e9 | 2175 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2176 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2177 | bgp_graceful_restart_cmd, |
2178 | "bgp graceful-restart", | |
2179 | "BGP specific commands\n" | |
2180 | GR_CMD | |
055679e9 | 2181 | ) |
538621f2 | 2182 | { |
055679e9 | 2183 | int ret = BGP_GR_FAILURE; |
2184 | ||
2185 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2186 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2187 | |
d62a17ae | 2188 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2189 | |
2190 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2191 | ||
36235319 QY |
2192 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2193 | ret); | |
5cce3f05 | 2194 | |
055679e9 | 2195 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2196 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2197 | vty_out(vty, |
2198 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2199 | return bgp_vty_return(vty, ret); |
538621f2 | 2200 | } |
2201 | ||
2202 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2203 | no_bgp_graceful_restart_cmd, |
2204 | "no bgp graceful-restart", | |
2205 | NO_STR | |
2206 | "BGP specific commands\n" | |
2207 | NO_GR_CMD | |
055679e9 | 2208 | ) |
538621f2 | 2209 | { |
d62a17ae | 2210 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2211 | |
2212 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2213 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2214 | |
2215 | int ret = BGP_GR_FAILURE; | |
2216 | ||
2217 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2218 | ||
36235319 QY |
2219 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2220 | ret); | |
5cce3f05 | 2221 | |
055679e9 | 2222 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2223 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2224 | vty_out(vty, |
2225 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2226 | |
2227 | return bgp_vty_return(vty, ret); | |
538621f2 | 2228 | } |
2229 | ||
93406d87 | 2230 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2231 | bgp_graceful_restart_stalepath_time_cmd, |
2232 | "bgp graceful-restart stalepath-time (1-4095)", | |
2233 | "BGP specific commands\n" | |
2234 | "Graceful restart capability parameters\n" | |
2235 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2236 | "Delay value (seconds)\n") | |
93406d87 | 2237 | { |
d62a17ae | 2238 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2239 | int idx_number = 3; | |
d7c0a89a | 2240 | uint32_t stalepath; |
93406d87 | 2241 | |
d62a17ae | 2242 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2243 | bgp->stalepath_time = stalepath; | |
2244 | return CMD_SUCCESS; | |
93406d87 | 2245 | } |
2246 | ||
eb6f1b41 | 2247 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2248 | bgp_graceful_restart_restart_time_cmd, |
2249 | "bgp graceful-restart restart-time (1-4095)", | |
2250 | "BGP specific commands\n" | |
2251 | "Graceful restart capability parameters\n" | |
2252 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2253 | "Delay value (seconds)\n") | |
eb6f1b41 | 2254 | { |
d62a17ae | 2255 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2256 | int idx_number = 3; | |
d7c0a89a | 2257 | uint32_t restart; |
eb6f1b41 | 2258 | |
d62a17ae | 2259 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2260 | bgp->restart_time = restart; | |
2261 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2262 | } |
2263 | ||
cfd47646 | 2264 | DEFUN (bgp_graceful_restart_select_defer_time, |
2265 | bgp_graceful_restart_select_defer_time_cmd, | |
2266 | "bgp graceful-restart select-defer-time (0-3600)", | |
2267 | "BGP specific commands\n" | |
2268 | "Graceful restart capability parameters\n" | |
2269 | "Set the time to defer the BGP route selection after restart\n" | |
2270 | "Delay value (seconds, 0 - disable)\n") | |
2271 | { | |
2272 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2273 | int idx_number = 3; | |
2274 | uint32_t defer_time; | |
2275 | ||
2276 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2277 | bgp->select_defer_time = defer_time; | |
2278 | if (defer_time == 0) | |
892fedb6 | 2279 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2280 | else |
892fedb6 | 2281 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2282 | |
2283 | return CMD_SUCCESS; | |
2284 | } | |
2285 | ||
93406d87 | 2286 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2287 | no_bgp_graceful_restart_stalepath_time_cmd, |
2288 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2289 | NO_STR | |
2290 | "BGP specific commands\n" | |
2291 | "Graceful restart capability parameters\n" | |
2292 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2293 | "Delay value (seconds)\n") | |
93406d87 | 2294 | { |
d62a17ae | 2295 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2296 | |
d62a17ae | 2297 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2298 | return CMD_SUCCESS; | |
93406d87 | 2299 | } |
2300 | ||
eb6f1b41 | 2301 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2302 | no_bgp_graceful_restart_restart_time_cmd, |
2303 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2304 | NO_STR | |
2305 | "BGP specific commands\n" | |
2306 | "Graceful restart capability parameters\n" | |
2307 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2308 | "Delay value (seconds)\n") | |
eb6f1b41 | 2309 | { |
d62a17ae | 2310 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2311 | |
d62a17ae | 2312 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2313 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2314 | } |
2315 | ||
cfd47646 | 2316 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2317 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2318 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2319 | NO_STR | |
2320 | "BGP specific commands\n" | |
2321 | "Graceful restart capability parameters\n" | |
2322 | "Set the time to defer the BGP route selection after restart\n" | |
2323 | "Delay value (seconds)\n") | |
2324 | { | |
2325 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2326 | ||
2327 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2328 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2329 | |
2330 | return CMD_SUCCESS; | |
2331 | } | |
2332 | ||
43fc21b3 | 2333 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2334 | bgp_graceful_restart_preserve_fw_cmd, |
2335 | "bgp graceful-restart preserve-fw-state", | |
2336 | "BGP specific commands\n" | |
2337 | "Graceful restart capability parameters\n" | |
2338 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2339 | { |
d62a17ae | 2340 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2341 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2342 | return CMD_SUCCESS; |
43fc21b3 JC |
2343 | } |
2344 | ||
2345 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2346 | no_bgp_graceful_restart_preserve_fw_cmd, |
2347 | "no bgp graceful-restart preserve-fw-state", | |
2348 | NO_STR | |
2349 | "BGP specific commands\n" | |
2350 | "Graceful restart capability parameters\n" | |
2351 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2352 | { |
d62a17ae | 2353 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2354 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2355 | return CMD_SUCCESS; |
43fc21b3 JC |
2356 | } |
2357 | ||
055679e9 | 2358 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2359 | bgp_graceful_restart_disable_cmd, |
2360 | "bgp graceful-restart-disable", | |
2361 | "BGP specific commands\n" | |
2362 | GR_DISABLE) | |
055679e9 | 2363 | { |
2364 | int ret = BGP_GR_FAILURE; | |
2365 | ||
2366 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2367 | zlog_debug( | |
2ba1fe69 | 2368 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2369 | |
055679e9 | 2370 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2371 | ||
2372 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2373 | ||
dc95985f | 2374 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2375 | bgp->peer, ret); | |
5cce3f05 | 2376 | |
055679e9 | 2377 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2378 | zlog_debug( | |
2ba1fe69 | 2379 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2380 | vty_out(vty, |
2381 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2382 | ||
055679e9 | 2383 | return bgp_vty_return(vty, ret); |
2384 | } | |
2385 | ||
2386 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2387 | no_bgp_graceful_restart_disable_cmd, |
2388 | "no bgp graceful-restart-disable", | |
2389 | NO_STR | |
2390 | "BGP specific commands\n" | |
2391 | NO_GR_DISABLE | |
055679e9 | 2392 | ) |
2393 | { | |
2394 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2395 | ||
2396 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2397 | zlog_debug( | |
2ba1fe69 | 2398 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2399 | |
2400 | int ret = BGP_GR_FAILURE; | |
2401 | ||
2402 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2403 | ||
36235319 QY |
2404 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2405 | ret); | |
5cce3f05 | 2406 | |
055679e9 | 2407 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2408 | zlog_debug( | |
2ba1fe69 | 2409 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2410 | vty_out(vty, |
2411 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2412 | |
2413 | return bgp_vty_return(vty, ret); | |
2414 | } | |
2415 | ||
2416 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2417 | bgp_neighbor_graceful_restart_set_cmd, |
2418 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2419 | NEIGHBOR_STR | |
2420 | NEIGHBOR_ADDR_STR2 | |
2421 | GR_NEIGHBOR_CMD | |
055679e9 | 2422 | ) |
2423 | { | |
2424 | int idx_peer = 1; | |
2425 | struct peer *peer; | |
2426 | int ret = BGP_GR_FAILURE; | |
2427 | ||
dc95985f | 2428 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2429 | ||
055679e9 | 2430 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2431 | zlog_debug( | |
2ba1fe69 | 2432 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2433 | |
055679e9 | 2434 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2435 | if (!peer) | |
2436 | return CMD_WARNING_CONFIG_FAILED; | |
2437 | ||
2438 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2439 | ||
dc95985f | 2440 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2441 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2442 | |
2443 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2444 | zlog_debug( | |
2ba1fe69 | 2445 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2446 | vty_out(vty, |
2447 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2448 | |
2449 | return bgp_vty_return(vty, ret); | |
2450 | } | |
2451 | ||
2452 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2453 | no_bgp_neighbor_graceful_restart_set_cmd, |
2454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2455 | NO_STR | |
2456 | NEIGHBOR_STR | |
2457 | NEIGHBOR_ADDR_STR2 | |
2458 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2459 | ) |
2460 | { | |
2461 | int idx_peer = 2; | |
2462 | int ret = BGP_GR_FAILURE; | |
2463 | struct peer *peer; | |
2464 | ||
dc95985f | 2465 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2466 | ||
055679e9 | 2467 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2468 | if (!peer) | |
2469 | return CMD_WARNING_CONFIG_FAILED; | |
2470 | ||
2471 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2472 | zlog_debug( | |
2ba1fe69 | 2473 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2474 | |
2475 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2476 | ||
dc95985f | 2477 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2478 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2479 | |
2480 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2481 | zlog_debug( | |
2ba1fe69 | 2482 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2483 | vty_out(vty, |
2484 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2485 | |
2486 | return bgp_vty_return(vty, ret); | |
2487 | } | |
2488 | ||
2489 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2490 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2491 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2492 | NEIGHBOR_STR | |
2493 | NEIGHBOR_ADDR_STR2 | |
2494 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2495 | ) |
2496 | { | |
2497 | int idx_peer = 1; | |
2498 | struct peer *peer; | |
2499 | int ret = BGP_GR_FAILURE; | |
2500 | ||
dc95985f | 2501 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2502 | ||
055679e9 | 2503 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2504 | zlog_debug( | |
2ba1fe69 | 2505 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2506 | |
055679e9 | 2507 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2508 | ||
055679e9 | 2509 | if (!peer) |
2510 | return CMD_WARNING_CONFIG_FAILED; | |
2511 | ||
2512 | ||
2513 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2514 | |
dc95985f | 2515 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2516 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2517 | |
055679e9 | 2518 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2519 | zlog_debug( | |
2ba1fe69 | 2520 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2521 | vty_out(vty, |
2522 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2523 | |
2524 | return bgp_vty_return(vty, ret); | |
2525 | } | |
2526 | ||
2527 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2528 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2529 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2530 | NO_STR | |
2531 | NEIGHBOR_STR | |
2532 | NEIGHBOR_ADDR_STR2 | |
2533 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2534 | ) |
2535 | { | |
2536 | int idx_peer = 2; | |
2537 | int ret = BGP_GR_FAILURE; | |
2538 | struct peer *peer; | |
2539 | ||
dc95985f | 2540 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2541 | ||
055679e9 | 2542 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2543 | if (!peer) | |
2544 | return CMD_WARNING_CONFIG_FAILED; | |
2545 | ||
2546 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2547 | zlog_debug( | |
2ba1fe69 | 2548 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2549 | |
36235319 | 2550 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2551 | |
dc95985f | 2552 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2553 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2554 | |
2555 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2556 | zlog_debug( | |
2ba1fe69 | 2557 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2558 | vty_out(vty, |
2559 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2560 | |
2561 | return bgp_vty_return(vty, ret); | |
2562 | } | |
2563 | ||
2564 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2565 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2566 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2567 | NEIGHBOR_STR | |
2568 | NEIGHBOR_ADDR_STR2 | |
2569 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2570 | ) |
2571 | { | |
2572 | int idx_peer = 1; | |
2573 | struct peer *peer; | |
2574 | int ret = BGP_GR_FAILURE; | |
2575 | ||
dc95985f | 2576 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2577 | ||
055679e9 | 2578 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2579 | zlog_debug( | |
2ba1fe69 | 2580 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2581 | |
2582 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2583 | if (!peer) | |
2584 | return CMD_WARNING_CONFIG_FAILED; | |
2585 | ||
36235319 | 2586 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2587 | |
2588 | if (peer->bgp->t_startup) | |
2589 | bgp_peer_gr_flags_update(peer); | |
2590 | ||
dc95985f | 2591 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2592 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2593 | ||
055679e9 | 2594 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2595 | zlog_debug( | |
2ba1fe69 | 2596 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2597 | vty_out(vty, |
2598 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2599 | |
2600 | return bgp_vty_return(vty, ret); | |
2601 | } | |
2602 | ||
2603 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2604 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2605 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2606 | NO_STR | |
2607 | NEIGHBOR_STR | |
2608 | NEIGHBOR_ADDR_STR2 | |
2609 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2610 | ) |
2611 | { | |
2612 | int idx_peer = 2; | |
2613 | int ret = BGP_GR_FAILURE; | |
2614 | struct peer *peer; | |
2615 | ||
dc95985f | 2616 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2617 | ||
055679e9 | 2618 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2619 | if (!peer) | |
2620 | return CMD_WARNING_CONFIG_FAILED; | |
2621 | ||
2622 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2623 | zlog_debug( | |
2ba1fe69 | 2624 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2625 | |
2626 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2627 | ||
dc95985f | 2628 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2629 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2630 | |
2631 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2632 | zlog_debug( | |
2ba1fe69 | 2633 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2634 | vty_out(vty, |
2635 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2636 | |
2637 | return bgp_vty_return(vty, ret); | |
2638 | } | |
2639 | ||
d6e3c15b | 2640 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2641 | bgp_graceful_restart_disable_eor_cmd, | |
2642 | "bgp graceful-restart disable-eor", | |
2643 | "BGP specific commands\n" | |
2644 | "Graceful restart configuration parameters\n" | |
2645 | "Disable EOR Check\n") | |
2646 | { | |
2647 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2648 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2649 | |
d6e3c15b | 2650 | return CMD_SUCCESS; |
2651 | } | |
2652 | ||
2653 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2654 | no_bgp_graceful_restart_disable_eor_cmd, | |
2655 | "no bgp graceful-restart disable-eor", | |
2656 | NO_STR | |
2657 | "BGP specific commands\n" | |
2658 | "Graceful restart configuration parameters\n" | |
2659 | "Disable EOR Check\n") | |
2660 | { | |
2661 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2662 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2663 | |
2664 | return CMD_SUCCESS; | |
2665 | } | |
2666 | ||
2667 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2668 | bgp_graceful_restart_rib_stale_time_cmd, | |
2669 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2670 | "BGP specific commands\n" | |
2671 | "Graceful restart configuration parameters\n" | |
2672 | "Specify the stale route removal timer in rib\n" | |
2673 | "Delay value (seconds)\n") | |
2674 | { | |
2675 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2676 | int idx_number = 3; | |
2677 | uint32_t stale_time; | |
2678 | ||
2679 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2680 | bgp->rib_stale_time = stale_time; | |
2681 | /* Send the stale timer update message to RIB */ | |
2682 | if (bgp_zebra_stale_timer_update(bgp)) | |
2683 | return CMD_WARNING; | |
2684 | ||
2685 | return CMD_SUCCESS; | |
2686 | } | |
2687 | ||
2688 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2689 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2690 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2691 | NO_STR | |
2692 | "BGP specific commands\n" | |
2693 | "Graceful restart configuration parameters\n" | |
2694 | "Specify the stale route removal timer in rib\n" | |
2695 | "Delay value (seconds)\n") | |
2696 | { | |
2697 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2698 | ||
2699 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2700 | /* Send the stale timer update message to RIB */ | |
2701 | if (bgp_zebra_stale_timer_update(bgp)) | |
2702 | return CMD_WARNING; | |
2703 | ||
d6e3c15b | 2704 | return CMD_SUCCESS; |
2705 | } | |
2706 | ||
7f323236 DW |
2707 | /* "bgp graceful-shutdown" configuration */ |
2708 | DEFUN (bgp_graceful_shutdown, | |
2709 | bgp_graceful_shutdown_cmd, | |
2710 | "bgp graceful-shutdown", | |
2711 | BGP_STR | |
2712 | "Graceful shutdown parameters\n") | |
2713 | { | |
2714 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2715 | ||
892fedb6 DA |
2716 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2717 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2718 | bgp_static_redo_import_check(bgp); |
2719 | bgp_redistribute_redo(bgp); | |
2720 | bgp_clear_star_soft_out(vty, bgp->name); | |
2721 | bgp_clear_star_soft_in(vty, bgp->name); | |
2722 | } | |
2723 | ||
2724 | return CMD_SUCCESS; | |
2725 | } | |
2726 | ||
2727 | DEFUN (no_bgp_graceful_shutdown, | |
2728 | no_bgp_graceful_shutdown_cmd, | |
2729 | "no bgp graceful-shutdown", | |
2730 | NO_STR | |
2731 | BGP_STR | |
2732 | "Graceful shutdown parameters\n") | |
2733 | { | |
2734 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2735 | ||
892fedb6 DA |
2736 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2737 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2738 | bgp_static_redo_import_check(bgp); |
2739 | bgp_redistribute_redo(bgp); | |
2740 | bgp_clear_star_soft_out(vty, bgp->name); | |
2741 | bgp_clear_star_soft_in(vty, bgp->name); | |
2742 | } | |
2743 | ||
2744 | return CMD_SUCCESS; | |
2745 | } | |
2746 | ||
718e3744 | 2747 | /* "bgp fast-external-failover" configuration. */ |
2748 | DEFUN (bgp_fast_external_failover, | |
2749 | bgp_fast_external_failover_cmd, | |
2750 | "bgp fast-external-failover", | |
2751 | BGP_STR | |
2752 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2753 | { | |
d62a17ae | 2754 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2755 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2756 | return CMD_SUCCESS; |
718e3744 | 2757 | } |
2758 | ||
2759 | DEFUN (no_bgp_fast_external_failover, | |
2760 | no_bgp_fast_external_failover_cmd, | |
2761 | "no bgp fast-external-failover", | |
2762 | NO_STR | |
2763 | BGP_STR | |
2764 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2765 | { | |
d62a17ae | 2766 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2767 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2768 | return CMD_SUCCESS; |
718e3744 | 2769 | } |
6b0655a2 | 2770 | |
718e3744 | 2771 | /* "bgp bestpath compare-routerid" configuration. */ |
2772 | DEFUN (bgp_bestpath_compare_router_id, | |
2773 | bgp_bestpath_compare_router_id_cmd, | |
2774 | "bgp bestpath compare-routerid", | |
2775 | "BGP specific commands\n" | |
2776 | "Change the default bestpath selection\n" | |
2777 | "Compare router-id for identical EBGP paths\n") | |
2778 | { | |
d62a17ae | 2779 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2780 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2781 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2782 | |
d62a17ae | 2783 | return CMD_SUCCESS; |
718e3744 | 2784 | } |
2785 | ||
2786 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2787 | no_bgp_bestpath_compare_router_id_cmd, | |
2788 | "no bgp bestpath compare-routerid", | |
2789 | NO_STR | |
2790 | "BGP specific commands\n" | |
2791 | "Change the default bestpath selection\n" | |
2792 | "Compare router-id for identical EBGP paths\n") | |
2793 | { | |
d62a17ae | 2794 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2795 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2796 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2797 | |
d62a17ae | 2798 | return CMD_SUCCESS; |
718e3744 | 2799 | } |
6b0655a2 | 2800 | |
718e3744 | 2801 | /* "bgp bestpath as-path ignore" configuration. */ |
2802 | DEFUN (bgp_bestpath_aspath_ignore, | |
2803 | bgp_bestpath_aspath_ignore_cmd, | |
2804 | "bgp bestpath as-path ignore", | |
2805 | "BGP specific commands\n" | |
2806 | "Change the default bestpath selection\n" | |
2807 | "AS-path attribute\n" | |
2808 | "Ignore as-path length in selecting a route\n") | |
2809 | { | |
d62a17ae | 2810 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2811 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2812 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2813 | |
d62a17ae | 2814 | return CMD_SUCCESS; |
718e3744 | 2815 | } |
2816 | ||
2817 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2818 | no_bgp_bestpath_aspath_ignore_cmd, | |
2819 | "no bgp bestpath as-path ignore", | |
2820 | NO_STR | |
2821 | "BGP specific commands\n" | |
2822 | "Change the default bestpath selection\n" | |
2823 | "AS-path attribute\n" | |
2824 | "Ignore as-path length in selecting a route\n") | |
2825 | { | |
d62a17ae | 2826 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2827 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2828 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2829 | |
d62a17ae | 2830 | return CMD_SUCCESS; |
718e3744 | 2831 | } |
6b0655a2 | 2832 | |
6811845b | 2833 | /* "bgp bestpath as-path confed" configuration. */ |
2834 | DEFUN (bgp_bestpath_aspath_confed, | |
2835 | bgp_bestpath_aspath_confed_cmd, | |
2836 | "bgp bestpath as-path confed", | |
2837 | "BGP specific commands\n" | |
2838 | "Change the default bestpath selection\n" | |
2839 | "AS-path attribute\n" | |
2840 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2841 | { | |
d62a17ae | 2842 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2843 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2844 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2845 | |
d62a17ae | 2846 | return CMD_SUCCESS; |
6811845b | 2847 | } |
2848 | ||
2849 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2850 | no_bgp_bestpath_aspath_confed_cmd, | |
2851 | "no bgp bestpath as-path confed", | |
2852 | NO_STR | |
2853 | "BGP specific commands\n" | |
2854 | "Change the default bestpath selection\n" | |
2855 | "AS-path attribute\n" | |
2856 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2857 | { | |
d62a17ae | 2858 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2859 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2860 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2861 | |
d62a17ae | 2862 | return CMD_SUCCESS; |
6811845b | 2863 | } |
6b0655a2 | 2864 | |
2fdd455c PM |
2865 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2866 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2867 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2868 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2869 | "BGP specific commands\n" |
2870 | "Change the default bestpath selection\n" | |
2871 | "AS-path attribute\n" | |
2872 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2873 | "Generate an AS_SET\n" |
16fc1eec DS |
2874 | "Do not generate an AS_SET\n") |
2875 | { | |
d62a17ae | 2876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2877 | int idx = 0; | |
892fedb6 | 2878 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2879 | |
d62a17ae | 2880 | /* no-as-set is now the default behavior so we can silently |
2881 | * ignore it */ | |
2882 | if (argv_find(argv, argc, "as-set", &idx)) | |
892fedb6 | 2883 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 2884 | else |
892fedb6 | 2885 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
219178b6 | 2886 | |
d62a17ae | 2887 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2888 | |
d62a17ae | 2889 | return CMD_SUCCESS; |
16fc1eec DS |
2890 | } |
2891 | ||
219178b6 DW |
2892 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2893 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2894 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2895 | NO_STR |
2896 | "BGP specific commands\n" | |
2897 | "Change the default bestpath selection\n" | |
2898 | "AS-path attribute\n" | |
2899 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2900 | "Generate an AS_SET\n" |
16fc1eec DS |
2901 | "Do not generate an AS_SET\n") |
2902 | { | |
d62a17ae | 2903 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
2904 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
2905 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
d62a17ae | 2906 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2907 | |
d62a17ae | 2908 | return CMD_SUCCESS; |
2fdd455c | 2909 | } |
6b0655a2 | 2910 | |
848973c7 | 2911 | /* "bgp log-neighbor-changes" configuration. */ |
2912 | DEFUN (bgp_log_neighbor_changes, | |
2913 | bgp_log_neighbor_changes_cmd, | |
2914 | "bgp log-neighbor-changes", | |
2915 | "BGP specific commands\n" | |
2916 | "Log neighbor up/down and reset reason\n") | |
2917 | { | |
d62a17ae | 2918 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2919 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2920 | return CMD_SUCCESS; |
848973c7 | 2921 | } |
2922 | ||
2923 | DEFUN (no_bgp_log_neighbor_changes, | |
2924 | no_bgp_log_neighbor_changes_cmd, | |
2925 | "no bgp log-neighbor-changes", | |
2926 | NO_STR | |
2927 | "BGP specific commands\n" | |
2928 | "Log neighbor up/down and reset reason\n") | |
2929 | { | |
d62a17ae | 2930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2931 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2932 | return CMD_SUCCESS; |
848973c7 | 2933 | } |
6b0655a2 | 2934 | |
718e3744 | 2935 | /* "bgp bestpath med" configuration. */ |
2936 | DEFUN (bgp_bestpath_med, | |
2937 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2938 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2939 | "BGP specific commands\n" |
2940 | "Change the default bestpath selection\n" | |
2941 | "MED attribute\n" | |
2942 | "Compare MED among confederation paths\n" | |
838758ac DW |
2943 | "Treat missing MED as the least preferred one\n" |
2944 | "Treat missing MED as the least preferred one\n" | |
2945 | "Compare MED among confederation paths\n") | |
718e3744 | 2946 | { |
d62a17ae | 2947 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2948 | |
d62a17ae | 2949 | int idx = 0; |
2950 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2951 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2952 | idx = 0; |
2953 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2954 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 2955 | |
d62a17ae | 2956 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2957 | |
d62a17ae | 2958 | return CMD_SUCCESS; |
718e3744 | 2959 | } |
2960 | ||
718e3744 | 2961 | DEFUN (no_bgp_bestpath_med, |
2962 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2963 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2964 | NO_STR |
2965 | "BGP specific commands\n" | |
2966 | "Change the default bestpath selection\n" | |
2967 | "MED attribute\n" | |
2968 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2969 | "Treat missing MED as the least preferred one\n" |
2970 | "Treat missing MED as the least preferred one\n" | |
2971 | "Compare MED among confederation paths\n") | |
718e3744 | 2972 | { |
d62a17ae | 2973 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2974 | |
d62a17ae | 2975 | int idx = 0; |
2976 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2977 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2978 | idx = 0; |
2979 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2980 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
718e3744 | 2981 | |
d62a17ae | 2982 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2983 | |
d62a17ae | 2984 | return CMD_SUCCESS; |
718e3744 | 2985 | } |
2986 | ||
f7e1c681 | 2987 | /* "bgp bestpath bandwidth" configuration. */ |
2988 | DEFPY (bgp_bestpath_bw, | |
2989 | bgp_bestpath_bw_cmd, | |
ad36d216 | 2990 | "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg", |
f7e1c681 | 2991 | "BGP specific commands\n" |
2992 | "Change the default bestpath selection\n" | |
2993 | "Link Bandwidth attribute\n" | |
2994 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
2995 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
2996 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
2997 | { | |
2998 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2999 | afi_t afi; | |
3000 | safi_t safi; | |
3001 | ||
ad36d216 DS |
3002 | if (!bw_cfg) { |
3003 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3004 | return CMD_ERR_INCOMPLETE; | |
f7e1c681 | 3005 | } |
ad36d216 DS |
3006 | if (!strcmp(bw_cfg, "ignore")) |
3007 | bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; | |
3008 | else if (!strcmp(bw_cfg, "skip-missing")) | |
3009 | bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; | |
3010 | else if (!strcmp(bw_cfg, "default-weight-for-missing")) | |
3011 | bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; | |
3012 | else | |
3013 | return CMD_ERR_NO_MATCH; | |
f7e1c681 | 3014 | |
3015 | /* This config is used in route install, so redo that. */ | |
3016 | FOREACH_AFI_SAFI (afi, safi) { | |
3017 | if (!bgp_fibupd_safi(safi)) | |
3018 | continue; | |
3019 | bgp_zebra_announce_table(bgp, afi, safi); | |
3020 | } | |
3021 | ||
3022 | return CMD_SUCCESS; | |
3023 | } | |
3024 | ||
ad36d216 DS |
3025 | DEFPY (no_bgp_bestpath_bw, |
3026 | no_bgp_bestpath_bw_cmd, | |
3027 | "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
3028 | NO_STR | |
3029 | "BGP specific commands\n" | |
3030 | "Change the default bestpath selection\n" | |
3031 | "Link Bandwidth attribute\n" | |
3032 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
3033 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
3034 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
3035 | { | |
3036 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3037 | afi_t afi; | |
3038 | safi_t safi; | |
3039 | ||
3040 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3041 | ||
3042 | /* This config is used in route install, so redo that. */ | |
3043 | FOREACH_AFI_SAFI (afi, safi) { | |
3044 | if (!bgp_fibupd_safi(safi)) | |
3045 | continue; | |
3046 | bgp_zebra_announce_table(bgp, afi, safi); | |
3047 | } | |
3048 | return CMD_SUCCESS; | |
3049 | } | |
3050 | ||
718e3744 | 3051 | /* "no bgp default ipv4-unicast". */ |
3052 | DEFUN (no_bgp_default_ipv4_unicast, | |
3053 | no_bgp_default_ipv4_unicast_cmd, | |
3054 | "no bgp default ipv4-unicast", | |
3055 | NO_STR | |
3056 | "BGP specific commands\n" | |
3057 | "Configure BGP defaults\n" | |
3058 | "Activate ipv4-unicast for a peer by default\n") | |
3059 | { | |
d62a17ae | 3060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3061 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3062 | return CMD_SUCCESS; |
718e3744 | 3063 | } |
3064 | ||
3065 | DEFUN (bgp_default_ipv4_unicast, | |
3066 | bgp_default_ipv4_unicast_cmd, | |
3067 | "bgp default ipv4-unicast", | |
3068 | "BGP specific commands\n" | |
3069 | "Configure BGP defaults\n" | |
3070 | "Activate ipv4-unicast for a peer by default\n") | |
3071 | { | |
d62a17ae | 3072 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3073 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3074 | return CMD_SUCCESS; |
718e3744 | 3075 | } |
6b0655a2 | 3076 | |
04b6bdc0 DW |
3077 | /* Display hostname in certain command outputs */ |
3078 | DEFUN (bgp_default_show_hostname, | |
3079 | bgp_default_show_hostname_cmd, | |
3080 | "bgp default show-hostname", | |
3081 | "BGP specific commands\n" | |
3082 | "Configure BGP defaults\n" | |
0437e105 | 3083 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3084 | { |
d62a17ae | 3085 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3086 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3087 | return CMD_SUCCESS; |
04b6bdc0 DW |
3088 | } |
3089 | ||
3090 | DEFUN (no_bgp_default_show_hostname, | |
3091 | no_bgp_default_show_hostname_cmd, | |
3092 | "no bgp default show-hostname", | |
3093 | NO_STR | |
3094 | "BGP specific commands\n" | |
3095 | "Configure BGP defaults\n" | |
0437e105 | 3096 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3097 | { |
d62a17ae | 3098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3099 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3100 | return CMD_SUCCESS; |
04b6bdc0 DW |
3101 | } |
3102 | ||
8233ef81 | 3103 | /* "bgp network import-check" configuration. */ |
718e3744 | 3104 | DEFUN (bgp_network_import_check, |
3105 | bgp_network_import_check_cmd, | |
5623e905 | 3106 | "bgp network import-check", |
718e3744 | 3107 | "BGP specific commands\n" |
3108 | "BGP network command\n" | |
5623e905 | 3109 | "Check BGP network route exists in IGP\n") |
718e3744 | 3110 | { |
d62a17ae | 3111 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3112 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3113 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3114 | bgp_static_redo_import_check(bgp); |
3115 | } | |
078430f6 | 3116 | |
d62a17ae | 3117 | return CMD_SUCCESS; |
718e3744 | 3118 | } |
3119 | ||
d62a17ae | 3120 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3121 | "bgp network import-check exact", | |
3122 | "BGP specific commands\n" | |
3123 | "BGP network command\n" | |
3124 | "Check BGP network route exists in IGP\n" | |
3125 | "Match route precisely\n") | |
8233ef81 | 3126 | |
718e3744 | 3127 | DEFUN (no_bgp_network_import_check, |
3128 | no_bgp_network_import_check_cmd, | |
5623e905 | 3129 | "no bgp network import-check", |
718e3744 | 3130 | NO_STR |
3131 | "BGP specific commands\n" | |
3132 | "BGP network command\n" | |
3133 | "Check BGP network route exists in IGP\n") | |
3134 | { | |
d62a17ae | 3135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3136 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3137 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3138 | bgp_static_redo_import_check(bgp); |
3139 | } | |
5623e905 | 3140 | |
d62a17ae | 3141 | return CMD_SUCCESS; |
718e3744 | 3142 | } |
6b0655a2 | 3143 | |
718e3744 | 3144 | DEFUN (bgp_default_local_preference, |
3145 | bgp_default_local_preference_cmd, | |
6147e2c6 | 3146 | "bgp default local-preference (0-4294967295)", |
718e3744 | 3147 | "BGP specific commands\n" |
3148 | "Configure BGP defaults\n" | |
3149 | "local preference (higher=more preferred)\n" | |
3150 | "Configure default local preference value\n") | |
3151 | { | |
d62a17ae | 3152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3153 | int idx_number = 3; | |
d7c0a89a | 3154 | uint32_t local_pref; |
718e3744 | 3155 | |
d62a17ae | 3156 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3157 | |
d62a17ae | 3158 | bgp_default_local_preference_set(bgp, local_pref); |
3159 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3160 | |
d62a17ae | 3161 | return CMD_SUCCESS; |
718e3744 | 3162 | } |
3163 | ||
3164 | DEFUN (no_bgp_default_local_preference, | |
3165 | no_bgp_default_local_preference_cmd, | |
838758ac | 3166 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 3167 | NO_STR |
3168 | "BGP specific commands\n" | |
3169 | "Configure BGP defaults\n" | |
838758ac DW |
3170 | "local preference (higher=more preferred)\n" |
3171 | "Configure default local preference value\n") | |
718e3744 | 3172 | { |
d62a17ae | 3173 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3174 | bgp_default_local_preference_unset(bgp); | |
3175 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3176 | |
d62a17ae | 3177 | return CMD_SUCCESS; |
718e3744 | 3178 | } |
3179 | ||
6b0655a2 | 3180 | |
3f9c7369 DS |
3181 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3182 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 3183 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
3184 | "BGP specific commands\n" |
3185 | "Configure BGP defaults\n" | |
3186 | "subgroup-pkt-queue-max\n" | |
3187 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3188 | { |
d62a17ae | 3189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3190 | int idx_number = 3; | |
d7c0a89a | 3191 | uint32_t max_size; |
8bd9d948 | 3192 | |
d62a17ae | 3193 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3194 | |
d62a17ae | 3195 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 3196 | |
d62a17ae | 3197 | return CMD_SUCCESS; |
3f9c7369 DS |
3198 | } |
3199 | ||
3200 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3201 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 3202 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
3203 | NO_STR |
3204 | "BGP specific commands\n" | |
3205 | "Configure BGP defaults\n" | |
838758ac DW |
3206 | "subgroup-pkt-queue-max\n" |
3207 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3208 | { |
d62a17ae | 3209 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3210 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3211 | return CMD_SUCCESS; | |
8bd9d948 DS |
3212 | } |
3213 | ||
813d4307 | 3214 | |
8bd9d948 DS |
3215 | DEFUN (bgp_rr_allow_outbound_policy, |
3216 | bgp_rr_allow_outbound_policy_cmd, | |
3217 | "bgp route-reflector allow-outbound-policy", | |
3218 | "BGP specific commands\n" | |
3219 | "Allow modifications made by out route-map\n" | |
3220 | "on ibgp neighbors\n") | |
3221 | { | |
d62a17ae | 3222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3223 | |
892fedb6 DA |
3224 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3225 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3226 | update_group_announce_rrclients(bgp); |
3227 | bgp_clear_star_soft_out(vty, bgp->name); | |
3228 | } | |
8bd9d948 | 3229 | |
d62a17ae | 3230 | return CMD_SUCCESS; |
8bd9d948 DS |
3231 | } |
3232 | ||
3233 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3234 | no_bgp_rr_allow_outbound_policy_cmd, | |
3235 | "no bgp route-reflector allow-outbound-policy", | |
3236 | NO_STR | |
3237 | "BGP specific commands\n" | |
3238 | "Allow modifications made by out route-map\n" | |
3239 | "on ibgp neighbors\n") | |
3240 | { | |
d62a17ae | 3241 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3242 | |
892fedb6 DA |
3243 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3244 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3245 | update_group_announce_rrclients(bgp); |
3246 | bgp_clear_star_soft_out(vty, bgp->name); | |
3247 | } | |
8bd9d948 | 3248 | |
d62a17ae | 3249 | return CMD_SUCCESS; |
8bd9d948 DS |
3250 | } |
3251 | ||
f14e6fdb DS |
3252 | DEFUN (bgp_listen_limit, |
3253 | bgp_listen_limit_cmd, | |
9ccf14f7 | 3254 | "bgp listen limit (1-5000)", |
f14e6fdb | 3255 | "BGP specific commands\n" |
1601a46f | 3256 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3257 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
3258 | "Configure Dynamic Neighbors listen limit value\n") |
3259 | { | |
d62a17ae | 3260 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3261 | int idx_number = 3; | |
3262 | int listen_limit; | |
f14e6fdb | 3263 | |
d62a17ae | 3264 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 3265 | |
d62a17ae | 3266 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3267 | |
d62a17ae | 3268 | return CMD_SUCCESS; |
f14e6fdb DS |
3269 | } |
3270 | ||
3271 | DEFUN (no_bgp_listen_limit, | |
3272 | no_bgp_listen_limit_cmd, | |
838758ac | 3273 | "no bgp listen limit [(1-5000)]", |
1601a46f | 3274 | NO_STR |
f14e6fdb | 3275 | "BGP specific commands\n" |
1601a46f | 3276 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3277 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 3278 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 3279 | { |
d62a17ae | 3280 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3281 | bgp_listen_limit_unset(bgp); | |
3282 | return CMD_SUCCESS; | |
f14e6fdb DS |
3283 | } |
3284 | ||
3285 | ||
20eb8864 | 3286 | /* |
3287 | * Check if this listen range is already configured. Check for exact | |
3288 | * match or overlap based on input. | |
3289 | */ | |
d62a17ae | 3290 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3291 | struct prefix *range, int exact) | |
3292 | { | |
3293 | struct listnode *node, *nnode; | |
3294 | struct listnode *node1, *nnode1; | |
3295 | struct peer_group *group; | |
3296 | struct prefix *lr; | |
3297 | afi_t afi; | |
3298 | int match; | |
3299 | ||
3300 | afi = family2afi(range->family); | |
3301 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3302 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3303 | lr)) { | |
3304 | if (exact) | |
3305 | match = prefix_same(range, lr); | |
3306 | else | |
3307 | match = (prefix_match(range, lr) | |
3308 | || prefix_match(lr, range)); | |
3309 | if (match) | |
3310 | return group; | |
3311 | } | |
3312 | } | |
3313 | ||
3314 | return NULL; | |
20eb8864 | 3315 | } |
3316 | ||
f14e6fdb DS |
3317 | DEFUN (bgp_listen_range, |
3318 | bgp_listen_range_cmd, | |
d7b9898c | 3319 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3320 | "BGP specific commands\n" |
d7fa34c1 QY |
3321 | "Configure BGP dynamic neighbors listen range\n" |
3322 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3323 | NEIGHBOR_ADDR_STR |
3324 | "Member of the peer-group\n" | |
3325 | "Peer-group name\n") | |
f14e6fdb | 3326 | { |
d62a17ae | 3327 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3328 | struct prefix range; | |
3329 | struct peer_group *group, *existing_group; | |
3330 | afi_t afi; | |
3331 | int ret; | |
3332 | int idx = 0; | |
3333 | ||
3334 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3335 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3336 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3337 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3338 | char *peergroup = argv[idx]->arg; |
3339 | ||
3340 | /* Convert IP prefix string to struct prefix. */ | |
3341 | ret = str2prefix(prefix, &range); | |
3342 | if (!ret) { | |
3343 | vty_out(vty, "%% Malformed listen range\n"); | |
3344 | return CMD_WARNING_CONFIG_FAILED; | |
3345 | } | |
3346 | ||
3347 | afi = family2afi(range.family); | |
3348 | ||
3349 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3350 | vty_out(vty, | |
3351 | "%% Malformed listen range (link-local address)\n"); | |
3352 | return CMD_WARNING_CONFIG_FAILED; | |
3353 | } | |
3354 | ||
3355 | apply_mask(&range); | |
3356 | ||
3357 | /* Check if same listen range is already configured. */ | |
3358 | existing_group = listen_range_exists(bgp, &range, 1); | |
3359 | if (existing_group) { | |
3360 | if (strcmp(existing_group->name, peergroup) == 0) | |
3361 | return CMD_SUCCESS; | |
3362 | else { | |
3363 | vty_out(vty, | |
3364 | "%% Same listen range is attached to peer-group %s\n", | |
3365 | existing_group->name); | |
3366 | return CMD_WARNING_CONFIG_FAILED; | |
3367 | } | |
3368 | } | |
3369 | ||
3370 | /* Check if an overlapping listen range exists. */ | |
3371 | if (listen_range_exists(bgp, &range, 0)) { | |
3372 | vty_out(vty, | |
3373 | "%% Listen range overlaps with existing listen range\n"); | |
3374 | return CMD_WARNING_CONFIG_FAILED; | |
3375 | } | |
3376 | ||
3377 | group = peer_group_lookup(bgp, peergroup); | |
3378 | if (!group) { | |
3379 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3380 | return CMD_WARNING_CONFIG_FAILED; | |
3381 | } | |
3382 | ||
3383 | ret = peer_group_listen_range_add(group, &range); | |
3384 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3385 | } |
3386 | ||
3387 | DEFUN (no_bgp_listen_range, | |
3388 | no_bgp_listen_range_cmd, | |
d7b9898c | 3389 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3390 | NO_STR |
f14e6fdb | 3391 | "BGP specific commands\n" |
d7fa34c1 QY |
3392 | "Unconfigure BGP dynamic neighbors listen range\n" |
3393 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3394 | NEIGHBOR_ADDR_STR | |
3395 | "Member of the peer-group\n" | |
3396 | "Peer-group name\n") | |
f14e6fdb | 3397 | { |
d62a17ae | 3398 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3399 | struct prefix range; | |
3400 | struct peer_group *group; | |
3401 | afi_t afi; | |
3402 | int ret; | |
3403 | int idx = 0; | |
3404 | ||
3405 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3406 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3407 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3408 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3409 | char *peergroup = argv[idx]->arg; |
3410 | ||
3411 | /* Convert IP prefix string to struct prefix. */ | |
3412 | ret = str2prefix(prefix, &range); | |
3413 | if (!ret) { | |
3414 | vty_out(vty, "%% Malformed listen range\n"); | |
3415 | return CMD_WARNING_CONFIG_FAILED; | |
3416 | } | |
3417 | ||
3418 | afi = family2afi(range.family); | |
3419 | ||
3420 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3421 | vty_out(vty, | |
3422 | "%% Malformed listen range (link-local address)\n"); | |
3423 | return CMD_WARNING_CONFIG_FAILED; | |
3424 | } | |
3425 | ||
3426 | apply_mask(&range); | |
3427 | ||
3428 | group = peer_group_lookup(bgp, peergroup); | |
3429 | if (!group) { | |
3430 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3431 | return CMD_WARNING_CONFIG_FAILED; | |
3432 | } | |
3433 | ||
3434 | ret = peer_group_listen_range_del(group, &range); | |
3435 | return bgp_vty_return(vty, ret); | |
3436 | } | |
3437 | ||
2b791107 | 3438 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3439 | { |
3440 | struct peer_group *group; | |
3441 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3442 | struct prefix *range; | |
3443 | afi_t afi; | |
3444 | char buf[PREFIX2STR_BUFFER]; | |
3445 | ||
3446 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3447 | vty_out(vty, " bgp listen limit %d\n", | |
3448 | bgp->dynamic_neighbors_limit); | |
3449 | ||
3450 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3451 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3452 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3453 | nrnode, range)) { | |
3454 | prefix2str(range, buf, sizeof(buf)); | |
3455 | vty_out(vty, | |
3456 | " bgp listen range %s peer-group %s\n", | |
3457 | buf, group->name); | |
3458 | } | |
3459 | } | |
3460 | } | |
f14e6fdb DS |
3461 | } |
3462 | ||
3463 | ||
907f92c8 DS |
3464 | DEFUN (bgp_disable_connected_route_check, |
3465 | bgp_disable_connected_route_check_cmd, | |
3466 | "bgp disable-ebgp-connected-route-check", | |
3467 | "BGP specific commands\n" | |
3468 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3469 | { | |
d62a17ae | 3470 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3471 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3472 | bgp_clear_star_soft_in(vty, bgp->name); |
7aafcaca | 3473 | |
d62a17ae | 3474 | return CMD_SUCCESS; |
907f92c8 DS |
3475 | } |
3476 | ||
3477 | DEFUN (no_bgp_disable_connected_route_check, | |
3478 | no_bgp_disable_connected_route_check_cmd, | |
3479 | "no bgp disable-ebgp-connected-route-check", | |
3480 | NO_STR | |
3481 | "BGP specific commands\n" | |
3482 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3483 | { | |
d62a17ae | 3484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3485 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3486 | bgp_clear_star_soft_in(vty, bgp->name); |
3487 | ||
3488 | return CMD_SUCCESS; | |
3489 | } | |
3490 | ||
3491 | ||
3492 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3493 | const char *as_str, afi_t afi, safi_t safi) | |
3494 | { | |
3495 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3496 | int ret; | |
3497 | as_t as; | |
3498 | int as_type = AS_SPECIFIED; | |
3499 | union sockunion su; | |
3500 | ||
3501 | if (as_str[0] == 'i') { | |
3502 | as = 0; | |
3503 | as_type = AS_INTERNAL; | |
3504 | } else if (as_str[0] == 'e') { | |
3505 | as = 0; | |
3506 | as_type = AS_EXTERNAL; | |
3507 | } else { | |
3508 | /* Get AS number. */ | |
3509 | as = strtoul(as_str, NULL, 10); | |
3510 | } | |
3511 | ||
390485fd | 3512 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3513 | ret = str2sockunion(peer_str, &su); |
3514 | if (ret < 0) { | |
390485fd DS |
3515 | struct peer *peer; |
3516 | ||
3517 | /* Check if existing interface peer */ | |
3518 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3519 | ||
d62a17ae | 3520 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3521 | safi); | |
390485fd DS |
3522 | |
3523 | /* if not interface peer, check peer-group settings */ | |
3524 | if (ret < 0 && !peer) { | |
d62a17ae | 3525 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3526 | if (ret < 0) { | |
3527 | vty_out(vty, | |
390485fd | 3528 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3529 | return CMD_WARNING_CONFIG_FAILED; |
3530 | } | |
3531 | return CMD_SUCCESS; | |
3532 | } | |
3533 | } else { | |
3534 | if (peer_address_self_check(bgp, &su)) { | |
3535 | vty_out(vty, | |
3536 | "%% Can not configure the local system as neighbor\n"); | |
3537 | return CMD_WARNING_CONFIG_FAILED; | |
3538 | } | |
3539 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3540 | } | |
3541 | ||
3542 | /* This peer belongs to peer group. */ | |
3543 | switch (ret) { | |
3544 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3545 | vty_out(vty, | |
faa16034 | 3546 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3547 | return CMD_WARNING_CONFIG_FAILED; |
3548 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3549 | vty_out(vty, | |
faa16034 | 3550 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3551 | return CMD_WARNING_CONFIG_FAILED; |
3552 | } | |
3553 | return bgp_vty_return(vty, ret); | |
718e3744 | 3554 | } |
3555 | ||
f26845f9 QY |
3556 | DEFUN (bgp_default_shutdown, |
3557 | bgp_default_shutdown_cmd, | |
3558 | "[no] bgp default shutdown", | |
3559 | NO_STR | |
3560 | BGP_STR | |
3561 | "Configure BGP defaults\n" | |
b012cbe2 | 3562 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3563 | { |
3564 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3565 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3566 | return CMD_SUCCESS; | |
3567 | } | |
3568 | ||
718e3744 | 3569 | DEFUN (neighbor_remote_as, |
3570 | neighbor_remote_as_cmd, | |
3a2d747c | 3571 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3572 | NEIGHBOR_STR |
3573 | NEIGHBOR_ADDR_STR2 | |
3574 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3575 | AS_STR |
3a2d747c QY |
3576 | "Internal BGP peer\n" |
3577 | "External BGP peer\n") | |
718e3744 | 3578 | { |
d62a17ae | 3579 | int idx_peer = 1; |
3580 | int idx_remote_as = 3; | |
3581 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3582 | argv[idx_remote_as]->arg, AFI_IP, | |
3583 | SAFI_UNICAST); | |
3584 | } | |
3585 | ||
3586 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3587 | afi_t afi, safi_t safi, int v6only, | |
3588 | const char *peer_group_name, | |
3589 | const char *as_str) | |
3590 | { | |
3591 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3592 | as_t as = 0; | |
3593 | int as_type = AS_UNSPECIFIED; | |
3594 | struct peer *peer; | |
3595 | struct peer_group *group; | |
3596 | int ret = 0; | |
3597 | union sockunion su; | |
3598 | ||
3599 | group = peer_group_lookup(bgp, conf_if); | |
3600 | ||
3601 | if (group) { | |
3602 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3603 | return CMD_WARNING_CONFIG_FAILED; | |
3604 | } | |
3605 | ||
3606 | if (as_str) { | |
3607 | if (as_str[0] == 'i') { | |
3608 | as_type = AS_INTERNAL; | |
3609 | } else if (as_str[0] == 'e') { | |
3610 | as_type = AS_EXTERNAL; | |
3611 | } else { | |
3612 | /* Get AS number. */ | |
3613 | as = strtoul(as_str, NULL, 10); | |
3614 | as_type = AS_SPECIFIED; | |
3615 | } | |
3616 | } | |
3617 | ||
3618 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3619 | if (peer) { | |
3620 | if (as_str) | |
cc4d4ce8 | 3621 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3622 | afi, safi); |
3623 | } else { | |
892fedb6 | 3624 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 3625 | && afi == AFI_IP && safi == SAFI_UNICAST) |
3626 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3627 | as_type, 0, 0, NULL); | |
3628 | else | |
3629 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3630 | as_type, afi, safi, NULL); | |
3631 | ||
3632 | if (!peer) { | |
3633 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3634 | return CMD_WARNING_CONFIG_FAILED; | |
3635 | } | |
3636 | ||
3637 | if (v6only) | |
527de3dc | 3638 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3639 | |
3640 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3641 | * this | |
3642 | * any unnumbered peer in order to not worry about run-time | |
3643 | * transitions | |
3644 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3645 | * address | |
3646 | * gets deleted later etc.) | |
3647 | */ | |
3648 | if (peer->ifp) | |
3649 | bgp_zebra_initiate_radv(bgp, peer); | |
3650 | } | |
3651 | ||
3652 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3653 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3654 | if (v6only) | |
527de3dc | 3655 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3656 | else |
527de3dc | 3657 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3658 | |
3659 | /* v6only flag changed. Reset bgp seesion */ | |
3660 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3661 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3662 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3663 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3664 | } else | |
3665 | bgp_session_reset(peer); | |
3666 | } | |
3667 | ||
9fb964de PM |
3668 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3669 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3670 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3671 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3672 | } |
d62a17ae | 3673 | |
3674 | if (peer_group_name) { | |
3675 | group = peer_group_lookup(bgp, peer_group_name); | |
3676 | if (!group) { | |
3677 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3678 | return CMD_WARNING_CONFIG_FAILED; | |
3679 | } | |
3680 | ||
3681 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3682 | } | |
3683 | ||
3684 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3685 | } |
3686 | ||
4c48cf63 DW |
3687 | DEFUN (neighbor_interface_config, |
3688 | neighbor_interface_config_cmd, | |
d7b9898c | 3689 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3690 | NEIGHBOR_STR |
3691 | "Interface name or neighbor tag\n" | |
31500417 DW |
3692 | "Enable BGP on interface\n" |
3693 | "Member of the peer-group\n" | |
16cedbb0 | 3694 | "Peer-group name\n") |
4c48cf63 | 3695 | { |
d62a17ae | 3696 | int idx_word = 1; |
3697 | int idx_peer_group_word = 4; | |
31500417 | 3698 | |
d62a17ae | 3699 | if (argc > idx_peer_group_word) |
3700 | return peer_conf_interface_get( | |
3701 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3702 | argv[idx_peer_group_word]->arg, NULL); | |
3703 | else | |
3704 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3705 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3706 | } |
3707 | ||
4c48cf63 DW |
3708 | DEFUN (neighbor_interface_config_v6only, |
3709 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3710 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3711 | NEIGHBOR_STR |
3712 | "Interface name or neighbor tag\n" | |
3713 | "Enable BGP on interface\n" | |
31500417 DW |
3714 | "Enable BGP with v6 link-local only\n" |
3715 | "Member of the peer-group\n" | |
16cedbb0 | 3716 | "Peer-group name\n") |
4c48cf63 | 3717 | { |
d62a17ae | 3718 | int idx_word = 1; |
3719 | int idx_peer_group_word = 5; | |
31500417 | 3720 | |
d62a17ae | 3721 | if (argc > idx_peer_group_word) |
3722 | return peer_conf_interface_get( | |
3723 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3724 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3725 | |
d62a17ae | 3726 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3727 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3728 | } |
3729 | ||
a80beece | 3730 | |
b3a39dc5 DD |
3731 | DEFUN (neighbor_interface_config_remote_as, |
3732 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3733 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3734 | NEIGHBOR_STR |
3735 | "Interface name or neighbor tag\n" | |
3736 | "Enable BGP on interface\n" | |
3a2d747c | 3737 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3738 | AS_STR |
3a2d747c QY |
3739 | "Internal BGP peer\n" |
3740 | "External BGP peer\n") | |
b3a39dc5 | 3741 | { |
d62a17ae | 3742 | int idx_word = 1; |
3743 | int idx_remote_as = 4; | |
3744 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3745 | SAFI_UNICAST, 0, NULL, | |
3746 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3747 | } |
3748 | ||
3749 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3750 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3751 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3752 | NEIGHBOR_STR |
3753 | "Interface name or neighbor tag\n" | |
3a2d747c | 3754 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3755 | "Enable BGP on interface\n" |
3a2d747c | 3756 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3757 | AS_STR |
3a2d747c QY |
3758 | "Internal BGP peer\n" |
3759 | "External BGP peer\n") | |
b3a39dc5 | 3760 | { |
d62a17ae | 3761 | int idx_word = 1; |
3762 | int idx_remote_as = 5; | |
3763 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3764 | SAFI_UNICAST, 1, NULL, | |
3765 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3766 | } |
3767 | ||
718e3744 | 3768 | DEFUN (neighbor_peer_group, |
3769 | neighbor_peer_group_cmd, | |
3770 | "neighbor WORD peer-group", | |
3771 | NEIGHBOR_STR | |
a80beece | 3772 | "Interface name or neighbor tag\n" |
718e3744 | 3773 | "Configure peer-group\n") |
3774 | { | |
d62a17ae | 3775 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3776 | int idx_word = 1; | |
3777 | struct peer *peer; | |
3778 | struct peer_group *group; | |
718e3744 | 3779 | |
d62a17ae | 3780 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3781 | if (peer) { | |
3782 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3783 | return CMD_WARNING_CONFIG_FAILED; | |
3784 | } | |
718e3744 | 3785 | |
d62a17ae | 3786 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3787 | if (!group) { | |
3788 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3789 | return CMD_WARNING_CONFIG_FAILED; | |
3790 | } | |
718e3744 | 3791 | |
d62a17ae | 3792 | return CMD_SUCCESS; |
718e3744 | 3793 | } |
3794 | ||
3795 | DEFUN (no_neighbor, | |
3796 | no_neighbor_cmd, | |
dab8cd00 | 3797 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3798 | NO_STR |
3799 | NEIGHBOR_STR | |
3a2d747c QY |
3800 | NEIGHBOR_ADDR_STR2 |
3801 | "Specify a BGP neighbor\n" | |
3802 | AS_STR | |
3803 | "Internal BGP peer\n" | |
3804 | "External BGP peer\n") | |
718e3744 | 3805 | { |
d62a17ae | 3806 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3807 | int idx_peer = 2; | |
3808 | int ret; | |
3809 | union sockunion su; | |
3810 | struct peer_group *group; | |
3811 | struct peer *peer; | |
3812 | struct peer *other; | |
3813 | ||
3814 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3815 | if (ret < 0) { | |
3816 | /* look up for neighbor by interface name config. */ | |
3817 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3818 | if (peer) { | |
3819 | /* Request zebra to terminate IPv6 RAs on this | |
3820 | * interface. */ | |
3821 | if (peer->ifp) | |
3822 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3823 | peer_notify_unconfig(peer); |
d62a17ae | 3824 | peer_delete(peer); |
3825 | return CMD_SUCCESS; | |
3826 | } | |
f14e6fdb | 3827 | |
d62a17ae | 3828 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3829 | if (group) { |
3830 | peer_group_notify_unconfig(group); | |
d62a17ae | 3831 | peer_group_delete(group); |
4e2786df | 3832 | } else { |
d62a17ae | 3833 | vty_out(vty, "%% Create the peer-group first\n"); |
3834 | return CMD_WARNING_CONFIG_FAILED; | |
3835 | } | |
3836 | } else { | |
3837 | peer = peer_lookup(bgp, &su); | |
3838 | if (peer) { | |
3839 | if (peer_dynamic_neighbor(peer)) { | |
3840 | vty_out(vty, | |
3841 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3842 | return CMD_WARNING_CONFIG_FAILED; | |
3843 | } | |
3844 | ||
3845 | other = peer->doppelganger; | |
b3a3290e DS |
3846 | |
3847 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
3848 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3849 | ||
4e2786df | 3850 | peer_notify_unconfig(peer); |
d62a17ae | 3851 | peer_delete(peer); |
4e2786df DA |
3852 | if (other && other->status != Deleted) { |
3853 | peer_notify_unconfig(other); | |
d62a17ae | 3854 | peer_delete(other); |
4e2786df | 3855 | } |
d62a17ae | 3856 | } |
1ff9a340 | 3857 | } |
718e3744 | 3858 | |
d62a17ae | 3859 | return CMD_SUCCESS; |
718e3744 | 3860 | } |
3861 | ||
a80beece DS |
3862 | DEFUN (no_neighbor_interface_config, |
3863 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3864 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3865 | NO_STR |
3866 | NEIGHBOR_STR | |
3867 | "Interface name\n" | |
31500417 DW |
3868 | "Configure BGP on interface\n" |
3869 | "Enable BGP with v6 link-local only\n" | |
3870 | "Member of the peer-group\n" | |
16cedbb0 | 3871 | "Peer-group name\n" |
3a2d747c QY |
3872 | "Specify a BGP neighbor\n" |
3873 | AS_STR | |
3874 | "Internal BGP peer\n" | |
3875 | "External BGP peer\n") | |
a80beece | 3876 | { |
d62a17ae | 3877 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3878 | int idx_word = 2; | |
3879 | struct peer *peer; | |
3880 | ||
3881 | /* look up for neighbor by interface name config. */ | |
3882 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3883 | if (peer) { | |
3884 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3885 | if (peer->ifp) | |
3886 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3887 | peer_notify_unconfig(peer); |
d62a17ae | 3888 | peer_delete(peer); |
3889 | } else { | |
3890 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3891 | return CMD_WARNING_CONFIG_FAILED; | |
3892 | } | |
3893 | return CMD_SUCCESS; | |
a80beece DS |
3894 | } |
3895 | ||
718e3744 | 3896 | DEFUN (no_neighbor_peer_group, |
3897 | no_neighbor_peer_group_cmd, | |
3898 | "no neighbor WORD peer-group", | |
3899 | NO_STR | |
3900 | NEIGHBOR_STR | |
3901 | "Neighbor tag\n" | |
3902 | "Configure peer-group\n") | |
3903 | { | |
d62a17ae | 3904 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3905 | int idx_word = 2; | |
3906 | struct peer_group *group; | |
718e3744 | 3907 | |
d62a17ae | 3908 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3909 | if (group) { |
3910 | peer_group_notify_unconfig(group); | |
d62a17ae | 3911 | peer_group_delete(group); |
4e2786df | 3912 | } else { |
d62a17ae | 3913 | vty_out(vty, "%% Create the peer-group first\n"); |
3914 | return CMD_WARNING_CONFIG_FAILED; | |
3915 | } | |
3916 | return CMD_SUCCESS; | |
718e3744 | 3917 | } |
3918 | ||
a80beece DS |
3919 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3920 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3921 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3922 | NO_STR |
3923 | NEIGHBOR_STR | |
a80beece | 3924 | "Interface name or neighbor tag\n" |
718e3744 | 3925 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3926 | AS_STR |
3927 | "Internal BGP peer\n" | |
3928 | "External BGP peer\n") | |
718e3744 | 3929 | { |
d62a17ae | 3930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3931 | int idx_word = 2; | |
3932 | struct peer_group *group; | |
3933 | struct peer *peer; | |
3934 | ||
3935 | /* look up for neighbor by interface name config. */ | |
3936 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3937 | if (peer) { | |
390485fd | 3938 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3939 | return CMD_SUCCESS; |
3940 | } | |
3941 | ||
3942 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3943 | if (group) | |
3944 | peer_group_remote_as_delete(group); | |
3945 | else { | |
3946 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3947 | return CMD_WARNING_CONFIG_FAILED; | |
3948 | } | |
3949 | return CMD_SUCCESS; | |
718e3744 | 3950 | } |
6b0655a2 | 3951 | |
718e3744 | 3952 | DEFUN (neighbor_local_as, |
3953 | neighbor_local_as_cmd, | |
9ccf14f7 | 3954 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3955 | NEIGHBOR_STR |
3956 | NEIGHBOR_ADDR_STR2 | |
3957 | "Specify a local-as number\n" | |
3958 | "AS number used as local AS\n") | |
3959 | { | |
d62a17ae | 3960 | int idx_peer = 1; |
3961 | int idx_number = 3; | |
3962 | struct peer *peer; | |
3963 | int ret; | |
3964 | as_t as; | |
718e3744 | 3965 | |
d62a17ae | 3966 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3967 | if (!peer) | |
3968 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3969 | |
d62a17ae | 3970 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3971 | ret = peer_local_as_set(peer, as, 0, 0); | |
3972 | return bgp_vty_return(vty, ret); | |
718e3744 | 3973 | } |
3974 | ||
3975 | DEFUN (neighbor_local_as_no_prepend, | |
3976 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3977 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3978 | NEIGHBOR_STR |
3979 | NEIGHBOR_ADDR_STR2 | |
3980 | "Specify a local-as number\n" | |
3981 | "AS number used as local AS\n" | |
3982 | "Do not prepend local-as to updates from ebgp peers\n") | |
3983 | { | |
d62a17ae | 3984 | int idx_peer = 1; |
3985 | int idx_number = 3; | |
3986 | struct peer *peer; | |
3987 | int ret; | |
3988 | as_t as; | |
718e3744 | 3989 | |
d62a17ae | 3990 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3991 | if (!peer) | |
3992 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3993 | |
d62a17ae | 3994 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3995 | ret = peer_local_as_set(peer, as, 1, 0); | |
3996 | return bgp_vty_return(vty, ret); | |
718e3744 | 3997 | } |
3998 | ||
9d3f9705 AC |
3999 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
4000 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 4001 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
4002 | NEIGHBOR_STR |
4003 | NEIGHBOR_ADDR_STR2 | |
4004 | "Specify a local-as number\n" | |
4005 | "AS number used as local AS\n" | |
4006 | "Do not prepend local-as to updates from ebgp peers\n" | |
4007 | "Do not prepend local-as to updates from ibgp peers\n") | |
4008 | { | |
d62a17ae | 4009 | int idx_peer = 1; |
4010 | int idx_number = 3; | |
4011 | struct peer *peer; | |
4012 | int ret; | |
4013 | as_t as; | |
9d3f9705 | 4014 | |
d62a17ae | 4015 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4016 | if (!peer) | |
4017 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 4018 | |
d62a17ae | 4019 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
4020 | ret = peer_local_as_set(peer, as, 1, 1); | |
4021 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
4022 | } |
4023 | ||
718e3744 | 4024 | DEFUN (no_neighbor_local_as, |
4025 | no_neighbor_local_as_cmd, | |
a636c635 | 4026 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 4027 | NO_STR |
4028 | NEIGHBOR_STR | |
4029 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4030 | "Specify a local-as number\n" |
4031 | "AS number used as local AS\n" | |
4032 | "Do not prepend local-as to updates from ebgp peers\n" | |
4033 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4034 | { |
d62a17ae | 4035 | int idx_peer = 2; |
4036 | struct peer *peer; | |
4037 | int ret; | |
718e3744 | 4038 | |
d62a17ae | 4039 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4040 | if (!peer) | |
4041 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4042 | |
d62a17ae | 4043 | ret = peer_local_as_unset(peer); |
4044 | return bgp_vty_return(vty, ret); | |
718e3744 | 4045 | } |
4046 | ||
718e3744 | 4047 | |
3f9c7369 DS |
4048 | DEFUN (neighbor_solo, |
4049 | neighbor_solo_cmd, | |
9ccf14f7 | 4050 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4051 | NEIGHBOR_STR |
4052 | NEIGHBOR_ADDR_STR2 | |
4053 | "Solo peer - part of its own update group\n") | |
4054 | { | |
d62a17ae | 4055 | int idx_peer = 1; |
4056 | struct peer *peer; | |
4057 | int ret; | |
3f9c7369 | 4058 | |
d62a17ae | 4059 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4060 | if (!peer) | |
4061 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4062 | |
d62a17ae | 4063 | ret = update_group_adjust_soloness(peer, 1); |
4064 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4065 | } |
4066 | ||
4067 | DEFUN (no_neighbor_solo, | |
4068 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4070 | NO_STR |
4071 | NEIGHBOR_STR | |
4072 | NEIGHBOR_ADDR_STR2 | |
4073 | "Solo peer - part of its own update group\n") | |
4074 | { | |
d62a17ae | 4075 | int idx_peer = 2; |
4076 | struct peer *peer; | |
4077 | int ret; | |
3f9c7369 | 4078 | |
d62a17ae | 4079 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4080 | if (!peer) | |
4081 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4082 | |
d62a17ae | 4083 | ret = update_group_adjust_soloness(peer, 0); |
4084 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4085 | } |
4086 | ||
0df7c91f PJ |
4087 | DEFUN (neighbor_password, |
4088 | neighbor_password_cmd, | |
9ccf14f7 | 4089 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4090 | NEIGHBOR_STR |
4091 | NEIGHBOR_ADDR_STR2 | |
4092 | "Set a password\n" | |
4093 | "The password\n") | |
4094 | { | |
d62a17ae | 4095 | int idx_peer = 1; |
4096 | int idx_line = 3; | |
4097 | struct peer *peer; | |
4098 | int ret; | |
0df7c91f | 4099 | |
d62a17ae | 4100 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4101 | if (!peer) | |
4102 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4103 | |
d62a17ae | 4104 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4105 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4106 | } |
4107 | ||
4108 | DEFUN (no_neighbor_password, | |
4109 | no_neighbor_password_cmd, | |
a636c635 | 4110 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4111 | NO_STR |
4112 | NEIGHBOR_STR | |
4113 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4114 | "Set a password\n" |
4115 | "The password\n") | |
0df7c91f | 4116 | { |
d62a17ae | 4117 | int idx_peer = 2; |
4118 | struct peer *peer; | |
4119 | int ret; | |
0df7c91f | 4120 | |
d62a17ae | 4121 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4122 | if (!peer) | |
4123 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4124 | |
d62a17ae | 4125 | ret = peer_password_unset(peer); |
4126 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4127 | } |
6b0655a2 | 4128 | |
718e3744 | 4129 | DEFUN (neighbor_activate, |
4130 | neighbor_activate_cmd, | |
9ccf14f7 | 4131 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4132 | NEIGHBOR_STR |
4133 | NEIGHBOR_ADDR_STR2 | |
4134 | "Enable the Address Family for this Neighbor\n") | |
4135 | { | |
d62a17ae | 4136 | int idx_peer = 1; |
4137 | int ret; | |
4138 | struct peer *peer; | |
718e3744 | 4139 | |
d62a17ae | 4140 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4141 | if (!peer) | |
4142 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4143 | |
d62a17ae | 4144 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4145 | return bgp_vty_return(vty, ret); | |
718e3744 | 4146 | } |
4147 | ||
d62a17ae | 4148 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4149 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4150 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4151 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4152 | |
718e3744 | 4153 | DEFUN (no_neighbor_activate, |
4154 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4155 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4156 | NO_STR |
4157 | NEIGHBOR_STR | |
4158 | NEIGHBOR_ADDR_STR2 | |
4159 | "Enable the Address Family for this Neighbor\n") | |
4160 | { | |
d62a17ae | 4161 | int idx_peer = 2; |
4162 | int ret; | |
4163 | struct peer *peer; | |
718e3744 | 4164 | |
d62a17ae | 4165 | /* Lookup peer. */ |
4166 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4167 | if (!peer) | |
4168 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4169 | |
d62a17ae | 4170 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4171 | return bgp_vty_return(vty, ret); | |
718e3744 | 4172 | } |
6b0655a2 | 4173 | |
d62a17ae | 4174 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4175 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4176 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4177 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4178 | |
718e3744 | 4179 | DEFUN (neighbor_set_peer_group, |
4180 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4181 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4182 | NEIGHBOR_STR |
a80beece | 4183 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4184 | "Member of the peer-group\n" |
16cedbb0 | 4185 | "Peer-group name\n") |
718e3744 | 4186 | { |
d62a17ae | 4187 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4188 | int idx_peer = 1; | |
4189 | int idx_word = 3; | |
4190 | int ret; | |
4191 | as_t as; | |
4192 | union sockunion su; | |
4193 | struct peer *peer; | |
4194 | struct peer_group *group; | |
4195 | ||
d62a17ae | 4196 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4197 | if (ret < 0) { | |
4198 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4199 | if (!peer) { | |
4200 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4201 | argv[idx_peer]->arg); | |
4202 | return CMD_WARNING_CONFIG_FAILED; | |
4203 | } | |
4204 | } else { | |
4205 | if (peer_address_self_check(bgp, &su)) { | |
4206 | vty_out(vty, | |
4207 | "%% Can not configure the local system as neighbor\n"); | |
4208 | return CMD_WARNING_CONFIG_FAILED; | |
4209 | } | |
4210 | ||
4211 | /* Disallow for dynamic neighbor. */ | |
4212 | peer = peer_lookup(bgp, &su); | |
4213 | if (peer && peer_dynamic_neighbor(peer)) { | |
4214 | vty_out(vty, | |
4215 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4216 | return CMD_WARNING_CONFIG_FAILED; | |
4217 | } | |
4218 | } | |
4219 | ||
4220 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4221 | if (!group) { | |
4222 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4223 | return CMD_WARNING_CONFIG_FAILED; | |
4224 | } | |
4225 | ||
4226 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4227 | ||
4228 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4229 | vty_out(vty, | |
4230 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4231 | as); | |
4232 | return CMD_WARNING_CONFIG_FAILED; | |
4233 | } | |
4234 | ||
4235 | return bgp_vty_return(vty, ret); | |
4236 | } | |
4237 | ||
4238 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4239 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4240 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4241 | "Member of the peer-group\n" | |
4242 | "Peer-group name\n") | |
596c17ba | 4243 | |
718e3744 | 4244 | DEFUN (no_neighbor_set_peer_group, |
4245 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4246 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4247 | NO_STR |
4248 | NEIGHBOR_STR | |
a80beece | 4249 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4250 | "Member of the peer-group\n" |
16cedbb0 | 4251 | "Peer-group name\n") |
718e3744 | 4252 | { |
d62a17ae | 4253 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4254 | int idx_peer = 2; | |
4255 | int idx_word = 4; | |
4256 | int ret; | |
4257 | struct peer *peer; | |
4258 | struct peer_group *group; | |
4259 | ||
4260 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4261 | if (!peer) | |
4262 | return CMD_WARNING_CONFIG_FAILED; | |
4263 | ||
4264 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4265 | if (!group) { | |
4266 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4267 | return CMD_WARNING_CONFIG_FAILED; | |
4268 | } | |
718e3744 | 4269 | |
b3a3290e DS |
4270 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) |
4271 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4272 | ||
4e2786df | 4273 | peer_notify_unconfig(peer); |
827ed707 | 4274 | ret = peer_delete(peer); |
718e3744 | 4275 | |
d62a17ae | 4276 | return bgp_vty_return(vty, ret); |
718e3744 | 4277 | } |
6b0655a2 | 4278 | |
d62a17ae | 4279 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4280 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4281 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4282 | "Member of the peer-group\n" | |
4283 | "Peer-group name\n") | |
596c17ba | 4284 | |
d62a17ae | 4285 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4286 | uint32_t flag, int set) |
718e3744 | 4287 | { |
d62a17ae | 4288 | int ret; |
4289 | struct peer *peer; | |
718e3744 | 4290 | |
d62a17ae | 4291 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4292 | if (!peer) | |
4293 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4294 | |
7ebe625c QY |
4295 | /* |
4296 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4297 | * we should not accept disable-connected-check. | |
4298 | */ | |
4299 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4300 | vty_out(vty, | |
4301 | "%s is directly connected peer, cannot accept disable-" | |
4302 | "connected-check\n", | |
4303 | ip_str); | |
4304 | return CMD_WARNING_CONFIG_FAILED; | |
4305 | } | |
4306 | ||
d62a17ae | 4307 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4308 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4309 | |
d62a17ae | 4310 | if (set) |
4311 | ret = peer_flag_set(peer, flag); | |
4312 | else | |
4313 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4314 | |
d62a17ae | 4315 | return bgp_vty_return(vty, ret); |
718e3744 | 4316 | } |
4317 | ||
47cbc09b | 4318 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4319 | { |
d62a17ae | 4320 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4321 | } |
4322 | ||
d62a17ae | 4323 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4324 | uint32_t flag) |
718e3744 | 4325 | { |
d62a17ae | 4326 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4327 | } |
4328 | ||
4329 | /* neighbor passive. */ | |
4330 | DEFUN (neighbor_passive, | |
4331 | neighbor_passive_cmd, | |
9ccf14f7 | 4332 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4333 | NEIGHBOR_STR |
4334 | NEIGHBOR_ADDR_STR2 | |
4335 | "Don't send open messages to this neighbor\n") | |
4336 | { | |
d62a17ae | 4337 | int idx_peer = 1; |
4338 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4339 | } |
4340 | ||
4341 | DEFUN (no_neighbor_passive, | |
4342 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4343 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4344 | NO_STR |
4345 | NEIGHBOR_STR | |
4346 | NEIGHBOR_ADDR_STR2 | |
4347 | "Don't send open messages to this neighbor\n") | |
4348 | { | |
d62a17ae | 4349 | int idx_peer = 2; |
4350 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4351 | } |
6b0655a2 | 4352 | |
718e3744 | 4353 | /* neighbor shutdown. */ |
73d70fa6 DL |
4354 | DEFUN (neighbor_shutdown_msg, |
4355 | neighbor_shutdown_msg_cmd, | |
4356 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4357 | NEIGHBOR_STR |
4358 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
4359 | "Administratively shut down this neighbor\n" |
4360 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4361 | "Shutdown message\n") | |
718e3744 | 4362 | { |
d62a17ae | 4363 | int idx_peer = 1; |
73d70fa6 | 4364 | |
d62a17ae | 4365 | if (argc >= 5) { |
4366 | struct peer *peer = | |
4367 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4368 | char *message; | |
73d70fa6 | 4369 | |
d62a17ae | 4370 | if (!peer) |
4371 | return CMD_WARNING_CONFIG_FAILED; | |
4372 | message = argv_concat(argv, argc, 4); | |
4373 | peer_tx_shutdown_message_set(peer, message); | |
4374 | XFREE(MTYPE_TMP, message); | |
4375 | } | |
73d70fa6 | 4376 | |
d62a17ae | 4377 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4378 | } |
4379 | ||
d62a17ae | 4380 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4381 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4382 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4383 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4384 | |
4385 | DEFUN (no_neighbor_shutdown_msg, | |
4386 | no_neighbor_shutdown_msg_cmd, | |
4387 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4388 | NO_STR | |
4389 | NEIGHBOR_STR | |
4390 | NEIGHBOR_ADDR_STR2 | |
4391 | "Administratively shut down this neighbor\n" | |
4392 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4393 | "Shutdown message\n") | |
718e3744 | 4394 | { |
d62a17ae | 4395 | int idx_peer = 2; |
73d70fa6 | 4396 | |
d62a17ae | 4397 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4398 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4399 | } |
6b0655a2 | 4400 | |
d62a17ae | 4401 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4402 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4403 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4404 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4405 | |
718e3744 | 4406 | /* neighbor capability dynamic. */ |
4407 | DEFUN (neighbor_capability_dynamic, | |
4408 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4409 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4410 | NEIGHBOR_STR |
4411 | NEIGHBOR_ADDR_STR2 | |
4412 | "Advertise capability to the peer\n" | |
4413 | "Advertise dynamic capability to this neighbor\n") | |
4414 | { | |
d62a17ae | 4415 | int idx_peer = 1; |
4416 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4417 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4418 | } |
4419 | ||
4420 | DEFUN (no_neighbor_capability_dynamic, | |
4421 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4422 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4423 | NO_STR |
4424 | NEIGHBOR_STR | |
4425 | NEIGHBOR_ADDR_STR2 | |
4426 | "Advertise capability to the peer\n" | |
4427 | "Advertise dynamic capability to this neighbor\n") | |
4428 | { | |
d62a17ae | 4429 | int idx_peer = 2; |
4430 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4431 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4432 | } |
6b0655a2 | 4433 | |
718e3744 | 4434 | /* neighbor dont-capability-negotiate */ |
4435 | DEFUN (neighbor_dont_capability_negotiate, | |
4436 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4437 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4438 | NEIGHBOR_STR |
4439 | NEIGHBOR_ADDR_STR2 | |
4440 | "Do not perform capability negotiation\n") | |
4441 | { | |
d62a17ae | 4442 | int idx_peer = 1; |
4443 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4444 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4445 | } |
4446 | ||
4447 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4448 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4449 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4450 | NO_STR |
4451 | NEIGHBOR_STR | |
4452 | NEIGHBOR_ADDR_STR2 | |
4453 | "Do not perform capability negotiation\n") | |
4454 | { | |
d62a17ae | 4455 | int idx_peer = 2; |
4456 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4457 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4458 | } |
6b0655a2 | 4459 | |
8a92a8a0 DS |
4460 | /* neighbor capability extended next hop encoding */ |
4461 | DEFUN (neighbor_capability_enhe, | |
4462 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4463 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4464 | NEIGHBOR_STR |
4465 | NEIGHBOR_ADDR_STR2 | |
4466 | "Advertise capability to the peer\n" | |
4467 | "Advertise extended next-hop capability to the peer\n") | |
4468 | { | |
d62a17ae | 4469 | int idx_peer = 1; |
4470 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4471 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4472 | } |
4473 | ||
4474 | DEFUN (no_neighbor_capability_enhe, | |
4475 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4476 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4477 | NO_STR |
4478 | NEIGHBOR_STR | |
4479 | NEIGHBOR_ADDR_STR2 | |
4480 | "Advertise capability to the peer\n" | |
4481 | "Advertise extended next-hop capability to the peer\n") | |
4482 | { | |
d62a17ae | 4483 | int idx_peer = 2; |
4484 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4485 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4486 | } |
4487 | ||
d62a17ae | 4488 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4489 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4490 | int set) |
718e3744 | 4491 | { |
d62a17ae | 4492 | int ret; |
4493 | struct peer *peer; | |
718e3744 | 4494 | |
d62a17ae | 4495 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4496 | if (!peer) | |
4497 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4498 | |
d62a17ae | 4499 | if (set) |
4500 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4501 | else | |
4502 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4503 | |
d62a17ae | 4504 | return bgp_vty_return(vty, ret); |
718e3744 | 4505 | } |
4506 | ||
d62a17ae | 4507 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4508 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4509 | { |
d62a17ae | 4510 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4511 | } |
4512 | ||
d62a17ae | 4513 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4514 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4515 | { |
d62a17ae | 4516 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4517 | } |
6b0655a2 | 4518 | |
718e3744 | 4519 | /* neighbor capability orf prefix-list. */ |
4520 | DEFUN (neighbor_capability_orf_prefix, | |
4521 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4522 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4523 | NEIGHBOR_STR |
4524 | NEIGHBOR_ADDR_STR2 | |
4525 | "Advertise capability to the peer\n" | |
4526 | "Advertise ORF capability to the peer\n" | |
4527 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4528 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4529 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4530 | "Capability to SEND the ORF to this neighbor\n") | |
4531 | { | |
d62a17ae | 4532 | int idx_peer = 1; |
4533 | int idx_send_recv = 5; | |
d7c0a89a | 4534 | uint16_t flag = 0; |
d62a17ae | 4535 | |
4536 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4537 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4538 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4539 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4540 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4541 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4542 | else { | |
4543 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4544 | return CMD_WARNING_CONFIG_FAILED; | |
4545 | } | |
4546 | ||
4547 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4548 | bgp_node_safi(vty), flag); | |
4549 | } | |
4550 | ||
4551 | ALIAS_HIDDEN( | |
4552 | neighbor_capability_orf_prefix, | |
4553 | neighbor_capability_orf_prefix_hidden_cmd, | |
4554 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4555 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4556 | "Advertise capability to the peer\n" | |
4557 | "Advertise ORF capability to the peer\n" | |
4558 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4559 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4560 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4561 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4562 | |
718e3744 | 4563 | DEFUN (no_neighbor_capability_orf_prefix, |
4564 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4565 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4566 | NO_STR |
4567 | NEIGHBOR_STR | |
4568 | NEIGHBOR_ADDR_STR2 | |
4569 | "Advertise capability to the peer\n" | |
4570 | "Advertise ORF capability to the peer\n" | |
4571 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4572 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4573 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4574 | "Capability to SEND the ORF to this neighbor\n") | |
4575 | { | |
d62a17ae | 4576 | int idx_peer = 2; |
4577 | int idx_send_recv = 6; | |
d7c0a89a | 4578 | uint16_t flag = 0; |
d62a17ae | 4579 | |
4580 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4581 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4582 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4583 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4584 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4585 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4586 | else { | |
4587 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4588 | return CMD_WARNING_CONFIG_FAILED; | |
4589 | } | |
4590 | ||
4591 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4592 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4593 | flag); | |
4594 | } | |
4595 | ||
4596 | ALIAS_HIDDEN( | |
4597 | no_neighbor_capability_orf_prefix, | |
4598 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4599 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4600 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4601 | "Advertise capability to the peer\n" | |
4602 | "Advertise ORF capability to the peer\n" | |
4603 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4604 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4605 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4606 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4607 | |
718e3744 | 4608 | /* neighbor next-hop-self. */ |
4609 | DEFUN (neighbor_nexthop_self, | |
4610 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4611 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4612 | NEIGHBOR_STR |
4613 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4614 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4615 | { |
d62a17ae | 4616 | int idx_peer = 1; |
4617 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4618 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4619 | } |
9e7a53c1 | 4620 | |
d62a17ae | 4621 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4622 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4623 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4624 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4625 | |
a538debe DS |
4626 | /* neighbor next-hop-self. */ |
4627 | DEFUN (neighbor_nexthop_self_force, | |
4628 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4629 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4630 | NEIGHBOR_STR |
4631 | NEIGHBOR_ADDR_STR2 | |
4632 | "Disable the next hop calculation for this neighbor\n" | |
4633 | "Set the next hop to self for reflected routes\n") | |
4634 | { | |
d62a17ae | 4635 | int idx_peer = 1; |
4636 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4637 | bgp_node_safi(vty), | |
4638 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4639 | } |
4640 | ||
d62a17ae | 4641 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4642 | neighbor_nexthop_self_force_hidden_cmd, | |
4643 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4644 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4645 | "Disable the next hop calculation for this neighbor\n" | |
4646 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4647 | |
1bc4e531 DA |
4648 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4649 | neighbor_nexthop_self_all_hidden_cmd, | |
4650 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4651 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4652 | "Disable the next hop calculation for this neighbor\n" | |
4653 | "Set the next hop to self for reflected routes\n") | |
4654 | ||
718e3744 | 4655 | DEFUN (no_neighbor_nexthop_self, |
4656 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4658 | NO_STR |
4659 | NEIGHBOR_STR | |
4660 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4661 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4662 | { |
d62a17ae | 4663 | int idx_peer = 2; |
4664 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4665 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4666 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4667 | } |
6b0655a2 | 4668 | |
d62a17ae | 4669 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4670 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4671 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4672 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4673 | |
88b8ed8d | 4674 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4675 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4676 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4677 | NO_STR |
4678 | NEIGHBOR_STR | |
4679 | NEIGHBOR_ADDR_STR2 | |
4680 | "Disable the next hop calculation for this neighbor\n" | |
4681 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4682 | { |
d62a17ae | 4683 | int idx_peer = 2; |
4684 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4685 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4686 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4687 | } |
a538debe | 4688 | |
d62a17ae | 4689 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4690 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4692 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4693 | "Disable the next hop calculation for this neighbor\n" | |
4694 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4695 | |
1bc4e531 DA |
4696 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4697 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4698 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4699 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4700 | "Disable the next hop calculation for this neighbor\n" | |
4701 | "Set the next hop to self for reflected routes\n") | |
4702 | ||
c7122e14 DS |
4703 | /* neighbor as-override */ |
4704 | DEFUN (neighbor_as_override, | |
4705 | neighbor_as_override_cmd, | |
9ccf14f7 | 4706 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4707 | NEIGHBOR_STR |
4708 | NEIGHBOR_ADDR_STR2 | |
4709 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4710 | { | |
d62a17ae | 4711 | int idx_peer = 1; |
4712 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4713 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4714 | } |
4715 | ||
d62a17ae | 4716 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4717 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4718 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4719 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4720 | |
c7122e14 DS |
4721 | DEFUN (no_neighbor_as_override, |
4722 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4723 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4724 | NO_STR |
4725 | NEIGHBOR_STR | |
4726 | NEIGHBOR_ADDR_STR2 | |
4727 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4728 | { | |
d62a17ae | 4729 | int idx_peer = 2; |
4730 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4731 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4732 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4733 | } |
4734 | ||
d62a17ae | 4735 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4736 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4737 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4738 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4739 | |
718e3744 | 4740 | /* neighbor remove-private-AS. */ |
4741 | DEFUN (neighbor_remove_private_as, | |
4742 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4743 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4744 | NEIGHBOR_STR |
4745 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4746 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4747 | { |
d62a17ae | 4748 | int idx_peer = 1; |
4749 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4750 | bgp_node_safi(vty), | |
4751 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4752 | } |
4753 | ||
d62a17ae | 4754 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4755 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4756 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4757 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4758 | |
5000f21c DS |
4759 | DEFUN (neighbor_remove_private_as_all, |
4760 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4761 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4762 | NEIGHBOR_STR |
4763 | NEIGHBOR_ADDR_STR2 | |
4764 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4765 | "Apply to all AS numbers\n") |
5000f21c | 4766 | { |
d62a17ae | 4767 | int idx_peer = 1; |
4768 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4769 | bgp_node_safi(vty), | |
4770 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4771 | } |
4772 | ||
d62a17ae | 4773 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4774 | neighbor_remove_private_as_all_hidden_cmd, | |
4775 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4776 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4777 | "Remove private ASNs in outbound updates\n" | |
4778 | "Apply to all AS numbers") | |
596c17ba | 4779 | |
5000f21c DS |
4780 | DEFUN (neighbor_remove_private_as_replace_as, |
4781 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4782 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4783 | NEIGHBOR_STR |
4784 | NEIGHBOR_ADDR_STR2 | |
4785 | "Remove private ASNs in outbound updates\n" | |
4786 | "Replace private ASNs with our ASN in outbound updates\n") | |
4787 | { | |
d62a17ae | 4788 | int idx_peer = 1; |
4789 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4790 | bgp_node_safi(vty), | |
4791 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4792 | } |
4793 | ||
d62a17ae | 4794 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4795 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4796 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4797 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4798 | "Remove private ASNs in outbound updates\n" | |
4799 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4800 | |
5000f21c DS |
4801 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4802 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4803 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4804 | NEIGHBOR_STR |
4805 | NEIGHBOR_ADDR_STR2 | |
4806 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4807 | "Apply to all AS numbers\n" |
5000f21c DS |
4808 | "Replace private ASNs with our ASN in outbound updates\n") |
4809 | { | |
d62a17ae | 4810 | int idx_peer = 1; |
4811 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4812 | bgp_node_safi(vty), | |
4813 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4814 | } |
4815 | ||
d62a17ae | 4816 | ALIAS_HIDDEN( |
4817 | neighbor_remove_private_as_all_replace_as, | |
4818 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4819 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4820 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4821 | "Remove private ASNs in outbound updates\n" | |
4822 | "Apply to all AS numbers\n" | |
4823 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4824 | |
718e3744 | 4825 | DEFUN (no_neighbor_remove_private_as, |
4826 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4827 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4828 | NO_STR |
4829 | NEIGHBOR_STR | |
4830 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4831 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4832 | { |
d62a17ae | 4833 | int idx_peer = 2; |
4834 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4835 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4836 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4837 | } |
6b0655a2 | 4838 | |
d62a17ae | 4839 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4840 | no_neighbor_remove_private_as_hidden_cmd, | |
4841 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4842 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4843 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4844 | |
88b8ed8d | 4845 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4846 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4847 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4848 | NO_STR |
4849 | NEIGHBOR_STR | |
4850 | NEIGHBOR_ADDR_STR2 | |
4851 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4852 | "Apply to all AS numbers\n") |
88b8ed8d | 4853 | { |
d62a17ae | 4854 | int idx_peer = 2; |
4855 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4856 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4857 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4858 | } |
5000f21c | 4859 | |
d62a17ae | 4860 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4861 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4862 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4863 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4864 | "Remove private ASNs in outbound updates\n" | |
4865 | "Apply to all AS numbers\n") | |
596c17ba | 4866 | |
88b8ed8d | 4867 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4868 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4869 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4870 | NO_STR |
4871 | NEIGHBOR_STR | |
4872 | NEIGHBOR_ADDR_STR2 | |
4873 | "Remove private ASNs in outbound updates\n" | |
4874 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4875 | { |
d62a17ae | 4876 | int idx_peer = 2; |
4877 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4878 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4879 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4880 | } |
5000f21c | 4881 | |
d62a17ae | 4882 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4883 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4885 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4886 | "Remove private ASNs in outbound updates\n" | |
4887 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4888 | |
88b8ed8d | 4889 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4890 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4891 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4892 | NO_STR |
4893 | NEIGHBOR_STR | |
4894 | NEIGHBOR_ADDR_STR2 | |
4895 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4896 | "Apply to all AS numbers\n" |
5000f21c | 4897 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4898 | { |
d62a17ae | 4899 | int idx_peer = 2; |
4900 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4901 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4902 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4903 | } |
5000f21c | 4904 | |
d62a17ae | 4905 | ALIAS_HIDDEN( |
4906 | no_neighbor_remove_private_as_all_replace_as, | |
4907 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4908 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4909 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4910 | "Remove private ASNs in outbound updates\n" | |
4911 | "Apply to all AS numbers\n" | |
4912 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4913 | |
5000f21c | 4914 | |
718e3744 | 4915 | /* neighbor send-community. */ |
4916 | DEFUN (neighbor_send_community, | |
4917 | neighbor_send_community_cmd, | |
9ccf14f7 | 4918 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4919 | NEIGHBOR_STR |
4920 | NEIGHBOR_ADDR_STR2 | |
4921 | "Send Community attribute to this neighbor\n") | |
4922 | { | |
d62a17ae | 4923 | int idx_peer = 1; |
27c05d4d | 4924 | |
d62a17ae | 4925 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4926 | bgp_node_safi(vty), | |
4927 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4928 | } |
4929 | ||
d62a17ae | 4930 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4931 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4932 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4933 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4934 | |
718e3744 | 4935 | DEFUN (no_neighbor_send_community, |
4936 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4937 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4938 | NO_STR |
4939 | NEIGHBOR_STR | |
4940 | NEIGHBOR_ADDR_STR2 | |
4941 | "Send Community attribute to this neighbor\n") | |
4942 | { | |
d62a17ae | 4943 | int idx_peer = 2; |
27c05d4d | 4944 | |
d62a17ae | 4945 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4946 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4947 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4948 | } |
6b0655a2 | 4949 | |
d62a17ae | 4950 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4951 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4952 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4953 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4954 | |
718e3744 | 4955 | /* neighbor send-community extended. */ |
4956 | DEFUN (neighbor_send_community_type, | |
4957 | neighbor_send_community_type_cmd, | |
57d187bc | 4958 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4959 | NEIGHBOR_STR |
4960 | NEIGHBOR_ADDR_STR2 | |
4961 | "Send Community attribute to this neighbor\n" | |
4962 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4963 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4964 | "Send Extended Community attributes\n" |
57d187bc JS |
4965 | "Send Standard Community attributes\n" |
4966 | "Send Large Community attributes\n") | |
718e3744 | 4967 | { |
27c05d4d | 4968 | int idx_peer = 1; |
d7c0a89a | 4969 | uint32_t flag = 0; |
27c05d4d | 4970 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4971 | |
27c05d4d | 4972 | if (strmatch(type, "standard")) { |
d62a17ae | 4973 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4974 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4975 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4976 | } else if (strmatch(type, "large")) { |
d62a17ae | 4977 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4978 | } else if (strmatch(type, "both")) { |
d62a17ae | 4979 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4980 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4981 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4982 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4983 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4984 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4985 | } | |
4986 | ||
27c05d4d | 4987 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4988 | bgp_node_safi(vty), flag); |
4989 | } | |
4990 | ||
4991 | ALIAS_HIDDEN( | |
4992 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4993 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4994 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4995 | "Send Community attribute to this neighbor\n" | |
4996 | "Send Standard and Extended Community attributes\n" | |
4997 | "Send Standard, Large and Extended Community attributes\n" | |
4998 | "Send Extended Community attributes\n" | |
4999 | "Send Standard Community attributes\n" | |
5000 | "Send Large Community attributes\n") | |
596c17ba | 5001 | |
718e3744 | 5002 | DEFUN (no_neighbor_send_community_type, |
5003 | no_neighbor_send_community_type_cmd, | |
57d187bc | 5004 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5005 | NO_STR |
5006 | NEIGHBOR_STR | |
5007 | NEIGHBOR_ADDR_STR2 | |
5008 | "Send Community attribute to this neighbor\n" | |
5009 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5010 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5011 | "Send Extended Community attributes\n" |
57d187bc JS |
5012 | "Send Standard Community attributes\n" |
5013 | "Send Large Community attributes\n") | |
718e3744 | 5014 | { |
d62a17ae | 5015 | int idx_peer = 2; |
27c05d4d | 5016 | uint32_t flag = 0; |
d62a17ae | 5017 | const char *type = argv[argc - 1]->text; |
5018 | ||
27c05d4d PM |
5019 | if (strmatch(type, "standard")) { |
5020 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
5021 | } else if (strmatch(type, "extended")) { | |
5022 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
5023 | } else if (strmatch(type, "large")) { | |
5024 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5025 | } else if (strmatch(type, "both")) { | |
5026 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
5027 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
5028 | } else { /* if (strmatch(type, "all")) */ | |
5029 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
5030 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
5031 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5032 | } | |
5033 | ||
5034 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5035 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5036 | flag); | |
d62a17ae | 5037 | } |
5038 | ||
5039 | ALIAS_HIDDEN( | |
5040 | no_neighbor_send_community_type, | |
5041 | no_neighbor_send_community_type_hidden_cmd, | |
5042 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5043 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5044 | "Send Community attribute to this neighbor\n" | |
5045 | "Send Standard and Extended Community attributes\n" | |
5046 | "Send Standard, Large and Extended Community attributes\n" | |
5047 | "Send Extended Community attributes\n" | |
5048 | "Send Standard Community attributes\n" | |
5049 | "Send Large Community attributes\n") | |
596c17ba | 5050 | |
718e3744 | 5051 | /* neighbor soft-reconfig. */ |
5052 | DEFUN (neighbor_soft_reconfiguration, | |
5053 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5054 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5055 | NEIGHBOR_STR |
5056 | NEIGHBOR_ADDR_STR2 | |
5057 | "Per neighbor soft reconfiguration\n" | |
5058 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5059 | { | |
d62a17ae | 5060 | int idx_peer = 1; |
5061 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5062 | bgp_node_safi(vty), | |
5063 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5064 | } |
5065 | ||
d62a17ae | 5066 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5067 | neighbor_soft_reconfiguration_hidden_cmd, | |
5068 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5069 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5070 | "Per neighbor soft reconfiguration\n" | |
5071 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5072 | |
718e3744 | 5073 | DEFUN (no_neighbor_soft_reconfiguration, |
5074 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5075 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5076 | NO_STR |
5077 | NEIGHBOR_STR | |
5078 | NEIGHBOR_ADDR_STR2 | |
5079 | "Per neighbor soft reconfiguration\n" | |
5080 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5081 | { | |
d62a17ae | 5082 | int idx_peer = 2; |
5083 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5084 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5085 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5086 | } |
6b0655a2 | 5087 | |
d62a17ae | 5088 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5089 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5090 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5091 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5092 | "Per neighbor soft reconfiguration\n" | |
5093 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5094 | |
718e3744 | 5095 | DEFUN (neighbor_route_reflector_client, |
5096 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5097 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5098 | NEIGHBOR_STR |
5099 | NEIGHBOR_ADDR_STR2 | |
5100 | "Configure a neighbor as Route Reflector client\n") | |
5101 | { | |
d62a17ae | 5102 | int idx_peer = 1; |
5103 | struct peer *peer; | |
718e3744 | 5104 | |
5105 | ||
d62a17ae | 5106 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5107 | if (!peer) | |
5108 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5109 | |
d62a17ae | 5110 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5111 | bgp_node_safi(vty), | |
5112 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5113 | } |
5114 | ||
d62a17ae | 5115 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5116 | neighbor_route_reflector_client_hidden_cmd, | |
5117 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5118 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5119 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5120 | |
718e3744 | 5121 | DEFUN (no_neighbor_route_reflector_client, |
5122 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5123 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5124 | NO_STR |
5125 | NEIGHBOR_STR | |
5126 | NEIGHBOR_ADDR_STR2 | |
5127 | "Configure a neighbor as Route Reflector client\n") | |
5128 | { | |
d62a17ae | 5129 | int idx_peer = 2; |
5130 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5131 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5132 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5133 | } |
6b0655a2 | 5134 | |
d62a17ae | 5135 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5136 | no_neighbor_route_reflector_client_hidden_cmd, | |
5137 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5138 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5139 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5140 | |
718e3744 | 5141 | /* neighbor route-server-client. */ |
5142 | DEFUN (neighbor_route_server_client, | |
5143 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5144 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5145 | NEIGHBOR_STR |
5146 | NEIGHBOR_ADDR_STR2 | |
5147 | "Configure a neighbor as Route Server client\n") | |
5148 | { | |
d62a17ae | 5149 | int idx_peer = 1; |
5150 | struct peer *peer; | |
2a3d5731 | 5151 | |
d62a17ae | 5152 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5153 | if (!peer) | |
5154 | return CMD_WARNING_CONFIG_FAILED; | |
5155 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5156 | bgp_node_safi(vty), | |
5157 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5158 | } |
5159 | ||
d62a17ae | 5160 | ALIAS_HIDDEN(neighbor_route_server_client, |
5161 | neighbor_route_server_client_hidden_cmd, | |
5162 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5163 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5164 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5165 | |
718e3744 | 5166 | DEFUN (no_neighbor_route_server_client, |
5167 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5168 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5169 | NO_STR |
5170 | NEIGHBOR_STR | |
5171 | NEIGHBOR_ADDR_STR2 | |
5172 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5173 | { |
d62a17ae | 5174 | int idx_peer = 2; |
5175 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5176 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5177 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5178 | } |
6b0655a2 | 5179 | |
d62a17ae | 5180 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5181 | no_neighbor_route_server_client_hidden_cmd, | |
5182 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5183 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5184 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5185 | |
fee0f4c6 | 5186 | DEFUN (neighbor_nexthop_local_unchanged, |
5187 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5188 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5189 | NEIGHBOR_STR |
5190 | NEIGHBOR_ADDR_STR2 | |
5191 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5192 | "Leave link-local nexthop unchanged for this peer\n") | |
5193 | { | |
d62a17ae | 5194 | int idx_peer = 1; |
5195 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5196 | bgp_node_safi(vty), | |
5197 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5198 | } |
6b0655a2 | 5199 | |
fee0f4c6 | 5200 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5201 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5202 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5203 | NO_STR |
5204 | NEIGHBOR_STR | |
5205 | NEIGHBOR_ADDR_STR2 | |
5206 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5207 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5208 | { |
d62a17ae | 5209 | int idx_peer = 2; |
5210 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5211 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5212 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5213 | } |
6b0655a2 | 5214 | |
718e3744 | 5215 | DEFUN (neighbor_attr_unchanged, |
5216 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5217 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5218 | NEIGHBOR_STR |
5219 | NEIGHBOR_ADDR_STR2 | |
5220 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5221 | "As-path attribute\n" | |
5222 | "Nexthop attribute\n" | |
a8206004 | 5223 | "Med attribute\n") |
718e3744 | 5224 | { |
d62a17ae | 5225 | int idx = 0; |
8eeb0335 DW |
5226 | char *peer_str = argv[1]->arg; |
5227 | struct peer *peer; | |
d7c0a89a | 5228 | uint16_t flags = 0; |
8eeb0335 DW |
5229 | afi_t afi = bgp_node_afi(vty); |
5230 | safi_t safi = bgp_node_safi(vty); | |
5231 | ||
5232 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5233 | if (!peer) | |
5234 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5235 | |
5236 | if (argv_find(argv, argc, "as-path", &idx)) | |
5237 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5238 | idx = 0; | |
5239 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5240 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5241 | idx = 0; | |
5242 | if (argv_find(argv, argc, "med", &idx)) | |
5243 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5244 | ||
8eeb0335 DW |
5245 | /* no flags means all of them! */ |
5246 | if (!flags) { | |
d62a17ae | 5247 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
5248 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5249 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5250 | } else { |
a4d82a8a PZ |
5251 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
5252 | && peer_af_flag_check(peer, afi, safi, | |
5253 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
5254 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5255 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5256 | } | |
5257 | ||
a4d82a8a PZ |
5258 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
5259 | && peer_af_flag_check(peer, afi, safi, | |
5260 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
5261 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5262 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5263 | } | |
5264 | ||
a4d82a8a PZ |
5265 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
5266 | && peer_af_flag_check(peer, afi, safi, | |
5267 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
5268 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5269 | PEER_FLAG_MED_UNCHANGED); | |
5270 | } | |
d62a17ae | 5271 | } |
5272 | ||
8eeb0335 | 5273 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 5274 | } |
5275 | ||
5276 | ALIAS_HIDDEN( | |
5277 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5278 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5279 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5280 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5281 | "As-path attribute\n" | |
5282 | "Nexthop attribute\n" | |
5283 | "Med attribute\n") | |
596c17ba | 5284 | |
718e3744 | 5285 | DEFUN (no_neighbor_attr_unchanged, |
5286 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5287 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5288 | NO_STR |
718e3744 | 5289 | NEIGHBOR_STR |
5290 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5291 | "BGP attribute is propagated unchanged to this neighbor\n" |
5292 | "As-path attribute\n" | |
40e718b5 | 5293 | "Nexthop attribute\n" |
a8206004 | 5294 | "Med attribute\n") |
718e3744 | 5295 | { |
d62a17ae | 5296 | int idx = 0; |
5297 | char *peer = argv[2]->arg; | |
d7c0a89a | 5298 | uint16_t flags = 0; |
d62a17ae | 5299 | |
5300 | if (argv_find(argv, argc, "as-path", &idx)) | |
5301 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5302 | idx = 0; | |
5303 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5304 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5305 | idx = 0; | |
5306 | if (argv_find(argv, argc, "med", &idx)) | |
5307 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5308 | ||
5309 | if (!flags) // no flags means all of them! | |
5310 | { | |
5311 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5312 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5313 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5314 | } | |
5315 | ||
5316 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
5317 | bgp_node_safi(vty), flags); | |
5318 | } | |
5319 | ||
5320 | ALIAS_HIDDEN( | |
5321 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5322 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5323 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5324 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5325 | "As-path attribute\n" | |
5326 | "Nexthop attribute\n" | |
5327 | "Med attribute\n") | |
718e3744 | 5328 | |
718e3744 | 5329 | /* EBGP multihop configuration. */ |
d62a17ae | 5330 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5331 | const char *ttl_str) | |
718e3744 | 5332 | { |
d62a17ae | 5333 | struct peer *peer; |
5334 | unsigned int ttl; | |
718e3744 | 5335 | |
d62a17ae | 5336 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5337 | if (!peer) | |
5338 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5339 | |
d62a17ae | 5340 | if (peer->conf_if) |
5341 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5342 | |
d62a17ae | 5343 | if (!ttl_str) |
5344 | ttl = MAXTTL; | |
5345 | else | |
5346 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5347 | |
d62a17ae | 5348 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5349 | } |
5350 | ||
d62a17ae | 5351 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5352 | { |
d62a17ae | 5353 | struct peer *peer; |
718e3744 | 5354 | |
d62a17ae | 5355 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5356 | if (!peer) | |
5357 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5358 | |
d62a17ae | 5359 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5360 | } |
5361 | ||
5362 | /* neighbor ebgp-multihop. */ | |
5363 | DEFUN (neighbor_ebgp_multihop, | |
5364 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5365 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5366 | NEIGHBOR_STR |
5367 | NEIGHBOR_ADDR_STR2 | |
5368 | "Allow EBGP neighbors not on directly connected networks\n") | |
5369 | { | |
d62a17ae | 5370 | int idx_peer = 1; |
5371 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5372 | } |
5373 | ||
5374 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5375 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5376 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5377 | NEIGHBOR_STR |
5378 | NEIGHBOR_ADDR_STR2 | |
5379 | "Allow EBGP neighbors not on directly connected networks\n" | |
5380 | "maximum hop count\n") | |
5381 | { | |
d62a17ae | 5382 | int idx_peer = 1; |
5383 | int idx_number = 3; | |
5384 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5385 | argv[idx_number]->arg); | |
718e3744 | 5386 | } |
5387 | ||
5388 | DEFUN (no_neighbor_ebgp_multihop, | |
5389 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5390 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5391 | NO_STR |
5392 | NEIGHBOR_STR | |
5393 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5394 | "Allow EBGP neighbors not on directly connected networks\n" |
5395 | "maximum hop count\n") | |
718e3744 | 5396 | { |
d62a17ae | 5397 | int idx_peer = 2; |
5398 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5399 | } |
5400 | ||
6b0655a2 | 5401 | |
6ffd2079 | 5402 | /* disable-connected-check */ |
5403 | DEFUN (neighbor_disable_connected_check, | |
5404 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5405 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5406 | NEIGHBOR_STR |
7ebe625c | 5407 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5408 | "one-hop away EBGP peer using loopback address\n" |
5409 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5410 | { |
d62a17ae | 5411 | int idx_peer = 1; |
5412 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5413 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5414 | } |
5415 | ||
5416 | DEFUN (no_neighbor_disable_connected_check, | |
5417 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5418 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5419 | NO_STR |
5420 | NEIGHBOR_STR | |
7ebe625c | 5421 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5422 | "one-hop away EBGP peer using loopback address\n" |
5423 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5424 | { |
d62a17ae | 5425 | int idx_peer = 2; |
5426 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5427 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5428 | } |
5429 | ||
47cbc09b PM |
5430 | |
5431 | /* enforce-first-as */ | |
5432 | DEFUN (neighbor_enforce_first_as, | |
5433 | neighbor_enforce_first_as_cmd, | |
5434 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5435 | NEIGHBOR_STR | |
5436 | NEIGHBOR_ADDR_STR2 | |
5437 | "Enforce the first AS for EBGP routes\n") | |
5438 | { | |
5439 | int idx_peer = 1; | |
5440 | ||
5441 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5442 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5443 | } | |
5444 | ||
5445 | DEFUN (no_neighbor_enforce_first_as, | |
5446 | no_neighbor_enforce_first_as_cmd, | |
5447 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5448 | NO_STR | |
5449 | NEIGHBOR_STR | |
5450 | NEIGHBOR_ADDR_STR2 | |
5451 | "Enforce the first AS for EBGP routes\n") | |
5452 | { | |
5453 | int idx_peer = 2; | |
5454 | ||
5455 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5456 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5457 | } | |
5458 | ||
5459 | ||
718e3744 | 5460 | DEFUN (neighbor_description, |
5461 | neighbor_description_cmd, | |
e961923c | 5462 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5463 | NEIGHBOR_STR |
5464 | NEIGHBOR_ADDR_STR2 | |
5465 | "Neighbor specific description\n" | |
5466 | "Up to 80 characters describing this neighbor\n") | |
5467 | { | |
d62a17ae | 5468 | int idx_peer = 1; |
5469 | int idx_line = 3; | |
5470 | struct peer *peer; | |
5471 | char *str; | |
718e3744 | 5472 | |
d62a17ae | 5473 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5474 | if (!peer) | |
5475 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5476 | |
d62a17ae | 5477 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5478 | |
d62a17ae | 5479 | peer_description_set(peer, str); |
718e3744 | 5480 | |
d62a17ae | 5481 | XFREE(MTYPE_TMP, str); |
718e3744 | 5482 | |
d62a17ae | 5483 | return CMD_SUCCESS; |
718e3744 | 5484 | } |
5485 | ||
5486 | DEFUN (no_neighbor_description, | |
5487 | no_neighbor_description_cmd, | |
a14810f4 | 5488 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5489 | NO_STR |
5490 | NEIGHBOR_STR | |
5491 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5492 | "Neighbor specific description\n") |
718e3744 | 5493 | { |
d62a17ae | 5494 | int idx_peer = 2; |
5495 | struct peer *peer; | |
718e3744 | 5496 | |
d62a17ae | 5497 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5498 | if (!peer) | |
5499 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5500 | |
d62a17ae | 5501 | peer_description_unset(peer); |
718e3744 | 5502 | |
d62a17ae | 5503 | return CMD_SUCCESS; |
718e3744 | 5504 | } |
5505 | ||
a14810f4 PM |
5506 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5507 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5508 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5509 | "Neighbor specific description\n" | |
5510 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5511 | |
718e3744 | 5512 | /* Neighbor update-source. */ |
d62a17ae | 5513 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5514 | const char *source_str) | |
5515 | { | |
5516 | struct peer *peer; | |
5517 | struct prefix p; | |
a14810f4 | 5518 | union sockunion su; |
d62a17ae | 5519 | |
5520 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5521 | if (!peer) | |
5522 | return CMD_WARNING_CONFIG_FAILED; | |
5523 | ||
5524 | if (peer->conf_if) | |
5525 | return CMD_WARNING; | |
5526 | ||
5527 | if (source_str) { | |
a14810f4 | 5528 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5529 | peer_update_source_addr_set(peer, &su); |
5530 | else { | |
5531 | if (str2prefix(source_str, &p)) { | |
5532 | vty_out(vty, | |
5533 | "%% Invalid update-source, remove prefix length \n"); | |
5534 | return CMD_WARNING_CONFIG_FAILED; | |
5535 | } else | |
5536 | peer_update_source_if_set(peer, source_str); | |
5537 | } | |
5538 | } else | |
5539 | peer_update_source_unset(peer); | |
5540 | ||
5541 | return CMD_SUCCESS; | |
5542 | } | |
5543 | ||
5544 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5545 | "IPv4 address\n" \ | |
5546 | "IPv6 address\n" \ | |
5547 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5548 | |
718e3744 | 5549 | DEFUN (neighbor_update_source, |
5550 | neighbor_update_source_cmd, | |
9ccf14f7 | 5551 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5552 | NEIGHBOR_STR |
5553 | NEIGHBOR_ADDR_STR2 | |
5554 | "Source of routing updates\n" | |
369688c0 | 5555 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5556 | { |
d62a17ae | 5557 | int idx_peer = 1; |
5558 | int idx_peer_2 = 3; | |
5559 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5560 | argv[idx_peer_2]->arg); | |
718e3744 | 5561 | } |
5562 | ||
5563 | DEFUN (no_neighbor_update_source, | |
5564 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5565 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5566 | NO_STR |
5567 | NEIGHBOR_STR | |
5568 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5569 | "Source of routing updates\n" |
5570 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5571 | { |
d62a17ae | 5572 | int idx_peer = 2; |
5573 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5574 | } |
6b0655a2 | 5575 | |
d62a17ae | 5576 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5577 | afi_t afi, safi_t safi, | |
5578 | const char *rmap, int set) | |
718e3744 | 5579 | { |
d62a17ae | 5580 | int ret; |
5581 | struct peer *peer; | |
80912664 | 5582 | struct route_map *route_map = NULL; |
718e3744 | 5583 | |
d62a17ae | 5584 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5585 | if (!peer) | |
5586 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5587 | |
1de27621 | 5588 | if (set) { |
80912664 DS |
5589 | if (rmap) |
5590 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5591 | ret = peer_default_originate_set(peer, afi, safi, |
5592 | rmap, route_map); | |
5593 | } else | |
d62a17ae | 5594 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5595 | |
d62a17ae | 5596 | return bgp_vty_return(vty, ret); |
718e3744 | 5597 | } |
5598 | ||
5599 | /* neighbor default-originate. */ | |
5600 | DEFUN (neighbor_default_originate, | |
5601 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5602 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5603 | NEIGHBOR_STR |
5604 | NEIGHBOR_ADDR_STR2 | |
5605 | "Originate default route to this neighbor\n") | |
5606 | { | |
d62a17ae | 5607 | int idx_peer = 1; |
5608 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5609 | bgp_node_afi(vty), | |
5610 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5611 | } |
5612 | ||
d62a17ae | 5613 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5614 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5615 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5616 | "Originate default route to this neighbor\n") | |
596c17ba | 5617 | |
718e3744 | 5618 | DEFUN (neighbor_default_originate_rmap, |
5619 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5620 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5621 | NEIGHBOR_STR |
5622 | NEIGHBOR_ADDR_STR2 | |
5623 | "Originate default route to this neighbor\n" | |
5624 | "Route-map to specify criteria to originate default\n" | |
5625 | "route-map name\n") | |
5626 | { | |
d62a17ae | 5627 | int idx_peer = 1; |
5628 | int idx_word = 4; | |
5629 | return peer_default_originate_set_vty( | |
5630 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5631 | argv[idx_word]->arg, 1); | |
718e3744 | 5632 | } |
5633 | ||
d62a17ae | 5634 | ALIAS_HIDDEN( |
5635 | neighbor_default_originate_rmap, | |
5636 | neighbor_default_originate_rmap_hidden_cmd, | |
5637 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5638 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5639 | "Originate default route to this neighbor\n" | |
5640 | "Route-map to specify criteria to originate default\n" | |
5641 | "route-map name\n") | |
596c17ba | 5642 | |
718e3744 | 5643 | DEFUN (no_neighbor_default_originate, |
5644 | no_neighbor_default_originate_cmd, | |
a636c635 | 5645 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5646 | NO_STR |
5647 | NEIGHBOR_STR | |
5648 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5649 | "Originate default route to this neighbor\n" |
5650 | "Route-map to specify criteria to originate default\n" | |
5651 | "route-map name\n") | |
718e3744 | 5652 | { |
d62a17ae | 5653 | int idx_peer = 2; |
5654 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5655 | bgp_node_afi(vty), | |
5656 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5657 | } |
5658 | ||
d62a17ae | 5659 | ALIAS_HIDDEN( |
5660 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5661 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5662 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5663 | "Originate default route to this neighbor\n" | |
5664 | "Route-map to specify criteria to originate default\n" | |
5665 | "route-map name\n") | |
596c17ba | 5666 | |
6b0655a2 | 5667 | |
718e3744 | 5668 | /* Set neighbor's BGP port. */ |
d62a17ae | 5669 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5670 | const char *port_str) | |
5671 | { | |
5672 | struct peer *peer; | |
d7c0a89a | 5673 | uint16_t port; |
d62a17ae | 5674 | struct servent *sp; |
5675 | ||
5676 | peer = peer_lookup_vty(vty, ip_str); | |
5677 | if (!peer) | |
5678 | return CMD_WARNING_CONFIG_FAILED; | |
5679 | ||
5680 | if (!port_str) { | |
5681 | sp = getservbyname("bgp", "tcp"); | |
5682 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5683 | } else { | |
5684 | port = strtoul(port_str, NULL, 10); | |
5685 | } | |
718e3744 | 5686 | |
d62a17ae | 5687 | peer_port_set(peer, port); |
718e3744 | 5688 | |
d62a17ae | 5689 | return CMD_SUCCESS; |
718e3744 | 5690 | } |
5691 | ||
f418446b | 5692 | /* Set specified peer's BGP port. */ |
718e3744 | 5693 | DEFUN (neighbor_port, |
5694 | neighbor_port_cmd, | |
9ccf14f7 | 5695 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5696 | NEIGHBOR_STR |
5697 | NEIGHBOR_ADDR_STR | |
5698 | "Neighbor's BGP port\n" | |
5699 | "TCP port number\n") | |
5700 | { | |
d62a17ae | 5701 | int idx_ip = 1; |
5702 | int idx_number = 3; | |
5703 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5704 | argv[idx_number]->arg); | |
718e3744 | 5705 | } |
5706 | ||
5707 | DEFUN (no_neighbor_port, | |
5708 | no_neighbor_port_cmd, | |
9ccf14f7 | 5709 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5710 | NO_STR |
5711 | NEIGHBOR_STR | |
5712 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5713 | "Neighbor's BGP port\n" |
5714 | "TCP port number\n") | |
718e3744 | 5715 | { |
d62a17ae | 5716 | int idx_ip = 2; |
5717 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5718 | } |
5719 | ||
6b0655a2 | 5720 | |
718e3744 | 5721 | /* neighbor weight. */ |
d62a17ae | 5722 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5723 | safi_t safi, const char *weight_str) | |
718e3744 | 5724 | { |
d62a17ae | 5725 | int ret; |
5726 | struct peer *peer; | |
5727 | unsigned long weight; | |
718e3744 | 5728 | |
d62a17ae | 5729 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5730 | if (!peer) | |
5731 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5732 | |
d62a17ae | 5733 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5734 | |
d62a17ae | 5735 | ret = peer_weight_set(peer, afi, safi, weight); |
5736 | return bgp_vty_return(vty, ret); | |
718e3744 | 5737 | } |
5738 | ||
d62a17ae | 5739 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5740 | safi_t safi) | |
718e3744 | 5741 | { |
d62a17ae | 5742 | int ret; |
5743 | struct peer *peer; | |
718e3744 | 5744 | |
d62a17ae | 5745 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5746 | if (!peer) | |
5747 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5748 | |
d62a17ae | 5749 | ret = peer_weight_unset(peer, afi, safi); |
5750 | return bgp_vty_return(vty, ret); | |
718e3744 | 5751 | } |
5752 | ||
5753 | DEFUN (neighbor_weight, | |
5754 | neighbor_weight_cmd, | |
9ccf14f7 | 5755 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5756 | NEIGHBOR_STR |
5757 | NEIGHBOR_ADDR_STR2 | |
5758 | "Set default weight for routes from this neighbor\n" | |
5759 | "default weight\n") | |
5760 | { | |
d62a17ae | 5761 | int idx_peer = 1; |
5762 | int idx_number = 3; | |
5763 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5764 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5765 | } |
5766 | ||
d62a17ae | 5767 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5768 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5769 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5770 | "Set default weight for routes from this neighbor\n" | |
5771 | "default weight\n") | |
596c17ba | 5772 | |
718e3744 | 5773 | DEFUN (no_neighbor_weight, |
5774 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5775 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5776 | NO_STR |
5777 | NEIGHBOR_STR | |
5778 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5779 | "Set default weight for routes from this neighbor\n" |
5780 | "default weight\n") | |
718e3744 | 5781 | { |
d62a17ae | 5782 | int idx_peer = 2; |
5783 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5784 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5785 | } |
5786 | ||
d62a17ae | 5787 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5788 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5789 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5790 | "Set default weight for routes from this neighbor\n" | |
5791 | "default weight\n") | |
596c17ba | 5792 | |
6b0655a2 | 5793 | |
718e3744 | 5794 | /* Override capability negotiation. */ |
5795 | DEFUN (neighbor_override_capability, | |
5796 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5797 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5798 | NEIGHBOR_STR |
5799 | NEIGHBOR_ADDR_STR2 | |
5800 | "Override capability negotiation result\n") | |
5801 | { | |
d62a17ae | 5802 | int idx_peer = 1; |
5803 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5804 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5805 | } |
5806 | ||
5807 | DEFUN (no_neighbor_override_capability, | |
5808 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5809 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5810 | NO_STR |
5811 | NEIGHBOR_STR | |
5812 | NEIGHBOR_ADDR_STR2 | |
5813 | "Override capability negotiation result\n") | |
5814 | { | |
d62a17ae | 5815 | int idx_peer = 2; |
5816 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5817 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5818 | } |
6b0655a2 | 5819 | |
718e3744 | 5820 | DEFUN (neighbor_strict_capability, |
5821 | neighbor_strict_capability_cmd, | |
9fb964de | 5822 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5823 | NEIGHBOR_STR |
9fb964de | 5824 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5825 | "Strict capability negotiation match\n") |
5826 | { | |
9fb964de PM |
5827 | int idx_peer = 1; |
5828 | ||
5829 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5830 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5831 | } |
5832 | ||
5833 | DEFUN (no_neighbor_strict_capability, | |
5834 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5835 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5836 | NO_STR |
5837 | NEIGHBOR_STR | |
9fb964de | 5838 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5839 | "Strict capability negotiation match\n") |
5840 | { | |
9fb964de PM |
5841 | int idx_peer = 2; |
5842 | ||
5843 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5844 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5845 | } |
6b0655a2 | 5846 | |
d62a17ae | 5847 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5848 | const char *keep_str, const char *hold_str) | |
718e3744 | 5849 | { |
d62a17ae | 5850 | int ret; |
5851 | struct peer *peer; | |
d7c0a89a QY |
5852 | uint32_t keepalive; |
5853 | uint32_t holdtime; | |
718e3744 | 5854 | |
d62a17ae | 5855 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5856 | if (!peer) | |
5857 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5858 | |
d62a17ae | 5859 | keepalive = strtoul(keep_str, NULL, 10); |
5860 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5861 | |
d62a17ae | 5862 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5863 | |
d62a17ae | 5864 | return bgp_vty_return(vty, ret); |
718e3744 | 5865 | } |
6b0655a2 | 5866 | |
d62a17ae | 5867 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5868 | { |
d62a17ae | 5869 | int ret; |
5870 | struct peer *peer; | |
718e3744 | 5871 | |
d62a17ae | 5872 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5873 | if (!peer) | |
5874 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5875 | |
d62a17ae | 5876 | ret = peer_timers_unset(peer); |
718e3744 | 5877 | |
d62a17ae | 5878 | return bgp_vty_return(vty, ret); |
718e3744 | 5879 | } |
5880 | ||
5881 | DEFUN (neighbor_timers, | |
5882 | neighbor_timers_cmd, | |
9ccf14f7 | 5883 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5884 | NEIGHBOR_STR |
5885 | NEIGHBOR_ADDR_STR2 | |
5886 | "BGP per neighbor timers\n" | |
5887 | "Keepalive interval\n" | |
5888 | "Holdtime\n") | |
5889 | { | |
d62a17ae | 5890 | int idx_peer = 1; |
5891 | int idx_number = 3; | |
5892 | int idx_number_2 = 4; | |
5893 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5894 | argv[idx_number]->arg, | |
5895 | argv[idx_number_2]->arg); | |
718e3744 | 5896 | } |
5897 | ||
5898 | DEFUN (no_neighbor_timers, | |
5899 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5900 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5901 | NO_STR |
5902 | NEIGHBOR_STR | |
5903 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5904 | "BGP per neighbor timers\n" |
5905 | "Keepalive interval\n" | |
5906 | "Holdtime\n") | |
718e3744 | 5907 | { |
d62a17ae | 5908 | int idx_peer = 2; |
5909 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5910 | } |
6b0655a2 | 5911 | |
813d4307 | 5912 | |
d62a17ae | 5913 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5914 | const char *time_str) | |
718e3744 | 5915 | { |
d62a17ae | 5916 | int ret; |
5917 | struct peer *peer; | |
d7c0a89a | 5918 | uint32_t connect; |
718e3744 | 5919 | |
d62a17ae | 5920 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5921 | if (!peer) | |
5922 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5923 | |
d62a17ae | 5924 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5925 | |
d62a17ae | 5926 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5927 | |
d62a17ae | 5928 | return bgp_vty_return(vty, ret); |
718e3744 | 5929 | } |
5930 | ||
d62a17ae | 5931 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5932 | { |
d62a17ae | 5933 | int ret; |
5934 | struct peer *peer; | |
718e3744 | 5935 | |
d62a17ae | 5936 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5937 | if (!peer) | |
5938 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5939 | |
d62a17ae | 5940 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5941 | |
d62a17ae | 5942 | return bgp_vty_return(vty, ret); |
718e3744 | 5943 | } |
5944 | ||
5945 | DEFUN (neighbor_timers_connect, | |
5946 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5947 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5948 | NEIGHBOR_STR |
966f821c | 5949 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5950 | "BGP per neighbor timers\n" |
5951 | "BGP connect timer\n" | |
5952 | "Connect timer\n") | |
5953 | { | |
d62a17ae | 5954 | int idx_peer = 1; |
5955 | int idx_number = 4; | |
5956 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5957 | argv[idx_number]->arg); | |
718e3744 | 5958 | } |
5959 | ||
5960 | DEFUN (no_neighbor_timers_connect, | |
5961 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5962 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5963 | NO_STR |
5964 | NEIGHBOR_STR | |
966f821c | 5965 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5966 | "BGP per neighbor timers\n" |
8334fd5a DW |
5967 | "BGP connect timer\n" |
5968 | "Connect timer\n") | |
718e3744 | 5969 | { |
d62a17ae | 5970 | int idx_peer = 2; |
5971 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5972 | } |
5973 | ||
6b0655a2 | 5974 | |
d62a17ae | 5975 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5976 | const char *time_str, int set) | |
718e3744 | 5977 | { |
d62a17ae | 5978 | int ret; |
5979 | struct peer *peer; | |
d7c0a89a | 5980 | uint32_t routeadv = 0; |
718e3744 | 5981 | |
d62a17ae | 5982 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5983 | if (!peer) | |
5984 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5985 | |
d62a17ae | 5986 | if (time_str) |
5987 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5988 | |
d62a17ae | 5989 | if (set) |
5990 | ret = peer_advertise_interval_set(peer, routeadv); | |
5991 | else | |
5992 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5993 | |
d62a17ae | 5994 | return bgp_vty_return(vty, ret); |
718e3744 | 5995 | } |
5996 | ||
5997 | DEFUN (neighbor_advertise_interval, | |
5998 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5999 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 6000 | NEIGHBOR_STR |
966f821c | 6001 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6002 | "Minimum interval between sending BGP routing updates\n" |
6003 | "time in seconds\n") | |
6004 | { | |
d62a17ae | 6005 | int idx_peer = 1; |
6006 | int idx_number = 3; | |
6007 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6008 | argv[idx_number]->arg, 1); | |
718e3744 | 6009 | } |
6010 | ||
6011 | DEFUN (no_neighbor_advertise_interval, | |
6012 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6013 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 6014 | NO_STR |
6015 | NEIGHBOR_STR | |
966f821c | 6016 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
6017 | "Minimum interval between sending BGP routing updates\n" |
6018 | "time in seconds\n") | |
718e3744 | 6019 | { |
d62a17ae | 6020 | int idx_peer = 2; |
6021 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6022 | } |
6023 | ||
6b0655a2 | 6024 | |
518f0eb1 DS |
6025 | /* Time to wait before processing route-map updates */ |
6026 | DEFUN (bgp_set_route_map_delay_timer, | |
6027 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6028 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6029 | SET_STR |
6030 | "BGP route-map delay timer\n" | |
6031 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6032 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6033 | { |
d62a17ae | 6034 | int idx_number = 3; |
d7c0a89a | 6035 | uint32_t rmap_delay_timer; |
d62a17ae | 6036 | |
6037 | if (argv[idx_number]->arg) { | |
6038 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6039 | bm->rmap_update_timer = rmap_delay_timer; | |
6040 | ||
6041 | /* if the dynamic update handling is being disabled, and a timer | |
6042 | * is | |
6043 | * running, stop the timer and act as if the timer has already | |
6044 | * fired. | |
6045 | */ | |
6046 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6047 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6048 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6049 | NULL, 0); | |
6050 | } | |
6051 | return CMD_SUCCESS; | |
6052 | } else { | |
6053 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6054 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6055 | } |
518f0eb1 DS |
6056 | } |
6057 | ||
6058 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6059 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6060 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6061 | NO_STR |
3a2d747c | 6062 | BGP_STR |
518f0eb1 | 6063 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6064 | "Reset to default time to wait for processing route-map changes\n" |
6065 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6066 | { |
518f0eb1 | 6067 | |
d62a17ae | 6068 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6069 | |
d62a17ae | 6070 | return CMD_SUCCESS; |
518f0eb1 DS |
6071 | } |
6072 | ||
f414725f | 6073 | |
718e3744 | 6074 | /* neighbor interface */ |
d62a17ae | 6075 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6076 | const char *str) | |
718e3744 | 6077 | { |
d62a17ae | 6078 | struct peer *peer; |
718e3744 | 6079 | |
d62a17ae | 6080 | peer = peer_lookup_vty(vty, ip_str); |
6081 | if (!peer || peer->conf_if) { | |
6082 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6083 | return CMD_WARNING_CONFIG_FAILED; | |
6084 | } | |
718e3744 | 6085 | |
d62a17ae | 6086 | if (str) |
6087 | peer_interface_set(peer, str); | |
6088 | else | |
6089 | peer_interface_unset(peer); | |
718e3744 | 6090 | |
d62a17ae | 6091 | return CMD_SUCCESS; |
718e3744 | 6092 | } |
6093 | ||
6094 | DEFUN (neighbor_interface, | |
6095 | neighbor_interface_cmd, | |
9ccf14f7 | 6096 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6097 | NEIGHBOR_STR |
6098 | NEIGHBOR_ADDR_STR | |
6099 | "Interface\n" | |
6100 | "Interface name\n") | |
6101 | { | |
d62a17ae | 6102 | int idx_ip = 1; |
6103 | int idx_word = 3; | |
6104 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6105 | } |
6106 | ||
6107 | DEFUN (no_neighbor_interface, | |
6108 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6109 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6110 | NO_STR |
6111 | NEIGHBOR_STR | |
16cedbb0 | 6112 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6113 | "Interface\n" |
6114 | "Interface name\n") | |
6115 | { | |
d62a17ae | 6116 | int idx_peer = 2; |
6117 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6118 | } |
6b0655a2 | 6119 | |
718e3744 | 6120 | DEFUN (neighbor_distribute_list, |
6121 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6122 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6123 | NEIGHBOR_STR |
6124 | NEIGHBOR_ADDR_STR2 | |
6125 | "Filter updates to/from this neighbor\n" | |
6126 | "IP access-list number\n" | |
6127 | "IP access-list number (expanded range)\n" | |
6128 | "IP Access-list name\n" | |
6129 | "Filter incoming updates\n" | |
6130 | "Filter outgoing updates\n") | |
6131 | { | |
d62a17ae | 6132 | int idx_peer = 1; |
6133 | int idx_acl = 3; | |
6134 | int direct, ret; | |
6135 | struct peer *peer; | |
a8206004 | 6136 | |
d62a17ae | 6137 | const char *pstr = argv[idx_peer]->arg; |
6138 | const char *acl = argv[idx_acl]->arg; | |
6139 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6140 | |
d62a17ae | 6141 | peer = peer_and_group_lookup_vty(vty, pstr); |
6142 | if (!peer) | |
6143 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6144 | |
d62a17ae | 6145 | /* Check filter direction. */ |
6146 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6147 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6148 | direct, acl); | |
a8206004 | 6149 | |
d62a17ae | 6150 | return bgp_vty_return(vty, ret); |
718e3744 | 6151 | } |
6152 | ||
d62a17ae | 6153 | ALIAS_HIDDEN( |
6154 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6155 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6156 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6157 | "Filter updates to/from this neighbor\n" | |
6158 | "IP access-list number\n" | |
6159 | "IP access-list number (expanded range)\n" | |
6160 | "IP Access-list name\n" | |
6161 | "Filter incoming updates\n" | |
6162 | "Filter outgoing updates\n") | |
596c17ba | 6163 | |
718e3744 | 6164 | DEFUN (no_neighbor_distribute_list, |
6165 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6166 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6167 | NO_STR |
6168 | NEIGHBOR_STR | |
6169 | NEIGHBOR_ADDR_STR2 | |
6170 | "Filter updates to/from this neighbor\n" | |
6171 | "IP access-list number\n" | |
6172 | "IP access-list number (expanded range)\n" | |
6173 | "IP Access-list name\n" | |
6174 | "Filter incoming updates\n" | |
6175 | "Filter outgoing updates\n") | |
6176 | { | |
d62a17ae | 6177 | int idx_peer = 2; |
6178 | int direct, ret; | |
6179 | struct peer *peer; | |
a8206004 | 6180 | |
d62a17ae | 6181 | const char *pstr = argv[idx_peer]->arg; |
6182 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6183 | |
d62a17ae | 6184 | peer = peer_and_group_lookup_vty(vty, pstr); |
6185 | if (!peer) | |
6186 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6187 | |
d62a17ae | 6188 | /* Check filter direction. */ |
6189 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6190 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6191 | direct); | |
a8206004 | 6192 | |
d62a17ae | 6193 | return bgp_vty_return(vty, ret); |
718e3744 | 6194 | } |
6b0655a2 | 6195 | |
d62a17ae | 6196 | ALIAS_HIDDEN( |
6197 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6198 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6199 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6200 | "Filter updates to/from this neighbor\n" | |
6201 | "IP access-list number\n" | |
6202 | "IP access-list number (expanded range)\n" | |
6203 | "IP Access-list name\n" | |
6204 | "Filter incoming updates\n" | |
6205 | "Filter outgoing updates\n") | |
596c17ba | 6206 | |
718e3744 | 6207 | /* Set prefix list to the peer. */ |
d62a17ae | 6208 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6209 | afi_t afi, safi_t safi, | |
6210 | const char *name_str, | |
6211 | const char *direct_str) | |
718e3744 | 6212 | { |
d62a17ae | 6213 | int ret; |
d62a17ae | 6214 | int direct = FILTER_IN; |
cf9ac8bf | 6215 | struct peer *peer; |
718e3744 | 6216 | |
d62a17ae | 6217 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6218 | if (!peer) | |
6219 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6220 | |
d62a17ae | 6221 | /* Check filter direction. */ |
6222 | if (strncmp(direct_str, "i", 1) == 0) | |
6223 | direct = FILTER_IN; | |
6224 | else if (strncmp(direct_str, "o", 1) == 0) | |
6225 | direct = FILTER_OUT; | |
718e3744 | 6226 | |
d62a17ae | 6227 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6228 | |
d62a17ae | 6229 | return bgp_vty_return(vty, ret); |
718e3744 | 6230 | } |
6231 | ||
d62a17ae | 6232 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6233 | afi_t afi, safi_t safi, | |
6234 | const char *direct_str) | |
718e3744 | 6235 | { |
d62a17ae | 6236 | int ret; |
6237 | struct peer *peer; | |
6238 | int direct = FILTER_IN; | |
718e3744 | 6239 | |
d62a17ae | 6240 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6241 | if (!peer) | |
6242 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6243 | |
d62a17ae | 6244 | /* Check filter direction. */ |
6245 | if (strncmp(direct_str, "i", 1) == 0) | |
6246 | direct = FILTER_IN; | |
6247 | else if (strncmp(direct_str, "o", 1) == 0) | |
6248 | direct = FILTER_OUT; | |
718e3744 | 6249 | |
d62a17ae | 6250 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6251 | |
d62a17ae | 6252 | return bgp_vty_return(vty, ret); |
718e3744 | 6253 | } |
6254 | ||
6255 | DEFUN (neighbor_prefix_list, | |
6256 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6257 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6258 | NEIGHBOR_STR |
6259 | NEIGHBOR_ADDR_STR2 | |
6260 | "Filter updates to/from this neighbor\n" | |
6261 | "Name of a prefix list\n" | |
6262 | "Filter incoming updates\n" | |
6263 | "Filter outgoing updates\n") | |
6264 | { | |
d62a17ae | 6265 | int idx_peer = 1; |
6266 | int idx_word = 3; | |
6267 | int idx_in_out = 4; | |
6268 | return peer_prefix_list_set_vty( | |
6269 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6270 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6271 | } |
6272 | ||
d62a17ae | 6273 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6274 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6275 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6276 | "Filter updates to/from this neighbor\n" | |
6277 | "Name of a prefix list\n" | |
6278 | "Filter incoming updates\n" | |
6279 | "Filter outgoing updates\n") | |
596c17ba | 6280 | |
718e3744 | 6281 | DEFUN (no_neighbor_prefix_list, |
6282 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6283 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6284 | NO_STR |
6285 | NEIGHBOR_STR | |
6286 | NEIGHBOR_ADDR_STR2 | |
6287 | "Filter updates to/from this neighbor\n" | |
6288 | "Name of a prefix list\n" | |
6289 | "Filter incoming updates\n" | |
6290 | "Filter outgoing updates\n") | |
6291 | { | |
d62a17ae | 6292 | int idx_peer = 2; |
6293 | int idx_in_out = 5; | |
6294 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6295 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6296 | argv[idx_in_out]->arg); | |
718e3744 | 6297 | } |
6b0655a2 | 6298 | |
d62a17ae | 6299 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6300 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6301 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6302 | "Filter updates to/from this neighbor\n" | |
6303 | "Name of a prefix list\n" | |
6304 | "Filter incoming updates\n" | |
6305 | "Filter outgoing updates\n") | |
596c17ba | 6306 | |
d62a17ae | 6307 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6308 | safi_t safi, const char *name_str, | |
6309 | const char *direct_str) | |
718e3744 | 6310 | { |
d62a17ae | 6311 | int ret; |
6312 | struct peer *peer; | |
6313 | int direct = FILTER_IN; | |
718e3744 | 6314 | |
d62a17ae | 6315 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6316 | if (!peer) | |
6317 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6318 | |
d62a17ae | 6319 | /* Check filter direction. */ |
6320 | if (strncmp(direct_str, "i", 1) == 0) | |
6321 | direct = FILTER_IN; | |
6322 | else if (strncmp(direct_str, "o", 1) == 0) | |
6323 | direct = FILTER_OUT; | |
718e3744 | 6324 | |
d62a17ae | 6325 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6326 | |
d62a17ae | 6327 | return bgp_vty_return(vty, ret); |
718e3744 | 6328 | } |
6329 | ||
d62a17ae | 6330 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6331 | safi_t safi, const char *direct_str) | |
718e3744 | 6332 | { |
d62a17ae | 6333 | int ret; |
6334 | struct peer *peer; | |
6335 | int direct = FILTER_IN; | |
718e3744 | 6336 | |
d62a17ae | 6337 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6338 | if (!peer) | |
6339 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6340 | |
d62a17ae | 6341 | /* Check filter direction. */ |
6342 | if (strncmp(direct_str, "i", 1) == 0) | |
6343 | direct = FILTER_IN; | |
6344 | else if (strncmp(direct_str, "o", 1) == 0) | |
6345 | direct = FILTER_OUT; | |
718e3744 | 6346 | |
d62a17ae | 6347 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6348 | |
d62a17ae | 6349 | return bgp_vty_return(vty, ret); |
718e3744 | 6350 | } |
6351 | ||
6352 | DEFUN (neighbor_filter_list, | |
6353 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6354 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6355 | NEIGHBOR_STR |
6356 | NEIGHBOR_ADDR_STR2 | |
6357 | "Establish BGP filters\n" | |
6358 | "AS path access-list name\n" | |
6359 | "Filter incoming routes\n" | |
6360 | "Filter outgoing routes\n") | |
6361 | { | |
d62a17ae | 6362 | int idx_peer = 1; |
6363 | int idx_word = 3; | |
6364 | int idx_in_out = 4; | |
6365 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6366 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6367 | argv[idx_in_out]->arg); | |
718e3744 | 6368 | } |
6369 | ||
d62a17ae | 6370 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6371 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6372 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6373 | "Establish BGP filters\n" | |
6374 | "AS path access-list name\n" | |
6375 | "Filter incoming routes\n" | |
6376 | "Filter outgoing routes\n") | |
596c17ba | 6377 | |
718e3744 | 6378 | DEFUN (no_neighbor_filter_list, |
6379 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6380 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6381 | NO_STR |
6382 | NEIGHBOR_STR | |
6383 | NEIGHBOR_ADDR_STR2 | |
6384 | "Establish BGP filters\n" | |
6385 | "AS path access-list name\n" | |
6386 | "Filter incoming routes\n" | |
6387 | "Filter outgoing routes\n") | |
6388 | { | |
d62a17ae | 6389 | int idx_peer = 2; |
6390 | int idx_in_out = 5; | |
6391 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6392 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6393 | argv[idx_in_out]->arg); | |
718e3744 | 6394 | } |
6b0655a2 | 6395 | |
d62a17ae | 6396 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6397 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6398 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6399 | "Establish BGP filters\n" | |
6400 | "AS path access-list name\n" | |
6401 | "Filter incoming routes\n" | |
6402 | "Filter outgoing routes\n") | |
596c17ba | 6403 | |
718e3744 | 6404 | /* Set route-map to the peer. */ |
d62a17ae | 6405 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6406 | afi_t afi, safi_t safi, const char *name_str, | |
6407 | const char *direct_str) | |
718e3744 | 6408 | { |
d62a17ae | 6409 | int ret; |
6410 | struct peer *peer; | |
6411 | int direct = RMAP_IN; | |
1de27621 | 6412 | struct route_map *route_map; |
718e3744 | 6413 | |
d62a17ae | 6414 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6415 | if (!peer) | |
6416 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6417 | |
d62a17ae | 6418 | /* Check filter direction. */ |
6419 | if (strncmp(direct_str, "in", 2) == 0) | |
6420 | direct = RMAP_IN; | |
6421 | else if (strncmp(direct_str, "o", 1) == 0) | |
6422 | direct = RMAP_OUT; | |
718e3744 | 6423 | |
1de27621 DA |
6424 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6425 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6426 | |
d62a17ae | 6427 | return bgp_vty_return(vty, ret); |
718e3744 | 6428 | } |
6429 | ||
d62a17ae | 6430 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6431 | afi_t afi, safi_t safi, | |
6432 | const char *direct_str) | |
718e3744 | 6433 | { |
d62a17ae | 6434 | int ret; |
6435 | struct peer *peer; | |
6436 | int direct = RMAP_IN; | |
718e3744 | 6437 | |
d62a17ae | 6438 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6439 | if (!peer) | |
6440 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6441 | |
d62a17ae | 6442 | /* Check filter direction. */ |
6443 | if (strncmp(direct_str, "in", 2) == 0) | |
6444 | direct = RMAP_IN; | |
6445 | else if (strncmp(direct_str, "o", 1) == 0) | |
6446 | direct = RMAP_OUT; | |
718e3744 | 6447 | |
d62a17ae | 6448 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6449 | |
d62a17ae | 6450 | return bgp_vty_return(vty, ret); |
718e3744 | 6451 | } |
6452 | ||
6453 | DEFUN (neighbor_route_map, | |
6454 | neighbor_route_map_cmd, | |
9ccf14f7 | 6455 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6456 | NEIGHBOR_STR |
6457 | NEIGHBOR_ADDR_STR2 | |
6458 | "Apply route map to neighbor\n" | |
6459 | "Name of route map\n" | |
6460 | "Apply map to incoming routes\n" | |
2a3d5731 | 6461 | "Apply map to outbound routes\n") |
718e3744 | 6462 | { |
d62a17ae | 6463 | int idx_peer = 1; |
6464 | int idx_word = 3; | |
6465 | int idx_in_out = 4; | |
6466 | return peer_route_map_set_vty( | |
6467 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6468 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6469 | } |
6470 | ||
d62a17ae | 6471 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6472 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6473 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6474 | "Apply route map to neighbor\n" | |
6475 | "Name of route map\n" | |
6476 | "Apply map to incoming routes\n" | |
6477 | "Apply map to outbound routes\n") | |
596c17ba | 6478 | |
718e3744 | 6479 | DEFUN (no_neighbor_route_map, |
6480 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6481 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6482 | NO_STR |
6483 | NEIGHBOR_STR | |
6484 | NEIGHBOR_ADDR_STR2 | |
6485 | "Apply route map to neighbor\n" | |
6486 | "Name of route map\n" | |
6487 | "Apply map to incoming routes\n" | |
2a3d5731 | 6488 | "Apply map to outbound routes\n") |
718e3744 | 6489 | { |
d62a17ae | 6490 | int idx_peer = 2; |
6491 | int idx_in_out = 5; | |
6492 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6493 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6494 | argv[idx_in_out]->arg); | |
718e3744 | 6495 | } |
6b0655a2 | 6496 | |
d62a17ae | 6497 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6498 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6499 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6500 | "Apply route map to neighbor\n" | |
6501 | "Name of route map\n" | |
6502 | "Apply map to incoming routes\n" | |
6503 | "Apply map to outbound routes\n") | |
596c17ba | 6504 | |
718e3744 | 6505 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6506 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6507 | afi_t afi, safi_t safi, | |
6508 | const char *name_str) | |
718e3744 | 6509 | { |
d62a17ae | 6510 | int ret; |
6511 | struct peer *peer; | |
1de27621 | 6512 | struct route_map *route_map; |
718e3744 | 6513 | |
d62a17ae | 6514 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6515 | if (!peer) | |
6516 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6517 | |
1de27621 DA |
6518 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6519 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6520 | |
d62a17ae | 6521 | return bgp_vty_return(vty, ret); |
718e3744 | 6522 | } |
6523 | ||
6524 | /* Unset route-map from the peer. */ | |
d62a17ae | 6525 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6526 | afi_t afi, safi_t safi) | |
718e3744 | 6527 | { |
d62a17ae | 6528 | int ret; |
6529 | struct peer *peer; | |
718e3744 | 6530 | |
d62a17ae | 6531 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6532 | if (!peer) | |
6533 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6534 | |
d62a17ae | 6535 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6536 | |
d62a17ae | 6537 | return bgp_vty_return(vty, ret); |
718e3744 | 6538 | } |
6539 | ||
6540 | DEFUN (neighbor_unsuppress_map, | |
6541 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6542 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6543 | NEIGHBOR_STR |
6544 | NEIGHBOR_ADDR_STR2 | |
6545 | "Route-map to selectively unsuppress suppressed routes\n" | |
6546 | "Name of route map\n") | |
6547 | { | |
d62a17ae | 6548 | int idx_peer = 1; |
6549 | int idx_word = 3; | |
6550 | return peer_unsuppress_map_set_vty( | |
6551 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6552 | argv[idx_word]->arg); | |
718e3744 | 6553 | } |
6554 | ||
d62a17ae | 6555 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6556 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6557 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6558 | "Route-map to selectively unsuppress suppressed routes\n" | |
6559 | "Name of route map\n") | |
596c17ba | 6560 | |
718e3744 | 6561 | DEFUN (no_neighbor_unsuppress_map, |
6562 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6563 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6564 | NO_STR |
6565 | NEIGHBOR_STR | |
6566 | NEIGHBOR_ADDR_STR2 | |
6567 | "Route-map to selectively unsuppress suppressed routes\n" | |
6568 | "Name of route map\n") | |
6569 | { | |
d62a17ae | 6570 | int idx_peer = 2; |
6571 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6572 | bgp_node_afi(vty), | |
6573 | bgp_node_safi(vty)); | |
718e3744 | 6574 | } |
6b0655a2 | 6575 | |
d62a17ae | 6576 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6577 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6578 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6579 | "Route-map to selectively unsuppress suppressed routes\n" | |
6580 | "Name of route map\n") | |
596c17ba | 6581 | |
d62a17ae | 6582 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6583 | afi_t afi, safi_t safi, | |
6584 | const char *num_str, | |
6585 | const char *threshold_str, int warning, | |
6586 | const char *restart_str) | |
718e3744 | 6587 | { |
d62a17ae | 6588 | int ret; |
6589 | struct peer *peer; | |
d7c0a89a QY |
6590 | uint32_t max; |
6591 | uint8_t threshold; | |
6592 | uint16_t restart; | |
718e3744 | 6593 | |
d62a17ae | 6594 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6595 | if (!peer) | |
6596 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6597 | |
d62a17ae | 6598 | max = strtoul(num_str, NULL, 10); |
6599 | if (threshold_str) | |
6600 | threshold = atoi(threshold_str); | |
6601 | else | |
6602 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6603 | |
d62a17ae | 6604 | if (restart_str) |
6605 | restart = atoi(restart_str); | |
6606 | else | |
6607 | restart = 0; | |
0a486e5f | 6608 | |
d62a17ae | 6609 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6610 | restart); | |
718e3744 | 6611 | |
d62a17ae | 6612 | return bgp_vty_return(vty, ret); |
718e3744 | 6613 | } |
6614 | ||
d62a17ae | 6615 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6616 | afi_t afi, safi_t safi) | |
718e3744 | 6617 | { |
d62a17ae | 6618 | int ret; |
6619 | struct peer *peer; | |
718e3744 | 6620 | |
d62a17ae | 6621 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6622 | if (!peer) | |
6623 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6624 | |
d62a17ae | 6625 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6626 | |
d62a17ae | 6627 | return bgp_vty_return(vty, ret); |
718e3744 | 6628 | } |
6629 | ||
fde246e8 DA |
6630 | /* Maximum number of prefix to be sent to the neighbor. */ |
6631 | DEFUN(neighbor_maximum_prefix_out, | |
6632 | neighbor_maximum_prefix_out_cmd, | |
6633 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6634 | NEIGHBOR_STR | |
6635 | NEIGHBOR_ADDR_STR2 | |
6636 | "Maximum number of prefixes to be sent to this peer\n" | |
6637 | "Maximum no. of prefix limit\n") | |
6638 | { | |
6639 | int idx_peer = 1; | |
6640 | int idx_number = 3; | |
6641 | struct peer *peer; | |
6642 | uint32_t max; | |
6643 | afi_t afi = bgp_node_afi(vty); | |
6644 | safi_t safi = bgp_node_safi(vty); | |
6645 | ||
6646 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6647 | if (!peer) | |
6648 | return CMD_WARNING_CONFIG_FAILED; | |
6649 | ||
6650 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6651 | ||
6652 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6653 | peer->pmax_out[afi][safi] = max; | |
6654 | ||
6655 | return CMD_SUCCESS; | |
6656 | } | |
6657 | ||
6658 | DEFUN(no_neighbor_maximum_prefix_out, | |
6659 | no_neighbor_maximum_prefix_out_cmd, | |
6660 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6661 | NO_STR | |
6662 | NEIGHBOR_STR | |
6663 | NEIGHBOR_ADDR_STR2 | |
6664 | "Maximum number of prefixes to be sent to this peer\n") | |
6665 | { | |
6666 | int idx_peer = 2; | |
6667 | struct peer *peer; | |
6668 | afi_t afi = bgp_node_afi(vty); | |
6669 | safi_t safi = bgp_node_safi(vty); | |
6670 | ||
6671 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6672 | if (!peer) | |
6673 | return CMD_WARNING_CONFIG_FAILED; | |
6674 | ||
ae00326a | 6675 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
6676 | peer->pmax_out[afi][safi] = 0; |
6677 | ||
6678 | return CMD_SUCCESS; | |
6679 | } | |
6680 | ||
718e3744 | 6681 | /* Maximum number of prefix configuration. prefix count is different |
6682 | for each peer configuration. So this configuration can be set for | |
6683 | each peer configuration. */ | |
6684 | DEFUN (neighbor_maximum_prefix, | |
6685 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6686 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6687 | NEIGHBOR_STR |
6688 | NEIGHBOR_ADDR_STR2 | |
6689 | "Maximum number of prefix accept from this peer\n" | |
6690 | "maximum no. of prefix limit\n") | |
6691 | { | |
d62a17ae | 6692 | int idx_peer = 1; |
6693 | int idx_number = 3; | |
6694 | return peer_maximum_prefix_set_vty( | |
6695 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6696 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6697 | } |
6698 | ||
d62a17ae | 6699 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6700 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6701 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6702 | "Maximum number of prefix accept from this peer\n" | |
6703 | "maximum no. of prefix limit\n") | |
596c17ba | 6704 | |
e0701b79 | 6705 | DEFUN (neighbor_maximum_prefix_threshold, |
6706 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6707 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6708 | NEIGHBOR_STR |
6709 | NEIGHBOR_ADDR_STR2 | |
6710 | "Maximum number of prefix accept from this peer\n" | |
6711 | "maximum no. of prefix limit\n" | |
6712 | "Threshold value (%) at which to generate a warning msg\n") | |
6713 | { | |
d62a17ae | 6714 | int idx_peer = 1; |
6715 | int idx_number = 3; | |
6716 | int idx_number_2 = 4; | |
6717 | return peer_maximum_prefix_set_vty( | |
6718 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6719 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6720 | } |
e0701b79 | 6721 | |
d62a17ae | 6722 | ALIAS_HIDDEN( |
6723 | neighbor_maximum_prefix_threshold, | |
6724 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6725 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6726 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6727 | "Maximum number of prefix accept from this peer\n" | |
6728 | "maximum no. of prefix limit\n" | |
6729 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6730 | |
718e3744 | 6731 | DEFUN (neighbor_maximum_prefix_warning, |
6732 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6733 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6734 | NEIGHBOR_STR |
6735 | NEIGHBOR_ADDR_STR2 | |
6736 | "Maximum number of prefix accept from this peer\n" | |
6737 | "maximum no. of prefix limit\n" | |
6738 | "Only give warning message when limit is exceeded\n") | |
6739 | { | |
d62a17ae | 6740 | int idx_peer = 1; |
6741 | int idx_number = 3; | |
6742 | return peer_maximum_prefix_set_vty( | |
6743 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6744 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6745 | } |
6746 | ||
d62a17ae | 6747 | ALIAS_HIDDEN( |
6748 | neighbor_maximum_prefix_warning, | |
6749 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6750 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6751 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6752 | "Maximum number of prefix accept from this peer\n" | |
6753 | "maximum no. of prefix limit\n" | |
6754 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6755 | |
e0701b79 | 6756 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6757 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6758 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6759 | NEIGHBOR_STR |
6760 | NEIGHBOR_ADDR_STR2 | |
6761 | "Maximum number of prefix accept from this peer\n" | |
6762 | "maximum no. of prefix limit\n" | |
6763 | "Threshold value (%) at which to generate a warning msg\n" | |
6764 | "Only give warning message when limit is exceeded\n") | |
6765 | { | |
d62a17ae | 6766 | int idx_peer = 1; |
6767 | int idx_number = 3; | |
6768 | int idx_number_2 = 4; | |
6769 | return peer_maximum_prefix_set_vty( | |
6770 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6771 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6772 | } |
6773 | ||
d62a17ae | 6774 | ALIAS_HIDDEN( |
6775 | neighbor_maximum_prefix_threshold_warning, | |
6776 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6777 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6778 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6779 | "Maximum number of prefix accept from this peer\n" | |
6780 | "maximum no. of prefix limit\n" | |
6781 | "Threshold value (%) at which to generate a warning msg\n" | |
6782 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6783 | |
0a486e5f | 6784 | DEFUN (neighbor_maximum_prefix_restart, |
6785 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6786 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6787 | NEIGHBOR_STR |
6788 | NEIGHBOR_ADDR_STR2 | |
6789 | "Maximum number of prefix accept from this peer\n" | |
6790 | "maximum no. of prefix limit\n" | |
6791 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6792 | "Restart interval in minutes\n") |
0a486e5f | 6793 | { |
d62a17ae | 6794 | int idx_peer = 1; |
6795 | int idx_number = 3; | |
6796 | int idx_number_2 = 5; | |
6797 | return peer_maximum_prefix_set_vty( | |
6798 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6799 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6800 | } |
6801 | ||
d62a17ae | 6802 | ALIAS_HIDDEN( |
6803 | neighbor_maximum_prefix_restart, | |
6804 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6805 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6806 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6807 | "Maximum number of prefix accept from this peer\n" | |
6808 | "maximum no. of prefix limit\n" | |
6809 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6810 | "Restart interval in minutes\n") |
596c17ba | 6811 | |
0a486e5f | 6812 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6813 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6814 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6815 | NEIGHBOR_STR |
6816 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6817 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6818 | "maximum no. of prefix limit\n" |
6819 | "Threshold value (%) at which to generate a warning msg\n" | |
6820 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6821 | "Restart interval in minutes\n") |
0a486e5f | 6822 | { |
d62a17ae | 6823 | int idx_peer = 1; |
6824 | int idx_number = 3; | |
6825 | int idx_number_2 = 4; | |
6826 | int idx_number_3 = 6; | |
6827 | return peer_maximum_prefix_set_vty( | |
6828 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6829 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6830 | argv[idx_number_3]->arg); | |
6831 | } | |
6832 | ||
6833 | ALIAS_HIDDEN( | |
6834 | neighbor_maximum_prefix_threshold_restart, | |
6835 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6836 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6837 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6838 | "Maximum number of prefixes to accept from this peer\n" | |
6839 | "maximum no. of prefix limit\n" | |
6840 | "Threshold value (%) at which to generate a warning msg\n" | |
6841 | "Restart bgp connection after limit is exceeded\n" | |
6842 | "Restart interval in minutes\n") | |
596c17ba | 6843 | |
718e3744 | 6844 | DEFUN (no_neighbor_maximum_prefix, |
6845 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6846 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6847 | NO_STR |
6848 | NEIGHBOR_STR | |
6849 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6850 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6851 | "maximum no. of prefix limit\n" |
6852 | "Threshold value (%) at which to generate a warning msg\n" | |
6853 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6854 | "Restart interval in minutes\n" |
31500417 | 6855 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6856 | { |
d62a17ae | 6857 | int idx_peer = 2; |
6858 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6859 | bgp_node_afi(vty), | |
6860 | bgp_node_safi(vty)); | |
718e3744 | 6861 | } |
e52702f2 | 6862 | |
d62a17ae | 6863 | ALIAS_HIDDEN( |
6864 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6865 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6866 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6867 | "Maximum number of prefixes to accept from this peer\n" | |
6868 | "maximum no. of prefix limit\n" | |
6869 | "Threshold value (%) at which to generate a warning msg\n" | |
6870 | "Restart bgp connection after limit is exceeded\n" | |
6871 | "Restart interval in minutes\n" | |
6872 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6873 | |
718e3744 | 6874 | |
718e3744 | 6875 | /* "neighbor allowas-in" */ |
6876 | DEFUN (neighbor_allowas_in, | |
6877 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6878 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6879 | NEIGHBOR_STR |
6880 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6881 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6882 | "Number of occurrences of AS number\n" |
fd8503f5 | 6883 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6884 | { |
d62a17ae | 6885 | int idx_peer = 1; |
6886 | int idx_number_origin = 3; | |
6887 | int ret; | |
6888 | int origin = 0; | |
6889 | struct peer *peer; | |
6890 | int allow_num = 0; | |
6891 | ||
6892 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6893 | if (!peer) | |
6894 | return CMD_WARNING_CONFIG_FAILED; | |
6895 | ||
6896 | if (argc <= idx_number_origin) | |
6897 | allow_num = 3; | |
6898 | else { | |
6899 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6900 | origin = 1; | |
6901 | else | |
6902 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6903 | } | |
6904 | ||
6905 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6906 | allow_num, origin); | |
6907 | ||
6908 | return bgp_vty_return(vty, ret); | |
6909 | } | |
6910 | ||
6911 | ALIAS_HIDDEN( | |
6912 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6913 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6914 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6915 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6916 | "Number of occurrences of AS number\n" |
d62a17ae | 6917 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6918 | |
718e3744 | 6919 | DEFUN (no_neighbor_allowas_in, |
6920 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6921 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6922 | NO_STR |
6923 | NEIGHBOR_STR | |
6924 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6925 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6926 | "Number of occurrences of AS number\n" |
fd8503f5 | 6927 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6928 | { |
d62a17ae | 6929 | int idx_peer = 2; |
6930 | int ret; | |
6931 | struct peer *peer; | |
718e3744 | 6932 | |
d62a17ae | 6933 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6934 | if (!peer) | |
6935 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6936 | |
d62a17ae | 6937 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6938 | bgp_node_safi(vty)); | |
718e3744 | 6939 | |
d62a17ae | 6940 | return bgp_vty_return(vty, ret); |
718e3744 | 6941 | } |
6b0655a2 | 6942 | |
d62a17ae | 6943 | ALIAS_HIDDEN( |
6944 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6946 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6947 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6948 | "Number of occurrences of AS number\n" |
d62a17ae | 6949 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6950 | |
fa411a21 NH |
6951 | DEFUN (neighbor_ttl_security, |
6952 | neighbor_ttl_security_cmd, | |
7ebe625c | 6953 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6954 | NEIGHBOR_STR |
7ebe625c | 6955 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6956 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6957 | "Specify the maximum number of hops to the BGP peer\n" |
6958 | "Number of hops to BGP peer\n") | |
fa411a21 | 6959 | { |
d62a17ae | 6960 | int idx_peer = 1; |
6961 | int idx_number = 4; | |
6962 | struct peer *peer; | |
6963 | int gtsm_hops; | |
6964 | ||
6965 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6966 | if (!peer) | |
6967 | return CMD_WARNING_CONFIG_FAILED; | |
6968 | ||
6969 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6970 | ||
7ebe625c QY |
6971 | /* |
6972 | * If 'neighbor swpX', then this is for directly connected peers, | |
6973 | * we should not accept a ttl-security hops value greater than 1. | |
6974 | */ | |
e2521429 | 6975 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
6976 | vty_out(vty, |
6977 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6978 | argv[idx_peer]->arg); | |
6979 | return CMD_WARNING_CONFIG_FAILED; | |
6980 | } | |
6981 | ||
d62a17ae | 6982 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6983 | } |
6984 | ||
6985 | DEFUN (no_neighbor_ttl_security, | |
6986 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6987 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6988 | NO_STR |
6989 | NEIGHBOR_STR | |
7ebe625c | 6990 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6991 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6992 | "Specify the maximum number of hops to the BGP peer\n" |
6993 | "Number of hops to BGP peer\n") | |
fa411a21 | 6994 | { |
d62a17ae | 6995 | int idx_peer = 2; |
6996 | struct peer *peer; | |
fa411a21 | 6997 | |
d62a17ae | 6998 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6999 | if (!peer) | |
7000 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 7001 | |
d62a17ae | 7002 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 7003 | } |
6b0655a2 | 7004 | |
adbac85e DW |
7005 | DEFUN (neighbor_addpath_tx_all_paths, |
7006 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7007 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7008 | NEIGHBOR_STR |
7009 | NEIGHBOR_ADDR_STR2 | |
7010 | "Use addpath to advertise all paths to a neighbor\n") | |
7011 | { | |
d62a17ae | 7012 | int idx_peer = 1; |
7013 | struct peer *peer; | |
adbac85e | 7014 | |
d62a17ae | 7015 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7016 | if (!peer) | |
7017 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 7018 | |
dcc68b5e MS |
7019 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7020 | BGP_ADDPATH_ALL); | |
7021 | return CMD_SUCCESS; | |
adbac85e DW |
7022 | } |
7023 | ||
d62a17ae | 7024 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
7025 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
7026 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7027 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7028 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7029 | |
adbac85e DW |
7030 | DEFUN (no_neighbor_addpath_tx_all_paths, |
7031 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7032 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7033 | NO_STR |
7034 | NEIGHBOR_STR | |
7035 | NEIGHBOR_ADDR_STR2 | |
7036 | "Use addpath to advertise all paths to a neighbor\n") | |
7037 | { | |
d62a17ae | 7038 | int idx_peer = 2; |
dcc68b5e MS |
7039 | struct peer *peer; |
7040 | ||
7041 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7042 | if (!peer) | |
7043 | return CMD_WARNING_CONFIG_FAILED; | |
7044 | ||
7045 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7046 | != BGP_ADDPATH_ALL) { | |
7047 | vty_out(vty, | |
7048 | "%% Peer not currently configured to transmit all paths."); | |
7049 | return CMD_WARNING_CONFIG_FAILED; | |
7050 | } | |
7051 | ||
7052 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7053 | BGP_ADDPATH_NONE); | |
7054 | ||
7055 | return CMD_SUCCESS; | |
adbac85e DW |
7056 | } |
7057 | ||
d62a17ae | 7058 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
7059 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
7060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7061 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7062 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7063 | |
06370dac DW |
7064 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7065 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7066 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7067 | NEIGHBOR_STR |
7068 | NEIGHBOR_ADDR_STR2 | |
7069 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7070 | { | |
d62a17ae | 7071 | int idx_peer = 1; |
7072 | struct peer *peer; | |
06370dac | 7073 | |
d62a17ae | 7074 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7075 | if (!peer) | |
7076 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7077 | |
dcc68b5e MS |
7078 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7079 | BGP_ADDPATH_BEST_PER_AS); | |
7080 | ||
7081 | return CMD_SUCCESS; | |
06370dac DW |
7082 | } |
7083 | ||
d62a17ae | 7084 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7085 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7086 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7087 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7088 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7089 | |
06370dac DW |
7090 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7091 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7092 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7093 | NO_STR |
7094 | NEIGHBOR_STR | |
7095 | NEIGHBOR_ADDR_STR2 | |
7096 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7097 | { | |
d62a17ae | 7098 | int idx_peer = 2; |
dcc68b5e MS |
7099 | struct peer *peer; |
7100 | ||
7101 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7102 | if (!peer) | |
7103 | return CMD_WARNING_CONFIG_FAILED; | |
7104 | ||
7105 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7106 | != BGP_ADDPATH_BEST_PER_AS) { | |
7107 | vty_out(vty, | |
7108 | "%% Peer not currently configured to transmit all best path per as."); | |
7109 | return CMD_WARNING_CONFIG_FAILED; | |
7110 | } | |
7111 | ||
7112 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7113 | BGP_ADDPATH_NONE); | |
7114 | ||
7115 | return CMD_SUCCESS; | |
06370dac DW |
7116 | } |
7117 | ||
d62a17ae | 7118 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7119 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7121 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7122 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7123 | |
2b31007c RZ |
7124 | DEFPY( |
7125 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7126 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7127 | NEIGHBOR_STR | |
7128 | NEIGHBOR_ADDR_STR2 | |
7129 | "Detect AS loops before sending to neighbor\n") | |
7130 | { | |
7131 | struct peer *peer; | |
7132 | ||
7133 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7134 | if (!peer) | |
7135 | return CMD_WARNING_CONFIG_FAILED; | |
7136 | ||
7137 | peer->as_path_loop_detection = true; | |
7138 | ||
7139 | return CMD_SUCCESS; | |
7140 | } | |
7141 | ||
7142 | DEFPY( | |
7143 | no_neighbor_aspath_loop_detection, | |
7144 | no_neighbor_aspath_loop_detection_cmd, | |
7145 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7146 | NO_STR | |
7147 | NEIGHBOR_STR | |
7148 | NEIGHBOR_ADDR_STR2 | |
7149 | "Detect AS loops before sending to neighbor\n") | |
7150 | { | |
7151 | struct peer *peer; | |
7152 | ||
7153 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7154 | if (!peer) | |
7155 | return CMD_WARNING_CONFIG_FAILED; | |
7156 | ||
7157 | peer->as_path_loop_detection = false; | |
7158 | ||
7159 | return CMD_SUCCESS; | |
7160 | } | |
7161 | ||
b9c7bc5a PZ |
7162 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7163 | struct ecommunity **list) | |
ddb5b488 | 7164 | { |
b9c7bc5a PZ |
7165 | struct ecommunity *ecom = NULL; |
7166 | struct ecommunity *ecomadd; | |
ddb5b488 | 7167 | |
b9c7bc5a | 7168 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7169 | |
b9c7bc5a PZ |
7170 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7171 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7172 | if (!ecomadd) { | |
7173 | vty_out(vty, "Malformed community-list value\n"); | |
7174 | if (ecom) | |
7175 | ecommunity_free(&ecom); | |
7176 | return CMD_WARNING_CONFIG_FAILED; | |
7177 | } | |
ddb5b488 | 7178 | |
b9c7bc5a PZ |
7179 | if (ecom) { |
7180 | ecommunity_merge(ecom, ecomadd); | |
7181 | ecommunity_free(&ecomadd); | |
7182 | } else { | |
7183 | ecom = ecomadd; | |
7184 | } | |
7185 | } | |
7186 | ||
7187 | if (*list) { | |
7188 | ecommunity_free(&*list); | |
ddb5b488 | 7189 | } |
b9c7bc5a PZ |
7190 | *list = ecom; |
7191 | ||
7192 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7193 | } |
7194 | ||
0ca70ba5 DS |
7195 | /* |
7196 | * v2vimport is true if we are handling a `import vrf ...` command | |
7197 | */ | |
7198 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7199 | { |
0ca70ba5 DS |
7200 | afi_t afi; |
7201 | ||
ddb5b488 | 7202 | switch (vty->node) { |
b9c7bc5a | 7203 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7204 | afi = AFI_IP; |
7205 | break; | |
b9c7bc5a | 7206 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7207 | afi = AFI_IP6; |
7208 | break; | |
ddb5b488 PZ |
7209 | default: |
7210 | vty_out(vty, | |
b9c7bc5a | 7211 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7212 | return AFI_MAX; |
ddb5b488 | 7213 | } |
69b07479 | 7214 | |
0ca70ba5 DS |
7215 | if (!v2vimport) { |
7216 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7217 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7218 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7219 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7220 | vty_out(vty, | |
7221 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7222 | return AFI_MAX; | |
7223 | } | |
7224 | } else { | |
7225 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7226 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7227 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7228 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7229 | vty_out(vty, | |
7230 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7231 | return AFI_MAX; | |
7232 | } | |
7233 | } | |
7234 | return afi; | |
ddb5b488 PZ |
7235 | } |
7236 | ||
b9c7bc5a PZ |
7237 | DEFPY (af_rd_vpn_export, |
7238 | af_rd_vpn_export_cmd, | |
7239 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7240 | NO_STR | |
ddb5b488 | 7241 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7242 | "Between current address-family and vpn\n" |
7243 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7244 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7245 | { | |
7246 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7247 | struct prefix_rd prd; | |
7248 | int ret; | |
ddb5b488 | 7249 | afi_t afi; |
b9c7bc5a PZ |
7250 | int idx = 0; |
7251 | int yes = 1; | |
ddb5b488 | 7252 | |
b9c7bc5a | 7253 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7254 | yes = 0; |
b9c7bc5a PZ |
7255 | |
7256 | if (yes) { | |
7257 | ret = str2prefix_rd(rd_str, &prd); | |
7258 | if (!ret) { | |
7259 | vty_out(vty, "%% Malformed rd\n"); | |
7260 | return CMD_WARNING_CONFIG_FAILED; | |
7261 | } | |
ddb5b488 PZ |
7262 | } |
7263 | ||
0ca70ba5 | 7264 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7265 | if (afi == AFI_MAX) |
7266 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7267 | |
69b07479 DS |
7268 | /* |
7269 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7270 | */ | |
7271 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7272 | bgp_get_default(), bgp); | |
ddb5b488 | 7273 | |
69b07479 DS |
7274 | if (yes) { |
7275 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7276 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7277 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7278 | } else { | |
7279 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7280 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7281 | } |
7282 | ||
69b07479 DS |
7283 | /* post-change: re-export vpn routes */ |
7284 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7285 | bgp_get_default(), bgp); | |
7286 | ||
ddb5b488 PZ |
7287 | return CMD_SUCCESS; |
7288 | } | |
7289 | ||
b9c7bc5a PZ |
7290 | ALIAS (af_rd_vpn_export, |
7291 | af_no_rd_vpn_export_cmd, | |
7292 | "no rd vpn export", | |
ddb5b488 | 7293 | NO_STR |
b9c7bc5a PZ |
7294 | "Specify route distinguisher\n" |
7295 | "Between current address-family and vpn\n" | |
7296 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7297 | |
b9c7bc5a PZ |
7298 | DEFPY (af_label_vpn_export, |
7299 | af_label_vpn_export_cmd, | |
e70e9f8e | 7300 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7301 | NO_STR |
ddb5b488 | 7302 | "label value for VRF\n" |
b9c7bc5a PZ |
7303 | "Between current address-family and vpn\n" |
7304 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7305 | "Label Value <0-1048575>\n" |
7306 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7307 | { |
7308 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7309 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7310 | afi_t afi; |
b9c7bc5a PZ |
7311 | int idx = 0; |
7312 | int yes = 1; | |
7313 | ||
7314 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7315 | yes = 0; |
ddb5b488 | 7316 | |
21a16cc2 PZ |
7317 | /* If "no ...", squash trailing parameter */ |
7318 | if (!yes) | |
7319 | label_auto = NULL; | |
7320 | ||
e70e9f8e PZ |
7321 | if (yes) { |
7322 | if (!label_auto) | |
7323 | label = label_val; /* parser should force unsigned */ | |
7324 | } | |
ddb5b488 | 7325 | |
0ca70ba5 | 7326 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7327 | if (afi == AFI_MAX) |
7328 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7329 | |
e70e9f8e | 7330 | |
69b07479 DS |
7331 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7332 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7333 | /* no change */ | |
7334 | return CMD_SUCCESS; | |
e70e9f8e | 7335 | |
69b07479 DS |
7336 | /* |
7337 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7338 | */ | |
7339 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7340 | bgp_get_default(), bgp); | |
7341 | ||
7342 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7343 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7344 | ||
7345 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7346 | ||
7347 | /* | |
7348 | * label has previously been automatically | |
7349 | * assigned by labelpool: release it | |
7350 | * | |
7351 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7352 | * means the automatic assignment is in flight | |
7353 | * and therefore the labelpool callback must | |
7354 | * detect that the auto label is not needed. | |
7355 | */ | |
7356 | ||
7357 | bgp_lp_release(LP_TYPE_VRF, | |
7358 | &bgp->vpn_policy[afi], | |
7359 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7360 | } |
69b07479 DS |
7361 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7362 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7363 | } | |
ddb5b488 | 7364 | |
69b07479 DS |
7365 | bgp->vpn_policy[afi].tovpn_label = label; |
7366 | if (label_auto) { | |
7367 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7368 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7369 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7370 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7371 | } |
7372 | ||
69b07479 DS |
7373 | /* post-change: re-export vpn routes */ |
7374 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7375 | bgp_get_default(), bgp); | |
7376 | ||
ddb5b488 PZ |
7377 | return CMD_SUCCESS; |
7378 | } | |
7379 | ||
b9c7bc5a PZ |
7380 | ALIAS (af_label_vpn_export, |
7381 | af_no_label_vpn_export_cmd, | |
7382 | "no label vpn export", | |
7383 | NO_STR | |
7384 | "label value for VRF\n" | |
7385 | "Between current address-family and vpn\n" | |
7386 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7387 | |
b9c7bc5a PZ |
7388 | DEFPY (af_nexthop_vpn_export, |
7389 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 7390 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 7391 | NO_STR |
ddb5b488 | 7392 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7393 | "Between current address-family and vpn\n" |
7394 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7395 | "IPv4 prefix\n" |
7396 | "IPv6 prefix\n") | |
7397 | { | |
7398 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7399 | afi_t afi; |
ddb5b488 PZ |
7400 | struct prefix p; |
7401 | ||
8c85ca28 QY |
7402 | if (!no) { |
7403 | if (!nexthop_su) { | |
7404 | vty_out(vty, "%% Nexthop required\n"); | |
7405 | return CMD_WARNING_CONFIG_FAILED; | |
7406 | } | |
b9c7bc5a | 7407 | |
8c85ca28 | 7408 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
7409 | return CMD_WARNING_CONFIG_FAILED; |
7410 | } | |
ddb5b488 | 7411 | |
0ca70ba5 | 7412 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7413 | if (afi == AFI_MAX) |
7414 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7415 | |
69b07479 DS |
7416 | /* |
7417 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7418 | */ | |
7419 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7420 | bgp_get_default(), bgp); | |
ddb5b488 | 7421 | |
8c85ca28 | 7422 | if (!no) { |
69b07479 DS |
7423 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
7424 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7425 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7426 | } else { | |
7427 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7428 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7429 | } |
7430 | ||
69b07479 DS |
7431 | /* post-change: re-export vpn routes */ |
7432 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7433 | bgp_get_default(), bgp); | |
7434 | ||
ddb5b488 PZ |
7435 | return CMD_SUCCESS; |
7436 | } | |
7437 | ||
b9c7bc5a | 7438 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7439 | { |
b9c7bc5a PZ |
7440 | if (!strcmp(dstr, "import")) { |
7441 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7442 | } else if (!strcmp(dstr, "export")) { | |
7443 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7444 | } else if (!strcmp(dstr, "both")) { | |
7445 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7446 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7447 | } else { | |
7448 | vty_out(vty, "%% direction parse error\n"); | |
7449 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7450 | } |
ddb5b488 PZ |
7451 | return CMD_SUCCESS; |
7452 | } | |
7453 | ||
b9c7bc5a PZ |
7454 | DEFPY (af_rt_vpn_imexport, |
7455 | af_rt_vpn_imexport_cmd, | |
7456 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7457 | NO_STR | |
7458 | "Specify route target list\n" | |
ddb5b488 | 7459 | "Specify route target list\n" |
b9c7bc5a PZ |
7460 | "Between current address-family and vpn\n" |
7461 | "For routes leaked from vpn to current address-family: match any\n" | |
7462 | "For routes leaked from current address-family to vpn: set\n" | |
7463 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7464 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7465 | { | |
7466 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7467 | int ret; | |
7468 | struct ecommunity *ecom = NULL; | |
7469 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7470 | vpn_policy_direction_t dir; |
7471 | afi_t afi; | |
7472 | int idx = 0; | |
b9c7bc5a | 7473 | int yes = 1; |
ddb5b488 | 7474 | |
b9c7bc5a | 7475 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7476 | yes = 0; |
b9c7bc5a | 7477 | |
0ca70ba5 | 7478 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7479 | if (afi == AFI_MAX) |
7480 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7481 | |
b9c7bc5a | 7482 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7483 | if (ret != CMD_SUCCESS) |
7484 | return ret; | |
7485 | ||
b9c7bc5a PZ |
7486 | if (yes) { |
7487 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7488 | vty_out(vty, "%% Missing RTLIST\n"); | |
7489 | return CMD_WARNING_CONFIG_FAILED; | |
7490 | } | |
7491 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7492 | if (ret != CMD_SUCCESS) { | |
7493 | return ret; | |
7494 | } | |
ddb5b488 PZ |
7495 | } |
7496 | ||
69b07479 DS |
7497 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7498 | if (!dodir[dir]) | |
ddb5b488 | 7499 | continue; |
ddb5b488 | 7500 | |
69b07479 | 7501 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7502 | |
69b07479 DS |
7503 | if (yes) { |
7504 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7505 | ecommunity_free( | |
7506 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7507 | bgp->vpn_policy[afi].rtlist[dir] = | |
7508 | ecommunity_dup(ecom); | |
7509 | } else { | |
7510 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7511 | ecommunity_free( | |
7512 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7513 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7514 | } |
69b07479 DS |
7515 | |
7516 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7517 | } |
69b07479 | 7518 | |
d555f3e9 PZ |
7519 | if (ecom) |
7520 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7521 | |
7522 | return CMD_SUCCESS; | |
7523 | } | |
7524 | ||
b9c7bc5a PZ |
7525 | ALIAS (af_rt_vpn_imexport, |
7526 | af_no_rt_vpn_imexport_cmd, | |
7527 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7528 | NO_STR |
7529 | "Specify route target list\n" | |
b9c7bc5a PZ |
7530 | "Specify route target list\n" |
7531 | "Between current address-family and vpn\n" | |
7532 | "For routes leaked from vpn to current address-family\n" | |
7533 | "For routes leaked from current address-family to vpn\n" | |
7534 | "both import and export\n") | |
7535 | ||
7536 | DEFPY (af_route_map_vpn_imexport, | |
7537 | af_route_map_vpn_imexport_cmd, | |
7538 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7539 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7540 | NO_STR | |
ddb5b488 | 7541 | "Specify route map\n" |
b9c7bc5a PZ |
7542 | "Between current address-family and vpn\n" |
7543 | "For routes leaked from vpn to current address-family\n" | |
7544 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7545 | "name of route-map\n") |
7546 | { | |
7547 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7548 | int ret; | |
7549 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7550 | vpn_policy_direction_t dir; |
7551 | afi_t afi; | |
ddb5b488 | 7552 | int idx = 0; |
b9c7bc5a | 7553 | int yes = 1; |
ddb5b488 | 7554 | |
b9c7bc5a | 7555 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7556 | yes = 0; |
b9c7bc5a | 7557 | |
0ca70ba5 | 7558 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7559 | if (afi == AFI_MAX) |
7560 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7561 | |
b9c7bc5a | 7562 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7563 | if (ret != CMD_SUCCESS) |
7564 | return ret; | |
7565 | ||
69b07479 DS |
7566 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7567 | if (!dodir[dir]) | |
ddb5b488 | 7568 | continue; |
ddb5b488 | 7569 | |
69b07479 | 7570 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7571 | |
69b07479 DS |
7572 | if (yes) { |
7573 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7574 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7575 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7576 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7577 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7578 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7579 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7580 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7581 | return CMD_SUCCESS; | |
7582 | } else { | |
7583 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7584 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7585 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7586 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7587 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7588 | } |
69b07479 DS |
7589 | |
7590 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7591 | } |
7592 | ||
7593 | return CMD_SUCCESS; | |
7594 | } | |
7595 | ||
b9c7bc5a PZ |
7596 | ALIAS (af_route_map_vpn_imexport, |
7597 | af_no_route_map_vpn_imexport_cmd, | |
7598 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7599 | NO_STR |
7600 | "Specify route map\n" | |
b9c7bc5a PZ |
7601 | "Between current address-family and vpn\n" |
7602 | "For routes leaked from vpn to current address-family\n" | |
7603 | "For routes leaked from current address-family to vpn\n") | |
7604 | ||
bb4f6190 | 7605 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 7606 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
7607 | "Import routes from another VRF\n" |
7608 | "Vrf routes being filtered\n" | |
7609 | "Specify route map\n" | |
7610 | "name of route-map\n") | |
7611 | { | |
7612 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7613 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7614 | afi_t afi; | |
bb4f6190 DS |
7615 | struct bgp *bgp_default; |
7616 | ||
0ca70ba5 | 7617 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7618 | if (afi == AFI_MAX) |
7619 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7620 | |
7621 | bgp_default = bgp_get_default(); | |
7622 | if (!bgp_default) { | |
7623 | int32_t ret; | |
7624 | as_t as = bgp->as; | |
7625 | ||
7626 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7627 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7628 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7629 | |
7630 | if (ret) { | |
7631 | vty_out(vty, | |
7632 | "VRF default is not configured as a bgp instance\n"); | |
7633 | return CMD_WARNING; | |
7634 | } | |
7635 | } | |
7636 | ||
69b07479 | 7637 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7638 | |
ae6a6fb4 DS |
7639 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
7640 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7641 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7642 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7643 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7644 | bgp->vpn_policy[afi].rmap[dir] = | |
7645 | route_map_lookup_warn_noexist(vty, rmap_str); | |
7646 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
7647 | return CMD_SUCCESS; | |
7648 | ||
7649 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7650 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 7651 | |
69b07479 DS |
7652 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7653 | ||
bb4f6190 DS |
7654 | return CMD_SUCCESS; |
7655 | } | |
7656 | ||
ae6a6fb4 DS |
7657 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
7658 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
7659 | NO_STR |
7660 | "Import routes from another VRF\n" | |
7661 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
7662 | "Specify route map\n" |
7663 | "name of route-map\n") | |
7664 | { | |
7665 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7666 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7667 | afi_t afi; | |
7668 | ||
7669 | afi = vpn_policy_getafi(vty, bgp, true); | |
7670 | if (afi == AFI_MAX) | |
7671 | return CMD_WARNING_CONFIG_FAILED; | |
7672 | ||
7673 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7674 | ||
7675 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7676 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7677 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7678 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7679 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
7680 | ||
7681 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
7682 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7683 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
7684 | ||
7685 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
7686 | ||
7687 | return CMD_SUCCESS; | |
7688 | } | |
bb4f6190 | 7689 | |
4d1b335c DA |
7690 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7691 | "[no] import vrf VIEWVRFNAME$import_name", | |
7692 | NO_STR | |
7693 | "Import routes from another VRF\n" | |
7694 | "VRF to import from\n" | |
7695 | "The name of the VRF\n") | |
12a844a5 DS |
7696 | { |
7697 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7698 | struct listnode *node; | |
79ef8664 DS |
7699 | struct bgp *vrf_bgp, *bgp_default; |
7700 | int32_t ret = 0; | |
7701 | as_t as = bgp->as; | |
12a844a5 DS |
7702 | bool remove = false; |
7703 | int32_t idx = 0; | |
7704 | char *vname; | |
a8dadcf6 | 7705 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7706 | safi_t safi; |
7707 | afi_t afi; | |
7708 | ||
867f0cca | 7709 | if (import_name == NULL) { |
7710 | vty_out(vty, "%% Missing import name\n"); | |
7711 | return CMD_WARNING; | |
7712 | } | |
7713 | ||
ae6a6fb4 DS |
7714 | if (strcmp(import_name, "route-map") == 0) { |
7715 | vty_out(vty, "%% Must include route-map name\n"); | |
7716 | return CMD_WARNING; | |
7717 | } | |
7718 | ||
12a844a5 DS |
7719 | if (argv_find(argv, argc, "no", &idx)) |
7720 | remove = true; | |
7721 | ||
0ca70ba5 DS |
7722 | afi = vpn_policy_getafi(vty, bgp, true); |
7723 | if (afi == AFI_MAX) | |
7724 | return CMD_WARNING_CONFIG_FAILED; | |
7725 | ||
12a844a5 DS |
7726 | safi = bgp_node_safi(vty); |
7727 | ||
25679caa | 7728 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7729 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7730 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7731 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7732 | remove ? "unimport" : "import", import_name); | |
7733 | return CMD_WARNING; | |
7734 | } | |
7735 | ||
79ef8664 DS |
7736 | bgp_default = bgp_get_default(); |
7737 | if (!bgp_default) { | |
7738 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7739 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7740 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7741 | |
7742 | if (ret) { | |
7743 | vty_out(vty, | |
7744 | "VRF default is not configured as a bgp instance\n"); | |
7745 | return CMD_WARNING; | |
7746 | } | |
7747 | } | |
7748 | ||
12a844a5 DS |
7749 | vrf_bgp = bgp_lookup_by_name(import_name); |
7750 | if (!vrf_bgp) { | |
5742e42b | 7751 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7752 | vrf_bgp = bgp_default; |
7753 | else | |
0fb8d6e6 | 7754 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7755 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7756 | |
6e2c7fe6 | 7757 | if (ret) { |
020a3f60 DS |
7758 | vty_out(vty, |
7759 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7760 | import_name); |
7761 | return CMD_WARNING; | |
7762 | } | |
12a844a5 DS |
7763 | } |
7764 | ||
12a844a5 | 7765 | if (remove) { |
44338987 | 7766 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7767 | } else { |
44338987 | 7768 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7769 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7770 | vname)) { | |
7771 | if (strcmp(vname, import_name) == 0) | |
7772 | return CMD_WARNING; | |
7773 | } | |
7774 | ||
44338987 | 7775 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7776 | } |
7777 | ||
7778 | return CMD_SUCCESS; | |
7779 | } | |
7780 | ||
b9c7bc5a PZ |
7781 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7782 | DEFPY (bgp_imexport_vpn, | |
7783 | bgp_imexport_vpn_cmd, | |
7784 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7785 | NO_STR |
7786 | "Import routes to this address-family\n" | |
7787 | "Export routes from this address-family\n" | |
7788 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7789 | { |
7790 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7791 | int previous_state; |
ddb5b488 | 7792 | afi_t afi; |
b9c7bc5a | 7793 | safi_t safi; |
ddb5b488 | 7794 | int idx = 0; |
b9c7bc5a PZ |
7795 | int yes = 1; |
7796 | int flag; | |
7797 | vpn_policy_direction_t dir; | |
ddb5b488 | 7798 | |
b9c7bc5a | 7799 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7800 | yes = 0; |
ddb5b488 | 7801 | |
b9c7bc5a PZ |
7802 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7803 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7804 | |
b9c7bc5a PZ |
7805 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7806 | return CMD_WARNING_CONFIG_FAILED; | |
7807 | } | |
ddb5b488 | 7808 | |
b9c7bc5a PZ |
7809 | afi = bgp_node_afi(vty); |
7810 | safi = bgp_node_safi(vty); | |
7811 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7812 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7813 | return CMD_WARNING_CONFIG_FAILED; | |
7814 | } | |
ddb5b488 | 7815 | |
b9c7bc5a PZ |
7816 | if (!strcmp(direction_str, "import")) { |
7817 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7818 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7819 | } else if (!strcmp(direction_str, "export")) { | |
7820 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7821 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7822 | } else { | |
7823 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7824 | return CMD_WARNING_CONFIG_FAILED; | |
7825 | } | |
7826 | ||
7827 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7828 | |
b9c7bc5a PZ |
7829 | if (yes) { |
7830 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7831 | if (!previous_state) { | |
7832 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7833 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7834 | } | |
b9c7bc5a PZ |
7835 | } else { |
7836 | if (previous_state) { | |
7837 | /* trigger un-export current vrf */ | |
7838 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7839 | } | |
7840 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7841 | } |
7842 | ||
7843 | return CMD_SUCCESS; | |
7844 | } | |
7845 | ||
301ad80a PG |
7846 | DEFPY (af_routetarget_import, |
7847 | af_routetarget_import_cmd, | |
7848 | "[no] <rt|route-target> redirect import RTLIST...", | |
7849 | NO_STR | |
7850 | "Specify route target list\n" | |
7851 | "Specify route target list\n" | |
7852 | "Flow-spec redirect type route target\n" | |
7853 | "Import routes to this address-family\n" | |
7854 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7855 | { | |
7856 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7857 | int ret; | |
7858 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7859 | afi_t afi; |
7860 | int idx = 0; | |
7861 | int yes = 1; | |
7862 | ||
7863 | if (argv_find(argv, argc, "no", &idx)) | |
7864 | yes = 0; | |
7865 | ||
0ca70ba5 | 7866 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7867 | if (afi == AFI_MAX) |
7868 | return CMD_WARNING_CONFIG_FAILED; | |
7869 | ||
301ad80a PG |
7870 | if (yes) { |
7871 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7872 | vty_out(vty, "%% Missing RTLIST\n"); | |
7873 | return CMD_WARNING_CONFIG_FAILED; | |
7874 | } | |
7875 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7876 | if (ret != CMD_SUCCESS) | |
7877 | return ret; | |
7878 | } | |
69b07479 DS |
7879 | |
7880 | if (yes) { | |
7881 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7882 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7883 | .import_redirect_rtlist); |
69b07479 DS |
7884 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7885 | ecommunity_dup(ecom); | |
7886 | } else { | |
7887 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7888 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7889 | .import_redirect_rtlist); |
69b07479 | 7890 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7891 | } |
69b07479 | 7892 | |
301ad80a PG |
7893 | if (ecom) |
7894 | ecommunity_free(&ecom); | |
7895 | ||
7896 | return CMD_SUCCESS; | |
7897 | } | |
7898 | ||
505e5056 | 7899 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7900 | address_family_ipv4_safi_cmd, |
7901 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7902 | "Enter Address Family command mode\n" | |
7903 | "Address Family\n" | |
7904 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7905 | { |
f51bae9c | 7906 | |
d62a17ae | 7907 | if (argc == 3) { |
2131d5cf | 7908 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7909 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7910 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7911 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7912 | && safi != SAFI_EVPN) { |
31947174 MK |
7913 | vty_out(vty, |
7914 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7915 | return CMD_WARNING_CONFIG_FAILED; |
7916 | } | |
d62a17ae | 7917 | vty->node = bgp_node_type(AFI_IP, safi); |
7918 | } else | |
7919 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7920 | |
d62a17ae | 7921 | return CMD_SUCCESS; |
718e3744 | 7922 | } |
7923 | ||
505e5056 | 7924 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7925 | address_family_ipv6_safi_cmd, |
7926 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7927 | "Enter Address Family command mode\n" | |
7928 | "Address Family\n" | |
7929 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7930 | { |
d62a17ae | 7931 | if (argc == 3) { |
2131d5cf | 7932 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7933 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7934 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7935 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7936 | && safi != SAFI_EVPN) { |
31947174 MK |
7937 | vty_out(vty, |
7938 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7939 | return CMD_WARNING_CONFIG_FAILED; |
7940 | } | |
d62a17ae | 7941 | vty->node = bgp_node_type(AFI_IP6, safi); |
7942 | } else | |
7943 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7944 | |
d62a17ae | 7945 | return CMD_SUCCESS; |
25ffbdc1 | 7946 | } |
718e3744 | 7947 | |
d6902373 | 7948 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7949 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7950 | address_family_vpnv4_cmd, |
8334fd5a | 7951 | "address-family vpnv4 [unicast]", |
718e3744 | 7952 | "Enter Address Family command mode\n" |
8c3deaae | 7953 | "Address Family\n" |
3a2d747c | 7954 | "Address Family modifier\n") |
718e3744 | 7955 | { |
d62a17ae | 7956 | vty->node = BGP_VPNV4_NODE; |
7957 | return CMD_SUCCESS; | |
718e3744 | 7958 | } |
7959 | ||
505e5056 | 7960 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7961 | address_family_vpnv6_cmd, |
8334fd5a | 7962 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7963 | "Enter Address Family command mode\n" |
8c3deaae | 7964 | "Address Family\n" |
3a2d747c | 7965 | "Address Family modifier\n") |
8ecd3266 | 7966 | { |
d62a17ae | 7967 | vty->node = BGP_VPNV6_NODE; |
7968 | return CMD_SUCCESS; | |
8ecd3266 | 7969 | } |
64e4a6c5 | 7970 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7971 | |
505e5056 | 7972 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7973 | address_family_evpn_cmd, |
7111c1a0 | 7974 | "address-family l2vpn evpn", |
4e0b7b6d | 7975 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7976 | "Address Family\n" |
7977 | "Address Family modifier\n") | |
4e0b7b6d | 7978 | { |
2131d5cf | 7979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7980 | vty->node = BGP_EVPN_NODE; |
7981 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7982 | } |
7983 | ||
505e5056 | 7984 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7985 | exit_address_family_cmd, |
7986 | "exit-address-family", | |
7987 | "Exit from Address Family configuration mode\n") | |
7988 | { | |
d62a17ae | 7989 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7990 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7991 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7992 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7993 | || vty->node == BGP_EVPN_NODE |
7994 | || vty->node == BGP_FLOWSPECV4_NODE | |
7995 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7996 | vty->node = BGP_NODE; |
7997 | return CMD_SUCCESS; | |
718e3744 | 7998 | } |
6b0655a2 | 7999 | |
8ad7271d | 8000 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 8001 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
8002 | const char *ip_str, afi_t afi, safi_t safi, | |
8003 | struct prefix_rd *prd) | |
8004 | { | |
8005 | int ret; | |
8006 | struct prefix match; | |
8007 | struct bgp_node *rn; | |
8008 | struct bgp_node *rm; | |
8009 | struct bgp *bgp; | |
8010 | struct bgp_table *table; | |
8011 | struct bgp_table *rib; | |
8012 | ||
8013 | /* BGP structure lookup. */ | |
8014 | if (view_name) { | |
8015 | bgp = bgp_lookup_by_name(view_name); | |
8016 | if (bgp == NULL) { | |
8017 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
8018 | view_name); | |
8019 | return CMD_WARNING; | |
8020 | } | |
8021 | } else { | |
8022 | bgp = bgp_get_default(); | |
8023 | if (bgp == NULL) { | |
8024 | vty_out(vty, "%% No BGP process is configured\n"); | |
8025 | return CMD_WARNING; | |
8026 | } | |
8027 | } | |
8028 | ||
8029 | /* Check IP address argument. */ | |
8030 | ret = str2prefix(ip_str, &match); | |
8031 | if (!ret) { | |
8032 | vty_out(vty, "%% address is malformed\n"); | |
8033 | return CMD_WARNING; | |
8034 | } | |
8035 | ||
8036 | match.family = afi2family(afi); | |
8037 | rib = bgp->rib[afi][safi]; | |
8038 | ||
8039 | if (safi == SAFI_MPLS_VPN) { | |
8040 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
b54892e0 DS |
8041 | const struct prefix *rn_p = bgp_node_get_prefix(rn); |
8042 | ||
8043 | if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0) | |
d62a17ae | 8044 | continue; |
8045 | ||
67009e22 | 8046 | table = bgp_node_get_bgp_table_info(rn); |
b54892e0 DS |
8047 | if (table == NULL) |
8048 | continue; | |
8049 | ||
8050 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
8051 | const struct prefix *rm_p = | |
8052 | bgp_node_get_prefix(rm); | |
8053 | ||
8054 | if (rm_p->prefixlen == match.prefixlen) { | |
8055 | SET_FLAG(rm->flags, | |
8056 | BGP_NODE_USER_CLEAR); | |
8057 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 8058 | } |
b54892e0 | 8059 | bgp_unlock_node(rm); |
d62a17ae | 8060 | } |
8061 | } | |
8062 | } else { | |
8063 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
b54892e0 DS |
8064 | const struct prefix *rn_p = bgp_node_get_prefix(rn); |
8065 | ||
8066 | if (rn_p->prefixlen == match.prefixlen) { | |
d62a17ae | 8067 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); |
8068 | bgp_process(bgp, rn, afi, safi); | |
8069 | } | |
8070 | bgp_unlock_node(rn); | |
8071 | } | |
8072 | } | |
8073 | ||
8074 | return CMD_SUCCESS; | |
8ad7271d DS |
8075 | } |
8076 | ||
b09b5ae0 | 8077 | /* one clear bgp command to rule them all */ |
718e3744 | 8078 | DEFUN (clear_ip_bgp_all, |
8079 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8080 | "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 | 8081 | CLEAR_STR |
8082 | IP_STR | |
8083 | BGP_STR | |
838758ac | 8084 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8085 | BGP_AFI_HELP_STR |
fd5e7b70 | 8086 | "Address Family\n" |
510afcd6 | 8087 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8088 | "Address Family modifier\n" |
b09b5ae0 | 8089 | "Clear all peers\n" |
453c92f6 | 8090 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8091 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8092 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8093 | "Clear peers with the AS number\n" |
8094 | "Clear all external peers\n" | |
718e3744 | 8095 | "Clear all members of peer-group\n" |
b09b5ae0 | 8096 | "BGP peer-group name\n" |
b09b5ae0 DW |
8097 | BGP_SOFT_STR |
8098 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8099 | BGP_SOFT_OUT_STR |
8100 | BGP_SOFT_IN_STR | |
8101 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8102 | BGP_SOFT_OUT_STR) |
718e3744 | 8103 | { |
d62a17ae | 8104 | char *vrf = NULL; |
8105 | ||
dc912615 DS |
8106 | afi_t afi = AFI_UNSPEC; |
8107 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8108 | enum clear_sort clr_sort = clear_peer; |
8109 | enum bgp_clear_type clr_type; | |
8110 | char *clr_arg = NULL; | |
8111 | ||
8112 | int idx = 0; | |
8113 | ||
8114 | /* clear [ip] bgp */ | |
8115 | if (argv_find(argv, argc, "ip", &idx)) | |
8116 | afi = AFI_IP; | |
8117 | ||
9a8bdf1c PG |
8118 | /* [<vrf> VIEWVRFNAME] */ |
8119 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8120 | vrf = argv[idx + 1]->arg; | |
8121 | idx += 2; | |
8122 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8123 | vrf = NULL; | |
8124 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8125 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8126 | vrf = argv[idx + 1]->arg; |
8127 | idx += 2; | |
8128 | } | |
d62a17ae | 8129 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8130 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8131 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8132 | ||
d7b9898c | 8133 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8134 | if (argv_find(argv, argc, "*", &idx)) { |
8135 | clr_sort = clear_all; | |
8136 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8137 | clr_sort = clear_peer; | |
8138 | clr_arg = argv[idx]->arg; | |
8139 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8140 | clr_sort = clear_peer; | |
8141 | clr_arg = argv[idx]->arg; | |
8142 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8143 | clr_sort = clear_group; | |
8144 | idx++; | |
8145 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8146 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8147 | clr_sort = clear_peer; |
8148 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8149 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8150 | clr_sort = clear_peer; | |
8151 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8152 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8153 | clr_sort = clear_as; | |
8154 | clr_arg = argv[idx]->arg; | |
8155 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8156 | clr_sort = clear_external; | |
8157 | } | |
8158 | ||
8159 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8160 | if (argv_find(argv, argc, "soft", &idx)) { | |
8161 | if (argv_find(argv, argc, "in", &idx) | |
8162 | || argv_find(argv, argc, "out", &idx)) | |
8163 | clr_type = strmatch(argv[idx]->text, "in") | |
8164 | ? BGP_CLEAR_SOFT_IN | |
8165 | : BGP_CLEAR_SOFT_OUT; | |
8166 | else | |
8167 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8168 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8169 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8170 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8171 | : BGP_CLEAR_SOFT_IN; | |
8172 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8173 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8174 | } else | |
8175 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8176 | ||
8177 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8178 | } |
01080f7c | 8179 | |
8ad7271d DS |
8180 | DEFUN (clear_ip_bgp_prefix, |
8181 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8182 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8183 | CLEAR_STR |
8184 | IP_STR | |
8185 | BGP_STR | |
838758ac | 8186 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8187 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8188 | "IPv4 prefix\n") |
8ad7271d | 8189 | { |
d62a17ae | 8190 | char *vrf = NULL; |
8191 | char *prefix = NULL; | |
8ad7271d | 8192 | |
d62a17ae | 8193 | int idx = 0; |
01080f7c | 8194 | |
d62a17ae | 8195 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8196 | if (argv_find(argv, argc, "vrf", &idx)) { |
8197 | vrf = argv[idx + 1]->arg; | |
8198 | idx += 2; | |
8199 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8200 | vrf = NULL; | |
8201 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8202 | /* [<view> VIEWVRFNAME] */ | |
8203 | vrf = argv[idx + 1]->arg; | |
8204 | idx += 2; | |
8205 | } | |
0c7b1b01 | 8206 | |
d62a17ae | 8207 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8208 | |
d62a17ae | 8209 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8210 | } |
8ad7271d | 8211 | |
b09b5ae0 DW |
8212 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8213 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8214 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8215 | CLEAR_STR |
3a2d747c | 8216 | IP_STR |
718e3744 | 8217 | BGP_STR |
8c3deaae | 8218 | "Address Family\n" |
46f296b4 | 8219 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8220 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8221 | "IPv6 prefix\n") |
718e3744 | 8222 | { |
9b475e76 PG |
8223 | int idx_safi = 0; |
8224 | int idx_ipv6_prefix = 0; | |
8225 | safi_t safi = SAFI_UNICAST; | |
8226 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8227 | argv[idx_ipv6_prefix]->arg : NULL; | |
8228 | ||
8229 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8230 | return bgp_clear_prefix( |
9b475e76 PG |
8231 | vty, NULL, prefix, AFI_IP6, |
8232 | safi, NULL); | |
838758ac | 8233 | } |
01080f7c | 8234 | |
b09b5ae0 DW |
8235 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8236 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8237 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8238 | CLEAR_STR |
3a2d747c | 8239 | IP_STR |
718e3744 | 8240 | BGP_STR |
838758ac | 8241 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8242 | "Address Family\n" |
46f296b4 | 8243 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8244 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8245 | "IPv6 prefix\n") |
718e3744 | 8246 | { |
9b475e76 | 8247 | int idx_safi = 0; |
9a8bdf1c | 8248 | int idx_vrfview = 0; |
9b475e76 PG |
8249 | int idx_ipv6_prefix = 0; |
8250 | safi_t safi = SAFI_UNICAST; | |
8251 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8252 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8253 | char *vrfview = NULL; |
9b475e76 | 8254 | |
9a8bdf1c PG |
8255 | /* [<view|vrf> VIEWVRFNAME] */ |
8256 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8257 | vrfview = argv[idx_vrfview + 1]->arg; | |
8258 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8259 | vrfview = NULL; | |
8260 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8261 | /* [<view> VIEWVRFNAME] */ | |
8262 | vrfview = argv[idx_vrfview + 1]->arg; | |
8263 | } | |
9b475e76 PG |
8264 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8265 | ||
d62a17ae | 8266 | return bgp_clear_prefix( |
9b475e76 PG |
8267 | vty, vrfview, prefix, |
8268 | AFI_IP6, safi, NULL); | |
718e3744 | 8269 | } |
8270 | ||
b09b5ae0 DW |
8271 | DEFUN (show_bgp_views, |
8272 | show_bgp_views_cmd, | |
d6e3c605 | 8273 | "show [ip] bgp views", |
b09b5ae0 | 8274 | SHOW_STR |
d6e3c605 | 8275 | IP_STR |
01080f7c | 8276 | BGP_STR |
b09b5ae0 | 8277 | "Show the defined BGP views\n") |
01080f7c | 8278 | { |
d62a17ae | 8279 | struct list *inst = bm->bgp; |
8280 | struct listnode *node; | |
8281 | struct bgp *bgp; | |
01080f7c | 8282 | |
d62a17ae | 8283 | vty_out(vty, "Defined BGP views:\n"); |
8284 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8285 | /* Skip VRFs. */ | |
8286 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8287 | continue; | |
8288 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8289 | bgp->as); | |
8290 | } | |
e52702f2 | 8291 | |
d62a17ae | 8292 | return CMD_SUCCESS; |
e0081f70 ML |
8293 | } |
8294 | ||
8386ac43 | 8295 | DEFUN (show_bgp_vrfs, |
8296 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8297 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8298 | SHOW_STR |
d6e3c605 | 8299 | IP_STR |
8386ac43 | 8300 | BGP_STR |
8301 | "Show BGP VRFs\n" | |
9973d184 | 8302 | JSON_STR) |
8386ac43 | 8303 | { |
fe1dc5a3 | 8304 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8305 | struct list *inst = bm->bgp; |
8306 | struct listnode *node; | |
8307 | struct bgp *bgp; | |
9f049418 | 8308 | bool uj = use_json(argc, argv); |
d62a17ae | 8309 | json_object *json = NULL; |
8310 | json_object *json_vrfs = NULL; | |
8311 | int count = 0; | |
d62a17ae | 8312 | |
d62a17ae | 8313 | if (uj) { |
8314 | json = json_object_new_object(); | |
8315 | json_vrfs = json_object_new_object(); | |
8316 | } | |
8317 | ||
8318 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8319 | const char *name, *type; | |
8320 | struct peer *peer; | |
7fe96307 | 8321 | struct listnode *node2, *nnode2; |
d62a17ae | 8322 | int peers_cfg, peers_estb; |
8323 | json_object *json_vrf = NULL; | |
d62a17ae | 8324 | |
8325 | /* Skip Views. */ | |
8326 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8327 | continue; | |
8328 | ||
8329 | count++; | |
efb4077a | 8330 | if (!uj && count == 1) { |
fe1dc5a3 | 8331 | vty_out(vty, |
efb4077a | 8332 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8333 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8334 | "#PeersEstb", "Name"); |
8335 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8336 | "L3-VNI", "RouterMAC", "Interface"); | |
8337 | } | |
d62a17ae | 8338 | |
8339 | peers_cfg = peers_estb = 0; | |
8340 | if (uj) | |
8341 | json_vrf = json_object_new_object(); | |
8342 | ||
8343 | ||
7fe96307 | 8344 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8345 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8346 | continue; | |
8347 | peers_cfg++; | |
8348 | if (peer->status == Established) | |
8349 | peers_estb++; | |
8350 | } | |
8351 | ||
8352 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8353 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8354 | type = "DFLT"; |
8355 | } else { | |
8356 | name = bgp->name; | |
8357 | type = "VRF"; | |
8358 | } | |
8359 | ||
a8bf7d9c | 8360 | |
d62a17ae | 8361 | if (uj) { |
a4d82a8a PZ |
8362 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8363 | ? -1 | |
8364 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8365 | json_object_string_add(json_vrf, "type", type); |
8366 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8367 | json_object_string_add(json_vrf, "routerId", | |
8368 | inet_ntoa(bgp->router_id)); | |
8369 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8370 | peers_cfg); | |
8371 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8372 | peers_estb); | |
8373 | ||
fe1dc5a3 | 8374 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8375 | json_object_string_add( |
8376 | json_vrf, "rmac", | |
8377 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8378 | json_object_string_add(json_vrf, "interface", |
8379 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8380 | bgp->vrf_id)); | |
d62a17ae | 8381 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8382 | } else { |
fe1dc5a3 | 8383 | vty_out(vty, |
efb4077a | 8384 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8385 | type, |
8386 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8387 | : (int)bgp->vrf_id, | |
8388 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8389 | peers_estb, name); |
8390 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8391 | bgp->l3vni, | |
8392 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8393 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8394 | bgp->vrf_id)); | |
8395 | } | |
d62a17ae | 8396 | } |
8397 | ||
8398 | if (uj) { | |
8399 | json_object_object_add(json, "vrfs", json_vrfs); | |
8400 | ||
8401 | json_object_int_add(json, "totalVrfs", count); | |
8402 | ||
996c9314 LB |
8403 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8404 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8405 | json_object_free(json); |
8406 | } else { | |
8407 | if (count) | |
8408 | vty_out(vty, | |
8409 | "\nTotal number of VRFs (including default): %d\n", | |
8410 | count); | |
8411 | } | |
8412 | ||
8413 | return CMD_SUCCESS; | |
8386ac43 | 8414 | } |
8415 | ||
48ecf8f5 DS |
8416 | DEFUN (show_bgp_mac_hash, |
8417 | show_bgp_mac_hash_cmd, | |
8418 | "show bgp mac hash", | |
8419 | SHOW_STR | |
8420 | BGP_STR | |
8421 | "Mac Address\n" | |
8422 | "Mac Address database\n") | |
8423 | { | |
8424 | bgp_mac_dump_table(vty); | |
8425 | ||
8426 | return CMD_SUCCESS; | |
8427 | } | |
acf71666 | 8428 | |
e3b78da8 | 8429 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8430 | { |
0291c246 | 8431 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8432 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8433 | |
60466a63 | 8434 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8435 | tip->refcnt); |
8436 | } | |
8437 | ||
8438 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8439 | { | |
8440 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8441 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8442 | |
8443 | vty_out(vty, "Tunnel-ip database:\n"); | |
8444 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8445 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8446 | vty); |
8447 | } | |
8448 | ||
15c81ca4 DS |
8449 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8450 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8451 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8452 | "martian next-hops\n" |
8453 | "martian next-hop database\n") | |
acf71666 | 8454 | { |
0291c246 | 8455 | struct bgp *bgp = NULL; |
15c81ca4 | 8456 | int idx = 0; |
9a8bdf1c PG |
8457 | char *name = NULL; |
8458 | ||
8459 | /* [<vrf> VIEWVRFNAME] */ | |
8460 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8461 | name = argv[idx + 1]->arg; | |
8462 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8463 | name = NULL; | |
8464 | } else if (argv_find(argv, argc, "view", &idx)) | |
8465 | /* [<view> VIEWVRFNAME] */ | |
8466 | name = argv[idx + 1]->arg; | |
8467 | if (name) | |
8468 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8469 | else |
8470 | bgp = bgp_get_default(); | |
acf71666 | 8471 | |
acf71666 MK |
8472 | if (!bgp) { |
8473 | vty_out(vty, "%% No BGP process is configured\n"); | |
8474 | return CMD_WARNING; | |
8475 | } | |
8476 | bgp_show_martian_nexthops(vty, bgp); | |
8477 | ||
8478 | return CMD_SUCCESS; | |
8479 | } | |
8480 | ||
f412b39a | 8481 | DEFUN (show_bgp_memory, |
4bf6a362 | 8482 | show_bgp_memory_cmd, |
7fa12b13 | 8483 | "show [ip] bgp memory", |
4bf6a362 | 8484 | SHOW_STR |
3a2d747c | 8485 | IP_STR |
4bf6a362 PJ |
8486 | BGP_STR |
8487 | "Global BGP memory statistics\n") | |
8488 | { | |
d62a17ae | 8489 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8490 | unsigned long count; | |
8491 | ||
8492 | /* RIB related usage stats */ | |
8493 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8494 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8495 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8496 | count * sizeof(struct bgp_node))); | |
8497 | ||
8498 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8499 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8500 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8501 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8502 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8503 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8504 | count, | |
4b7e6066 DS |
8505 | mtype_memstr( |
8506 | memstrbuf, sizeof(memstrbuf), | |
8507 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8508 | |
8509 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8510 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8511 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8512 | count * sizeof(struct bgp_static))); | |
8513 | ||
8514 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8515 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8516 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8517 | count * sizeof(struct bpacket))); | |
8518 | ||
8519 | /* Adj-In/Out */ | |
8520 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8521 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8522 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8523 | count * sizeof(struct bgp_adj_in))); | |
8524 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8525 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8526 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8527 | count * sizeof(struct bgp_adj_out))); | |
8528 | ||
8529 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8530 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8531 | count, | |
8532 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8533 | count * sizeof(struct bgp_nexthop_cache))); | |
8534 | ||
8535 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8536 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8537 | count, | |
8538 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8539 | count * sizeof(struct bgp_damp_info))); | |
8540 | ||
8541 | /* Attributes */ | |
8542 | count = attr_count(); | |
8543 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8544 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8545 | count * sizeof(struct attr))); | |
8546 | ||
8547 | if ((count = attr_unknown_count())) | |
8548 | vty_out(vty, "%ld unknown attributes\n", count); | |
8549 | ||
8550 | /* AS_PATH attributes */ | |
8551 | count = aspath_count(); | |
8552 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8553 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8554 | count * sizeof(struct aspath))); | |
8555 | ||
8556 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8557 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8558 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8559 | count * sizeof(struct assegment))); | |
8560 | ||
8561 | /* Other attributes */ | |
8562 | if ((count = community_count())) | |
8563 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8564 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8565 | count * sizeof(struct community))); | |
d62a17ae | 8566 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8567 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8568 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8569 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8570 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8571 | vty_out(vty, | |
8572 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8573 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8574 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8575 | |
8576 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8577 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8578 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8579 | count * sizeof(struct cluster_list))); | |
8580 | ||
8581 | /* Peer related usage */ | |
8582 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8583 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8584 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8585 | count * sizeof(struct peer))); | |
8586 | ||
8587 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8588 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8589 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8590 | count * sizeof(struct peer_group))); | |
8591 | ||
8592 | /* Other */ | |
d62a17ae | 8593 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8594 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8595 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8596 | count * sizeof(regex_t))); | |
d62a17ae | 8597 | return CMD_SUCCESS; |
4bf6a362 | 8598 | } |
fee0f4c6 | 8599 | |
57a9c8a8 DS |
8600 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8601 | { | |
8602 | json_object *bestpath = json_object_new_object(); | |
8603 | ||
892fedb6 | 8604 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
8605 | json_object_string_add(bestpath, "asPath", "ignore"); |
8606 | ||
892fedb6 | 8607 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
8608 | json_object_string_add(bestpath, "asPath", "confed"); |
8609 | ||
892fedb6 DA |
8610 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
8611 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 8612 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8613 | "as-set"); |
8614 | else | |
a4d82a8a | 8615 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8616 | "true"); |
8617 | } else | |
a4d82a8a | 8618 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 8619 | |
892fedb6 | 8620 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 8621 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
8622 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
8623 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8624 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8625 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 8626 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
8627 | json_object_string_add(bestpath, "med", |
8628 | "missing-as-worst"); | |
8629 | else | |
8630 | json_object_string_add(bestpath, "med", "true"); | |
8631 | } | |
8632 | ||
8633 | json_object_object_add(json, "bestPath", bestpath); | |
8634 | } | |
8635 | ||
3577f1c5 DD |
8636 | /* Print the error code/subcode for why the peer is down */ |
8637 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8638 | json_object *json_peer, bool use_json) | |
8639 | { | |
8640 | const char *code_str; | |
8641 | const char *subcode_str; | |
8642 | ||
8643 | if (use_json) { | |
8644 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8645 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8646 | char errorcodesubcode_hexstr[5]; | |
8647 | char errorcodesubcode_str[256]; | |
8648 | ||
8649 | code_str = bgp_notify_code_str(peer->notify.code); | |
8650 | subcode_str = bgp_notify_subcode_str( | |
8651 | peer->notify.code, | |
8652 | peer->notify.subcode); | |
8653 | ||
772270f3 QY |
8654 | snprintf(errorcodesubcode_hexstr, |
8655 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
8656 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
8657 | json_object_string_add(json_peer, |
8658 | "lastErrorCodeSubcode", | |
8659 | errorcodesubcode_hexstr); | |
8660 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8661 | code_str, subcode_str); | |
8662 | json_object_string_add(json_peer, | |
8663 | "lastNotificationReason", | |
8664 | errorcodesubcode_str); | |
8665 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8666 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8667 | && (peer->notify.subcode | |
8668 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8669 | || peer->notify.subcode | |
8670 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8671 | && peer->notify.length) { | |
8672 | char msgbuf[1024]; | |
8673 | const char *msg_str; | |
8674 | ||
8675 | msg_str = bgp_notify_admin_message( | |
8676 | msgbuf, sizeof(msgbuf), | |
8677 | (uint8_t *)peer->notify.data, | |
8678 | peer->notify.length); | |
8679 | if (msg_str) | |
8680 | json_object_string_add( | |
8681 | json_peer, | |
8682 | "lastShutdownDescription", | |
8683 | msg_str); | |
8684 | } | |
8685 | ||
c258527b | 8686 | } |
3577f1c5 DD |
8687 | json_object_string_add(json_peer, "lastResetDueTo", |
8688 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8689 | json_object_int_add(json_peer, "lastResetCode", |
8690 | peer->last_reset); | |
3577f1c5 DD |
8691 | } else { |
8692 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8693 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8694 | code_str = bgp_notify_code_str(peer->notify.code); | |
8695 | subcode_str = | |
8696 | bgp_notify_subcode_str(peer->notify.code, | |
8697 | peer->notify.subcode); | |
8698 | vty_out(vty, " Notification %s (%s%s)\n", | |
8699 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8700 | ? "sent" | |
8701 | : "received", | |
8702 | code_str, subcode_str); | |
8703 | } else { | |
e91c24c8 | 8704 | vty_out(vty, " %s\n", |
3577f1c5 DD |
8705 | peer_down_str[(int)peer->last_reset]); |
8706 | } | |
8707 | } | |
8708 | } | |
8709 | ||
8710 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8711 | safi_t safi) | |
8712 | { | |
8713 | return ((peer->status != Established) || | |
8714 | !peer->afc_recv[afi][safi]); | |
8715 | } | |
8716 | ||
8717 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8718 | struct peer *peer, json_object *json_peer, | |
8719 | int max_neighbor_width, bool use_json) | |
8720 | { | |
8721 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8722 | int len; | |
8723 | ||
8724 | if (use_json) { | |
8725 | if (peer_dynamic_neighbor(peer)) | |
8726 | json_object_boolean_true_add(json_peer, | |
8727 | "dynamicPeer"); | |
8728 | if (peer->hostname) | |
8729 | json_object_string_add(json_peer, "hostname", | |
8730 | peer->hostname); | |
8731 | ||
8732 | if (peer->domainname) | |
8733 | json_object_string_add(json_peer, "domainname", | |
8734 | peer->domainname); | |
8735 | json_object_int_add(json_peer, "connectionsEstablished", | |
8736 | peer->established); | |
8737 | json_object_int_add(json_peer, "connectionsDropped", | |
8738 | peer->dropped); | |
8739 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8740 | use_json, json_peer); | |
8741 | if (peer->status == Established) | |
8742 | json_object_string_add(json_peer, "lastResetDueTo", | |
8743 | "AFI/SAFI Not Negotiated"); | |
8744 | else | |
8745 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8746 | } else { | |
8747 | dn_flag[1] = '\0'; | |
8748 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8749 | if (peer->hostname | |
892fedb6 | 8750 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
8751 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
8752 | peer->hostname, peer->host); | |
8753 | else | |
8754 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8755 | ||
8756 | /* pad the neighbor column with spaces */ | |
8757 | if (len < max_neighbor_width) | |
8758 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8759 | " "); | |
e91c24c8 | 8760 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
8761 | peer->dropped, |
8762 | peer_uptime(peer->uptime, timebuf, | |
8763 | BGP_UPTIME_LEN, 0, NULL)); | |
8764 | if (peer->status == Established) | |
8765 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8766 | else | |
8767 | bgp_show_peer_reset(vty, peer, NULL, | |
8768 | false); | |
8769 | } | |
8770 | } | |
c258527b | 8771 | |
3577f1c5 | 8772 | |
718e3744 | 8773 | /* Show BGP peer's summary information. */ |
d62a17ae | 8774 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8775 | bool show_failed, bool use_json) |
d62a17ae | 8776 | { |
8777 | struct peer *peer; | |
8778 | struct listnode *node, *nnode; | |
8779 | unsigned int count = 0, dn_count = 0; | |
8780 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8781 | char neighbor_buf[VTY_BUFSIZ]; | |
8782 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8783 | int len, failed_count = 0; |
d62a17ae | 8784 | int max_neighbor_width = 0; |
8785 | int pfx_rcd_safi; | |
3c13337d | 8786 | json_object *json = NULL; |
d62a17ae | 8787 | json_object *json_peer = NULL; |
8788 | json_object *json_peers = NULL; | |
50e05855 | 8789 | struct peer_af *paf; |
d3ada366 | 8790 | struct bgp_filter *filter; |
d62a17ae | 8791 | |
8792 | /* labeled-unicast routes are installed in the unicast table so in order | |
8793 | * to | |
8794 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8795 | */ | |
3577f1c5 | 8796 | |
d62a17ae | 8797 | if (safi == SAFI_LABELED_UNICAST) |
8798 | pfx_rcd_safi = SAFI_UNICAST; | |
8799 | else | |
8800 | pfx_rcd_safi = safi; | |
8801 | ||
8802 | if (use_json) { | |
3c13337d | 8803 | json = json_object_new_object(); |
d62a17ae | 8804 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8805 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8806 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8807 | continue; | |
8808 | ||
8809 | if (peer->afc[afi][safi]) { | |
8810 | /* See if we have at least a single failed peer */ | |
8811 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8812 | failed_count++; | |
8813 | count++; | |
8814 | } | |
8815 | if (peer_dynamic_neighbor(peer)) | |
8816 | dn_count++; | |
8817 | } | |
c258527b | 8818 | |
d62a17ae | 8819 | } else { |
8820 | /* Loop over all neighbors that will be displayed to determine | |
8821 | * how many | |
8822 | * characters are needed for the Neighbor column | |
8823 | */ | |
8824 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8825 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8826 | continue; | |
8827 | ||
8828 | if (peer->afc[afi][safi]) { | |
8829 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8830 | if (peer_dynamic_neighbor(peer)) | |
8831 | dn_flag[0] = '*'; | |
8832 | ||
8833 | if (peer->hostname | |
892fedb6 DA |
8834 | && CHECK_FLAG(bgp->flags, |
8835 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
8836 | snprintf(neighbor_buf, |
8837 | sizeof(neighbor_buf), | |
8838 | "%s%s(%s) ", dn_flag, | |
8839 | peer->hostname, peer->host); | |
d62a17ae | 8840 | else |
772270f3 QY |
8841 | snprintf(neighbor_buf, |
8842 | sizeof(neighbor_buf), "%s%s ", | |
8843 | dn_flag, peer->host); | |
d62a17ae | 8844 | |
8845 | len = strlen(neighbor_buf); | |
8846 | ||
8847 | if (len > max_neighbor_width) | |
8848 | max_neighbor_width = len; | |
c258527b | 8849 | |
3577f1c5 DD |
8850 | /* See if we have at least a single failed peer */ |
8851 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8852 | failed_count++; | |
8853 | count++; | |
d62a17ae | 8854 | } |
8855 | } | |
f933309e | 8856 | |
d62a17ae | 8857 | /* Originally we displayed the Neighbor column as 16 |
8858 | * characters wide so make that the default | |
8859 | */ | |
8860 | if (max_neighbor_width < neighbor_col_default_width) | |
8861 | max_neighbor_width = neighbor_col_default_width; | |
8862 | } | |
f933309e | 8863 | |
3577f1c5 DD |
8864 | if (show_failed && !failed_count) { |
8865 | if (use_json) { | |
8866 | json_object_int_add(json, "failedPeersCount", 0); | |
8867 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8868 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8869 | |
8870 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8871 | json, JSON_C_TO_STRING_PRETTY)); | |
8872 | json_object_free(json); | |
8873 | } else { | |
8874 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8875 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8876 | } | |
8877 | return CMD_SUCCESS; | |
8878 | } | |
c258527b | 8879 | |
3577f1c5 | 8880 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8881 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8882 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8883 | continue; | |
8884 | ||
ea47320b DL |
8885 | if (!peer->afc[afi][safi]) |
8886 | continue; | |
d62a17ae | 8887 | |
ea47320b DL |
8888 | if (!count) { |
8889 | unsigned long ents; | |
8890 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8891 | int64_t vrf_id_ui; |
d62a17ae | 8892 | |
a4d82a8a PZ |
8893 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8894 | ? -1 | |
8895 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8896 | |
8897 | /* Usage summary and header */ | |
8898 | if (use_json) { | |
8899 | json_object_string_add( | |
8900 | json, "routerId", | |
8901 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8902 | json_object_int_add(json, "as", bgp->as); |
8903 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8904 | json_object_string_add( |
8905 | json, "vrfName", | |
8906 | (bgp->inst_type | |
8907 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8908 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8909 | : bgp->name); |
8910 | } else { | |
8911 | vty_out(vty, | |
8912 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8913 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8914 | bgp->vrf_id == VRF_UNKNOWN |
8915 | ? -1 | |
8916 | : (int)bgp->vrf_id); | |
ea47320b DL |
8917 | vty_out(vty, "\n"); |
8918 | } | |
d62a17ae | 8919 | |
ea47320b | 8920 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8921 | if (use_json) { |
ea47320b | 8922 | json_object_int_add( |
60466a63 | 8923 | json, "updateDelayLimit", |
ea47320b | 8924 | bgp->v_update_delay); |
d62a17ae | 8925 | |
ea47320b DL |
8926 | if (bgp->v_update_delay |
8927 | != bgp->v_establish_wait) | |
d62a17ae | 8928 | json_object_int_add( |
8929 | json, | |
ea47320b DL |
8930 | "updateDelayEstablishWait", |
8931 | bgp->v_establish_wait); | |
d62a17ae | 8932 | |
60466a63 | 8933 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8934 | json_object_string_add( |
8935 | json, | |
8936 | "updateDelayFirstNeighbor", | |
8937 | bgp->update_delay_begin_time); | |
8938 | json_object_boolean_true_add( | |
8939 | json, | |
8940 | "updateDelayInProgress"); | |
8941 | } else { | |
8942 | if (bgp->update_delay_over) { | |
d62a17ae | 8943 | json_object_string_add( |
8944 | json, | |
8945 | "updateDelayFirstNeighbor", | |
8946 | bgp->update_delay_begin_time); | |
ea47320b | 8947 | json_object_string_add( |
d62a17ae | 8948 | json, |
ea47320b DL |
8949 | "updateDelayBestpathResumed", |
8950 | bgp->update_delay_end_time); | |
8951 | json_object_string_add( | |
d62a17ae | 8952 | json, |
ea47320b DL |
8953 | "updateDelayZebraUpdateResume", |
8954 | bgp->update_delay_zebra_resume_time); | |
8955 | json_object_string_add( | |
8956 | json, | |
8957 | "updateDelayPeerUpdateResume", | |
8958 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8959 | } |
ea47320b DL |
8960 | } |
8961 | } else { | |
8962 | vty_out(vty, | |
8963 | "Read-only mode update-delay limit: %d seconds\n", | |
8964 | bgp->v_update_delay); | |
8965 | if (bgp->v_update_delay | |
8966 | != bgp->v_establish_wait) | |
d62a17ae | 8967 | vty_out(vty, |
ea47320b DL |
8968 | " Establish wait: %d seconds\n", |
8969 | bgp->v_establish_wait); | |
d62a17ae | 8970 | |
60466a63 | 8971 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8972 | vty_out(vty, |
8973 | " First neighbor established: %s\n", | |
8974 | bgp->update_delay_begin_time); | |
8975 | vty_out(vty, | |
8976 | " Delay in progress\n"); | |
8977 | } else { | |
8978 | if (bgp->update_delay_over) { | |
d62a17ae | 8979 | vty_out(vty, |
8980 | " First neighbor established: %s\n", | |
8981 | bgp->update_delay_begin_time); | |
8982 | vty_out(vty, | |
ea47320b DL |
8983 | " Best-paths resumed: %s\n", |
8984 | bgp->update_delay_end_time); | |
8985 | vty_out(vty, | |
8986 | " zebra update resumed: %s\n", | |
8987 | bgp->update_delay_zebra_resume_time); | |
8988 | vty_out(vty, | |
8989 | " peers update resumed: %s\n", | |
8990 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8991 | } |
8992 | } | |
8993 | } | |
ea47320b | 8994 | } |
d62a17ae | 8995 | |
ea47320b DL |
8996 | if (use_json) { |
8997 | if (bgp_maxmed_onstartup_configured(bgp) | |
8998 | && bgp->maxmed_active) | |
8999 | json_object_boolean_true_add( | |
60466a63 | 9000 | json, "maxMedOnStartup"); |
ea47320b DL |
9001 | if (bgp->v_maxmed_admin) |
9002 | json_object_boolean_true_add( | |
60466a63 | 9003 | json, "maxMedAdministrative"); |
d62a17ae | 9004 | |
ea47320b DL |
9005 | json_object_int_add( |
9006 | json, "tableVersion", | |
60466a63 | 9007 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 9008 | |
60466a63 QY |
9009 | ents = bgp_table_count(bgp->rib[afi][safi]); |
9010 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
9011 | json_object_int_add( |
9012 | json, "ribMemory", | |
9013 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 9014 | |
210ec2a0 | 9015 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
9016 | json_object_int_add(json, "peerCount", ents); |
9017 | json_object_int_add(json, "peerMemory", | |
9018 | ents * sizeof(struct peer)); | |
d62a17ae | 9019 | |
ea47320b DL |
9020 | if ((ents = listcount(bgp->group))) { |
9021 | json_object_int_add( | |
60466a63 | 9022 | json, "peerGroupCount", ents); |
ea47320b DL |
9023 | json_object_int_add( |
9024 | json, "peerGroupMemory", | |
996c9314 LB |
9025 | ents * sizeof(struct |
9026 | peer_group)); | |
ea47320b | 9027 | } |
d62a17ae | 9028 | |
ea47320b DL |
9029 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9030 | BGP_CONFIG_DAMPENING)) | |
9031 | json_object_boolean_true_add( | |
60466a63 | 9032 | json, "dampeningEnabled"); |
ea47320b DL |
9033 | } else { |
9034 | if (bgp_maxmed_onstartup_configured(bgp) | |
9035 | && bgp->maxmed_active) | |
d62a17ae | 9036 | vty_out(vty, |
ea47320b DL |
9037 | "Max-med on-startup active\n"); |
9038 | if (bgp->v_maxmed_admin) | |
d62a17ae | 9039 | vty_out(vty, |
ea47320b | 9040 | "Max-med administrative active\n"); |
d62a17ae | 9041 | |
60466a63 QY |
9042 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
9043 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 9044 | |
60466a63 | 9045 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
9046 | vty_out(vty, |
9047 | "RIB entries %ld, using %s of memory\n", | |
9048 | ents, | |
996c9314 LB |
9049 | mtype_memstr(memstrbuf, |
9050 | sizeof(memstrbuf), | |
9051 | ents * sizeof(struct | |
9052 | bgp_node))); | |
ea47320b DL |
9053 | |
9054 | /* Peer related usage */ | |
210ec2a0 | 9055 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 9056 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
9057 | ents, |
9058 | mtype_memstr( | |
60466a63 QY |
9059 | memstrbuf, sizeof(memstrbuf), |
9060 | ents * sizeof(struct peer))); | |
ea47320b DL |
9061 | |
9062 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 9063 | vty_out(vty, |
ea47320b | 9064 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 9065 | ents, |
9066 | mtype_memstr( | |
9067 | memstrbuf, | |
9068 | sizeof(memstrbuf), | |
996c9314 LB |
9069 | ents * sizeof(struct |
9070 | peer_group))); | |
d62a17ae | 9071 | |
ea47320b DL |
9072 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9073 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 9074 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 9075 | vty_out(vty, "\n"); |
d62a17ae | 9076 | |
ea47320b DL |
9077 | /* Subtract 8 here because 'Neighbor' is |
9078 | * 8 characters */ | |
9079 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
9080 | vty_out(vty, "%*s", max_neighbor_width - 8, |
9081 | " "); | |
3577f1c5 DD |
9082 | if (show_failed) |
9083 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9084 | else | |
9085 | vty_out(vty, | |
db92d226 | 9086 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 9087 | } |
ea47320b | 9088 | } |
d62a17ae | 9089 | |
d55811cc | 9090 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 9091 | filter = &peer->filter[afi][safi]; |
db92d226 | 9092 | |
ea47320b | 9093 | count++; |
3577f1c5 DD |
9094 | /* Works for both failed & successful cases */ |
9095 | if (peer_dynamic_neighbor(peer)) | |
9096 | dn_count++; | |
d62a17ae | 9097 | |
ea47320b | 9098 | if (use_json) { |
3577f1c5 DD |
9099 | json_peer = NULL; |
9100 | ||
9101 | if (show_failed && | |
9102 | bgp_has_peer_failed(peer, afi, safi)) { | |
9103 | json_peer = json_object_new_object(); | |
9104 | bgp_show_failed_summary(vty, bgp, peer, | |
9105 | json_peer, 0, use_json); | |
9106 | } else if (!show_failed) { | |
9107 | json_peer = json_object_new_object(); | |
9108 | if (peer_dynamic_neighbor(peer)) { | |
9109 | json_object_boolean_true_add(json_peer, | |
9110 | "dynamicPeer"); | |
9111 | } | |
d62a17ae | 9112 | |
3577f1c5 DD |
9113 | if (peer->hostname) |
9114 | json_object_string_add(json_peer, "hostname", | |
9115 | peer->hostname); | |
9116 | ||
9117 | if (peer->domainname) | |
9118 | json_object_string_add(json_peer, "domainname", | |
9119 | peer->domainname); | |
9120 | ||
9121 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9122 | json_object_int_add(json_peer, "version", 4); | |
9123 | json_object_int_add(json_peer, "msgRcvd", | |
9124 | PEER_TOTAL_RX(peer)); | |
9125 | json_object_int_add(json_peer, "msgSent", | |
9126 | PEER_TOTAL_TX(peer)); | |
9127 | ||
43aa5965 QY |
9128 | atomic_size_t outq_count, inq_count; |
9129 | outq_count = atomic_load_explicit( | |
9130 | &peer->obuf->count, | |
9131 | memory_order_relaxed); | |
9132 | inq_count = atomic_load_explicit( | |
9133 | &peer->ibuf->count, | |
9134 | memory_order_relaxed); | |
9135 | ||
3577f1c5 DD |
9136 | json_object_int_add(json_peer, "tableVersion", |
9137 | peer->version[afi][safi]); | |
9138 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
9139 | outq_count); |
9140 | json_object_int_add(json_peer, "inq", | |
9141 | inq_count); | |
3577f1c5 DD |
9142 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
9143 | use_json, json_peer); | |
9144 | ||
3577f1c5 DD |
9145 | json_object_int_add(json_peer, "pfxRcd", |
9146 | peer->pcount[afi][pfx_rcd_safi]); | |
9147 | ||
3577f1c5 DD |
9148 | if (paf && PAF_SUBGRP(paf)) |
9149 | json_object_int_add(json_peer, | |
9150 | "pfxSnt", | |
9151 | (PAF_SUBGRP(paf))->scount); | |
9152 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9153 | json_object_string_add(json_peer, "state", | |
9154 | "Idle (Admin)"); | |
9155 | else if (peer->afc_recv[afi][safi]) | |
9156 | json_object_string_add( | |
9157 | json_peer, "state", | |
9158 | lookup_msg(bgp_status_msg, peer->status, | |
9159 | NULL)); | |
9160 | else if (CHECK_FLAG(peer->sflags, | |
9161 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9162 | json_object_string_add(json_peer, "state", | |
9163 | "Idle (PfxCt)"); | |
9164 | else | |
9165 | json_object_string_add( | |
9166 | json_peer, "state", | |
9167 | lookup_msg(bgp_status_msg, peer->status, | |
9168 | NULL)); | |
200116db DD |
9169 | json_object_int_add(json_peer, "connectionsEstablished", |
9170 | peer->established); | |
9171 | json_object_int_add(json_peer, "connectionsDropped", | |
9172 | peer->dropped); | |
b4e9dcba | 9173 | } |
3577f1c5 DD |
9174 | /* Avoid creating empty peer dicts in JSON */ |
9175 | if (json_peer == NULL) | |
9176 | continue; | |
ea47320b DL |
9177 | |
9178 | if (peer->conf_if) | |
60466a63 | 9179 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9180 | "interface"); |
9181 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9182 | json_object_string_add(json_peer, "idType", |
9183 | "ipv4"); | |
ea47320b | 9184 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9185 | json_object_string_add(json_peer, "idType", |
9186 | "ipv6"); | |
ea47320b DL |
9187 | json_object_object_add(json_peers, peer->host, |
9188 | json_peer); | |
9189 | } else { | |
3577f1c5 DD |
9190 | if (show_failed && |
9191 | bgp_has_peer_failed(peer, afi, safi)) { | |
9192 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9193 | max_neighbor_width, | |
9194 | use_json); | |
9195 | } else if (!show_failed) { | |
9196 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9197 | if (peer_dynamic_neighbor(peer)) { | |
9198 | dn_flag[0] = '*'; | |
9199 | } | |
d62a17ae | 9200 | |
3577f1c5 | 9201 | if (peer->hostname |
892fedb6 DA |
9202 | && CHECK_FLAG(bgp->flags, |
9203 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 9204 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
9205 | peer->hostname, |
9206 | peer->host); | |
d62a17ae | 9207 | else |
3577f1c5 DD |
9208 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9209 | ||
9210 | /* pad the neighbor column with spaces */ | |
9211 | if (len < max_neighbor_width) | |
9212 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9213 | " "); | |
9214 | ||
43aa5965 QY |
9215 | atomic_size_t outq_count, inq_count; |
9216 | outq_count = atomic_load_explicit( | |
9217 | &peer->obuf->count, | |
9218 | memory_order_relaxed); | |
9219 | inq_count = atomic_load_explicit( | |
9220 | &peer->ibuf->count, | |
9221 | memory_order_relaxed); | |
9222 | ||
566bdaf6 | 9223 | vty_out(vty, |
43aa5965 QY |
9224 | "4 %10u %9u %9u %8" PRIu64 |
9225 | " %4zu %4zu %8s", | |
3577f1c5 | 9226 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 9227 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
9228 | peer->version[afi][safi], inq_count, |
9229 | outq_count, | |
3577f1c5 DD |
9230 | peer_uptime(peer->uptime, timebuf, |
9231 | BGP_UPTIME_LEN, 0, NULL)); | |
9232 | ||
db92d226 | 9233 | if (peer->status == Established) { |
d3ada366 DA |
9234 | if (peer->afc_recv[afi][safi]) { |
9235 | if (CHECK_FLAG( | |
9236 | bgp->flags, | |
9237 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9238 | && !bgp_inbound_policy_exists( | |
9239 | peer, filter)) | |
9240 | vty_out(vty, " %12s", | |
9241 | "(Policy)"); | |
9242 | else | |
9243 | vty_out(vty, | |
9244 | " %12" PRIu32, | |
9245 | peer->pcount | |
9246 | [afi] | |
9247 | [pfx_rcd_safi]); | |
9248 | } else { | |
3577f1c5 | 9249 | vty_out(vty, " NoNeg"); |
d3ada366 | 9250 | } |
db92d226 | 9251 | |
d3ada366 DA |
9252 | if (paf && PAF_SUBGRP(paf)) { |
9253 | if (CHECK_FLAG( | |
9254 | bgp->flags, | |
9255 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9256 | && !bgp_outbound_policy_exists( | |
9257 | peer, filter)) | |
9258 | vty_out(vty, " %8s", | |
9259 | "(Policy)"); | |
9260 | else | |
9261 | vty_out(vty, | |
9262 | " %8" PRIu32, | |
9263 | (PAF_SUBGRP( | |
9264 | paf)) | |
9265 | ->scount); | |
9266 | } | |
db92d226 | 9267 | } else { |
3577f1c5 DD |
9268 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
9269 | vty_out(vty, " Idle (Admin)"); | |
9270 | else if (CHECK_FLAG( | |
9271 | peer->sflags, | |
9272 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9273 | vty_out(vty, " Idle (PfxCt)"); | |
9274 | else | |
9275 | vty_out(vty, " %12s", | |
9276 | lookup_msg(bgp_status_msg, | |
9277 | peer->status, NULL)); | |
db92d226 DA |
9278 | |
9279 | vty_out(vty, " %8" PRIu32, 0); | |
3577f1c5 DD |
9280 | } |
9281 | vty_out(vty, "\n"); | |
d62a17ae | 9282 | } |
3577f1c5 | 9283 | |
d62a17ae | 9284 | } |
9285 | } | |
f933309e | 9286 | |
d62a17ae | 9287 | if (use_json) { |
9288 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9289 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9290 | json_object_int_add(json, "totalPeers", count); |
9291 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9292 | ||
3577f1c5 DD |
9293 | if (!show_failed) |
9294 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9295 | |
996c9314 LB |
9296 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9297 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9298 | json_object_free(json); |
9299 | } else { | |
9300 | if (count) | |
9301 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9302 | else { | |
d6ceaca3 | 9303 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9304 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9305 | } |
b05a1c8b | 9306 | |
d6ceaca3 | 9307 | if (dn_count) { |
d62a17ae | 9308 | vty_out(vty, "* - dynamic neighbor\n"); |
9309 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9310 | dn_count, bgp->dynamic_neighbors_limit); | |
9311 | } | |
9312 | } | |
1ff9a340 | 9313 | |
d62a17ae | 9314 | return CMD_SUCCESS; |
718e3744 | 9315 | } |
9316 | ||
d62a17ae | 9317 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 9318 | int safi, bool show_failed, bool use_json) |
d62a17ae | 9319 | { |
9320 | int is_first = 1; | |
9321 | int afi_wildcard = (afi == AFI_MAX); | |
9322 | int safi_wildcard = (safi == SAFI_MAX); | |
9323 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9324 | bool nbr_output = false; |
d62a17ae | 9325 | |
9326 | if (use_json && is_wildcard) | |
9327 | vty_out(vty, "{\n"); | |
9328 | if (afi_wildcard) | |
9329 | afi = 1; /* AFI_IP */ | |
9330 | while (afi < AFI_MAX) { | |
9331 | if (safi_wildcard) | |
9332 | safi = 1; /* SAFI_UNICAST */ | |
9333 | while (safi < SAFI_MAX) { | |
318cac96 | 9334 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9335 | nbr_output = true; |
f86897b9 | 9336 | |
d62a17ae | 9337 | if (is_wildcard) { |
9338 | /* | |
9339 | * So limit output to those afi/safi | |
9340 | * pairs that | |
9341 | * actualy have something interesting in | |
9342 | * them | |
9343 | */ | |
9344 | if (use_json) { | |
d62a17ae | 9345 | if (!is_first) |
9346 | vty_out(vty, ",\n"); | |
9347 | else | |
9348 | is_first = 0; | |
9349 | ||
9350 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9351 | get_afi_safi_str(afi, |
9352 | safi, | |
9353 | true)); | |
d62a17ae | 9354 | } else { |
9355 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9356 | get_afi_safi_str(afi, |
9357 | safi, | |
9358 | false)); | |
d62a17ae | 9359 | } |
9360 | } | |
3577f1c5 DD |
9361 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
9362 | use_json); | |
d62a17ae | 9363 | } |
9364 | safi++; | |
d62a17ae | 9365 | if (!safi_wildcard) |
9366 | safi = SAFI_MAX; | |
9367 | } | |
9368 | afi++; | |
ee851c8c | 9369 | if (!afi_wildcard) |
d62a17ae | 9370 | afi = AFI_MAX; |
9371 | } | |
9372 | ||
9373 | if (use_json && is_wildcard) | |
9374 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9375 | else if (!nbr_output) { |
9376 | if (use_json) | |
9377 | vty_out(vty, "{}\n"); | |
9378 | else | |
9379 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9380 | } | |
d62a17ae | 9381 | } |
9382 | ||
9383 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
9384 | safi_t safi, bool show_failed, |
9385 | bool use_json) | |
d62a17ae | 9386 | { |
9387 | struct listnode *node, *nnode; | |
9388 | struct bgp *bgp; | |
d62a17ae | 9389 | int is_first = 1; |
9f049418 | 9390 | bool nbr_output = false; |
d62a17ae | 9391 | |
9392 | if (use_json) | |
9393 | vty_out(vty, "{\n"); | |
9394 | ||
9395 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9396 | nbr_output = true; |
d62a17ae | 9397 | if (use_json) { |
d62a17ae | 9398 | if (!is_first) |
9399 | vty_out(vty, ",\n"); | |
9400 | else | |
9401 | is_first = 0; | |
9402 | ||
9403 | vty_out(vty, "\"%s\":", | |
9404 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9405 | ? VRF_DEFAULT_NAME |
d62a17ae | 9406 | : bgp->name); |
9407 | } else { | |
9408 | vty_out(vty, "\nInstance %s:\n", | |
9409 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9410 | ? VRF_DEFAULT_NAME |
d62a17ae | 9411 | : bgp->name); |
9412 | } | |
3577f1c5 DD |
9413 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9414 | use_json); | |
d62a17ae | 9415 | } |
9416 | ||
9417 | if (use_json) | |
9418 | vty_out(vty, "}\n"); | |
9f049418 DS |
9419 | else if (!nbr_output) |
9420 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9421 | } |
9422 | ||
9423 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 9424 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 9425 | { |
9426 | struct bgp *bgp; | |
9427 | ||
9428 | if (name) { | |
9429 | if (strmatch(name, "all")) { | |
9430 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 9431 | show_failed, |
d62a17ae | 9432 | use_json); |
9433 | return CMD_SUCCESS; | |
9434 | } else { | |
9435 | bgp = bgp_lookup_by_name(name); | |
9436 | ||
9437 | if (!bgp) { | |
9438 | if (use_json) | |
9439 | vty_out(vty, "{}\n"); | |
9440 | else | |
9441 | vty_out(vty, | |
ca61fd25 | 9442 | "%% BGP instance not found\n"); |
d62a17ae | 9443 | return CMD_WARNING; |
9444 | } | |
9445 | ||
f86897b9 | 9446 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 9447 | show_failed, use_json); |
d62a17ae | 9448 | return CMD_SUCCESS; |
9449 | } | |
9450 | } | |
9451 | ||
9452 | bgp = bgp_get_default(); | |
9453 | ||
9454 | if (bgp) | |
3577f1c5 DD |
9455 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9456 | use_json); | |
9f049418 | 9457 | else { |
ca61fd25 DS |
9458 | if (use_json) |
9459 | vty_out(vty, "{}\n"); | |
9460 | else | |
9461 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9462 | return CMD_WARNING; |
9463 | } | |
d62a17ae | 9464 | |
9465 | return CMD_SUCCESS; | |
4fb25c53 DW |
9466 | } |
9467 | ||
716b2d8a | 9468 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9469 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9470 | show_ip_bgp_summary_cmd, |
3577f1c5 | 9471 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 9472 | SHOW_STR |
9473 | IP_STR | |
9474 | BGP_STR | |
8386ac43 | 9475 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9476 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9477 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9478 | "Summary of BGP neighbor status\n" |
3577f1c5 | 9479 | "Show only sessions not in Established state\n" |
9973d184 | 9480 | JSON_STR) |
718e3744 | 9481 | { |
d62a17ae | 9482 | char *vrf = NULL; |
9483 | afi_t afi = AFI_MAX; | |
9484 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9485 | bool show_failed = false; |
d62a17ae | 9486 | |
9487 | int idx = 0; | |
9488 | ||
9489 | /* show [ip] bgp */ | |
9490 | if (argv_find(argv, argc, "ip", &idx)) | |
9491 | afi = AFI_IP; | |
9a8bdf1c PG |
9492 | /* [<vrf> VIEWVRFNAME] */ |
9493 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9494 | vrf = argv[idx + 1]->arg; | |
9495 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9496 | vrf = NULL; | |
9497 | } else if (argv_find(argv, argc, "view", &idx)) | |
9498 | /* [<view> VIEWVRFNAME] */ | |
9499 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9500 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9501 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9502 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9503 | } | |
9504 | ||
3577f1c5 DD |
9505 | if (argv_find(argv, argc, "failed", &idx)) |
9506 | show_failed = true; | |
9507 | ||
9f049418 | 9508 | bool uj = use_json(argc, argv); |
d62a17ae | 9509 | |
3577f1c5 | 9510 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 9511 | } |
9512 | ||
5cb5f4d0 | 9513 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9514 | { |
5cb5f4d0 DD |
9515 | if (for_json) |
9516 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9517 | else |
5cb5f4d0 | 9518 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9519 | } |
9520 | ||
d62a17ae | 9521 | |
9522 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9523 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9524 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9525 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9526 | bool use_json, json_object *json_pref) |
d62a17ae | 9527 | { |
9528 | /* Send-Mode */ | |
9529 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9530 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9531 | if (use_json) { | |
9532 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9533 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9534 | json_object_string_add(json_pref, "sendMode", | |
9535 | "advertisedAndReceived"); | |
9536 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9537 | json_object_string_add(json_pref, "sendMode", | |
9538 | "advertised"); | |
9539 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9540 | json_object_string_add(json_pref, "sendMode", | |
9541 | "received"); | |
9542 | } else { | |
9543 | vty_out(vty, " Send-mode: "); | |
9544 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9545 | vty_out(vty, "advertised"); | |
9546 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9547 | vty_out(vty, "%sreceived", | |
9548 | CHECK_FLAG(p->af_cap[afi][safi], | |
9549 | adv_smcap) | |
9550 | ? ", " | |
9551 | : ""); | |
9552 | vty_out(vty, "\n"); | |
9553 | } | |
9554 | } | |
9555 | ||
9556 | /* Receive-Mode */ | |
9557 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9558 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9559 | if (use_json) { | |
9560 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9561 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9562 | json_object_string_add(json_pref, "recvMode", | |
9563 | "advertisedAndReceived"); | |
9564 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9565 | json_object_string_add(json_pref, "recvMode", | |
9566 | "advertised"); | |
9567 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9568 | json_object_string_add(json_pref, "recvMode", | |
9569 | "received"); | |
9570 | } else { | |
9571 | vty_out(vty, " Receive-mode: "); | |
9572 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9573 | vty_out(vty, "advertised"); | |
9574 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9575 | vty_out(vty, "%sreceived", | |
9576 | CHECK_FLAG(p->af_cap[afi][safi], | |
9577 | adv_rmcap) | |
9578 | ? ", " | |
9579 | : ""); | |
9580 | vty_out(vty, "\n"); | |
9581 | } | |
9582 | } | |
9583 | } | |
9584 | ||
13909c4f DS |
9585 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9586 | struct peer *p, | |
9587 | bool use_json, | |
9588 | json_object *json) | |
2986cac2 | 9589 | { |
08c2d52a | 9590 | bool rbit_status = false; |
2986cac2 | 9591 | |
9592 | if (!use_json) | |
a53ca37b | 9593 | vty_out(vty, "\n R bit: "); |
2986cac2 | 9594 | |
13909c4f DS |
9595 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9596 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9597 | && (p->status == Established)) { | |
2986cac2 | 9598 | |
9599 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 9600 | rbit_status = true; |
2986cac2 | 9601 | else |
08c2d52a | 9602 | rbit_status = false; |
2986cac2 | 9603 | } |
9604 | ||
9605 | if (rbit_status) { | |
9606 | if (use_json) | |
13909c4f | 9607 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9608 | else |
9609 | vty_out(vty, "True\n"); | |
9610 | } else { | |
9611 | if (use_json) | |
13909c4f | 9612 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9613 | else |
9614 | vty_out(vty, "False\n"); | |
9615 | } | |
9616 | } | |
9617 | ||
13909c4f DS |
9618 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9619 | struct peer *peer, | |
9620 | bool use_json, | |
9621 | json_object *json) | |
2986cac2 | 9622 | { |
2bb5d39b | 9623 | const char *mode = "NotApplicable"; |
2986cac2 | 9624 | |
9625 | if (!use_json) | |
a53ca37b | 9626 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 9627 | |
13909c4f DS |
9628 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9629 | && (peer->status == Established)) { | |
2986cac2 | 9630 | |
13909c4f DS |
9631 | if ((peer->nsf_af_count == 0) |
9632 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9633 | |
2986cac2 | 9634 | mode = "Disable"; |
9635 | ||
13909c4f DS |
9636 | } else if (peer->nsf_af_count == 0 |
9637 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9638 | |
2986cac2 | 9639 | mode = "Helper"; |
9640 | ||
13909c4f DS |
9641 | } else if (peer->nsf_af_count != 0 |
9642 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9643 | |
2986cac2 | 9644 | mode = "Restart"; |
2986cac2 | 9645 | } |
9646 | } | |
9647 | ||
9648 | if (use_json) { | |
13909c4f | 9649 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9650 | } else |
9651 | vty_out(vty, mode, "\n"); | |
9652 | } | |
9653 | ||
13909c4f DS |
9654 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9655 | struct peer *p, | |
9656 | bool use_json, | |
9657 | json_object *json) | |
2986cac2 | 9658 | { |
9659 | const char *mode = "Invalid"; | |
9660 | ||
9661 | if (!use_json) | |
a53ca37b | 9662 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 9663 | |
9664 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9665 | mode = "Helper"; | |
9666 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9667 | mode = "Restart"; | |
9668 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9669 | mode = "Disable"; | |
2ba1fe69 | 9670 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9671 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9672 | mode = "Helper*"; | |
9673 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9674 | mode = "Restart*"; | |
9675 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9676 | mode = "Disable*"; | |
9677 | else | |
9678 | mode = "Invalid*"; | |
2ba1fe69 | 9679 | } |
2986cac2 | 9680 | |
9681 | if (use_json) { | |
13909c4f | 9682 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9683 | } else { |
9684 | vty_out(vty, mode, "\n"); | |
9685 | } | |
9686 | } | |
9687 | ||
13909c4f DS |
9688 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9689 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9690 | { |
2ba1fe69 | 9691 | afi_t afi; |
9692 | safi_t safi; | |
2986cac2 | 9693 | json_object *json_afi_safi = NULL; |
9694 | json_object *json_timer = NULL; | |
9695 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9696 | bool eor_flag = false; |
2986cac2 | 9697 | |
9698 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9699 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9700 | if (!peer->afc[afi][safi]) |
9701 | continue; | |
2986cac2 | 9702 | |
13909c4f DS |
9703 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9704 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9705 | continue; | |
9e3b51a7 | 9706 | |
13909c4f DS |
9707 | if (use_json) { |
9708 | json_afi_safi = json_object_new_object(); | |
9709 | json_endofrib_status = json_object_new_object(); | |
9710 | json_timer = json_object_new_object(); | |
9711 | } | |
2986cac2 | 9712 | |
13909c4f DS |
9713 | if (peer->eor_stime[afi][safi] |
9714 | >= peer->pkt_stime[afi][safi]) | |
9715 | eor_flag = true; | |
9716 | else | |
9717 | eor_flag = false; | |
2986cac2 | 9718 | |
13909c4f | 9719 | if (!use_json) { |
a53ca37b | 9720 | vty_out(vty, " %s:\n", |
13909c4f | 9721 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 9722 | |
a53ca37b | 9723 | vty_out(vty, " F bit: "); |
698ba8d0 | 9724 | } |
2986cac2 | 9725 | |
13909c4f DS |
9726 | if (peer->nsf[afi][safi] |
9727 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9728 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9729 | |
13909c4f DS |
9730 | if (use_json) { |
9731 | json_object_boolean_true_add( | |
2986cac2 | 9732 | json_afi_safi, "fBit"); |
13909c4f DS |
9733 | } else |
9734 | vty_out(vty, "True\n"); | |
9735 | } else { | |
9736 | if (use_json) | |
9737 | json_object_boolean_false_add( | |
9738 | json_afi_safi, "fBit"); | |
9739 | else | |
9740 | vty_out(vty, "False\n"); | |
9741 | } | |
2986cac2 | 9742 | |
13909c4f | 9743 | if (!use_json) |
a53ca37b | 9744 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 9745 | |
13909c4f DS |
9746 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9747 | PEER_STATUS_EOR_SEND)) { | |
9748 | if (use_json) { | |
9749 | json_object_boolean_true_add( | |
2986cac2 | 9750 | json_endofrib_status, |
13909c4f | 9751 | "endOfRibSend"); |
9e3b51a7 | 9752 | |
13909c4f DS |
9753 | PRINT_EOR_JSON(eor_flag); |
9754 | } else { | |
9755 | vty_out(vty, "Yes\n"); | |
9756 | vty_out(vty, | |
a53ca37b | 9757 | " End-of-RIB sent after update: "); |
2986cac2 | 9758 | |
13909c4f DS |
9759 | PRINT_EOR(eor_flag); |
9760 | } | |
9761 | } else { | |
9762 | if (use_json) { | |
9763 | json_object_boolean_false_add( | |
2986cac2 | 9764 | json_endofrib_status, |
13909c4f DS |
9765 | "endOfRibSend"); |
9766 | json_object_boolean_false_add( | |
9e3b51a7 | 9767 | json_endofrib_status, |
13909c4f DS |
9768 | "endOfRibSentAfterUpdate"); |
9769 | } else { | |
9770 | vty_out(vty, "No\n"); | |
9771 | vty_out(vty, | |
a53ca37b | 9772 | " End-of-RIB sent after update: "); |
13909c4f | 9773 | vty_out(vty, "No\n"); |
2986cac2 | 9774 | } |
13909c4f | 9775 | } |
2986cac2 | 9776 | |
a53ca37b DA |
9777 | if (!use_json) |
9778 | vty_out(vty, " End-of-RIB received: "); | |
9779 | ||
9780 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9781 | PEER_STATUS_EOR_RECEIVED)) { | |
9782 | if (use_json) | |
9783 | json_object_boolean_true_add( | |
9784 | json_endofrib_status, | |
9785 | "endOfRibRecv"); | |
9786 | else | |
9787 | vty_out(vty, "Yes\n"); | |
9788 | } else { | |
9789 | if (use_json) | |
9790 | json_object_boolean_false_add( | |
9791 | json_endofrib_status, | |
9792 | "endOfRibRecv"); | |
9793 | else | |
9794 | vty_out(vty, "No\n"); | |
9795 | } | |
9796 | ||
13909c4f DS |
9797 | if (use_json) { |
9798 | json_object_int_add(json_timer, | |
9799 | "stalePathTimer", | |
9800 | peer->bgp->stalepath_time); | |
2986cac2 | 9801 | |
13909c4f DS |
9802 | if (peer->t_gr_stale != NULL) { |
9803 | json_object_int_add( | |
2986cac2 | 9804 | json_timer, |
9805 | "stalePathTimerRemaining", | |
9806 | thread_timer_remain_second( | |
13909c4f DS |
9807 | peer->t_gr_stale)); |
9808 | } | |
3a75afa4 | 9809 | |
13909c4f DS |
9810 | /* Display Configured Selection |
9811 | * Deferral only when when | |
9812 | * Gr mode is enabled. | |
9813 | */ | |
9814 | if (CHECK_FLAG(peer->flags, | |
9815 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9816 | json_object_int_add( | |
3a75afa4 | 9817 | json_timer, |
2986cac2 | 9818 | "selectionDeferralTimer", |
9819 | peer->bgp->stalepath_time); | |
13909c4f | 9820 | } |
2986cac2 | 9821 | |
13909c4f DS |
9822 | if (peer->bgp->gr_info[afi][safi] |
9823 | .t_select_deferral | |
9824 | != NULL) { | |
2986cac2 | 9825 | |
13909c4f | 9826 | json_object_int_add( |
2986cac2 | 9827 | json_timer, |
9828 | "selectionDeferralTimerRemaining", | |
9829 | thread_timer_remain_second( | |
13909c4f DS |
9830 | peer->bgp |
9831 | ->gr_info[afi] | |
9832 | [safi] | |
9833 | .t_select_deferral)); | |
9834 | } | |
9835 | } else { | |
a53ca37b | 9836 | vty_out(vty, " Timers:\n"); |
13909c4f | 9837 | vty_out(vty, |
a53ca37b DA |
9838 | " Configured Stale Path Time(sec): %u\n", |
9839 | peer->bgp->stalepath_time); | |
2986cac2 | 9840 | |
a53ca37b | 9841 | if (peer->t_gr_stale != NULL) |
2986cac2 | 9842 | vty_out(vty, |
a53ca37b | 9843 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 9844 | thread_timer_remain_second( |
13909c4f | 9845 | peer->t_gr_stale)); |
13909c4f DS |
9846 | /* Display Configured Selection |
9847 | * Deferral only when when | |
9848 | * Gr mode is enabled. | |
9849 | */ | |
9850 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 9851 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 9852 | vty_out(vty, |
a53ca37b | 9853 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 9854 | peer->bgp->select_defer_time); |
2986cac2 | 9855 | |
13909c4f DS |
9856 | if (peer->bgp->gr_info[afi][safi] |
9857 | .t_select_deferral | |
a53ca37b | 9858 | != NULL) |
13909c4f | 9859 | vty_out(vty, |
a53ca37b | 9860 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 9861 | thread_timer_remain_second( |
13909c4f DS |
9862 | peer->bgp |
9863 | ->gr_info[afi] | |
9864 | [safi] | |
9865 | .t_select_deferral)); | |
2986cac2 | 9866 | } |
13909c4f DS |
9867 | if (use_json) { |
9868 | json_object_object_add(json_afi_safi, | |
9869 | "endOfRibStatus", | |
9870 | json_endofrib_status); | |
9871 | json_object_object_add(json_afi_safi, "timers", | |
9872 | json_timer); | |
9873 | json_object_object_add( | |
9874 | json, get_afi_safi_str(afi, safi, true), | |
9875 | json_afi_safi); | |
9876 | } | |
2986cac2 | 9877 | } |
9878 | } | |
9879 | } | |
9880 | ||
36235319 QY |
9881 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
9882 | struct peer *p, | |
9883 | bool use_json, | |
9884 | json_object *json) | |
2986cac2 | 9885 | { |
9886 | if (use_json) { | |
9887 | json_object *json_timer = NULL; | |
9888 | ||
9889 | json_timer = json_object_new_object(); | |
9890 | ||
13909c4f DS |
9891 | json_object_int_add(json_timer, "configuredRestartTimer", |
9892 | p->bgp->restart_time); | |
2986cac2 | 9893 | |
13909c4f DS |
9894 | json_object_int_add(json_timer, "receivedRestartTimer", |
9895 | p->v_gr_restart); | |
2986cac2 | 9896 | |
13909c4f DS |
9897 | if (p->t_gr_restart != NULL) |
9898 | json_object_int_add( | |
9899 | json_timer, "restartTimerRemaining", | |
9900 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 9901 | |
9902 | json_object_object_add(json, "timers", json_timer); | |
9903 | } else { | |
9904 | ||
a53ca37b DA |
9905 | vty_out(vty, " Timers:\n"); |
9906 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 9907 | p->bgp->restart_time); |
2986cac2 | 9908 | |
a53ca37b | 9909 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
9910 | p->v_gr_restart); |
9911 | if (p->t_gr_restart != NULL) | |
a53ca37b | 9912 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 9913 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 9914 | if (p->t_gr_restart != NULL) { |
a53ca37b | 9915 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
9916 | thread_timer_remain_second(p->t_gr_restart)); |
9917 | } | |
2986cac2 | 9918 | } |
9919 | } | |
9920 | ||
9921 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 9922 | bool use_json, json_object *json) |
2986cac2 | 9923 | { |
9924 | char buf[SU_ADDRSTRLEN] = {0}; | |
9925 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
9926 | /* '*' + v6 address of neighbor */ |
9927 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 9928 | |
2986cac2 | 9929 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
9930 | dn_flag[0] = '*'; | |
9931 | ||
9932 | if (p->conf_if) { | |
9933 | if (use_json) | |
13909c4f DS |
9934 | json_object_string_add( |
9935 | json, "neighborAddr", | |
2986cac2 | 9936 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
9937 | ? "none" |
9938 | : sockunion2str(&p->su, buf, | |
9939 | SU_ADDRSTRLEN)); | |
2986cac2 | 9940 | else |
13909c4f | 9941 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 9942 | BGP_PEER_SU_UNSPEC(p) |
9943 | ? "none" | |
9944 | : sockunion2str(&p->su, buf, | |
9945 | SU_ADDRSTRLEN)); | |
9946 | } else { | |
772270f3 QY |
9947 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
9948 | p->host); | |
2986cac2 | 9949 | |
9950 | if (use_json) | |
36235319 QY |
9951 | json_object_string_add(json, "neighborAddr", |
9952 | neighborAddr); | |
2986cac2 | 9953 | else |
36235319 | 9954 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 9955 | } |
9956 | ||
9957 | /* more gr info in new format */ | |
9958 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
9959 | } | |
9960 | ||
d62a17ae | 9961 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 9962 | safi_t safi, bool use_json, |
d62a17ae | 9963 | json_object *json_neigh) |
9964 | { | |
0291c246 MK |
9965 | struct bgp_filter *filter; |
9966 | struct peer_af *paf; | |
9967 | char orf_pfx_name[BUFSIZ]; | |
9968 | int orf_pfx_count; | |
9969 | json_object *json_af = NULL; | |
9970 | json_object *json_prefA = NULL; | |
9971 | json_object *json_prefB = NULL; | |
9972 | json_object *json_addr = NULL; | |
d62a17ae | 9973 | |
9974 | if (use_json) { | |
9975 | json_addr = json_object_new_object(); | |
9976 | json_af = json_object_new_object(); | |
9977 | filter = &p->filter[afi][safi]; | |
9978 | ||
9979 | if (peer_group_active(p)) | |
9980 | json_object_string_add(json_addr, "peerGroupMember", | |
9981 | p->group->name); | |
9982 | ||
9983 | paf = peer_af_find(p, afi, safi); | |
9984 | if (paf && PAF_SUBGRP(paf)) { | |
9985 | json_object_int_add(json_addr, "updateGroupId", | |
9986 | PAF_UPDGRP(paf)->id); | |
9987 | json_object_int_add(json_addr, "subGroupId", | |
9988 | PAF_SUBGRP(paf)->id); | |
9989 | json_object_int_add(json_addr, "packetQueueLength", | |
9990 | bpacket_queue_virtual_length(paf)); | |
9991 | } | |
9992 | ||
9993 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9994 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9995 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9996 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9997 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9998 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9999 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10000 | json_object_int_add(json_af, "orfType", | |
10001 | ORF_TYPE_PREFIX); | |
10002 | json_prefA = json_object_new_object(); | |
10003 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
10004 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
10005 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10006 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10007 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
10008 | use_json, json_prefA); | |
10009 | json_object_object_add(json_af, "orfPrefixList", | |
10010 | json_prefA); | |
10011 | } | |
10012 | ||
10013 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10014 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10015 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10016 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10017 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10018 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10019 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10020 | json_object_int_add(json_af, "orfOldType", | |
10021 | ORF_TYPE_PREFIX_OLD); | |
10022 | json_prefB = json_object_new_object(); | |
10023 | bgp_show_peer_afi_orf_cap( | |
10024 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10025 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10026 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10027 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
10028 | json_prefB); | |
10029 | json_object_object_add(json_af, "orfOldPrefixList", | |
10030 | json_prefB); | |
10031 | } | |
10032 | ||
10033 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10034 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10035 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10036 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10037 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10038 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10039 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10040 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10041 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10042 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10043 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10044 | json_object_object_add(json_addr, "afDependentCap", | |
10045 | json_af); | |
10046 | else | |
10047 | json_object_free(json_af); | |
10048 | ||
772270f3 QY |
10049 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10050 | p->host, afi, safi); | |
d62a17ae | 10051 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10052 | NULL, afi, orf_pfx_name, use_json); | |
10053 | ||
10054 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10055 | PEER_STATUS_ORF_PREFIX_SEND) | |
10056 | || orf_pfx_count) { | |
10057 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10058 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10059 | json_object_boolean_true_add(json_neigh, | |
10060 | "orfSent"); | |
10061 | if (orf_pfx_count) | |
10062 | json_object_int_add(json_addr, "orfRecvCounter", | |
10063 | orf_pfx_count); | |
10064 | } | |
10065 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10066 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10067 | json_object_string_add( | |
10068 | json_addr, "orfFirstUpdate", | |
10069 | "deferredUntilORFOrRouteRefreshRecvd"); | |
10070 | ||
10071 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10072 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10073 | json_object_boolean_true_add(json_addr, | |
10074 | "routeReflectorClient"); | |
10075 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10076 | PEER_FLAG_RSERVER_CLIENT)) | |
10077 | json_object_boolean_true_add(json_addr, | |
10078 | "routeServerClient"); | |
10079 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10080 | json_object_boolean_true_add(json_addr, | |
10081 | "inboundSoftConfigPermit"); | |
10082 | ||
10083 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10084 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10085 | json_object_boolean_true_add( | |
10086 | json_addr, | |
10087 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10088 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10089 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10090 | json_object_boolean_true_add( | |
10091 | json_addr, | |
10092 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10093 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10094 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10095 | json_object_boolean_true_add( | |
10096 | json_addr, | |
10097 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10098 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10099 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10100 | json_object_boolean_true_add( | |
10101 | json_addr, | |
10102 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10103 | ||
dcc68b5e MS |
10104 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10105 | json_object_boolean_true_add( | |
10106 | json_addr, | |
10107 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10108 | ->type_json_name); | |
d62a17ae | 10109 | |
10110 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10111 | json_object_string_add(json_addr, | |
10112 | "overrideASNsInOutboundUpdates", | |
10113 | "ifAspathEqualRemoteAs"); | |
10114 | ||
10115 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10116 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10117 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10118 | json_object_boolean_true_add(json_addr, | |
10119 | "routerAlwaysNextHop"); | |
10120 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10121 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10122 | json_object_boolean_true_add( | |
10123 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10124 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10125 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10126 | json_object_boolean_true_add( | |
10127 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10128 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10129 | json_object_boolean_true_add( | |
10130 | json_addr, "unchangedMedPropogatedToNbr"); | |
10131 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10132 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10133 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10134 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10135 | PEER_FLAG_SEND_COMMUNITY) | |
10136 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10137 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10138 | json_object_string_add(json_addr, | |
10139 | "commAttriSentToNbr", | |
10140 | "extendedAndStandard"); | |
10141 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10142 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10143 | json_object_string_add(json_addr, | |
10144 | "commAttriSentToNbr", | |
10145 | "extended"); | |
10146 | else | |
10147 | json_object_string_add(json_addr, | |
10148 | "commAttriSentToNbr", | |
10149 | "standard"); | |
10150 | } | |
10151 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10152 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10153 | if (p->default_rmap[afi][safi].name) | |
10154 | json_object_string_add( | |
10155 | json_addr, "defaultRouteMap", | |
10156 | p->default_rmap[afi][safi].name); | |
10157 | ||
10158 | if (paf && PAF_SUBGRP(paf) | |
10159 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10160 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10161 | json_object_boolean_true_add(json_addr, | |
10162 | "defaultSent"); | |
10163 | else | |
10164 | json_object_boolean_true_add(json_addr, | |
10165 | "defaultNotSent"); | |
10166 | } | |
10167 | ||
dff8f48d | 10168 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10169 | if (is_evpn_enabled()) |
60466a63 QY |
10170 | json_object_boolean_true_add( |
10171 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10172 | } |
10173 | ||
d62a17ae | 10174 | if (filter->plist[FILTER_IN].name |
10175 | || filter->dlist[FILTER_IN].name | |
10176 | || filter->aslist[FILTER_IN].name | |
10177 | || filter->map[RMAP_IN].name) | |
10178 | json_object_boolean_true_add(json_addr, | |
10179 | "inboundPathPolicyConfig"); | |
10180 | if (filter->plist[FILTER_OUT].name | |
10181 | || filter->dlist[FILTER_OUT].name | |
10182 | || filter->aslist[FILTER_OUT].name | |
10183 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10184 | json_object_boolean_true_add( | |
10185 | json_addr, "outboundPathPolicyConfig"); | |
10186 | ||
10187 | /* prefix-list */ | |
10188 | if (filter->plist[FILTER_IN].name) | |
10189 | json_object_string_add(json_addr, | |
10190 | "incomingUpdatePrefixFilterList", | |
10191 | filter->plist[FILTER_IN].name); | |
10192 | if (filter->plist[FILTER_OUT].name) | |
10193 | json_object_string_add(json_addr, | |
10194 | "outgoingUpdatePrefixFilterList", | |
10195 | filter->plist[FILTER_OUT].name); | |
10196 | ||
10197 | /* distribute-list */ | |
10198 | if (filter->dlist[FILTER_IN].name) | |
10199 | json_object_string_add( | |
10200 | json_addr, "incomingUpdateNetworkFilterList", | |
10201 | filter->dlist[FILTER_IN].name); | |
10202 | if (filter->dlist[FILTER_OUT].name) | |
10203 | json_object_string_add( | |
10204 | json_addr, "outgoingUpdateNetworkFilterList", | |
10205 | filter->dlist[FILTER_OUT].name); | |
10206 | ||
10207 | /* filter-list. */ | |
10208 | if (filter->aslist[FILTER_IN].name) | |
10209 | json_object_string_add(json_addr, | |
10210 | "incomingUpdateAsPathFilterList", | |
10211 | filter->aslist[FILTER_IN].name); | |
10212 | if (filter->aslist[FILTER_OUT].name) | |
10213 | json_object_string_add(json_addr, | |
10214 | "outgoingUpdateAsPathFilterList", | |
10215 | filter->aslist[FILTER_OUT].name); | |
10216 | ||
10217 | /* route-map. */ | |
10218 | if (filter->map[RMAP_IN].name) | |
10219 | json_object_string_add( | |
10220 | json_addr, "routeMapForIncomingAdvertisements", | |
10221 | filter->map[RMAP_IN].name); | |
10222 | if (filter->map[RMAP_OUT].name) | |
10223 | json_object_string_add( | |
10224 | json_addr, "routeMapForOutgoingAdvertisements", | |
10225 | filter->map[RMAP_OUT].name); | |
10226 | ||
9dac9fc8 | 10227 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10228 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10229 | && !bgp_inbound_policy_exists(p, filter)) |
10230 | json_object_string_add( | |
10231 | json_addr, "inboundEbgpRequiresPolicy", | |
10232 | "Inbound updates discarded due to missing policy"); | |
10233 | ||
10234 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10235 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10236 | && (!bgp_outbound_policy_exists(p, filter))) |
10237 | json_object_string_add( | |
10238 | json_addr, "outboundEbgpRequiresPolicy", | |
10239 | "Outbound updates discarded due to missing policy"); | |
10240 | ||
d62a17ae | 10241 | /* unsuppress-map */ |
10242 | if (filter->usmap.name) | |
10243 | json_object_string_add(json_addr, | |
10244 | "selectiveUnsuppressRouteMap", | |
10245 | filter->usmap.name); | |
10246 | ||
10247 | /* Receive prefix count */ | |
10248 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10249 | p->pcount[afi][safi]); | |
50e05855 AD |
10250 | if (paf && PAF_SUBGRP(paf)) |
10251 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10252 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10253 | |
fde246e8 DA |
10254 | /* Maximum prefix */ |
10255 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10256 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10257 | p->pmax_out[afi][safi]); | |
10258 | ||
d62a17ae | 10259 | /* Maximum prefix */ |
10260 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10261 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10262 | p->pmax[afi][safi]); | |
10263 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10264 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10265 | json_object_boolean_true_add( | |
10266 | json_addr, "prefixAllowedMaxWarning"); | |
10267 | json_object_int_add(json_addr, | |
10268 | "prefixAllowedWarningThresh", | |
10269 | p->pmax_threshold[afi][safi]); | |
10270 | if (p->pmax_restart[afi][safi]) | |
10271 | json_object_int_add( | |
10272 | json_addr, | |
10273 | "prefixAllowedRestartIntervalMsecs", | |
10274 | p->pmax_restart[afi][safi] * 60000); | |
10275 | } | |
2986cac2 | 10276 | json_object_object_add(json_neigh, |
36235319 | 10277 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10278 | json_addr); |
10279 | ||
10280 | } else { | |
10281 | filter = &p->filter[afi][safi]; | |
10282 | ||
10283 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10284 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10285 | |
10286 | if (peer_group_active(p)) | |
10287 | vty_out(vty, " %s peer-group member\n", | |
10288 | p->group->name); | |
10289 | ||
10290 | paf = peer_af_find(p, afi, safi); | |
10291 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10292 | vty_out(vty, " Update group %" PRIu64 |
10293 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10294 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10295 | vty_out(vty, " Packet Queue length %d\n", | |
10296 | bpacket_queue_virtual_length(paf)); | |
10297 | } else { | |
10298 | vty_out(vty, " Not part of any update group\n"); | |
10299 | } | |
10300 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10301 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10302 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10303 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10304 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10305 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10306 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10307 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10308 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10309 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10310 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10311 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10312 | ||
10313 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10314 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10315 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10316 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10317 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10318 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10319 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10320 | vty_out(vty, | |
10321 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10322 | ORF_TYPE_PREFIX); | |
10323 | bgp_show_peer_afi_orf_cap( | |
10324 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10325 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10326 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10327 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10328 | } | |
10329 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10330 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10331 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10332 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10333 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10334 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10335 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10336 | vty_out(vty, | |
10337 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10338 | ORF_TYPE_PREFIX_OLD); | |
10339 | bgp_show_peer_afi_orf_cap( | |
10340 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10341 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10342 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10343 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10344 | } | |
10345 | ||
772270f3 QY |
10346 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10347 | p->host, afi, safi); | |
d62a17ae | 10348 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10349 | NULL, afi, orf_pfx_name, use_json); | |
10350 | ||
10351 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10352 | PEER_STATUS_ORF_PREFIX_SEND) | |
10353 | || orf_pfx_count) { | |
10354 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10355 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10356 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10357 | vty_out(vty, " sent;"); | |
10358 | if (orf_pfx_count) | |
10359 | vty_out(vty, " received (%d entries)", | |
10360 | orf_pfx_count); | |
10361 | vty_out(vty, "\n"); | |
10362 | } | |
10363 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10364 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10365 | vty_out(vty, | |
10366 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10367 | ||
10368 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10369 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10370 | vty_out(vty, " Route-Reflector Client\n"); | |
10371 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10372 | PEER_FLAG_RSERVER_CLIENT)) | |
10373 | vty_out(vty, " Route-Server Client\n"); | |
10374 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10375 | vty_out(vty, | |
10376 | " Inbound soft reconfiguration allowed\n"); | |
10377 | ||
10378 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10379 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10380 | vty_out(vty, | |
10381 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10382 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10383 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10384 | vty_out(vty, | |
10385 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10386 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10387 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10388 | vty_out(vty, | |
10389 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10390 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10391 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10392 | vty_out(vty, | |
10393 | " Private AS numbers removed in updates to this neighbor\n"); | |
10394 | ||
dcc68b5e MS |
10395 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10396 | vty_out(vty, " %s\n", | |
10397 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10398 | ->human_description); | |
d62a17ae | 10399 | |
10400 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10401 | vty_out(vty, | |
10402 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10403 | ||
10404 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10405 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10406 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10407 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10408 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10409 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10410 | vty_out(vty, | |
10411 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10412 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10413 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10414 | vty_out(vty, | |
10415 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10416 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10417 | vty_out(vty, | |
10418 | " MED is propagated unchanged to this neighbor\n"); | |
10419 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10420 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10421 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10422 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10423 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10424 | vty_out(vty, | |
10425 | " Community attribute sent to this neighbor"); | |
10426 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10427 | PEER_FLAG_SEND_COMMUNITY) | |
10428 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10429 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10430 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10431 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10432 | vty_out(vty, "(all)\n"); | |
10433 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10434 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10435 | vty_out(vty, "(large)\n"); | |
10436 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10437 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10438 | vty_out(vty, "(extended)\n"); | |
10439 | else | |
10440 | vty_out(vty, "(standard)\n"); | |
10441 | } | |
10442 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10443 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10444 | vty_out(vty, " Default information originate,"); | |
10445 | ||
10446 | if (p->default_rmap[afi][safi].name) | |
10447 | vty_out(vty, " default route-map %s%s,", | |
10448 | p->default_rmap[afi][safi].map ? "*" | |
10449 | : "", | |
10450 | p->default_rmap[afi][safi].name); | |
10451 | if (paf && PAF_SUBGRP(paf) | |
10452 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10453 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10454 | vty_out(vty, " default sent\n"); | |
10455 | else | |
10456 | vty_out(vty, " default not sent\n"); | |
10457 | } | |
10458 | ||
dff8f48d MK |
10459 | /* advertise-vni-all */ |
10460 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10461 | if (is_evpn_enabled()) |
dff8f48d MK |
10462 | vty_out(vty, " advertise-all-vni\n"); |
10463 | } | |
10464 | ||
d62a17ae | 10465 | if (filter->plist[FILTER_IN].name |
10466 | || filter->dlist[FILTER_IN].name | |
10467 | || filter->aslist[FILTER_IN].name | |
10468 | || filter->map[RMAP_IN].name) | |
10469 | vty_out(vty, " Inbound path policy configured\n"); | |
10470 | if (filter->plist[FILTER_OUT].name | |
10471 | || filter->dlist[FILTER_OUT].name | |
10472 | || filter->aslist[FILTER_OUT].name | |
10473 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10474 | vty_out(vty, " Outbound path policy configured\n"); | |
10475 | ||
10476 | /* prefix-list */ | |
10477 | if (filter->plist[FILTER_IN].name) | |
10478 | vty_out(vty, | |
10479 | " Incoming update prefix filter list is %s%s\n", | |
10480 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10481 | filter->plist[FILTER_IN].name); | |
10482 | if (filter->plist[FILTER_OUT].name) | |
10483 | vty_out(vty, | |
10484 | " Outgoing update prefix filter list is %s%s\n", | |
10485 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10486 | filter->plist[FILTER_OUT].name); | |
10487 | ||
10488 | /* distribute-list */ | |
10489 | if (filter->dlist[FILTER_IN].name) | |
10490 | vty_out(vty, | |
10491 | " Incoming update network filter list is %s%s\n", | |
10492 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10493 | filter->dlist[FILTER_IN].name); | |
10494 | if (filter->dlist[FILTER_OUT].name) | |
10495 | vty_out(vty, | |
10496 | " Outgoing update network filter list is %s%s\n", | |
10497 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10498 | filter->dlist[FILTER_OUT].name); | |
10499 | ||
10500 | /* filter-list. */ | |
10501 | if (filter->aslist[FILTER_IN].name) | |
10502 | vty_out(vty, | |
10503 | " Incoming update AS path filter list is %s%s\n", | |
10504 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10505 | filter->aslist[FILTER_IN].name); | |
10506 | if (filter->aslist[FILTER_OUT].name) | |
10507 | vty_out(vty, | |
10508 | " Outgoing update AS path filter list is %s%s\n", | |
10509 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10510 | filter->aslist[FILTER_OUT].name); | |
10511 | ||
10512 | /* route-map. */ | |
10513 | if (filter->map[RMAP_IN].name) | |
10514 | vty_out(vty, | |
10515 | " Route map for incoming advertisements is %s%s\n", | |
10516 | filter->map[RMAP_IN].map ? "*" : "", | |
10517 | filter->map[RMAP_IN].name); | |
10518 | if (filter->map[RMAP_OUT].name) | |
10519 | vty_out(vty, | |
10520 | " Route map for outgoing advertisements is %s%s\n", | |
10521 | filter->map[RMAP_OUT].map ? "*" : "", | |
10522 | filter->map[RMAP_OUT].name); | |
10523 | ||
9dac9fc8 | 10524 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10525 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10526 | && !bgp_inbound_policy_exists(p, filter)) |
10527 | vty_out(vty, | |
10528 | " Inbound updates discarded due to missing policy\n"); | |
10529 | ||
10530 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10531 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10532 | && !bgp_outbound_policy_exists(p, filter)) |
10533 | vty_out(vty, | |
10534 | " Outbound updates discarded due to missing policy\n"); | |
10535 | ||
d62a17ae | 10536 | /* unsuppress-map */ |
10537 | if (filter->usmap.name) | |
10538 | vty_out(vty, | |
10539 | " Route map for selective unsuppress is %s%s\n", | |
10540 | filter->usmap.map ? "*" : "", | |
10541 | filter->usmap.name); | |
10542 | ||
10543 | /* Receive prefix count */ | |
a0a87037 DA |
10544 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10545 | p->pcount[afi][safi]); | |
d62a17ae | 10546 | |
fde246e8 DA |
10547 | /* maximum-prefix-out */ |
10548 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10549 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10550 | vty_out(vty, | |
10551 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10552 | p->pmax_out[afi][safi]); | |
10553 | ||
d62a17ae | 10554 | /* Maximum prefix */ |
10555 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10556 | vty_out(vty, |
10557 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10558 | p->pmax[afi][safi], |
10559 | CHECK_FLAG(p->af_flags[afi][safi], | |
10560 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10561 | ? " (warning-only)" | |
10562 | : ""); | |
10563 | vty_out(vty, " Threshold for warning message %d%%", | |
10564 | p->pmax_threshold[afi][safi]); | |
10565 | if (p->pmax_restart[afi][safi]) | |
10566 | vty_out(vty, ", restart interval %d min", | |
10567 | p->pmax_restart[afi][safi]); | |
10568 | vty_out(vty, "\n"); | |
10569 | } | |
10570 | ||
10571 | vty_out(vty, "\n"); | |
10572 | } | |
10573 | } | |
10574 | ||
9f049418 | 10575 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10576 | json_object *json) |
718e3744 | 10577 | { |
d62a17ae | 10578 | struct bgp *bgp; |
10579 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10580 | char timebuf[BGP_UPTIME_LEN]; | |
10581 | char dn_flag[2]; | |
d62a17ae | 10582 | afi_t afi; |
10583 | safi_t safi; | |
d7c0a89a QY |
10584 | uint16_t i; |
10585 | uint8_t *msg; | |
d62a17ae | 10586 | json_object *json_neigh = NULL; |
10587 | time_t epoch_tbuf; | |
718e3744 | 10588 | |
d62a17ae | 10589 | bgp = p->bgp; |
10590 | ||
10591 | if (use_json) | |
10592 | json_neigh = json_object_new_object(); | |
10593 | ||
10594 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10595 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10596 | dn_flag[0] = '*'; | |
10597 | ||
10598 | if (!use_json) { | |
10599 | if (p->conf_if) /* Configured interface name. */ | |
10600 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10601 | BGP_PEER_SU_UNSPEC(p) | |
10602 | ? "None" | |
10603 | : sockunion2str(&p->su, buf, | |
10604 | SU_ADDRSTRLEN)); | |
10605 | else /* Configured IP address. */ | |
10606 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10607 | p->host); | |
10608 | } | |
10609 | ||
10610 | if (use_json) { | |
10611 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10612 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10613 | "none"); | |
10614 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10615 | json_object_string_add( | |
10616 | json_neigh, "bgpNeighborAddr", | |
10617 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10618 | ||
10619 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10620 | ||
10621 | if (p->change_local_as) | |
10622 | json_object_int_add(json_neigh, "localAs", | |
10623 | p->change_local_as); | |
10624 | else | |
10625 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10626 | ||
10627 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10628 | json_object_boolean_true_add(json_neigh, | |
10629 | "localAsNoPrepend"); | |
10630 | ||
10631 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10632 | json_object_boolean_true_add(json_neigh, | |
10633 | "localAsReplaceAs"); | |
10634 | } else { | |
10635 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10636 | || (p->as_type == AS_INTERNAL)) | |
10637 | vty_out(vty, "remote AS %u, ", p->as); | |
10638 | else | |
10639 | vty_out(vty, "remote AS Unspecified, "); | |
10640 | vty_out(vty, "local AS %u%s%s, ", | |
10641 | p->change_local_as ? p->change_local_as : p->local_as, | |
10642 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10643 | ? " no-prepend" | |
10644 | : "", | |
10645 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10646 | ? " replace-as" | |
10647 | : ""); | |
10648 | } | |
faa16034 DS |
10649 | /* peer type internal or confed-internal */ |
10650 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10651 | if (use_json) { |
10652 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10653 | json_object_boolean_true_add( | |
10654 | json_neigh, "nbrConfedInternalLink"); | |
10655 | else | |
10656 | json_object_boolean_true_add(json_neigh, | |
10657 | "nbrInternalLink"); | |
10658 | } else { | |
10659 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10660 | vty_out(vty, "confed-internal link\n"); | |
10661 | else | |
10662 | vty_out(vty, "internal link\n"); | |
10663 | } | |
faa16034 DS |
10664 | /* peer type external or confed-external */ |
10665 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10666 | if (use_json) { |
10667 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10668 | json_object_boolean_true_add( | |
10669 | json_neigh, "nbrConfedExternalLink"); | |
10670 | else | |
10671 | json_object_boolean_true_add(json_neigh, | |
10672 | "nbrExternalLink"); | |
10673 | } else { | |
10674 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10675 | vty_out(vty, "confed-external link\n"); | |
10676 | else | |
10677 | vty_out(vty, "external link\n"); | |
10678 | } | |
faa16034 DS |
10679 | } else { |
10680 | if (use_json) | |
10681 | json_object_boolean_true_add(json_neigh, | |
10682 | "nbrUnspecifiedLink"); | |
10683 | else | |
10684 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10685 | } |
10686 | ||
10687 | /* Description. */ | |
10688 | if (p->desc) { | |
10689 | if (use_json) | |
10690 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10691 | else | |
10692 | vty_out(vty, " Description: %s\n", p->desc); | |
10693 | } | |
10694 | ||
10695 | if (p->hostname) { | |
10696 | if (use_json) { | |
10697 | if (p->hostname) | |
10698 | json_object_string_add(json_neigh, "hostname", | |
10699 | p->hostname); | |
10700 | ||
10701 | if (p->domainname) | |
10702 | json_object_string_add(json_neigh, "domainname", | |
10703 | p->domainname); | |
10704 | } else { | |
10705 | if (p->domainname && (p->domainname[0] != '\0')) | |
10706 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10707 | p->domainname); | |
10708 | else | |
10709 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10710 | } | |
10711 | } | |
10712 | ||
10713 | /* Peer-group */ | |
10714 | if (p->group) { | |
10715 | if (use_json) { | |
10716 | json_object_string_add(json_neigh, "peerGroup", | |
10717 | p->group->name); | |
10718 | ||
10719 | if (dn_flag[0]) { | |
10720 | struct prefix prefix, *range = NULL; | |
10721 | ||
10722 | sockunion2hostprefix(&(p->su), &prefix); | |
10723 | range = peer_group_lookup_dynamic_neighbor_range( | |
10724 | p->group, &prefix); | |
10725 | ||
10726 | if (range) { | |
10727 | prefix2str(range, buf1, sizeof(buf1)); | |
10728 | json_object_string_add( | |
10729 | json_neigh, | |
10730 | "peerSubnetRangeGroup", buf1); | |
10731 | } | |
10732 | } | |
10733 | } else { | |
10734 | vty_out(vty, | |
10735 | " Member of peer-group %s for session parameters\n", | |
10736 | p->group->name); | |
10737 | ||
10738 | if (dn_flag[0]) { | |
10739 | struct prefix prefix, *range = NULL; | |
10740 | ||
10741 | sockunion2hostprefix(&(p->su), &prefix); | |
10742 | range = peer_group_lookup_dynamic_neighbor_range( | |
10743 | p->group, &prefix); | |
10744 | ||
10745 | if (range) { | |
10746 | prefix2str(range, buf1, sizeof(buf1)); | |
10747 | vty_out(vty, | |
10748 | " Belongs to the subnet range group: %s\n", | |
10749 | buf1); | |
10750 | } | |
10751 | } | |
10752 | } | |
10753 | } | |
10754 | ||
10755 | if (use_json) { | |
10756 | /* Administrative shutdown. */ | |
10757 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10758 | json_object_boolean_true_add(json_neigh, | |
10759 | "adminShutDown"); | |
10760 | ||
10761 | /* BGP Version. */ | |
10762 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10763 | json_object_string_add( | |
10764 | json_neigh, "remoteRouterId", | |
10765 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10766 | json_object_string_add( |
10767 | json_neigh, "localRouterId", | |
10768 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10769 | sizeof(buf1))); | |
d62a17ae | 10770 | |
10771 | /* Confederation */ | |
10772 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10773 | && bgp_confederation_peers_check(bgp, p->as)) | |
10774 | json_object_boolean_true_add(json_neigh, | |
10775 | "nbrCommonAdmin"); | |
10776 | ||
10777 | /* Status. */ | |
10778 | json_object_string_add( | |
10779 | json_neigh, "bgpState", | |
10780 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10781 | ||
10782 | if (p->status == Established) { | |
10783 | time_t uptime; | |
d62a17ae | 10784 | |
10785 | uptime = bgp_clock(); | |
10786 | uptime -= p->uptime; | |
d62a17ae | 10787 | epoch_tbuf = time(NULL) - uptime; |
10788 | ||
d3c7efed DS |
10789 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10790 | uptime * 1000); | |
d62a17ae | 10791 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10792 | peer_uptime(p->uptime, timebuf, | |
10793 | BGP_UPTIME_LEN, 0, | |
10794 | NULL)); | |
10795 | json_object_int_add(json_neigh, | |
10796 | "bgpTimerUpEstablishedEpoch", | |
10797 | epoch_tbuf); | |
10798 | } | |
10799 | ||
10800 | else if (p->status == Active) { | |
10801 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10802 | json_object_string_add(json_neigh, "bgpStateIs", | |
10803 | "passive"); | |
10804 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10805 | json_object_string_add(json_neigh, "bgpStateIs", | |
10806 | "passiveNSF"); | |
10807 | } | |
10808 | ||
10809 | /* read timer */ | |
10810 | time_t uptime; | |
a2700b50 | 10811 | struct tm tm; |
d62a17ae | 10812 | |
10813 | uptime = bgp_clock(); | |
10814 | uptime -= p->readtime; | |
a2700b50 MS |
10815 | gmtime_r(&uptime, &tm); |
10816 | ||
d62a17ae | 10817 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
10818 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10819 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10820 | |
10821 | uptime = bgp_clock(); | |
10822 | uptime -= p->last_write; | |
a2700b50 MS |
10823 | gmtime_r(&uptime, &tm); |
10824 | ||
d62a17ae | 10825 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
10826 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10827 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10828 | |
10829 | uptime = bgp_clock(); | |
10830 | uptime -= p->update_time; | |
a2700b50 MS |
10831 | gmtime_r(&uptime, &tm); |
10832 | ||
d62a17ae | 10833 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
10834 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10835 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10836 | |
10837 | /* Configured timer values. */ | |
10838 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10839 | p->v_holdtime * 1000); | |
10840 | json_object_int_add(json_neigh, | |
10841 | "bgpTimerKeepAliveIntervalMsecs", | |
10842 | p->v_keepalive * 1000); | |
b90a8e13 | 10843 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10844 | json_object_int_add(json_neigh, |
10845 | "bgpTimerConfiguredHoldTimeMsecs", | |
10846 | p->holdtime * 1000); | |
10847 | json_object_int_add( | |
10848 | json_neigh, | |
10849 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10850 | p->keepalive * 1000); | |
5d5393b9 DL |
10851 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10852 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10853 | json_object_int_add(json_neigh, |
10854 | "bgpTimerConfiguredHoldTimeMsecs", | |
10855 | bgp->default_holdtime); | |
10856 | json_object_int_add( | |
10857 | json_neigh, | |
10858 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10859 | bgp->default_keepalive); | |
d62a17ae | 10860 | } |
10861 | } else { | |
10862 | /* Administrative shutdown. */ | |
10863 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10864 | vty_out(vty, " Administratively shut down\n"); | |
10865 | ||
10866 | /* BGP Version. */ | |
10867 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10868 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10869 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10870 | vty_out(vty, ", local router ID %s\n", |
10871 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10872 | sizeof(buf1))); | |
d62a17ae | 10873 | |
10874 | /* Confederation */ | |
10875 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10876 | && bgp_confederation_peers_check(bgp, p->as)) | |
10877 | vty_out(vty, | |
10878 | " Neighbor under common administration\n"); | |
10879 | ||
10880 | /* Status. */ | |
10881 | vty_out(vty, " BGP state = %s", | |
10882 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10883 | ||
10884 | if (p->status == Established) | |
10885 | vty_out(vty, ", up for %8s", | |
10886 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10887 | 0, NULL)); | |
10888 | ||
10889 | else if (p->status == Active) { | |
10890 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10891 | vty_out(vty, " (passive)"); | |
10892 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10893 | vty_out(vty, " (NSF passive)"); | |
10894 | } | |
10895 | vty_out(vty, "\n"); | |
10896 | ||
10897 | /* read timer */ | |
10898 | vty_out(vty, " Last read %s", | |
10899 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
10900 | NULL)); | |
10901 | vty_out(vty, ", Last write %s\n", | |
10902 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
10903 | NULL)); | |
10904 | ||
10905 | /* Configured timer values. */ | |
10906 | vty_out(vty, | |
10907 | " Hold time is %d, keepalive interval is %d seconds\n", | |
10908 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 10909 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10910 | vty_out(vty, " Configured hold time is %d", |
10911 | p->holdtime); | |
10912 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10913 | p->keepalive); | |
5d5393b9 DL |
10914 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10915 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10916 | vty_out(vty, " Configured hold time is %d", |
10917 | bgp->default_holdtime); | |
10918 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10919 | bgp->default_keepalive); | |
d62a17ae | 10920 | } |
10921 | } | |
10922 | /* Capability. */ | |
10923 | if (p->status == Established) { | |
10924 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
10925 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
10926 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
10927 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
10928 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
10929 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
10930 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
10931 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
10932 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
10933 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
10934 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
10935 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 10936 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
10937 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 10938 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
10939 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 10940 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
10941 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 10942 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
10943 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
10944 | if (use_json) { | |
10945 | json_object *json_cap = NULL; | |
10946 | ||
10947 | json_cap = json_object_new_object(); | |
10948 | ||
10949 | /* AS4 */ | |
10950 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10951 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10952 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
10953 | && CHECK_FLAG(p->cap, | |
10954 | PEER_CAP_AS4_RCV)) | |
10955 | json_object_string_add( | |
10956 | json_cap, "4byteAs", | |
10957 | "advertisedAndReceived"); | |
10958 | else if (CHECK_FLAG(p->cap, | |
10959 | PEER_CAP_AS4_ADV)) | |
10960 | json_object_string_add( | |
10961 | json_cap, "4byteAs", | |
10962 | "advertised"); | |
10963 | else if (CHECK_FLAG(p->cap, | |
10964 | PEER_CAP_AS4_RCV)) | |
10965 | json_object_string_add( | |
10966 | json_cap, "4byteAs", | |
10967 | "received"); | |
10968 | } | |
10969 | ||
10970 | /* AddPath */ | |
10971 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10972 | || CHECK_FLAG(p->cap, | |
10973 | PEER_CAP_ADDPATH_ADV)) { | |
10974 | json_object *json_add = NULL; | |
10975 | const char *print_store; | |
10976 | ||
10977 | json_add = json_object_new_object(); | |
10978 | ||
05c7a1cc QY |
10979 | FOREACH_AFI_SAFI (afi, safi) { |
10980 | json_object *json_sub = NULL; | |
10981 | json_sub = | |
10982 | json_object_new_object(); | |
5cb5f4d0 DD |
10983 | print_store = get_afi_safi_str( |
10984 | afi, safi, true); | |
d62a17ae | 10985 | |
05c7a1cc QY |
10986 | if (CHECK_FLAG( |
10987 | p->af_cap[afi] | |
10988 | [safi], | |
10989 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10990 | || CHECK_FLAG( | |
10991 | p->af_cap[afi] | |
10992 | [safi], | |
10993 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 10994 | if (CHECK_FLAG( |
10995 | p->af_cap | |
10996 | [afi] | |
10997 | [safi], | |
10998 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 10999 | && CHECK_FLAG( |
d62a17ae | 11000 | p->af_cap |
11001 | [afi] | |
11002 | [safi], | |
05c7a1cc QY |
11003 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
11004 | json_object_boolean_true_add( | |
11005 | json_sub, | |
11006 | "txAdvertisedAndReceived"); | |
11007 | else if ( | |
11008 | CHECK_FLAG( | |
11009 | p->af_cap | |
11010 | [afi] | |
11011 | [safi], | |
11012 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
11013 | json_object_boolean_true_add( | |
11014 | json_sub, | |
11015 | "txAdvertised"); | |
11016 | else if ( | |
11017 | CHECK_FLAG( | |
11018 | p->af_cap | |
11019 | [afi] | |
11020 | [safi], | |
11021 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11022 | json_object_boolean_true_add( | |
11023 | json_sub, | |
11024 | "txReceived"); | |
11025 | } | |
d62a17ae | 11026 | |
05c7a1cc QY |
11027 | if (CHECK_FLAG( |
11028 | p->af_cap[afi] | |
11029 | [safi], | |
11030 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11031 | || CHECK_FLAG( | |
11032 | p->af_cap[afi] | |
11033 | [safi], | |
11034 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 11035 | if (CHECK_FLAG( |
11036 | p->af_cap | |
11037 | [afi] | |
11038 | [safi], | |
11039 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 11040 | && CHECK_FLAG( |
d62a17ae | 11041 | p->af_cap |
11042 | [afi] | |
11043 | [safi], | |
11044 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
11045 | json_object_boolean_true_add( |
11046 | json_sub, | |
11047 | "rxAdvertisedAndReceived"); | |
11048 | else if ( | |
11049 | CHECK_FLAG( | |
11050 | p->af_cap | |
11051 | [afi] | |
11052 | [safi], | |
11053 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
11054 | json_object_boolean_true_add( | |
11055 | json_sub, | |
11056 | "rxAdvertised"); | |
11057 | else if ( | |
11058 | CHECK_FLAG( | |
11059 | p->af_cap | |
11060 | [afi] | |
11061 | [safi], | |
11062 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11063 | json_object_boolean_true_add( | |
11064 | json_sub, | |
11065 | "rxReceived"); | |
d62a17ae | 11066 | } |
11067 | ||
05c7a1cc QY |
11068 | if (CHECK_FLAG( |
11069 | p->af_cap[afi] | |
11070 | [safi], | |
11071 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11072 | || CHECK_FLAG( | |
11073 | p->af_cap[afi] | |
11074 | [safi], | |
11075 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
11076 | || CHECK_FLAG( | |
11077 | p->af_cap[afi] | |
11078 | [safi], | |
11079 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11080 | || CHECK_FLAG( | |
11081 | p->af_cap[afi] | |
11082 | [safi], | |
11083 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11084 | json_object_object_add( | |
11085 | json_add, | |
11086 | print_store, | |
11087 | json_sub); | |
11088 | else | |
11089 | json_object_free( | |
11090 | json_sub); | |
11091 | } | |
11092 | ||
d62a17ae | 11093 | json_object_object_add( |
11094 | json_cap, "addPath", json_add); | |
11095 | } | |
11096 | ||
11097 | /* Dynamic */ | |
11098 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11099 | || CHECK_FLAG(p->cap, | |
11100 | PEER_CAP_DYNAMIC_ADV)) { | |
11101 | if (CHECK_FLAG(p->cap, | |
11102 | PEER_CAP_DYNAMIC_ADV) | |
11103 | && CHECK_FLAG(p->cap, | |
11104 | PEER_CAP_DYNAMIC_RCV)) | |
11105 | json_object_string_add( | |
11106 | json_cap, "dynamic", | |
11107 | "advertisedAndReceived"); | |
11108 | else if (CHECK_FLAG( | |
11109 | p->cap, | |
11110 | PEER_CAP_DYNAMIC_ADV)) | |
11111 | json_object_string_add( | |
11112 | json_cap, "dynamic", | |
11113 | "advertised"); | |
11114 | else if (CHECK_FLAG( | |
11115 | p->cap, | |
11116 | PEER_CAP_DYNAMIC_RCV)) | |
11117 | json_object_string_add( | |
11118 | json_cap, "dynamic", | |
11119 | "received"); | |
11120 | } | |
11121 | ||
11122 | /* Extended nexthop */ | |
11123 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11124 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11125 | json_object *json_nxt = NULL; | |
11126 | const char *print_store; | |
11127 | ||
11128 | ||
11129 | if (CHECK_FLAG(p->cap, | |
11130 | PEER_CAP_ENHE_ADV) | |
11131 | && CHECK_FLAG(p->cap, | |
11132 | PEER_CAP_ENHE_RCV)) | |
11133 | json_object_string_add( | |
11134 | json_cap, | |
11135 | "extendedNexthop", | |
11136 | "advertisedAndReceived"); | |
11137 | else if (CHECK_FLAG(p->cap, | |
11138 | PEER_CAP_ENHE_ADV)) | |
11139 | json_object_string_add( | |
11140 | json_cap, | |
11141 | "extendedNexthop", | |
11142 | "advertised"); | |
11143 | else if (CHECK_FLAG(p->cap, | |
11144 | PEER_CAP_ENHE_RCV)) | |
11145 | json_object_string_add( | |
11146 | json_cap, | |
11147 | "extendedNexthop", | |
11148 | "received"); | |
11149 | ||
11150 | if (CHECK_FLAG(p->cap, | |
11151 | PEER_CAP_ENHE_RCV)) { | |
11152 | json_nxt = | |
11153 | json_object_new_object(); | |
11154 | ||
11155 | for (safi = SAFI_UNICAST; | |
11156 | safi < SAFI_MAX; safi++) { | |
11157 | if (CHECK_FLAG( | |
11158 | p->af_cap | |
11159 | [AFI_IP] | |
11160 | [safi], | |
11161 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11162 | print_store = get_afi_safi_str( |
d62a17ae | 11163 | AFI_IP, |
5cb5f4d0 | 11164 | safi, true); |
d62a17ae | 11165 | json_object_string_add( |
11166 | json_nxt, | |
11167 | print_store, | |
54f29523 | 11168 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11169 | } |
11170 | } | |
11171 | json_object_object_add( | |
11172 | json_cap, | |
11173 | "extendedNexthopFamililesByPeer", | |
11174 | json_nxt); | |
11175 | } | |
11176 | } | |
11177 | ||
11178 | /* Route Refresh */ | |
11179 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11180 | || CHECK_FLAG(p->cap, | |
11181 | PEER_CAP_REFRESH_NEW_RCV) | |
11182 | || CHECK_FLAG(p->cap, | |
11183 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11184 | if (CHECK_FLAG(p->cap, | |
11185 | PEER_CAP_REFRESH_ADV) | |
11186 | && (CHECK_FLAG( | |
11187 | p->cap, | |
11188 | PEER_CAP_REFRESH_NEW_RCV) | |
11189 | || CHECK_FLAG( | |
11190 | p->cap, | |
11191 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11192 | if (CHECK_FLAG( | |
11193 | p->cap, | |
11194 | PEER_CAP_REFRESH_OLD_RCV) | |
11195 | && CHECK_FLAG( | |
11196 | p->cap, | |
11197 | PEER_CAP_REFRESH_NEW_RCV)) | |
11198 | json_object_string_add( | |
11199 | json_cap, | |
11200 | "routeRefresh", | |
11201 | "advertisedAndReceivedOldNew"); | |
11202 | else { | |
11203 | if (CHECK_FLAG( | |
11204 | p->cap, | |
11205 | PEER_CAP_REFRESH_OLD_RCV)) | |
11206 | json_object_string_add( | |
11207 | json_cap, | |
11208 | "routeRefresh", | |
11209 | "advertisedAndReceivedOld"); | |
11210 | else | |
11211 | json_object_string_add( | |
11212 | json_cap, | |
11213 | "routeRefresh", | |
11214 | "advertisedAndReceivedNew"); | |
11215 | } | |
11216 | } else if ( | |
11217 | CHECK_FLAG( | |
11218 | p->cap, | |
11219 | PEER_CAP_REFRESH_ADV)) | |
11220 | json_object_string_add( | |
11221 | json_cap, | |
11222 | "routeRefresh", | |
11223 | "advertised"); | |
11224 | else if ( | |
11225 | CHECK_FLAG( | |
11226 | p->cap, | |
11227 | PEER_CAP_REFRESH_NEW_RCV) | |
11228 | || CHECK_FLAG( | |
11229 | p->cap, | |
11230 | PEER_CAP_REFRESH_OLD_RCV)) | |
11231 | json_object_string_add( | |
11232 | json_cap, | |
11233 | "routeRefresh", | |
11234 | "received"); | |
11235 | } | |
11236 | ||
11237 | /* Multiprotocol Extensions */ | |
11238 | json_object *json_multi = NULL; | |
11239 | json_multi = json_object_new_object(); | |
11240 | ||
05c7a1cc QY |
11241 | FOREACH_AFI_SAFI (afi, safi) { |
11242 | if (p->afc_adv[afi][safi] | |
11243 | || p->afc_recv[afi][safi]) { | |
11244 | json_object *json_exten = NULL; | |
11245 | json_exten = | |
11246 | json_object_new_object(); | |
11247 | ||
d62a17ae | 11248 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11249 | && p->afc_recv[afi][safi]) |
11250 | json_object_boolean_true_add( | |
11251 | json_exten, | |
11252 | "advertisedAndReceived"); | |
11253 | else if (p->afc_adv[afi][safi]) | |
11254 | json_object_boolean_true_add( | |
11255 | json_exten, | |
11256 | "advertised"); | |
11257 | else if (p->afc_recv[afi][safi]) | |
11258 | json_object_boolean_true_add( | |
11259 | json_exten, | |
11260 | "received"); | |
d62a17ae | 11261 | |
05c7a1cc QY |
11262 | json_object_object_add( |
11263 | json_multi, | |
5cb5f4d0 DD |
11264 | get_afi_safi_str(afi, |
11265 | safi, | |
11266 | true), | |
05c7a1cc | 11267 | json_exten); |
d62a17ae | 11268 | } |
11269 | } | |
11270 | json_object_object_add( | |
11271 | json_cap, "multiprotocolExtensions", | |
11272 | json_multi); | |
11273 | ||
d77114b7 | 11274 | /* Hostname capabilities */ |
60466a63 | 11275 | json_object *json_hname = NULL; |
d77114b7 MK |
11276 | |
11277 | json_hname = json_object_new_object(); | |
11278 | ||
11279 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11280 | json_object_string_add( | |
60466a63 QY |
11281 | json_hname, "advHostName", |
11282 | bgp->peer_self->hostname | |
11283 | ? bgp->peer_self | |
11284 | ->hostname | |
d77114b7 MK |
11285 | : "n/a"); |
11286 | json_object_string_add( | |
60466a63 QY |
11287 | json_hname, "advDomainName", |
11288 | bgp->peer_self->domainname | |
11289 | ? bgp->peer_self | |
11290 | ->domainname | |
d77114b7 MK |
11291 | : "n/a"); |
11292 | } | |
11293 | ||
11294 | ||
11295 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11296 | json_object_string_add( | |
60466a63 QY |
11297 | json_hname, "rcvHostName", |
11298 | p->hostname ? p->hostname | |
11299 | : "n/a"); | |
d77114b7 | 11300 | json_object_string_add( |
60466a63 QY |
11301 | json_hname, "rcvDomainName", |
11302 | p->domainname ? p->domainname | |
11303 | : "n/a"); | |
d77114b7 MK |
11304 | } |
11305 | ||
60466a63 | 11306 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11307 | json_hname); |
11308 | ||
d62a17ae | 11309 | /* Gracefull Restart */ |
11310 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11311 | || CHECK_FLAG(p->cap, | |
11312 | PEER_CAP_RESTART_ADV)) { | |
11313 | if (CHECK_FLAG(p->cap, | |
11314 | PEER_CAP_RESTART_ADV) | |
11315 | && CHECK_FLAG(p->cap, | |
11316 | PEER_CAP_RESTART_RCV)) | |
11317 | json_object_string_add( | |
11318 | json_cap, | |
11319 | "gracefulRestart", | |
11320 | "advertisedAndReceived"); | |
11321 | else if (CHECK_FLAG( | |
11322 | p->cap, | |
11323 | PEER_CAP_RESTART_ADV)) | |
11324 | json_object_string_add( | |
11325 | json_cap, | |
11326 | "gracefulRestartCapability", | |
11327 | "advertised"); | |
11328 | else if (CHECK_FLAG( | |
11329 | p->cap, | |
11330 | PEER_CAP_RESTART_RCV)) | |
11331 | json_object_string_add( | |
11332 | json_cap, | |
11333 | "gracefulRestartCapability", | |
11334 | "received"); | |
11335 | ||
11336 | if (CHECK_FLAG(p->cap, | |
11337 | PEER_CAP_RESTART_RCV)) { | |
11338 | int restart_af_count = 0; | |
11339 | json_object *json_restart = | |
11340 | NULL; | |
11341 | json_restart = | |
11342 | json_object_new_object(); | |
11343 | ||
11344 | json_object_int_add( | |
11345 | json_cap, | |
11346 | "gracefulRestartRemoteTimerMsecs", | |
11347 | p->v_gr_restart * 1000); | |
11348 | ||
05c7a1cc QY |
11349 | FOREACH_AFI_SAFI (afi, safi) { |
11350 | if (CHECK_FLAG( | |
11351 | p->af_cap | |
11352 | [afi] | |
11353 | [safi], | |
11354 | PEER_CAP_RESTART_AF_RCV)) { | |
11355 | json_object * | |
11356 | json_sub = | |
11357 | NULL; | |
11358 | json_sub = | |
11359 | json_object_new_object(); | |
11360 | ||
d62a17ae | 11361 | if (CHECK_FLAG( |
11362 | p->af_cap | |
11363 | [afi] | |
11364 | [safi], | |
05c7a1cc QY |
11365 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11366 | json_object_boolean_true_add( | |
11367 | json_sub, | |
11368 | "preserved"); | |
11369 | restart_af_count++; | |
11370 | json_object_object_add( | |
11371 | json_restart, | |
5cb5f4d0 | 11372 | get_afi_safi_str( |
05c7a1cc | 11373 | afi, |
5cb5f4d0 DD |
11374 | safi, |
11375 | true), | |
05c7a1cc | 11376 | json_sub); |
d62a17ae | 11377 | } |
11378 | } | |
11379 | if (!restart_af_count) { | |
11380 | json_object_string_add( | |
11381 | json_cap, | |
11382 | "addressFamiliesByPeer", | |
11383 | "none"); | |
11384 | json_object_free( | |
11385 | json_restart); | |
11386 | } else | |
11387 | json_object_object_add( | |
11388 | json_cap, | |
11389 | "addressFamiliesByPeer", | |
11390 | json_restart); | |
11391 | } | |
11392 | } | |
11393 | json_object_object_add(json_neigh, | |
11394 | "neighborCapabilities", | |
11395 | json_cap); | |
11396 | } else { | |
11397 | vty_out(vty, " Neighbor capabilities:\n"); | |
11398 | ||
11399 | /* AS4 */ | |
11400 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11401 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11402 | vty_out(vty, " 4 Byte AS:"); | |
11403 | if (CHECK_FLAG(p->cap, | |
11404 | PEER_CAP_AS4_ADV)) | |
11405 | vty_out(vty, " advertised"); | |
11406 | if (CHECK_FLAG(p->cap, | |
11407 | PEER_CAP_AS4_RCV)) | |
11408 | vty_out(vty, " %sreceived", | |
11409 | CHECK_FLAG( | |
11410 | p->cap, | |
11411 | PEER_CAP_AS4_ADV) | |
11412 | ? "and " | |
11413 | : ""); | |
11414 | vty_out(vty, "\n"); | |
11415 | } | |
11416 | ||
11417 | /* AddPath */ | |
11418 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11419 | || CHECK_FLAG(p->cap, | |
11420 | PEER_CAP_ADDPATH_ADV)) { | |
11421 | vty_out(vty, " AddPath:\n"); | |
11422 | ||
05c7a1cc QY |
11423 | FOREACH_AFI_SAFI (afi, safi) { |
11424 | if (CHECK_FLAG( | |
11425 | p->af_cap[afi] | |
11426 | [safi], | |
11427 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11428 | || CHECK_FLAG( | |
11429 | p->af_cap[afi] | |
11430 | [safi], | |
11431 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11432 | vty_out(vty, | |
11433 | " %s: TX ", | |
5cb5f4d0 | 11434 | get_afi_safi_str( |
05c7a1cc | 11435 | afi, |
5cb5f4d0 DD |
11436 | safi, |
11437 | false)); | |
05c7a1cc | 11438 | |
d62a17ae | 11439 | if (CHECK_FLAG( |
11440 | p->af_cap | |
11441 | [afi] | |
11442 | [safi], | |
05c7a1cc | 11443 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11444 | vty_out(vty, |
05c7a1cc | 11445 | "advertised %s", |
5cb5f4d0 | 11446 | get_afi_safi_str( |
d62a17ae | 11447 | afi, |
5cb5f4d0 DD |
11448 | safi, |
11449 | false)); | |
d62a17ae | 11450 | |
05c7a1cc QY |
11451 | if (CHECK_FLAG( |
11452 | p->af_cap | |
11453 | [afi] | |
11454 | [safi], | |
11455 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11456 | vty_out(vty, | |
11457 | "%sreceived", | |
11458 | CHECK_FLAG( | |
11459 | p->af_cap | |
11460 | [afi] | |
11461 | [safi], | |
11462 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11463 | ? " and " | |
11464 | : ""); | |
d62a17ae | 11465 | |
05c7a1cc QY |
11466 | vty_out(vty, "\n"); |
11467 | } | |
d62a17ae | 11468 | |
05c7a1cc QY |
11469 | if (CHECK_FLAG( |
11470 | p->af_cap[afi] | |
11471 | [safi], | |
11472 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11473 | || CHECK_FLAG( | |
11474 | p->af_cap[afi] | |
11475 | [safi], | |
11476 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11477 | vty_out(vty, | |
11478 | " %s: RX ", | |
5cb5f4d0 | 11479 | get_afi_safi_str( |
05c7a1cc | 11480 | afi, |
5cb5f4d0 DD |
11481 | safi, |
11482 | false)); | |
d62a17ae | 11483 | |
11484 | if (CHECK_FLAG( | |
11485 | p->af_cap | |
11486 | [afi] | |
11487 | [safi], | |
05c7a1cc | 11488 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11489 | vty_out(vty, |
05c7a1cc | 11490 | "advertised %s", |
5cb5f4d0 | 11491 | get_afi_safi_str( |
d62a17ae | 11492 | afi, |
5cb5f4d0 DD |
11493 | safi, |
11494 | false)); | |
d62a17ae | 11495 | |
05c7a1cc QY |
11496 | if (CHECK_FLAG( |
11497 | p->af_cap | |
11498 | [afi] | |
11499 | [safi], | |
11500 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11501 | vty_out(vty, |
05c7a1cc QY |
11502 | "%sreceived", |
11503 | CHECK_FLAG( | |
11504 | p->af_cap | |
11505 | [afi] | |
11506 | [safi], | |
11507 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11508 | ? " and " | |
11509 | : ""); | |
11510 | ||
11511 | vty_out(vty, "\n"); | |
d62a17ae | 11512 | } |
05c7a1cc | 11513 | } |
d62a17ae | 11514 | } |
11515 | ||
11516 | /* Dynamic */ | |
11517 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11518 | || CHECK_FLAG(p->cap, | |
11519 | PEER_CAP_DYNAMIC_ADV)) { | |
11520 | vty_out(vty, " Dynamic:"); | |
11521 | if (CHECK_FLAG(p->cap, | |
11522 | PEER_CAP_DYNAMIC_ADV)) | |
11523 | vty_out(vty, " advertised"); | |
11524 | if (CHECK_FLAG(p->cap, | |
11525 | PEER_CAP_DYNAMIC_RCV)) | |
11526 | vty_out(vty, " %sreceived", | |
11527 | CHECK_FLAG( | |
11528 | p->cap, | |
11529 | PEER_CAP_DYNAMIC_ADV) | |
11530 | ? "and " | |
11531 | : ""); | |
11532 | vty_out(vty, "\n"); | |
11533 | } | |
11534 | ||
11535 | /* Extended nexthop */ | |
11536 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11537 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11538 | vty_out(vty, " Extended nexthop:"); | |
11539 | if (CHECK_FLAG(p->cap, | |
11540 | PEER_CAP_ENHE_ADV)) | |
11541 | vty_out(vty, " advertised"); | |
11542 | if (CHECK_FLAG(p->cap, | |
11543 | PEER_CAP_ENHE_RCV)) | |
11544 | vty_out(vty, " %sreceived", | |
11545 | CHECK_FLAG( | |
11546 | p->cap, | |
11547 | PEER_CAP_ENHE_ADV) | |
11548 | ? "and " | |
11549 | : ""); | |
11550 | vty_out(vty, "\n"); | |
11551 | ||
11552 | if (CHECK_FLAG(p->cap, | |
11553 | PEER_CAP_ENHE_RCV)) { | |
11554 | vty_out(vty, | |
11555 | " Address families by peer:\n "); | |
11556 | for (safi = SAFI_UNICAST; | |
11557 | safi < SAFI_MAX; safi++) | |
11558 | if (CHECK_FLAG( | |
11559 | p->af_cap | |
11560 | [AFI_IP] | |
11561 | [safi], | |
11562 | PEER_CAP_ENHE_AF_RCV)) | |
11563 | vty_out(vty, | |
11564 | " %s\n", | |
5cb5f4d0 | 11565 | get_afi_safi_str( |
d62a17ae | 11566 | AFI_IP, |
5cb5f4d0 DD |
11567 | safi, |
11568 | false)); | |
d62a17ae | 11569 | } |
11570 | } | |
11571 | ||
11572 | /* Route Refresh */ | |
11573 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11574 | || CHECK_FLAG(p->cap, | |
11575 | PEER_CAP_REFRESH_NEW_RCV) | |
11576 | || CHECK_FLAG(p->cap, | |
11577 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11578 | vty_out(vty, " Route refresh:"); | |
11579 | if (CHECK_FLAG(p->cap, | |
11580 | PEER_CAP_REFRESH_ADV)) | |
11581 | vty_out(vty, " advertised"); | |
11582 | if (CHECK_FLAG(p->cap, | |
11583 | PEER_CAP_REFRESH_NEW_RCV) | |
11584 | || CHECK_FLAG( | |
11585 | p->cap, | |
11586 | PEER_CAP_REFRESH_OLD_RCV)) | |
11587 | vty_out(vty, " %sreceived(%s)", | |
11588 | CHECK_FLAG( | |
11589 | p->cap, | |
11590 | PEER_CAP_REFRESH_ADV) | |
11591 | ? "and " | |
11592 | : "", | |
11593 | (CHECK_FLAG( | |
11594 | p->cap, | |
11595 | PEER_CAP_REFRESH_OLD_RCV) | |
11596 | && CHECK_FLAG( | |
11597 | p->cap, | |
11598 | PEER_CAP_REFRESH_NEW_RCV)) | |
11599 | ? "old & new" | |
11600 | : CHECK_FLAG( | |
11601 | p->cap, | |
11602 | PEER_CAP_REFRESH_OLD_RCV) | |
11603 | ? "old" | |
11604 | : "new"); | |
11605 | ||
11606 | vty_out(vty, "\n"); | |
11607 | } | |
11608 | ||
11609 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11610 | FOREACH_AFI_SAFI (afi, safi) |
11611 | if (p->afc_adv[afi][safi] | |
11612 | || p->afc_recv[afi][safi]) { | |
11613 | vty_out(vty, | |
11614 | " Address Family %s:", | |
5cb5f4d0 DD |
11615 | get_afi_safi_str( |
11616 | afi, | |
11617 | safi, | |
11618 | false)); | |
05c7a1cc | 11619 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11620 | vty_out(vty, |
05c7a1cc QY |
11621 | " advertised"); |
11622 | if (p->afc_recv[afi][safi]) | |
11623 | vty_out(vty, | |
11624 | " %sreceived", | |
11625 | p->afc_adv[afi] | |
11626 | [safi] | |
11627 | ? "and " | |
11628 | : ""); | |
11629 | vty_out(vty, "\n"); | |
11630 | } | |
d62a17ae | 11631 | |
11632 | /* Hostname capability */ | |
60466a63 | 11633 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11634 | |
11635 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11636 | vty_out(vty, |
11637 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11638 | bgp->peer_self->hostname |
11639 | ? bgp->peer_self | |
11640 | ->hostname | |
d77114b7 | 11641 | : "n/a", |
60466a63 QY |
11642 | bgp->peer_self->domainname |
11643 | ? bgp->peer_self | |
11644 | ->domainname | |
d77114b7 MK |
11645 | : "n/a"); |
11646 | } else { | |
11647 | vty_out(vty, " not advertised"); | |
d62a17ae | 11648 | } |
11649 | ||
d77114b7 | 11650 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11651 | vty_out(vty, |
11652 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11653 | p->hostname ? p->hostname |
11654 | : "n/a", | |
11655 | p->domainname ? p->domainname | |
11656 | : "n/a"); | |
d77114b7 MK |
11657 | } else { |
11658 | vty_out(vty, " not received"); | |
11659 | } | |
11660 | ||
11661 | vty_out(vty, "\n"); | |
11662 | ||
61bfbd51 | 11663 | /* Graceful Restart */ |
d62a17ae | 11664 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
11665 | || CHECK_FLAG(p->cap, | |
11666 | PEER_CAP_RESTART_ADV)) { | |
11667 | vty_out(vty, | |
61bfbd51 | 11668 | " Graceful Restart Capability:"); |
d62a17ae | 11669 | if (CHECK_FLAG(p->cap, |
11670 | PEER_CAP_RESTART_ADV)) | |
11671 | vty_out(vty, " advertised"); | |
11672 | if (CHECK_FLAG(p->cap, | |
11673 | PEER_CAP_RESTART_RCV)) | |
11674 | vty_out(vty, " %sreceived", | |
11675 | CHECK_FLAG( | |
11676 | p->cap, | |
11677 | PEER_CAP_RESTART_ADV) | |
11678 | ? "and " | |
11679 | : ""); | |
11680 | vty_out(vty, "\n"); | |
11681 | ||
11682 | if (CHECK_FLAG(p->cap, | |
11683 | PEER_CAP_RESTART_RCV)) { | |
11684 | int restart_af_count = 0; | |
11685 | ||
11686 | vty_out(vty, | |
11687 | " Remote Restart timer is %d seconds\n", | |
11688 | p->v_gr_restart); | |
11689 | vty_out(vty, | |
11690 | " Address families by peer:\n "); | |
11691 | ||
05c7a1cc QY |
11692 | FOREACH_AFI_SAFI (afi, safi) |
11693 | if (CHECK_FLAG( | |
11694 | p->af_cap | |
11695 | [afi] | |
11696 | [safi], | |
11697 | PEER_CAP_RESTART_AF_RCV)) { | |
11698 | vty_out(vty, | |
11699 | "%s%s(%s)", | |
11700 | restart_af_count | |
11701 | ? ", " | |
11702 | : "", | |
5cb5f4d0 | 11703 | get_afi_safi_str( |
05c7a1cc | 11704 | afi, |
5cb5f4d0 DD |
11705 | safi, |
11706 | false), | |
05c7a1cc QY |
11707 | CHECK_FLAG( |
11708 | p->af_cap | |
11709 | [afi] | |
11710 | [safi], | |
11711 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11712 | ? "preserved" | |
11713 | : "not preserved"); | |
11714 | restart_af_count++; | |
11715 | } | |
d62a17ae | 11716 | if (!restart_af_count) |
11717 | vty_out(vty, "none"); | |
11718 | vty_out(vty, "\n"); | |
11719 | } | |
2986cac2 | 11720 | } /* Gracefull Restart */ |
d62a17ae | 11721 | } |
11722 | } | |
11723 | } | |
11724 | ||
11725 | /* graceful restart information */ | |
d62a17ae | 11726 | json_object *json_grace = NULL; |
11727 | json_object *json_grace_send = NULL; | |
11728 | json_object *json_grace_recv = NULL; | |
11729 | int eor_send_af_count = 0; | |
11730 | int eor_receive_af_count = 0; | |
11731 | ||
11732 | if (use_json) { | |
11733 | json_grace = json_object_new_object(); | |
11734 | json_grace_send = json_object_new_object(); | |
11735 | json_grace_recv = json_object_new_object(); | |
11736 | ||
36235319 QY |
11737 | if ((p->status == Established) |
11738 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11739 | FOREACH_AFI_SAFI (afi, safi) { |
11740 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11741 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11742 | json_object_boolean_true_add( |
11743 | json_grace_send, | |
5cb5f4d0 DD |
11744 | get_afi_safi_str(afi, |
11745 | safi, | |
11746 | true)); | |
05c7a1cc | 11747 | eor_send_af_count++; |
d62a17ae | 11748 | } |
11749 | } | |
05c7a1cc QY |
11750 | FOREACH_AFI_SAFI (afi, safi) { |
11751 | if (CHECK_FLAG( | |
36235319 QY |
11752 | p->af_sflags[afi][safi], |
11753 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11754 | json_object_boolean_true_add( |
11755 | json_grace_recv, | |
5cb5f4d0 DD |
11756 | get_afi_safi_str(afi, |
11757 | safi, | |
11758 | true)); | |
05c7a1cc | 11759 | eor_receive_af_count++; |
d62a17ae | 11760 | } |
11761 | } | |
11762 | } | |
36235319 QY |
11763 | json_object_object_add(json_grace, "endOfRibSend", |
11764 | json_grace_send); | |
11765 | json_object_object_add(json_grace, "endOfRibRecv", | |
11766 | json_grace_recv); | |
d62a17ae | 11767 | |
d62a17ae | 11768 | |
11769 | if (p->t_gr_restart) | |
11770 | json_object_int_add(json_grace, | |
11771 | "gracefulRestartTimerMsecs", | |
11772 | thread_timer_remain_second( | |
11773 | p->t_gr_restart) | |
11774 | * 1000); | |
11775 | ||
11776 | if (p->t_gr_stale) | |
11777 | json_object_int_add( | |
11778 | json_grace, | |
11779 | "gracefulStalepathTimerMsecs", | |
11780 | thread_timer_remain_second( | |
11781 | p->t_gr_stale) | |
11782 | * 1000); | |
2986cac2 | 11783 | /* more gr info in new format */ |
11784 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 11785 | json_grace); |
d62a17ae | 11786 | json_object_object_add( |
11787 | json_neigh, "gracefulRestartInfo", json_grace); | |
11788 | } else { | |
2089dd80 | 11789 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
11790 | if ((p->status == Established) |
11791 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11792 | |
d62a17ae | 11793 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11794 | FOREACH_AFI_SAFI (afi, safi) { |
11795 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11796 | PEER_STATUS_EOR_SEND)) { | |
11797 | vty_out(vty, "%s%s", | |
11798 | eor_send_af_count ? ", " | |
11799 | : "", | |
36235319 QY |
11800 | get_afi_safi_str( |
11801 | afi, safi, | |
11802 | false)); | |
05c7a1cc | 11803 | eor_send_af_count++; |
d62a17ae | 11804 | } |
11805 | } | |
11806 | vty_out(vty, "\n"); | |
11807 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11808 | FOREACH_AFI_SAFI (afi, safi) { |
11809 | if (CHECK_FLAG( | |
11810 | p->af_sflags[afi][safi], | |
11811 | PEER_STATUS_EOR_RECEIVED)) { | |
11812 | vty_out(vty, "%s%s", | |
11813 | eor_receive_af_count | |
11814 | ? ", " | |
11815 | : "", | |
5cb5f4d0 DD |
11816 | get_afi_safi_str(afi, |
11817 | safi, | |
11818 | false)); | |
05c7a1cc | 11819 | eor_receive_af_count++; |
d62a17ae | 11820 | } |
11821 | } | |
11822 | vty_out(vty, "\n"); | |
11823 | } | |
11824 | ||
11825 | if (p->t_gr_restart) | |
11826 | vty_out(vty, | |
11827 | " The remaining time of restart timer is %ld\n", | |
11828 | thread_timer_remain_second( | |
11829 | p->t_gr_restart)); | |
11830 | ||
11831 | if (p->t_gr_stale) | |
11832 | vty_out(vty, | |
11833 | " The remaining time of stalepath timer is %ld\n", | |
11834 | thread_timer_remain_second( | |
11835 | p->t_gr_stale)); | |
2986cac2 | 11836 | |
11837 | /* more gr info in new format */ | |
11838 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11839 | } |
2986cac2 | 11840 | |
d62a17ae | 11841 | if (use_json) { |
11842 | json_object *json_stat = NULL; | |
11843 | json_stat = json_object_new_object(); | |
11844 | /* Packet counts. */ | |
43aa5965 QY |
11845 | |
11846 | atomic_size_t outq_count, inq_count; | |
11847 | outq_count = atomic_load_explicit(&p->obuf->count, | |
11848 | memory_order_relaxed); | |
11849 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
11850 | memory_order_relaxed); | |
11851 | ||
11852 | json_object_int_add(json_stat, "depthInq", | |
11853 | (unsigned long)inq_count); | |
d62a17ae | 11854 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 11855 | (unsigned long)outq_count); |
0112e9e0 QY |
11856 | json_object_int_add(json_stat, "opensSent", |
11857 | atomic_load_explicit(&p->open_out, | |
11858 | memory_order_relaxed)); | |
11859 | json_object_int_add(json_stat, "opensRecv", | |
11860 | atomic_load_explicit(&p->open_in, | |
11861 | memory_order_relaxed)); | |
d62a17ae | 11862 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11863 | atomic_load_explicit(&p->notify_out, |
11864 | memory_order_relaxed)); | |
d62a17ae | 11865 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11866 | atomic_load_explicit(&p->notify_in, |
11867 | memory_order_relaxed)); | |
11868 | json_object_int_add(json_stat, "updatesSent", | |
11869 | atomic_load_explicit(&p->update_out, | |
11870 | memory_order_relaxed)); | |
11871 | json_object_int_add(json_stat, "updatesRecv", | |
11872 | atomic_load_explicit(&p->update_in, | |
11873 | memory_order_relaxed)); | |
d62a17ae | 11874 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11875 | atomic_load_explicit(&p->keepalive_out, |
11876 | memory_order_relaxed)); | |
d62a17ae | 11877 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11878 | atomic_load_explicit(&p->keepalive_in, |
11879 | memory_order_relaxed)); | |
d62a17ae | 11880 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11881 | atomic_load_explicit(&p->refresh_out, |
11882 | memory_order_relaxed)); | |
d62a17ae | 11883 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11884 | atomic_load_explicit(&p->refresh_in, |
11885 | memory_order_relaxed)); | |
d62a17ae | 11886 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11887 | atomic_load_explicit(&p->dynamic_cap_out, |
11888 | memory_order_relaxed)); | |
d62a17ae | 11889 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11890 | atomic_load_explicit(&p->dynamic_cap_in, |
11891 | memory_order_relaxed)); | |
11892 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
11893 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 11894 | json_object_object_add(json_neigh, "messageStats", json_stat); |
11895 | } else { | |
43aa5965 QY |
11896 | atomic_size_t outq_count, inq_count; |
11897 | outq_count = atomic_load_explicit(&p->obuf->count, | |
11898 | memory_order_relaxed); | |
11899 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
11900 | memory_order_relaxed); | |
11901 | ||
d62a17ae | 11902 | /* Packet counts. */ |
11903 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
11904 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
11905 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 11906 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
11907 | vty_out(vty, " Opens: %10d %10d\n", |
11908 | atomic_load_explicit(&p->open_out, | |
11909 | memory_order_relaxed), | |
11910 | atomic_load_explicit(&p->open_in, | |
11911 | memory_order_relaxed)); | |
11912 | vty_out(vty, " Notifications: %10d %10d\n", | |
11913 | atomic_load_explicit(&p->notify_out, | |
11914 | memory_order_relaxed), | |
11915 | atomic_load_explicit(&p->notify_in, | |
11916 | memory_order_relaxed)); | |
11917 | vty_out(vty, " Updates: %10d %10d\n", | |
11918 | atomic_load_explicit(&p->update_out, | |
11919 | memory_order_relaxed), | |
11920 | atomic_load_explicit(&p->update_in, | |
11921 | memory_order_relaxed)); | |
11922 | vty_out(vty, " Keepalives: %10d %10d\n", | |
11923 | atomic_load_explicit(&p->keepalive_out, | |
11924 | memory_order_relaxed), | |
11925 | atomic_load_explicit(&p->keepalive_in, | |
11926 | memory_order_relaxed)); | |
11927 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
11928 | atomic_load_explicit(&p->refresh_out, | |
11929 | memory_order_relaxed), | |
11930 | atomic_load_explicit(&p->refresh_in, | |
11931 | memory_order_relaxed)); | |
d62a17ae | 11932 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
11933 | atomic_load_explicit(&p->dynamic_cap_out, |
11934 | memory_order_relaxed), | |
11935 | atomic_load_explicit(&p->dynamic_cap_in, | |
11936 | memory_order_relaxed)); | |
11937 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
11938 | PEER_TOTAL_RX(p)); | |
d62a17ae | 11939 | } |
11940 | ||
11941 | if (use_json) { | |
11942 | /* advertisement-interval */ | |
11943 | json_object_int_add(json_neigh, | |
11944 | "minBtwnAdvertisementRunsTimerMsecs", | |
11945 | p->v_routeadv * 1000); | |
11946 | ||
11947 | /* Update-source. */ | |
11948 | if (p->update_if || p->update_source) { | |
11949 | if (p->update_if) | |
11950 | json_object_string_add(json_neigh, | |
11951 | "updateSource", | |
11952 | p->update_if); | |
11953 | else if (p->update_source) | |
11954 | json_object_string_add( | |
11955 | json_neigh, "updateSource", | |
11956 | sockunion2str(p->update_source, buf1, | |
11957 | SU_ADDRSTRLEN)); | |
11958 | } | |
11959 | } else { | |
11960 | /* advertisement-interval */ | |
11961 | vty_out(vty, | |
11962 | " Minimum time between advertisement runs is %d seconds\n", | |
11963 | p->v_routeadv); | |
11964 | ||
11965 | /* Update-source. */ | |
11966 | if (p->update_if || p->update_source) { | |
11967 | vty_out(vty, " Update source is "); | |
11968 | if (p->update_if) | |
11969 | vty_out(vty, "%s", p->update_if); | |
11970 | else if (p->update_source) | |
11971 | vty_out(vty, "%s", | |
11972 | sockunion2str(p->update_source, buf1, | |
11973 | SU_ADDRSTRLEN)); | |
11974 | vty_out(vty, "\n"); | |
11975 | } | |
11976 | ||
11977 | vty_out(vty, "\n"); | |
11978 | } | |
11979 | ||
11980 | /* Address Family Information */ | |
11981 | json_object *json_hold = NULL; | |
11982 | ||
11983 | if (use_json) | |
11984 | json_hold = json_object_new_object(); | |
11985 | ||
05c7a1cc QY |
11986 | FOREACH_AFI_SAFI (afi, safi) |
11987 | if (p->afc[afi][safi]) | |
11988 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
11989 | json_hold); | |
d62a17ae | 11990 | |
11991 | if (use_json) { | |
11992 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
11993 | json_hold); | |
11994 | json_object_int_add(json_neigh, "connectionsEstablished", | |
11995 | p->established); | |
11996 | json_object_int_add(json_neigh, "connectionsDropped", | |
11997 | p->dropped); | |
11998 | } else | |
11999 | vty_out(vty, " Connections established %d; dropped %d\n", | |
12000 | p->established, p->dropped); | |
12001 | ||
12002 | if (!p->last_reset) { | |
12003 | if (use_json) | |
12004 | json_object_string_add(json_neigh, "lastReset", | |
12005 | "never"); | |
12006 | else | |
12007 | vty_out(vty, " Last reset never\n"); | |
12008 | } else { | |
12009 | if (use_json) { | |
12010 | time_t uptime; | |
a2700b50 | 12011 | struct tm tm; |
d62a17ae | 12012 | |
12013 | uptime = bgp_clock(); | |
12014 | uptime -= p->resettime; | |
a2700b50 MS |
12015 | gmtime_r(&uptime, &tm); |
12016 | ||
d62a17ae | 12017 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
12018 | (tm.tm_sec * 1000) |
12019 | + (tm.tm_min * 60000) | |
12020 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 12021 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 12022 | } else { |
12023 | vty_out(vty, " Last reset %s, ", | |
12024 | peer_uptime(p->resettime, timebuf, | |
12025 | BGP_UPTIME_LEN, 0, NULL)); | |
12026 | ||
3577f1c5 | 12027 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 12028 | if (p->last_reset_cause_size) { |
12029 | msg = p->last_reset_cause; | |
12030 | vty_out(vty, | |
12031 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
12032 | for (i = 1; i <= p->last_reset_cause_size; | |
12033 | i++) { | |
12034 | vty_out(vty, "%02X", *msg++); | |
12035 | ||
12036 | if (i != p->last_reset_cause_size) { | |
12037 | if (i % 16 == 0) { | |
12038 | vty_out(vty, "\n "); | |
12039 | } else if (i % 4 == 0) { | |
12040 | vty_out(vty, " "); | |
12041 | } | |
12042 | } | |
12043 | } | |
12044 | vty_out(vty, "\n"); | |
12045 | } | |
12046 | } | |
12047 | } | |
12048 | ||
12049 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
12050 | if (use_json) | |
12051 | json_object_boolean_true_add(json_neigh, | |
12052 | "prefixesConfigExceedMax"); | |
12053 | else | |
12054 | vty_out(vty, | |
12055 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
12056 | ||
12057 | if (p->t_pmax_restart) { | |
12058 | if (use_json) { | |
12059 | json_object_boolean_true_add( | |
12060 | json_neigh, "reducePrefixNumFrom"); | |
12061 | json_object_int_add(json_neigh, | |
12062 | "restartInTimerMsec", | |
12063 | thread_timer_remain_second( | |
12064 | p->t_pmax_restart) | |
12065 | * 1000); | |
12066 | } else | |
12067 | vty_out(vty, | |
12068 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
12069 | p->host, thread_timer_remain_second( |
12070 | p->t_pmax_restart)); | |
d62a17ae | 12071 | } else { |
12072 | if (use_json) | |
12073 | json_object_boolean_true_add( | |
12074 | json_neigh, | |
12075 | "reducePrefixNumAndClearIpBgp"); | |
12076 | else | |
12077 | vty_out(vty, | |
12078 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
12079 | p->host); | |
12080 | } | |
12081 | } | |
12082 | ||
12083 | /* EBGP Multihop and GTSM */ | |
12084 | if (p->sort != BGP_PEER_IBGP) { | |
12085 | if (use_json) { | |
e2521429 | 12086 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12087 | json_object_int_add(json_neigh, |
12088 | "externalBgpNbrMaxHopsAway", | |
12089 | p->gtsm_hops); | |
c8d6f0d6 | 12090 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12091 | json_object_int_add(json_neigh, |
12092 | "externalBgpNbrMaxHopsAway", | |
12093 | p->ttl); | |
12094 | } else { | |
e2521429 | 12095 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12096 | vty_out(vty, |
12097 | " External BGP neighbor may be up to %d hops away.\n", | |
12098 | p->gtsm_hops); | |
c8d6f0d6 | 12099 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12100 | vty_out(vty, |
12101 | " External BGP neighbor may be up to %d hops away.\n", | |
12102 | p->ttl); | |
12103 | } | |
12104 | } else { | |
e2521429 | 12105 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 12106 | if (use_json) |
12107 | json_object_int_add(json_neigh, | |
12108 | "internalBgpNbrMaxHopsAway", | |
12109 | p->gtsm_hops); | |
12110 | else | |
12111 | vty_out(vty, | |
12112 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12113 | p->gtsm_hops); | |
12114 | } | |
12115 | } | |
12116 | ||
12117 | /* Local address. */ | |
12118 | if (p->su_local) { | |
12119 | if (use_json) { | |
12120 | json_object_string_add(json_neigh, "hostLocal", | |
12121 | sockunion2str(p->su_local, buf1, | |
12122 | SU_ADDRSTRLEN)); | |
12123 | json_object_int_add(json_neigh, "portLocal", | |
12124 | ntohs(p->su_local->sin.sin_port)); | |
12125 | } else | |
12126 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
12127 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
12128 | ntohs(p->su_local->sin.sin_port)); | |
12129 | } | |
12130 | ||
12131 | /* Remote address. */ | |
12132 | if (p->su_remote) { | |
12133 | if (use_json) { | |
12134 | json_object_string_add(json_neigh, "hostForeign", | |
12135 | sockunion2str(p->su_remote, buf1, | |
12136 | SU_ADDRSTRLEN)); | |
12137 | json_object_int_add(json_neigh, "portForeign", | |
12138 | ntohs(p->su_remote->sin.sin_port)); | |
12139 | } else | |
12140 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
12141 | sockunion2str(p->su_remote, buf1, | |
12142 | SU_ADDRSTRLEN), | |
12143 | ntohs(p->su_remote->sin.sin_port)); | |
12144 | } | |
12145 | ||
12146 | /* Nexthop display. */ | |
12147 | if (p->su_local) { | |
12148 | if (use_json) { | |
12149 | json_object_string_add(json_neigh, "nexthop", | |
12150 | inet_ntop(AF_INET, | |
12151 | &p->nexthop.v4, buf1, | |
12152 | sizeof(buf1))); | |
12153 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12154 | inet_ntop(AF_INET6, | |
12155 | &p->nexthop.v6_global, | |
12156 | buf1, sizeof(buf1))); | |
12157 | json_object_string_add(json_neigh, "nexthopLocal", | |
12158 | inet_ntop(AF_INET6, | |
12159 | &p->nexthop.v6_local, | |
12160 | buf1, sizeof(buf1))); | |
12161 | if (p->shared_network) | |
12162 | json_object_string_add(json_neigh, | |
12163 | "bgpConnection", | |
12164 | "sharedNetwork"); | |
12165 | else | |
12166 | json_object_string_add(json_neigh, | |
12167 | "bgpConnection", | |
12168 | "nonSharedNetwork"); | |
12169 | } else { | |
12170 | vty_out(vty, "Nexthop: %s\n", | |
12171 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12172 | sizeof(buf1))); | |
12173 | vty_out(vty, "Nexthop global: %s\n", | |
12174 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12175 | sizeof(buf1))); | |
12176 | vty_out(vty, "Nexthop local: %s\n", | |
12177 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12178 | sizeof(buf1))); | |
12179 | vty_out(vty, "BGP connection: %s\n", | |
12180 | p->shared_network ? "shared network" | |
12181 | : "non shared network"); | |
12182 | } | |
12183 | } | |
12184 | ||
12185 | /* Timer information. */ | |
12186 | if (use_json) { | |
12187 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12188 | p->v_connect); | |
12189 | if (p->status == Established && p->rtt) | |
12190 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12191 | p->rtt); | |
12192 | if (p->t_start) | |
12193 | json_object_int_add( | |
12194 | json_neigh, "nextStartTimerDueInMsecs", | |
12195 | thread_timer_remain_second(p->t_start) * 1000); | |
12196 | if (p->t_connect) | |
12197 | json_object_int_add( | |
12198 | json_neigh, "nextConnectTimerDueInMsecs", | |
12199 | thread_timer_remain_second(p->t_connect) | |
12200 | * 1000); | |
12201 | if (p->t_routeadv) { | |
12202 | json_object_int_add(json_neigh, "mraiInterval", | |
12203 | p->v_routeadv); | |
12204 | json_object_int_add( | |
12205 | json_neigh, "mraiTimerExpireInMsecs", | |
12206 | thread_timer_remain_second(p->t_routeadv) | |
12207 | * 1000); | |
12208 | } | |
12209 | if (p->password) | |
12210 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12211 | 1); | |
12212 | ||
12213 | if (p->t_read) | |
12214 | json_object_string_add(json_neigh, "readThread", "on"); | |
12215 | else | |
12216 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12217 | |
12218 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12219 | json_object_string_add(json_neigh, "writeThread", "on"); |
12220 | else | |
12221 | json_object_string_add(json_neigh, "writeThread", | |
12222 | "off"); | |
12223 | } else { | |
12224 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12225 | p->v_connect); | |
12226 | if (p->status == Established && p->rtt) | |
12227 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12228 | p->rtt); | |
12229 | if (p->t_start) | |
12230 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12231 | thread_timer_remain_second(p->t_start)); | |
12232 | if (p->t_connect) | |
12233 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12234 | thread_timer_remain_second(p->t_connect)); | |
12235 | if (p->t_routeadv) | |
12236 | vty_out(vty, | |
12237 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12238 | p->v_routeadv, | |
12239 | thread_timer_remain_second(p->t_routeadv)); | |
12240 | if (p->password) | |
12241 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12242 | ||
cac9e917 | 12243 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12244 | p->t_read ? "on" : "off", |
12245 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12246 | ? "on" | |
cac9e917 | 12247 | : "off", p->fd); |
d62a17ae | 12248 | } |
12249 | ||
12250 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12251 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12252 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12253 | ||
12254 | if (!use_json) | |
12255 | vty_out(vty, "\n"); | |
12256 | ||
12257 | /* BFD information. */ | |
12258 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12259 | ||
12260 | if (use_json) { | |
12261 | if (p->conf_if) /* Configured interface name. */ | |
12262 | json_object_object_add(json, p->conf_if, json_neigh); | |
12263 | else /* Configured IP address. */ | |
12264 | json_object_object_add(json, p->host, json_neigh); | |
12265 | } | |
12266 | } | |
12267 | ||
36235319 QY |
12268 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12269 | enum show_type type, | |
12270 | union sockunion *su, | |
12271 | const char *conf_if, afi_t afi, | |
74a630b6 | 12272 | bool use_json) |
2986cac2 | 12273 | { |
12274 | struct listnode *node, *nnode; | |
12275 | struct peer *peer; | |
12276 | int find = 0; | |
12277 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 12278 | json_object *json = NULL; |
2986cac2 | 12279 | json_object *json_neighbor = NULL; |
12280 | ||
74a630b6 NT |
12281 | if (use_json) { |
12282 | json = json_object_new_object(); | |
12283 | json_neighbor = json_object_new_object(); | |
12284 | } | |
12285 | ||
2986cac2 | 12286 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
12287 | ||
12288 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12289 | continue; | |
12290 | ||
12291 | if ((peer->afc[afi][safi]) == 0) | |
12292 | continue; | |
12293 | ||
2ba1fe69 | 12294 | if (type == show_all) { |
2986cac2 | 12295 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12296 | json_neighbor); |
2986cac2 | 12297 | |
74a630b6 | 12298 | if (use_json) { |
13909c4f DS |
12299 | json_object_object_add(json, peer->host, |
12300 | json_neighbor); | |
74a630b6 NT |
12301 | json_neighbor = NULL; |
12302 | } | |
2986cac2 | 12303 | |
2ba1fe69 | 12304 | } else if (type == show_peer) { |
2986cac2 | 12305 | if (conf_if) { |
12306 | if ((peer->conf_if | |
13909c4f DS |
12307 | && !strcmp(peer->conf_if, conf_if)) |
12308 | || (peer->hostname | |
2986cac2 | 12309 | && !strcmp(peer->hostname, conf_if))) { |
12310 | find = 1; | |
13909c4f DS |
12311 | bgp_show_peer_gr_status(vty, peer, |
12312 | use_json, | |
12313 | json_neighbor); | |
2986cac2 | 12314 | } |
12315 | } else { | |
12316 | if (sockunion_same(&peer->su, su)) { | |
12317 | find = 1; | |
13909c4f DS |
12318 | bgp_show_peer_gr_status(vty, peer, |
12319 | use_json, | |
12320 | json_neighbor); | |
2986cac2 | 12321 | } |
12322 | } | |
13909c4f DS |
12323 | if (use_json && find) |
12324 | json_object_object_add(json, peer->host, | |
12325 | json_neighbor); | |
2986cac2 | 12326 | } |
12327 | ||
74a630b6 NT |
12328 | if (find) { |
12329 | json_neighbor = NULL; | |
2986cac2 | 12330 | break; |
74a630b6 | 12331 | } |
2986cac2 | 12332 | } |
12333 | ||
12334 | if (type == show_peer && !find) { | |
12335 | if (use_json) | |
13909c4f | 12336 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12337 | else |
12338 | vty_out(vty, "%% No such neighbor\n"); | |
12339 | } | |
12340 | if (use_json) { | |
13909c4f DS |
12341 | vty_out(vty, "%s\n", |
12342 | json_object_to_json_string_ext( | |
12343 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
12344 | |
12345 | if (json_neighbor) | |
12346 | json_object_free(json_neighbor); | |
12347 | json_object_free(json); | |
2986cac2 | 12348 | } else { |
12349 | vty_out(vty, "\n"); | |
12350 | } | |
12351 | ||
12352 | return CMD_SUCCESS; | |
12353 | } | |
12354 | ||
d62a17ae | 12355 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12356 | enum show_type type, union sockunion *su, | |
9f049418 | 12357 | const char *conf_if, bool use_json, |
d62a17ae | 12358 | json_object *json) |
12359 | { | |
12360 | struct listnode *node, *nnode; | |
12361 | struct peer *peer; | |
12362 | int find = 0; | |
9f049418 | 12363 | bool nbr_output = false; |
d1927ebe AS |
12364 | afi_t afi = AFI_MAX; |
12365 | safi_t safi = SAFI_MAX; | |
12366 | ||
12367 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12368 | afi = AFI_IP; | |
12369 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12370 | afi = AFI_IP6; | |
12371 | } | |
d62a17ae | 12372 | |
12373 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12374 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12375 | continue; | |
12376 | ||
12377 | switch (type) { | |
12378 | case show_all: | |
12379 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12380 | nbr_output = true; |
d62a17ae | 12381 | break; |
12382 | case show_peer: | |
12383 | if (conf_if) { | |
12384 | if ((peer->conf_if | |
12385 | && !strcmp(peer->conf_if, conf_if)) | |
12386 | || (peer->hostname | |
12387 | && !strcmp(peer->hostname, conf_if))) { | |
12388 | find = 1; | |
12389 | bgp_show_peer(vty, peer, use_json, | |
12390 | json); | |
12391 | } | |
12392 | } else { | |
12393 | if (sockunion_same(&peer->su, su)) { | |
12394 | find = 1; | |
12395 | bgp_show_peer(vty, peer, use_json, | |
12396 | json); | |
12397 | } | |
12398 | } | |
12399 | break; | |
d1927ebe AS |
12400 | case show_ipv4_peer: |
12401 | case show_ipv6_peer: | |
12402 | FOREACH_SAFI (safi) { | |
12403 | if (peer->afc[afi][safi]) { | |
12404 | if (conf_if) { | |
12405 | if ((peer->conf_if | |
12406 | && !strcmp(peer->conf_if, conf_if)) | |
12407 | || (peer->hostname | |
12408 | && !strcmp(peer->hostname, conf_if))) { | |
12409 | find = 1; | |
12410 | bgp_show_peer(vty, peer, use_json, | |
12411 | json); | |
12412 | break; | |
12413 | } | |
12414 | } else { | |
12415 | if (sockunion_same(&peer->su, su)) { | |
12416 | find = 1; | |
12417 | bgp_show_peer(vty, peer, use_json, | |
12418 | json); | |
12419 | break; | |
12420 | } | |
12421 | } | |
12422 | } | |
12423 | } | |
12424 | break; | |
12425 | case show_ipv4_all: | |
12426 | case show_ipv6_all: | |
12427 | FOREACH_SAFI (safi) { | |
12428 | if (peer->afc[afi][safi]) { | |
12429 | bgp_show_peer(vty, peer, use_json, json); | |
12430 | nbr_output = true; | |
12431 | break; | |
12432 | } | |
12433 | } | |
12434 | break; | |
d62a17ae | 12435 | } |
12436 | } | |
12437 | ||
d1927ebe AS |
12438 | if ((type == show_peer || type == show_ipv4_peer || |
12439 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12440 | if (use_json) |
12441 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12442 | else | |
88b7d255 | 12443 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12444 | } |
12445 | ||
d1927ebe AS |
12446 | if (type != show_peer && type != show_ipv4_peer && |
12447 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12448 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12449 | |
d62a17ae | 12450 | if (use_json) { |
996c9314 LB |
12451 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12452 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12453 | } else { |
12454 | vty_out(vty, "\n"); | |
12455 | } | |
12456 | ||
12457 | return CMD_SUCCESS; | |
12458 | } | |
12459 | ||
36235319 QY |
12460 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12461 | enum show_type type, | |
12462 | const char *ip_str, | |
12463 | afi_t afi, bool use_json) | |
2986cac2 | 12464 | { |
12465 | ||
12466 | int ret; | |
12467 | struct bgp *bgp; | |
12468 | union sockunion su; | |
2986cac2 | 12469 | |
12470 | bgp = bgp_get_default(); | |
12471 | ||
13909c4f DS |
12472 | if (!bgp) |
12473 | return; | |
2986cac2 | 12474 | |
13909c4f DS |
12475 | if (!use_json) |
12476 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12477 | NULL); | |
2986cac2 | 12478 | |
13909c4f DS |
12479 | if (ip_str) { |
12480 | ret = str2sockunion(ip_str, &su); | |
12481 | if (ret < 0) | |
13909c4f | 12482 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
12483 | vty, bgp, type, NULL, ip_str, afi, use_json); |
12484 | else | |
12485 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
12486 | NULL, afi, use_json); | |
13909c4f DS |
12487 | } else |
12488 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 12489 | afi, use_json); |
2986cac2 | 12490 | } |
12491 | ||
d62a17ae | 12492 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12493 | enum show_type type, |
12494 | const char *ip_str, | |
9f049418 | 12495 | bool use_json) |
d62a17ae | 12496 | { |
0291c246 MK |
12497 | struct listnode *node, *nnode; |
12498 | struct bgp *bgp; | |
71aedaa3 | 12499 | union sockunion su; |
0291c246 | 12500 | json_object *json = NULL; |
71aedaa3 | 12501 | int ret, is_first = 1; |
9f049418 | 12502 | bool nbr_output = false; |
d62a17ae | 12503 | |
12504 | if (use_json) | |
12505 | vty_out(vty, "{\n"); | |
12506 | ||
12507 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12508 | nbr_output = true; |
d62a17ae | 12509 | if (use_json) { |
12510 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12511 | flog_err( |
e50f7cfd | 12512 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12513 | "Unable to allocate memory for JSON object"); |
12514 | vty_out(vty, | |
12515 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12516 | return; | |
12517 | } | |
12518 | ||
12519 | json_object_int_add(json, "vrfId", | |
12520 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12521 | ? -1 |
12522 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12523 | json_object_string_add( |
12524 | json, "vrfName", | |
12525 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12526 | ? VRF_DEFAULT_NAME |
d62a17ae | 12527 | : bgp->name); |
12528 | ||
12529 | if (!is_first) | |
12530 | vty_out(vty, ",\n"); | |
12531 | else | |
12532 | is_first = 0; | |
12533 | ||
12534 | vty_out(vty, "\"%s\":", | |
12535 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12536 | ? VRF_DEFAULT_NAME |
d62a17ae | 12537 | : bgp->name); |
12538 | } else { | |
12539 | vty_out(vty, "\nInstance %s:\n", | |
12540 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12541 | ? VRF_DEFAULT_NAME |
d62a17ae | 12542 | : bgp->name); |
12543 | } | |
71aedaa3 | 12544 | |
d1927ebe AS |
12545 | if (type == show_peer || type == show_ipv4_peer || |
12546 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12547 | ret = str2sockunion(ip_str, &su); |
12548 | if (ret < 0) | |
12549 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12550 | use_json, json); | |
12551 | else | |
12552 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12553 | use_json, json); | |
12554 | } else { | |
d1927ebe | 12555 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12556 | use_json, json); |
12557 | } | |
b77004d6 | 12558 | json_object_free(json); |
d62a17ae | 12559 | } |
12560 | ||
01cbfd04 | 12561 | if (use_json) { |
d62a17ae | 12562 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12563 | json_object_free(json); |
12564 | } | |
9f049418 DS |
12565 | else if (!nbr_output) |
12566 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12567 | } |
12568 | ||
12569 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12570 | enum show_type type, const char *ip_str, | |
9f049418 | 12571 | bool use_json) |
d62a17ae | 12572 | { |
12573 | int ret; | |
12574 | struct bgp *bgp; | |
12575 | union sockunion su; | |
12576 | json_object *json = NULL; | |
12577 | ||
12578 | if (name) { | |
12579 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12580 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12581 | use_json); | |
d62a17ae | 12582 | return CMD_SUCCESS; |
12583 | } else { | |
12584 | bgp = bgp_lookup_by_name(name); | |
12585 | if (!bgp) { | |
12586 | if (use_json) { | |
12587 | json = json_object_new_object(); | |
d62a17ae | 12588 | vty_out(vty, "%s\n", |
12589 | json_object_to_json_string_ext( | |
12590 | json, | |
12591 | JSON_C_TO_STRING_PRETTY)); | |
12592 | json_object_free(json); | |
12593 | } else | |
12594 | vty_out(vty, | |
9f049418 | 12595 | "%% BGP instance not found\n"); |
d62a17ae | 12596 | |
12597 | return CMD_WARNING; | |
12598 | } | |
12599 | } | |
12600 | } else { | |
12601 | bgp = bgp_get_default(); | |
12602 | } | |
12603 | ||
12604 | if (bgp) { | |
12605 | json = json_object_new_object(); | |
12606 | if (ip_str) { | |
12607 | ret = str2sockunion(ip_str, &su); | |
12608 | if (ret < 0) | |
12609 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12610 | use_json, json); | |
12611 | else | |
12612 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12613 | use_json, json); | |
12614 | } else { | |
12615 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12616 | json); | |
12617 | } | |
12618 | json_object_free(json); | |
ca61fd25 DS |
12619 | } else { |
12620 | if (use_json) | |
12621 | vty_out(vty, "{}\n"); | |
12622 | else | |
12623 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12624 | } |
12625 | ||
12626 | return CMD_SUCCESS; | |
4fb25c53 DW |
12627 | } |
12628 | ||
2986cac2 | 12629 | |
12630 | ||
12631 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12632 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12633 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12634 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12635 | SHOW_STR | |
12636 | BGP_STR | |
12637 | IP_STR | |
12638 | IPV6_STR | |
12639 | NEIGHBOR_STR | |
12640 | "Neighbor to display information about\n" | |
12641 | "Neighbor to display information about\n" | |
12642 | "Neighbor on BGP configured interface\n" | |
12643 | GR_SHOW | |
12644 | JSON_STR) | |
12645 | { | |
12646 | char *sh_arg = NULL; | |
12647 | enum show_type sh_type; | |
12648 | int idx = 0; | |
12649 | afi_t afi = AFI_MAX; | |
2986cac2 | 12650 | bool uj = use_json(argc, argv); |
12651 | ||
36235319 | 12652 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12653 | afi = AFI_MAX; |
12654 | ||
12655 | idx++; | |
12656 | ||
12657 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12658 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12659 | || argv_find(argv, argc, "WORD", &idx)) { | |
12660 | sh_type = show_peer; | |
12661 | sh_arg = argv[idx]->arg; | |
12662 | } else | |
12663 | sh_type = show_all; | |
12664 | ||
12665 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12666 | return CMD_SUCCESS; | |
12667 | ||
12668 | ||
36235319 QY |
12669 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12670 | afi, uj); | |
2986cac2 | 12671 | } |
12672 | ||
716b2d8a | 12673 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12674 | DEFUN (show_ip_bgp_neighbors, |
12675 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12676 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12677 | SHOW_STR |
12678 | IP_STR | |
12679 | BGP_STR | |
f2a8972b | 12680 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12681 | "Address Family\n" |
12682 | "Address Family\n" | |
718e3744 | 12683 | "Detailed information on TCP and BGP neighbor connections\n" |
12684 | "Neighbor to display information about\n" | |
a80beece | 12685 | "Neighbor to display information about\n" |
91d37724 | 12686 | "Neighbor on BGP configured interface\n" |
9973d184 | 12687 | JSON_STR) |
718e3744 | 12688 | { |
d62a17ae | 12689 | char *vrf = NULL; |
12690 | char *sh_arg = NULL; | |
12691 | enum show_type sh_type; | |
d1927ebe | 12692 | afi_t afi = AFI_MAX; |
718e3744 | 12693 | |
9f049418 | 12694 | bool uj = use_json(argc, argv); |
718e3744 | 12695 | |
d62a17ae | 12696 | int idx = 0; |
718e3744 | 12697 | |
9a8bdf1c PG |
12698 | /* [<vrf> VIEWVRFNAME] */ |
12699 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12700 | vrf = argv[idx + 1]->arg; | |
12701 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12702 | vrf = NULL; | |
12703 | } else if (argv_find(argv, argc, "view", &idx)) | |
12704 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12705 | vrf = argv[idx + 1]->arg; |
718e3744 | 12706 | |
d62a17ae | 12707 | idx++; |
d1927ebe AS |
12708 | |
12709 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12710 | sh_type = show_ipv4_all; | |
12711 | afi = AFI_IP; | |
12712 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12713 | sh_type = show_ipv6_all; | |
12714 | afi = AFI_IP6; | |
12715 | } else { | |
12716 | sh_type = show_all; | |
12717 | } | |
12718 | ||
d62a17ae | 12719 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12720 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12721 | || argv_find(argv, argc, "WORD", &idx)) { | |
12722 | sh_type = show_peer; | |
12723 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12724 | } |
12725 | ||
12726 | if (sh_type == show_peer && afi == AFI_IP) { | |
12727 | sh_type = show_ipv4_peer; | |
12728 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12729 | sh_type = show_ipv6_peer; | |
12730 | } | |
856ca177 | 12731 | |
d62a17ae | 12732 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12733 | } |
12734 | ||
716b2d8a | 12735 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12736 | paths' and `show ip mbgp paths'. Those functions results are the |
12737 | same.*/ | |
f412b39a | 12738 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12739 | show_ip_bgp_paths_cmd, |
46f296b4 | 12740 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12741 | SHOW_STR |
12742 | IP_STR | |
12743 | BGP_STR | |
46f296b4 | 12744 | BGP_SAFI_HELP_STR |
718e3744 | 12745 | "Path information\n") |
12746 | { | |
d62a17ae | 12747 | vty_out(vty, "Address Refcnt Path\n"); |
12748 | aspath_print_all_vty(vty); | |
12749 | return CMD_SUCCESS; | |
718e3744 | 12750 | } |
12751 | ||
718e3744 | 12752 | #include "hash.h" |
12753 | ||
e3b78da8 | 12754 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12755 | struct vty *vty) |
718e3744 | 12756 | { |
d62a17ae | 12757 | struct community *com; |
718e3744 | 12758 | |
e3b78da8 | 12759 | com = (struct community *)bucket->data; |
3f65c5b1 | 12760 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12761 | community_str(com, false)); |
718e3744 | 12762 | } |
12763 | ||
12764 | /* Show BGP's community internal data. */ | |
f412b39a | 12765 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12766 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12767 | "show [ip] bgp community-info", |
718e3744 | 12768 | SHOW_STR |
12769 | IP_STR | |
12770 | BGP_STR | |
12771 | "List all bgp community information\n") | |
12772 | { | |
d62a17ae | 12773 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12774 | |
d62a17ae | 12775 | hash_iterate(community_hash(), |
e3b78da8 | 12776 | (void (*)(struct hash_bucket *, |
d62a17ae | 12777 | void *))community_show_all_iterator, |
12778 | vty); | |
718e3744 | 12779 | |
d62a17ae | 12780 | return CMD_SUCCESS; |
718e3744 | 12781 | } |
12782 | ||
e3b78da8 | 12783 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12784 | struct vty *vty) |
57d187bc | 12785 | { |
d62a17ae | 12786 | struct lcommunity *lcom; |
57d187bc | 12787 | |
e3b78da8 | 12788 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12789 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12790 | lcommunity_str(lcom, false)); |
57d187bc JS |
12791 | } |
12792 | ||
12793 | /* Show BGP's community internal data. */ | |
12794 | DEFUN (show_ip_bgp_lcommunity_info, | |
12795 | show_ip_bgp_lcommunity_info_cmd, | |
12796 | "show ip bgp large-community-info", | |
12797 | SHOW_STR | |
12798 | IP_STR | |
12799 | BGP_STR | |
12800 | "List all bgp large-community information\n") | |
12801 | { | |
d62a17ae | 12802 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12803 | |
d62a17ae | 12804 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12805 | (void (*)(struct hash_bucket *, |
d62a17ae | 12806 | void *))lcommunity_show_all_iterator, |
12807 | vty); | |
57d187bc | 12808 | |
d62a17ae | 12809 | return CMD_SUCCESS; |
57d187bc | 12810 | } |
2986cac2 | 12811 | /* Graceful Restart */ |
12812 | ||
12813 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
12814 | struct bgp *bgp, |
12815 | bool use_json, | |
12816 | json_object *json) | |
2986cac2 | 12817 | { |
57d187bc JS |
12818 | |
12819 | ||
2986cac2 | 12820 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12821 | ||
7318ae88 | 12822 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 12823 | |
12824 | switch (bgp_global_gr_mode) { | |
12825 | ||
12826 | case GLOBAL_HELPER: | |
13909c4f | 12827 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 12828 | break; |
12829 | ||
12830 | case GLOBAL_GR: | |
13909c4f | 12831 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 12832 | break; |
12833 | ||
12834 | case GLOBAL_DISABLE: | |
13909c4f | 12835 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 12836 | break; |
12837 | ||
12838 | case GLOBAL_INVALID: | |
2986cac2 | 12839 | vty_out(vty, |
2ba1fe69 | 12840 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 12841 | break; |
12842 | } | |
12843 | vty_out(vty, "\n"); | |
12844 | } | |
12845 | ||
36235319 QY |
12846 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
12847 | enum show_type type, | |
12848 | const char *ip_str, | |
12849 | afi_t afi, bool use_json) | |
2986cac2 | 12850 | { |
12851 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12852 | afi = AFI_IP; | |
12853 | ||
12854 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12855 | ||
36235319 QY |
12856 | bgp_show_neighbor_graceful_restart_vty( |
12857 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 12858 | afi++; |
12859 | } | |
12860 | } else if (afi != AFI_MAX) { | |
36235319 QY |
12861 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
12862 | use_json); | |
2986cac2 | 12863 | } else { |
12864 | return CMD_ERR_INCOMPLETE; | |
12865 | } | |
12866 | ||
12867 | return CMD_SUCCESS; | |
12868 | } | |
12869 | /* Graceful Restart */ | |
12870 | ||
f412b39a | 12871 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12872 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12873 | "show [ip] bgp attribute-info", |
718e3744 | 12874 | SHOW_STR |
12875 | IP_STR | |
12876 | BGP_STR | |
12877 | "List all bgp attribute information\n") | |
12878 | { | |
d62a17ae | 12879 | attr_show_all(vty); |
12880 | return CMD_SUCCESS; | |
718e3744 | 12881 | } |
6b0655a2 | 12882 | |
03915806 CS |
12883 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12884 | afi_t afi, safi_t safi, | |
12885 | bool use_json, json_object *json) | |
53089bec | 12886 | { |
12887 | struct bgp *bgp; | |
12888 | struct listnode *node; | |
12889 | char *vname; | |
12890 | char buf1[INET6_ADDRSTRLEN]; | |
12891 | char *ecom_str; | |
12892 | vpn_policy_direction_t dir; | |
12893 | ||
03915806 | 12894 | if (json) { |
b46dfd20 DS |
12895 | json_object *json_import_vrfs = NULL; |
12896 | json_object *json_export_vrfs = NULL; | |
12897 | ||
b46dfd20 DS |
12898 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12899 | ||
53089bec | 12900 | if (!bgp) { |
b46dfd20 DS |
12901 | vty_out(vty, "%s\n", |
12902 | json_object_to_json_string_ext( | |
12903 | json, | |
12904 | JSON_C_TO_STRING_PRETTY)); | |
12905 | json_object_free(json); | |
12906 | ||
53089bec | 12907 | return CMD_WARNING; |
12908 | } | |
b46dfd20 | 12909 | |
94d4c685 DS |
12910 | /* Provide context for the block */ |
12911 | json_object_string_add(json, "vrf", name ? name : "default"); | |
12912 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 12913 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 12914 | |
b46dfd20 DS |
12915 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12916 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
12917 | json_object_string_add(json, "importFromVrfs", "none"); | |
12918 | json_object_string_add(json, "importRts", "none"); | |
12919 | } else { | |
6ce24e52 DS |
12920 | json_import_vrfs = json_object_new_array(); |
12921 | ||
b46dfd20 DS |
12922 | for (ALL_LIST_ELEMENTS_RO( |
12923 | bgp->vpn_policy[afi].import_vrf, | |
12924 | node, vname)) | |
12925 | json_object_array_add(json_import_vrfs, | |
12926 | json_object_new_string(vname)); | |
12927 | ||
b20875ea CS |
12928 | json_object_object_add(json, "importFromVrfs", |
12929 | json_import_vrfs); | |
b46dfd20 | 12930 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
12931 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12932 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12933 | bgp->vpn_policy[afi].rtlist[dir], |
12934 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12935 | json_object_string_add(json, "importRts", |
12936 | ecom_str); | |
12937 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12938 | } else | |
12939 | json_object_string_add(json, "importRts", | |
12940 | "none"); | |
b46dfd20 DS |
12941 | } |
12942 | ||
12943 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
12944 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
12945 | json_object_string_add(json, "exportToVrfs", "none"); | |
12946 | json_object_string_add(json, "routeDistinguisher", | |
12947 | "none"); | |
12948 | json_object_string_add(json, "exportRts", "none"); | |
12949 | } else { | |
6ce24e52 DS |
12950 | json_export_vrfs = json_object_new_array(); |
12951 | ||
b46dfd20 DS |
12952 | for (ALL_LIST_ELEMENTS_RO( |
12953 | bgp->vpn_policy[afi].export_vrf, | |
12954 | node, vname)) | |
12955 | json_object_array_add(json_export_vrfs, | |
12956 | json_object_new_string(vname)); | |
12957 | json_object_object_add(json, "exportToVrfs", | |
12958 | json_export_vrfs); | |
12959 | json_object_string_add(json, "routeDistinguisher", | |
12960 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12961 | buf1, RD_ADDRSTRLEN)); | |
12962 | ||
12963 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12964 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12965 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12966 | bgp->vpn_policy[afi].rtlist[dir], |
12967 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12968 | json_object_string_add(json, "exportRts", |
12969 | ecom_str); | |
12970 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12971 | } else | |
12972 | json_object_string_add(json, "exportRts", | |
12973 | "none"); | |
b46dfd20 DS |
12974 | } |
12975 | ||
03915806 CS |
12976 | if (use_json) { |
12977 | vty_out(vty, "%s\n", | |
12978 | json_object_to_json_string_ext(json, | |
b46dfd20 | 12979 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
12980 | json_object_free(json); |
12981 | } | |
53089bec | 12982 | } else { |
b46dfd20 DS |
12983 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12984 | ||
53089bec | 12985 | if (!bgp) { |
b46dfd20 | 12986 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 12987 | return CMD_WARNING; |
12988 | } | |
53089bec | 12989 | |
b46dfd20 DS |
12990 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12991 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
12992 | vty_out(vty, | |
12993 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 12994 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12995 | else { |
12996 | vty_out(vty, | |
12997 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 12998 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12999 | |
13000 | for (ALL_LIST_ELEMENTS_RO( | |
13001 | bgp->vpn_policy[afi].import_vrf, | |
13002 | node, vname)) | |
13003 | vty_out(vty, " %s\n", vname); | |
13004 | ||
13005 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
13006 | ecom_str = NULL; |
13007 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
13008 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13009 | bgp->vpn_policy[afi].rtlist[dir], |
13010 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 13011 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 13012 | |
b20875ea CS |
13013 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
13014 | } else | |
13015 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13016 | } |
53089bec | 13017 | |
b46dfd20 DS |
13018 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13019 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
13020 | vty_out(vty, | |
13021 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 13022 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13023 | else { |
13024 | vty_out(vty, | |
04c9077f | 13025 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 13026 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13027 | |
13028 | for (ALL_LIST_ELEMENTS_RO( | |
13029 | bgp->vpn_policy[afi].export_vrf, | |
13030 | node, vname)) | |
13031 | vty_out(vty, " %s\n", vname); | |
13032 | ||
13033 | vty_out(vty, "RD: %s\n", | |
13034 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13035 | buf1, RD_ADDRSTRLEN)); | |
13036 | ||
13037 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13038 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13039 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13040 | bgp->vpn_policy[afi].rtlist[dir], |
13041 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13042 | vty_out(vty, "Export RT: %s\n", ecom_str); |
13043 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13044 | } else | |
13045 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13046 | } |
53089bec | 13047 | } |
13048 | ||
13049 | return CMD_SUCCESS; | |
13050 | } | |
13051 | ||
03915806 CS |
13052 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
13053 | safi_t safi, bool use_json) | |
13054 | { | |
13055 | struct listnode *node, *nnode; | |
13056 | struct bgp *bgp; | |
13057 | char *vrf_name = NULL; | |
13058 | json_object *json = NULL; | |
13059 | json_object *json_vrf = NULL; | |
13060 | json_object *json_vrfs = NULL; | |
13061 | ||
13062 | if (use_json) { | |
13063 | json = json_object_new_object(); | |
13064 | json_vrfs = json_object_new_object(); | |
13065 | } | |
13066 | ||
13067 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
13068 | ||
13069 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
13070 | vrf_name = bgp->name; | |
13071 | ||
13072 | if (use_json) { | |
13073 | json_vrf = json_object_new_object(); | |
13074 | } else { | |
13075 | vty_out(vty, "\nInstance %s:\n", | |
13076 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13077 | ? VRF_DEFAULT_NAME : bgp->name); | |
13078 | } | |
13079 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
13080 | if (use_json) { | |
13081 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13082 | json_object_object_add(json_vrfs, | |
13083 | VRF_DEFAULT_NAME, json_vrf); | |
13084 | else | |
13085 | json_object_object_add(json_vrfs, vrf_name, | |
13086 | json_vrf); | |
13087 | } | |
13088 | } | |
13089 | ||
13090 | if (use_json) { | |
13091 | json_object_object_add(json, "vrfs", json_vrfs); | |
13092 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13093 | JSON_C_TO_STRING_PRETTY)); | |
13094 | json_object_free(json); | |
13095 | } | |
13096 | ||
13097 | return CMD_SUCCESS; | |
13098 | } | |
13099 | ||
53089bec | 13100 | /* "show [ip] bgp route-leak" command. */ |
13101 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13102 | show_ip_bgp_route_leak_cmd, |
13103 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13104 | SHOW_STR |
13105 | IP_STR | |
13106 | BGP_STR | |
13107 | BGP_INSTANCE_HELP_STR | |
13108 | BGP_AFI_HELP_STR | |
13109 | BGP_SAFI_HELP_STR | |
13110 | "Route leaking information\n" | |
13111 | JSON_STR) | |
53089bec | 13112 | { |
13113 | char *vrf = NULL; | |
13114 | afi_t afi = AFI_MAX; | |
13115 | safi_t safi = SAFI_MAX; | |
13116 | ||
9f049418 | 13117 | bool uj = use_json(argc, argv); |
53089bec | 13118 | int idx = 0; |
03915806 | 13119 | json_object *json = NULL; |
53089bec | 13120 | |
13121 | /* show [ip] bgp */ | |
13122 | if (argv_find(argv, argc, "ip", &idx)) { | |
13123 | afi = AFI_IP; | |
13124 | safi = SAFI_UNICAST; | |
13125 | } | |
13126 | /* [vrf VIEWVRFNAME] */ | |
13127 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
13128 | vty_out(vty, |
13129 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 13130 | return CMD_WARNING; |
13131 | } | |
13132 | ||
9a8bdf1c PG |
13133 | if (argv_find(argv, argc, "vrf", &idx)) { |
13134 | vrf = argv[idx + 1]->arg; | |
13135 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13136 | vrf = NULL; | |
13137 | } | |
53089bec | 13138 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13139 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13140 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13141 | } | |
13142 | ||
13143 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
13144 | vty_out(vty, |
13145 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 13146 | return CMD_WARNING; |
13147 | } | |
13148 | ||
03915806 CS |
13149 | if (vrf && strmatch(vrf, "all")) |
13150 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13151 | ||
13152 | if (uj) | |
13153 | json = json_object_new_object(); | |
13154 | ||
13155 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13156 | } |
13157 | ||
d62a17ae | 13158 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13159 | safi_t safi) | |
f186de26 | 13160 | { |
d62a17ae | 13161 | struct listnode *node, *nnode; |
13162 | struct bgp *bgp; | |
f186de26 | 13163 | |
d62a17ae | 13164 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13165 | vty_out(vty, "\nInstance %s:\n", | |
13166 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13167 | ? VRF_DEFAULT_NAME |
d62a17ae | 13168 | : bgp->name); |
13169 | update_group_show(bgp, afi, safi, vty, 0); | |
13170 | } | |
f186de26 | 13171 | } |
13172 | ||
d62a17ae | 13173 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13174 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13175 | { |
d62a17ae | 13176 | struct bgp *bgp; |
4fb25c53 | 13177 | |
d62a17ae | 13178 | if (name) { |
13179 | if (strmatch(name, "all")) { | |
13180 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13181 | return CMD_SUCCESS; | |
13182 | } else { | |
13183 | bgp = bgp_lookup_by_name(name); | |
13184 | } | |
13185 | } else { | |
13186 | bgp = bgp_get_default(); | |
13187 | } | |
4fb25c53 | 13188 | |
d62a17ae | 13189 | if (bgp) |
13190 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13191 | return CMD_SUCCESS; | |
4fb25c53 DW |
13192 | } |
13193 | ||
8fe8a7f6 DS |
13194 | DEFUN (show_ip_bgp_updgrps, |
13195 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13196 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13197 | SHOW_STR |
13198 | IP_STR | |
13199 | BGP_STR | |
13200 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13201 | BGP_AFI_HELP_STR |
9bedbb1e | 13202 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13203 | "Detailed info about dynamic update groups\n" |
13204 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13205 | { |
d62a17ae | 13206 | char *vrf = NULL; |
13207 | afi_t afi = AFI_IP6; | |
13208 | safi_t safi = SAFI_UNICAST; | |
13209 | uint64_t subgrp_id = 0; | |
13210 | ||
13211 | int idx = 0; | |
13212 | ||
13213 | /* show [ip] bgp */ | |
13214 | if (argv_find(argv, argc, "ip", &idx)) | |
13215 | afi = AFI_IP; | |
9a8bdf1c PG |
13216 | /* [<vrf> VIEWVRFNAME] */ |
13217 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13218 | vrf = argv[idx + 1]->arg; | |
13219 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13220 | vrf = NULL; | |
13221 | } else if (argv_find(argv, argc, "view", &idx)) | |
13222 | /* [<view> VIEWVRFNAME] */ | |
13223 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13224 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13225 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13226 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13227 | } | |
5bf15956 | 13228 | |
d62a17ae | 13229 | /* get subgroup id, if provided */ |
13230 | idx = argc - 1; | |
13231 | if (argv[idx]->type == VARIABLE_TKN) | |
13232 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13233 | |
d62a17ae | 13234 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13235 | } |
13236 | ||
f186de26 | 13237 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13238 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13239 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13240 | SHOW_STR |
716b2d8a | 13241 | IP_STR |
f186de26 | 13242 | BGP_STR |
13243 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13244 | "Detailed info about dynamic update groups\n") |
f186de26 | 13245 | { |
d62a17ae | 13246 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13247 | return CMD_SUCCESS; | |
f186de26 | 13248 | } |
13249 | ||
43d3f4fc DS |
13250 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13251 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13252 | "show [ip] bgp l2vpn evpn update-groups", | |
13253 | SHOW_STR | |
13254 | IP_STR | |
13255 | BGP_STR | |
13256 | "l2vpn address family\n" | |
13257 | "evpn sub-address family\n" | |
13258 | "Detailed info about dynamic update groups\n") | |
13259 | { | |
13260 | char *vrf = NULL; | |
13261 | uint64_t subgrp_id = 0; | |
13262 | ||
13263 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13264 | return CMD_SUCCESS; | |
13265 | } | |
13266 | ||
5bf15956 DW |
13267 | DEFUN (show_bgp_updgrps_stats, |
13268 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13269 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13270 | SHOW_STR |
716b2d8a | 13271 | IP_STR |
3f9c7369 | 13272 | BGP_STR |
0c7b1b01 | 13273 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13274 | "Statistics\n") |
13275 | { | |
d62a17ae | 13276 | struct bgp *bgp; |
3f9c7369 | 13277 | |
d62a17ae | 13278 | bgp = bgp_get_default(); |
13279 | if (bgp) | |
13280 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13281 | |
d62a17ae | 13282 | return CMD_SUCCESS; |
3f9c7369 DS |
13283 | } |
13284 | ||
8386ac43 | 13285 | DEFUN (show_bgp_instance_updgrps_stats, |
13286 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13287 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13288 | SHOW_STR |
716b2d8a | 13289 | IP_STR |
8386ac43 | 13290 | BGP_STR |
13291 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13292 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13293 | "Statistics\n") |
13294 | { | |
d62a17ae | 13295 | int idx_word = 3; |
13296 | struct bgp *bgp; | |
8386ac43 | 13297 | |
d62a17ae | 13298 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13299 | if (bgp) | |
13300 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13301 | |
d62a17ae | 13302 | return CMD_SUCCESS; |
8386ac43 | 13303 | } |
13304 | ||
d62a17ae | 13305 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13306 | afi_t afi, safi_t safi, | |
13307 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13308 | { |
d62a17ae | 13309 | struct bgp *bgp; |
8386ac43 | 13310 | |
d62a17ae | 13311 | if (name) |
13312 | bgp = bgp_lookup_by_name(name); | |
13313 | else | |
13314 | bgp = bgp_get_default(); | |
8386ac43 | 13315 | |
d62a17ae | 13316 | if (bgp) { |
13317 | if (!strcmp(what, "advertise-queue")) | |
13318 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13319 | subgrp_id); | |
13320 | else if (!strcmp(what, "advertised-routes")) | |
13321 | update_group_show_advertised(bgp, afi, safi, vty, | |
13322 | subgrp_id); | |
13323 | else if (!strcmp(what, "packet-queue")) | |
13324 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13325 | subgrp_id); | |
13326 | } | |
3f9c7369 DS |
13327 | } |
13328 | ||
dc64bdec QY |
13329 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13330 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13331 | "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", | |
13332 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13333 | BGP_SAFI_HELP_STR | |
13334 | "Detailed info about dynamic update groups\n" | |
13335 | "Specific subgroup to display info for\n" | |
13336 | "Advertisement queue\n" | |
13337 | "Announced routes\n" | |
13338 | "Packet queue\n") | |
3f9c7369 | 13339 | { |
dc64bdec QY |
13340 | uint64_t subgrp_id = 0; |
13341 | afi_t afiz; | |
13342 | safi_t safiz; | |
13343 | if (sgid) | |
13344 | subgrp_id = strtoull(sgid, NULL, 10); | |
13345 | ||
13346 | if (!ip && !afi) | |
13347 | afiz = AFI_IP6; | |
13348 | if (!ip && afi) | |
13349 | afiz = bgp_vty_afi_from_str(afi); | |
13350 | if (ip && !afi) | |
13351 | afiz = AFI_IP; | |
13352 | if (ip && afi) { | |
13353 | afiz = bgp_vty_afi_from_str(afi); | |
13354 | if (afiz != AFI_IP) | |
13355 | vty_out(vty, | |
13356 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13357 | return CMD_WARNING; | |
13358 | } | |
d62a17ae | 13359 | |
dc64bdec | 13360 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13361 | |
dc64bdec | 13362 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13363 | return CMD_SUCCESS; |
13364 | } | |
13365 | ||
d62a17ae | 13366 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13367 | { | |
13368 | struct listnode *node, *nnode; | |
13369 | struct prefix *range; | |
13370 | struct peer *conf; | |
13371 | struct peer *peer; | |
13372 | char buf[PREFIX2STR_BUFFER]; | |
13373 | afi_t afi; | |
13374 | safi_t safi; | |
13375 | const char *peer_status; | |
13376 | const char *af_str; | |
13377 | int lr_count; | |
13378 | int dynamic; | |
13379 | int af_cfgd; | |
13380 | ||
13381 | conf = group->conf; | |
13382 | ||
13383 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13384 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13385 | group->name, conf->as); | |
d62a17ae | 13386 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13387 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13388 | group->name, group->bgp->as); | |
d62a17ae | 13389 | } else { |
13390 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13391 | } | |
f14e6fdb | 13392 | |
d62a17ae | 13393 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13394 | vty_out(vty, " Peer-group type is internal\n"); | |
13395 | else | |
13396 | vty_out(vty, " Peer-group type is external\n"); | |
13397 | ||
13398 | /* Display AFs configured. */ | |
13399 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13400 | FOREACH_AFI_SAFI (afi, safi) { |
13401 | if (conf->afc[afi][safi]) { | |
13402 | af_cfgd = 1; | |
5cb5f4d0 | 13403 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13404 | } |
05c7a1cc | 13405 | } |
d62a17ae | 13406 | if (!af_cfgd) |
13407 | vty_out(vty, " none\n"); | |
13408 | else | |
13409 | vty_out(vty, "\n"); | |
13410 | ||
13411 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13412 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13413 | if (afi == AFI_IP) | |
13414 | af_str = "IPv4"; | |
13415 | else if (afi == AFI_IP6) | |
13416 | af_str = "IPv6"; | |
13417 | else | |
13418 | af_str = "???"; | |
13419 | lr_count = listcount(group->listen_range[afi]); | |
13420 | if (lr_count) { | |
13421 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13422 | af_str); | |
13423 | ||
13424 | ||
13425 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13426 | nnode, range)) { | |
13427 | prefix2str(range, buf, sizeof(buf)); | |
13428 | vty_out(vty, " %s\n", buf); | |
13429 | } | |
13430 | } | |
13431 | } | |
f14e6fdb | 13432 | |
d62a17ae | 13433 | /* Display group members and their status */ |
13434 | if (listcount(group->peer)) { | |
13435 | vty_out(vty, " Peer-group members:\n"); | |
13436 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13437 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13438 | peer_status = "Idle (Admin)"; | |
13439 | else if (CHECK_FLAG(peer->sflags, | |
13440 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13441 | peer_status = "Idle (PfxCt)"; | |
13442 | else | |
13443 | peer_status = lookup_msg(bgp_status_msg, | |
13444 | peer->status, NULL); | |
13445 | ||
13446 | dynamic = peer_dynamic_neighbor(peer); | |
13447 | vty_out(vty, " %s %s %s \n", peer->host, | |
13448 | dynamic ? "(dynamic)" : "", peer_status); | |
13449 | } | |
13450 | } | |
f14e6fdb | 13451 | |
d62a17ae | 13452 | return CMD_SUCCESS; |
13453 | } | |
13454 | ||
ff9959b0 QY |
13455 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13456 | const char *group_name) | |
d62a17ae | 13457 | { |
ff9959b0 | 13458 | struct bgp *bgp; |
d62a17ae | 13459 | struct listnode *node, *nnode; |
13460 | struct peer_group *group; | |
ff9959b0 QY |
13461 | bool found = false; |
13462 | ||
13463 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13464 | ||
13465 | if (!bgp) { | |
9f049418 | 13466 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13467 | return CMD_WARNING; |
13468 | } | |
d62a17ae | 13469 | |
13470 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13471 | if (group_name) { |
13472 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13473 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13474 | found = true; |
13475 | break; | |
d62a17ae | 13476 | } |
ff9959b0 QY |
13477 | } else { |
13478 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13479 | } |
f14e6fdb | 13480 | } |
f14e6fdb | 13481 | |
ff9959b0 | 13482 | if (group_name && !found) |
d62a17ae | 13483 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13484 | |
d62a17ae | 13485 | return CMD_SUCCESS; |
f14e6fdb DS |
13486 | } |
13487 | ||
f14e6fdb DS |
13488 | DEFUN (show_ip_bgp_peer_groups, |
13489 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13490 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13491 | SHOW_STR |
13492 | IP_STR | |
13493 | BGP_STR | |
8386ac43 | 13494 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13495 | "Detailed information on BGP peer groups\n" |
13496 | "Peer group name\n") | |
f14e6fdb | 13497 | { |
d62a17ae | 13498 | char *vrf, *pg; |
d62a17ae | 13499 | int idx = 0; |
f14e6fdb | 13500 | |
a4d82a8a PZ |
13501 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13502 | : NULL; | |
d62a17ae | 13503 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13504 | |
ff9959b0 | 13505 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13506 | } |
3f9c7369 | 13507 | |
d6e3c605 | 13508 | |
718e3744 | 13509 | /* Redistribute VTY commands. */ |
13510 | ||
718e3744 | 13511 | DEFUN (bgp_redistribute_ipv4, |
13512 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13513 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13514 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13515 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13516 | { |
d62a17ae | 13517 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13518 | int idx_protocol = 1; | |
13519 | int type; | |
718e3744 | 13520 | |
d62a17ae | 13521 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13522 | if (type < 0) { | |
13523 | vty_out(vty, "%% Invalid route type\n"); | |
13524 | return CMD_WARNING_CONFIG_FAILED; | |
13525 | } | |
7f323236 | 13526 | |
d62a17ae | 13527 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13528 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13529 | } |
13530 | ||
d62a17ae | 13531 | ALIAS_HIDDEN( |
13532 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13533 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13534 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13535 | |
718e3744 | 13536 | DEFUN (bgp_redistribute_ipv4_rmap, |
13537 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13538 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13539 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13540 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13541 | "Route map reference\n" |
13542 | "Pointer to route-map entries\n") | |
13543 | { | |
d62a17ae | 13544 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13545 | int idx_protocol = 1; | |
13546 | int idx_word = 3; | |
13547 | int type; | |
13548 | struct bgp_redist *red; | |
e923dd62 | 13549 | bool changed; |
1de27621 DA |
13550 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13551 | vty, argv[idx_word]->arg); | |
718e3744 | 13552 | |
d62a17ae | 13553 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13554 | if (type < 0) { | |
13555 | vty_out(vty, "%% Invalid route type\n"); | |
13556 | return CMD_WARNING_CONFIG_FAILED; | |
13557 | } | |
718e3744 | 13558 | |
d62a17ae | 13559 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13560 | changed = |
13561 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13562 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13563 | } |
13564 | ||
d62a17ae | 13565 | ALIAS_HIDDEN( |
13566 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13567 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13568 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13569 | "Route map reference\n" | |
13570 | "Pointer to route-map entries\n") | |
596c17ba | 13571 | |
718e3744 | 13572 | DEFUN (bgp_redistribute_ipv4_metric, |
13573 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13574 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13575 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13576 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13577 | "Metric for redistributed routes\n" |
13578 | "Default metric\n") | |
13579 | { | |
d62a17ae | 13580 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13581 | int idx_protocol = 1; | |
13582 | int idx_number = 3; | |
13583 | int type; | |
d7c0a89a | 13584 | uint32_t metric; |
d62a17ae | 13585 | struct bgp_redist *red; |
e923dd62 | 13586 | bool changed; |
d62a17ae | 13587 | |
13588 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13589 | if (type < 0) { | |
13590 | vty_out(vty, "%% Invalid route type\n"); | |
13591 | return CMD_WARNING_CONFIG_FAILED; | |
13592 | } | |
13593 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13594 | ||
13595 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13596 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13597 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13598 | } |
13599 | ||
13600 | ALIAS_HIDDEN( | |
13601 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13602 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13603 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13604 | "Metric for redistributed routes\n" | |
13605 | "Default metric\n") | |
596c17ba | 13606 | |
718e3744 | 13607 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13608 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13609 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13610 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13611 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13612 | "Route map reference\n" |
13613 | "Pointer to route-map entries\n" | |
13614 | "Metric for redistributed routes\n" | |
13615 | "Default metric\n") | |
13616 | { | |
d62a17ae | 13617 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13618 | int idx_protocol = 1; | |
13619 | int idx_word = 3; | |
13620 | int idx_number = 5; | |
13621 | int type; | |
d7c0a89a | 13622 | uint32_t metric; |
d62a17ae | 13623 | struct bgp_redist *red; |
e923dd62 | 13624 | bool changed; |
1de27621 DA |
13625 | struct route_map *route_map = |
13626 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13627 | |
13628 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13629 | if (type < 0) { | |
13630 | vty_out(vty, "%% Invalid route type\n"); | |
13631 | return CMD_WARNING_CONFIG_FAILED; | |
13632 | } | |
13633 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13634 | ||
13635 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13636 | changed = |
13637 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13638 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13639 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13640 | } |
13641 | ||
13642 | ALIAS_HIDDEN( | |
13643 | bgp_redistribute_ipv4_rmap_metric, | |
13644 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13645 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13646 | " route-map WORD metric (0-4294967295)", | |
13647 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13648 | "Route map reference\n" | |
13649 | "Pointer to route-map entries\n" | |
13650 | "Metric for redistributed routes\n" | |
13651 | "Default metric\n") | |
596c17ba | 13652 | |
718e3744 | 13653 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13654 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13655 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13656 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13657 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13658 | "Metric for redistributed routes\n" |
13659 | "Default metric\n" | |
13660 | "Route map reference\n" | |
13661 | "Pointer to route-map entries\n") | |
13662 | { | |
d62a17ae | 13663 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13664 | int idx_protocol = 1; | |
13665 | int idx_number = 3; | |
13666 | int idx_word = 5; | |
13667 | int type; | |
d7c0a89a | 13668 | uint32_t metric; |
d62a17ae | 13669 | struct bgp_redist *red; |
e923dd62 | 13670 | bool changed; |
1de27621 DA |
13671 | struct route_map *route_map = |
13672 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13673 | |
13674 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13675 | if (type < 0) { | |
13676 | vty_out(vty, "%% Invalid route type\n"); | |
13677 | return CMD_WARNING_CONFIG_FAILED; | |
13678 | } | |
13679 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13680 | ||
13681 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13682 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13683 | changed |= |
13684 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13685 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13686 | } |
13687 | ||
13688 | ALIAS_HIDDEN( | |
13689 | bgp_redistribute_ipv4_metric_rmap, | |
13690 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13691 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13692 | " metric (0-4294967295) route-map WORD", | |
13693 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13694 | "Metric for redistributed routes\n" | |
13695 | "Default metric\n" | |
13696 | "Route map reference\n" | |
13697 | "Pointer to route-map entries\n") | |
596c17ba | 13698 | |
7c8ff89e DS |
13699 | DEFUN (bgp_redistribute_ipv4_ospf, |
13700 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13701 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13702 | "Redistribute information from another routing protocol\n" |
13703 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13704 | "Non-main Kernel Routing Table\n" |
13705 | "Instance ID/Table ID\n") | |
7c8ff89e | 13706 | { |
d62a17ae | 13707 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13708 | int idx_ospf_table = 1; | |
13709 | int idx_number = 2; | |
d7c0a89a QY |
13710 | unsigned short instance; |
13711 | unsigned short protocol; | |
7c8ff89e | 13712 | |
d62a17ae | 13713 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13714 | |
d62a17ae | 13715 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13716 | protocol = ZEBRA_ROUTE_OSPF; | |
13717 | else | |
13718 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13719 | |
d62a17ae | 13720 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13721 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13722 | } |
13723 | ||
d62a17ae | 13724 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13725 | "redistribute <ospf|table> (1-65535)", | |
13726 | "Redistribute information from another routing protocol\n" | |
13727 | "Open Shortest Path First (OSPFv2)\n" | |
13728 | "Non-main Kernel Routing Table\n" | |
13729 | "Instance ID/Table ID\n") | |
596c17ba | 13730 | |
7c8ff89e DS |
13731 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13732 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13733 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13734 | "Redistribute information from another routing protocol\n" |
13735 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13736 | "Non-main Kernel Routing Table\n" |
13737 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13738 | "Route map reference\n" |
13739 | "Pointer to route-map entries\n") | |
13740 | { | |
d62a17ae | 13741 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13742 | int idx_ospf_table = 1; | |
13743 | int idx_number = 2; | |
13744 | int idx_word = 4; | |
13745 | struct bgp_redist *red; | |
d7c0a89a | 13746 | unsigned short instance; |
d62a17ae | 13747 | int protocol; |
e923dd62 | 13748 | bool changed; |
1de27621 DA |
13749 | struct route_map *route_map = |
13750 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13751 | |
13752 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13753 | protocol = ZEBRA_ROUTE_OSPF; | |
13754 | else | |
13755 | protocol = ZEBRA_ROUTE_TABLE; | |
13756 | ||
13757 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13758 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13759 | changed = |
13760 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13761 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13762 | } |
13763 | ||
13764 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13765 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13766 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13767 | "Redistribute information from another routing protocol\n" | |
13768 | "Open Shortest Path First (OSPFv2)\n" | |
13769 | "Non-main Kernel Routing Table\n" | |
13770 | "Instance ID/Table ID\n" | |
13771 | "Route map reference\n" | |
13772 | "Pointer to route-map entries\n") | |
596c17ba | 13773 | |
7c8ff89e DS |
13774 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13775 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13776 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13777 | "Redistribute information from another routing protocol\n" |
13778 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13779 | "Non-main Kernel Routing Table\n" |
13780 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13781 | "Metric for redistributed routes\n" |
13782 | "Default metric\n") | |
13783 | { | |
d62a17ae | 13784 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13785 | int idx_ospf_table = 1; | |
13786 | int idx_number = 2; | |
13787 | int idx_number_2 = 4; | |
d7c0a89a | 13788 | uint32_t metric; |
d62a17ae | 13789 | struct bgp_redist *red; |
d7c0a89a | 13790 | unsigned short instance; |
d62a17ae | 13791 | int protocol; |
e923dd62 | 13792 | bool changed; |
d62a17ae | 13793 | |
13794 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13795 | protocol = ZEBRA_ROUTE_OSPF; | |
13796 | else | |
13797 | protocol = ZEBRA_ROUTE_TABLE; | |
13798 | ||
13799 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13800 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13801 | ||
13802 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13803 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13804 | metric); | |
13805 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13806 | } |
13807 | ||
13808 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13809 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13810 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13811 | "Redistribute information from another routing protocol\n" | |
13812 | "Open Shortest Path First (OSPFv2)\n" | |
13813 | "Non-main Kernel Routing Table\n" | |
13814 | "Instance ID/Table ID\n" | |
13815 | "Metric for redistributed routes\n" | |
13816 | "Default metric\n") | |
596c17ba | 13817 | |
7c8ff89e DS |
13818 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13819 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13820 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13821 | "Redistribute information from another routing protocol\n" |
13822 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13823 | "Non-main Kernel Routing Table\n" |
13824 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13825 | "Route map reference\n" |
13826 | "Pointer to route-map entries\n" | |
13827 | "Metric for redistributed routes\n" | |
13828 | "Default metric\n") | |
13829 | { | |
d62a17ae | 13830 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13831 | int idx_ospf_table = 1; | |
13832 | int idx_number = 2; | |
13833 | int idx_word = 4; | |
13834 | int idx_number_2 = 6; | |
d7c0a89a | 13835 | uint32_t metric; |
d62a17ae | 13836 | struct bgp_redist *red; |
d7c0a89a | 13837 | unsigned short instance; |
d62a17ae | 13838 | int protocol; |
e923dd62 | 13839 | bool changed; |
1de27621 DA |
13840 | struct route_map *route_map = |
13841 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13842 | |
13843 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13844 | protocol = ZEBRA_ROUTE_OSPF; | |
13845 | else | |
13846 | protocol = ZEBRA_ROUTE_TABLE; | |
13847 | ||
13848 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13849 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13850 | ||
13851 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13852 | changed = |
13853 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13854 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13855 | metric); | |
13856 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13857 | } |
13858 | ||
13859 | ALIAS_HIDDEN( | |
13860 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13861 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13862 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13863 | "Redistribute information from another routing protocol\n" | |
13864 | "Open Shortest Path First (OSPFv2)\n" | |
13865 | "Non-main Kernel Routing Table\n" | |
13866 | "Instance ID/Table ID\n" | |
13867 | "Route map reference\n" | |
13868 | "Pointer to route-map entries\n" | |
13869 | "Metric for redistributed routes\n" | |
13870 | "Default metric\n") | |
596c17ba | 13871 | |
7c8ff89e DS |
13872 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13873 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13874 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13875 | "Redistribute information from another routing protocol\n" |
13876 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13877 | "Non-main Kernel Routing Table\n" |
13878 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13879 | "Metric for redistributed routes\n" |
13880 | "Default metric\n" | |
13881 | "Route map reference\n" | |
13882 | "Pointer to route-map entries\n") | |
13883 | { | |
d62a17ae | 13884 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13885 | int idx_ospf_table = 1; | |
13886 | int idx_number = 2; | |
13887 | int idx_number_2 = 4; | |
13888 | int idx_word = 6; | |
d7c0a89a | 13889 | uint32_t metric; |
d62a17ae | 13890 | struct bgp_redist *red; |
d7c0a89a | 13891 | unsigned short instance; |
d62a17ae | 13892 | int protocol; |
e923dd62 | 13893 | bool changed; |
1de27621 DA |
13894 | struct route_map *route_map = |
13895 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13896 | |
13897 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13898 | protocol = ZEBRA_ROUTE_OSPF; | |
13899 | else | |
13900 | protocol = ZEBRA_ROUTE_TABLE; | |
13901 | ||
13902 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13903 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13904 | ||
13905 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13906 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13907 | metric); | |
1de27621 DA |
13908 | changed |= |
13909 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13910 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13911 | } |
13912 | ||
13913 | ALIAS_HIDDEN( | |
13914 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
13915 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
13916 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
13917 | "Redistribute information from another routing protocol\n" | |
13918 | "Open Shortest Path First (OSPFv2)\n" | |
13919 | "Non-main Kernel Routing Table\n" | |
13920 | "Instance ID/Table ID\n" | |
13921 | "Metric for redistributed routes\n" | |
13922 | "Default metric\n" | |
13923 | "Route map reference\n" | |
13924 | "Pointer to route-map entries\n") | |
596c17ba | 13925 | |
7c8ff89e DS |
13926 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
13927 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 13928 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
13929 | NO_STR |
13930 | "Redistribute information from another routing protocol\n" | |
13931 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 13932 | "Non-main Kernel Routing Table\n" |
31500417 DW |
13933 | "Instance ID/Table ID\n" |
13934 | "Metric for redistributed routes\n" | |
13935 | "Default metric\n" | |
13936 | "Route map reference\n" | |
13937 | "Pointer to route-map entries\n") | |
7c8ff89e | 13938 | { |
d62a17ae | 13939 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13940 | int idx_ospf_table = 2; | |
13941 | int idx_number = 3; | |
d7c0a89a | 13942 | unsigned short instance; |
d62a17ae | 13943 | int protocol; |
13944 | ||
13945 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13946 | protocol = ZEBRA_ROUTE_OSPF; | |
13947 | else | |
13948 | protocol = ZEBRA_ROUTE_TABLE; | |
13949 | ||
13950 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13951 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
13952 | } | |
13953 | ||
13954 | ALIAS_HIDDEN( | |
13955 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 13956 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13957 | NO_STR |
13958 | "Redistribute information from another routing protocol\n" | |
13959 | "Open Shortest Path First (OSPFv2)\n" | |
13960 | "Non-main Kernel Routing Table\n" | |
13961 | "Instance ID/Table ID\n" | |
13962 | "Metric for redistributed routes\n" | |
13963 | "Default metric\n" | |
13964 | "Route map reference\n" | |
13965 | "Pointer to route-map entries\n") | |
596c17ba | 13966 | |
718e3744 | 13967 | DEFUN (no_bgp_redistribute_ipv4, |
13968 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 13969 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13970 | NO_STR |
13971 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13972 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
13973 | "Metric for redistributed routes\n" |
13974 | "Default metric\n" | |
13975 | "Route map reference\n" | |
13976 | "Pointer to route-map entries\n") | |
718e3744 | 13977 | { |
d62a17ae | 13978 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13979 | int idx_protocol = 2; | |
13980 | int type; | |
13981 | ||
13982 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13983 | if (type < 0) { | |
13984 | vty_out(vty, "%% Invalid route type\n"); | |
13985 | return CMD_WARNING_CONFIG_FAILED; | |
13986 | } | |
13987 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
13988 | } | |
13989 | ||
13990 | ALIAS_HIDDEN( | |
13991 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
13992 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 13993 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13994 | NO_STR |
13995 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13996 | "Metric for redistributed routes\n" | |
13997 | "Default metric\n" | |
13998 | "Route map reference\n" | |
13999 | "Pointer to route-map entries\n") | |
596c17ba | 14000 | |
718e3744 | 14001 | DEFUN (bgp_redistribute_ipv6, |
14002 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 14003 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 14004 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14005 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 14006 | { |
d62a17ae | 14007 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14008 | int idx_protocol = 1; | |
14009 | int type; | |
718e3744 | 14010 | |
d62a17ae | 14011 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14012 | if (type < 0) { | |
14013 | vty_out(vty, "%% Invalid route type\n"); | |
14014 | return CMD_WARNING_CONFIG_FAILED; | |
14015 | } | |
718e3744 | 14016 | |
d62a17ae | 14017 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14018 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 14019 | } |
14020 | ||
14021 | DEFUN (bgp_redistribute_ipv6_rmap, | |
14022 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 14023 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14024 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14025 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14026 | "Route map reference\n" |
14027 | "Pointer to route-map entries\n") | |
14028 | { | |
d62a17ae | 14029 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14030 | int idx_protocol = 1; | |
14031 | int idx_word = 3; | |
14032 | int type; | |
14033 | struct bgp_redist *red; | |
e923dd62 | 14034 | bool changed; |
1de27621 DA |
14035 | struct route_map *route_map = |
14036 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 14037 | |
d62a17ae | 14038 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14039 | if (type < 0) { | |
14040 | vty_out(vty, "%% Invalid route type\n"); | |
14041 | return CMD_WARNING_CONFIG_FAILED; | |
14042 | } | |
718e3744 | 14043 | |
d62a17ae | 14044 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14045 | changed = |
14046 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14047 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14048 | } |
14049 | ||
14050 | DEFUN (bgp_redistribute_ipv6_metric, | |
14051 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 14052 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14053 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14054 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14055 | "Metric for redistributed routes\n" |
14056 | "Default metric\n") | |
14057 | { | |
d62a17ae | 14058 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14059 | int idx_protocol = 1; | |
14060 | int idx_number = 3; | |
14061 | int type; | |
d7c0a89a | 14062 | uint32_t metric; |
d62a17ae | 14063 | struct bgp_redist *red; |
e923dd62 | 14064 | bool changed; |
d62a17ae | 14065 | |
14066 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14067 | if (type < 0) { | |
14068 | vty_out(vty, "%% Invalid route type\n"); | |
14069 | return CMD_WARNING_CONFIG_FAILED; | |
14070 | } | |
14071 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14072 | |
d62a17ae | 14073 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14074 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
14075 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14076 | } |
14077 | ||
14078 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
14079 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 14080 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14081 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14082 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14083 | "Route map reference\n" |
14084 | "Pointer to route-map entries\n" | |
14085 | "Metric for redistributed routes\n" | |
14086 | "Default metric\n") | |
14087 | { | |
d62a17ae | 14088 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14089 | int idx_protocol = 1; | |
14090 | int idx_word = 3; | |
14091 | int idx_number = 5; | |
14092 | int type; | |
d7c0a89a | 14093 | uint32_t metric; |
d62a17ae | 14094 | struct bgp_redist *red; |
e923dd62 | 14095 | bool changed; |
1de27621 DA |
14096 | struct route_map *route_map = |
14097 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14098 | |
14099 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14100 | if (type < 0) { | |
14101 | vty_out(vty, "%% Invalid route type\n"); | |
14102 | return CMD_WARNING_CONFIG_FAILED; | |
14103 | } | |
14104 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14105 | |
d62a17ae | 14106 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14107 | changed = |
14108 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14109 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14110 | metric); | |
14111 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14112 | } |
14113 | ||
14114 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14115 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14116 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14117 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14118 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14119 | "Metric for redistributed routes\n" |
14120 | "Default metric\n" | |
14121 | "Route map reference\n" | |
14122 | "Pointer to route-map entries\n") | |
14123 | { | |
d62a17ae | 14124 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14125 | int idx_protocol = 1; | |
14126 | int idx_number = 3; | |
14127 | int idx_word = 5; | |
14128 | int type; | |
d7c0a89a | 14129 | uint32_t metric; |
d62a17ae | 14130 | struct bgp_redist *red; |
e923dd62 | 14131 | bool changed; |
1de27621 DA |
14132 | struct route_map *route_map = |
14133 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14134 | |
14135 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14136 | if (type < 0) { | |
14137 | vty_out(vty, "%% Invalid route type\n"); | |
14138 | return CMD_WARNING_CONFIG_FAILED; | |
14139 | } | |
14140 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14141 | |
d62a17ae | 14142 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14143 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
14144 | metric); | |
1de27621 DA |
14145 | changed |= |
14146 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14147 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14148 | } |
14149 | ||
14150 | DEFUN (no_bgp_redistribute_ipv6, | |
14151 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14152 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14153 | NO_STR |
14154 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14155 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14156 | "Metric for redistributed routes\n" |
14157 | "Default metric\n" | |
14158 | "Route map reference\n" | |
14159 | "Pointer to route-map entries\n") | |
718e3744 | 14160 | { |
d62a17ae | 14161 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14162 | int idx_protocol = 2; | |
14163 | int type; | |
718e3744 | 14164 | |
d62a17ae | 14165 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14166 | if (type < 0) { | |
14167 | vty_out(vty, "%% Invalid route type\n"); | |
14168 | return CMD_WARNING_CONFIG_FAILED; | |
14169 | } | |
718e3744 | 14170 | |
d62a17ae | 14171 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14172 | } | |
14173 | ||
dd65f45e DL |
14174 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14175 | afi_t afi, safi_t safi) | |
d62a17ae | 14176 | { |
14177 | int i; | |
14178 | ||
14179 | /* Unicast redistribution only. */ | |
14180 | if (safi != SAFI_UNICAST) | |
2b791107 | 14181 | return; |
d62a17ae | 14182 | |
14183 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14184 | /* Redistribute BGP does not make sense. */ | |
14185 | if (i != ZEBRA_ROUTE_BGP) { | |
14186 | struct list *red_list; | |
14187 | struct listnode *node; | |
14188 | struct bgp_redist *red; | |
14189 | ||
14190 | red_list = bgp->redist[afi][i]; | |
14191 | if (!red_list) | |
14192 | continue; | |
14193 | ||
14194 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14195 | /* "redistribute" configuration. */ |
14196 | vty_out(vty, " redistribute %s", | |
14197 | zebra_route_string(i)); | |
14198 | if (red->instance) | |
14199 | vty_out(vty, " %d", red->instance); | |
14200 | if (red->redist_metric_flag) | |
14201 | vty_out(vty, " metric %u", | |
14202 | red->redist_metric); | |
14203 | if (red->rmap.name) | |
14204 | vty_out(vty, " route-map %s", | |
14205 | red->rmap.name); | |
14206 | vty_out(vty, "\n"); | |
14207 | } | |
14208 | } | |
14209 | } | |
718e3744 | 14210 | } |
6b0655a2 | 14211 | |
dd65f45e DL |
14212 | /* peer-group helpers for config-write */ |
14213 | ||
14214 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14215 | { | |
14216 | if (!peer_group_active(peer)) { | |
14217 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14218 | return !CHECK_FLAG(peer->flags, flag); | |
14219 | else | |
14220 | return !!CHECK_FLAG(peer->flags, flag); | |
14221 | } | |
14222 | ||
14223 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14224 | } | |
14225 | ||
14226 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14227 | uint32_t flag) | |
14228 | { | |
14229 | if (!peer_group_active(peer)) { | |
14230 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14231 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14232 | else | |
14233 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14234 | } | |
14235 | ||
14236 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14237 | } | |
14238 | ||
14239 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14240 | uint8_t type, int direct) | |
14241 | { | |
14242 | struct bgp_filter *filter; | |
14243 | ||
14244 | if (peer_group_active(peer)) | |
14245 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14246 | type); | |
14247 | ||
14248 | filter = &peer->filter[afi][safi]; | |
14249 | switch (type) { | |
14250 | case PEER_FT_DISTRIBUTE_LIST: | |
14251 | return !!(filter->dlist[direct].name); | |
14252 | case PEER_FT_FILTER_LIST: | |
14253 | return !!(filter->aslist[direct].name); | |
14254 | case PEER_FT_PREFIX_LIST: | |
14255 | return !!(filter->plist[direct].name); | |
14256 | case PEER_FT_ROUTE_MAP: | |
14257 | return !!(filter->map[direct].name); | |
14258 | case PEER_FT_UNSUPPRESS_MAP: | |
14259 | return !!(filter->usmap.name); | |
14260 | default: | |
14261 | return false; | |
14262 | } | |
14263 | } | |
14264 | ||
14265 | /* Return true if the addpath type is set for peer and different from | |
14266 | * peer-group. | |
14267 | */ | |
3dc339cd DA |
14268 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
14269 | safi_t safi) | |
dd65f45e DL |
14270 | { |
14271 | enum bgp_addpath_strat type, g_type; | |
14272 | ||
14273 | type = peer->addpath_type[afi][safi]; | |
14274 | ||
14275 | if (type != BGP_ADDPATH_NONE) { | |
14276 | if (peer_group_active(peer)) { | |
14277 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14278 | ||
14279 | if (type != g_type) | |
3dc339cd | 14280 | return true; |
dd65f45e | 14281 | else |
3dc339cd | 14282 | return false; |
dd65f45e DL |
14283 | } |
14284 | ||
3dc339cd | 14285 | return true; |
dd65f45e DL |
14286 | } |
14287 | ||
3dc339cd | 14288 | return false; |
dd65f45e DL |
14289 | } |
14290 | ||
b9c7bc5a | 14291 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14292 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14293 | afi_t afi) |
14294 | { | |
b9c7bc5a | 14295 | int indent = 2; |
ddb5b488 | 14296 | |
8a066a70 | 14297 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
14298 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14299 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
14300 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
14301 | bgp->vpn_policy[afi] | |
bb4f6190 | 14302 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14303 | else |
14304 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14305 | bgp->vpn_policy[afi] | |
14306 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14307 | } | |
12a844a5 DS |
14308 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14309 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14310 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14311 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14312 | return; | |
14313 | ||
e70e9f8e PZ |
14314 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14315 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14316 | ||
14317 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14318 | ||
14319 | } else { | |
14320 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14321 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14322 | bgp->vpn_policy[afi].tovpn_label); | |
14323 | } | |
ddb5b488 PZ |
14324 | } |
14325 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14326 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14327 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14328 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14329 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14330 | sizeof(buf))); | |
14331 | } | |
14332 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14333 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14334 | ||
14335 | char buf[PREFIX_STRLEN]; | |
14336 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14337 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14338 | sizeof(buf))) { | |
14339 | ||
b9c7bc5a PZ |
14340 | vty_out(vty, "%*snexthop vpn export %s\n", |
14341 | indent, "", buf); | |
ddb5b488 PZ |
14342 | } |
14343 | } | |
14344 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14345 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14346 | && ecommunity_cmp( | |
14347 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14348 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14349 | ||
14350 | char *b = ecommunity_ecom2str( | |
14351 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14352 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14353 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14354 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14355 | } else { | |
14356 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14357 | char *b = ecommunity_ecom2str( | |
14358 | bgp->vpn_policy[afi] | |
14359 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14360 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14361 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14362 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14363 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14364 | } | |
14365 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14366 | char *b = ecommunity_ecom2str( | |
14367 | bgp->vpn_policy[afi] | |
14368 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14369 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14370 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14371 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14372 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14373 | } | |
14374 | } | |
bb4f6190 DS |
14375 | |
14376 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14377 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14378 | bgp->vpn_policy[afi] |
14379 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14380 | |
301ad80a PG |
14381 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14382 | char *b = ecommunity_ecom2str( | |
14383 | bgp->vpn_policy[afi] | |
14384 | .import_redirect_rtlist, | |
14385 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14386 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14387 | |
301ad80a PG |
14388 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14389 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14390 | } | |
ddb5b488 PZ |
14391 | } |
14392 | ||
dd65f45e DL |
14393 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14394 | afi_t afi, safi_t safi) | |
14395 | { | |
14396 | struct bgp_filter *filter; | |
14397 | char *addr; | |
14398 | ||
14399 | addr = peer->host; | |
14400 | filter = &peer->filter[afi][safi]; | |
14401 | ||
14402 | /* distribute-list. */ | |
14403 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14404 | FILTER_IN)) | |
14405 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14406 | filter->dlist[FILTER_IN].name); | |
14407 | ||
14408 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14409 | FILTER_OUT)) | |
14410 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14411 | filter->dlist[FILTER_OUT].name); | |
14412 | ||
14413 | /* prefix-list. */ | |
14414 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14415 | FILTER_IN)) | |
14416 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14417 | filter->plist[FILTER_IN].name); | |
14418 | ||
14419 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14420 | FILTER_OUT)) | |
14421 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14422 | filter->plist[FILTER_OUT].name); | |
14423 | ||
14424 | /* route-map. */ | |
14425 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14426 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14427 | filter->map[RMAP_IN].name); | |
14428 | ||
14429 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14430 | RMAP_OUT)) | |
14431 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14432 | filter->map[RMAP_OUT].name); | |
14433 | ||
14434 | /* unsuppress-map */ | |
14435 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14436 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14437 | filter->usmap.name); | |
14438 | ||
14439 | /* filter-list. */ | |
14440 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14441 | FILTER_IN)) | |
14442 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14443 | filter->aslist[FILTER_IN].name); | |
14444 | ||
14445 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14446 | FILTER_OUT)) | |
14447 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14448 | filter->aslist[FILTER_OUT].name); | |
14449 | } | |
14450 | ||
14451 | /* BGP peer configuration display function. */ | |
14452 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14453 | struct peer *peer) | |
14454 | { | |
14455 | struct peer *g_peer = NULL; | |
14456 | char buf[SU_ADDRSTRLEN]; | |
14457 | char *addr; | |
14458 | int if_pg_printed = false; | |
14459 | int if_ras_printed = false; | |
14460 | ||
14461 | /* Skip dynamic neighbors. */ | |
14462 | if (peer_dynamic_neighbor(peer)) | |
14463 | return; | |
14464 | ||
14465 | if (peer->conf_if) | |
14466 | addr = peer->conf_if; | |
14467 | else | |
14468 | addr = peer->host; | |
14469 | ||
14470 | /************************************ | |
14471 | ****** Global to the neighbor ****** | |
14472 | ************************************/ | |
14473 | if (peer->conf_if) { | |
14474 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14475 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14476 | else | |
14477 | vty_out(vty, " neighbor %s interface", addr); | |
14478 | ||
14479 | if (peer_group_active(peer)) { | |
14480 | vty_out(vty, " peer-group %s", peer->group->name); | |
14481 | if_pg_printed = true; | |
14482 | } else if (peer->as_type == AS_SPECIFIED) { | |
14483 | vty_out(vty, " remote-as %u", peer->as); | |
14484 | if_ras_printed = true; | |
14485 | } else if (peer->as_type == AS_INTERNAL) { | |
14486 | vty_out(vty, " remote-as internal"); | |
14487 | if_ras_printed = true; | |
14488 | } else if (peer->as_type == AS_EXTERNAL) { | |
14489 | vty_out(vty, " remote-as external"); | |
14490 | if_ras_printed = true; | |
14491 | } | |
14492 | ||
14493 | vty_out(vty, "\n"); | |
14494 | } | |
14495 | ||
14496 | /* remote-as and peer-group */ | |
14497 | /* peer is a member of a peer-group */ | |
14498 | if (peer_group_active(peer)) { | |
14499 | g_peer = peer->group->conf; | |
14500 | ||
14501 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14502 | if (peer->as_type == AS_SPECIFIED) { | |
14503 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14504 | addr, peer->as); | |
14505 | } else if (peer->as_type == AS_INTERNAL) { | |
14506 | vty_out(vty, | |
14507 | " neighbor %s remote-as internal\n", | |
14508 | addr); | |
14509 | } else if (peer->as_type == AS_EXTERNAL) { | |
14510 | vty_out(vty, | |
14511 | " neighbor %s remote-as external\n", | |
14512 | addr); | |
14513 | } | |
14514 | } | |
14515 | ||
14516 | /* For swpX peers we displayed the peer-group | |
14517 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14518 | if (!if_pg_printed) | |
14519 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14520 | peer->group->name); | |
14521 | } | |
14522 | ||
14523 | /* peer is NOT a member of a peer-group */ | |
14524 | else { | |
14525 | /* peer is a peer-group, declare the peer-group */ | |
14526 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14527 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14528 | } | |
14529 | ||
14530 | if (!if_ras_printed) { | |
14531 | if (peer->as_type == AS_SPECIFIED) { | |
14532 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14533 | addr, peer->as); | |
14534 | } else if (peer->as_type == AS_INTERNAL) { | |
14535 | vty_out(vty, | |
14536 | " neighbor %s remote-as internal\n", | |
14537 | addr); | |
14538 | } else if (peer->as_type == AS_EXTERNAL) { | |
14539 | vty_out(vty, | |
14540 | " neighbor %s remote-as external\n", | |
14541 | addr); | |
14542 | } | |
14543 | } | |
14544 | } | |
14545 | ||
14546 | /* local-as */ | |
14547 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14548 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14549 | peer->change_local_as); | |
14550 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14551 | vty_out(vty, " no-prepend"); | |
14552 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14553 | vty_out(vty, " replace-as"); | |
14554 | vty_out(vty, "\n"); | |
14555 | } | |
14556 | ||
14557 | /* description */ | |
14558 | if (peer->desc) { | |
14559 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14560 | } | |
14561 | ||
14562 | /* shutdown */ | |
14563 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14564 | if (peer->tx_shutdown_message) | |
14565 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14566 | peer->tx_shutdown_message); | |
14567 | else | |
14568 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14569 | } | |
14570 | ||
14571 | /* bfd */ | |
14572 | if (peer->bfd_info) { | |
14573 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14574 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14575 | } | |
14576 | } | |
14577 | ||
14578 | /* password */ | |
14579 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14580 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14581 | peer->password); | |
14582 | ||
14583 | /* neighbor solo */ | |
14584 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14585 | if (!peer_group_active(peer)) { | |
14586 | vty_out(vty, " neighbor %s solo\n", addr); | |
14587 | } | |
14588 | } | |
14589 | ||
14590 | /* BGP port */ | |
14591 | if (peer->port != BGP_PORT_DEFAULT) { | |
14592 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14593 | } | |
14594 | ||
14595 | /* Local interface name */ | |
14596 | if (peer->ifname) { | |
14597 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14598 | } | |
14599 | ||
14600 | /* passive */ | |
14601 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14602 | vty_out(vty, " neighbor %s passive\n", addr); | |
14603 | ||
14604 | /* ebgp-multihop */ | |
14605 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
14606 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
14607 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
14608 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
14609 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14610 | peer->ttl); | |
14611 | } | |
14612 | } | |
14613 | ||
14614 | /* ttl-security hops */ | |
e2521429 | 14615 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
14616 | if (!peer_group_active(peer) |
14617 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14618 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14619 | addr, peer->gtsm_hops); | |
14620 | } | |
14621 | } | |
14622 | ||
14623 | /* disable-connected-check */ | |
14624 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14625 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14626 | ||
14627 | /* enforce-first-as */ | |
14628 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14629 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14630 | ||
14631 | /* update-source */ | |
14632 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14633 | if (peer->update_source) | |
14634 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14635 | sockunion2str(peer->update_source, buf, | |
14636 | SU_ADDRSTRLEN)); | |
14637 | else if (peer->update_if) | |
14638 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14639 | peer->update_if); | |
14640 | } | |
14641 | ||
14642 | /* advertisement-interval */ | |
14643 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14644 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14645 | peer->routeadv); | |
14646 | ||
14647 | /* timers */ | |
14648 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14649 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14650 | peer->keepalive, peer->holdtime); | |
14651 | ||
14652 | /* timers connect */ | |
14653 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14654 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14655 | peer->connect); | |
5d5393b9 DL |
14656 | /* need special-case handling for changed default values due to |
14657 | * config profile / version (because there is no "timers bgp connect" | |
14658 | * command, we need to save this per-peer :/) | |
14659 | */ | |
14660 | else if (!peer_group_active(peer) && !peer->connect && | |
14661 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14662 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14663 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14664 | |
14665 | /* capability dynamic */ | |
14666 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14667 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14668 | ||
14669 | /* capability extended-nexthop */ | |
14670 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14671 | if (!peer->conf_if) { | |
14672 | if (CHECK_FLAG(peer->flags_invert, | |
14673 | PEER_FLAG_CAPABILITY_ENHE)) | |
14674 | vty_out(vty, | |
14675 | " no neighbor %s capability extended-nexthop\n", | |
14676 | addr); | |
14677 | else | |
14678 | vty_out(vty, | |
14679 | " neighbor %s capability extended-nexthop\n", | |
14680 | addr); | |
14681 | } | |
14682 | } | |
14683 | ||
14684 | /* dont-capability-negotiation */ | |
14685 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14686 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14687 | ||
14688 | /* override-capability */ | |
14689 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14690 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14691 | ||
14692 | /* strict-capability-match */ | |
14693 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14694 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14695 | ||
14696 | /* Sender side AS path loop detection. */ | |
14697 | if (peer->as_path_loop_detection) | |
14698 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14699 | addr); | |
cfd47646 | 14700 | |
14701 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14702 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14703 | |
14704 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14705 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14706 | vty_out(vty, |
14707 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14708 | } else if (CHECK_FLAG( |
14709 | peer->peer_gr_new_status_flag, | |
14710 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14711 | vty_out(vty, |
14712 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14713 | } else if ( |
14714 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14715 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14716 | && !(CHECK_FLAG( | |
14717 | peer->peer_gr_new_status_flag, | |
14718 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14719 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14720 | addr); | |
cfd47646 | 14721 | } |
14722 | } | |
dd65f45e DL |
14723 | } |
14724 | ||
14725 | /* BGP peer configuration display function. */ | |
14726 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14727 | struct peer *peer, afi_t afi, safi_t safi) | |
14728 | { | |
14729 | struct peer *g_peer = NULL; | |
14730 | char *addr; | |
14731 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14732 | ||
14733 | /* Skip dynamic neighbors. */ | |
14734 | if (peer_dynamic_neighbor(peer)) | |
14735 | return; | |
14736 | ||
14737 | if (peer->conf_if) | |
14738 | addr = peer->conf_if; | |
14739 | else | |
14740 | addr = peer->host; | |
14741 | ||
14742 | /************************************ | |
14743 | ****** Per AF to the neighbor ****** | |
14744 | ************************************/ | |
14745 | if (peer_group_active(peer)) { | |
14746 | g_peer = peer->group->conf; | |
14747 | ||
14748 | /* If the peer-group is active but peer is not, print a 'no | |
14749 | * activate' */ | |
14750 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14751 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14752 | } | |
14753 | ||
14754 | /* If the peer-group is not active but peer is, print an | |
14755 | 'activate' */ | |
14756 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14757 | vty_out(vty, " neighbor %s activate\n", addr); | |
14758 | } | |
14759 | } else { | |
14760 | if (peer->afc[afi][safi]) { | |
14761 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14762 | if (CHECK_FLAG(bgp->flags, |
14763 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14764 | vty_out(vty, " neighbor %s activate\n", |
14765 | addr); | |
14766 | } | |
14767 | } else | |
14768 | vty_out(vty, " neighbor %s activate\n", addr); | |
14769 | } else { | |
14770 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14771 | if (!CHECK_FLAG(bgp->flags, |
14772 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14773 | vty_out(vty, |
14774 | " no neighbor %s activate\n", | |
14775 | addr); | |
14776 | } | |
14777 | } | |
14778 | } | |
14779 | } | |
14780 | ||
14781 | /* addpath TX knobs */ | |
14782 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14783 | switch (peer->addpath_type[afi][safi]) { | |
14784 | case BGP_ADDPATH_ALL: | |
14785 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14786 | addr); | |
14787 | break; | |
14788 | case BGP_ADDPATH_BEST_PER_AS: | |
14789 | vty_out(vty, | |
14790 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14791 | addr); | |
14792 | break; | |
14793 | case BGP_ADDPATH_MAX: | |
14794 | case BGP_ADDPATH_NONE: | |
14795 | break; | |
14796 | } | |
14797 | } | |
14798 | ||
14799 | /* ORF capability. */ | |
14800 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14801 | || peergroup_af_flag_check(peer, afi, safi, | |
14802 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14803 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14804 | ||
14805 | if (peergroup_af_flag_check(peer, afi, safi, | |
14806 | PEER_FLAG_ORF_PREFIX_SM) | |
14807 | && peergroup_af_flag_check(peer, afi, safi, | |
14808 | PEER_FLAG_ORF_PREFIX_RM)) | |
14809 | vty_out(vty, " both"); | |
14810 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14811 | PEER_FLAG_ORF_PREFIX_SM)) | |
14812 | vty_out(vty, " send"); | |
14813 | else | |
14814 | vty_out(vty, " receive"); | |
14815 | vty_out(vty, "\n"); | |
14816 | } | |
14817 | ||
dd65f45e DL |
14818 | /* Route reflector client. */ |
14819 | if (peergroup_af_flag_check(peer, afi, safi, | |
14820 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14821 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14822 | } | |
14823 | ||
14824 | /* next-hop-self force */ | |
14825 | if (peergroup_af_flag_check(peer, afi, safi, | |
14826 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14827 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14828 | } | |
14829 | ||
14830 | /* next-hop-self */ | |
14831 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14832 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14833 | } | |
14834 | ||
14835 | /* remove-private-AS */ | |
14836 | if (peergroup_af_flag_check(peer, afi, safi, | |
14837 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14838 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14839 | addr); | |
14840 | } | |
14841 | ||
14842 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14843 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14844 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14845 | addr); | |
14846 | } | |
14847 | ||
14848 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14849 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14850 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14851 | } | |
14852 | ||
14853 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14854 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14855 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14856 | } | |
14857 | ||
14858 | /* as-override */ | |
14859 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14860 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14861 | } | |
14862 | ||
14863 | /* send-community print. */ | |
14864 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14865 | PEER_FLAG_SEND_COMMUNITY); | |
14866 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14867 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14868 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14869 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14870 | ||
14871 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14872 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14873 | } else { | |
14874 | if (flag_scomm) | |
14875 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14876 | if (flag_secomm) | |
14877 | vty_out(vty, | |
14878 | " no neighbor %s send-community extended\n", | |
14879 | addr); | |
14880 | ||
14881 | if (flag_slcomm) | |
14882 | vty_out(vty, " no neighbor %s send-community large\n", | |
14883 | addr); | |
14884 | } | |
14885 | ||
14886 | /* Default information */ | |
14887 | if (peergroup_af_flag_check(peer, afi, safi, | |
14888 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14889 | vty_out(vty, " neighbor %s default-originate", addr); | |
14890 | ||
14891 | if (peer->default_rmap[afi][safi].name) | |
14892 | vty_out(vty, " route-map %s", | |
14893 | peer->default_rmap[afi][safi].name); | |
14894 | ||
14895 | vty_out(vty, "\n"); | |
14896 | } | |
14897 | ||
14898 | /* Soft reconfiguration inbound. */ | |
14899 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
14900 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
14901 | addr); | |
14902 | } | |
14903 | ||
14904 | /* maximum-prefix. */ | |
14905 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
14906 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
14907 | peer->pmax[afi][safi]); | |
14908 | ||
14909 | if (peer->pmax_threshold[afi][safi] | |
14910 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
14911 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
14912 | if (peer_af_flag_check(peer, afi, safi, | |
14913 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
14914 | vty_out(vty, " warning-only"); | |
14915 | if (peer->pmax_restart[afi][safi]) | |
14916 | vty_out(vty, " restart %u", | |
14917 | peer->pmax_restart[afi][safi]); | |
14918 | ||
14919 | vty_out(vty, "\n"); | |
14920 | } | |
14921 | ||
fde246e8 DA |
14922 | /* maximum-prefix-out */ |
14923 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
14924 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
14925 | addr, peer->pmax_out[afi][safi]); | |
14926 | ||
dd65f45e DL |
14927 | /* Route server client. */ |
14928 | if (peergroup_af_flag_check(peer, afi, safi, | |
14929 | PEER_FLAG_RSERVER_CLIENT)) { | |
14930 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
14931 | } | |
14932 | ||
14933 | /* Nexthop-local unchanged. */ | |
14934 | if (peergroup_af_flag_check(peer, afi, safi, | |
14935 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
14936 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
14937 | } | |
14938 | ||
14939 | /* allowas-in <1-10> */ | |
14940 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
14941 | if (peer_af_flag_check(peer, afi, safi, | |
14942 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
14943 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
14944 | } else if (peer->allowas_in[afi][safi] == 3) { | |
14945 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
14946 | } else { | |
14947 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
14948 | peer->allowas_in[afi][safi]); | |
14949 | } | |
14950 | } | |
14951 | ||
14952 | /* weight */ | |
14953 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
14954 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
14955 | peer->weight[afi][safi]); | |
14956 | ||
14957 | /* Filter. */ | |
14958 | bgp_config_write_filter(vty, peer, afi, safi); | |
14959 | ||
14960 | /* atribute-unchanged. */ | |
14961 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
14962 | || (safi != SAFI_EVPN | |
14963 | && peer_af_flag_check(peer, afi, safi, | |
14964 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
14965 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
14966 | ||
14967 | if (!peer_group_active(peer) | |
14968 | || peergroup_af_flag_check(peer, afi, safi, | |
14969 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14970 | || peergroup_af_flag_check(peer, afi, safi, | |
14971 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14972 | || peergroup_af_flag_check(peer, afi, safi, | |
14973 | PEER_FLAG_MED_UNCHANGED)) { | |
14974 | ||
14975 | vty_out(vty, | |
14976 | " neighbor %s attribute-unchanged%s%s%s\n", | |
14977 | addr, | |
14978 | peer_af_flag_check(peer, afi, safi, | |
14979 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14980 | ? " as-path" | |
14981 | : "", | |
14982 | peer_af_flag_check(peer, afi, safi, | |
14983 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14984 | ? " next-hop" | |
14985 | : "", | |
14986 | peer_af_flag_check(peer, afi, safi, | |
14987 | PEER_FLAG_MED_UNCHANGED) | |
14988 | ? " med" | |
14989 | : ""); | |
14990 | } | |
14991 | } | |
14992 | } | |
14993 | ||
14994 | /* Address family based peer configuration display. */ | |
14995 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
14996 | safi_t safi) | |
14997 | { | |
14998 | struct peer *peer; | |
14999 | struct peer_group *group; | |
15000 | struct listnode *node, *nnode; | |
15001 | ||
15002 | ||
15003 | vty_frame(vty, " !\n address-family "); | |
15004 | if (afi == AFI_IP) { | |
15005 | if (safi == SAFI_UNICAST) | |
15006 | vty_frame(vty, "ipv4 unicast"); | |
15007 | else if (safi == SAFI_LABELED_UNICAST) | |
15008 | vty_frame(vty, "ipv4 labeled-unicast"); | |
15009 | else if (safi == SAFI_MULTICAST) | |
15010 | vty_frame(vty, "ipv4 multicast"); | |
15011 | else if (safi == SAFI_MPLS_VPN) | |
15012 | vty_frame(vty, "ipv4 vpn"); | |
15013 | else if (safi == SAFI_ENCAP) | |
15014 | vty_frame(vty, "ipv4 encap"); | |
15015 | else if (safi == SAFI_FLOWSPEC) | |
15016 | vty_frame(vty, "ipv4 flowspec"); | |
15017 | } else if (afi == AFI_IP6) { | |
15018 | if (safi == SAFI_UNICAST) | |
15019 | vty_frame(vty, "ipv6 unicast"); | |
15020 | else if (safi == SAFI_LABELED_UNICAST) | |
15021 | vty_frame(vty, "ipv6 labeled-unicast"); | |
15022 | else if (safi == SAFI_MULTICAST) | |
15023 | vty_frame(vty, "ipv6 multicast"); | |
15024 | else if (safi == SAFI_MPLS_VPN) | |
15025 | vty_frame(vty, "ipv6 vpn"); | |
15026 | else if (safi == SAFI_ENCAP) | |
15027 | vty_frame(vty, "ipv6 encap"); | |
15028 | else if (safi == SAFI_FLOWSPEC) | |
15029 | vty_frame(vty, "ipv6 flowspec"); | |
15030 | } else if (afi == AFI_L2VPN) { | |
15031 | if (safi == SAFI_EVPN) | |
15032 | vty_frame(vty, "l2vpn evpn"); | |
15033 | } | |
15034 | vty_frame(vty, "\n"); | |
15035 | ||
15036 | bgp_config_write_distance(vty, bgp, afi, safi); | |
15037 | ||
15038 | bgp_config_write_network(vty, bgp, afi, safi); | |
15039 | ||
15040 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
15041 | ||
8a4e7fe6 DA |
15042 | /* BGP flag dampening. */ |
15043 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
15044 | bgp_config_write_damp(vty, afi, safi); | |
15045 | ||
dd65f45e DL |
15046 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
15047 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
15048 | ||
15049 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15050 | /* Skip dynamic neighbors. */ | |
15051 | if (peer_dynamic_neighbor(peer)) | |
15052 | continue; | |
15053 | ||
15054 | /* Do not display doppelganger peers */ | |
15055 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15056 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
15057 | } | |
15058 | ||
15059 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
15060 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
15061 | ||
15062 | if (safi == SAFI_EVPN) | |
15063 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
15064 | ||
15065 | if (safi == SAFI_FLOWSPEC) | |
15066 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
15067 | ||
15068 | if (safi == SAFI_UNICAST) { | |
15069 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
15070 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15071 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
15072 | ||
15073 | vty_out(vty, " export vpn\n"); | |
15074 | } | |
15075 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15076 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
15077 | ||
15078 | vty_out(vty, " import vpn\n"); | |
15079 | } | |
15080 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15081 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15082 | char *name; | |
15083 | ||
15084 | for (ALL_LIST_ELEMENTS_RO( | |
15085 | bgp->vpn_policy[afi].import_vrf, node, | |
15086 | name)) | |
15087 | vty_out(vty, " import vrf %s\n", name); | |
15088 | } | |
15089 | } | |
15090 | ||
15091 | vty_endframe(vty, " exit-address-family\n"); | |
15092 | } | |
15093 | ||
15094 | int bgp_config_write(struct vty *vty) | |
15095 | { | |
15096 | struct bgp *bgp; | |
15097 | struct peer_group *group; | |
15098 | struct peer *peer; | |
15099 | struct listnode *node, *nnode; | |
15100 | struct listnode *mnode, *mnnode; | |
15101 | ||
15102 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
15103 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
15104 | bm->rmap_update_timer); | |
15105 | ||
15106 | /* BGP configuration. */ | |
15107 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
15108 | ||
15109 | /* skip all auto created vrf as they dont have user config */ | |
15110 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
15111 | continue; | |
15112 | ||
15113 | /* Router bgp ASN */ | |
15114 | vty_out(vty, "router bgp %u", bgp->as); | |
15115 | ||
15116 | if (bgp->name) | |
15117 | vty_out(vty, " %s %s", | |
15118 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
15119 | ? "view" : "vrf", bgp->name); | |
15120 | vty_out(vty, "\n"); | |
15121 | ||
15122 | /* BGP fast-external-failover. */ | |
15123 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
15124 | vty_out(vty, " no bgp fast-external-failover\n"); | |
15125 | ||
15126 | /* BGP router ID. */ | |
15127 | if (bgp->router_id_static.s_addr != 0) | |
15128 | vty_out(vty, " bgp router-id %s\n", | |
15129 | inet_ntoa(bgp->router_id_static)); | |
15130 | ||
15131 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 15132 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 15133 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 15134 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
15135 | CHECK_FLAG(bgp->flags, |
15136 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
15137 | ? "" |
15138 | : "no "); | |
15139 | ||
15140 | /* BGP configuration. */ | |
892fedb6 | 15141 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
15142 | vty_out(vty, " bgp always-compare-med\n"); |
15143 | ||
15144 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
15145 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
15146 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
15147 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
15148 | CHECK_FLAG(bgp->flags, | |
15149 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
15150 | ? "" | |
15151 | : "no "); | |
dd65f45e DL |
15152 | |
15153 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 15154 | if (bgp->reject_as_sets) |
dd65f45e DL |
15155 | vty_out(vty, " bgp reject-as-sets\n"); |
15156 | ||
15157 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 15158 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
15159 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
15160 | ||
15161 | /* BGP default local-preference. */ | |
15162 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15163 | vty_out(vty, " bgp default local-preference %u\n", | |
15164 | bgp->default_local_pref); | |
15165 | ||
15166 | /* BGP default show-hostname */ | |
892fedb6 | 15167 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 15168 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 15169 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 15170 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
15171 | ? "" |
15172 | : "no "); | |
15173 | ||
15174 | /* BGP default subgroup-pkt-queue-max. */ | |
15175 | if (bgp->default_subgroup_pkt_queue_max | |
15176 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15177 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15178 | bgp->default_subgroup_pkt_queue_max); | |
15179 | ||
15180 | /* BGP client-to-client reflection. */ | |
892fedb6 | 15181 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
15182 | vty_out(vty, " no bgp client-to-client reflection\n"); |
15183 | ||
15184 | /* BGP cluster ID. */ | |
15185 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15186 | vty_out(vty, " bgp cluster-id %s\n", | |
15187 | inet_ntoa(bgp->cluster_id)); | |
15188 | ||
15189 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 15190 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
15191 | vty_out(vty, |
15192 | " bgp disable-ebgp-connected-route-check\n"); | |
15193 | ||
15194 | /* Confederation identifier*/ | |
15195 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15196 | vty_out(vty, " bgp confederation identifier %u\n", | |
15197 | bgp->confed_id); | |
15198 | ||
15199 | /* Confederation peer */ | |
15200 | if (bgp->confed_peers_cnt > 0) { | |
15201 | int i; | |
15202 | ||
15203 | vty_out(vty, " bgp confederation peers"); | |
15204 | ||
15205 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15206 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15207 | ||
15208 | vty_out(vty, "\n"); | |
15209 | } | |
15210 | ||
15211 | /* BGP deterministic-med. */ | |
892fedb6 | 15212 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 15213 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 15214 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
15215 | CHECK_FLAG(bgp->flags, |
15216 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
15217 | ? "" |
15218 | : "no "); | |
15219 | ||
15220 | /* BGP update-delay. */ | |
15221 | bgp_config_write_update_delay(vty, bgp); | |
15222 | ||
15223 | if (bgp->v_maxmed_onstartup | |
15224 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15225 | vty_out(vty, " bgp max-med on-startup %u", | |
15226 | bgp->v_maxmed_onstartup); | |
15227 | if (bgp->maxmed_onstartup_value | |
15228 | != BGP_MAXMED_VALUE_DEFAULT) | |
15229 | vty_out(vty, " %u", | |
15230 | bgp->maxmed_onstartup_value); | |
15231 | vty_out(vty, "\n"); | |
15232 | } | |
15233 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15234 | vty_out(vty, " bgp max-med administrative"); | |
15235 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15236 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15237 | vty_out(vty, "\n"); | |
15238 | } | |
15239 | ||
15240 | /* write quanta */ | |
15241 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15242 | /* read quanta */ | |
15243 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15244 | ||
15245 | /* coalesce time */ | |
15246 | bgp_config_write_coalesce_time(vty, bgp); | |
15247 | ||
15248 | /* BGP graceful-restart. */ | |
15249 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15250 | vty_out(vty, | |
15251 | " bgp graceful-restart stalepath-time %u\n", | |
15252 | bgp->stalepath_time); | |
cfd47646 | 15253 | |
dd65f45e DL |
15254 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15255 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15256 | bgp->restart_time); | |
cfd47646 | 15257 | |
15258 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15259 | vty_out(vty, | |
15260 | " bgp graceful-restart select-defer-time %u\n", | |
15261 | bgp->select_defer_time); | |
15262 | ||
15263 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15264 | vty_out(vty, " bgp graceful-restart\n"); |
15265 | ||
cfd47646 | 15266 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15267 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15268 | ||
dd65f45e | 15269 | /* BGP graceful-shutdown */ |
892fedb6 | 15270 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) |
dd65f45e DL |
15271 | vty_out(vty, " bgp graceful-shutdown\n"); |
15272 | ||
15273 | /* BGP graceful-restart Preserve State F bit. */ | |
892fedb6 | 15274 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
15275 | vty_out(vty, |
15276 | " bgp graceful-restart preserve-fw-state\n"); | |
15277 | ||
dc95985f | 15278 | /* Stale timer for RIB */ |
15279 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15280 | vty_out(vty, | |
15281 | " bgp graceful-restart rib-stale-time %u\n", | |
15282 | bgp->rib_stale_time); | |
15283 | ||
dd65f45e | 15284 | /* BGP bestpath method. */ |
892fedb6 | 15285 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 15286 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 15287 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
15288 | vty_out(vty, " bgp bestpath as-path confed\n"); |
15289 | ||
892fedb6 DA |
15290 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
15291 | if (CHECK_FLAG(bgp->flags, | |
15292 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
15293 | vty_out(vty, |
15294 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15295 | } else { | |
15296 | vty_out(vty, | |
15297 | " bgp bestpath as-path multipath-relax\n"); | |
15298 | } | |
15299 | } | |
15300 | ||
892fedb6 | 15301 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
15302 | vty_out(vty, |
15303 | " bgp route-reflector allow-outbound-policy\n"); | |
15304 | } | |
892fedb6 | 15305 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 15306 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
15307 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
15308 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 15309 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 15310 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 15311 | vty_out(vty, " confed"); |
892fedb6 DA |
15312 | if (CHECK_FLAG(bgp->flags, |
15313 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
15314 | vty_out(vty, " missing-as-worst"); |
15315 | vty_out(vty, "\n"); | |
15316 | } | |
15317 | ||
f7e1c681 | 15318 | /* Link bandwidth handling. */ |
15319 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
15320 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
15321 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
15322 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
15323 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
15324 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
15325 | ||
dd65f45e | 15326 | /* BGP network import check. */ |
892fedb6 | 15327 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 15328 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 15329 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 15330 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
15331 | ? "" |
15332 | : "no "); | |
15333 | ||
15334 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15335 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15336 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15337 | vty_out(vty, " timers bgp %u %u\n", |
15338 | bgp->default_keepalive, bgp->default_holdtime); | |
15339 | ||
15340 | /* peer-group */ | |
15341 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15342 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15343 | } | |
15344 | ||
15345 | /* Normal neighbor configuration. */ | |
15346 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15347 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15348 | bgp_config_write_peer_global(vty, bgp, peer); | |
15349 | } | |
15350 | ||
15351 | /* listen range and limit for dynamic BGP neighbors */ | |
15352 | bgp_config_write_listen(vty, bgp); | |
15353 | ||
15354 | /* | |
15355 | * BGP default autoshutdown neighbors | |
15356 | * | |
15357 | * This must be placed after any peer and peer-group | |
15358 | * configuration, to avoid setting all peers to shutdown after | |
15359 | * a daemon restart, which is undesired behavior. (see #2286) | |
15360 | */ | |
15361 | if (bgp->autoshutdown) | |
15362 | vty_out(vty, " bgp default shutdown\n"); | |
15363 | ||
15364 | /* IPv4 unicast configuration. */ | |
15365 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15366 | ||
15367 | /* IPv4 multicast configuration. */ | |
15368 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15369 | ||
15370 | /* IPv4 labeled-unicast configuration. */ | |
15371 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15372 | ||
15373 | /* IPv4 VPN configuration. */ | |
15374 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15375 | ||
15376 | /* ENCAPv4 configuration. */ | |
15377 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15378 | ||
15379 | /* FLOWSPEC v4 configuration. */ | |
15380 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15381 | ||
15382 | /* IPv6 unicast configuration. */ | |
15383 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15384 | ||
15385 | /* IPv6 multicast configuration. */ | |
15386 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15387 | ||
15388 | /* IPv6 labeled-unicast configuration. */ | |
15389 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15390 | SAFI_LABELED_UNICAST); | |
15391 | ||
15392 | /* IPv6 VPN configuration. */ | |
15393 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15394 | ||
15395 | /* ENCAPv6 configuration. */ | |
15396 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15397 | ||
15398 | /* FLOWSPEC v6 configuration. */ | |
15399 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15400 | ||
15401 | /* EVPN configuration. */ | |
15402 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15403 | ||
15404 | hook_call(bgp_inst_config_write, bgp, vty); | |
15405 | ||
49e5a4a0 | 15406 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
15407 | bgp_rfapi_cfg_write(vty, bgp); |
15408 | #endif | |
15409 | ||
15410 | vty_out(vty, "!\n"); | |
15411 | } | |
15412 | return 0; | |
15413 | } | |
15414 | ||
ddb5b488 | 15415 | |
718e3744 | 15416 | /* BGP node structure. */ |
d62a17ae | 15417 | static struct cmd_node bgp_node = { |
f4b8291f | 15418 | .name = "bgp", |
62b346ee | 15419 | .node = BGP_NODE, |
24389580 | 15420 | .parent_node = CONFIG_NODE, |
62b346ee | 15421 | .prompt = "%s(config-router)# ", |
612c2c15 | 15422 | .config_write = bgp_config_write, |
718e3744 | 15423 | }; |
15424 | ||
d62a17ae | 15425 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 15426 | .name = "bgp ipv4 unicast", |
62b346ee | 15427 | .node = BGP_IPV4_NODE, |
24389580 | 15428 | .parent_node = BGP_NODE, |
62b346ee | 15429 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15430 | }; |
15431 | ||
d62a17ae | 15432 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 15433 | .name = "bgp ipv4 multicast", |
62b346ee | 15434 | .node = BGP_IPV4M_NODE, |
24389580 | 15435 | .parent_node = BGP_NODE, |
62b346ee | 15436 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15437 | }; |
15438 | ||
d62a17ae | 15439 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 15440 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 15441 | .node = BGP_IPV4L_NODE, |
24389580 | 15442 | .parent_node = BGP_NODE, |
62b346ee | 15443 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15444 | }; |
15445 | ||
d62a17ae | 15446 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 15447 | .name = "bgp ipv6", |
62b346ee | 15448 | .node = BGP_IPV6_NODE, |
24389580 | 15449 | .parent_node = BGP_NODE, |
62b346ee | 15450 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15451 | }; |
15452 | ||
d62a17ae | 15453 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 15454 | .name = "bgp ipv6 multicast", |
62b346ee | 15455 | .node = BGP_IPV6M_NODE, |
24389580 | 15456 | .parent_node = BGP_NODE, |
62b346ee | 15457 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 15458 | }; |
15459 | ||
d62a17ae | 15460 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 15461 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 15462 | .node = BGP_IPV6L_NODE, |
24389580 | 15463 | .parent_node = BGP_NODE, |
62b346ee | 15464 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15465 | }; |
15466 | ||
62b346ee | 15467 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 15468 | .name = "bgp vpnv4", |
62b346ee | 15469 | .node = BGP_VPNV4_NODE, |
24389580 | 15470 | .parent_node = BGP_NODE, |
62b346ee | 15471 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15472 | }; |
6b0655a2 | 15473 | |
62b346ee | 15474 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 15475 | .name = "bgp vpnv6", |
62b346ee | 15476 | .node = BGP_VPNV6_NODE, |
24389580 | 15477 | .parent_node = BGP_NODE, |
62b346ee | 15478 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15479 | }; |
8ecd3266 | 15480 | |
62b346ee | 15481 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 15482 | .name = "bgp evpn", |
62b346ee | 15483 | .node = BGP_EVPN_NODE, |
24389580 | 15484 | .parent_node = BGP_NODE, |
62b346ee | 15485 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 15486 | }; |
4e0b7b6d | 15487 | |
62b346ee | 15488 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 15489 | .name = "bgp evpn vni", |
62b346ee | 15490 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 15491 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 15492 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 15493 | }; |
90e60aa7 | 15494 | |
62b346ee | 15495 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 15496 | .name = "bgp ipv4 flowspec", |
62b346ee | 15497 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 15498 | .parent_node = BGP_NODE, |
62b346ee | 15499 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15500 | }; |
7c40bf39 | 15501 | |
62b346ee | 15502 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 15503 | .name = "bgp ipv6 flowspec", |
62b346ee | 15504 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 15505 | .parent_node = BGP_NODE, |
62b346ee | 15506 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15507 | }; |
7c40bf39 | 15508 | |
d62a17ae | 15509 | static void community_list_vty(void); |
1f8ae70b | 15510 | |
d62a17ae | 15511 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15512 | { |
d62a17ae | 15513 | struct bgp *bgp; |
15514 | struct peer *peer; | |
d62a17ae | 15515 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15516 | |
d62a17ae | 15517 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15518 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15519 | /* only provide suggestions on the appropriate input | |
15520 | * token type, | |
15521 | * they'll otherwise show up multiple times */ | |
15522 | enum cmd_token_type match_type; | |
15523 | char *name = peer->host; | |
d48ed3e0 | 15524 | |
d62a17ae | 15525 | if (peer->conf_if) { |
15526 | match_type = VARIABLE_TKN; | |
15527 | name = peer->conf_if; | |
15528 | } else if (strchr(peer->host, ':')) | |
15529 | match_type = IPV6_TKN; | |
15530 | else | |
15531 | match_type = IPV4_TKN; | |
d48ed3e0 | 15532 | |
d62a17ae | 15533 | if (token->type != match_type) |
15534 | continue; | |
d48ed3e0 | 15535 | |
d62a17ae | 15536 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15537 | } | |
d62a17ae | 15538 | } |
b8a815e5 DL |
15539 | } |
15540 | ||
15541 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15542 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15543 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15544 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15545 | {.completions = NULL}}; |
15546 | ||
47a306a0 DS |
15547 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15548 | { | |
15549 | struct bgp *bgp; | |
15550 | struct peer_group *group; | |
15551 | struct listnode *lnbgp, *lnpeer; | |
15552 | ||
15553 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15554 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15555 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15556 | group->name)); | |
15557 | } | |
15558 | } | |
15559 | ||
15560 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15561 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15562 | {.completions = NULL} }; | |
15563 | ||
d62a17ae | 15564 | void bgp_vty_init(void) |
15565 | { | |
15566 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15567 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15568 | |
15569 | /* Install bgp top node. */ | |
612c2c15 DL |
15570 | install_node(&bgp_node); |
15571 | install_node(&bgp_ipv4_unicast_node); | |
15572 | install_node(&bgp_ipv4_multicast_node); | |
15573 | install_node(&bgp_ipv4_labeled_unicast_node); | |
15574 | install_node(&bgp_ipv6_unicast_node); | |
15575 | install_node(&bgp_ipv6_multicast_node); | |
15576 | install_node(&bgp_ipv6_labeled_unicast_node); | |
15577 | install_node(&bgp_vpnv4_node); | |
15578 | install_node(&bgp_vpnv6_node); | |
15579 | install_node(&bgp_evpn_node); | |
15580 | install_node(&bgp_evpn_vni_node); | |
15581 | install_node(&bgp_flowspecv4_node); | |
15582 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 15583 | |
15584 | /* Install default VTY commands to new nodes. */ | |
15585 | install_default(BGP_NODE); | |
15586 | install_default(BGP_IPV4_NODE); | |
15587 | install_default(BGP_IPV4M_NODE); | |
15588 | install_default(BGP_IPV4L_NODE); | |
15589 | install_default(BGP_IPV6_NODE); | |
15590 | install_default(BGP_IPV6M_NODE); | |
15591 | install_default(BGP_IPV6L_NODE); | |
15592 | install_default(BGP_VPNV4_NODE); | |
15593 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15594 | install_default(BGP_FLOWSPECV4_NODE); |
15595 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15596 | install_default(BGP_EVPN_NODE); |
15597 | install_default(BGP_EVPN_VNI_NODE); | |
15598 | ||
8029b216 AK |
15599 | /* "bgp local-mac" hidden commands. */ |
15600 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15601 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15602 | ||
d62a17ae | 15603 | /* bgp route-map delay-timer commands. */ |
15604 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15605 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15606 | ||
15607 | /* Dummy commands (Currently not supported) */ | |
15608 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15609 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15610 | ||
15611 | /* "router bgp" commands. */ | |
15612 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15613 | ||
15614 | /* "no router bgp" commands. */ | |
15615 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15616 | ||
15617 | /* "bgp router-id" commands. */ | |
15618 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15619 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15620 | ||
15621 | /* "bgp cluster-id" commands. */ | |
15622 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15623 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15624 | ||
15625 | /* "bgp confederation" commands. */ | |
15626 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15627 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15628 | ||
15629 | /* "bgp confederation peers" commands. */ | |
15630 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15631 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15632 | ||
15633 | /* bgp max-med command */ | |
15634 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15635 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15636 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15637 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15638 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15639 | ||
15640 | /* bgp disable-ebgp-connected-nh-check */ | |
15641 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15642 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15643 | ||
15644 | /* bgp update-delay command */ | |
15645 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15646 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15647 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15648 | ||
15649 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15650 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15651 | |
15652 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15653 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15654 | ||
15655 | /* "maximum-paths" commands. */ | |
15656 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15657 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15658 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15659 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15660 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15661 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15662 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15663 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15664 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15665 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15666 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15667 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15668 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15669 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15670 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15671 | ||
15672 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
15673 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15674 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15675 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15676 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15677 | ||
15678 | /* "timers bgp" commands. */ | |
15679 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15680 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15681 | ||
15682 | /* route-map delay-timer commands - per instance for backwards compat. | |
15683 | */ | |
15684 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15685 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15686 | ||
15687 | /* "bgp client-to-client reflection" commands */ | |
15688 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15689 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15690 | ||
15691 | /* "bgp always-compare-med" commands */ | |
15692 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15693 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15694 | ||
9dac9fc8 DA |
15695 | /* bgp ebgp-requires-policy */ |
15696 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15697 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15698 | ||
fb29348a DA |
15699 | /* bgp reject-as-sets */ |
15700 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15701 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15702 | ||
d62a17ae | 15703 | /* "bgp deterministic-med" commands */ |
15704 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15705 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15706 | ||
055679e9 | 15707 | /* "bgp graceful-restart" command */ |
36235319 QY |
15708 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15709 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15710 | |
15711 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15712 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15713 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15714 | |
15715 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15716 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15717 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15718 | |
15719 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15720 | install_element(BGP_NODE, | |
15721 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15722 | install_element(BGP_NODE, | |
15723 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15724 | ||
15725 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15726 | install_element(BGP_NODE, | |
15727 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15728 | install_element(BGP_NODE, | |
15729 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15730 | ||
d62a17ae | 15731 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15732 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15733 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15734 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15735 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15736 | install_element(BGP_NODE, |
15737 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15738 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15739 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15740 | ||
d6e3c15b | 15741 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15742 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15743 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15744 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15745 | |
7f323236 DW |
15746 | /* "bgp graceful-shutdown" commands */ |
15747 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15748 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15749 | ||
d62a17ae | 15750 | /* "bgp fast-external-failover" commands */ |
15751 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15752 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15753 | ||
d62a17ae | 15754 | /* "bgp bestpath compare-routerid" commands */ |
15755 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15756 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15757 | ||
15758 | /* "bgp bestpath as-path ignore" commands */ | |
15759 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15760 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15761 | ||
15762 | /* "bgp bestpath as-path confed" commands */ | |
15763 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15764 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15765 | ||
15766 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15767 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15768 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15769 | ||
15770 | /* "bgp log-neighbor-changes" commands */ | |
15771 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15772 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15773 | ||
15774 | /* "bgp bestpath med" commands */ | |
15775 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15776 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15777 | ||
f7e1c681 | 15778 | /* "bgp bestpath bandwidth" commands */ |
15779 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 15780 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 15781 | |
d62a17ae | 15782 | /* "no bgp default ipv4-unicast" commands. */ |
15783 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15784 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15785 | ||
15786 | /* "bgp network import-check" commands. */ | |
15787 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15788 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15789 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15790 | ||
15791 | /* "bgp default local-preference" commands. */ | |
15792 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15793 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15794 | ||
15795 | /* bgp default show-hostname */ | |
15796 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15797 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15798 | ||
15799 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15800 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15801 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15802 | ||
15803 | /* bgp ibgp-allow-policy-mods command */ | |
15804 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15805 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15806 | ||
15807 | /* "bgp listen limit" commands. */ | |
15808 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15809 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15810 | ||
15811 | /* "bgp listen range" commands. */ | |
15812 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15813 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15814 | ||
8175f54a | 15815 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15816 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15817 | ||
d62a17ae | 15818 | /* "neighbor remote-as" commands. */ |
15819 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15820 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15821 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15822 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15823 | install_element(BGP_NODE, | |
15824 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15825 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15826 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15827 | ||
15828 | /* "neighbor peer-group" commands. */ | |
15829 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15830 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15831 | install_element(BGP_NODE, | |
15832 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15833 | ||
15834 | /* "neighbor local-as" commands. */ | |
15835 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15836 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15837 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15838 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15839 | ||
15840 | /* "neighbor solo" commands. */ | |
15841 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15842 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15843 | ||
15844 | /* "neighbor password" commands. */ | |
15845 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15846 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15847 | ||
15848 | /* "neighbor activate" commands. */ | |
15849 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15850 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15851 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15852 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15853 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15854 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15855 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15856 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15857 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15858 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15859 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15860 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15861 | ||
15862 | /* "no neighbor activate" commands. */ | |
15863 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15864 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15865 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15866 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15867 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15868 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15869 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15870 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15871 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15872 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15873 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15874 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15875 | ||
15876 | /* "neighbor peer-group" set commands. */ | |
15877 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15878 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15879 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15880 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15881 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15882 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15883 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15884 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15885 | install_element(BGP_FLOWSPECV4_NODE, |
15886 | &neighbor_set_peer_group_hidden_cmd); | |
15887 | install_element(BGP_FLOWSPECV6_NODE, | |
15888 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15889 | |
15890 | /* "no neighbor peer-group unset" commands. */ | |
15891 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
15892 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15893 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15894 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15895 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15896 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15897 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15898 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15899 | install_element(BGP_FLOWSPECV4_NODE, |
15900 | &no_neighbor_set_peer_group_hidden_cmd); | |
15901 | install_element(BGP_FLOWSPECV6_NODE, | |
15902 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15903 | |
15904 | /* "neighbor softreconfiguration inbound" commands.*/ | |
15905 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
15906 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
15907 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15908 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15909 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15910 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15911 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15912 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15913 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15914 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15915 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15916 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15917 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15918 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15919 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15920 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15921 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15922 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 15923 | install_element(BGP_FLOWSPECV4_NODE, |
15924 | &neighbor_soft_reconfiguration_cmd); | |
15925 | install_element(BGP_FLOWSPECV4_NODE, | |
15926 | &no_neighbor_soft_reconfiguration_cmd); | |
15927 | install_element(BGP_FLOWSPECV6_NODE, | |
15928 | &neighbor_soft_reconfiguration_cmd); | |
15929 | install_element(BGP_FLOWSPECV6_NODE, | |
15930 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
15931 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
15932 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 15933 | |
15934 | /* "neighbor attribute-unchanged" commands. */ | |
15935 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
15936 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
15937 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
15938 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15939 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
15940 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15941 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
15942 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15943 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
15944 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15945 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
15946 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15947 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
15948 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15949 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
15950 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15951 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
15952 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15953 | ||
15954 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
15955 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
15956 | ||
15957 | /* "nexthop-local unchanged" commands */ | |
15958 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
15959 | install_element(BGP_IPV6_NODE, | |
15960 | &no_neighbor_nexthop_local_unchanged_cmd); | |
15961 | ||
15962 | /* "neighbor next-hop-self" commands. */ | |
15963 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
15964 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
15965 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
15966 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15967 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
15968 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
15969 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
15970 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
15971 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
15972 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
15973 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
15974 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
15975 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
15976 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
15977 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
15978 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15979 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
15980 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
15981 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
15982 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 15983 | |
15984 | /* "neighbor next-hop-self force" commands. */ | |
15985 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
15986 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
15987 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15988 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15989 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
15990 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15991 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15992 | install_element(BGP_IPV4_NODE, | |
15993 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15994 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
15995 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15996 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15997 | install_element(BGP_IPV4M_NODE, | |
15998 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15999 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
16000 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16001 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16002 | install_element(BGP_IPV4L_NODE, | |
16003 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16004 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
16005 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16006 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16007 | install_element(BGP_IPV6_NODE, | |
16008 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16009 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
16010 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16011 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16012 | install_element(BGP_IPV6M_NODE, | |
16013 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16014 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
16015 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16016 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16017 | install_element(BGP_IPV6L_NODE, | |
16018 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16019 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
16020 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16021 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16022 | install_element(BGP_VPNV4_NODE, | |
16023 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16024 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
16025 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16026 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16027 | install_element(BGP_VPNV6_NODE, | |
16028 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
16029 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
16030 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 16031 | |
16032 | /* "neighbor as-override" commands. */ | |
16033 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
16034 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
16035 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
16036 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
16037 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
16038 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
16039 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
16040 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
16041 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
16042 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
16043 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
16044 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
16045 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
16046 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
16047 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
16048 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
16049 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
16050 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
16051 | ||
16052 | /* "neighbor remove-private-AS" commands. */ | |
16053 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
16054 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
16055 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
16056 | install_element(BGP_NODE, | |
16057 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
16058 | install_element(BGP_NODE, | |
16059 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
16060 | install_element(BGP_NODE, | |
16061 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
16062 | install_element(BGP_NODE, | |
16063 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16064 | install_element( | |
16065 | BGP_NODE, | |
16066 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16067 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
16068 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16069 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16070 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16071 | install_element(BGP_IPV4_NODE, | |
16072 | &neighbor_remove_private_as_replace_as_cmd); | |
16073 | install_element(BGP_IPV4_NODE, | |
16074 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16075 | install_element(BGP_IPV4_NODE, | |
16076 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16077 | install_element(BGP_IPV4_NODE, | |
16078 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16079 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
16080 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
16081 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
16082 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16083 | install_element(BGP_IPV4M_NODE, | |
16084 | &neighbor_remove_private_as_replace_as_cmd); | |
16085 | install_element(BGP_IPV4M_NODE, | |
16086 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16087 | install_element(BGP_IPV4M_NODE, | |
16088 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16089 | install_element(BGP_IPV4M_NODE, | |
16090 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16091 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
16092 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
16093 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
16094 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16095 | install_element(BGP_IPV4L_NODE, | |
16096 | &neighbor_remove_private_as_replace_as_cmd); | |
16097 | install_element(BGP_IPV4L_NODE, | |
16098 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16099 | install_element(BGP_IPV4L_NODE, | |
16100 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16101 | install_element(BGP_IPV4L_NODE, | |
16102 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16103 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
16104 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16105 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16106 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16107 | install_element(BGP_IPV6_NODE, | |
16108 | &neighbor_remove_private_as_replace_as_cmd); | |
16109 | install_element(BGP_IPV6_NODE, | |
16110 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16111 | install_element(BGP_IPV6_NODE, | |
16112 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16113 | install_element(BGP_IPV6_NODE, | |
16114 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16115 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
16116 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
16117 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
16118 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16119 | install_element(BGP_IPV6M_NODE, | |
16120 | &neighbor_remove_private_as_replace_as_cmd); | |
16121 | install_element(BGP_IPV6M_NODE, | |
16122 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16123 | install_element(BGP_IPV6M_NODE, | |
16124 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16125 | install_element(BGP_IPV6M_NODE, | |
16126 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16127 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
16128 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
16129 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
16130 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16131 | install_element(BGP_IPV6L_NODE, | |
16132 | &neighbor_remove_private_as_replace_as_cmd); | |
16133 | install_element(BGP_IPV6L_NODE, | |
16134 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16135 | install_element(BGP_IPV6L_NODE, | |
16136 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16137 | install_element(BGP_IPV6L_NODE, | |
16138 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16139 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
16140 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16141 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16142 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16143 | install_element(BGP_VPNV4_NODE, | |
16144 | &neighbor_remove_private_as_replace_as_cmd); | |
16145 | install_element(BGP_VPNV4_NODE, | |
16146 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16147 | install_element(BGP_VPNV4_NODE, | |
16148 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16149 | install_element(BGP_VPNV4_NODE, | |
16150 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16151 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
16152 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16153 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16154 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16155 | install_element(BGP_VPNV6_NODE, | |
16156 | &neighbor_remove_private_as_replace_as_cmd); | |
16157 | install_element(BGP_VPNV6_NODE, | |
16158 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16159 | install_element(BGP_VPNV6_NODE, | |
16160 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16161 | install_element(BGP_VPNV6_NODE, | |
16162 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16163 | ||
16164 | /* "neighbor send-community" commands.*/ | |
16165 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
16166 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
16167 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
16168 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
16169 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
16170 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
16171 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
16172 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
16173 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
16174 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
16175 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
16176 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
16177 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
16178 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
16179 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
16180 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
16181 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
16182 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
16183 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
16184 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
16185 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
16186 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
16187 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
16188 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
16189 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
16190 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
16191 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
16192 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
16193 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
16194 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
16195 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
16196 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
16197 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
16198 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
16199 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
16200 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
16201 | ||
16202 | /* "neighbor route-reflector" commands.*/ | |
16203 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
16204 | install_element(BGP_NODE, | |
16205 | &no_neighbor_route_reflector_client_hidden_cmd); | |
16206 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
16207 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
16208 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
16209 | install_element(BGP_IPV4M_NODE, | |
16210 | &no_neighbor_route_reflector_client_cmd); | |
16211 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
16212 | install_element(BGP_IPV4L_NODE, | |
16213 | &no_neighbor_route_reflector_client_cmd); | |
16214 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
16215 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
16216 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
16217 | install_element(BGP_IPV6M_NODE, | |
16218 | &no_neighbor_route_reflector_client_cmd); | |
16219 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
16220 | install_element(BGP_IPV6L_NODE, | |
16221 | &no_neighbor_route_reflector_client_cmd); | |
16222 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16223 | install_element(BGP_VPNV4_NODE, | |
16224 | &no_neighbor_route_reflector_client_cmd); | |
16225 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16226 | install_element(BGP_VPNV6_NODE, | |
16227 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16228 | install_element(BGP_FLOWSPECV4_NODE, |
16229 | &neighbor_route_reflector_client_cmd); | |
16230 | install_element(BGP_FLOWSPECV4_NODE, | |
16231 | &no_neighbor_route_reflector_client_cmd); | |
16232 | install_element(BGP_FLOWSPECV6_NODE, | |
16233 | &neighbor_route_reflector_client_cmd); | |
16234 | install_element(BGP_FLOWSPECV6_NODE, | |
16235 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16236 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16237 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16238 | ||
16239 | /* "neighbor route-server" commands.*/ | |
16240 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16241 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16242 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16243 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16244 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16245 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16246 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16247 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16248 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16249 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16250 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16251 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16252 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16253 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16254 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16255 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16256 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16257 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16258 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16259 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16260 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16261 | install_element(BGP_FLOWSPECV4_NODE, | |
16262 | &no_neighbor_route_server_client_cmd); | |
16263 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16264 | install_element(BGP_FLOWSPECV6_NODE, | |
16265 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16266 | |
16267 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16268 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16269 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16270 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16271 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16272 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16273 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16274 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16275 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16276 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16277 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16278 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16279 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16280 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16281 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16282 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16283 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16284 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16285 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16286 | ||
16287 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16288 | install_element(BGP_NODE, | |
16289 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16290 | install_element(BGP_NODE, | |
16291 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16292 | install_element(BGP_IPV4_NODE, | |
16293 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16294 | install_element(BGP_IPV4_NODE, | |
16295 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16296 | install_element(BGP_IPV4M_NODE, | |
16297 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16298 | install_element(BGP_IPV4M_NODE, | |
16299 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16300 | install_element(BGP_IPV4L_NODE, | |
16301 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16302 | install_element(BGP_IPV4L_NODE, | |
16303 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16304 | install_element(BGP_IPV6_NODE, | |
16305 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16306 | install_element(BGP_IPV6_NODE, | |
16307 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16308 | install_element(BGP_IPV6M_NODE, | |
16309 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16310 | install_element(BGP_IPV6M_NODE, | |
16311 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16312 | install_element(BGP_IPV6L_NODE, | |
16313 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16314 | install_element(BGP_IPV6L_NODE, | |
16315 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16316 | install_element(BGP_VPNV4_NODE, | |
16317 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16318 | install_element(BGP_VPNV4_NODE, | |
16319 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16320 | install_element(BGP_VPNV6_NODE, | |
16321 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16322 | install_element(BGP_VPNV6_NODE, | |
16323 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16324 | ||
2b31007c RZ |
16325 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16326 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16327 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16328 | ||
d62a17ae | 16329 | /* "neighbor passive" commands. */ |
16330 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16331 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16332 | ||
16333 | ||
16334 | /* "neighbor shutdown" commands. */ | |
16335 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16336 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16337 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16338 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16339 | ||
16340 | /* "neighbor capability extended-nexthop" commands.*/ | |
16341 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16342 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16343 | ||
16344 | /* "neighbor capability orf prefix-list" commands.*/ | |
16345 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16346 | install_element(BGP_NODE, | |
16347 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16348 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16349 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16350 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16351 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16352 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16353 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16354 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16355 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16356 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16357 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16358 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16359 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16360 | ||
16361 | /* "neighbor capability dynamic" commands.*/ | |
16362 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16363 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16364 | ||
16365 | /* "neighbor dont-capability-negotiate" commands. */ | |
16366 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16367 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16368 | ||
16369 | /* "neighbor ebgp-multihop" commands. */ | |
16370 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16371 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16372 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16373 | ||
16374 | /* "neighbor disable-connected-check" commands. */ | |
16375 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16376 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16377 | ||
47cbc09b PM |
16378 | /* "neighbor enforce-first-as" commands. */ |
16379 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16380 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16381 | ||
d62a17ae | 16382 | /* "neighbor description" commands. */ |
16383 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16384 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16385 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16386 | |
16387 | /* "neighbor update-source" commands. "*/ | |
16388 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16389 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16390 | ||
16391 | /* "neighbor default-originate" commands. */ | |
16392 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16393 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16394 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16395 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16396 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16397 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16398 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16399 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16400 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16401 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16402 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16403 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16404 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16405 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16406 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16407 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16408 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16409 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16410 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16411 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16412 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16413 | ||
16414 | /* "neighbor port" commands. */ | |
16415 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16416 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16417 | ||
16418 | /* "neighbor weight" commands. */ | |
16419 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16420 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16421 | ||
16422 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16423 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16424 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16425 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16426 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16427 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16428 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16429 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16430 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16431 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16432 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16433 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16434 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16435 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16436 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16437 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16438 | ||
16439 | /* "neighbor override-capability" commands. */ | |
16440 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16441 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16442 | ||
16443 | /* "neighbor strict-capability-match" commands. */ | |
16444 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16445 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16446 | ||
16447 | /* "neighbor timers" commands. */ | |
16448 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16449 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16450 | ||
16451 | /* "neighbor timers connect" commands. */ | |
16452 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16453 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16454 | ||
16455 | /* "neighbor advertisement-interval" commands. */ | |
16456 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16457 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16458 | ||
16459 | /* "neighbor interface" commands. */ | |
16460 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16461 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16462 | ||
16463 | /* "neighbor distribute" commands. */ | |
16464 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16465 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16466 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16467 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16468 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16469 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16470 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16471 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16472 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16473 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16474 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16475 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16476 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16477 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16478 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16479 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16480 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16481 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16482 | ||
16483 | /* "neighbor prefix-list" commands. */ | |
16484 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16485 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16486 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16487 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16488 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16489 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16490 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16491 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16492 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16493 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16494 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16495 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16496 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16497 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16498 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16499 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16500 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16501 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16502 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16503 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16504 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16505 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16506 | |
16507 | /* "neighbor filter-list" commands. */ | |
16508 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16509 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16510 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16511 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16512 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16513 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16514 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16515 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16516 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16517 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16518 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16519 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16520 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16521 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16522 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16523 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16524 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16525 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16526 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16527 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16528 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16529 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16530 | |
16531 | /* "neighbor route-map" commands. */ | |
16532 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16533 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16534 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16535 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16536 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16537 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16538 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16539 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16540 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16541 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16542 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16543 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16544 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16545 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16546 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16547 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16548 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16549 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16550 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16551 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16552 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16553 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16554 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16555 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16556 | |
16557 | /* "neighbor unsuppress-map" commands. */ | |
16558 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16559 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16560 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16561 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16562 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16563 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16564 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16565 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16566 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16567 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16568 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16569 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16570 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16571 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16572 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16573 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16574 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16575 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16576 | ||
fde246e8 DA |
16577 | /* neighbor maximum-prefix-out commands. */ |
16578 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16579 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16580 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16581 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16582 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16583 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16584 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16585 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16586 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16587 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16588 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16589 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16590 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16591 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16592 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16593 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16594 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16595 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16596 | ||
d62a17ae | 16597 | /* "neighbor maximum-prefix" commands. */ |
16598 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16599 | install_element(BGP_NODE, | |
16600 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16601 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16602 | install_element(BGP_NODE, | |
16603 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16604 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16605 | install_element(BGP_NODE, | |
16606 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16607 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16608 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16609 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16610 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16611 | install_element(BGP_IPV4_NODE, | |
16612 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16613 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16614 | install_element(BGP_IPV4_NODE, | |
16615 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16616 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16617 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16618 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16619 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16620 | install_element(BGP_IPV4M_NODE, | |
16621 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16622 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16623 | install_element(BGP_IPV4M_NODE, | |
16624 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16625 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16626 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16627 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16628 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16629 | install_element(BGP_IPV4L_NODE, | |
16630 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16631 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16632 | install_element(BGP_IPV4L_NODE, | |
16633 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16634 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16635 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16636 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16637 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16638 | install_element(BGP_IPV6_NODE, | |
16639 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16640 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16641 | install_element(BGP_IPV6_NODE, | |
16642 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16643 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16644 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16645 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16646 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16647 | install_element(BGP_IPV6M_NODE, | |
16648 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16649 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16650 | install_element(BGP_IPV6M_NODE, | |
16651 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16652 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16653 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16654 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16655 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16656 | install_element(BGP_IPV6L_NODE, | |
16657 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16658 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16659 | install_element(BGP_IPV6L_NODE, | |
16660 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16661 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16662 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16663 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16664 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16665 | install_element(BGP_VPNV4_NODE, | |
16666 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16667 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16668 | install_element(BGP_VPNV4_NODE, | |
16669 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16670 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16671 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16672 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16673 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16674 | install_element(BGP_VPNV6_NODE, | |
16675 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16676 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16677 | install_element(BGP_VPNV6_NODE, | |
16678 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16679 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16680 | ||
16681 | /* "neighbor allowas-in" */ | |
16682 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16683 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16684 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16685 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16686 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16687 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16688 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16689 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16690 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16691 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16692 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16693 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16694 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16695 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16696 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16697 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16698 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16699 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16700 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16701 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16702 | ||
16703 | /* address-family commands. */ | |
16704 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16705 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16706 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16707 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16708 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16709 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16710 | |
d62a17ae | 16711 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16712 | ||
16713 | /* "exit-address-family" command. */ | |
16714 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16715 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16716 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16717 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16718 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16719 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16720 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16721 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16722 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16723 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16724 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16725 | ||
16726 | /* "clear ip bgp commands" */ | |
16727 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16728 | ||
16729 | /* clear ip bgp prefix */ | |
16730 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16731 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16732 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16733 | ||
16734 | /* "show [ip] bgp summary" commands. */ | |
16735 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16736 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16737 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16738 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16739 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16740 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16741 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16742 | ||
16743 | /* "show [ip] bgp neighbors" commands. */ | |
16744 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16745 | ||
36235319 | 16746 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 16747 | |
d62a17ae | 16748 | /* "show [ip] bgp peer-group" commands. */ |
16749 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16750 | ||
16751 | /* "show [ip] bgp paths" commands. */ | |
16752 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16753 | ||
16754 | /* "show [ip] bgp community" commands. */ | |
16755 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16756 | ||
16757 | /* "show ip bgp large-community" commands. */ | |
16758 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16759 | /* "show [ip] bgp attribute-info" commands. */ | |
16760 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16761 | /* "show [ip] bgp route-leak" command */ |
16762 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16763 | |
16764 | /* "redistribute" commands. */ | |
16765 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16766 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16767 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16768 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16769 | install_element(BGP_NODE, | |
16770 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16771 | install_element(BGP_NODE, | |
16772 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16773 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16774 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16775 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16776 | install_element(BGP_NODE, | |
16777 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16778 | install_element(BGP_NODE, | |
16779 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16780 | install_element(BGP_NODE, | |
16781 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16782 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16783 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16784 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16785 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16786 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16787 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16788 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16789 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16790 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16791 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16792 | install_element(BGP_IPV4_NODE, | |
16793 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16794 | install_element(BGP_IPV4_NODE, | |
16795 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16796 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16797 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16798 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16799 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16800 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16801 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16802 | ||
b9c7bc5a PZ |
16803 | /* import|export vpn [route-map WORD] */ |
16804 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16805 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16806 | |
12a844a5 DS |
16807 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16808 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16809 | ||
d62a17ae | 16810 | /* ttl_security commands */ |
16811 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16812 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16813 | ||
16814 | /* "show [ip] bgp memory" commands. */ | |
16815 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16816 | ||
acf71666 MK |
16817 | /* "show bgp martian next-hop" */ |
16818 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16819 | ||
48ecf8f5 DS |
16820 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16821 | ||
d62a17ae | 16822 | /* "show [ip] bgp views" commands. */ |
16823 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16824 | ||
16825 | /* "show [ip] bgp vrfs" commands. */ | |
16826 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16827 | ||
16828 | /* Community-list. */ | |
16829 | community_list_vty(); | |
ddb5b488 PZ |
16830 | |
16831 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16832 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16833 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16834 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16835 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16836 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16837 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16838 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16839 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16840 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16841 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16842 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16843 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16844 | |
301ad80a PG |
16845 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16846 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16847 | ||
b9c7bc5a PZ |
16848 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16849 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16850 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16851 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
16852 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
16853 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16854 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16855 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16856 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16857 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16858 | } |
6b0655a2 | 16859 | |
718e3744 | 16860 | #include "memory.h" |
16861 | #include "bgp_regex.h" | |
16862 | #include "bgp_clist.h" | |
16863 | #include "bgp_ecommunity.h" | |
16864 | ||
16865 | /* VTY functions. */ | |
16866 | ||
16867 | /* Direction value to string conversion. */ | |
d62a17ae | 16868 | static const char *community_direct_str(int direct) |
16869 | { | |
16870 | switch (direct) { | |
16871 | case COMMUNITY_DENY: | |
16872 | return "deny"; | |
16873 | case COMMUNITY_PERMIT: | |
16874 | return "permit"; | |
16875 | default: | |
16876 | return "unknown"; | |
16877 | } | |
718e3744 | 16878 | } |
16879 | ||
16880 | /* Display error string. */ | |
d62a17ae | 16881 | static void community_list_perror(struct vty *vty, int ret) |
16882 | { | |
16883 | switch (ret) { | |
16884 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16885 | vty_out(vty, "%% Can't find community-list\n"); | |
16886 | break; | |
16887 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
16888 | vty_out(vty, "%% Malformed community-list value\n"); | |
16889 | break; | |
16890 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
16891 | vty_out(vty, | |
16892 | "%% Community name conflict, previously defined as standard community\n"); | |
16893 | break; | |
16894 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
16895 | vty_out(vty, | |
16896 | "%% Community name conflict, previously defined as expanded community\n"); | |
16897 | break; | |
16898 | } | |
718e3744 | 16899 | } |
16900 | ||
5bf15956 DW |
16901 | /* "community-list" keyword help string. */ |
16902 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
16903 | ||
7336e101 SP |
16904 | /*community-list standard */ |
16905 | DEFUN (community_list_standard, | |
16906 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 16907 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 16908 | BGP_STR |
718e3744 | 16909 | COMMUNITY_LIST_STR |
16910 | "Community list number (standard)\n" | |
5bf15956 | 16911 | "Add an standard community-list entry\n" |
718e3744 | 16912 | "Community list name\n" |
2f8cc0e5 DA |
16913 | "Sequence number of an entry\n" |
16914 | "Sequence number\n" | |
718e3744 | 16915 | "Specify community to reject\n" |
16916 | "Specify community to accept\n" | |
16917 | COMMUNITY_VAL_STR) | |
16918 | { | |
d62a17ae | 16919 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16920 | char *seq = NULL; |
d62a17ae | 16921 | int direct = 0; |
16922 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 16923 | int idx = 0; |
7336e101 | 16924 | |
2f8cc0e5 DA |
16925 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16926 | if (idx) | |
16927 | seq = argv[idx]->arg; | |
16928 | ||
16929 | idx = 0; | |
d62a17ae | 16930 | argv_find(argv, argc, "(1-99)", &idx); |
16931 | argv_find(argv, argc, "WORD", &idx); | |
16932 | cl_name_or_number = argv[idx]->arg; | |
16933 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16934 | : COMMUNITY_DENY; | |
16935 | argv_find(argv, argc, "AA:NN", &idx); | |
16936 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16937 | |
2f8cc0e5 DA |
16938 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16939 | direct, style); | |
42f914d4 | 16940 | |
d62a17ae | 16941 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16942 | |
d62a17ae | 16943 | if (ret < 0) { |
16944 | /* Display error string. */ | |
16945 | community_list_perror(vty, ret); | |
16946 | return CMD_WARNING_CONFIG_FAILED; | |
16947 | } | |
42f914d4 | 16948 | |
d62a17ae | 16949 | return CMD_SUCCESS; |
718e3744 | 16950 | } |
16951 | ||
7336e101 SP |
16952 | DEFUN (no_community_list_standard_all, |
16953 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 16954 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16955 | NO_STR |
16956 | BGP_STR | |
16957 | COMMUNITY_LIST_STR | |
16958 | "Community list number (standard)\n" | |
16959 | "Add an standard community-list entry\n" | |
16960 | "Community list name\n" | |
2f8cc0e5 DA |
16961 | "Sequence number of an entry\n" |
16962 | "Sequence number\n" | |
7336e101 SP |
16963 | "Specify community to reject\n" |
16964 | "Specify community to accept\n" | |
16965 | COMMUNITY_VAL_STR) | |
718e3744 | 16966 | { |
d62a17ae | 16967 | char *cl_name_or_number = NULL; |
174b5cb9 | 16968 | char *str = NULL; |
d62a17ae | 16969 | int direct = 0; |
16970 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 16971 | char *seq = NULL; |
d62a17ae | 16972 | int idx = 0; |
7336e101 | 16973 | |
2f8cc0e5 DA |
16974 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16975 | if (idx) | |
16976 | seq = argv[idx]->arg; | |
16977 | ||
16978 | idx = 0; | |
174b5cb9 DA |
16979 | argv_find(argv, argc, "permit", &idx); |
16980 | argv_find(argv, argc, "deny", &idx); | |
16981 | ||
16982 | if (idx) { | |
16983 | direct = argv_find(argv, argc, "permit", &idx) | |
16984 | ? COMMUNITY_PERMIT | |
16985 | : COMMUNITY_DENY; | |
16986 | ||
16987 | idx = 0; | |
16988 | argv_find(argv, argc, "AA:NN", &idx); | |
16989 | str = argv_concat(argv, argc, idx); | |
16990 | } | |
16991 | ||
16992 | idx = 0; | |
d62a17ae | 16993 | argv_find(argv, argc, "(1-99)", &idx); |
16994 | argv_find(argv, argc, "WORD", &idx); | |
16995 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16996 | |
2f8cc0e5 | 16997 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16998 | direct, style); |
42f914d4 | 16999 | |
d62a17ae | 17000 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17001 | |
d62a17ae | 17002 | if (ret < 0) { |
17003 | community_list_perror(vty, ret); | |
17004 | return CMD_WARNING_CONFIG_FAILED; | |
17005 | } | |
42f914d4 | 17006 | |
d62a17ae | 17007 | return CMD_SUCCESS; |
718e3744 | 17008 | } |
7336e101 | 17009 | |
174b5cb9 DA |
17010 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
17011 | "no bgp community-list <(1-99)|standard WORD>", | |
17012 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
17013 | "Community list number (standard)\n" | |
17014 | "Add an standard community-list entry\n" | |
17015 | "Community list name\n") | |
17016 | ||
7336e101 SP |
17017 | /*community-list expanded */ |
17018 | DEFUN (community_list_expanded_all, | |
17019 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17020 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17021 | BGP_STR |
17022 | COMMUNITY_LIST_STR | |
718e3744 | 17023 | "Community list number (expanded)\n" |
5bf15956 | 17024 | "Add an expanded community-list entry\n" |
718e3744 | 17025 | "Community list name\n" |
2f8cc0e5 DA |
17026 | "Sequence number of an entry\n" |
17027 | "Sequence number\n" | |
718e3744 | 17028 | "Specify community to reject\n" |
17029 | "Specify community to accept\n" | |
17030 | COMMUNITY_VAL_STR) | |
17031 | { | |
d62a17ae | 17032 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17033 | char *seq = NULL; |
d62a17ae | 17034 | int direct = 0; |
17035 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17036 | int idx = 0; |
7b9a4750 | 17037 | |
2f8cc0e5 DA |
17038 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17039 | if (idx) | |
17040 | seq = argv[idx]->arg; | |
17041 | ||
17042 | idx = 0; | |
17043 | ||
d62a17ae | 17044 | argv_find(argv, argc, "(100-500)", &idx); |
17045 | argv_find(argv, argc, "WORD", &idx); | |
17046 | cl_name_or_number = argv[idx]->arg; | |
17047 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17048 | : COMMUNITY_DENY; | |
17049 | argv_find(argv, argc, "AA:NN", &idx); | |
17050 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17051 | |
2f8cc0e5 DA |
17052 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17053 | direct, style); | |
42f914d4 | 17054 | |
d62a17ae | 17055 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17056 | |
d62a17ae | 17057 | if (ret < 0) { |
17058 | /* Display error string. */ | |
17059 | community_list_perror(vty, ret); | |
17060 | return CMD_WARNING_CONFIG_FAILED; | |
17061 | } | |
42f914d4 | 17062 | |
d62a17ae | 17063 | return CMD_SUCCESS; |
718e3744 | 17064 | } |
17065 | ||
7336e101 SP |
17066 | DEFUN (no_community_list_expanded_all, |
17067 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17068 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17069 | NO_STR |
17070 | BGP_STR | |
17071 | COMMUNITY_LIST_STR | |
17072 | "Community list number (expanded)\n" | |
17073 | "Add an expanded community-list entry\n" | |
17074 | "Community list name\n" | |
2f8cc0e5 DA |
17075 | "Sequence number of an entry\n" |
17076 | "Sequence number\n" | |
7336e101 SP |
17077 | "Specify community to reject\n" |
17078 | "Specify community to accept\n" | |
17079 | COMMUNITY_VAL_STR) | |
718e3744 | 17080 | { |
d62a17ae | 17081 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17082 | char *seq = NULL; |
174b5cb9 | 17083 | char *str = NULL; |
d62a17ae | 17084 | int direct = 0; |
17085 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17086 | int idx = 0; |
174b5cb9 | 17087 | |
2f8cc0e5 DA |
17088 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17089 | if (idx) | |
17090 | seq = argv[idx]->arg; | |
17091 | ||
17092 | idx = 0; | |
174b5cb9 DA |
17093 | argv_find(argv, argc, "permit", &idx); |
17094 | argv_find(argv, argc, "deny", &idx); | |
17095 | ||
17096 | if (idx) { | |
17097 | direct = argv_find(argv, argc, "permit", &idx) | |
17098 | ? COMMUNITY_PERMIT | |
17099 | : COMMUNITY_DENY; | |
17100 | ||
17101 | idx = 0; | |
17102 | argv_find(argv, argc, "AA:NN", &idx); | |
17103 | str = argv_concat(argv, argc, idx); | |
7336e101 | 17104 | } |
174b5cb9 DA |
17105 | |
17106 | idx = 0; | |
d62a17ae | 17107 | argv_find(argv, argc, "(100-500)", &idx); |
17108 | argv_find(argv, argc, "WORD", &idx); | |
17109 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17110 | |
2f8cc0e5 | 17111 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17112 | direct, style); |
42f914d4 | 17113 | |
d62a17ae | 17114 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17115 | |
d62a17ae | 17116 | if (ret < 0) { |
17117 | community_list_perror(vty, ret); | |
17118 | return CMD_WARNING_CONFIG_FAILED; | |
17119 | } | |
42f914d4 | 17120 | |
d62a17ae | 17121 | return CMD_SUCCESS; |
718e3744 | 17122 | } |
17123 | ||
174b5cb9 DA |
17124 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
17125 | "no bgp community-list <(100-500)|expanded WORD>", | |
17126 | NO_STR IP_STR COMMUNITY_LIST_STR | |
17127 | "Community list number (expanded)\n" | |
17128 | "Add an expanded community-list entry\n" | |
17129 | "Community list name\n") | |
17130 | ||
8d9b8ed9 PM |
17131 | /* Return configuration string of community-list entry. */ |
17132 | static const char *community_list_config_str(struct community_entry *entry) | |
17133 | { | |
17134 | const char *str; | |
17135 | ||
17136 | if (entry->any) | |
17137 | str = ""; | |
17138 | else { | |
17139 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
17140 | str = community_str(entry->u.com, false); | |
17141 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
17142 | str = lcommunity_str(entry->u.lcom, false); | |
17143 | else | |
17144 | str = entry->config; | |
17145 | } | |
17146 | return str; | |
17147 | } | |
17148 | ||
d62a17ae | 17149 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17150 | { |
d62a17ae | 17151 | struct community_entry *entry; |
718e3744 | 17152 | |
d62a17ae | 17153 | for (entry = list->head; entry; entry = entry->next) { |
17154 | if (entry == list->head) { | |
17155 | if (all_digit(list->name)) | |
17156 | vty_out(vty, "Community %s list %s\n", | |
17157 | entry->style == COMMUNITY_LIST_STANDARD | |
17158 | ? "standard" | |
17159 | : "(expanded) access", | |
17160 | list->name); | |
17161 | else | |
17162 | vty_out(vty, "Named Community %s list %s\n", | |
17163 | entry->style == COMMUNITY_LIST_STANDARD | |
17164 | ? "standard" | |
17165 | : "expanded", | |
17166 | list->name); | |
17167 | } | |
17168 | if (entry->any) | |
17169 | vty_out(vty, " %s\n", | |
17170 | community_direct_str(entry->direct)); | |
17171 | else | |
17172 | vty_out(vty, " %s %s\n", | |
17173 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17174 | community_list_config_str(entry)); |
d62a17ae | 17175 | } |
718e3744 | 17176 | } |
17177 | ||
7336e101 SP |
17178 | DEFUN (show_community_list, |
17179 | show_bgp_community_list_cmd, | |
17180 | "show bgp community-list", | |
718e3744 | 17181 | SHOW_STR |
7336e101 | 17182 | BGP_STR |
718e3744 | 17183 | "List community-list\n") |
17184 | { | |
d62a17ae | 17185 | struct community_list *list; |
17186 | struct community_list_master *cm; | |
718e3744 | 17187 | |
d62a17ae | 17188 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
17189 | if (!cm) | |
17190 | return CMD_SUCCESS; | |
718e3744 | 17191 | |
d62a17ae | 17192 | for (list = cm->num.head; list; list = list->next) |
17193 | community_list_show(vty, list); | |
718e3744 | 17194 | |
d62a17ae | 17195 | for (list = cm->str.head; list; list = list->next) |
17196 | community_list_show(vty, list); | |
718e3744 | 17197 | |
d62a17ae | 17198 | return CMD_SUCCESS; |
718e3744 | 17199 | } |
17200 | ||
7336e101 SP |
17201 | DEFUN (show_community_list_arg, |
17202 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 17203 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
17204 | SHOW_STR |
17205 | BGP_STR | |
718e3744 | 17206 | "List community-list\n" |
17207 | "Community-list number\n" | |
960b69b9 | 17208 | "Community-list name\n" |
17209 | "Detailed information on community-list\n") | |
718e3744 | 17210 | { |
d62a17ae | 17211 | int idx_comm_list = 3; |
17212 | struct community_list *list; | |
718e3744 | 17213 | |
e237b0d2 | 17214 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17215 | COMMUNITY_LIST_MASTER); |
17216 | if (!list) { | |
17217 | vty_out(vty, "%% Can't find community-list\n"); | |
17218 | return CMD_WARNING; | |
17219 | } | |
718e3744 | 17220 | |
d62a17ae | 17221 | community_list_show(vty, list); |
718e3744 | 17222 | |
d62a17ae | 17223 | return CMD_SUCCESS; |
718e3744 | 17224 | } |
6b0655a2 | 17225 | |
57d187bc JS |
17226 | /* |
17227 | * Large Community code. | |
17228 | */ | |
d62a17ae | 17229 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17230 | struct cmd_token **argv, int style, | |
17231 | int reject_all_digit_name) | |
17232 | { | |
17233 | int ret; | |
17234 | int direct; | |
17235 | char *str; | |
17236 | int idx = 0; | |
17237 | char *cl_name; | |
2f8cc0e5 DA |
17238 | char *seq = NULL; |
17239 | ||
17240 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17241 | if (idx) | |
17242 | seq = argv[idx]->arg; | |
d62a17ae | 17243 | |
2f8cc0e5 | 17244 | idx = 0; |
d62a17ae | 17245 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17246 | : COMMUNITY_DENY; | |
17247 | ||
17248 | /* All digit name check. */ | |
17249 | idx = 0; | |
17250 | argv_find(argv, argc, "WORD", &idx); | |
17251 | argv_find(argv, argc, "(1-99)", &idx); | |
17252 | argv_find(argv, argc, "(100-500)", &idx); | |
17253 | cl_name = argv[idx]->arg; | |
17254 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17255 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17256 | return CMD_WARNING_CONFIG_FAILED; | |
17257 | } | |
17258 | ||
17259 | idx = 0; | |
17260 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17261 | argv_find(argv, argc, "LINE", &idx); | |
17262 | /* Concat community string argument. */ | |
17263 | if (idx) | |
17264 | str = argv_concat(argv, argc, idx); | |
17265 | else | |
17266 | str = NULL; | |
17267 | ||
2f8cc0e5 | 17268 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17269 | |
17270 | /* Free temporary community list string allocated by | |
17271 | argv_concat(). */ | |
0a22ddfb | 17272 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17273 | |
17274 | if (ret < 0) { | |
17275 | community_list_perror(vty, ret); | |
17276 | return CMD_WARNING_CONFIG_FAILED; | |
17277 | } | |
17278 | return CMD_SUCCESS; | |
17279 | } | |
17280 | ||
17281 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17282 | struct cmd_token **argv, int style) | |
17283 | { | |
17284 | int ret; | |
17285 | int direct = 0; | |
17286 | char *str = NULL; | |
17287 | int idx = 0; | |
2f8cc0e5 | 17288 | char *seq = NULL; |
d62a17ae | 17289 | |
2f8cc0e5 DA |
17290 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17291 | if (idx) | |
17292 | seq = argv[idx]->arg; | |
d62a17ae | 17293 | |
2f8cc0e5 | 17294 | idx = 0; |
d62a17ae | 17295 | argv_find(argv, argc, "permit", &idx); |
17296 | argv_find(argv, argc, "deny", &idx); | |
17297 | ||
17298 | if (idx) { | |
17299 | /* Check the list direct. */ | |
17300 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17301 | direct = COMMUNITY_PERMIT; | |
17302 | else | |
17303 | direct = COMMUNITY_DENY; | |
17304 | ||
17305 | idx = 0; | |
17306 | argv_find(argv, argc, "LINE", &idx); | |
17307 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17308 | /* Concat community string argument. */ | |
17309 | str = argv_concat(argv, argc, idx); | |
17310 | } | |
17311 | ||
17312 | idx = 0; | |
17313 | argv_find(argv, argc, "(1-99)", &idx); | |
17314 | argv_find(argv, argc, "(100-500)", &idx); | |
17315 | argv_find(argv, argc, "WORD", &idx); | |
17316 | ||
17317 | /* Unset community list. */ | |
2f8cc0e5 | 17318 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17319 | style); |
17320 | ||
17321 | /* Free temporary community list string allocated by | |
17322 | argv_concat(). */ | |
0a22ddfb | 17323 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17324 | |
17325 | if (ret < 0) { | |
17326 | community_list_perror(vty, ret); | |
17327 | return CMD_WARNING_CONFIG_FAILED; | |
17328 | } | |
17329 | ||
17330 | return CMD_SUCCESS; | |
57d187bc JS |
17331 | } |
17332 | ||
17333 | /* "large-community-list" keyword help string. */ | |
17334 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17335 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17336 | ||
7336e101 SP |
17337 | DEFUN (lcommunity_list_standard, |
17338 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17339 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17340 | BGP_STR |
17341 | LCOMMUNITY_LIST_STR | |
17342 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17343 | "Sequence number of an entry\n" |
17344 | "Sequence number\n" | |
7336e101 SP |
17345 | "Specify large community to reject\n" |
17346 | "Specify large community to accept\n" | |
17347 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17348 | { |
d62a17ae | 17349 | return lcommunity_list_set_vty(vty, argc, argv, |
17350 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17351 | } |
17352 | ||
7336e101 SP |
17353 | DEFUN (lcommunity_list_expanded, |
17354 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17355 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17356 | BGP_STR |
17357 | LCOMMUNITY_LIST_STR | |
17358 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17359 | "Sequence number of an entry\n" |
17360 | "Sequence number\n" | |
7336e101 SP |
17361 | "Specify large community to reject\n" |
17362 | "Specify large community to accept\n" | |
17363 | "An ordered list as a regular-expression\n") | |
57d187bc | 17364 | { |
d62a17ae | 17365 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17366 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17367 | } |
17368 | ||
7336e101 SP |
17369 | DEFUN (lcommunity_list_name_standard, |
17370 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17371 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17372 | BGP_STR |
17373 | LCOMMUNITY_LIST_STR | |
17374 | "Specify standard large-community-list\n" | |
17375 | "Large Community list name\n" | |
2f8cc0e5 DA |
17376 | "Sequence number of an entry\n" |
17377 | "Sequence number\n" | |
7336e101 SP |
17378 | "Specify large community to reject\n" |
17379 | "Specify large community to accept\n" | |
17380 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17381 | { |
d62a17ae | 17382 | return lcommunity_list_set_vty(vty, argc, argv, |
17383 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17384 | } |
17385 | ||
7336e101 SP |
17386 | DEFUN (lcommunity_list_name_expanded, |
17387 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17388 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17389 | BGP_STR |
17390 | LCOMMUNITY_LIST_STR | |
17391 | "Specify expanded large-community-list\n" | |
17392 | "Large Community list name\n" | |
2f8cc0e5 DA |
17393 | "Sequence number of an entry\n" |
17394 | "Sequence number\n" | |
7336e101 SP |
17395 | "Specify large community to reject\n" |
17396 | "Specify large community to accept\n" | |
17397 | "An ordered list as a regular-expression\n") | |
57d187bc | 17398 | { |
d62a17ae | 17399 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17400 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17401 | } |
17402 | ||
4378f57c DA |
17403 | DEFUN (no_lcommunity_list_all, |
17404 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17405 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17406 | NO_STR | |
17407 | BGP_STR | |
17408 | LCOMMUNITY_LIST_STR | |
17409 | "Large Community list number (standard)\n" | |
17410 | "Large Community list number (expanded)\n" | |
17411 | "Large Community list name\n") | |
57d187bc | 17412 | { |
7336e101 SP |
17413 | return lcommunity_list_unset_vty(vty, argc, argv, |
17414 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17415 | } |
17416 | ||
4378f57c DA |
17417 | DEFUN (no_lcommunity_list_name_standard_all, |
17418 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17419 | "no bgp large-community-list standard WORD", | |
17420 | NO_STR | |
17421 | BGP_STR | |
17422 | LCOMMUNITY_LIST_STR | |
17423 | "Specify standard large-community-list\n" | |
17424 | "Large Community list name\n") | |
17425 | { | |
17426 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17427 | LARGE_COMMUNITY_LIST_STANDARD); | |
17428 | } | |
17429 | ||
7336e101 SP |
17430 | DEFUN (no_lcommunity_list_name_expanded_all, |
17431 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17432 | "no bgp large-community-list expanded WORD", | |
17433 | NO_STR | |
17434 | BGP_STR | |
17435 | LCOMMUNITY_LIST_STR | |
17436 | "Specify expanded large-community-list\n" | |
17437 | "Large Community list name\n") | |
57d187bc | 17438 | { |
d62a17ae | 17439 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17440 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17441 | } |
17442 | ||
7336e101 SP |
17443 | DEFUN (no_lcommunity_list_standard, |
17444 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17445 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17446 | NO_STR |
17447 | BGP_STR | |
17448 | LCOMMUNITY_LIST_STR | |
17449 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17450 | "Sequence number of an entry\n" |
17451 | "Sequence number\n" | |
7336e101 SP |
17452 | "Specify large community to reject\n" |
17453 | "Specify large community to accept\n" | |
17454 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17455 | { |
d62a17ae | 17456 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17457 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17458 | } |
17459 | ||
7336e101 SP |
17460 | DEFUN (no_lcommunity_list_expanded, |
17461 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17462 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17463 | NO_STR |
17464 | BGP_STR | |
17465 | LCOMMUNITY_LIST_STR | |
17466 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17467 | "Sequence number of an entry\n" |
17468 | "Sequence number\n" | |
7336e101 SP |
17469 | "Specify large community to reject\n" |
17470 | "Specify large community to accept\n" | |
17471 | "An ordered list as a regular-expression\n") | |
57d187bc | 17472 | { |
d62a17ae | 17473 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17474 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17475 | } |
17476 | ||
7336e101 SP |
17477 | DEFUN (no_lcommunity_list_name_standard, |
17478 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17479 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17480 | NO_STR |
17481 | BGP_STR | |
17482 | LCOMMUNITY_LIST_STR | |
17483 | "Specify standard large-community-list\n" | |
17484 | "Large Community list name\n" | |
2f8cc0e5 DA |
17485 | "Sequence number of an entry\n" |
17486 | "Sequence number\n" | |
7336e101 SP |
17487 | "Specify large community to reject\n" |
17488 | "Specify large community to accept\n" | |
17489 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17490 | { |
d62a17ae | 17491 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17492 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17493 | } |
17494 | ||
7336e101 SP |
17495 | DEFUN (no_lcommunity_list_name_expanded, |
17496 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17497 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17498 | NO_STR |
17499 | BGP_STR | |
17500 | LCOMMUNITY_LIST_STR | |
17501 | "Specify expanded large-community-list\n" | |
17502 | "Large community list name\n" | |
2f8cc0e5 DA |
17503 | "Sequence number of an entry\n" |
17504 | "Sequence number\n" | |
7336e101 SP |
17505 | "Specify large community to reject\n" |
17506 | "Specify large community to accept\n" | |
17507 | "An ordered list as a regular-expression\n") | |
57d187bc | 17508 | { |
d62a17ae | 17509 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17510 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17511 | } |
17512 | ||
d62a17ae | 17513 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17514 | { | |
17515 | struct community_entry *entry; | |
17516 | ||
17517 | for (entry = list->head; entry; entry = entry->next) { | |
17518 | if (entry == list->head) { | |
17519 | if (all_digit(list->name)) | |
17520 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17521 | entry->style == |
17522 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17523 | ? "standard" |
17524 | : "(expanded) access", | |
17525 | list->name); | |
17526 | else | |
17527 | vty_out(vty, | |
17528 | "Named large community %s list %s\n", | |
169b72c8 | 17529 | entry->style == |
17530 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17531 | ? "standard" |
17532 | : "expanded", | |
17533 | list->name); | |
17534 | } | |
17535 | if (entry->any) | |
17536 | vty_out(vty, " %s\n", | |
17537 | community_direct_str(entry->direct)); | |
17538 | else | |
17539 | vty_out(vty, " %s %s\n", | |
17540 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17541 | community_list_config_str(entry)); |
d62a17ae | 17542 | } |
57d187bc JS |
17543 | } |
17544 | ||
7336e101 SP |
17545 | DEFUN (show_lcommunity_list, |
17546 | show_bgp_lcommunity_list_cmd, | |
17547 | "show bgp large-community-list", | |
57d187bc | 17548 | SHOW_STR |
7336e101 | 17549 | BGP_STR |
57d187bc JS |
17550 | "List large-community list\n") |
17551 | { | |
d62a17ae | 17552 | struct community_list *list; |
17553 | struct community_list_master *cm; | |
57d187bc | 17554 | |
d62a17ae | 17555 | cm = community_list_master_lookup(bgp_clist, |
17556 | LARGE_COMMUNITY_LIST_MASTER); | |
17557 | if (!cm) | |
17558 | return CMD_SUCCESS; | |
57d187bc | 17559 | |
d62a17ae | 17560 | for (list = cm->num.head; list; list = list->next) |
17561 | lcommunity_list_show(vty, list); | |
57d187bc | 17562 | |
d62a17ae | 17563 | for (list = cm->str.head; list; list = list->next) |
17564 | lcommunity_list_show(vty, list); | |
57d187bc | 17565 | |
d62a17ae | 17566 | return CMD_SUCCESS; |
57d187bc JS |
17567 | } |
17568 | ||
7336e101 SP |
17569 | DEFUN (show_lcommunity_list_arg, |
17570 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17571 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17572 | SHOW_STR |
17573 | BGP_STR | |
57d187bc | 17574 | "List large-community list\n" |
960b69b9 | 17575 | "Large-community-list number\n" |
17576 | "Large-community-list name\n" | |
17577 | "Detailed information on large-community-list\n") | |
57d187bc | 17578 | { |
d62a17ae | 17579 | struct community_list *list; |
57d187bc | 17580 | |
e237b0d2 | 17581 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17582 | LARGE_COMMUNITY_LIST_MASTER); |
17583 | if (!list) { | |
960b69b9 | 17584 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17585 | return CMD_WARNING; |
17586 | } | |
57d187bc | 17587 | |
d62a17ae | 17588 | lcommunity_list_show(vty, list); |
57d187bc | 17589 | |
d62a17ae | 17590 | return CMD_SUCCESS; |
57d187bc JS |
17591 | } |
17592 | ||
718e3744 | 17593 | /* "extcommunity-list" keyword help string. */ |
17594 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17595 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17596 | ||
7336e101 SP |
17597 | DEFUN (extcommunity_list_standard, |
17598 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17599 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17600 | BGP_STR |
718e3744 | 17601 | EXTCOMMUNITY_LIST_STR |
17602 | "Extended Community list number (standard)\n" | |
718e3744 | 17603 | "Specify standard extcommunity-list\n" |
5bf15956 | 17604 | "Community list name\n" |
2f8cc0e5 DA |
17605 | "Sequence number of an entry\n" |
17606 | "Sequence number\n" | |
718e3744 | 17607 | "Specify community to reject\n" |
17608 | "Specify community to accept\n" | |
17609 | EXTCOMMUNITY_VAL_STR) | |
17610 | { | |
d62a17ae | 17611 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17612 | int direct = 0; | |
17613 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17614 | char *seq = NULL; |
42f914d4 | 17615 | |
d62a17ae | 17616 | int idx = 0; |
7b9a4750 | 17617 | |
d62a17ae | 17618 | argv_find(argv, argc, "(1-99)", &idx); |
17619 | argv_find(argv, argc, "WORD", &idx); | |
17620 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17621 | |
409148f6 | 17622 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17623 | seq = argv[idx]->arg; |
17624 | ||
d62a17ae | 17625 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17626 | : COMMUNITY_DENY; | |
17627 | argv_find(argv, argc, "AA:NN", &idx); | |
17628 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17629 | |
2f8cc0e5 | 17630 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17631 | direct, style); |
42f914d4 | 17632 | |
d62a17ae | 17633 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17634 | |
d62a17ae | 17635 | if (ret < 0) { |
17636 | community_list_perror(vty, ret); | |
17637 | return CMD_WARNING_CONFIG_FAILED; | |
17638 | } | |
42f914d4 | 17639 | |
d62a17ae | 17640 | return CMD_SUCCESS; |
718e3744 | 17641 | } |
17642 | ||
7336e101 SP |
17643 | DEFUN (extcommunity_list_name_expanded, |
17644 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17645 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17646 | BGP_STR |
17647 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17648 | "Extended Community list number (expanded)\n" |
718e3744 | 17649 | "Specify expanded extcommunity-list\n" |
17650 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17651 | "Sequence number of an entry\n" |
17652 | "Sequence number\n" | |
718e3744 | 17653 | "Specify community to reject\n" |
17654 | "Specify community to accept\n" | |
17655 | "An ordered list as a regular-expression\n") | |
17656 | { | |
d62a17ae | 17657 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17658 | int direct = 0; | |
17659 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17660 | char *seq = NULL; |
d62a17ae | 17661 | int idx = 0; |
7336e101 | 17662 | |
d62a17ae | 17663 | argv_find(argv, argc, "(100-500)", &idx); |
17664 | argv_find(argv, argc, "WORD", &idx); | |
17665 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17666 | |
409148f6 | 17667 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17668 | seq = argv[idx]->arg; |
17669 | ||
d62a17ae | 17670 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17671 | : COMMUNITY_DENY; | |
17672 | argv_find(argv, argc, "LINE", &idx); | |
17673 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17674 | |
2f8cc0e5 | 17675 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17676 | direct, style); |
42f914d4 | 17677 | |
d62a17ae | 17678 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17679 | |
d62a17ae | 17680 | if (ret < 0) { |
17681 | community_list_perror(vty, ret); | |
17682 | return CMD_WARNING_CONFIG_FAILED; | |
17683 | } | |
42f914d4 | 17684 | |
d62a17ae | 17685 | return CMD_SUCCESS; |
718e3744 | 17686 | } |
17687 | ||
7336e101 SP |
17688 | DEFUN (no_extcommunity_list_standard_all, |
17689 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17690 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17691 | NO_STR |
17692 | BGP_STR | |
17693 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17694 | "Extended Community list number (standard)\n" |
718e3744 | 17695 | "Specify standard extcommunity-list\n" |
5bf15956 | 17696 | "Community list name\n" |
2f8cc0e5 DA |
17697 | "Sequence number of an entry\n" |
17698 | "Sequence number\n" | |
718e3744 | 17699 | "Specify community to reject\n" |
17700 | "Specify community to accept\n" | |
17701 | EXTCOMMUNITY_VAL_STR) | |
17702 | { | |
d62a17ae | 17703 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17704 | int direct = 0; | |
17705 | char *cl_number_or_name = NULL; | |
d4455c89 | 17706 | char *str = NULL; |
2f8cc0e5 | 17707 | char *seq = NULL; |
d62a17ae | 17708 | int idx = 0; |
d4455c89 | 17709 | |
409148f6 | 17710 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17711 | seq = argv[idx]->arg; |
17712 | ||
17713 | idx = 0; | |
d4455c89 DA |
17714 | argv_find(argv, argc, "permit", &idx); |
17715 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17716 | if (idx) { |
17717 | direct = argv_find(argv, argc, "permit", &idx) | |
17718 | ? COMMUNITY_PERMIT | |
17719 | : COMMUNITY_DENY; | |
17720 | ||
17721 | idx = 0; | |
17722 | argv_find(argv, argc, "AA:NN", &idx); | |
17723 | str = argv_concat(argv, argc, idx); | |
17724 | } | |
17725 | ||
17726 | idx = 0; | |
d62a17ae | 17727 | argv_find(argv, argc, "(1-99)", &idx); |
17728 | argv_find(argv, argc, "WORD", &idx); | |
17729 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17730 | |
d62a17ae | 17731 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17732 | seq, direct, style); |
42f914d4 | 17733 | |
d62a17ae | 17734 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17735 | |
d62a17ae | 17736 | if (ret < 0) { |
17737 | community_list_perror(vty, ret); | |
17738 | return CMD_WARNING_CONFIG_FAILED; | |
17739 | } | |
42f914d4 | 17740 | |
d62a17ae | 17741 | return CMD_SUCCESS; |
718e3744 | 17742 | } |
17743 | ||
d4455c89 DA |
17744 | ALIAS(no_extcommunity_list_standard_all, |
17745 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17746 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17747 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17748 | "Extended Community list number (standard)\n" | |
17749 | "Specify standard extcommunity-list\n" | |
17750 | "Community list name\n") | |
17751 | ||
7336e101 SP |
17752 | DEFUN (no_extcommunity_list_expanded_all, |
17753 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 17754 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17755 | NO_STR |
17756 | BGP_STR | |
17757 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17758 | "Extended Community list number (expanded)\n" |
718e3744 | 17759 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17760 | "Extended Community list name\n" |
2f8cc0e5 DA |
17761 | "Sequence number of an entry\n" |
17762 | "Sequence number\n" | |
718e3744 | 17763 | "Specify community to reject\n" |
17764 | "Specify community to accept\n" | |
17765 | "An ordered list as a regular-expression\n") | |
17766 | { | |
d62a17ae | 17767 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17768 | int direct = 0; | |
17769 | char *cl_number_or_name = NULL; | |
d4455c89 | 17770 | char *str = NULL; |
2f8cc0e5 | 17771 | char *seq = NULL; |
d62a17ae | 17772 | int idx = 0; |
d4455c89 | 17773 | |
409148f6 | 17774 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17775 | seq = argv[idx]->arg; |
17776 | ||
17777 | idx = 0; | |
d4455c89 DA |
17778 | argv_find(argv, argc, "permit", &idx); |
17779 | argv_find(argv, argc, "deny", &idx); | |
17780 | ||
17781 | if (idx) { | |
17782 | direct = argv_find(argv, argc, "permit", &idx) | |
17783 | ? COMMUNITY_PERMIT | |
17784 | : COMMUNITY_DENY; | |
17785 | ||
17786 | idx = 0; | |
17787 | argv_find(argv, argc, "LINE", &idx); | |
17788 | str = argv_concat(argv, argc, idx); | |
17789 | } | |
17790 | ||
17791 | idx = 0; | |
d62a17ae | 17792 | argv_find(argv, argc, "(100-500)", &idx); |
17793 | argv_find(argv, argc, "WORD", &idx); | |
17794 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17795 | |
d62a17ae | 17796 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17797 | seq, direct, style); |
42f914d4 | 17798 | |
d62a17ae | 17799 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17800 | |
d62a17ae | 17801 | if (ret < 0) { |
17802 | community_list_perror(vty, ret); | |
17803 | return CMD_WARNING_CONFIG_FAILED; | |
17804 | } | |
42f914d4 | 17805 | |
d62a17ae | 17806 | return CMD_SUCCESS; |
718e3744 | 17807 | } |
17808 | ||
d4455c89 DA |
17809 | ALIAS(no_extcommunity_list_expanded_all, |
17810 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17811 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17812 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17813 | "Extended Community list number (expanded)\n" | |
17814 | "Specify expanded extcommunity-list\n" | |
17815 | "Extended Community list name\n") | |
17816 | ||
d62a17ae | 17817 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17818 | { |
d62a17ae | 17819 | struct community_entry *entry; |
718e3744 | 17820 | |
d62a17ae | 17821 | for (entry = list->head; entry; entry = entry->next) { |
17822 | if (entry == list->head) { | |
17823 | if (all_digit(list->name)) | |
17824 | vty_out(vty, "Extended community %s list %s\n", | |
17825 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17826 | ? "standard" | |
17827 | : "(expanded) access", | |
17828 | list->name); | |
17829 | else | |
17830 | vty_out(vty, | |
17831 | "Named extended community %s list %s\n", | |
17832 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17833 | ? "standard" | |
17834 | : "expanded", | |
17835 | list->name); | |
17836 | } | |
17837 | if (entry->any) | |
17838 | vty_out(vty, " %s\n", | |
17839 | community_direct_str(entry->direct)); | |
17840 | else | |
17841 | vty_out(vty, " %s %s\n", | |
17842 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17843 | community_list_config_str(entry)); |
d62a17ae | 17844 | } |
718e3744 | 17845 | } |
17846 | ||
7336e101 SP |
17847 | DEFUN (show_extcommunity_list, |
17848 | show_bgp_extcommunity_list_cmd, | |
17849 | "show bgp extcommunity-list", | |
718e3744 | 17850 | SHOW_STR |
7336e101 | 17851 | BGP_STR |
718e3744 | 17852 | "List extended-community list\n") |
17853 | { | |
d62a17ae | 17854 | struct community_list *list; |
17855 | struct community_list_master *cm; | |
718e3744 | 17856 | |
d62a17ae | 17857 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17858 | if (!cm) | |
17859 | return CMD_SUCCESS; | |
718e3744 | 17860 | |
d62a17ae | 17861 | for (list = cm->num.head; list; list = list->next) |
17862 | extcommunity_list_show(vty, list); | |
718e3744 | 17863 | |
d62a17ae | 17864 | for (list = cm->str.head; list; list = list->next) |
17865 | extcommunity_list_show(vty, list); | |
718e3744 | 17866 | |
d62a17ae | 17867 | return CMD_SUCCESS; |
718e3744 | 17868 | } |
17869 | ||
7336e101 SP |
17870 | DEFUN (show_extcommunity_list_arg, |
17871 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17872 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17873 | SHOW_STR |
17874 | BGP_STR | |
718e3744 | 17875 | "List extended-community list\n" |
17876 | "Extcommunity-list number\n" | |
960b69b9 | 17877 | "Extcommunity-list name\n" |
17878 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17879 | { |
d62a17ae | 17880 | int idx_comm_list = 3; |
17881 | struct community_list *list; | |
718e3744 | 17882 | |
e237b0d2 | 17883 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17884 | EXTCOMMUNITY_LIST_MASTER); |
17885 | if (!list) { | |
17886 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17887 | return CMD_WARNING; | |
17888 | } | |
718e3744 | 17889 | |
d62a17ae | 17890 | extcommunity_list_show(vty, list); |
718e3744 | 17891 | |
d62a17ae | 17892 | return CMD_SUCCESS; |
718e3744 | 17893 | } |
6b0655a2 | 17894 | |
718e3744 | 17895 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 17896 | static int community_list_config_write(struct vty *vty) |
17897 | { | |
17898 | struct community_list *list; | |
17899 | struct community_entry *entry; | |
17900 | struct community_list_master *cm; | |
17901 | int write = 0; | |
17902 | ||
17903 | /* Community-list. */ | |
17904 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
17905 | ||
17906 | for (list = cm->num.head; list; list = list->next) | |
17907 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17908 | vty_out(vty, |
17909 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
17910 | list->name, entry->seq, | |
d62a17ae | 17911 | community_direct_str(entry->direct), |
17912 | community_list_config_str(entry)); | |
17913 | write++; | |
17914 | } | |
17915 | for (list = cm->str.head; list; list = list->next) | |
17916 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17917 | vty_out(vty, |
17918 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 17919 | entry->style == COMMUNITY_LIST_STANDARD |
17920 | ? "standard" | |
17921 | : "expanded", | |
2f8cc0e5 DA |
17922 | list->name, entry->seq, |
17923 | community_direct_str(entry->direct), | |
d62a17ae | 17924 | community_list_config_str(entry)); |
17925 | write++; | |
17926 | } | |
17927 | ||
17928 | /* Extcommunity-list. */ | |
17929 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
17930 | ||
17931 | for (list = cm->num.head; list; list = list->next) | |
17932 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17933 | vty_out(vty, |
17934 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
17935 | list->name, entry->seq, | |
17936 | community_direct_str(entry->direct), | |
d62a17ae | 17937 | community_list_config_str(entry)); |
17938 | write++; | |
17939 | } | |
17940 | for (list = cm->str.head; list; list = list->next) | |
17941 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17942 | vty_out(vty, |
17943 | "bgp extcommunity-list %s %s seq %" PRId64 | |
17944 | " %s %s\n", | |
d62a17ae | 17945 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
17946 | ? "standard" | |
17947 | : "expanded", | |
2f8cc0e5 DA |
17948 | list->name, entry->seq, |
17949 | community_direct_str(entry->direct), | |
d62a17ae | 17950 | community_list_config_str(entry)); |
17951 | write++; | |
17952 | } | |
17953 | ||
17954 | ||
17955 | /* lcommunity-list. */ | |
17956 | cm = community_list_master_lookup(bgp_clist, | |
17957 | LARGE_COMMUNITY_LIST_MASTER); | |
17958 | ||
17959 | for (list = cm->num.head; list; list = list->next) | |
17960 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17961 | vty_out(vty, |
17962 | "bgp large-community-list %s seq %" PRId64 | |
17963 | " %s %s\n", | |
17964 | list->name, entry->seq, | |
17965 | community_direct_str(entry->direct), | |
d62a17ae | 17966 | community_list_config_str(entry)); |
17967 | write++; | |
17968 | } | |
17969 | for (list = cm->str.head; list; list = list->next) | |
17970 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17971 | vty_out(vty, |
17972 | "bgp large-community-list %s %s seq %" PRId64 | |
17973 | " %s %s\n", | |
17974 | ||
d62a17ae | 17975 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
17976 | ? "standard" | |
17977 | : "expanded", | |
2f8cc0e5 | 17978 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 17979 | community_list_config_str(entry)); |
17980 | write++; | |
17981 | } | |
17982 | ||
17983 | return write; | |
17984 | } | |
17985 | ||
612c2c15 | 17986 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 17987 | static struct cmd_node community_list_node = { |
f4b8291f | 17988 | .name = "community list", |
62b346ee DL |
17989 | .node = COMMUNITY_LIST_NODE, |
17990 | .prompt = "", | |
612c2c15 | 17991 | .config_write = community_list_config_write, |
718e3744 | 17992 | }; |
17993 | ||
d62a17ae | 17994 | static void community_list_vty(void) |
17995 | { | |
612c2c15 | 17996 | install_node(&community_list_node); |
d62a17ae | 17997 | |
17998 | /* Community-list. */ | |
7336e101 SP |
17999 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
18000 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
18001 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 18002 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 18003 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 18004 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
18005 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
18006 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 18007 | |
18008 | /* Extcommunity-list. */ | |
7336e101 SP |
18009 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
18010 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
18011 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
18012 | install_element(CONFIG_NODE, |
18013 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 18014 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
18015 | install_element(CONFIG_NODE, |
18016 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
18017 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
18018 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 18019 | |
18020 | /* Large Community List */ | |
7336e101 | 18021 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
18022 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
18023 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 18024 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
18025 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
18026 | install_element(CONFIG_NODE, | |
18027 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
18028 | install_element(CONFIG_NODE, |
18029 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
18030 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
18031 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
18032 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
18033 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
18034 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
18035 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 18036 | } |