]>
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_send_recv = 5; |
db45f64d DS |
4533 | char *peer_str = argv[1]->arg; |
4534 | struct peer *peer; | |
4535 | afi_t afi = bgp_node_afi(vty); | |
4536 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 4537 | |
db45f64d DS |
4538 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4539 | if (!peer) | |
d62a17ae | 4540 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4541 | |
db45f64d DS |
4542 | if (strmatch(argv[idx_send_recv]->text, "send")) |
4543 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4544 | PEER_FLAG_ORF_PREFIX_SM); | |
4545 | ||
4546 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4547 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4548 | PEER_FLAG_ORF_PREFIX_RM); | |
4549 | ||
4550 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
4551 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4552 | PEER_FLAG_ORF_PREFIX_SM) | |
4553 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4554 | PEER_FLAG_ORF_PREFIX_RM); | |
4555 | ||
4556 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4557 | } |
4558 | ||
4559 | ALIAS_HIDDEN( | |
4560 | neighbor_capability_orf_prefix, | |
4561 | neighbor_capability_orf_prefix_hidden_cmd, | |
4562 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4563 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4564 | "Advertise capability to the peer\n" | |
4565 | "Advertise ORF capability to the peer\n" | |
4566 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4567 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4568 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4569 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4570 | |
718e3744 | 4571 | DEFUN (no_neighbor_capability_orf_prefix, |
4572 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4573 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4574 | NO_STR |
4575 | NEIGHBOR_STR | |
4576 | NEIGHBOR_ADDR_STR2 | |
4577 | "Advertise capability to the peer\n" | |
4578 | "Advertise ORF capability to the peer\n" | |
4579 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4580 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4581 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4582 | "Capability to SEND the ORF to this neighbor\n") | |
4583 | { | |
d62a17ae | 4584 | int idx_send_recv = 6; |
db45f64d DS |
4585 | char *peer_str = argv[2]->arg; |
4586 | struct peer *peer; | |
4587 | afi_t afi = bgp_node_afi(vty); | |
4588 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 4589 | |
db45f64d DS |
4590 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4591 | if (!peer) | |
d62a17ae | 4592 | return CMD_WARNING_CONFIG_FAILED; |
d62a17ae | 4593 | |
db45f64d DS |
4594 | if (strmatch(argv[idx_send_recv]->text, "send")) |
4595 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4596 | PEER_FLAG_ORF_PREFIX_SM); | |
4597 | ||
4598 | if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4599 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4600 | PEER_FLAG_ORF_PREFIX_RM); | |
4601 | ||
4602 | if (strmatch(argv[idx_send_recv]->text, "both")) | |
4603 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4604 | PEER_FLAG_ORF_PREFIX_SM) | |
4605 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4606 | PEER_FLAG_ORF_PREFIX_RM); | |
4607 | ||
4608 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4609 | } |
4610 | ||
4611 | ALIAS_HIDDEN( | |
4612 | no_neighbor_capability_orf_prefix, | |
4613 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4614 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4615 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4616 | "Advertise capability to the peer\n" | |
4617 | "Advertise ORF capability to the peer\n" | |
4618 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4619 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4620 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4621 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4622 | |
718e3744 | 4623 | /* neighbor next-hop-self. */ |
4624 | DEFUN (neighbor_nexthop_self, | |
4625 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4626 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4627 | NEIGHBOR_STR |
4628 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4629 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4630 | { |
d62a17ae | 4631 | int idx_peer = 1; |
4632 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4633 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4634 | } |
9e7a53c1 | 4635 | |
d62a17ae | 4636 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4637 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4638 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4639 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4640 | |
a538debe DS |
4641 | /* neighbor next-hop-self. */ |
4642 | DEFUN (neighbor_nexthop_self_force, | |
4643 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4644 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4645 | NEIGHBOR_STR |
4646 | NEIGHBOR_ADDR_STR2 | |
4647 | "Disable the next hop calculation for this neighbor\n" | |
4648 | "Set the next hop to self for reflected routes\n") | |
4649 | { | |
d62a17ae | 4650 | int idx_peer = 1; |
4651 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4652 | bgp_node_safi(vty), | |
4653 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4654 | } |
4655 | ||
d62a17ae | 4656 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4657 | neighbor_nexthop_self_force_hidden_cmd, | |
4658 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4659 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4660 | "Disable the next hop calculation for this neighbor\n" | |
4661 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4662 | |
1bc4e531 DA |
4663 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4664 | neighbor_nexthop_self_all_hidden_cmd, | |
4665 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4666 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4667 | "Disable the next hop calculation for this neighbor\n" | |
4668 | "Set the next hop to self for reflected routes\n") | |
4669 | ||
718e3744 | 4670 | DEFUN (no_neighbor_nexthop_self, |
4671 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4672 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4673 | NO_STR |
4674 | NEIGHBOR_STR | |
4675 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4676 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4677 | { |
d62a17ae | 4678 | int idx_peer = 2; |
4679 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4680 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4681 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4682 | } |
6b0655a2 | 4683 | |
d62a17ae | 4684 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4685 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4686 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4687 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4688 | |
88b8ed8d | 4689 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4690 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4692 | NO_STR |
4693 | NEIGHBOR_STR | |
4694 | NEIGHBOR_ADDR_STR2 | |
4695 | "Disable the next hop calculation for this neighbor\n" | |
4696 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4697 | { |
d62a17ae | 4698 | int idx_peer = 2; |
4699 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4700 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4701 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4702 | } |
a538debe | 4703 | |
d62a17ae | 4704 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4705 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4706 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4707 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4708 | "Disable the next hop calculation for this neighbor\n" | |
4709 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4710 | |
1bc4e531 DA |
4711 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4712 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4713 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4714 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4715 | "Disable the next hop calculation for this neighbor\n" | |
4716 | "Set the next hop to self for reflected routes\n") | |
4717 | ||
c7122e14 DS |
4718 | /* neighbor as-override */ |
4719 | DEFUN (neighbor_as_override, | |
4720 | neighbor_as_override_cmd, | |
9ccf14f7 | 4721 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4722 | NEIGHBOR_STR |
4723 | NEIGHBOR_ADDR_STR2 | |
4724 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4725 | { | |
d62a17ae | 4726 | int idx_peer = 1; |
4727 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4728 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4729 | } |
4730 | ||
d62a17ae | 4731 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4732 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4733 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4734 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4735 | |
c7122e14 DS |
4736 | DEFUN (no_neighbor_as_override, |
4737 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4738 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4739 | NO_STR |
4740 | NEIGHBOR_STR | |
4741 | NEIGHBOR_ADDR_STR2 | |
4742 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4743 | { | |
d62a17ae | 4744 | int idx_peer = 2; |
4745 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4746 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4747 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4748 | } |
4749 | ||
d62a17ae | 4750 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4751 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4752 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4753 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4754 | |
718e3744 | 4755 | /* neighbor remove-private-AS. */ |
4756 | DEFUN (neighbor_remove_private_as, | |
4757 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4758 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4759 | NEIGHBOR_STR |
4760 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4761 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4762 | { |
d62a17ae | 4763 | int idx_peer = 1; |
4764 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4765 | bgp_node_safi(vty), | |
4766 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4767 | } |
4768 | ||
d62a17ae | 4769 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4770 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4771 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4772 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4773 | |
5000f21c DS |
4774 | DEFUN (neighbor_remove_private_as_all, |
4775 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4776 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4777 | NEIGHBOR_STR |
4778 | NEIGHBOR_ADDR_STR2 | |
4779 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4780 | "Apply to all AS numbers\n") |
5000f21c | 4781 | { |
d62a17ae | 4782 | int idx_peer = 1; |
4783 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4784 | bgp_node_safi(vty), | |
4785 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4786 | } |
4787 | ||
d62a17ae | 4788 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4789 | neighbor_remove_private_as_all_hidden_cmd, | |
4790 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4791 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4792 | "Remove private ASNs in outbound updates\n" | |
4793 | "Apply to all AS numbers") | |
596c17ba | 4794 | |
5000f21c DS |
4795 | DEFUN (neighbor_remove_private_as_replace_as, |
4796 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4797 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4798 | NEIGHBOR_STR |
4799 | NEIGHBOR_ADDR_STR2 | |
4800 | "Remove private ASNs in outbound updates\n" | |
4801 | "Replace private ASNs with our ASN in outbound updates\n") | |
4802 | { | |
d62a17ae | 4803 | int idx_peer = 1; |
4804 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4805 | bgp_node_safi(vty), | |
4806 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4807 | } |
4808 | ||
d62a17ae | 4809 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4810 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4811 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4812 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4813 | "Remove private ASNs in outbound updates\n" | |
4814 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4815 | |
5000f21c DS |
4816 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4817 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4818 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4819 | NEIGHBOR_STR |
4820 | NEIGHBOR_ADDR_STR2 | |
4821 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4822 | "Apply to all AS numbers\n" |
5000f21c DS |
4823 | "Replace private ASNs with our ASN in outbound updates\n") |
4824 | { | |
d62a17ae | 4825 | int idx_peer = 1; |
4826 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4827 | bgp_node_safi(vty), | |
4828 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4829 | } |
4830 | ||
d62a17ae | 4831 | ALIAS_HIDDEN( |
4832 | neighbor_remove_private_as_all_replace_as, | |
4833 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4834 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4835 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4836 | "Remove private ASNs in outbound updates\n" | |
4837 | "Apply to all AS numbers\n" | |
4838 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4839 | |
718e3744 | 4840 | DEFUN (no_neighbor_remove_private_as, |
4841 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4842 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4843 | NO_STR |
4844 | NEIGHBOR_STR | |
4845 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4846 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4847 | { |
d62a17ae | 4848 | int idx_peer = 2; |
4849 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4850 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4851 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4852 | } |
6b0655a2 | 4853 | |
d62a17ae | 4854 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4855 | no_neighbor_remove_private_as_hidden_cmd, | |
4856 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4857 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4858 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4859 | |
88b8ed8d | 4860 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4861 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4862 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4863 | NO_STR |
4864 | NEIGHBOR_STR | |
4865 | NEIGHBOR_ADDR_STR2 | |
4866 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4867 | "Apply to all AS numbers\n") |
88b8ed8d | 4868 | { |
d62a17ae | 4869 | int idx_peer = 2; |
4870 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4871 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4872 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4873 | } |
5000f21c | 4874 | |
d62a17ae | 4875 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4876 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4877 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4878 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4879 | "Remove private ASNs in outbound updates\n" | |
4880 | "Apply to all AS numbers\n") | |
596c17ba | 4881 | |
88b8ed8d | 4882 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4883 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4885 | NO_STR |
4886 | NEIGHBOR_STR | |
4887 | NEIGHBOR_ADDR_STR2 | |
4888 | "Remove private ASNs in outbound updates\n" | |
4889 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4890 | { |
d62a17ae | 4891 | int idx_peer = 2; |
4892 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4893 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4894 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4895 | } |
5000f21c | 4896 | |
d62a17ae | 4897 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4898 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4899 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4900 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4901 | "Remove private ASNs in outbound updates\n" | |
4902 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4903 | |
88b8ed8d | 4904 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4905 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4907 | NO_STR |
4908 | NEIGHBOR_STR | |
4909 | NEIGHBOR_ADDR_STR2 | |
4910 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4911 | "Apply to all AS numbers\n" |
5000f21c | 4912 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4913 | { |
d62a17ae | 4914 | int idx_peer = 2; |
4915 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4916 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4917 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4918 | } |
5000f21c | 4919 | |
d62a17ae | 4920 | ALIAS_HIDDEN( |
4921 | no_neighbor_remove_private_as_all_replace_as, | |
4922 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4923 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4924 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4925 | "Remove private ASNs in outbound updates\n" | |
4926 | "Apply to all AS numbers\n" | |
4927 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4928 | |
5000f21c | 4929 | |
718e3744 | 4930 | /* neighbor send-community. */ |
4931 | DEFUN (neighbor_send_community, | |
4932 | neighbor_send_community_cmd, | |
9ccf14f7 | 4933 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4934 | NEIGHBOR_STR |
4935 | NEIGHBOR_ADDR_STR2 | |
4936 | "Send Community attribute to this neighbor\n") | |
4937 | { | |
d62a17ae | 4938 | int idx_peer = 1; |
27c05d4d | 4939 | |
d62a17ae | 4940 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4941 | bgp_node_safi(vty), | |
4942 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4943 | } |
4944 | ||
d62a17ae | 4945 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4946 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4947 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4948 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4949 | |
718e3744 | 4950 | DEFUN (no_neighbor_send_community, |
4951 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4952 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4953 | NO_STR |
4954 | NEIGHBOR_STR | |
4955 | NEIGHBOR_ADDR_STR2 | |
4956 | "Send Community attribute to this neighbor\n") | |
4957 | { | |
d62a17ae | 4958 | int idx_peer = 2; |
27c05d4d | 4959 | |
d62a17ae | 4960 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4961 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4962 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4963 | } |
6b0655a2 | 4964 | |
d62a17ae | 4965 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4966 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4967 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4968 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4969 | |
718e3744 | 4970 | /* neighbor send-community extended. */ |
4971 | DEFUN (neighbor_send_community_type, | |
4972 | neighbor_send_community_type_cmd, | |
57d187bc | 4973 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4974 | NEIGHBOR_STR |
4975 | NEIGHBOR_ADDR_STR2 | |
4976 | "Send Community attribute to this neighbor\n" | |
4977 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4978 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4979 | "Send Extended Community attributes\n" |
57d187bc JS |
4980 | "Send Standard Community attributes\n" |
4981 | "Send Large Community attributes\n") | |
718e3744 | 4982 | { |
27c05d4d | 4983 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
4984 | char *peer_str = argv[1]->arg; |
4985 | struct peer *peer; | |
4986 | afi_t afi = bgp_node_afi(vty); | |
4987 | safi_t safi = bgp_node_safi(vty); | |
d62a17ae | 4988 | |
db45f64d DS |
4989 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4990 | if (!peer) | |
4991 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4992 | |
db45f64d DS |
4993 | if (strmatch(type, "standard")) |
4994 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4995 | PEER_FLAG_SEND_COMMUNITY); | |
4996 | ||
4997 | if (strmatch(type, "extended")) | |
4998 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
4999 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5000 | ||
5001 | if (strmatch(type, "large")) | |
5002 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5003 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5004 | ||
5005 | if (strmatch(type, "both")) { | |
5006 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5007 | PEER_FLAG_SEND_COMMUNITY) | |
5008 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5009 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5010 | } | |
5011 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5012 | PEER_FLAG_SEND_COMMUNITY) | |
5013 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5014 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5015 | | peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5016 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5017 | } |
5018 | ||
5019 | ALIAS_HIDDEN( | |
5020 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
5021 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5022 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5023 | "Send Community attribute to this neighbor\n" | |
5024 | "Send Standard and Extended Community attributes\n" | |
5025 | "Send Standard, Large and Extended Community attributes\n" | |
5026 | "Send Extended Community attributes\n" | |
5027 | "Send Standard Community attributes\n" | |
5028 | "Send Large Community attributes\n") | |
596c17ba | 5029 | |
718e3744 | 5030 | DEFUN (no_neighbor_send_community_type, |
5031 | no_neighbor_send_community_type_cmd, | |
57d187bc | 5032 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 5033 | NO_STR |
5034 | NEIGHBOR_STR | |
5035 | NEIGHBOR_ADDR_STR2 | |
5036 | "Send Community attribute to this neighbor\n" | |
5037 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 5038 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 5039 | "Send Extended Community attributes\n" |
57d187bc JS |
5040 | "Send Standard Community attributes\n" |
5041 | "Send Large Community attributes\n") | |
718e3744 | 5042 | { |
d62a17ae | 5043 | const char *type = argv[argc - 1]->text; |
db45f64d DS |
5044 | char *peer_str = argv[2]->arg; |
5045 | struct peer *peer; | |
5046 | afi_t afi = bgp_node_afi(vty); | |
5047 | safi_t safi = bgp_node_safi(vty); | |
5048 | ||
5049 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5050 | if (!peer) | |
5051 | return CMD_WARNING_CONFIG_FAILED; | |
5052 | ||
5053 | if (strmatch(type, "standard")) | |
5054 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5055 | PEER_FLAG_SEND_COMMUNITY); | |
5056 | ||
5057 | if (strmatch(type, "extended")) | |
5058 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5059 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
5060 | ||
5061 | if (strmatch(type, "large")) | |
5062 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5063 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5064 | ||
5065 | if (strmatch(type, "both")) { | |
d62a17ae | 5066 | |
db45f64d DS |
5067 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5068 | PEER_FLAG_SEND_COMMUNITY) | |
5069 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5070 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d PM |
5071 | } |
5072 | ||
db45f64d DS |
5073 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5074 | PEER_FLAG_SEND_COMMUNITY) | |
5075 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5076 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
5077 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5078 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
d62a17ae | 5079 | } |
5080 | ||
5081 | ALIAS_HIDDEN( | |
5082 | no_neighbor_send_community_type, | |
5083 | no_neighbor_send_community_type_hidden_cmd, | |
5084 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5085 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5086 | "Send Community attribute to this neighbor\n" | |
5087 | "Send Standard and Extended Community attributes\n" | |
5088 | "Send Standard, Large and Extended Community attributes\n" | |
5089 | "Send Extended Community attributes\n" | |
5090 | "Send Standard Community attributes\n" | |
5091 | "Send Large Community attributes\n") | |
596c17ba | 5092 | |
718e3744 | 5093 | /* neighbor soft-reconfig. */ |
5094 | DEFUN (neighbor_soft_reconfiguration, | |
5095 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5096 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5097 | NEIGHBOR_STR |
5098 | NEIGHBOR_ADDR_STR2 | |
5099 | "Per neighbor soft reconfiguration\n" | |
5100 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5101 | { | |
d62a17ae | 5102 | int idx_peer = 1; |
5103 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5104 | bgp_node_safi(vty), | |
5105 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5106 | } |
5107 | ||
d62a17ae | 5108 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5109 | neighbor_soft_reconfiguration_hidden_cmd, | |
5110 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5111 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5112 | "Per neighbor soft reconfiguration\n" | |
5113 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5114 | |
718e3744 | 5115 | DEFUN (no_neighbor_soft_reconfiguration, |
5116 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5117 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5118 | NO_STR |
5119 | NEIGHBOR_STR | |
5120 | NEIGHBOR_ADDR_STR2 | |
5121 | "Per neighbor soft reconfiguration\n" | |
5122 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5123 | { | |
d62a17ae | 5124 | int idx_peer = 2; |
5125 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5126 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5127 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5128 | } |
6b0655a2 | 5129 | |
d62a17ae | 5130 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5131 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5132 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5133 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5134 | "Per neighbor soft reconfiguration\n" | |
5135 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5136 | |
718e3744 | 5137 | DEFUN (neighbor_route_reflector_client, |
5138 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5139 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5140 | NEIGHBOR_STR |
5141 | NEIGHBOR_ADDR_STR2 | |
5142 | "Configure a neighbor as Route Reflector client\n") | |
5143 | { | |
d62a17ae | 5144 | int idx_peer = 1; |
5145 | struct peer *peer; | |
718e3744 | 5146 | |
5147 | ||
d62a17ae | 5148 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5149 | if (!peer) | |
5150 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5151 | |
d62a17ae | 5152 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5153 | bgp_node_safi(vty), | |
5154 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5155 | } |
5156 | ||
d62a17ae | 5157 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5158 | neighbor_route_reflector_client_hidden_cmd, | |
5159 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5160 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5161 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5162 | |
718e3744 | 5163 | DEFUN (no_neighbor_route_reflector_client, |
5164 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5165 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5166 | NO_STR |
5167 | NEIGHBOR_STR | |
5168 | NEIGHBOR_ADDR_STR2 | |
5169 | "Configure a neighbor as Route Reflector client\n") | |
5170 | { | |
d62a17ae | 5171 | int idx_peer = 2; |
5172 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5173 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5174 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5175 | } |
6b0655a2 | 5176 | |
d62a17ae | 5177 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5178 | no_neighbor_route_reflector_client_hidden_cmd, | |
5179 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5180 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5181 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5182 | |
718e3744 | 5183 | /* neighbor route-server-client. */ |
5184 | DEFUN (neighbor_route_server_client, | |
5185 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5186 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5187 | NEIGHBOR_STR |
5188 | NEIGHBOR_ADDR_STR2 | |
5189 | "Configure a neighbor as Route Server client\n") | |
5190 | { | |
d62a17ae | 5191 | int idx_peer = 1; |
5192 | struct peer *peer; | |
2a3d5731 | 5193 | |
d62a17ae | 5194 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5195 | if (!peer) | |
5196 | return CMD_WARNING_CONFIG_FAILED; | |
5197 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5198 | bgp_node_safi(vty), | |
5199 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5200 | } |
5201 | ||
d62a17ae | 5202 | ALIAS_HIDDEN(neighbor_route_server_client, |
5203 | neighbor_route_server_client_hidden_cmd, | |
5204 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5205 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5206 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5207 | |
718e3744 | 5208 | DEFUN (no_neighbor_route_server_client, |
5209 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5210 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5211 | NO_STR |
5212 | NEIGHBOR_STR | |
5213 | NEIGHBOR_ADDR_STR2 | |
5214 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5215 | { |
d62a17ae | 5216 | int idx_peer = 2; |
5217 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5218 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5219 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5220 | } |
6b0655a2 | 5221 | |
d62a17ae | 5222 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5223 | no_neighbor_route_server_client_hidden_cmd, | |
5224 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5225 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5226 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5227 | |
fee0f4c6 | 5228 | DEFUN (neighbor_nexthop_local_unchanged, |
5229 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5230 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5231 | NEIGHBOR_STR |
5232 | NEIGHBOR_ADDR_STR2 | |
5233 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5234 | "Leave link-local nexthop unchanged for this peer\n") | |
5235 | { | |
d62a17ae | 5236 | int idx_peer = 1; |
5237 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5238 | bgp_node_safi(vty), | |
5239 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5240 | } |
6b0655a2 | 5241 | |
fee0f4c6 | 5242 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5243 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5244 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5245 | NO_STR |
5246 | NEIGHBOR_STR | |
5247 | NEIGHBOR_ADDR_STR2 | |
5248 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5249 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5250 | { |
d62a17ae | 5251 | int idx_peer = 2; |
5252 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5253 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5254 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5255 | } |
6b0655a2 | 5256 | |
718e3744 | 5257 | DEFUN (neighbor_attr_unchanged, |
5258 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5259 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5260 | NEIGHBOR_STR |
5261 | NEIGHBOR_ADDR_STR2 | |
5262 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5263 | "As-path attribute\n" | |
5264 | "Nexthop attribute\n" | |
a8206004 | 5265 | "Med attribute\n") |
718e3744 | 5266 | { |
d62a17ae | 5267 | int idx = 0; |
8eeb0335 DW |
5268 | char *peer_str = argv[1]->arg; |
5269 | struct peer *peer; | |
db45f64d DS |
5270 | bool aspath = false; |
5271 | bool nexthop = false; | |
5272 | bool med = false; | |
8eeb0335 DW |
5273 | afi_t afi = bgp_node_afi(vty); |
5274 | safi_t safi = bgp_node_safi(vty); | |
db45f64d | 5275 | int ret = 0; |
8eeb0335 DW |
5276 | |
5277 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5278 | if (!peer) | |
5279 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5280 | |
5281 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5282 | aspath = true; |
5283 | ||
d62a17ae | 5284 | idx = 0; |
5285 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5286 | nexthop = true; |
5287 | ||
d62a17ae | 5288 | idx = 0; |
5289 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5290 | med = true; |
d62a17ae | 5291 | |
8eeb0335 | 5292 | /* no flags means all of them! */ |
db45f64d DS |
5293 | if (!aspath && !nexthop && !med) { |
5294 | ret = peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5295 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5296 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5297 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5298 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5299 | PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5300 | } else { |
db45f64d DS |
5301 | if (!aspath) { |
5302 | if (peer_af_flag_check(peer, afi, safi, | |
5303 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
5304 | ret |= peer_af_flag_unset_vty( | |
5305 | vty, peer_str, afi, safi, | |
5306 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5307 | } | |
5308 | } else | |
5309 | ret |= peer_af_flag_set_vty( | |
5310 | vty, peer_str, afi, safi, | |
5311 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5312 | ||
5313 | if (!nexthop) { | |
5314 | if (peer_af_flag_check(peer, afi, safi, | |
5315 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
5316 | ret |= peer_af_flag_unset_vty( | |
5317 | vty, peer_str, afi, safi, | |
5318 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5319 | } | |
5320 | } else | |
5321 | ret |= peer_af_flag_set_vty( | |
5322 | vty, peer_str, afi, safi, | |
5323 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5324 | ||
5325 | if (!med) { | |
5326 | if (peer_af_flag_check(peer, afi, safi, | |
5327 | PEER_FLAG_MED_UNCHANGED)) { | |
5328 | ret |= peer_af_flag_unset_vty( | |
5329 | vty, peer_str, afi, safi, | |
5330 | PEER_FLAG_MED_UNCHANGED); | |
5331 | } | |
5332 | } else | |
5333 | ret |= peer_af_flag_set_vty(vty, peer_str, afi, safi, | |
5334 | PEER_FLAG_MED_UNCHANGED); | |
d62a17ae | 5335 | } |
5336 | ||
db45f64d | 5337 | return ret; |
d62a17ae | 5338 | } |
5339 | ||
5340 | ALIAS_HIDDEN( | |
5341 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5342 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5343 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5344 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5345 | "As-path attribute\n" | |
5346 | "Nexthop attribute\n" | |
5347 | "Med attribute\n") | |
596c17ba | 5348 | |
718e3744 | 5349 | DEFUN (no_neighbor_attr_unchanged, |
5350 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5351 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5352 | NO_STR |
718e3744 | 5353 | NEIGHBOR_STR |
5354 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5355 | "BGP attribute is propagated unchanged to this neighbor\n" |
5356 | "As-path attribute\n" | |
40e718b5 | 5357 | "Nexthop attribute\n" |
a8206004 | 5358 | "Med attribute\n") |
718e3744 | 5359 | { |
d62a17ae | 5360 | int idx = 0; |
db45f64d DS |
5361 | char *peer_str = argv[2]->arg; |
5362 | struct peer *peer; | |
5363 | bool aspath = false; | |
5364 | bool nexthop = false; | |
5365 | bool med = false; | |
5366 | afi_t afi = bgp_node_afi(vty); | |
5367 | safi_t safi = bgp_node_safi(vty); | |
5368 | int ret = 0; | |
5369 | ||
5370 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5371 | if (!peer) | |
5372 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5373 | |
5374 | if (argv_find(argv, argc, "as-path", &idx)) | |
db45f64d DS |
5375 | aspath = true; |
5376 | ||
d62a17ae | 5377 | idx = 0; |
5378 | if (argv_find(argv, argc, "next-hop", &idx)) | |
db45f64d DS |
5379 | nexthop = true; |
5380 | ||
d62a17ae | 5381 | idx = 0; |
5382 | if (argv_find(argv, argc, "med", &idx)) | |
db45f64d | 5383 | med = true; |
d62a17ae | 5384 | |
db45f64d DS |
5385 | if (!aspath && !nexthop && !med) // no flags means all of them! |
5386 | return peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5387 | PEER_FLAG_AS_PATH_UNCHANGED) | |
5388 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5389 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
5390 | | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5391 | PEER_FLAG_MED_UNCHANGED); | |
5392 | ||
5393 | if (aspath) | |
5394 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5395 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5396 | ||
5397 | if (nexthop) | |
5398 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5399 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
d62a17ae | 5400 | |
db45f64d DS |
5401 | if (med) |
5402 | ret |= peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
5403 | PEER_FLAG_MED_UNCHANGED); | |
5404 | ||
5405 | return ret; | |
d62a17ae | 5406 | } |
5407 | ||
5408 | ALIAS_HIDDEN( | |
5409 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5410 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5411 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5412 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5413 | "As-path attribute\n" | |
5414 | "Nexthop attribute\n" | |
5415 | "Med attribute\n") | |
718e3744 | 5416 | |
718e3744 | 5417 | /* EBGP multihop configuration. */ |
d62a17ae | 5418 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5419 | const char *ttl_str) | |
718e3744 | 5420 | { |
d62a17ae | 5421 | struct peer *peer; |
5422 | unsigned int ttl; | |
718e3744 | 5423 | |
d62a17ae | 5424 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5425 | if (!peer) | |
5426 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5427 | |
d62a17ae | 5428 | if (peer->conf_if) |
5429 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5430 | |
d62a17ae | 5431 | if (!ttl_str) |
5432 | ttl = MAXTTL; | |
5433 | else | |
5434 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5435 | |
d62a17ae | 5436 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5437 | } |
5438 | ||
d62a17ae | 5439 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5440 | { |
d62a17ae | 5441 | struct peer *peer; |
718e3744 | 5442 | |
d62a17ae | 5443 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5444 | if (!peer) | |
5445 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5446 | |
d62a17ae | 5447 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5448 | } |
5449 | ||
5450 | /* neighbor ebgp-multihop. */ | |
5451 | DEFUN (neighbor_ebgp_multihop, | |
5452 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5453 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5454 | NEIGHBOR_STR |
5455 | NEIGHBOR_ADDR_STR2 | |
5456 | "Allow EBGP neighbors not on directly connected networks\n") | |
5457 | { | |
d62a17ae | 5458 | int idx_peer = 1; |
5459 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5460 | } |
5461 | ||
5462 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5463 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5464 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5465 | NEIGHBOR_STR |
5466 | NEIGHBOR_ADDR_STR2 | |
5467 | "Allow EBGP neighbors not on directly connected networks\n" | |
5468 | "maximum hop count\n") | |
5469 | { | |
d62a17ae | 5470 | int idx_peer = 1; |
5471 | int idx_number = 3; | |
5472 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5473 | argv[idx_number]->arg); | |
718e3744 | 5474 | } |
5475 | ||
5476 | DEFUN (no_neighbor_ebgp_multihop, | |
5477 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5479 | NO_STR |
5480 | NEIGHBOR_STR | |
5481 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5482 | "Allow EBGP neighbors not on directly connected networks\n" |
5483 | "maximum hop count\n") | |
718e3744 | 5484 | { |
d62a17ae | 5485 | int idx_peer = 2; |
5486 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5487 | } |
5488 | ||
6b0655a2 | 5489 | |
6ffd2079 | 5490 | /* disable-connected-check */ |
5491 | DEFUN (neighbor_disable_connected_check, | |
5492 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5493 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5494 | NEIGHBOR_STR |
7ebe625c | 5495 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5496 | "one-hop away EBGP peer using loopback address\n" |
5497 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5498 | { |
d62a17ae | 5499 | int idx_peer = 1; |
5500 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5501 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5502 | } |
5503 | ||
5504 | DEFUN (no_neighbor_disable_connected_check, | |
5505 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5506 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5507 | NO_STR |
5508 | NEIGHBOR_STR | |
7ebe625c | 5509 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5510 | "one-hop away EBGP peer using loopback address\n" |
5511 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5512 | { |
d62a17ae | 5513 | int idx_peer = 2; |
5514 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5515 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5516 | } |
5517 | ||
47cbc09b PM |
5518 | |
5519 | /* enforce-first-as */ | |
5520 | DEFUN (neighbor_enforce_first_as, | |
5521 | neighbor_enforce_first_as_cmd, | |
5522 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5523 | NEIGHBOR_STR | |
5524 | NEIGHBOR_ADDR_STR2 | |
5525 | "Enforce the first AS for EBGP routes\n") | |
5526 | { | |
5527 | int idx_peer = 1; | |
5528 | ||
5529 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5530 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5531 | } | |
5532 | ||
5533 | DEFUN (no_neighbor_enforce_first_as, | |
5534 | no_neighbor_enforce_first_as_cmd, | |
5535 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5536 | NO_STR | |
5537 | NEIGHBOR_STR | |
5538 | NEIGHBOR_ADDR_STR2 | |
5539 | "Enforce the first AS for EBGP routes\n") | |
5540 | { | |
5541 | int idx_peer = 2; | |
5542 | ||
5543 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5544 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5545 | } | |
5546 | ||
5547 | ||
718e3744 | 5548 | DEFUN (neighbor_description, |
5549 | neighbor_description_cmd, | |
e961923c | 5550 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5551 | NEIGHBOR_STR |
5552 | NEIGHBOR_ADDR_STR2 | |
5553 | "Neighbor specific description\n" | |
5554 | "Up to 80 characters describing this neighbor\n") | |
5555 | { | |
d62a17ae | 5556 | int idx_peer = 1; |
5557 | int idx_line = 3; | |
5558 | struct peer *peer; | |
5559 | char *str; | |
718e3744 | 5560 | |
d62a17ae | 5561 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5562 | if (!peer) | |
5563 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5564 | |
d62a17ae | 5565 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5566 | |
d62a17ae | 5567 | peer_description_set(peer, str); |
718e3744 | 5568 | |
d62a17ae | 5569 | XFREE(MTYPE_TMP, str); |
718e3744 | 5570 | |
d62a17ae | 5571 | return CMD_SUCCESS; |
718e3744 | 5572 | } |
5573 | ||
5574 | DEFUN (no_neighbor_description, | |
5575 | no_neighbor_description_cmd, | |
a14810f4 | 5576 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5577 | NO_STR |
5578 | NEIGHBOR_STR | |
5579 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5580 | "Neighbor specific description\n") |
718e3744 | 5581 | { |
d62a17ae | 5582 | int idx_peer = 2; |
5583 | struct peer *peer; | |
718e3744 | 5584 | |
d62a17ae | 5585 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5586 | if (!peer) | |
5587 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5588 | |
d62a17ae | 5589 | peer_description_unset(peer); |
718e3744 | 5590 | |
d62a17ae | 5591 | return CMD_SUCCESS; |
718e3744 | 5592 | } |
5593 | ||
a14810f4 PM |
5594 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5595 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5596 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5597 | "Neighbor specific description\n" | |
5598 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5599 | |
718e3744 | 5600 | /* Neighbor update-source. */ |
d62a17ae | 5601 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5602 | const char *source_str) | |
5603 | { | |
5604 | struct peer *peer; | |
5605 | struct prefix p; | |
a14810f4 | 5606 | union sockunion su; |
d62a17ae | 5607 | |
5608 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5609 | if (!peer) | |
5610 | return CMD_WARNING_CONFIG_FAILED; | |
5611 | ||
5612 | if (peer->conf_if) | |
5613 | return CMD_WARNING; | |
5614 | ||
5615 | if (source_str) { | |
a14810f4 | 5616 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5617 | peer_update_source_addr_set(peer, &su); |
5618 | else { | |
5619 | if (str2prefix(source_str, &p)) { | |
5620 | vty_out(vty, | |
5621 | "%% Invalid update-source, remove prefix length \n"); | |
5622 | return CMD_WARNING_CONFIG_FAILED; | |
5623 | } else | |
5624 | peer_update_source_if_set(peer, source_str); | |
5625 | } | |
5626 | } else | |
5627 | peer_update_source_unset(peer); | |
5628 | ||
5629 | return CMD_SUCCESS; | |
5630 | } | |
5631 | ||
5632 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5633 | "IPv4 address\n" \ | |
5634 | "IPv6 address\n" \ | |
5635 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5636 | |
718e3744 | 5637 | DEFUN (neighbor_update_source, |
5638 | neighbor_update_source_cmd, | |
9ccf14f7 | 5639 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5640 | NEIGHBOR_STR |
5641 | NEIGHBOR_ADDR_STR2 | |
5642 | "Source of routing updates\n" | |
369688c0 | 5643 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5644 | { |
d62a17ae | 5645 | int idx_peer = 1; |
5646 | int idx_peer_2 = 3; | |
5647 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5648 | argv[idx_peer_2]->arg); | |
718e3744 | 5649 | } |
5650 | ||
5651 | DEFUN (no_neighbor_update_source, | |
5652 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5653 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5654 | NO_STR |
5655 | NEIGHBOR_STR | |
5656 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5657 | "Source of routing updates\n" |
5658 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5659 | { |
d62a17ae | 5660 | int idx_peer = 2; |
5661 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5662 | } |
6b0655a2 | 5663 | |
d62a17ae | 5664 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5665 | afi_t afi, safi_t safi, | |
5666 | const char *rmap, int set) | |
718e3744 | 5667 | { |
d62a17ae | 5668 | int ret; |
5669 | struct peer *peer; | |
80912664 | 5670 | struct route_map *route_map = NULL; |
718e3744 | 5671 | |
d62a17ae | 5672 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5673 | if (!peer) | |
5674 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5675 | |
1de27621 | 5676 | if (set) { |
80912664 DS |
5677 | if (rmap) |
5678 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5679 | ret = peer_default_originate_set(peer, afi, safi, |
5680 | rmap, route_map); | |
5681 | } else | |
d62a17ae | 5682 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5683 | |
d62a17ae | 5684 | return bgp_vty_return(vty, ret); |
718e3744 | 5685 | } |
5686 | ||
5687 | /* neighbor default-originate. */ | |
5688 | DEFUN (neighbor_default_originate, | |
5689 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5690 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5691 | NEIGHBOR_STR |
5692 | NEIGHBOR_ADDR_STR2 | |
5693 | "Originate default route to this neighbor\n") | |
5694 | { | |
d62a17ae | 5695 | int idx_peer = 1; |
5696 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5697 | bgp_node_afi(vty), | |
5698 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5699 | } |
5700 | ||
d62a17ae | 5701 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5702 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5703 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5704 | "Originate default route to this neighbor\n") | |
596c17ba | 5705 | |
718e3744 | 5706 | DEFUN (neighbor_default_originate_rmap, |
5707 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5708 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5709 | NEIGHBOR_STR |
5710 | NEIGHBOR_ADDR_STR2 | |
5711 | "Originate default route to this neighbor\n" | |
5712 | "Route-map to specify criteria to originate default\n" | |
5713 | "route-map name\n") | |
5714 | { | |
d62a17ae | 5715 | int idx_peer = 1; |
5716 | int idx_word = 4; | |
5717 | return peer_default_originate_set_vty( | |
5718 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5719 | argv[idx_word]->arg, 1); | |
718e3744 | 5720 | } |
5721 | ||
d62a17ae | 5722 | ALIAS_HIDDEN( |
5723 | neighbor_default_originate_rmap, | |
5724 | neighbor_default_originate_rmap_hidden_cmd, | |
5725 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5726 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5727 | "Originate default route to this neighbor\n" | |
5728 | "Route-map to specify criteria to originate default\n" | |
5729 | "route-map name\n") | |
596c17ba | 5730 | |
718e3744 | 5731 | DEFUN (no_neighbor_default_originate, |
5732 | no_neighbor_default_originate_cmd, | |
a636c635 | 5733 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5734 | NO_STR |
5735 | NEIGHBOR_STR | |
5736 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5737 | "Originate default route to this neighbor\n" |
5738 | "Route-map to specify criteria to originate default\n" | |
5739 | "route-map name\n") | |
718e3744 | 5740 | { |
d62a17ae | 5741 | int idx_peer = 2; |
5742 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5743 | bgp_node_afi(vty), | |
5744 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5745 | } |
5746 | ||
d62a17ae | 5747 | ALIAS_HIDDEN( |
5748 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5749 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5750 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5751 | "Originate default route to this neighbor\n" | |
5752 | "Route-map to specify criteria to originate default\n" | |
5753 | "route-map name\n") | |
596c17ba | 5754 | |
6b0655a2 | 5755 | |
718e3744 | 5756 | /* Set neighbor's BGP port. */ |
d62a17ae | 5757 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5758 | const char *port_str) | |
5759 | { | |
5760 | struct peer *peer; | |
d7c0a89a | 5761 | uint16_t port; |
d62a17ae | 5762 | struct servent *sp; |
5763 | ||
5764 | peer = peer_lookup_vty(vty, ip_str); | |
5765 | if (!peer) | |
5766 | return CMD_WARNING_CONFIG_FAILED; | |
5767 | ||
5768 | if (!port_str) { | |
5769 | sp = getservbyname("bgp", "tcp"); | |
5770 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5771 | } else { | |
5772 | port = strtoul(port_str, NULL, 10); | |
5773 | } | |
718e3744 | 5774 | |
d62a17ae | 5775 | peer_port_set(peer, port); |
718e3744 | 5776 | |
d62a17ae | 5777 | return CMD_SUCCESS; |
718e3744 | 5778 | } |
5779 | ||
f418446b | 5780 | /* Set specified peer's BGP port. */ |
718e3744 | 5781 | DEFUN (neighbor_port, |
5782 | neighbor_port_cmd, | |
9ccf14f7 | 5783 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5784 | NEIGHBOR_STR |
5785 | NEIGHBOR_ADDR_STR | |
5786 | "Neighbor's BGP port\n" | |
5787 | "TCP port number\n") | |
5788 | { | |
d62a17ae | 5789 | int idx_ip = 1; |
5790 | int idx_number = 3; | |
5791 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5792 | argv[idx_number]->arg); | |
718e3744 | 5793 | } |
5794 | ||
5795 | DEFUN (no_neighbor_port, | |
5796 | no_neighbor_port_cmd, | |
9ccf14f7 | 5797 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5798 | NO_STR |
5799 | NEIGHBOR_STR | |
5800 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5801 | "Neighbor's BGP port\n" |
5802 | "TCP port number\n") | |
718e3744 | 5803 | { |
d62a17ae | 5804 | int idx_ip = 2; |
5805 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5806 | } |
5807 | ||
6b0655a2 | 5808 | |
718e3744 | 5809 | /* neighbor weight. */ |
d62a17ae | 5810 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5811 | safi_t safi, const char *weight_str) | |
718e3744 | 5812 | { |
d62a17ae | 5813 | int ret; |
5814 | struct peer *peer; | |
5815 | unsigned long weight; | |
718e3744 | 5816 | |
d62a17ae | 5817 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5818 | if (!peer) | |
5819 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5820 | |
d62a17ae | 5821 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5822 | |
d62a17ae | 5823 | ret = peer_weight_set(peer, afi, safi, weight); |
5824 | return bgp_vty_return(vty, ret); | |
718e3744 | 5825 | } |
5826 | ||
d62a17ae | 5827 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5828 | safi_t safi) | |
718e3744 | 5829 | { |
d62a17ae | 5830 | int ret; |
5831 | struct peer *peer; | |
718e3744 | 5832 | |
d62a17ae | 5833 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5834 | if (!peer) | |
5835 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5836 | |
d62a17ae | 5837 | ret = peer_weight_unset(peer, afi, safi); |
5838 | return bgp_vty_return(vty, ret); | |
718e3744 | 5839 | } |
5840 | ||
5841 | DEFUN (neighbor_weight, | |
5842 | neighbor_weight_cmd, | |
9ccf14f7 | 5843 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5844 | NEIGHBOR_STR |
5845 | NEIGHBOR_ADDR_STR2 | |
5846 | "Set default weight for routes from this neighbor\n" | |
5847 | "default weight\n") | |
5848 | { | |
d62a17ae | 5849 | int idx_peer = 1; |
5850 | int idx_number = 3; | |
5851 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5852 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5853 | } |
5854 | ||
d62a17ae | 5855 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5856 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5857 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5858 | "Set default weight for routes from this neighbor\n" | |
5859 | "default weight\n") | |
596c17ba | 5860 | |
718e3744 | 5861 | DEFUN (no_neighbor_weight, |
5862 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5863 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5864 | NO_STR |
5865 | NEIGHBOR_STR | |
5866 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5867 | "Set default weight for routes from this neighbor\n" |
5868 | "default weight\n") | |
718e3744 | 5869 | { |
d62a17ae | 5870 | int idx_peer = 2; |
5871 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5872 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5873 | } |
5874 | ||
d62a17ae | 5875 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5876 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5877 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5878 | "Set default weight for routes from this neighbor\n" | |
5879 | "default weight\n") | |
596c17ba | 5880 | |
6b0655a2 | 5881 | |
718e3744 | 5882 | /* Override capability negotiation. */ |
5883 | DEFUN (neighbor_override_capability, | |
5884 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5885 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5886 | NEIGHBOR_STR |
5887 | NEIGHBOR_ADDR_STR2 | |
5888 | "Override capability negotiation result\n") | |
5889 | { | |
d62a17ae | 5890 | int idx_peer = 1; |
5891 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5892 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5893 | } |
5894 | ||
5895 | DEFUN (no_neighbor_override_capability, | |
5896 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5897 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5898 | NO_STR |
5899 | NEIGHBOR_STR | |
5900 | NEIGHBOR_ADDR_STR2 | |
5901 | "Override capability negotiation result\n") | |
5902 | { | |
d62a17ae | 5903 | int idx_peer = 2; |
5904 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5905 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5906 | } |
6b0655a2 | 5907 | |
718e3744 | 5908 | DEFUN (neighbor_strict_capability, |
5909 | neighbor_strict_capability_cmd, | |
9fb964de | 5910 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5911 | NEIGHBOR_STR |
9fb964de | 5912 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5913 | "Strict capability negotiation match\n") |
5914 | { | |
9fb964de PM |
5915 | int idx_peer = 1; |
5916 | ||
5917 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5918 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5919 | } |
5920 | ||
5921 | DEFUN (no_neighbor_strict_capability, | |
5922 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5923 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5924 | NO_STR |
5925 | NEIGHBOR_STR | |
9fb964de | 5926 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5927 | "Strict capability negotiation match\n") |
5928 | { | |
9fb964de PM |
5929 | int idx_peer = 2; |
5930 | ||
5931 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5932 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5933 | } |
6b0655a2 | 5934 | |
d62a17ae | 5935 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5936 | const char *keep_str, const char *hold_str) | |
718e3744 | 5937 | { |
d62a17ae | 5938 | int ret; |
5939 | struct peer *peer; | |
d7c0a89a QY |
5940 | uint32_t keepalive; |
5941 | uint32_t holdtime; | |
718e3744 | 5942 | |
d62a17ae | 5943 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5944 | if (!peer) | |
5945 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5946 | |
d62a17ae | 5947 | keepalive = strtoul(keep_str, NULL, 10); |
5948 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5949 | |
d62a17ae | 5950 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5951 | |
d62a17ae | 5952 | return bgp_vty_return(vty, ret); |
718e3744 | 5953 | } |
6b0655a2 | 5954 | |
d62a17ae | 5955 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5956 | { |
d62a17ae | 5957 | int ret; |
5958 | struct peer *peer; | |
718e3744 | 5959 | |
d62a17ae | 5960 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5961 | if (!peer) | |
5962 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5963 | |
d62a17ae | 5964 | ret = peer_timers_unset(peer); |
718e3744 | 5965 | |
d62a17ae | 5966 | return bgp_vty_return(vty, ret); |
718e3744 | 5967 | } |
5968 | ||
5969 | DEFUN (neighbor_timers, | |
5970 | neighbor_timers_cmd, | |
9ccf14f7 | 5971 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5972 | NEIGHBOR_STR |
5973 | NEIGHBOR_ADDR_STR2 | |
5974 | "BGP per neighbor timers\n" | |
5975 | "Keepalive interval\n" | |
5976 | "Holdtime\n") | |
5977 | { | |
d62a17ae | 5978 | int idx_peer = 1; |
5979 | int idx_number = 3; | |
5980 | int idx_number_2 = 4; | |
5981 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5982 | argv[idx_number]->arg, | |
5983 | argv[idx_number_2]->arg); | |
718e3744 | 5984 | } |
5985 | ||
5986 | DEFUN (no_neighbor_timers, | |
5987 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5988 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5989 | NO_STR |
5990 | NEIGHBOR_STR | |
5991 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5992 | "BGP per neighbor timers\n" |
5993 | "Keepalive interval\n" | |
5994 | "Holdtime\n") | |
718e3744 | 5995 | { |
d62a17ae | 5996 | int idx_peer = 2; |
5997 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5998 | } |
6b0655a2 | 5999 | |
813d4307 | 6000 | |
d62a17ae | 6001 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
6002 | const char *time_str) | |
718e3744 | 6003 | { |
d62a17ae | 6004 | int ret; |
6005 | struct peer *peer; | |
d7c0a89a | 6006 | uint32_t connect; |
718e3744 | 6007 | |
d62a17ae | 6008 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6009 | if (!peer) | |
6010 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6011 | |
d62a17ae | 6012 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 6013 | |
d62a17ae | 6014 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 6015 | |
d62a17ae | 6016 | return bgp_vty_return(vty, ret); |
718e3744 | 6017 | } |
6018 | ||
d62a17ae | 6019 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 6020 | { |
d62a17ae | 6021 | int ret; |
6022 | struct peer *peer; | |
718e3744 | 6023 | |
d62a17ae | 6024 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6025 | if (!peer) | |
6026 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6027 | |
d62a17ae | 6028 | ret = peer_timers_connect_unset(peer); |
718e3744 | 6029 | |
d62a17ae | 6030 | return bgp_vty_return(vty, ret); |
718e3744 | 6031 | } |
6032 | ||
6033 | DEFUN (neighbor_timers_connect, | |
6034 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 6035 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 6036 | NEIGHBOR_STR |
966f821c | 6037 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6038 | "BGP per neighbor timers\n" |
6039 | "BGP connect timer\n" | |
6040 | "Connect timer\n") | |
6041 | { | |
d62a17ae | 6042 | int idx_peer = 1; |
6043 | int idx_number = 4; | |
6044 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
6045 | argv[idx_number]->arg); | |
718e3744 | 6046 | } |
6047 | ||
6048 | DEFUN (no_neighbor_timers_connect, | |
6049 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 6050 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 6051 | NO_STR |
6052 | NEIGHBOR_STR | |
966f821c | 6053 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6054 | "BGP per neighbor timers\n" |
8334fd5a DW |
6055 | "BGP connect timer\n" |
6056 | "Connect timer\n") | |
718e3744 | 6057 | { |
d62a17ae | 6058 | int idx_peer = 2; |
6059 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 6060 | } |
6061 | ||
6b0655a2 | 6062 | |
d62a17ae | 6063 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
6064 | const char *time_str, int set) | |
718e3744 | 6065 | { |
d62a17ae | 6066 | int ret; |
6067 | struct peer *peer; | |
d7c0a89a | 6068 | uint32_t routeadv = 0; |
718e3744 | 6069 | |
d62a17ae | 6070 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6071 | if (!peer) | |
6072 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6073 | |
d62a17ae | 6074 | if (time_str) |
6075 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 6076 | |
d62a17ae | 6077 | if (set) |
6078 | ret = peer_advertise_interval_set(peer, routeadv); | |
6079 | else | |
6080 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 6081 | |
d62a17ae | 6082 | return bgp_vty_return(vty, ret); |
718e3744 | 6083 | } |
6084 | ||
6085 | DEFUN (neighbor_advertise_interval, | |
6086 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6087 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 6088 | NEIGHBOR_STR |
966f821c | 6089 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6090 | "Minimum interval between sending BGP routing updates\n" |
6091 | "time in seconds\n") | |
6092 | { | |
d62a17ae | 6093 | int idx_peer = 1; |
6094 | int idx_number = 3; | |
6095 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
6096 | argv[idx_number]->arg, 1); | |
718e3744 | 6097 | } |
6098 | ||
6099 | DEFUN (no_neighbor_advertise_interval, | |
6100 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 6101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 6102 | NO_STR |
6103 | NEIGHBOR_STR | |
966f821c | 6104 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
6105 | "Minimum interval between sending BGP routing updates\n" |
6106 | "time in seconds\n") | |
718e3744 | 6107 | { |
d62a17ae | 6108 | int idx_peer = 2; |
6109 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 6110 | } |
6111 | ||
6b0655a2 | 6112 | |
518f0eb1 DS |
6113 | /* Time to wait before processing route-map updates */ |
6114 | DEFUN (bgp_set_route_map_delay_timer, | |
6115 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 6116 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
6117 | SET_STR |
6118 | "BGP route-map delay timer\n" | |
6119 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6120 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6121 | { |
d62a17ae | 6122 | int idx_number = 3; |
d7c0a89a | 6123 | uint32_t rmap_delay_timer; |
d62a17ae | 6124 | |
6125 | if (argv[idx_number]->arg) { | |
6126 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6127 | bm->rmap_update_timer = rmap_delay_timer; | |
6128 | ||
6129 | /* if the dynamic update handling is being disabled, and a timer | |
6130 | * is | |
6131 | * running, stop the timer and act as if the timer has already | |
6132 | * fired. | |
6133 | */ | |
6134 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6135 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6136 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6137 | NULL, 0); | |
6138 | } | |
6139 | return CMD_SUCCESS; | |
6140 | } else { | |
6141 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6142 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6143 | } |
518f0eb1 DS |
6144 | } |
6145 | ||
6146 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6147 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6148 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6149 | NO_STR |
3a2d747c | 6150 | BGP_STR |
518f0eb1 | 6151 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6152 | "Reset to default time to wait for processing route-map changes\n" |
6153 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6154 | { |
518f0eb1 | 6155 | |
d62a17ae | 6156 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6157 | |
d62a17ae | 6158 | return CMD_SUCCESS; |
518f0eb1 DS |
6159 | } |
6160 | ||
f414725f | 6161 | |
718e3744 | 6162 | /* neighbor interface */ |
d62a17ae | 6163 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6164 | const char *str) | |
718e3744 | 6165 | { |
d62a17ae | 6166 | struct peer *peer; |
718e3744 | 6167 | |
d62a17ae | 6168 | peer = peer_lookup_vty(vty, ip_str); |
6169 | if (!peer || peer->conf_if) { | |
6170 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6171 | return CMD_WARNING_CONFIG_FAILED; | |
6172 | } | |
718e3744 | 6173 | |
d62a17ae | 6174 | if (str) |
6175 | peer_interface_set(peer, str); | |
6176 | else | |
6177 | peer_interface_unset(peer); | |
718e3744 | 6178 | |
d62a17ae | 6179 | return CMD_SUCCESS; |
718e3744 | 6180 | } |
6181 | ||
6182 | DEFUN (neighbor_interface, | |
6183 | neighbor_interface_cmd, | |
9ccf14f7 | 6184 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6185 | NEIGHBOR_STR |
6186 | NEIGHBOR_ADDR_STR | |
6187 | "Interface\n" | |
6188 | "Interface name\n") | |
6189 | { | |
d62a17ae | 6190 | int idx_ip = 1; |
6191 | int idx_word = 3; | |
6192 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6193 | } |
6194 | ||
6195 | DEFUN (no_neighbor_interface, | |
6196 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6197 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6198 | NO_STR |
6199 | NEIGHBOR_STR | |
16cedbb0 | 6200 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6201 | "Interface\n" |
6202 | "Interface name\n") | |
6203 | { | |
d62a17ae | 6204 | int idx_peer = 2; |
6205 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6206 | } |
6b0655a2 | 6207 | |
718e3744 | 6208 | DEFUN (neighbor_distribute_list, |
6209 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6210 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6211 | NEIGHBOR_STR |
6212 | NEIGHBOR_ADDR_STR2 | |
6213 | "Filter updates to/from this neighbor\n" | |
6214 | "IP access-list number\n" | |
6215 | "IP access-list number (expanded range)\n" | |
6216 | "IP Access-list name\n" | |
6217 | "Filter incoming updates\n" | |
6218 | "Filter outgoing updates\n") | |
6219 | { | |
d62a17ae | 6220 | int idx_peer = 1; |
6221 | int idx_acl = 3; | |
6222 | int direct, ret; | |
6223 | struct peer *peer; | |
a8206004 | 6224 | |
d62a17ae | 6225 | const char *pstr = argv[idx_peer]->arg; |
6226 | const char *acl = argv[idx_acl]->arg; | |
6227 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6228 | |
d62a17ae | 6229 | peer = peer_and_group_lookup_vty(vty, pstr); |
6230 | if (!peer) | |
6231 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6232 | |
d62a17ae | 6233 | /* Check filter direction. */ |
6234 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6235 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6236 | direct, acl); | |
a8206004 | 6237 | |
d62a17ae | 6238 | return bgp_vty_return(vty, ret); |
718e3744 | 6239 | } |
6240 | ||
d62a17ae | 6241 | ALIAS_HIDDEN( |
6242 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6243 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6244 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6245 | "Filter updates to/from this neighbor\n" | |
6246 | "IP access-list number\n" | |
6247 | "IP access-list number (expanded range)\n" | |
6248 | "IP Access-list name\n" | |
6249 | "Filter incoming updates\n" | |
6250 | "Filter outgoing updates\n") | |
596c17ba | 6251 | |
718e3744 | 6252 | DEFUN (no_neighbor_distribute_list, |
6253 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6254 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6255 | NO_STR |
6256 | NEIGHBOR_STR | |
6257 | NEIGHBOR_ADDR_STR2 | |
6258 | "Filter updates to/from this neighbor\n" | |
6259 | "IP access-list number\n" | |
6260 | "IP access-list number (expanded range)\n" | |
6261 | "IP Access-list name\n" | |
6262 | "Filter incoming updates\n" | |
6263 | "Filter outgoing updates\n") | |
6264 | { | |
d62a17ae | 6265 | int idx_peer = 2; |
6266 | int direct, ret; | |
6267 | struct peer *peer; | |
a8206004 | 6268 | |
d62a17ae | 6269 | const char *pstr = argv[idx_peer]->arg; |
6270 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6271 | |
d62a17ae | 6272 | peer = peer_and_group_lookup_vty(vty, pstr); |
6273 | if (!peer) | |
6274 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6275 | |
d62a17ae | 6276 | /* Check filter direction. */ |
6277 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6278 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6279 | direct); | |
a8206004 | 6280 | |
d62a17ae | 6281 | return bgp_vty_return(vty, ret); |
718e3744 | 6282 | } |
6b0655a2 | 6283 | |
d62a17ae | 6284 | ALIAS_HIDDEN( |
6285 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6286 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6287 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6288 | "Filter updates to/from this neighbor\n" | |
6289 | "IP access-list number\n" | |
6290 | "IP access-list number (expanded range)\n" | |
6291 | "IP Access-list name\n" | |
6292 | "Filter incoming updates\n" | |
6293 | "Filter outgoing updates\n") | |
596c17ba | 6294 | |
718e3744 | 6295 | /* Set prefix list to the peer. */ |
d62a17ae | 6296 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6297 | afi_t afi, safi_t safi, | |
6298 | const char *name_str, | |
6299 | const char *direct_str) | |
718e3744 | 6300 | { |
d62a17ae | 6301 | int ret; |
d62a17ae | 6302 | int direct = FILTER_IN; |
cf9ac8bf | 6303 | struct peer *peer; |
718e3744 | 6304 | |
d62a17ae | 6305 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6306 | if (!peer) | |
6307 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6308 | |
d62a17ae | 6309 | /* Check filter direction. */ |
6310 | if (strncmp(direct_str, "i", 1) == 0) | |
6311 | direct = FILTER_IN; | |
6312 | else if (strncmp(direct_str, "o", 1) == 0) | |
6313 | direct = FILTER_OUT; | |
718e3744 | 6314 | |
d62a17ae | 6315 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6316 | |
d62a17ae | 6317 | return bgp_vty_return(vty, ret); |
718e3744 | 6318 | } |
6319 | ||
d62a17ae | 6320 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6321 | afi_t afi, safi_t safi, | |
6322 | const char *direct_str) | |
718e3744 | 6323 | { |
d62a17ae | 6324 | int ret; |
6325 | struct peer *peer; | |
6326 | int direct = FILTER_IN; | |
718e3744 | 6327 | |
d62a17ae | 6328 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6329 | if (!peer) | |
6330 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6331 | |
d62a17ae | 6332 | /* Check filter direction. */ |
6333 | if (strncmp(direct_str, "i", 1) == 0) | |
6334 | direct = FILTER_IN; | |
6335 | else if (strncmp(direct_str, "o", 1) == 0) | |
6336 | direct = FILTER_OUT; | |
718e3744 | 6337 | |
d62a17ae | 6338 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6339 | |
d62a17ae | 6340 | return bgp_vty_return(vty, ret); |
718e3744 | 6341 | } |
6342 | ||
6343 | DEFUN (neighbor_prefix_list, | |
6344 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6345 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6346 | NEIGHBOR_STR |
6347 | NEIGHBOR_ADDR_STR2 | |
6348 | "Filter updates to/from this neighbor\n" | |
6349 | "Name of a prefix list\n" | |
6350 | "Filter incoming updates\n" | |
6351 | "Filter outgoing updates\n") | |
6352 | { | |
d62a17ae | 6353 | int idx_peer = 1; |
6354 | int idx_word = 3; | |
6355 | int idx_in_out = 4; | |
6356 | return peer_prefix_list_set_vty( | |
6357 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6358 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6359 | } |
6360 | ||
d62a17ae | 6361 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6362 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6363 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6364 | "Filter updates to/from this neighbor\n" | |
6365 | "Name of a prefix list\n" | |
6366 | "Filter incoming updates\n" | |
6367 | "Filter outgoing updates\n") | |
596c17ba | 6368 | |
718e3744 | 6369 | DEFUN (no_neighbor_prefix_list, |
6370 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6371 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6372 | NO_STR |
6373 | NEIGHBOR_STR | |
6374 | NEIGHBOR_ADDR_STR2 | |
6375 | "Filter updates to/from this neighbor\n" | |
6376 | "Name of a prefix list\n" | |
6377 | "Filter incoming updates\n" | |
6378 | "Filter outgoing updates\n") | |
6379 | { | |
d62a17ae | 6380 | int idx_peer = 2; |
6381 | int idx_in_out = 5; | |
6382 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6383 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6384 | argv[idx_in_out]->arg); | |
718e3744 | 6385 | } |
6b0655a2 | 6386 | |
d62a17ae | 6387 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6388 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6389 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6390 | "Filter updates to/from this neighbor\n" | |
6391 | "Name of a prefix list\n" | |
6392 | "Filter incoming updates\n" | |
6393 | "Filter outgoing updates\n") | |
596c17ba | 6394 | |
d62a17ae | 6395 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6396 | safi_t safi, const char *name_str, | |
6397 | const char *direct_str) | |
718e3744 | 6398 | { |
d62a17ae | 6399 | int ret; |
6400 | struct peer *peer; | |
6401 | int direct = FILTER_IN; | |
718e3744 | 6402 | |
d62a17ae | 6403 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6404 | if (!peer) | |
6405 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6406 | |
d62a17ae | 6407 | /* Check filter direction. */ |
6408 | if (strncmp(direct_str, "i", 1) == 0) | |
6409 | direct = FILTER_IN; | |
6410 | else if (strncmp(direct_str, "o", 1) == 0) | |
6411 | direct = FILTER_OUT; | |
718e3744 | 6412 | |
d62a17ae | 6413 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6414 | |
d62a17ae | 6415 | return bgp_vty_return(vty, ret); |
718e3744 | 6416 | } |
6417 | ||
d62a17ae | 6418 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6419 | safi_t safi, const char *direct_str) | |
718e3744 | 6420 | { |
d62a17ae | 6421 | int ret; |
6422 | struct peer *peer; | |
6423 | int direct = FILTER_IN; | |
718e3744 | 6424 | |
d62a17ae | 6425 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6426 | if (!peer) | |
6427 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6428 | |
d62a17ae | 6429 | /* Check filter direction. */ |
6430 | if (strncmp(direct_str, "i", 1) == 0) | |
6431 | direct = FILTER_IN; | |
6432 | else if (strncmp(direct_str, "o", 1) == 0) | |
6433 | direct = FILTER_OUT; | |
718e3744 | 6434 | |
d62a17ae | 6435 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6436 | |
d62a17ae | 6437 | return bgp_vty_return(vty, ret); |
718e3744 | 6438 | } |
6439 | ||
6440 | DEFUN (neighbor_filter_list, | |
6441 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6442 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6443 | NEIGHBOR_STR |
6444 | NEIGHBOR_ADDR_STR2 | |
6445 | "Establish BGP filters\n" | |
6446 | "AS path access-list name\n" | |
6447 | "Filter incoming routes\n" | |
6448 | "Filter outgoing routes\n") | |
6449 | { | |
d62a17ae | 6450 | int idx_peer = 1; |
6451 | int idx_word = 3; | |
6452 | int idx_in_out = 4; | |
6453 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6454 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6455 | argv[idx_in_out]->arg); | |
718e3744 | 6456 | } |
6457 | ||
d62a17ae | 6458 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6459 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6460 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6461 | "Establish BGP filters\n" | |
6462 | "AS path access-list name\n" | |
6463 | "Filter incoming routes\n" | |
6464 | "Filter outgoing routes\n") | |
596c17ba | 6465 | |
718e3744 | 6466 | DEFUN (no_neighbor_filter_list, |
6467 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6468 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6469 | NO_STR |
6470 | NEIGHBOR_STR | |
6471 | NEIGHBOR_ADDR_STR2 | |
6472 | "Establish BGP filters\n" | |
6473 | "AS path access-list name\n" | |
6474 | "Filter incoming routes\n" | |
6475 | "Filter outgoing routes\n") | |
6476 | { | |
d62a17ae | 6477 | int idx_peer = 2; |
6478 | int idx_in_out = 5; | |
6479 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6480 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6481 | argv[idx_in_out]->arg); | |
718e3744 | 6482 | } |
6b0655a2 | 6483 | |
d62a17ae | 6484 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6485 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6486 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6487 | "Establish BGP filters\n" | |
6488 | "AS path access-list name\n" | |
6489 | "Filter incoming routes\n" | |
6490 | "Filter outgoing routes\n") | |
596c17ba | 6491 | |
718e3744 | 6492 | /* Set route-map to the peer. */ |
d62a17ae | 6493 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6494 | afi_t afi, safi_t safi, const char *name_str, | |
6495 | const char *direct_str) | |
718e3744 | 6496 | { |
d62a17ae | 6497 | int ret; |
6498 | struct peer *peer; | |
6499 | int direct = RMAP_IN; | |
1de27621 | 6500 | struct route_map *route_map; |
718e3744 | 6501 | |
d62a17ae | 6502 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6503 | if (!peer) | |
6504 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6505 | |
d62a17ae | 6506 | /* Check filter direction. */ |
6507 | if (strncmp(direct_str, "in", 2) == 0) | |
6508 | direct = RMAP_IN; | |
6509 | else if (strncmp(direct_str, "o", 1) == 0) | |
6510 | direct = RMAP_OUT; | |
718e3744 | 6511 | |
1de27621 DA |
6512 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6513 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6514 | |
d62a17ae | 6515 | return bgp_vty_return(vty, ret); |
718e3744 | 6516 | } |
6517 | ||
d62a17ae | 6518 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6519 | afi_t afi, safi_t safi, | |
6520 | const char *direct_str) | |
718e3744 | 6521 | { |
d62a17ae | 6522 | int ret; |
6523 | struct peer *peer; | |
6524 | int direct = RMAP_IN; | |
718e3744 | 6525 | |
d62a17ae | 6526 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6527 | if (!peer) | |
6528 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6529 | |
d62a17ae | 6530 | /* Check filter direction. */ |
6531 | if (strncmp(direct_str, "in", 2) == 0) | |
6532 | direct = RMAP_IN; | |
6533 | else if (strncmp(direct_str, "o", 1) == 0) | |
6534 | direct = RMAP_OUT; | |
718e3744 | 6535 | |
d62a17ae | 6536 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6537 | |
d62a17ae | 6538 | return bgp_vty_return(vty, ret); |
718e3744 | 6539 | } |
6540 | ||
6541 | DEFUN (neighbor_route_map, | |
6542 | neighbor_route_map_cmd, | |
9ccf14f7 | 6543 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6544 | NEIGHBOR_STR |
6545 | NEIGHBOR_ADDR_STR2 | |
6546 | "Apply route map to neighbor\n" | |
6547 | "Name of route map\n" | |
6548 | "Apply map to incoming routes\n" | |
2a3d5731 | 6549 | "Apply map to outbound routes\n") |
718e3744 | 6550 | { |
d62a17ae | 6551 | int idx_peer = 1; |
6552 | int idx_word = 3; | |
6553 | int idx_in_out = 4; | |
6554 | return peer_route_map_set_vty( | |
6555 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6556 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6557 | } |
6558 | ||
d62a17ae | 6559 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6560 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6561 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6562 | "Apply route map to neighbor\n" | |
6563 | "Name of route map\n" | |
6564 | "Apply map to incoming routes\n" | |
6565 | "Apply map to outbound routes\n") | |
596c17ba | 6566 | |
718e3744 | 6567 | DEFUN (no_neighbor_route_map, |
6568 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6569 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6570 | NO_STR |
6571 | NEIGHBOR_STR | |
6572 | NEIGHBOR_ADDR_STR2 | |
6573 | "Apply route map to neighbor\n" | |
6574 | "Name of route map\n" | |
6575 | "Apply map to incoming routes\n" | |
2a3d5731 | 6576 | "Apply map to outbound routes\n") |
718e3744 | 6577 | { |
d62a17ae | 6578 | int idx_peer = 2; |
6579 | int idx_in_out = 5; | |
6580 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6581 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6582 | argv[idx_in_out]->arg); | |
718e3744 | 6583 | } |
6b0655a2 | 6584 | |
d62a17ae | 6585 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6586 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6587 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6588 | "Apply route map to neighbor\n" | |
6589 | "Name of route map\n" | |
6590 | "Apply map to incoming routes\n" | |
6591 | "Apply map to outbound routes\n") | |
596c17ba | 6592 | |
718e3744 | 6593 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6594 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6595 | afi_t afi, safi_t safi, | |
6596 | const char *name_str) | |
718e3744 | 6597 | { |
d62a17ae | 6598 | int ret; |
6599 | struct peer *peer; | |
1de27621 | 6600 | struct route_map *route_map; |
718e3744 | 6601 | |
d62a17ae | 6602 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6603 | if (!peer) | |
6604 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6605 | |
1de27621 DA |
6606 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6607 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6608 | |
d62a17ae | 6609 | return bgp_vty_return(vty, ret); |
718e3744 | 6610 | } |
6611 | ||
6612 | /* Unset route-map from the peer. */ | |
d62a17ae | 6613 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6614 | afi_t afi, safi_t safi) | |
718e3744 | 6615 | { |
d62a17ae | 6616 | int ret; |
6617 | struct peer *peer; | |
718e3744 | 6618 | |
d62a17ae | 6619 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6620 | if (!peer) | |
6621 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6622 | |
d62a17ae | 6623 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6624 | |
d62a17ae | 6625 | return bgp_vty_return(vty, ret); |
718e3744 | 6626 | } |
6627 | ||
6628 | DEFUN (neighbor_unsuppress_map, | |
6629 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6630 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6631 | NEIGHBOR_STR |
6632 | NEIGHBOR_ADDR_STR2 | |
6633 | "Route-map to selectively unsuppress suppressed routes\n" | |
6634 | "Name of route map\n") | |
6635 | { | |
d62a17ae | 6636 | int idx_peer = 1; |
6637 | int idx_word = 3; | |
6638 | return peer_unsuppress_map_set_vty( | |
6639 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6640 | argv[idx_word]->arg); | |
718e3744 | 6641 | } |
6642 | ||
d62a17ae | 6643 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6644 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6645 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6646 | "Route-map to selectively unsuppress suppressed routes\n" | |
6647 | "Name of route map\n") | |
596c17ba | 6648 | |
718e3744 | 6649 | DEFUN (no_neighbor_unsuppress_map, |
6650 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6651 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6652 | NO_STR |
6653 | NEIGHBOR_STR | |
6654 | NEIGHBOR_ADDR_STR2 | |
6655 | "Route-map to selectively unsuppress suppressed routes\n" | |
6656 | "Name of route map\n") | |
6657 | { | |
d62a17ae | 6658 | int idx_peer = 2; |
6659 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6660 | bgp_node_afi(vty), | |
6661 | bgp_node_safi(vty)); | |
718e3744 | 6662 | } |
6b0655a2 | 6663 | |
d62a17ae | 6664 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6665 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6666 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6667 | "Route-map to selectively unsuppress suppressed routes\n" | |
6668 | "Name of route map\n") | |
596c17ba | 6669 | |
d62a17ae | 6670 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6671 | afi_t afi, safi_t safi, | |
6672 | const char *num_str, | |
6673 | const char *threshold_str, int warning, | |
6674 | const char *restart_str) | |
718e3744 | 6675 | { |
d62a17ae | 6676 | int ret; |
6677 | struct peer *peer; | |
d7c0a89a QY |
6678 | uint32_t max; |
6679 | uint8_t threshold; | |
6680 | uint16_t restart; | |
718e3744 | 6681 | |
d62a17ae | 6682 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6683 | if (!peer) | |
6684 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6685 | |
d62a17ae | 6686 | max = strtoul(num_str, NULL, 10); |
6687 | if (threshold_str) | |
6688 | threshold = atoi(threshold_str); | |
6689 | else | |
6690 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6691 | |
d62a17ae | 6692 | if (restart_str) |
6693 | restart = atoi(restart_str); | |
6694 | else | |
6695 | restart = 0; | |
0a486e5f | 6696 | |
d62a17ae | 6697 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6698 | restart); | |
718e3744 | 6699 | |
d62a17ae | 6700 | return bgp_vty_return(vty, ret); |
718e3744 | 6701 | } |
6702 | ||
d62a17ae | 6703 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6704 | afi_t afi, safi_t safi) | |
718e3744 | 6705 | { |
d62a17ae | 6706 | int ret; |
6707 | struct peer *peer; | |
718e3744 | 6708 | |
d62a17ae | 6709 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6710 | if (!peer) | |
6711 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6712 | |
d62a17ae | 6713 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6714 | |
d62a17ae | 6715 | return bgp_vty_return(vty, ret); |
718e3744 | 6716 | } |
6717 | ||
fde246e8 DA |
6718 | /* Maximum number of prefix to be sent to the neighbor. */ |
6719 | DEFUN(neighbor_maximum_prefix_out, | |
6720 | neighbor_maximum_prefix_out_cmd, | |
6721 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6722 | NEIGHBOR_STR | |
6723 | NEIGHBOR_ADDR_STR2 | |
6724 | "Maximum number of prefixes to be sent to this peer\n" | |
6725 | "Maximum no. of prefix limit\n") | |
6726 | { | |
6727 | int idx_peer = 1; | |
6728 | int idx_number = 3; | |
6729 | struct peer *peer; | |
6730 | uint32_t max; | |
6731 | afi_t afi = bgp_node_afi(vty); | |
6732 | safi_t safi = bgp_node_safi(vty); | |
6733 | ||
6734 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6735 | if (!peer) | |
6736 | return CMD_WARNING_CONFIG_FAILED; | |
6737 | ||
6738 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6739 | ||
6740 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6741 | peer->pmax_out[afi][safi] = max; | |
6742 | ||
6743 | return CMD_SUCCESS; | |
6744 | } | |
6745 | ||
6746 | DEFUN(no_neighbor_maximum_prefix_out, | |
6747 | no_neighbor_maximum_prefix_out_cmd, | |
6748 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6749 | NO_STR | |
6750 | NEIGHBOR_STR | |
6751 | NEIGHBOR_ADDR_STR2 | |
6752 | "Maximum number of prefixes to be sent to this peer\n") | |
6753 | { | |
6754 | int idx_peer = 2; | |
6755 | struct peer *peer; | |
6756 | afi_t afi = bgp_node_afi(vty); | |
6757 | safi_t safi = bgp_node_safi(vty); | |
6758 | ||
6759 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6760 | if (!peer) | |
6761 | return CMD_WARNING_CONFIG_FAILED; | |
6762 | ||
ae00326a | 6763 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
6764 | peer->pmax_out[afi][safi] = 0; |
6765 | ||
6766 | return CMD_SUCCESS; | |
6767 | } | |
6768 | ||
718e3744 | 6769 | /* Maximum number of prefix configuration. prefix count is different |
6770 | for each peer configuration. So this configuration can be set for | |
6771 | each peer configuration. */ | |
6772 | DEFUN (neighbor_maximum_prefix, | |
6773 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6774 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6775 | NEIGHBOR_STR |
6776 | NEIGHBOR_ADDR_STR2 | |
6777 | "Maximum number of prefix accept from this peer\n" | |
6778 | "maximum no. of prefix limit\n") | |
6779 | { | |
d62a17ae | 6780 | int idx_peer = 1; |
6781 | int idx_number = 3; | |
6782 | return peer_maximum_prefix_set_vty( | |
6783 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6784 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6785 | } |
6786 | ||
d62a17ae | 6787 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6788 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6789 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6790 | "Maximum number of prefix accept from this peer\n" | |
6791 | "maximum no. of prefix limit\n") | |
596c17ba | 6792 | |
e0701b79 | 6793 | DEFUN (neighbor_maximum_prefix_threshold, |
6794 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6795 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6796 | NEIGHBOR_STR |
6797 | NEIGHBOR_ADDR_STR2 | |
6798 | "Maximum number of prefix accept from this peer\n" | |
6799 | "maximum no. of prefix limit\n" | |
6800 | "Threshold value (%) at which to generate a warning msg\n") | |
6801 | { | |
d62a17ae | 6802 | int idx_peer = 1; |
6803 | int idx_number = 3; | |
6804 | int idx_number_2 = 4; | |
6805 | return peer_maximum_prefix_set_vty( | |
6806 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6807 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6808 | } |
e0701b79 | 6809 | |
d62a17ae | 6810 | ALIAS_HIDDEN( |
6811 | neighbor_maximum_prefix_threshold, | |
6812 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6813 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6814 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6815 | "Maximum number of prefix accept from this peer\n" | |
6816 | "maximum no. of prefix limit\n" | |
6817 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6818 | |
718e3744 | 6819 | DEFUN (neighbor_maximum_prefix_warning, |
6820 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6821 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6822 | NEIGHBOR_STR |
6823 | NEIGHBOR_ADDR_STR2 | |
6824 | "Maximum number of prefix accept from this peer\n" | |
6825 | "maximum no. of prefix limit\n" | |
6826 | "Only give warning message when limit is exceeded\n") | |
6827 | { | |
d62a17ae | 6828 | int idx_peer = 1; |
6829 | int idx_number = 3; | |
6830 | return peer_maximum_prefix_set_vty( | |
6831 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6832 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6833 | } |
6834 | ||
d62a17ae | 6835 | ALIAS_HIDDEN( |
6836 | neighbor_maximum_prefix_warning, | |
6837 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6838 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6839 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6840 | "Maximum number of prefix accept from this peer\n" | |
6841 | "maximum no. of prefix limit\n" | |
6842 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6843 | |
e0701b79 | 6844 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6845 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6846 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6847 | NEIGHBOR_STR |
6848 | NEIGHBOR_ADDR_STR2 | |
6849 | "Maximum number of prefix accept from this peer\n" | |
6850 | "maximum no. of prefix limit\n" | |
6851 | "Threshold value (%) at which to generate a warning msg\n" | |
6852 | "Only give warning message when limit is exceeded\n") | |
6853 | { | |
d62a17ae | 6854 | int idx_peer = 1; |
6855 | int idx_number = 3; | |
6856 | int idx_number_2 = 4; | |
6857 | return peer_maximum_prefix_set_vty( | |
6858 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6859 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6860 | } |
6861 | ||
d62a17ae | 6862 | ALIAS_HIDDEN( |
6863 | neighbor_maximum_prefix_threshold_warning, | |
6864 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6865 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6866 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6867 | "Maximum number of prefix accept from this peer\n" | |
6868 | "maximum no. of prefix limit\n" | |
6869 | "Threshold value (%) at which to generate a warning msg\n" | |
6870 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6871 | |
0a486e5f | 6872 | DEFUN (neighbor_maximum_prefix_restart, |
6873 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6874 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6875 | NEIGHBOR_STR |
6876 | NEIGHBOR_ADDR_STR2 | |
6877 | "Maximum number of prefix accept from this peer\n" | |
6878 | "maximum no. of prefix limit\n" | |
6879 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6880 | "Restart interval in minutes\n") |
0a486e5f | 6881 | { |
d62a17ae | 6882 | int idx_peer = 1; |
6883 | int idx_number = 3; | |
6884 | int idx_number_2 = 5; | |
6885 | return peer_maximum_prefix_set_vty( | |
6886 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6887 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6888 | } |
6889 | ||
d62a17ae | 6890 | ALIAS_HIDDEN( |
6891 | neighbor_maximum_prefix_restart, | |
6892 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6893 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6894 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6895 | "Maximum number of prefix accept from this peer\n" | |
6896 | "maximum no. of prefix limit\n" | |
6897 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6898 | "Restart interval in minutes\n") |
596c17ba | 6899 | |
0a486e5f | 6900 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6901 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6902 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6903 | NEIGHBOR_STR |
6904 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6905 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6906 | "maximum no. of prefix limit\n" |
6907 | "Threshold value (%) at which to generate a warning msg\n" | |
6908 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6909 | "Restart interval in minutes\n") |
0a486e5f | 6910 | { |
d62a17ae | 6911 | int idx_peer = 1; |
6912 | int idx_number = 3; | |
6913 | int idx_number_2 = 4; | |
6914 | int idx_number_3 = 6; | |
6915 | return peer_maximum_prefix_set_vty( | |
6916 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6917 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6918 | argv[idx_number_3]->arg); | |
6919 | } | |
6920 | ||
6921 | ALIAS_HIDDEN( | |
6922 | neighbor_maximum_prefix_threshold_restart, | |
6923 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6924 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6925 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6926 | "Maximum number of prefixes to accept from this peer\n" | |
6927 | "maximum no. of prefix limit\n" | |
6928 | "Threshold value (%) at which to generate a warning msg\n" | |
6929 | "Restart bgp connection after limit is exceeded\n" | |
6930 | "Restart interval in minutes\n") | |
596c17ba | 6931 | |
718e3744 | 6932 | DEFUN (no_neighbor_maximum_prefix, |
6933 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6934 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6935 | NO_STR |
6936 | NEIGHBOR_STR | |
6937 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6938 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6939 | "maximum no. of prefix limit\n" |
6940 | "Threshold value (%) at which to generate a warning msg\n" | |
6941 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6942 | "Restart interval in minutes\n" |
31500417 | 6943 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6944 | { |
d62a17ae | 6945 | int idx_peer = 2; |
6946 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6947 | bgp_node_afi(vty), | |
6948 | bgp_node_safi(vty)); | |
718e3744 | 6949 | } |
e52702f2 | 6950 | |
d62a17ae | 6951 | ALIAS_HIDDEN( |
6952 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6953 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6954 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6955 | "Maximum number of prefixes to accept from this peer\n" | |
6956 | "maximum no. of prefix limit\n" | |
6957 | "Threshold value (%) at which to generate a warning msg\n" | |
6958 | "Restart bgp connection after limit is exceeded\n" | |
6959 | "Restart interval in minutes\n" | |
6960 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6961 | |
718e3744 | 6962 | |
718e3744 | 6963 | /* "neighbor allowas-in" */ |
6964 | DEFUN (neighbor_allowas_in, | |
6965 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6966 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6967 | NEIGHBOR_STR |
6968 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6969 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6970 | "Number of occurrences of AS number\n" |
fd8503f5 | 6971 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6972 | { |
d62a17ae | 6973 | int idx_peer = 1; |
6974 | int idx_number_origin = 3; | |
6975 | int ret; | |
6976 | int origin = 0; | |
6977 | struct peer *peer; | |
6978 | int allow_num = 0; | |
6979 | ||
6980 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6981 | if (!peer) | |
6982 | return CMD_WARNING_CONFIG_FAILED; | |
6983 | ||
6984 | if (argc <= idx_number_origin) | |
6985 | allow_num = 3; | |
6986 | else { | |
6987 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6988 | origin = 1; | |
6989 | else | |
6990 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6991 | } | |
6992 | ||
6993 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6994 | allow_num, origin); | |
6995 | ||
6996 | return bgp_vty_return(vty, ret); | |
6997 | } | |
6998 | ||
6999 | ALIAS_HIDDEN( | |
7000 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
7001 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7002 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7003 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 7004 | "Number of occurrences of AS number\n" |
d62a17ae | 7005 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7006 | |
718e3744 | 7007 | DEFUN (no_neighbor_allowas_in, |
7008 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 7009 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 7010 | NO_STR |
7011 | NEIGHBOR_STR | |
7012 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 7013 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 7014 | "Number of occurrences of AS number\n" |
fd8503f5 | 7015 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 7016 | { |
d62a17ae | 7017 | int idx_peer = 2; |
7018 | int ret; | |
7019 | struct peer *peer; | |
718e3744 | 7020 | |
d62a17ae | 7021 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7022 | if (!peer) | |
7023 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 7024 | |
d62a17ae | 7025 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
7026 | bgp_node_safi(vty)); | |
718e3744 | 7027 | |
d62a17ae | 7028 | return bgp_vty_return(vty, ret); |
718e3744 | 7029 | } |
6b0655a2 | 7030 | |
d62a17ae | 7031 | ALIAS_HIDDEN( |
7032 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
7033 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
7034 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7035 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 7036 | "Number of occurrences of AS number\n" |
d62a17ae | 7037 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 7038 | |
fa411a21 NH |
7039 | DEFUN (neighbor_ttl_security, |
7040 | neighbor_ttl_security_cmd, | |
7ebe625c | 7041 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 7042 | NEIGHBOR_STR |
7ebe625c | 7043 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7044 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
7045 | "Specify the maximum number of hops to the BGP peer\n" |
7046 | "Number of hops to BGP peer\n") | |
fa411a21 | 7047 | { |
d62a17ae | 7048 | int idx_peer = 1; |
7049 | int idx_number = 4; | |
7050 | struct peer *peer; | |
7051 | int gtsm_hops; | |
7052 | ||
7053 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7054 | if (!peer) | |
7055 | return CMD_WARNING_CONFIG_FAILED; | |
7056 | ||
7057 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
7058 | ||
7ebe625c QY |
7059 | /* |
7060 | * If 'neighbor swpX', then this is for directly connected peers, | |
7061 | * we should not accept a ttl-security hops value greater than 1. | |
7062 | */ | |
e2521429 | 7063 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
7064 | vty_out(vty, |
7065 | "%s is directly connected peer, hops cannot exceed 1\n", | |
7066 | argv[idx_peer]->arg); | |
7067 | return CMD_WARNING_CONFIG_FAILED; | |
7068 | } | |
7069 | ||
d62a17ae | 7070 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
7071 | } |
7072 | ||
7073 | DEFUN (no_neighbor_ttl_security, | |
7074 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 7075 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
7076 | NO_STR |
7077 | NEIGHBOR_STR | |
7ebe625c | 7078 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 7079 | "BGP ttl-security parameters\n" |
3a2d747c QY |
7080 | "Specify the maximum number of hops to the BGP peer\n" |
7081 | "Number of hops to BGP peer\n") | |
fa411a21 | 7082 | { |
d62a17ae | 7083 | int idx_peer = 2; |
7084 | struct peer *peer; | |
fa411a21 | 7085 | |
d62a17ae | 7086 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7087 | if (!peer) | |
7088 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 7089 | |
d62a17ae | 7090 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 7091 | } |
6b0655a2 | 7092 | |
adbac85e DW |
7093 | DEFUN (neighbor_addpath_tx_all_paths, |
7094 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7095 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7096 | NEIGHBOR_STR |
7097 | NEIGHBOR_ADDR_STR2 | |
7098 | "Use addpath to advertise all paths to a neighbor\n") | |
7099 | { | |
d62a17ae | 7100 | int idx_peer = 1; |
7101 | struct peer *peer; | |
adbac85e | 7102 | |
d62a17ae | 7103 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7104 | if (!peer) | |
7105 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 7106 | |
dcc68b5e MS |
7107 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7108 | BGP_ADDPATH_ALL); | |
7109 | return CMD_SUCCESS; | |
adbac85e DW |
7110 | } |
7111 | ||
d62a17ae | 7112 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
7113 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
7114 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7115 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7116 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7117 | |
adbac85e DW |
7118 | DEFUN (no_neighbor_addpath_tx_all_paths, |
7119 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7121 | NO_STR |
7122 | NEIGHBOR_STR | |
7123 | NEIGHBOR_ADDR_STR2 | |
7124 | "Use addpath to advertise all paths to a neighbor\n") | |
7125 | { | |
d62a17ae | 7126 | int idx_peer = 2; |
dcc68b5e MS |
7127 | struct peer *peer; |
7128 | ||
7129 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7130 | if (!peer) | |
7131 | return CMD_WARNING_CONFIG_FAILED; | |
7132 | ||
7133 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7134 | != BGP_ADDPATH_ALL) { | |
7135 | vty_out(vty, | |
7136 | "%% Peer not currently configured to transmit all paths."); | |
7137 | return CMD_WARNING_CONFIG_FAILED; | |
7138 | } | |
7139 | ||
7140 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7141 | BGP_ADDPATH_NONE); | |
7142 | ||
7143 | return CMD_SUCCESS; | |
adbac85e DW |
7144 | } |
7145 | ||
d62a17ae | 7146 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
7147 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
7148 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7149 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7150 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7151 | |
06370dac DW |
7152 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7153 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7154 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7155 | NEIGHBOR_STR |
7156 | NEIGHBOR_ADDR_STR2 | |
7157 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7158 | { | |
d62a17ae | 7159 | int idx_peer = 1; |
7160 | struct peer *peer; | |
06370dac | 7161 | |
d62a17ae | 7162 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7163 | if (!peer) | |
7164 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7165 | |
dcc68b5e MS |
7166 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7167 | BGP_ADDPATH_BEST_PER_AS); | |
7168 | ||
7169 | return CMD_SUCCESS; | |
06370dac DW |
7170 | } |
7171 | ||
d62a17ae | 7172 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7173 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7174 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7175 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7176 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7177 | |
06370dac DW |
7178 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7179 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7180 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7181 | NO_STR |
7182 | NEIGHBOR_STR | |
7183 | NEIGHBOR_ADDR_STR2 | |
7184 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7185 | { | |
d62a17ae | 7186 | int idx_peer = 2; |
dcc68b5e MS |
7187 | struct peer *peer; |
7188 | ||
7189 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7190 | if (!peer) | |
7191 | return CMD_WARNING_CONFIG_FAILED; | |
7192 | ||
7193 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7194 | != BGP_ADDPATH_BEST_PER_AS) { | |
7195 | vty_out(vty, | |
7196 | "%% Peer not currently configured to transmit all best path per as."); | |
7197 | return CMD_WARNING_CONFIG_FAILED; | |
7198 | } | |
7199 | ||
7200 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7201 | BGP_ADDPATH_NONE); | |
7202 | ||
7203 | return CMD_SUCCESS; | |
06370dac DW |
7204 | } |
7205 | ||
d62a17ae | 7206 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7207 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7208 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7209 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7210 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7211 | |
2b31007c RZ |
7212 | DEFPY( |
7213 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7214 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7215 | NEIGHBOR_STR | |
7216 | NEIGHBOR_ADDR_STR2 | |
7217 | "Detect AS loops before sending to neighbor\n") | |
7218 | { | |
7219 | struct peer *peer; | |
7220 | ||
7221 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7222 | if (!peer) | |
7223 | return CMD_WARNING_CONFIG_FAILED; | |
7224 | ||
7225 | peer->as_path_loop_detection = true; | |
7226 | ||
7227 | return CMD_SUCCESS; | |
7228 | } | |
7229 | ||
7230 | DEFPY( | |
7231 | no_neighbor_aspath_loop_detection, | |
7232 | no_neighbor_aspath_loop_detection_cmd, | |
7233 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7234 | NO_STR | |
7235 | NEIGHBOR_STR | |
7236 | NEIGHBOR_ADDR_STR2 | |
7237 | "Detect AS loops before sending to neighbor\n") | |
7238 | { | |
7239 | struct peer *peer; | |
7240 | ||
7241 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7242 | if (!peer) | |
7243 | return CMD_WARNING_CONFIG_FAILED; | |
7244 | ||
7245 | peer->as_path_loop_detection = false; | |
7246 | ||
7247 | return CMD_SUCCESS; | |
7248 | } | |
7249 | ||
b9c7bc5a PZ |
7250 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7251 | struct ecommunity **list) | |
ddb5b488 | 7252 | { |
b9c7bc5a PZ |
7253 | struct ecommunity *ecom = NULL; |
7254 | struct ecommunity *ecomadd; | |
ddb5b488 | 7255 | |
b9c7bc5a | 7256 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7257 | |
b9c7bc5a PZ |
7258 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7259 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7260 | if (!ecomadd) { | |
7261 | vty_out(vty, "Malformed community-list value\n"); | |
7262 | if (ecom) | |
7263 | ecommunity_free(&ecom); | |
7264 | return CMD_WARNING_CONFIG_FAILED; | |
7265 | } | |
ddb5b488 | 7266 | |
b9c7bc5a PZ |
7267 | if (ecom) { |
7268 | ecommunity_merge(ecom, ecomadd); | |
7269 | ecommunity_free(&ecomadd); | |
7270 | } else { | |
7271 | ecom = ecomadd; | |
7272 | } | |
7273 | } | |
7274 | ||
7275 | if (*list) { | |
7276 | ecommunity_free(&*list); | |
ddb5b488 | 7277 | } |
b9c7bc5a PZ |
7278 | *list = ecom; |
7279 | ||
7280 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7281 | } |
7282 | ||
0ca70ba5 DS |
7283 | /* |
7284 | * v2vimport is true if we are handling a `import vrf ...` command | |
7285 | */ | |
7286 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7287 | { |
0ca70ba5 DS |
7288 | afi_t afi; |
7289 | ||
ddb5b488 | 7290 | switch (vty->node) { |
b9c7bc5a | 7291 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7292 | afi = AFI_IP; |
7293 | break; | |
b9c7bc5a | 7294 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7295 | afi = AFI_IP6; |
7296 | break; | |
ddb5b488 PZ |
7297 | default: |
7298 | vty_out(vty, | |
b9c7bc5a | 7299 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7300 | return AFI_MAX; |
ddb5b488 | 7301 | } |
69b07479 | 7302 | |
0ca70ba5 DS |
7303 | if (!v2vimport) { |
7304 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7305 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7306 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7307 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7308 | vty_out(vty, | |
7309 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7310 | return AFI_MAX; | |
7311 | } | |
7312 | } else { | |
7313 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7314 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7315 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7316 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7317 | vty_out(vty, | |
7318 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7319 | return AFI_MAX; | |
7320 | } | |
7321 | } | |
7322 | return afi; | |
ddb5b488 PZ |
7323 | } |
7324 | ||
b9c7bc5a PZ |
7325 | DEFPY (af_rd_vpn_export, |
7326 | af_rd_vpn_export_cmd, | |
7327 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7328 | NO_STR | |
ddb5b488 | 7329 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7330 | "Between current address-family and vpn\n" |
7331 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7332 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7333 | { | |
7334 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7335 | struct prefix_rd prd; | |
7336 | int ret; | |
ddb5b488 | 7337 | afi_t afi; |
b9c7bc5a PZ |
7338 | int idx = 0; |
7339 | int yes = 1; | |
ddb5b488 | 7340 | |
b9c7bc5a | 7341 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7342 | yes = 0; |
b9c7bc5a PZ |
7343 | |
7344 | if (yes) { | |
7345 | ret = str2prefix_rd(rd_str, &prd); | |
7346 | if (!ret) { | |
7347 | vty_out(vty, "%% Malformed rd\n"); | |
7348 | return CMD_WARNING_CONFIG_FAILED; | |
7349 | } | |
ddb5b488 PZ |
7350 | } |
7351 | ||
0ca70ba5 | 7352 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7353 | if (afi == AFI_MAX) |
7354 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7355 | |
69b07479 DS |
7356 | /* |
7357 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7358 | */ | |
7359 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7360 | bgp_get_default(), bgp); | |
ddb5b488 | 7361 | |
69b07479 DS |
7362 | if (yes) { |
7363 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7364 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7365 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7366 | } else { | |
7367 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7368 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7369 | } |
7370 | ||
69b07479 DS |
7371 | /* post-change: re-export vpn routes */ |
7372 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7373 | bgp_get_default(), bgp); | |
7374 | ||
ddb5b488 PZ |
7375 | return CMD_SUCCESS; |
7376 | } | |
7377 | ||
b9c7bc5a PZ |
7378 | ALIAS (af_rd_vpn_export, |
7379 | af_no_rd_vpn_export_cmd, | |
7380 | "no rd vpn export", | |
ddb5b488 | 7381 | NO_STR |
b9c7bc5a PZ |
7382 | "Specify route distinguisher\n" |
7383 | "Between current address-family and vpn\n" | |
7384 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7385 | |
b9c7bc5a PZ |
7386 | DEFPY (af_label_vpn_export, |
7387 | af_label_vpn_export_cmd, | |
e70e9f8e | 7388 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7389 | NO_STR |
ddb5b488 | 7390 | "label value for VRF\n" |
b9c7bc5a PZ |
7391 | "Between current address-family and vpn\n" |
7392 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7393 | "Label Value <0-1048575>\n" |
7394 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7395 | { |
7396 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7397 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7398 | afi_t afi; |
b9c7bc5a PZ |
7399 | int idx = 0; |
7400 | int yes = 1; | |
7401 | ||
7402 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7403 | yes = 0; |
ddb5b488 | 7404 | |
21a16cc2 PZ |
7405 | /* If "no ...", squash trailing parameter */ |
7406 | if (!yes) | |
7407 | label_auto = NULL; | |
7408 | ||
e70e9f8e PZ |
7409 | if (yes) { |
7410 | if (!label_auto) | |
7411 | label = label_val; /* parser should force unsigned */ | |
7412 | } | |
ddb5b488 | 7413 | |
0ca70ba5 | 7414 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7415 | if (afi == AFI_MAX) |
7416 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7417 | |
e70e9f8e | 7418 | |
69b07479 DS |
7419 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7420 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7421 | /* no change */ | |
7422 | return CMD_SUCCESS; | |
e70e9f8e | 7423 | |
69b07479 DS |
7424 | /* |
7425 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7426 | */ | |
7427 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7428 | bgp_get_default(), bgp); | |
7429 | ||
7430 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7431 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7432 | ||
7433 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7434 | ||
7435 | /* | |
7436 | * label has previously been automatically | |
7437 | * assigned by labelpool: release it | |
7438 | * | |
7439 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7440 | * means the automatic assignment is in flight | |
7441 | * and therefore the labelpool callback must | |
7442 | * detect that the auto label is not needed. | |
7443 | */ | |
7444 | ||
7445 | bgp_lp_release(LP_TYPE_VRF, | |
7446 | &bgp->vpn_policy[afi], | |
7447 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7448 | } |
69b07479 DS |
7449 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7450 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7451 | } | |
ddb5b488 | 7452 | |
69b07479 DS |
7453 | bgp->vpn_policy[afi].tovpn_label = label; |
7454 | if (label_auto) { | |
7455 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7456 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7457 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7458 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7459 | } |
7460 | ||
69b07479 DS |
7461 | /* post-change: re-export vpn routes */ |
7462 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7463 | bgp_get_default(), bgp); | |
7464 | ||
ddb5b488 PZ |
7465 | return CMD_SUCCESS; |
7466 | } | |
7467 | ||
b9c7bc5a PZ |
7468 | ALIAS (af_label_vpn_export, |
7469 | af_no_label_vpn_export_cmd, | |
7470 | "no label vpn export", | |
7471 | NO_STR | |
7472 | "label value for VRF\n" | |
7473 | "Between current address-family and vpn\n" | |
7474 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7475 | |
b9c7bc5a PZ |
7476 | DEFPY (af_nexthop_vpn_export, |
7477 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 7478 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 7479 | NO_STR |
ddb5b488 | 7480 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7481 | "Between current address-family and vpn\n" |
7482 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7483 | "IPv4 prefix\n" |
7484 | "IPv6 prefix\n") | |
7485 | { | |
7486 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7487 | afi_t afi; |
ddb5b488 PZ |
7488 | struct prefix p; |
7489 | ||
8c85ca28 QY |
7490 | if (!no) { |
7491 | if (!nexthop_su) { | |
7492 | vty_out(vty, "%% Nexthop required\n"); | |
7493 | return CMD_WARNING_CONFIG_FAILED; | |
7494 | } | |
b9c7bc5a | 7495 | |
8c85ca28 | 7496 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
7497 | return CMD_WARNING_CONFIG_FAILED; |
7498 | } | |
ddb5b488 | 7499 | |
0ca70ba5 | 7500 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7501 | if (afi == AFI_MAX) |
7502 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7503 | |
69b07479 DS |
7504 | /* |
7505 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7506 | */ | |
7507 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7508 | bgp_get_default(), bgp); | |
ddb5b488 | 7509 | |
8c85ca28 | 7510 | if (!no) { |
69b07479 DS |
7511 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
7512 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7513 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7514 | } else { | |
7515 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7516 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7517 | } |
7518 | ||
69b07479 DS |
7519 | /* post-change: re-export vpn routes */ |
7520 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7521 | bgp_get_default(), bgp); | |
7522 | ||
ddb5b488 PZ |
7523 | return CMD_SUCCESS; |
7524 | } | |
7525 | ||
b9c7bc5a | 7526 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7527 | { |
b9c7bc5a PZ |
7528 | if (!strcmp(dstr, "import")) { |
7529 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7530 | } else if (!strcmp(dstr, "export")) { | |
7531 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7532 | } else if (!strcmp(dstr, "both")) { | |
7533 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7534 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7535 | } else { | |
7536 | vty_out(vty, "%% direction parse error\n"); | |
7537 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7538 | } |
ddb5b488 PZ |
7539 | return CMD_SUCCESS; |
7540 | } | |
7541 | ||
b9c7bc5a PZ |
7542 | DEFPY (af_rt_vpn_imexport, |
7543 | af_rt_vpn_imexport_cmd, | |
7544 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7545 | NO_STR | |
7546 | "Specify route target list\n" | |
ddb5b488 | 7547 | "Specify route target list\n" |
b9c7bc5a PZ |
7548 | "Between current address-family and vpn\n" |
7549 | "For routes leaked from vpn to current address-family: match any\n" | |
7550 | "For routes leaked from current address-family to vpn: set\n" | |
7551 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7552 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7553 | { | |
7554 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7555 | int ret; | |
7556 | struct ecommunity *ecom = NULL; | |
7557 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7558 | vpn_policy_direction_t dir; |
7559 | afi_t afi; | |
7560 | int idx = 0; | |
b9c7bc5a | 7561 | int yes = 1; |
ddb5b488 | 7562 | |
b9c7bc5a | 7563 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7564 | yes = 0; |
b9c7bc5a | 7565 | |
0ca70ba5 | 7566 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7567 | if (afi == AFI_MAX) |
7568 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7569 | |
b9c7bc5a | 7570 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7571 | if (ret != CMD_SUCCESS) |
7572 | return ret; | |
7573 | ||
b9c7bc5a PZ |
7574 | if (yes) { |
7575 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7576 | vty_out(vty, "%% Missing RTLIST\n"); | |
7577 | return CMD_WARNING_CONFIG_FAILED; | |
7578 | } | |
7579 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7580 | if (ret != CMD_SUCCESS) { | |
7581 | return ret; | |
7582 | } | |
ddb5b488 PZ |
7583 | } |
7584 | ||
69b07479 DS |
7585 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7586 | if (!dodir[dir]) | |
ddb5b488 | 7587 | continue; |
ddb5b488 | 7588 | |
69b07479 | 7589 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7590 | |
69b07479 DS |
7591 | if (yes) { |
7592 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7593 | ecommunity_free( | |
7594 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7595 | bgp->vpn_policy[afi].rtlist[dir] = | |
7596 | ecommunity_dup(ecom); | |
7597 | } else { | |
7598 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7599 | ecommunity_free( | |
7600 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7601 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7602 | } |
69b07479 DS |
7603 | |
7604 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7605 | } |
69b07479 | 7606 | |
d555f3e9 PZ |
7607 | if (ecom) |
7608 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7609 | |
7610 | return CMD_SUCCESS; | |
7611 | } | |
7612 | ||
b9c7bc5a PZ |
7613 | ALIAS (af_rt_vpn_imexport, |
7614 | af_no_rt_vpn_imexport_cmd, | |
7615 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7616 | NO_STR |
7617 | "Specify route target list\n" | |
b9c7bc5a PZ |
7618 | "Specify route target list\n" |
7619 | "Between current address-family and vpn\n" | |
7620 | "For routes leaked from vpn to current address-family\n" | |
7621 | "For routes leaked from current address-family to vpn\n" | |
7622 | "both import and export\n") | |
7623 | ||
7624 | DEFPY (af_route_map_vpn_imexport, | |
7625 | af_route_map_vpn_imexport_cmd, | |
7626 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7627 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7628 | NO_STR | |
ddb5b488 | 7629 | "Specify route map\n" |
b9c7bc5a PZ |
7630 | "Between current address-family and vpn\n" |
7631 | "For routes leaked from vpn to current address-family\n" | |
7632 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7633 | "name of route-map\n") |
7634 | { | |
7635 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7636 | int ret; | |
7637 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7638 | vpn_policy_direction_t dir; |
7639 | afi_t afi; | |
ddb5b488 | 7640 | int idx = 0; |
b9c7bc5a | 7641 | int yes = 1; |
ddb5b488 | 7642 | |
b9c7bc5a | 7643 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7644 | yes = 0; |
b9c7bc5a | 7645 | |
0ca70ba5 | 7646 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7647 | if (afi == AFI_MAX) |
7648 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7649 | |
b9c7bc5a | 7650 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7651 | if (ret != CMD_SUCCESS) |
7652 | return ret; | |
7653 | ||
69b07479 DS |
7654 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7655 | if (!dodir[dir]) | |
ddb5b488 | 7656 | continue; |
ddb5b488 | 7657 | |
69b07479 | 7658 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7659 | |
69b07479 DS |
7660 | if (yes) { |
7661 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7662 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7663 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7664 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7665 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7666 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7667 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7668 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7669 | return CMD_SUCCESS; | |
7670 | } else { | |
7671 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7672 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7673 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7674 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7675 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7676 | } |
69b07479 DS |
7677 | |
7678 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7679 | } |
7680 | ||
7681 | return CMD_SUCCESS; | |
7682 | } | |
7683 | ||
b9c7bc5a PZ |
7684 | ALIAS (af_route_map_vpn_imexport, |
7685 | af_no_route_map_vpn_imexport_cmd, | |
7686 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7687 | NO_STR |
7688 | "Specify route map\n" | |
b9c7bc5a PZ |
7689 | "Between current address-family and vpn\n" |
7690 | "For routes leaked from vpn to current address-family\n" | |
7691 | "For routes leaked from current address-family to vpn\n") | |
7692 | ||
bb4f6190 | 7693 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 7694 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
7695 | "Import routes from another VRF\n" |
7696 | "Vrf routes being filtered\n" | |
7697 | "Specify route map\n" | |
7698 | "name of route-map\n") | |
7699 | { | |
7700 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7701 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7702 | afi_t afi; | |
bb4f6190 DS |
7703 | struct bgp *bgp_default; |
7704 | ||
0ca70ba5 | 7705 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7706 | if (afi == AFI_MAX) |
7707 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7708 | |
7709 | bgp_default = bgp_get_default(); | |
7710 | if (!bgp_default) { | |
7711 | int32_t ret; | |
7712 | as_t as = bgp->as; | |
7713 | ||
7714 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7715 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7716 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7717 | |
7718 | if (ret) { | |
7719 | vty_out(vty, | |
7720 | "VRF default is not configured as a bgp instance\n"); | |
7721 | return CMD_WARNING; | |
7722 | } | |
7723 | } | |
7724 | ||
69b07479 | 7725 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7726 | |
ae6a6fb4 DS |
7727 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
7728 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7729 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7730 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7731 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7732 | bgp->vpn_policy[afi].rmap[dir] = | |
7733 | route_map_lookup_warn_noexist(vty, rmap_str); | |
7734 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
7735 | return CMD_SUCCESS; | |
7736 | ||
7737 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7738 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 7739 | |
69b07479 DS |
7740 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7741 | ||
bb4f6190 DS |
7742 | return CMD_SUCCESS; |
7743 | } | |
7744 | ||
ae6a6fb4 DS |
7745 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
7746 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
7747 | NO_STR |
7748 | "Import routes from another VRF\n" | |
7749 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
7750 | "Specify route map\n" |
7751 | "name of route-map\n") | |
7752 | { | |
7753 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7754 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7755 | afi_t afi; | |
7756 | ||
7757 | afi = vpn_policy_getafi(vty, bgp, true); | |
7758 | if (afi == AFI_MAX) | |
7759 | return CMD_WARNING_CONFIG_FAILED; | |
7760 | ||
7761 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7762 | ||
7763 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7764 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7765 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7766 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7767 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
7768 | ||
7769 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
7770 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7771 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
7772 | ||
7773 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
7774 | ||
7775 | return CMD_SUCCESS; | |
7776 | } | |
bb4f6190 | 7777 | |
4d1b335c DA |
7778 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7779 | "[no] import vrf VIEWVRFNAME$import_name", | |
7780 | NO_STR | |
7781 | "Import routes from another VRF\n" | |
7782 | "VRF to import from\n" | |
7783 | "The name of the VRF\n") | |
12a844a5 DS |
7784 | { |
7785 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7786 | struct listnode *node; | |
79ef8664 DS |
7787 | struct bgp *vrf_bgp, *bgp_default; |
7788 | int32_t ret = 0; | |
7789 | as_t as = bgp->as; | |
12a844a5 DS |
7790 | bool remove = false; |
7791 | int32_t idx = 0; | |
7792 | char *vname; | |
a8dadcf6 | 7793 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7794 | safi_t safi; |
7795 | afi_t afi; | |
7796 | ||
867f0cca | 7797 | if (import_name == NULL) { |
7798 | vty_out(vty, "%% Missing import name\n"); | |
7799 | return CMD_WARNING; | |
7800 | } | |
7801 | ||
ae6a6fb4 DS |
7802 | if (strcmp(import_name, "route-map") == 0) { |
7803 | vty_out(vty, "%% Must include route-map name\n"); | |
7804 | return CMD_WARNING; | |
7805 | } | |
7806 | ||
12a844a5 DS |
7807 | if (argv_find(argv, argc, "no", &idx)) |
7808 | remove = true; | |
7809 | ||
0ca70ba5 DS |
7810 | afi = vpn_policy_getafi(vty, bgp, true); |
7811 | if (afi == AFI_MAX) | |
7812 | return CMD_WARNING_CONFIG_FAILED; | |
7813 | ||
12a844a5 DS |
7814 | safi = bgp_node_safi(vty); |
7815 | ||
25679caa | 7816 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7817 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7818 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7819 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7820 | remove ? "unimport" : "import", import_name); | |
7821 | return CMD_WARNING; | |
7822 | } | |
7823 | ||
79ef8664 DS |
7824 | bgp_default = bgp_get_default(); |
7825 | if (!bgp_default) { | |
7826 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7827 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7828 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7829 | |
7830 | if (ret) { | |
7831 | vty_out(vty, | |
7832 | "VRF default is not configured as a bgp instance\n"); | |
7833 | return CMD_WARNING; | |
7834 | } | |
7835 | } | |
7836 | ||
12a844a5 DS |
7837 | vrf_bgp = bgp_lookup_by_name(import_name); |
7838 | if (!vrf_bgp) { | |
5742e42b | 7839 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7840 | vrf_bgp = bgp_default; |
7841 | else | |
0fb8d6e6 | 7842 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7843 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7844 | |
6e2c7fe6 | 7845 | if (ret) { |
020a3f60 DS |
7846 | vty_out(vty, |
7847 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7848 | import_name); |
7849 | return CMD_WARNING; | |
7850 | } | |
12a844a5 DS |
7851 | } |
7852 | ||
12a844a5 | 7853 | if (remove) { |
44338987 | 7854 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7855 | } else { |
44338987 | 7856 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7857 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7858 | vname)) { | |
7859 | if (strcmp(vname, import_name) == 0) | |
7860 | return CMD_WARNING; | |
7861 | } | |
7862 | ||
44338987 | 7863 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7864 | } |
7865 | ||
7866 | return CMD_SUCCESS; | |
7867 | } | |
7868 | ||
b9c7bc5a PZ |
7869 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7870 | DEFPY (bgp_imexport_vpn, | |
7871 | bgp_imexport_vpn_cmd, | |
7872 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7873 | NO_STR |
7874 | "Import routes to this address-family\n" | |
7875 | "Export routes from this address-family\n" | |
7876 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7877 | { |
7878 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7879 | int previous_state; |
ddb5b488 | 7880 | afi_t afi; |
b9c7bc5a | 7881 | safi_t safi; |
ddb5b488 | 7882 | int idx = 0; |
b9c7bc5a PZ |
7883 | int yes = 1; |
7884 | int flag; | |
7885 | vpn_policy_direction_t dir; | |
ddb5b488 | 7886 | |
b9c7bc5a | 7887 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7888 | yes = 0; |
ddb5b488 | 7889 | |
b9c7bc5a PZ |
7890 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7891 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7892 | |
b9c7bc5a PZ |
7893 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7894 | return CMD_WARNING_CONFIG_FAILED; | |
7895 | } | |
ddb5b488 | 7896 | |
b9c7bc5a PZ |
7897 | afi = bgp_node_afi(vty); |
7898 | safi = bgp_node_safi(vty); | |
7899 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7900 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7901 | return CMD_WARNING_CONFIG_FAILED; | |
7902 | } | |
ddb5b488 | 7903 | |
b9c7bc5a PZ |
7904 | if (!strcmp(direction_str, "import")) { |
7905 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7906 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7907 | } else if (!strcmp(direction_str, "export")) { | |
7908 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7909 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7910 | } else { | |
7911 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7912 | return CMD_WARNING_CONFIG_FAILED; | |
7913 | } | |
7914 | ||
7915 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7916 | |
b9c7bc5a PZ |
7917 | if (yes) { |
7918 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7919 | if (!previous_state) { | |
7920 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7921 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7922 | } | |
b9c7bc5a PZ |
7923 | } else { |
7924 | if (previous_state) { | |
7925 | /* trigger un-export current vrf */ | |
7926 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7927 | } | |
7928 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7929 | } |
7930 | ||
7931 | return CMD_SUCCESS; | |
7932 | } | |
7933 | ||
301ad80a PG |
7934 | DEFPY (af_routetarget_import, |
7935 | af_routetarget_import_cmd, | |
7936 | "[no] <rt|route-target> redirect import RTLIST...", | |
7937 | NO_STR | |
7938 | "Specify route target list\n" | |
7939 | "Specify route target list\n" | |
7940 | "Flow-spec redirect type route target\n" | |
7941 | "Import routes to this address-family\n" | |
7942 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7943 | { | |
7944 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7945 | int ret; | |
7946 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7947 | afi_t afi; |
7948 | int idx = 0; | |
7949 | int yes = 1; | |
7950 | ||
7951 | if (argv_find(argv, argc, "no", &idx)) | |
7952 | yes = 0; | |
7953 | ||
0ca70ba5 | 7954 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7955 | if (afi == AFI_MAX) |
7956 | return CMD_WARNING_CONFIG_FAILED; | |
7957 | ||
301ad80a PG |
7958 | if (yes) { |
7959 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7960 | vty_out(vty, "%% Missing RTLIST\n"); | |
7961 | return CMD_WARNING_CONFIG_FAILED; | |
7962 | } | |
7963 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7964 | if (ret != CMD_SUCCESS) | |
7965 | return ret; | |
7966 | } | |
69b07479 DS |
7967 | |
7968 | if (yes) { | |
7969 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7970 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7971 | .import_redirect_rtlist); |
69b07479 DS |
7972 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7973 | ecommunity_dup(ecom); | |
7974 | } else { | |
7975 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7976 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7977 | .import_redirect_rtlist); |
69b07479 | 7978 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7979 | } |
69b07479 | 7980 | |
301ad80a PG |
7981 | if (ecom) |
7982 | ecommunity_free(&ecom); | |
7983 | ||
7984 | return CMD_SUCCESS; | |
7985 | } | |
7986 | ||
505e5056 | 7987 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7988 | address_family_ipv4_safi_cmd, |
7989 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7990 | "Enter Address Family command mode\n" | |
7991 | "Address Family\n" | |
7992 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7993 | { |
f51bae9c | 7994 | |
d62a17ae | 7995 | if (argc == 3) { |
2131d5cf | 7996 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7997 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7998 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7999 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8000 | && safi != SAFI_EVPN) { |
31947174 MK |
8001 | vty_out(vty, |
8002 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8003 | return CMD_WARNING_CONFIG_FAILED; |
8004 | } | |
d62a17ae | 8005 | vty->node = bgp_node_type(AFI_IP, safi); |
8006 | } else | |
8007 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 8008 | |
d62a17ae | 8009 | return CMD_SUCCESS; |
718e3744 | 8010 | } |
8011 | ||
505e5056 | 8012 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 8013 | address_family_ipv6_safi_cmd, |
8014 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
8015 | "Enter Address Family command mode\n" | |
8016 | "Address Family\n" | |
8017 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 8018 | { |
d62a17ae | 8019 | if (argc == 3) { |
2131d5cf | 8020 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8021 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
8022 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
8023 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 8024 | && safi != SAFI_EVPN) { |
31947174 MK |
8025 | vty_out(vty, |
8026 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
8027 | return CMD_WARNING_CONFIG_FAILED; |
8028 | } | |
d62a17ae | 8029 | vty->node = bgp_node_type(AFI_IP6, safi); |
8030 | } else | |
8031 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 8032 | |
d62a17ae | 8033 | return CMD_SUCCESS; |
25ffbdc1 | 8034 | } |
718e3744 | 8035 | |
d6902373 | 8036 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 8037 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 8038 | address_family_vpnv4_cmd, |
8334fd5a | 8039 | "address-family vpnv4 [unicast]", |
718e3744 | 8040 | "Enter Address Family command mode\n" |
8c3deaae | 8041 | "Address Family\n" |
3a2d747c | 8042 | "Address Family modifier\n") |
718e3744 | 8043 | { |
d62a17ae | 8044 | vty->node = BGP_VPNV4_NODE; |
8045 | return CMD_SUCCESS; | |
718e3744 | 8046 | } |
8047 | ||
505e5056 | 8048 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 8049 | address_family_vpnv6_cmd, |
8334fd5a | 8050 | "address-family vpnv6 [unicast]", |
8ecd3266 | 8051 | "Enter Address Family command mode\n" |
8c3deaae | 8052 | "Address Family\n" |
3a2d747c | 8053 | "Address Family modifier\n") |
8ecd3266 | 8054 | { |
d62a17ae | 8055 | vty->node = BGP_VPNV6_NODE; |
8056 | return CMD_SUCCESS; | |
8ecd3266 | 8057 | } |
64e4a6c5 | 8058 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 8059 | |
505e5056 | 8060 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 8061 | address_family_evpn_cmd, |
7111c1a0 | 8062 | "address-family l2vpn evpn", |
4e0b7b6d | 8063 | "Enter Address Family command mode\n" |
7111c1a0 QY |
8064 | "Address Family\n" |
8065 | "Address Family modifier\n") | |
4e0b7b6d | 8066 | { |
2131d5cf | 8067 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 8068 | vty->node = BGP_EVPN_NODE; |
8069 | return CMD_SUCCESS; | |
4e0b7b6d PG |
8070 | } |
8071 | ||
505e5056 | 8072 | DEFUN_NOSH (exit_address_family, |
718e3744 | 8073 | exit_address_family_cmd, |
8074 | "exit-address-family", | |
8075 | "Exit from Address Family configuration mode\n") | |
8076 | { | |
d62a17ae | 8077 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
8078 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
8079 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
8080 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
8081 | || vty->node == BGP_EVPN_NODE |
8082 | || vty->node == BGP_FLOWSPECV4_NODE | |
8083 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 8084 | vty->node = BGP_NODE; |
8085 | return CMD_SUCCESS; | |
718e3744 | 8086 | } |
6b0655a2 | 8087 | |
8ad7271d | 8088 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 8089 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
8090 | const char *ip_str, afi_t afi, safi_t safi, | |
8091 | struct prefix_rd *prd) | |
8092 | { | |
8093 | int ret; | |
8094 | struct prefix match; | |
9bcb3eef DS |
8095 | struct bgp_dest *dest; |
8096 | struct bgp_dest *rm; | |
d62a17ae | 8097 | struct bgp *bgp; |
8098 | struct bgp_table *table; | |
8099 | struct bgp_table *rib; | |
8100 | ||
8101 | /* BGP structure lookup. */ | |
8102 | if (view_name) { | |
8103 | bgp = bgp_lookup_by_name(view_name); | |
8104 | if (bgp == NULL) { | |
8105 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
8106 | view_name); | |
8107 | return CMD_WARNING; | |
8108 | } | |
8109 | } else { | |
8110 | bgp = bgp_get_default(); | |
8111 | if (bgp == NULL) { | |
8112 | vty_out(vty, "%% No BGP process is configured\n"); | |
8113 | return CMD_WARNING; | |
8114 | } | |
8115 | } | |
8116 | ||
8117 | /* Check IP address argument. */ | |
8118 | ret = str2prefix(ip_str, &match); | |
8119 | if (!ret) { | |
8120 | vty_out(vty, "%% address is malformed\n"); | |
8121 | return CMD_WARNING; | |
8122 | } | |
8123 | ||
8124 | match.family = afi2family(afi); | |
8125 | rib = bgp->rib[afi][safi]; | |
8126 | ||
8127 | if (safi == SAFI_MPLS_VPN) { | |
9bcb3eef DS |
8128 | for (dest = bgp_table_top(rib); dest; |
8129 | dest = bgp_route_next(dest)) { | |
8130 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8131 | |
9bcb3eef | 8132 | if (prd && memcmp(dest_p->u.val, prd->val, 8) != 0) |
d62a17ae | 8133 | continue; |
8134 | ||
9bcb3eef | 8135 | table = bgp_dest_get_bgp_table_info(dest); |
b54892e0 DS |
8136 | if (table == NULL) |
8137 | continue; | |
8138 | ||
8139 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
8140 | const struct prefix *rm_p = | |
9bcb3eef | 8141 | bgp_dest_get_prefix(rm); |
b54892e0 DS |
8142 | |
8143 | if (rm_p->prefixlen == match.prefixlen) { | |
8144 | SET_FLAG(rm->flags, | |
8145 | BGP_NODE_USER_CLEAR); | |
8146 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 8147 | } |
9bcb3eef | 8148 | bgp_dest_unlock_node(rm); |
d62a17ae | 8149 | } |
8150 | } | |
8151 | } else { | |
9bcb3eef DS |
8152 | if ((dest = bgp_node_match(rib, &match)) != NULL) { |
8153 | const struct prefix *dest_p = bgp_dest_get_prefix(dest); | |
b54892e0 | 8154 | |
9bcb3eef DS |
8155 | if (dest_p->prefixlen == match.prefixlen) { |
8156 | SET_FLAG(dest->flags, BGP_NODE_USER_CLEAR); | |
8157 | bgp_process(bgp, dest, afi, safi); | |
d62a17ae | 8158 | } |
9bcb3eef | 8159 | bgp_dest_unlock_node(dest); |
d62a17ae | 8160 | } |
8161 | } | |
8162 | ||
8163 | return CMD_SUCCESS; | |
8ad7271d DS |
8164 | } |
8165 | ||
b09b5ae0 | 8166 | /* one clear bgp command to rule them all */ |
718e3744 | 8167 | DEFUN (clear_ip_bgp_all, |
8168 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8169 | "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 | 8170 | CLEAR_STR |
8171 | IP_STR | |
8172 | BGP_STR | |
838758ac | 8173 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8174 | BGP_AFI_HELP_STR |
fd5e7b70 | 8175 | "Address Family\n" |
510afcd6 | 8176 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8177 | "Address Family modifier\n" |
b09b5ae0 | 8178 | "Clear all peers\n" |
453c92f6 | 8179 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8180 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8181 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8182 | "Clear peers with the AS number\n" |
8183 | "Clear all external peers\n" | |
718e3744 | 8184 | "Clear all members of peer-group\n" |
b09b5ae0 | 8185 | "BGP peer-group name\n" |
b09b5ae0 DW |
8186 | BGP_SOFT_STR |
8187 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8188 | BGP_SOFT_OUT_STR |
8189 | BGP_SOFT_IN_STR | |
8190 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8191 | BGP_SOFT_OUT_STR) |
718e3744 | 8192 | { |
d62a17ae | 8193 | char *vrf = NULL; |
8194 | ||
dc912615 DS |
8195 | afi_t afi = AFI_UNSPEC; |
8196 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8197 | enum clear_sort clr_sort = clear_peer; |
8198 | enum bgp_clear_type clr_type; | |
8199 | char *clr_arg = NULL; | |
8200 | ||
8201 | int idx = 0; | |
8202 | ||
8203 | /* clear [ip] bgp */ | |
8204 | if (argv_find(argv, argc, "ip", &idx)) | |
8205 | afi = AFI_IP; | |
8206 | ||
9a8bdf1c PG |
8207 | /* [<vrf> VIEWVRFNAME] */ |
8208 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8209 | vrf = argv[idx + 1]->arg; | |
8210 | idx += 2; | |
8211 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8212 | vrf = NULL; | |
8213 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8214 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8215 | vrf = argv[idx + 1]->arg; |
8216 | idx += 2; | |
8217 | } | |
d62a17ae | 8218 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8219 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8220 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8221 | ||
d7b9898c | 8222 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8223 | if (argv_find(argv, argc, "*", &idx)) { |
8224 | clr_sort = clear_all; | |
8225 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8226 | clr_sort = clear_peer; | |
8227 | clr_arg = argv[idx]->arg; | |
8228 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8229 | clr_sort = clear_peer; | |
8230 | clr_arg = argv[idx]->arg; | |
8231 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8232 | clr_sort = clear_group; | |
8233 | idx++; | |
8234 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8235 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8236 | clr_sort = clear_peer; |
8237 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8238 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8239 | clr_sort = clear_peer; | |
8240 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8241 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8242 | clr_sort = clear_as; | |
8243 | clr_arg = argv[idx]->arg; | |
8244 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8245 | clr_sort = clear_external; | |
8246 | } | |
8247 | ||
8248 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8249 | if (argv_find(argv, argc, "soft", &idx)) { | |
8250 | if (argv_find(argv, argc, "in", &idx) | |
8251 | || argv_find(argv, argc, "out", &idx)) | |
8252 | clr_type = strmatch(argv[idx]->text, "in") | |
8253 | ? BGP_CLEAR_SOFT_IN | |
8254 | : BGP_CLEAR_SOFT_OUT; | |
8255 | else | |
8256 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8257 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8258 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8259 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8260 | : BGP_CLEAR_SOFT_IN; | |
8261 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8262 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8263 | } else | |
8264 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8265 | ||
8266 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8267 | } |
01080f7c | 8268 | |
8ad7271d DS |
8269 | DEFUN (clear_ip_bgp_prefix, |
8270 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8271 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8272 | CLEAR_STR |
8273 | IP_STR | |
8274 | BGP_STR | |
838758ac | 8275 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8276 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8277 | "IPv4 prefix\n") |
8ad7271d | 8278 | { |
d62a17ae | 8279 | char *vrf = NULL; |
8280 | char *prefix = NULL; | |
8ad7271d | 8281 | |
d62a17ae | 8282 | int idx = 0; |
01080f7c | 8283 | |
d62a17ae | 8284 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8285 | if (argv_find(argv, argc, "vrf", &idx)) { |
8286 | vrf = argv[idx + 1]->arg; | |
8287 | idx += 2; | |
8288 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8289 | vrf = NULL; | |
8290 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8291 | /* [<view> VIEWVRFNAME] */ | |
8292 | vrf = argv[idx + 1]->arg; | |
8293 | idx += 2; | |
8294 | } | |
0c7b1b01 | 8295 | |
d62a17ae | 8296 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8297 | |
d62a17ae | 8298 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8299 | } |
8ad7271d | 8300 | |
b09b5ae0 DW |
8301 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8302 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8303 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8304 | CLEAR_STR |
3a2d747c | 8305 | IP_STR |
718e3744 | 8306 | BGP_STR |
8c3deaae | 8307 | "Address Family\n" |
46f296b4 | 8308 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8309 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8310 | "IPv6 prefix\n") |
718e3744 | 8311 | { |
9b475e76 PG |
8312 | int idx_safi = 0; |
8313 | int idx_ipv6_prefix = 0; | |
8314 | safi_t safi = SAFI_UNICAST; | |
8315 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8316 | argv[idx_ipv6_prefix]->arg : NULL; | |
8317 | ||
8318 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8319 | return bgp_clear_prefix( |
9b475e76 PG |
8320 | vty, NULL, prefix, AFI_IP6, |
8321 | safi, NULL); | |
838758ac | 8322 | } |
01080f7c | 8323 | |
b09b5ae0 DW |
8324 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8325 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8326 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8327 | CLEAR_STR |
3a2d747c | 8328 | IP_STR |
718e3744 | 8329 | BGP_STR |
838758ac | 8330 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8331 | "Address Family\n" |
46f296b4 | 8332 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8333 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8334 | "IPv6 prefix\n") |
718e3744 | 8335 | { |
9b475e76 | 8336 | int idx_safi = 0; |
9a8bdf1c | 8337 | int idx_vrfview = 0; |
9b475e76 PG |
8338 | int idx_ipv6_prefix = 0; |
8339 | safi_t safi = SAFI_UNICAST; | |
8340 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8341 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8342 | char *vrfview = NULL; |
9b475e76 | 8343 | |
9a8bdf1c PG |
8344 | /* [<view|vrf> VIEWVRFNAME] */ |
8345 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8346 | vrfview = argv[idx_vrfview + 1]->arg; | |
8347 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8348 | vrfview = NULL; | |
8349 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8350 | /* [<view> VIEWVRFNAME] */ | |
8351 | vrfview = argv[idx_vrfview + 1]->arg; | |
8352 | } | |
9b475e76 PG |
8353 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8354 | ||
d62a17ae | 8355 | return bgp_clear_prefix( |
9b475e76 PG |
8356 | vty, vrfview, prefix, |
8357 | AFI_IP6, safi, NULL); | |
718e3744 | 8358 | } |
8359 | ||
b09b5ae0 DW |
8360 | DEFUN (show_bgp_views, |
8361 | show_bgp_views_cmd, | |
d6e3c605 | 8362 | "show [ip] bgp views", |
b09b5ae0 | 8363 | SHOW_STR |
d6e3c605 | 8364 | IP_STR |
01080f7c | 8365 | BGP_STR |
b09b5ae0 | 8366 | "Show the defined BGP views\n") |
01080f7c | 8367 | { |
d62a17ae | 8368 | struct list *inst = bm->bgp; |
8369 | struct listnode *node; | |
8370 | struct bgp *bgp; | |
01080f7c | 8371 | |
d62a17ae | 8372 | vty_out(vty, "Defined BGP views:\n"); |
8373 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8374 | /* Skip VRFs. */ | |
8375 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8376 | continue; | |
8377 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8378 | bgp->as); | |
8379 | } | |
e52702f2 | 8380 | |
d62a17ae | 8381 | return CMD_SUCCESS; |
e0081f70 ML |
8382 | } |
8383 | ||
8386ac43 | 8384 | DEFUN (show_bgp_vrfs, |
8385 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8386 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8387 | SHOW_STR |
d6e3c605 | 8388 | IP_STR |
8386ac43 | 8389 | BGP_STR |
8390 | "Show BGP VRFs\n" | |
9973d184 | 8391 | JSON_STR) |
8386ac43 | 8392 | { |
fe1dc5a3 | 8393 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8394 | struct list *inst = bm->bgp; |
8395 | struct listnode *node; | |
8396 | struct bgp *bgp; | |
9f049418 | 8397 | bool uj = use_json(argc, argv); |
d62a17ae | 8398 | json_object *json = NULL; |
8399 | json_object *json_vrfs = NULL; | |
8400 | int count = 0; | |
d62a17ae | 8401 | |
d62a17ae | 8402 | if (uj) { |
8403 | json = json_object_new_object(); | |
8404 | json_vrfs = json_object_new_object(); | |
8405 | } | |
8406 | ||
8407 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8408 | const char *name, *type; | |
8409 | struct peer *peer; | |
7fe96307 | 8410 | struct listnode *node2, *nnode2; |
d62a17ae | 8411 | int peers_cfg, peers_estb; |
8412 | json_object *json_vrf = NULL; | |
d62a17ae | 8413 | |
8414 | /* Skip Views. */ | |
8415 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8416 | continue; | |
8417 | ||
8418 | count++; | |
efb4077a | 8419 | if (!uj && count == 1) { |
fe1dc5a3 | 8420 | vty_out(vty, |
efb4077a | 8421 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8422 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8423 | "#PeersEstb", "Name"); |
8424 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8425 | "L3-VNI", "RouterMAC", "Interface"); | |
8426 | } | |
d62a17ae | 8427 | |
8428 | peers_cfg = peers_estb = 0; | |
8429 | if (uj) | |
8430 | json_vrf = json_object_new_object(); | |
8431 | ||
8432 | ||
7fe96307 | 8433 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8434 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8435 | continue; | |
8436 | peers_cfg++; | |
8437 | if (peer->status == Established) | |
8438 | peers_estb++; | |
8439 | } | |
8440 | ||
8441 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8442 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8443 | type = "DFLT"; |
8444 | } else { | |
8445 | name = bgp->name; | |
8446 | type = "VRF"; | |
8447 | } | |
8448 | ||
a8bf7d9c | 8449 | |
d62a17ae | 8450 | if (uj) { |
a4d82a8a PZ |
8451 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8452 | ? -1 | |
8453 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8454 | json_object_string_add(json_vrf, "type", type); |
8455 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8456 | json_object_string_add(json_vrf, "routerId", | |
8457 | inet_ntoa(bgp->router_id)); | |
8458 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8459 | peers_cfg); | |
8460 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8461 | peers_estb); | |
8462 | ||
fe1dc5a3 | 8463 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8464 | json_object_string_add( |
8465 | json_vrf, "rmac", | |
8466 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8467 | json_object_string_add(json_vrf, "interface", |
8468 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8469 | bgp->vrf_id)); | |
d62a17ae | 8470 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8471 | } else { |
fe1dc5a3 | 8472 | vty_out(vty, |
efb4077a | 8473 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8474 | type, |
8475 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8476 | : (int)bgp->vrf_id, | |
8477 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8478 | peers_estb, name); |
8479 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8480 | bgp->l3vni, | |
8481 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8482 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8483 | bgp->vrf_id)); | |
8484 | } | |
d62a17ae | 8485 | } |
8486 | ||
8487 | if (uj) { | |
8488 | json_object_object_add(json, "vrfs", json_vrfs); | |
8489 | ||
8490 | json_object_int_add(json, "totalVrfs", count); | |
8491 | ||
996c9314 LB |
8492 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8493 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8494 | json_object_free(json); |
8495 | } else { | |
8496 | if (count) | |
8497 | vty_out(vty, | |
8498 | "\nTotal number of VRFs (including default): %d\n", | |
8499 | count); | |
8500 | } | |
8501 | ||
8502 | return CMD_SUCCESS; | |
8386ac43 | 8503 | } |
8504 | ||
48ecf8f5 DS |
8505 | DEFUN (show_bgp_mac_hash, |
8506 | show_bgp_mac_hash_cmd, | |
8507 | "show bgp mac hash", | |
8508 | SHOW_STR | |
8509 | BGP_STR | |
8510 | "Mac Address\n" | |
8511 | "Mac Address database\n") | |
8512 | { | |
8513 | bgp_mac_dump_table(vty); | |
8514 | ||
8515 | return CMD_SUCCESS; | |
8516 | } | |
acf71666 | 8517 | |
e3b78da8 | 8518 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8519 | { |
0291c246 | 8520 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8521 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8522 | |
60466a63 | 8523 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8524 | tip->refcnt); |
8525 | } | |
8526 | ||
8527 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8528 | { | |
8529 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8530 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8531 | |
8532 | vty_out(vty, "Tunnel-ip database:\n"); | |
8533 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8534 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8535 | vty); |
8536 | } | |
8537 | ||
15c81ca4 DS |
8538 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8539 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8540 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8541 | "martian next-hops\n" |
8542 | "martian next-hop database\n") | |
acf71666 | 8543 | { |
0291c246 | 8544 | struct bgp *bgp = NULL; |
15c81ca4 | 8545 | int idx = 0; |
9a8bdf1c PG |
8546 | char *name = NULL; |
8547 | ||
8548 | /* [<vrf> VIEWVRFNAME] */ | |
8549 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8550 | name = argv[idx + 1]->arg; | |
8551 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8552 | name = NULL; | |
8553 | } else if (argv_find(argv, argc, "view", &idx)) | |
8554 | /* [<view> VIEWVRFNAME] */ | |
8555 | name = argv[idx + 1]->arg; | |
8556 | if (name) | |
8557 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8558 | else |
8559 | bgp = bgp_get_default(); | |
acf71666 | 8560 | |
acf71666 MK |
8561 | if (!bgp) { |
8562 | vty_out(vty, "%% No BGP process is configured\n"); | |
8563 | return CMD_WARNING; | |
8564 | } | |
8565 | bgp_show_martian_nexthops(vty, bgp); | |
8566 | ||
8567 | return CMD_SUCCESS; | |
8568 | } | |
8569 | ||
f412b39a | 8570 | DEFUN (show_bgp_memory, |
4bf6a362 | 8571 | show_bgp_memory_cmd, |
7fa12b13 | 8572 | "show [ip] bgp memory", |
4bf6a362 | 8573 | SHOW_STR |
3a2d747c | 8574 | IP_STR |
4bf6a362 PJ |
8575 | BGP_STR |
8576 | "Global BGP memory statistics\n") | |
8577 | { | |
d62a17ae | 8578 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8579 | unsigned long count; | |
8580 | ||
8581 | /* RIB related usage stats */ | |
8582 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8583 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8584 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
9bcb3eef | 8585 | count * sizeof(struct bgp_dest))); |
d62a17ae | 8586 | |
8587 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8588 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8589 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8590 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8591 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8592 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8593 | count, | |
4b7e6066 DS |
8594 | mtype_memstr( |
8595 | memstrbuf, sizeof(memstrbuf), | |
8596 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8597 | |
8598 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8599 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8600 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8601 | count * sizeof(struct bgp_static))); | |
8602 | ||
8603 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8604 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8605 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8606 | count * sizeof(struct bpacket))); | |
8607 | ||
8608 | /* Adj-In/Out */ | |
8609 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8610 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8611 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8612 | count * sizeof(struct bgp_adj_in))); | |
8613 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8614 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8615 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8616 | count * sizeof(struct bgp_adj_out))); | |
8617 | ||
8618 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8619 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8620 | count, | |
8621 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8622 | count * sizeof(struct bgp_nexthop_cache))); | |
8623 | ||
8624 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8625 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8626 | count, | |
8627 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8628 | count * sizeof(struct bgp_damp_info))); | |
8629 | ||
8630 | /* Attributes */ | |
8631 | count = attr_count(); | |
8632 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8633 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8634 | count * sizeof(struct attr))); | |
8635 | ||
8636 | if ((count = attr_unknown_count())) | |
8637 | vty_out(vty, "%ld unknown attributes\n", count); | |
8638 | ||
8639 | /* AS_PATH attributes */ | |
8640 | count = aspath_count(); | |
8641 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8642 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8643 | count * sizeof(struct aspath))); | |
8644 | ||
8645 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8646 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8647 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8648 | count * sizeof(struct assegment))); | |
8649 | ||
8650 | /* Other attributes */ | |
8651 | if ((count = community_count())) | |
8652 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8653 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8654 | count * sizeof(struct community))); | |
d62a17ae | 8655 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8656 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8657 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8658 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8659 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8660 | vty_out(vty, | |
8661 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8662 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8663 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8664 | |
8665 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8666 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8667 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8668 | count * sizeof(struct cluster_list))); | |
8669 | ||
8670 | /* Peer related usage */ | |
8671 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8672 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8673 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8674 | count * sizeof(struct peer))); | |
8675 | ||
8676 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8677 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8678 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8679 | count * sizeof(struct peer_group))); | |
8680 | ||
8681 | /* Other */ | |
d62a17ae | 8682 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8683 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8684 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8685 | count * sizeof(regex_t))); | |
d62a17ae | 8686 | return CMD_SUCCESS; |
4bf6a362 | 8687 | } |
fee0f4c6 | 8688 | |
57a9c8a8 DS |
8689 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8690 | { | |
8691 | json_object *bestpath = json_object_new_object(); | |
8692 | ||
892fedb6 | 8693 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
8694 | json_object_string_add(bestpath, "asPath", "ignore"); |
8695 | ||
892fedb6 | 8696 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
8697 | json_object_string_add(bestpath, "asPath", "confed"); |
8698 | ||
892fedb6 DA |
8699 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
8700 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 8701 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8702 | "as-set"); |
8703 | else | |
a4d82a8a | 8704 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8705 | "true"); |
8706 | } else | |
a4d82a8a | 8707 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 8708 | |
892fedb6 | 8709 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 8710 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
8711 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
8712 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8713 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8714 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 8715 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
8716 | json_object_string_add(bestpath, "med", |
8717 | "missing-as-worst"); | |
8718 | else | |
8719 | json_object_string_add(bestpath, "med", "true"); | |
8720 | } | |
8721 | ||
8722 | json_object_object_add(json, "bestPath", bestpath); | |
8723 | } | |
8724 | ||
3577f1c5 DD |
8725 | /* Print the error code/subcode for why the peer is down */ |
8726 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8727 | json_object *json_peer, bool use_json) | |
8728 | { | |
8729 | const char *code_str; | |
8730 | const char *subcode_str; | |
8731 | ||
8732 | if (use_json) { | |
8733 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8734 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8735 | char errorcodesubcode_hexstr[5]; | |
8736 | char errorcodesubcode_str[256]; | |
8737 | ||
8738 | code_str = bgp_notify_code_str(peer->notify.code); | |
8739 | subcode_str = bgp_notify_subcode_str( | |
8740 | peer->notify.code, | |
8741 | peer->notify.subcode); | |
8742 | ||
772270f3 QY |
8743 | snprintf(errorcodesubcode_hexstr, |
8744 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
8745 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
8746 | json_object_string_add(json_peer, |
8747 | "lastErrorCodeSubcode", | |
8748 | errorcodesubcode_hexstr); | |
8749 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8750 | code_str, subcode_str); | |
8751 | json_object_string_add(json_peer, | |
8752 | "lastNotificationReason", | |
8753 | errorcodesubcode_str); | |
8754 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8755 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8756 | && (peer->notify.subcode | |
8757 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8758 | || peer->notify.subcode | |
8759 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8760 | && peer->notify.length) { | |
8761 | char msgbuf[1024]; | |
8762 | const char *msg_str; | |
8763 | ||
8764 | msg_str = bgp_notify_admin_message( | |
8765 | msgbuf, sizeof(msgbuf), | |
8766 | (uint8_t *)peer->notify.data, | |
8767 | peer->notify.length); | |
8768 | if (msg_str) | |
8769 | json_object_string_add( | |
8770 | json_peer, | |
8771 | "lastShutdownDescription", | |
8772 | msg_str); | |
8773 | } | |
8774 | ||
c258527b | 8775 | } |
3577f1c5 DD |
8776 | json_object_string_add(json_peer, "lastResetDueTo", |
8777 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8778 | json_object_int_add(json_peer, "lastResetCode", |
8779 | peer->last_reset); | |
3577f1c5 DD |
8780 | } else { |
8781 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8782 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8783 | code_str = bgp_notify_code_str(peer->notify.code); | |
8784 | subcode_str = | |
8785 | bgp_notify_subcode_str(peer->notify.code, | |
8786 | peer->notify.subcode); | |
8787 | vty_out(vty, " Notification %s (%s%s)\n", | |
8788 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8789 | ? "sent" | |
8790 | : "received", | |
8791 | code_str, subcode_str); | |
8792 | } else { | |
e91c24c8 | 8793 | vty_out(vty, " %s\n", |
3577f1c5 DD |
8794 | peer_down_str[(int)peer->last_reset]); |
8795 | } | |
8796 | } | |
8797 | } | |
8798 | ||
8799 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8800 | safi_t safi) | |
8801 | { | |
8802 | return ((peer->status != Established) || | |
8803 | !peer->afc_recv[afi][safi]); | |
8804 | } | |
8805 | ||
8806 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8807 | struct peer *peer, json_object *json_peer, | |
8808 | int max_neighbor_width, bool use_json) | |
8809 | { | |
8810 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8811 | int len; | |
8812 | ||
8813 | if (use_json) { | |
8814 | if (peer_dynamic_neighbor(peer)) | |
8815 | json_object_boolean_true_add(json_peer, | |
8816 | "dynamicPeer"); | |
8817 | if (peer->hostname) | |
8818 | json_object_string_add(json_peer, "hostname", | |
8819 | peer->hostname); | |
8820 | ||
8821 | if (peer->domainname) | |
8822 | json_object_string_add(json_peer, "domainname", | |
8823 | peer->domainname); | |
8824 | json_object_int_add(json_peer, "connectionsEstablished", | |
8825 | peer->established); | |
8826 | json_object_int_add(json_peer, "connectionsDropped", | |
8827 | peer->dropped); | |
8828 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8829 | use_json, json_peer); | |
8830 | if (peer->status == Established) | |
8831 | json_object_string_add(json_peer, "lastResetDueTo", | |
8832 | "AFI/SAFI Not Negotiated"); | |
8833 | else | |
8834 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8835 | } else { | |
8836 | dn_flag[1] = '\0'; | |
8837 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8838 | if (peer->hostname | |
892fedb6 | 8839 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
8840 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
8841 | peer->hostname, peer->host); | |
8842 | else | |
8843 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8844 | ||
8845 | /* pad the neighbor column with spaces */ | |
8846 | if (len < max_neighbor_width) | |
8847 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8848 | " "); | |
e91c24c8 | 8849 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
8850 | peer->dropped, |
8851 | peer_uptime(peer->uptime, timebuf, | |
8852 | BGP_UPTIME_LEN, 0, NULL)); | |
8853 | if (peer->status == Established) | |
8854 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8855 | else | |
8856 | bgp_show_peer_reset(vty, peer, NULL, | |
8857 | false); | |
8858 | } | |
8859 | } | |
c258527b | 8860 | |
3577f1c5 | 8861 | |
718e3744 | 8862 | /* Show BGP peer's summary information. */ |
d62a17ae | 8863 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
10b49f14 DA |
8864 | bool show_failed, bool show_established, |
8865 | bool use_json) | |
d62a17ae | 8866 | { |
8867 | struct peer *peer; | |
8868 | struct listnode *node, *nnode; | |
8869 | unsigned int count = 0, dn_count = 0; | |
8870 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8871 | char neighbor_buf[VTY_BUFSIZ]; | |
8872 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8873 | int len, failed_count = 0; |
d62a17ae | 8874 | int max_neighbor_width = 0; |
8875 | int pfx_rcd_safi; | |
3c13337d | 8876 | json_object *json = NULL; |
d62a17ae | 8877 | json_object *json_peer = NULL; |
8878 | json_object *json_peers = NULL; | |
50e05855 | 8879 | struct peer_af *paf; |
d3ada366 | 8880 | struct bgp_filter *filter; |
d62a17ae | 8881 | |
8882 | /* labeled-unicast routes are installed in the unicast table so in order | |
8883 | * to | |
8884 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8885 | */ | |
3577f1c5 | 8886 | |
d62a17ae | 8887 | if (safi == SAFI_LABELED_UNICAST) |
8888 | pfx_rcd_safi = SAFI_UNICAST; | |
8889 | else | |
8890 | pfx_rcd_safi = safi; | |
8891 | ||
8892 | if (use_json) { | |
3c13337d | 8893 | json = json_object_new_object(); |
d62a17ae | 8894 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8895 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8896 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8897 | continue; | |
8898 | ||
8899 | if (peer->afc[afi][safi]) { | |
8900 | /* See if we have at least a single failed peer */ | |
8901 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8902 | failed_count++; | |
8903 | count++; | |
8904 | } | |
8905 | if (peer_dynamic_neighbor(peer)) | |
8906 | dn_count++; | |
8907 | } | |
c258527b | 8908 | |
d62a17ae | 8909 | } else { |
8910 | /* Loop over all neighbors that will be displayed to determine | |
8911 | * how many | |
8912 | * characters are needed for the Neighbor column | |
8913 | */ | |
8914 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8915 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8916 | continue; | |
8917 | ||
8918 | if (peer->afc[afi][safi]) { | |
8919 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8920 | if (peer_dynamic_neighbor(peer)) | |
8921 | dn_flag[0] = '*'; | |
8922 | ||
8923 | if (peer->hostname | |
892fedb6 DA |
8924 | && CHECK_FLAG(bgp->flags, |
8925 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
8926 | snprintf(neighbor_buf, |
8927 | sizeof(neighbor_buf), | |
8928 | "%s%s(%s) ", dn_flag, | |
8929 | peer->hostname, peer->host); | |
d62a17ae | 8930 | else |
772270f3 QY |
8931 | snprintf(neighbor_buf, |
8932 | sizeof(neighbor_buf), "%s%s ", | |
8933 | dn_flag, peer->host); | |
d62a17ae | 8934 | |
8935 | len = strlen(neighbor_buf); | |
8936 | ||
8937 | if (len > max_neighbor_width) | |
8938 | max_neighbor_width = len; | |
c258527b | 8939 | |
3577f1c5 DD |
8940 | /* See if we have at least a single failed peer */ |
8941 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8942 | failed_count++; | |
8943 | count++; | |
d62a17ae | 8944 | } |
8945 | } | |
f933309e | 8946 | |
d62a17ae | 8947 | /* Originally we displayed the Neighbor column as 16 |
8948 | * characters wide so make that the default | |
8949 | */ | |
8950 | if (max_neighbor_width < neighbor_col_default_width) | |
8951 | max_neighbor_width = neighbor_col_default_width; | |
8952 | } | |
f933309e | 8953 | |
3577f1c5 DD |
8954 | if (show_failed && !failed_count) { |
8955 | if (use_json) { | |
8956 | json_object_int_add(json, "failedPeersCount", 0); | |
8957 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8958 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8959 | |
8960 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8961 | json, JSON_C_TO_STRING_PRETTY)); | |
8962 | json_object_free(json); | |
8963 | } else { | |
8964 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8965 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8966 | } | |
8967 | return CMD_SUCCESS; | |
8968 | } | |
c258527b | 8969 | |
3577f1c5 | 8970 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8971 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8972 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8973 | continue; | |
8974 | ||
ea47320b DL |
8975 | if (!peer->afc[afi][safi]) |
8976 | continue; | |
d62a17ae | 8977 | |
ea47320b DL |
8978 | if (!count) { |
8979 | unsigned long ents; | |
8980 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8981 | int64_t vrf_id_ui; |
d62a17ae | 8982 | |
a4d82a8a PZ |
8983 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8984 | ? -1 | |
8985 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8986 | |
8987 | /* Usage summary and header */ | |
8988 | if (use_json) { | |
8989 | json_object_string_add( | |
8990 | json, "routerId", | |
8991 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8992 | json_object_int_add(json, "as", bgp->as); |
8993 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8994 | json_object_string_add( |
8995 | json, "vrfName", | |
8996 | (bgp->inst_type | |
8997 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8998 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8999 | : bgp->name); |
9000 | } else { | |
9001 | vty_out(vty, | |
9002 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 9003 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
9004 | bgp->vrf_id == VRF_UNKNOWN |
9005 | ? -1 | |
9006 | : (int)bgp->vrf_id); | |
ea47320b DL |
9007 | vty_out(vty, "\n"); |
9008 | } | |
d62a17ae | 9009 | |
ea47320b | 9010 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 9011 | if (use_json) { |
ea47320b | 9012 | json_object_int_add( |
60466a63 | 9013 | json, "updateDelayLimit", |
ea47320b | 9014 | bgp->v_update_delay); |
d62a17ae | 9015 | |
ea47320b DL |
9016 | if (bgp->v_update_delay |
9017 | != bgp->v_establish_wait) | |
d62a17ae | 9018 | json_object_int_add( |
9019 | json, | |
ea47320b DL |
9020 | "updateDelayEstablishWait", |
9021 | bgp->v_establish_wait); | |
d62a17ae | 9022 | |
60466a63 | 9023 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9024 | json_object_string_add( |
9025 | json, | |
9026 | "updateDelayFirstNeighbor", | |
9027 | bgp->update_delay_begin_time); | |
9028 | json_object_boolean_true_add( | |
9029 | json, | |
9030 | "updateDelayInProgress"); | |
9031 | } else { | |
9032 | if (bgp->update_delay_over) { | |
d62a17ae | 9033 | json_object_string_add( |
9034 | json, | |
9035 | "updateDelayFirstNeighbor", | |
9036 | bgp->update_delay_begin_time); | |
ea47320b | 9037 | json_object_string_add( |
d62a17ae | 9038 | json, |
ea47320b DL |
9039 | "updateDelayBestpathResumed", |
9040 | bgp->update_delay_end_time); | |
9041 | json_object_string_add( | |
d62a17ae | 9042 | json, |
ea47320b DL |
9043 | "updateDelayZebraUpdateResume", |
9044 | bgp->update_delay_zebra_resume_time); | |
9045 | json_object_string_add( | |
9046 | json, | |
9047 | "updateDelayPeerUpdateResume", | |
9048 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9049 | } |
ea47320b DL |
9050 | } |
9051 | } else { | |
9052 | vty_out(vty, | |
9053 | "Read-only mode update-delay limit: %d seconds\n", | |
9054 | bgp->v_update_delay); | |
9055 | if (bgp->v_update_delay | |
9056 | != bgp->v_establish_wait) | |
d62a17ae | 9057 | vty_out(vty, |
ea47320b DL |
9058 | " Establish wait: %d seconds\n", |
9059 | bgp->v_establish_wait); | |
d62a17ae | 9060 | |
60466a63 | 9061 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
9062 | vty_out(vty, |
9063 | " First neighbor established: %s\n", | |
9064 | bgp->update_delay_begin_time); | |
9065 | vty_out(vty, | |
9066 | " Delay in progress\n"); | |
9067 | } else { | |
9068 | if (bgp->update_delay_over) { | |
d62a17ae | 9069 | vty_out(vty, |
9070 | " First neighbor established: %s\n", | |
9071 | bgp->update_delay_begin_time); | |
9072 | vty_out(vty, | |
ea47320b DL |
9073 | " Best-paths resumed: %s\n", |
9074 | bgp->update_delay_end_time); | |
9075 | vty_out(vty, | |
9076 | " zebra update resumed: %s\n", | |
9077 | bgp->update_delay_zebra_resume_time); | |
9078 | vty_out(vty, | |
9079 | " peers update resumed: %s\n", | |
9080 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 9081 | } |
9082 | } | |
9083 | } | |
ea47320b | 9084 | } |
d62a17ae | 9085 | |
ea47320b DL |
9086 | if (use_json) { |
9087 | if (bgp_maxmed_onstartup_configured(bgp) | |
9088 | && bgp->maxmed_active) | |
9089 | json_object_boolean_true_add( | |
60466a63 | 9090 | json, "maxMedOnStartup"); |
ea47320b DL |
9091 | if (bgp->v_maxmed_admin) |
9092 | json_object_boolean_true_add( | |
60466a63 | 9093 | json, "maxMedAdministrative"); |
d62a17ae | 9094 | |
ea47320b DL |
9095 | json_object_int_add( |
9096 | json, "tableVersion", | |
60466a63 | 9097 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 9098 | |
60466a63 QY |
9099 | ents = bgp_table_count(bgp->rib[afi][safi]); |
9100 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
9101 | json_object_int_add( |
9102 | json, "ribMemory", | |
9bcb3eef | 9103 | ents * sizeof(struct bgp_dest)); |
d62a17ae | 9104 | |
210ec2a0 | 9105 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
9106 | json_object_int_add(json, "peerCount", ents); |
9107 | json_object_int_add(json, "peerMemory", | |
9108 | ents * sizeof(struct peer)); | |
d62a17ae | 9109 | |
ea47320b DL |
9110 | if ((ents = listcount(bgp->group))) { |
9111 | json_object_int_add( | |
60466a63 | 9112 | json, "peerGroupCount", ents); |
ea47320b DL |
9113 | json_object_int_add( |
9114 | json, "peerGroupMemory", | |
996c9314 LB |
9115 | ents * sizeof(struct |
9116 | peer_group)); | |
ea47320b | 9117 | } |
d62a17ae | 9118 | |
ea47320b DL |
9119 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9120 | BGP_CONFIG_DAMPENING)) | |
9121 | json_object_boolean_true_add( | |
60466a63 | 9122 | json, "dampeningEnabled"); |
ea47320b DL |
9123 | } else { |
9124 | if (bgp_maxmed_onstartup_configured(bgp) | |
9125 | && bgp->maxmed_active) | |
d62a17ae | 9126 | vty_out(vty, |
ea47320b DL |
9127 | "Max-med on-startup active\n"); |
9128 | if (bgp->v_maxmed_admin) | |
d62a17ae | 9129 | vty_out(vty, |
ea47320b | 9130 | "Max-med administrative active\n"); |
d62a17ae | 9131 | |
60466a63 QY |
9132 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
9133 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 9134 | |
60466a63 | 9135 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
9136 | vty_out(vty, |
9137 | "RIB entries %ld, using %s of memory\n", | |
9138 | ents, | |
9bcb3eef DS |
9139 | mtype_memstr( |
9140 | memstrbuf, sizeof(memstrbuf), | |
9141 | ents | |
9142 | * sizeof(struct | |
9143 | bgp_dest))); | |
ea47320b DL |
9144 | |
9145 | /* Peer related usage */ | |
210ec2a0 | 9146 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 9147 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
9148 | ents, |
9149 | mtype_memstr( | |
60466a63 QY |
9150 | memstrbuf, sizeof(memstrbuf), |
9151 | ents * sizeof(struct peer))); | |
ea47320b DL |
9152 | |
9153 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 9154 | vty_out(vty, |
ea47320b | 9155 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 9156 | ents, |
9157 | mtype_memstr( | |
9158 | memstrbuf, | |
9159 | sizeof(memstrbuf), | |
996c9314 LB |
9160 | ents * sizeof(struct |
9161 | peer_group))); | |
d62a17ae | 9162 | |
ea47320b DL |
9163 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9164 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 9165 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 9166 | vty_out(vty, "\n"); |
d62a17ae | 9167 | |
ea47320b DL |
9168 | /* Subtract 8 here because 'Neighbor' is |
9169 | * 8 characters */ | |
9170 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
9171 | vty_out(vty, "%*s", max_neighbor_width - 8, |
9172 | " "); | |
3577f1c5 DD |
9173 | if (show_failed) |
9174 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9175 | else | |
9176 | vty_out(vty, | |
db92d226 | 9177 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n"); |
d62a17ae | 9178 | } |
ea47320b | 9179 | } |
d62a17ae | 9180 | |
d55811cc | 9181 | paf = peer_af_find(peer, afi, safi); |
d3ada366 | 9182 | filter = &peer->filter[afi][safi]; |
db92d226 | 9183 | |
ea47320b | 9184 | count++; |
3577f1c5 DD |
9185 | /* Works for both failed & successful cases */ |
9186 | if (peer_dynamic_neighbor(peer)) | |
9187 | dn_count++; | |
d62a17ae | 9188 | |
ea47320b | 9189 | if (use_json) { |
3577f1c5 DD |
9190 | json_peer = NULL; |
9191 | ||
9192 | if (show_failed && | |
9193 | bgp_has_peer_failed(peer, afi, safi)) { | |
9194 | json_peer = json_object_new_object(); | |
9195 | bgp_show_failed_summary(vty, bgp, peer, | |
9196 | json_peer, 0, use_json); | |
9197 | } else if (!show_failed) { | |
10b49f14 DA |
9198 | if (show_established |
9199 | && bgp_has_peer_failed(peer, afi, safi)) | |
9200 | continue; | |
9201 | ||
3577f1c5 DD |
9202 | json_peer = json_object_new_object(); |
9203 | if (peer_dynamic_neighbor(peer)) { | |
9204 | json_object_boolean_true_add(json_peer, | |
9205 | "dynamicPeer"); | |
9206 | } | |
d62a17ae | 9207 | |
3577f1c5 DD |
9208 | if (peer->hostname) |
9209 | json_object_string_add(json_peer, "hostname", | |
9210 | peer->hostname); | |
9211 | ||
9212 | if (peer->domainname) | |
9213 | json_object_string_add(json_peer, "domainname", | |
9214 | peer->domainname); | |
9215 | ||
9216 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9217 | json_object_int_add(json_peer, "version", 4); | |
9218 | json_object_int_add(json_peer, "msgRcvd", | |
9219 | PEER_TOTAL_RX(peer)); | |
9220 | json_object_int_add(json_peer, "msgSent", | |
9221 | PEER_TOTAL_TX(peer)); | |
9222 | ||
43aa5965 QY |
9223 | atomic_size_t outq_count, inq_count; |
9224 | outq_count = atomic_load_explicit( | |
9225 | &peer->obuf->count, | |
9226 | memory_order_relaxed); | |
9227 | inq_count = atomic_load_explicit( | |
9228 | &peer->ibuf->count, | |
9229 | memory_order_relaxed); | |
9230 | ||
3577f1c5 DD |
9231 | json_object_int_add(json_peer, "tableVersion", |
9232 | peer->version[afi][safi]); | |
9233 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
9234 | outq_count); |
9235 | json_object_int_add(json_peer, "inq", | |
9236 | inq_count); | |
3577f1c5 DD |
9237 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
9238 | use_json, json_peer); | |
9239 | ||
3577f1c5 DD |
9240 | json_object_int_add(json_peer, "pfxRcd", |
9241 | peer->pcount[afi][pfx_rcd_safi]); | |
9242 | ||
3577f1c5 DD |
9243 | if (paf && PAF_SUBGRP(paf)) |
9244 | json_object_int_add(json_peer, | |
9245 | "pfxSnt", | |
9246 | (PAF_SUBGRP(paf))->scount); | |
9247 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9248 | json_object_string_add(json_peer, "state", | |
9249 | "Idle (Admin)"); | |
9250 | else if (peer->afc_recv[afi][safi]) | |
9251 | json_object_string_add( | |
9252 | json_peer, "state", | |
9253 | lookup_msg(bgp_status_msg, peer->status, | |
9254 | NULL)); | |
9255 | else if (CHECK_FLAG(peer->sflags, | |
9256 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9257 | json_object_string_add(json_peer, "state", | |
9258 | "Idle (PfxCt)"); | |
9259 | else | |
9260 | json_object_string_add( | |
9261 | json_peer, "state", | |
9262 | lookup_msg(bgp_status_msg, peer->status, | |
9263 | NULL)); | |
200116db DD |
9264 | json_object_int_add(json_peer, "connectionsEstablished", |
9265 | peer->established); | |
9266 | json_object_int_add(json_peer, "connectionsDropped", | |
9267 | peer->dropped); | |
b4e9dcba | 9268 | } |
3577f1c5 DD |
9269 | /* Avoid creating empty peer dicts in JSON */ |
9270 | if (json_peer == NULL) | |
9271 | continue; | |
ea47320b DL |
9272 | |
9273 | if (peer->conf_if) | |
60466a63 | 9274 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9275 | "interface"); |
9276 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9277 | json_object_string_add(json_peer, "idType", |
9278 | "ipv4"); | |
ea47320b | 9279 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9280 | json_object_string_add(json_peer, "idType", |
9281 | "ipv6"); | |
ea47320b DL |
9282 | json_object_object_add(json_peers, peer->host, |
9283 | json_peer); | |
9284 | } else { | |
3577f1c5 DD |
9285 | if (show_failed && |
9286 | bgp_has_peer_failed(peer, afi, safi)) { | |
9287 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9288 | max_neighbor_width, | |
9289 | use_json); | |
9290 | } else if (!show_failed) { | |
10b49f14 DA |
9291 | if (show_established |
9292 | && bgp_has_peer_failed(peer, afi, safi)) | |
9293 | continue; | |
9294 | ||
3577f1c5 DD |
9295 | memset(dn_flag, '\0', sizeof(dn_flag)); |
9296 | if (peer_dynamic_neighbor(peer)) { | |
9297 | dn_flag[0] = '*'; | |
9298 | } | |
d62a17ae | 9299 | |
3577f1c5 | 9300 | if (peer->hostname |
892fedb6 DA |
9301 | && CHECK_FLAG(bgp->flags, |
9302 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 9303 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
9304 | peer->hostname, |
9305 | peer->host); | |
d62a17ae | 9306 | else |
3577f1c5 DD |
9307 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9308 | ||
9309 | /* pad the neighbor column with spaces */ | |
9310 | if (len < max_neighbor_width) | |
9311 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9312 | " "); | |
9313 | ||
43aa5965 QY |
9314 | atomic_size_t outq_count, inq_count; |
9315 | outq_count = atomic_load_explicit( | |
9316 | &peer->obuf->count, | |
9317 | memory_order_relaxed); | |
9318 | inq_count = atomic_load_explicit( | |
9319 | &peer->ibuf->count, | |
9320 | memory_order_relaxed); | |
9321 | ||
566bdaf6 | 9322 | vty_out(vty, |
43aa5965 QY |
9323 | "4 %10u %9u %9u %8" PRIu64 |
9324 | " %4zu %4zu %8s", | |
3577f1c5 | 9325 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 9326 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
9327 | peer->version[afi][safi], inq_count, |
9328 | outq_count, | |
3577f1c5 DD |
9329 | peer_uptime(peer->uptime, timebuf, |
9330 | BGP_UPTIME_LEN, 0, NULL)); | |
9331 | ||
db92d226 | 9332 | if (peer->status == Established) { |
d3ada366 DA |
9333 | if (peer->afc_recv[afi][safi]) { |
9334 | if (CHECK_FLAG( | |
9335 | bgp->flags, | |
9336 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9337 | && !bgp_inbound_policy_exists( | |
9338 | peer, filter)) | |
9339 | vty_out(vty, " %12s", | |
9340 | "(Policy)"); | |
9341 | else | |
9342 | vty_out(vty, | |
9343 | " %12" PRIu32, | |
9344 | peer->pcount | |
9345 | [afi] | |
9346 | [pfx_rcd_safi]); | |
9347 | } else { | |
3577f1c5 | 9348 | vty_out(vty, " NoNeg"); |
d3ada366 | 9349 | } |
db92d226 | 9350 | |
d3ada366 DA |
9351 | if (paf && PAF_SUBGRP(paf)) { |
9352 | if (CHECK_FLAG( | |
9353 | bgp->flags, | |
9354 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
9355 | && !bgp_outbound_policy_exists( | |
9356 | peer, filter)) | |
9357 | vty_out(vty, " %8s", | |
9358 | "(Policy)"); | |
9359 | else | |
9360 | vty_out(vty, | |
9361 | " %8" PRIu32, | |
9362 | (PAF_SUBGRP( | |
9363 | paf)) | |
9364 | ->scount); | |
9365 | } | |
db92d226 | 9366 | } else { |
3577f1c5 DD |
9367 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
9368 | vty_out(vty, " Idle (Admin)"); | |
9369 | else if (CHECK_FLAG( | |
9370 | peer->sflags, | |
9371 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9372 | vty_out(vty, " Idle (PfxCt)"); | |
9373 | else | |
9374 | vty_out(vty, " %12s", | |
9375 | lookup_msg(bgp_status_msg, | |
9376 | peer->status, NULL)); | |
db92d226 DA |
9377 | |
9378 | vty_out(vty, " %8" PRIu32, 0); | |
3577f1c5 DD |
9379 | } |
9380 | vty_out(vty, "\n"); | |
d62a17ae | 9381 | } |
3577f1c5 | 9382 | |
d62a17ae | 9383 | } |
9384 | } | |
f933309e | 9385 | |
d62a17ae | 9386 | if (use_json) { |
9387 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9388 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9389 | json_object_int_add(json, "totalPeers", count); |
9390 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9391 | ||
3577f1c5 DD |
9392 | if (!show_failed) |
9393 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9394 | |
996c9314 LB |
9395 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9396 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9397 | json_object_free(json); |
9398 | } else { | |
9399 | if (count) | |
9400 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9401 | else { | |
d6ceaca3 | 9402 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9403 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9404 | } |
b05a1c8b | 9405 | |
d6ceaca3 | 9406 | if (dn_count) { |
d62a17ae | 9407 | vty_out(vty, "* - dynamic neighbor\n"); |
9408 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9409 | dn_count, bgp->dynamic_neighbors_limit); | |
9410 | } | |
9411 | } | |
1ff9a340 | 9412 | |
d62a17ae | 9413 | return CMD_SUCCESS; |
718e3744 | 9414 | } |
9415 | ||
d62a17ae | 9416 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
10b49f14 DA |
9417 | int safi, bool show_failed, |
9418 | bool show_established, bool use_json) | |
d62a17ae | 9419 | { |
9420 | int is_first = 1; | |
9421 | int afi_wildcard = (afi == AFI_MAX); | |
9422 | int safi_wildcard = (safi == SAFI_MAX); | |
9423 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9424 | bool nbr_output = false; |
d62a17ae | 9425 | |
9426 | if (use_json && is_wildcard) | |
9427 | vty_out(vty, "{\n"); | |
9428 | if (afi_wildcard) | |
9429 | afi = 1; /* AFI_IP */ | |
9430 | while (afi < AFI_MAX) { | |
9431 | if (safi_wildcard) | |
9432 | safi = 1; /* SAFI_UNICAST */ | |
9433 | while (safi < SAFI_MAX) { | |
318cac96 | 9434 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9435 | nbr_output = true; |
f86897b9 | 9436 | |
d62a17ae | 9437 | if (is_wildcard) { |
9438 | /* | |
9439 | * So limit output to those afi/safi | |
9440 | * pairs that | |
9441 | * actualy have something interesting in | |
9442 | * them | |
9443 | */ | |
9444 | if (use_json) { | |
d62a17ae | 9445 | if (!is_first) |
9446 | vty_out(vty, ",\n"); | |
9447 | else | |
9448 | is_first = 0; | |
9449 | ||
9450 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9451 | get_afi_safi_str(afi, |
9452 | safi, | |
9453 | true)); | |
d62a17ae | 9454 | } else { |
9455 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9456 | get_afi_safi_str(afi, |
9457 | safi, | |
9458 | false)); | |
d62a17ae | 9459 | } |
9460 | } | |
10b49f14 DA |
9461 | bgp_show_summary(vty, bgp, afi, safi, |
9462 | show_failed, show_established, | |
3577f1c5 | 9463 | use_json); |
d62a17ae | 9464 | } |
9465 | safi++; | |
d62a17ae | 9466 | if (!safi_wildcard) |
9467 | safi = SAFI_MAX; | |
9468 | } | |
9469 | afi++; | |
ee851c8c | 9470 | if (!afi_wildcard) |
d62a17ae | 9471 | afi = AFI_MAX; |
9472 | } | |
9473 | ||
9474 | if (use_json && is_wildcard) | |
9475 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9476 | else if (!nbr_output) { |
9477 | if (use_json) | |
9478 | vty_out(vty, "{}\n"); | |
9479 | else | |
9480 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9481 | } | |
d62a17ae | 9482 | } |
9483 | ||
9484 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 | 9485 | safi_t safi, bool show_failed, |
10b49f14 | 9486 | bool show_established, |
3577f1c5 | 9487 | bool use_json) |
d62a17ae | 9488 | { |
9489 | struct listnode *node, *nnode; | |
9490 | struct bgp *bgp; | |
d62a17ae | 9491 | int is_first = 1; |
9f049418 | 9492 | bool nbr_output = false; |
d62a17ae | 9493 | |
9494 | if (use_json) | |
9495 | vty_out(vty, "{\n"); | |
9496 | ||
9497 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9498 | nbr_output = true; |
d62a17ae | 9499 | if (use_json) { |
d62a17ae | 9500 | if (!is_first) |
9501 | vty_out(vty, ",\n"); | |
9502 | else | |
9503 | is_first = 0; | |
9504 | ||
9505 | vty_out(vty, "\"%s\":", | |
9506 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9507 | ? VRF_DEFAULT_NAME |
d62a17ae | 9508 | : bgp->name); |
9509 | } else { | |
9510 | vty_out(vty, "\nInstance %s:\n", | |
9511 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9512 | ? VRF_DEFAULT_NAME |
d62a17ae | 9513 | : bgp->name); |
9514 | } | |
3577f1c5 | 9515 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 9516 | show_established, use_json); |
d62a17ae | 9517 | } |
9518 | ||
9519 | if (use_json) | |
9520 | vty_out(vty, "}\n"); | |
9f049418 DS |
9521 | else if (!nbr_output) |
9522 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9523 | } |
9524 | ||
9525 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
10b49f14 DA |
9526 | safi_t safi, bool show_failed, bool show_established, |
9527 | bool use_json) | |
d62a17ae | 9528 | { |
9529 | struct bgp *bgp; | |
9530 | ||
9531 | if (name) { | |
9532 | if (strmatch(name, "all")) { | |
10b49f14 DA |
9533 | bgp_show_all_instances_summary_vty( |
9534 | vty, afi, safi, show_failed, show_established, | |
9535 | use_json); | |
d62a17ae | 9536 | return CMD_SUCCESS; |
9537 | } else { | |
9538 | bgp = bgp_lookup_by_name(name); | |
9539 | ||
9540 | if (!bgp) { | |
9541 | if (use_json) | |
9542 | vty_out(vty, "{}\n"); | |
9543 | else | |
9544 | vty_out(vty, | |
ca61fd25 | 9545 | "%% BGP instance not found\n"); |
d62a17ae | 9546 | return CMD_WARNING; |
9547 | } | |
9548 | ||
f86897b9 | 9549 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
10b49f14 DA |
9550 | show_failed, show_established, |
9551 | use_json); | |
d62a17ae | 9552 | return CMD_SUCCESS; |
9553 | } | |
9554 | } | |
9555 | ||
9556 | bgp = bgp_get_default(); | |
9557 | ||
9558 | if (bgp) | |
3577f1c5 | 9559 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
10b49f14 | 9560 | show_established, use_json); |
9f049418 | 9561 | else { |
ca61fd25 DS |
9562 | if (use_json) |
9563 | vty_out(vty, "{}\n"); | |
9564 | else | |
9565 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9566 | return CMD_WARNING; |
9567 | } | |
d62a17ae | 9568 | |
9569 | return CMD_SUCCESS; | |
4fb25c53 DW |
9570 | } |
9571 | ||
716b2d8a | 9572 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9573 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9574 | show_ip_bgp_summary_cmd, |
10b49f14 | 9575 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [established|failed] [json]", |
718e3744 | 9576 | SHOW_STR |
9577 | IP_STR | |
9578 | BGP_STR | |
8386ac43 | 9579 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9580 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9581 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9582 | "Summary of BGP neighbor status\n" |
10b49f14 | 9583 | "Show only sessions in Established state\n" |
3577f1c5 | 9584 | "Show only sessions not in Established state\n" |
9973d184 | 9585 | JSON_STR) |
718e3744 | 9586 | { |
d62a17ae | 9587 | char *vrf = NULL; |
9588 | afi_t afi = AFI_MAX; | |
9589 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9590 | bool show_failed = false; |
10b49f14 | 9591 | bool show_established = false; |
d62a17ae | 9592 | |
9593 | int idx = 0; | |
9594 | ||
9595 | /* show [ip] bgp */ | |
9596 | if (argv_find(argv, argc, "ip", &idx)) | |
9597 | afi = AFI_IP; | |
9a8bdf1c PG |
9598 | /* [<vrf> VIEWVRFNAME] */ |
9599 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9600 | vrf = argv[idx + 1]->arg; | |
9601 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9602 | vrf = NULL; | |
9603 | } else if (argv_find(argv, argc, "view", &idx)) | |
9604 | /* [<view> VIEWVRFNAME] */ | |
9605 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9606 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9607 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9608 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9609 | } | |
9610 | ||
3577f1c5 DD |
9611 | if (argv_find(argv, argc, "failed", &idx)) |
9612 | show_failed = true; | |
10b49f14 DA |
9613 | if (argv_find(argv, argc, "established", &idx)) |
9614 | show_established = true; | |
3577f1c5 | 9615 | |
9f049418 | 9616 | bool uj = use_json(argc, argv); |
d62a17ae | 9617 | |
10b49f14 DA |
9618 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, |
9619 | show_established, uj); | |
d62a17ae | 9620 | } |
9621 | ||
5cb5f4d0 | 9622 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9623 | { |
5cb5f4d0 DD |
9624 | if (for_json) |
9625 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9626 | else |
5cb5f4d0 | 9627 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9628 | } |
9629 | ||
d62a17ae | 9630 | |
9631 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9632 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9633 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9634 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9635 | bool use_json, json_object *json_pref) |
d62a17ae | 9636 | { |
9637 | /* Send-Mode */ | |
9638 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9639 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9640 | if (use_json) { | |
9641 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9642 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9643 | json_object_string_add(json_pref, "sendMode", | |
9644 | "advertisedAndReceived"); | |
9645 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9646 | json_object_string_add(json_pref, "sendMode", | |
9647 | "advertised"); | |
9648 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9649 | json_object_string_add(json_pref, "sendMode", | |
9650 | "received"); | |
9651 | } else { | |
9652 | vty_out(vty, " Send-mode: "); | |
9653 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9654 | vty_out(vty, "advertised"); | |
9655 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9656 | vty_out(vty, "%sreceived", | |
9657 | CHECK_FLAG(p->af_cap[afi][safi], | |
9658 | adv_smcap) | |
9659 | ? ", " | |
9660 | : ""); | |
9661 | vty_out(vty, "\n"); | |
9662 | } | |
9663 | } | |
9664 | ||
9665 | /* Receive-Mode */ | |
9666 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9667 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9668 | if (use_json) { | |
9669 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9670 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9671 | json_object_string_add(json_pref, "recvMode", | |
9672 | "advertisedAndReceived"); | |
9673 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9674 | json_object_string_add(json_pref, "recvMode", | |
9675 | "advertised"); | |
9676 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9677 | json_object_string_add(json_pref, "recvMode", | |
9678 | "received"); | |
9679 | } else { | |
9680 | vty_out(vty, " Receive-mode: "); | |
9681 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9682 | vty_out(vty, "advertised"); | |
9683 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9684 | vty_out(vty, "%sreceived", | |
9685 | CHECK_FLAG(p->af_cap[afi][safi], | |
9686 | adv_rmcap) | |
9687 | ? ", " | |
9688 | : ""); | |
9689 | vty_out(vty, "\n"); | |
9690 | } | |
9691 | } | |
9692 | } | |
9693 | ||
13909c4f DS |
9694 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9695 | struct peer *p, | |
9696 | bool use_json, | |
9697 | json_object *json) | |
2986cac2 | 9698 | { |
08c2d52a | 9699 | bool rbit_status = false; |
2986cac2 | 9700 | |
9701 | if (!use_json) | |
a53ca37b | 9702 | vty_out(vty, "\n R bit: "); |
2986cac2 | 9703 | |
13909c4f DS |
9704 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9705 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9706 | && (p->status == Established)) { | |
2986cac2 | 9707 | |
9708 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 9709 | rbit_status = true; |
2986cac2 | 9710 | else |
08c2d52a | 9711 | rbit_status = false; |
2986cac2 | 9712 | } |
9713 | ||
9714 | if (rbit_status) { | |
9715 | if (use_json) | |
13909c4f | 9716 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9717 | else |
9718 | vty_out(vty, "True\n"); | |
9719 | } else { | |
9720 | if (use_json) | |
13909c4f | 9721 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9722 | else |
9723 | vty_out(vty, "False\n"); | |
9724 | } | |
9725 | } | |
9726 | ||
13909c4f DS |
9727 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9728 | struct peer *peer, | |
9729 | bool use_json, | |
9730 | json_object *json) | |
2986cac2 | 9731 | { |
2bb5d39b | 9732 | const char *mode = "NotApplicable"; |
2986cac2 | 9733 | |
9734 | if (!use_json) | |
a53ca37b | 9735 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 9736 | |
13909c4f DS |
9737 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9738 | && (peer->status == Established)) { | |
2986cac2 | 9739 | |
13909c4f DS |
9740 | if ((peer->nsf_af_count == 0) |
9741 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9742 | |
2986cac2 | 9743 | mode = "Disable"; |
9744 | ||
13909c4f DS |
9745 | } else if (peer->nsf_af_count == 0 |
9746 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9747 | |
2986cac2 | 9748 | mode = "Helper"; |
9749 | ||
13909c4f DS |
9750 | } else if (peer->nsf_af_count != 0 |
9751 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9752 | |
2986cac2 | 9753 | mode = "Restart"; |
2986cac2 | 9754 | } |
9755 | } | |
9756 | ||
9757 | if (use_json) { | |
13909c4f | 9758 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9759 | } else |
9760 | vty_out(vty, mode, "\n"); | |
9761 | } | |
9762 | ||
13909c4f DS |
9763 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9764 | struct peer *p, | |
9765 | bool use_json, | |
9766 | json_object *json) | |
2986cac2 | 9767 | { |
9768 | const char *mode = "Invalid"; | |
9769 | ||
9770 | if (!use_json) | |
a53ca37b | 9771 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 9772 | |
9773 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9774 | mode = "Helper"; | |
9775 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9776 | mode = "Restart"; | |
9777 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9778 | mode = "Disable"; | |
2ba1fe69 | 9779 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9780 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9781 | mode = "Helper*"; | |
9782 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9783 | mode = "Restart*"; | |
9784 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9785 | mode = "Disable*"; | |
9786 | else | |
9787 | mode = "Invalid*"; | |
2ba1fe69 | 9788 | } |
2986cac2 | 9789 | |
9790 | if (use_json) { | |
13909c4f | 9791 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9792 | } else { |
9793 | vty_out(vty, mode, "\n"); | |
9794 | } | |
9795 | } | |
9796 | ||
13909c4f DS |
9797 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9798 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9799 | { |
2ba1fe69 | 9800 | afi_t afi; |
9801 | safi_t safi; | |
2986cac2 | 9802 | json_object *json_afi_safi = NULL; |
9803 | json_object *json_timer = NULL; | |
9804 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9805 | bool eor_flag = false; |
2986cac2 | 9806 | |
9807 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9808 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9809 | if (!peer->afc[afi][safi]) |
9810 | continue; | |
2986cac2 | 9811 | |
13909c4f DS |
9812 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9813 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9814 | continue; | |
9e3b51a7 | 9815 | |
13909c4f DS |
9816 | if (use_json) { |
9817 | json_afi_safi = json_object_new_object(); | |
9818 | json_endofrib_status = json_object_new_object(); | |
9819 | json_timer = json_object_new_object(); | |
9820 | } | |
2986cac2 | 9821 | |
13909c4f DS |
9822 | if (peer->eor_stime[afi][safi] |
9823 | >= peer->pkt_stime[afi][safi]) | |
9824 | eor_flag = true; | |
9825 | else | |
9826 | eor_flag = false; | |
2986cac2 | 9827 | |
13909c4f | 9828 | if (!use_json) { |
a53ca37b | 9829 | vty_out(vty, " %s:\n", |
13909c4f | 9830 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 9831 | |
a53ca37b | 9832 | vty_out(vty, " F bit: "); |
698ba8d0 | 9833 | } |
2986cac2 | 9834 | |
13909c4f DS |
9835 | if (peer->nsf[afi][safi] |
9836 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9837 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9838 | |
13909c4f DS |
9839 | if (use_json) { |
9840 | json_object_boolean_true_add( | |
2986cac2 | 9841 | json_afi_safi, "fBit"); |
13909c4f DS |
9842 | } else |
9843 | vty_out(vty, "True\n"); | |
9844 | } else { | |
9845 | if (use_json) | |
9846 | json_object_boolean_false_add( | |
9847 | json_afi_safi, "fBit"); | |
9848 | else | |
9849 | vty_out(vty, "False\n"); | |
9850 | } | |
2986cac2 | 9851 | |
13909c4f | 9852 | if (!use_json) |
a53ca37b | 9853 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 9854 | |
13909c4f DS |
9855 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9856 | PEER_STATUS_EOR_SEND)) { | |
9857 | if (use_json) { | |
9858 | json_object_boolean_true_add( | |
2986cac2 | 9859 | json_endofrib_status, |
13909c4f | 9860 | "endOfRibSend"); |
9e3b51a7 | 9861 | |
13909c4f DS |
9862 | PRINT_EOR_JSON(eor_flag); |
9863 | } else { | |
9864 | vty_out(vty, "Yes\n"); | |
9865 | vty_out(vty, | |
a53ca37b | 9866 | " End-of-RIB sent after update: "); |
2986cac2 | 9867 | |
13909c4f DS |
9868 | PRINT_EOR(eor_flag); |
9869 | } | |
9870 | } else { | |
9871 | if (use_json) { | |
9872 | json_object_boolean_false_add( | |
2986cac2 | 9873 | json_endofrib_status, |
13909c4f DS |
9874 | "endOfRibSend"); |
9875 | json_object_boolean_false_add( | |
9e3b51a7 | 9876 | json_endofrib_status, |
13909c4f DS |
9877 | "endOfRibSentAfterUpdate"); |
9878 | } else { | |
9879 | vty_out(vty, "No\n"); | |
9880 | vty_out(vty, | |
a53ca37b | 9881 | " End-of-RIB sent after update: "); |
13909c4f | 9882 | vty_out(vty, "No\n"); |
2986cac2 | 9883 | } |
13909c4f | 9884 | } |
2986cac2 | 9885 | |
a53ca37b DA |
9886 | if (!use_json) |
9887 | vty_out(vty, " End-of-RIB received: "); | |
9888 | ||
9889 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9890 | PEER_STATUS_EOR_RECEIVED)) { | |
9891 | if (use_json) | |
9892 | json_object_boolean_true_add( | |
9893 | json_endofrib_status, | |
9894 | "endOfRibRecv"); | |
9895 | else | |
9896 | vty_out(vty, "Yes\n"); | |
9897 | } else { | |
9898 | if (use_json) | |
9899 | json_object_boolean_false_add( | |
9900 | json_endofrib_status, | |
9901 | "endOfRibRecv"); | |
9902 | else | |
9903 | vty_out(vty, "No\n"); | |
9904 | } | |
9905 | ||
13909c4f DS |
9906 | if (use_json) { |
9907 | json_object_int_add(json_timer, | |
9908 | "stalePathTimer", | |
9909 | peer->bgp->stalepath_time); | |
2986cac2 | 9910 | |
13909c4f DS |
9911 | if (peer->t_gr_stale != NULL) { |
9912 | json_object_int_add( | |
2986cac2 | 9913 | json_timer, |
9914 | "stalePathTimerRemaining", | |
9915 | thread_timer_remain_second( | |
13909c4f DS |
9916 | peer->t_gr_stale)); |
9917 | } | |
3a75afa4 | 9918 | |
13909c4f DS |
9919 | /* Display Configured Selection |
9920 | * Deferral only when when | |
9921 | * Gr mode is enabled. | |
9922 | */ | |
9923 | if (CHECK_FLAG(peer->flags, | |
9924 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9925 | json_object_int_add( | |
3a75afa4 | 9926 | json_timer, |
2986cac2 | 9927 | "selectionDeferralTimer", |
9928 | peer->bgp->stalepath_time); | |
13909c4f | 9929 | } |
2986cac2 | 9930 | |
13909c4f DS |
9931 | if (peer->bgp->gr_info[afi][safi] |
9932 | .t_select_deferral | |
9933 | != NULL) { | |
2986cac2 | 9934 | |
13909c4f | 9935 | json_object_int_add( |
2986cac2 | 9936 | json_timer, |
9937 | "selectionDeferralTimerRemaining", | |
9938 | thread_timer_remain_second( | |
13909c4f DS |
9939 | peer->bgp |
9940 | ->gr_info[afi] | |
9941 | [safi] | |
9942 | .t_select_deferral)); | |
9943 | } | |
9944 | } else { | |
a53ca37b | 9945 | vty_out(vty, " Timers:\n"); |
13909c4f | 9946 | vty_out(vty, |
a53ca37b DA |
9947 | " Configured Stale Path Time(sec): %u\n", |
9948 | peer->bgp->stalepath_time); | |
2986cac2 | 9949 | |
a53ca37b | 9950 | if (peer->t_gr_stale != NULL) |
2986cac2 | 9951 | vty_out(vty, |
a53ca37b | 9952 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 9953 | thread_timer_remain_second( |
13909c4f | 9954 | peer->t_gr_stale)); |
13909c4f DS |
9955 | /* Display Configured Selection |
9956 | * Deferral only when when | |
9957 | * Gr mode is enabled. | |
9958 | */ | |
9959 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 9960 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 9961 | vty_out(vty, |
a53ca37b | 9962 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 9963 | peer->bgp->select_defer_time); |
2986cac2 | 9964 | |
13909c4f DS |
9965 | if (peer->bgp->gr_info[afi][safi] |
9966 | .t_select_deferral | |
a53ca37b | 9967 | != NULL) |
13909c4f | 9968 | vty_out(vty, |
a53ca37b | 9969 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 9970 | thread_timer_remain_second( |
13909c4f DS |
9971 | peer->bgp |
9972 | ->gr_info[afi] | |
9973 | [safi] | |
9974 | .t_select_deferral)); | |
2986cac2 | 9975 | } |
13909c4f DS |
9976 | if (use_json) { |
9977 | json_object_object_add(json_afi_safi, | |
9978 | "endOfRibStatus", | |
9979 | json_endofrib_status); | |
9980 | json_object_object_add(json_afi_safi, "timers", | |
9981 | json_timer); | |
9982 | json_object_object_add( | |
9983 | json, get_afi_safi_str(afi, safi, true), | |
9984 | json_afi_safi); | |
9985 | } | |
2986cac2 | 9986 | } |
9987 | } | |
9988 | } | |
9989 | ||
36235319 QY |
9990 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
9991 | struct peer *p, | |
9992 | bool use_json, | |
9993 | json_object *json) | |
2986cac2 | 9994 | { |
9995 | if (use_json) { | |
9996 | json_object *json_timer = NULL; | |
9997 | ||
9998 | json_timer = json_object_new_object(); | |
9999 | ||
13909c4f DS |
10000 | json_object_int_add(json_timer, "configuredRestartTimer", |
10001 | p->bgp->restart_time); | |
2986cac2 | 10002 | |
13909c4f DS |
10003 | json_object_int_add(json_timer, "receivedRestartTimer", |
10004 | p->v_gr_restart); | |
2986cac2 | 10005 | |
13909c4f DS |
10006 | if (p->t_gr_restart != NULL) |
10007 | json_object_int_add( | |
10008 | json_timer, "restartTimerRemaining", | |
10009 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 10010 | |
10011 | json_object_object_add(json, "timers", json_timer); | |
10012 | } else { | |
10013 | ||
a53ca37b DA |
10014 | vty_out(vty, " Timers:\n"); |
10015 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 10016 | p->bgp->restart_time); |
2986cac2 | 10017 | |
a53ca37b | 10018 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
10019 | p->v_gr_restart); |
10020 | if (p->t_gr_restart != NULL) | |
a53ca37b | 10021 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 10022 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 10023 | if (p->t_gr_restart != NULL) { |
a53ca37b | 10024 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
10025 | thread_timer_remain_second(p->t_gr_restart)); |
10026 | } | |
2986cac2 | 10027 | } |
10028 | } | |
10029 | ||
10030 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 10031 | bool use_json, json_object *json) |
2986cac2 | 10032 | { |
10033 | char buf[SU_ADDRSTRLEN] = {0}; | |
10034 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
10035 | /* '*' + v6 address of neighbor */ |
10036 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 10037 | |
2986cac2 | 10038 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
10039 | dn_flag[0] = '*'; | |
10040 | ||
10041 | if (p->conf_if) { | |
10042 | if (use_json) | |
13909c4f DS |
10043 | json_object_string_add( |
10044 | json, "neighborAddr", | |
2986cac2 | 10045 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
10046 | ? "none" |
10047 | : sockunion2str(&p->su, buf, | |
10048 | SU_ADDRSTRLEN)); | |
2986cac2 | 10049 | else |
13909c4f | 10050 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 10051 | BGP_PEER_SU_UNSPEC(p) |
10052 | ? "none" | |
10053 | : sockunion2str(&p->su, buf, | |
10054 | SU_ADDRSTRLEN)); | |
10055 | } else { | |
772270f3 QY |
10056 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
10057 | p->host); | |
2986cac2 | 10058 | |
10059 | if (use_json) | |
36235319 QY |
10060 | json_object_string_add(json, "neighborAddr", |
10061 | neighborAddr); | |
2986cac2 | 10062 | else |
36235319 | 10063 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 10064 | } |
10065 | ||
10066 | /* more gr info in new format */ | |
10067 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
10068 | } | |
10069 | ||
d62a17ae | 10070 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 10071 | safi_t safi, bool use_json, |
d62a17ae | 10072 | json_object *json_neigh) |
10073 | { | |
0291c246 MK |
10074 | struct bgp_filter *filter; |
10075 | struct peer_af *paf; | |
10076 | char orf_pfx_name[BUFSIZ]; | |
10077 | int orf_pfx_count; | |
10078 | json_object *json_af = NULL; | |
10079 | json_object *json_prefA = NULL; | |
10080 | json_object *json_prefB = NULL; | |
10081 | json_object *json_addr = NULL; | |
d62a17ae | 10082 | |
10083 | if (use_json) { | |
10084 | json_addr = json_object_new_object(); | |
10085 | json_af = json_object_new_object(); | |
10086 | filter = &p->filter[afi][safi]; | |
10087 | ||
10088 | if (peer_group_active(p)) | |
10089 | json_object_string_add(json_addr, "peerGroupMember", | |
10090 | p->group->name); | |
10091 | ||
10092 | paf = peer_af_find(p, afi, safi); | |
10093 | if (paf && PAF_SUBGRP(paf)) { | |
10094 | json_object_int_add(json_addr, "updateGroupId", | |
10095 | PAF_UPDGRP(paf)->id); | |
10096 | json_object_int_add(json_addr, "subGroupId", | |
10097 | PAF_SUBGRP(paf)->id); | |
10098 | json_object_int_add(json_addr, "packetQueueLength", | |
10099 | bpacket_queue_virtual_length(paf)); | |
10100 | } | |
10101 | ||
10102 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10103 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10104 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10105 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10106 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10107 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10108 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10109 | json_object_int_add(json_af, "orfType", | |
10110 | ORF_TYPE_PREFIX); | |
10111 | json_prefA = json_object_new_object(); | |
10112 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
10113 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
10114 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10115 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10116 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
10117 | use_json, json_prefA); | |
10118 | json_object_object_add(json_af, "orfPrefixList", | |
10119 | json_prefA); | |
10120 | } | |
10121 | ||
10122 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10123 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10124 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10125 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10126 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10127 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10128 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10129 | json_object_int_add(json_af, "orfOldType", | |
10130 | ORF_TYPE_PREFIX_OLD); | |
10131 | json_prefB = json_object_new_object(); | |
10132 | bgp_show_peer_afi_orf_cap( | |
10133 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10134 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10135 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10136 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
10137 | json_prefB); | |
10138 | json_object_object_add(json_af, "orfOldPrefixList", | |
10139 | json_prefB); | |
10140 | } | |
10141 | ||
10142 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10143 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10144 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10145 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10146 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10147 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10148 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10149 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10150 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10151 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10152 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10153 | json_object_object_add(json_addr, "afDependentCap", | |
10154 | json_af); | |
10155 | else | |
10156 | json_object_free(json_af); | |
10157 | ||
772270f3 QY |
10158 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10159 | p->host, afi, safi); | |
d62a17ae | 10160 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10161 | NULL, afi, orf_pfx_name, use_json); | |
10162 | ||
10163 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10164 | PEER_STATUS_ORF_PREFIX_SEND) | |
10165 | || orf_pfx_count) { | |
10166 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10167 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10168 | json_object_boolean_true_add(json_neigh, | |
10169 | "orfSent"); | |
10170 | if (orf_pfx_count) | |
10171 | json_object_int_add(json_addr, "orfRecvCounter", | |
10172 | orf_pfx_count); | |
10173 | } | |
10174 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10175 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10176 | json_object_string_add( | |
10177 | json_addr, "orfFirstUpdate", | |
10178 | "deferredUntilORFOrRouteRefreshRecvd"); | |
10179 | ||
10180 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10181 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10182 | json_object_boolean_true_add(json_addr, | |
10183 | "routeReflectorClient"); | |
10184 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10185 | PEER_FLAG_RSERVER_CLIENT)) | |
10186 | json_object_boolean_true_add(json_addr, | |
10187 | "routeServerClient"); | |
10188 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10189 | json_object_boolean_true_add(json_addr, | |
10190 | "inboundSoftConfigPermit"); | |
10191 | ||
10192 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10193 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10194 | json_object_boolean_true_add( | |
10195 | json_addr, | |
10196 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10197 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10198 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10199 | json_object_boolean_true_add( | |
10200 | json_addr, | |
10201 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10202 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10203 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10204 | json_object_boolean_true_add( | |
10205 | json_addr, | |
10206 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10207 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10208 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10209 | json_object_boolean_true_add( | |
10210 | json_addr, | |
10211 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10212 | ||
dcc68b5e MS |
10213 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10214 | json_object_boolean_true_add( | |
10215 | json_addr, | |
10216 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10217 | ->type_json_name); | |
d62a17ae | 10218 | |
10219 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10220 | json_object_string_add(json_addr, | |
10221 | "overrideASNsInOutboundUpdates", | |
10222 | "ifAspathEqualRemoteAs"); | |
10223 | ||
10224 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10225 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10226 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10227 | json_object_boolean_true_add(json_addr, | |
10228 | "routerAlwaysNextHop"); | |
10229 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10230 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10231 | json_object_boolean_true_add( | |
10232 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10233 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10234 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10235 | json_object_boolean_true_add( | |
10236 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10237 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10238 | json_object_boolean_true_add( | |
10239 | json_addr, "unchangedMedPropogatedToNbr"); | |
10240 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10241 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10242 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10243 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10244 | PEER_FLAG_SEND_COMMUNITY) | |
10245 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10246 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10247 | json_object_string_add(json_addr, | |
10248 | "commAttriSentToNbr", | |
10249 | "extendedAndStandard"); | |
10250 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10251 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10252 | json_object_string_add(json_addr, | |
10253 | "commAttriSentToNbr", | |
10254 | "extended"); | |
10255 | else | |
10256 | json_object_string_add(json_addr, | |
10257 | "commAttriSentToNbr", | |
10258 | "standard"); | |
10259 | } | |
10260 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10261 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10262 | if (p->default_rmap[afi][safi].name) | |
10263 | json_object_string_add( | |
10264 | json_addr, "defaultRouteMap", | |
10265 | p->default_rmap[afi][safi].name); | |
10266 | ||
10267 | if (paf && PAF_SUBGRP(paf) | |
10268 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10269 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10270 | json_object_boolean_true_add(json_addr, | |
10271 | "defaultSent"); | |
10272 | else | |
10273 | json_object_boolean_true_add(json_addr, | |
10274 | "defaultNotSent"); | |
10275 | } | |
10276 | ||
dff8f48d | 10277 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10278 | if (is_evpn_enabled()) |
60466a63 QY |
10279 | json_object_boolean_true_add( |
10280 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10281 | } |
10282 | ||
d62a17ae | 10283 | if (filter->plist[FILTER_IN].name |
10284 | || filter->dlist[FILTER_IN].name | |
10285 | || filter->aslist[FILTER_IN].name | |
10286 | || filter->map[RMAP_IN].name) | |
10287 | json_object_boolean_true_add(json_addr, | |
10288 | "inboundPathPolicyConfig"); | |
10289 | if (filter->plist[FILTER_OUT].name | |
10290 | || filter->dlist[FILTER_OUT].name | |
10291 | || filter->aslist[FILTER_OUT].name | |
10292 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10293 | json_object_boolean_true_add( | |
10294 | json_addr, "outboundPathPolicyConfig"); | |
10295 | ||
10296 | /* prefix-list */ | |
10297 | if (filter->plist[FILTER_IN].name) | |
10298 | json_object_string_add(json_addr, | |
10299 | "incomingUpdatePrefixFilterList", | |
10300 | filter->plist[FILTER_IN].name); | |
10301 | if (filter->plist[FILTER_OUT].name) | |
10302 | json_object_string_add(json_addr, | |
10303 | "outgoingUpdatePrefixFilterList", | |
10304 | filter->plist[FILTER_OUT].name); | |
10305 | ||
10306 | /* distribute-list */ | |
10307 | if (filter->dlist[FILTER_IN].name) | |
10308 | json_object_string_add( | |
10309 | json_addr, "incomingUpdateNetworkFilterList", | |
10310 | filter->dlist[FILTER_IN].name); | |
10311 | if (filter->dlist[FILTER_OUT].name) | |
10312 | json_object_string_add( | |
10313 | json_addr, "outgoingUpdateNetworkFilterList", | |
10314 | filter->dlist[FILTER_OUT].name); | |
10315 | ||
10316 | /* filter-list. */ | |
10317 | if (filter->aslist[FILTER_IN].name) | |
10318 | json_object_string_add(json_addr, | |
10319 | "incomingUpdateAsPathFilterList", | |
10320 | filter->aslist[FILTER_IN].name); | |
10321 | if (filter->aslist[FILTER_OUT].name) | |
10322 | json_object_string_add(json_addr, | |
10323 | "outgoingUpdateAsPathFilterList", | |
10324 | filter->aslist[FILTER_OUT].name); | |
10325 | ||
10326 | /* route-map. */ | |
10327 | if (filter->map[RMAP_IN].name) | |
10328 | json_object_string_add( | |
10329 | json_addr, "routeMapForIncomingAdvertisements", | |
10330 | filter->map[RMAP_IN].name); | |
10331 | if (filter->map[RMAP_OUT].name) | |
10332 | json_object_string_add( | |
10333 | json_addr, "routeMapForOutgoingAdvertisements", | |
10334 | filter->map[RMAP_OUT].name); | |
10335 | ||
9dac9fc8 | 10336 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10337 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10338 | && !bgp_inbound_policy_exists(p, filter)) |
10339 | json_object_string_add( | |
10340 | json_addr, "inboundEbgpRequiresPolicy", | |
10341 | "Inbound updates discarded due to missing policy"); | |
10342 | ||
10343 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10344 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10345 | && (!bgp_outbound_policy_exists(p, filter))) |
10346 | json_object_string_add( | |
10347 | json_addr, "outboundEbgpRequiresPolicy", | |
10348 | "Outbound updates discarded due to missing policy"); | |
10349 | ||
d62a17ae | 10350 | /* unsuppress-map */ |
10351 | if (filter->usmap.name) | |
10352 | json_object_string_add(json_addr, | |
10353 | "selectiveUnsuppressRouteMap", | |
10354 | filter->usmap.name); | |
10355 | ||
10356 | /* Receive prefix count */ | |
10357 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10358 | p->pcount[afi][safi]); | |
50e05855 AD |
10359 | if (paf && PAF_SUBGRP(paf)) |
10360 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10361 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10362 | |
fde246e8 DA |
10363 | /* Maximum prefix */ |
10364 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10365 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10366 | p->pmax_out[afi][safi]); | |
10367 | ||
d62a17ae | 10368 | /* Maximum prefix */ |
10369 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10370 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10371 | p->pmax[afi][safi]); | |
10372 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10373 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10374 | json_object_boolean_true_add( | |
10375 | json_addr, "prefixAllowedMaxWarning"); | |
10376 | json_object_int_add(json_addr, | |
10377 | "prefixAllowedWarningThresh", | |
10378 | p->pmax_threshold[afi][safi]); | |
10379 | if (p->pmax_restart[afi][safi]) | |
10380 | json_object_int_add( | |
10381 | json_addr, | |
10382 | "prefixAllowedRestartIntervalMsecs", | |
10383 | p->pmax_restart[afi][safi] * 60000); | |
10384 | } | |
2986cac2 | 10385 | json_object_object_add(json_neigh, |
36235319 | 10386 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10387 | json_addr); |
10388 | ||
10389 | } else { | |
10390 | filter = &p->filter[afi][safi]; | |
10391 | ||
10392 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10393 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10394 | |
10395 | if (peer_group_active(p)) | |
10396 | vty_out(vty, " %s peer-group member\n", | |
10397 | p->group->name); | |
10398 | ||
10399 | paf = peer_af_find(p, afi, safi); | |
10400 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10401 | vty_out(vty, " Update group %" PRIu64 |
10402 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10403 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10404 | vty_out(vty, " Packet Queue length %d\n", | |
10405 | bpacket_queue_virtual_length(paf)); | |
10406 | } else { | |
10407 | vty_out(vty, " Not part of any update group\n"); | |
10408 | } | |
10409 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10410 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10411 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10412 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10413 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10414 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10415 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10416 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10417 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10418 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10419 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10420 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10421 | ||
10422 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10423 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10424 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10425 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10426 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10427 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10428 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10429 | vty_out(vty, | |
10430 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10431 | ORF_TYPE_PREFIX); | |
10432 | bgp_show_peer_afi_orf_cap( | |
10433 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10434 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10435 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10436 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10437 | } | |
10438 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10439 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10440 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10441 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10442 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10443 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10444 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10445 | vty_out(vty, | |
10446 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10447 | ORF_TYPE_PREFIX_OLD); | |
10448 | bgp_show_peer_afi_orf_cap( | |
10449 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10450 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10451 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10452 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10453 | } | |
10454 | ||
772270f3 QY |
10455 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10456 | p->host, afi, safi); | |
d62a17ae | 10457 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10458 | NULL, afi, orf_pfx_name, use_json); | |
10459 | ||
10460 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10461 | PEER_STATUS_ORF_PREFIX_SEND) | |
10462 | || orf_pfx_count) { | |
10463 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10464 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10465 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10466 | vty_out(vty, " sent;"); | |
10467 | if (orf_pfx_count) | |
10468 | vty_out(vty, " received (%d entries)", | |
10469 | orf_pfx_count); | |
10470 | vty_out(vty, "\n"); | |
10471 | } | |
10472 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10473 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10474 | vty_out(vty, | |
10475 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10476 | ||
10477 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10478 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10479 | vty_out(vty, " Route-Reflector Client\n"); | |
10480 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10481 | PEER_FLAG_RSERVER_CLIENT)) | |
10482 | vty_out(vty, " Route-Server Client\n"); | |
10483 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10484 | vty_out(vty, | |
10485 | " Inbound soft reconfiguration allowed\n"); | |
10486 | ||
10487 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10488 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10489 | vty_out(vty, | |
10490 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10491 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10492 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10493 | vty_out(vty, | |
10494 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10495 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10496 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10497 | vty_out(vty, | |
10498 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10499 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10500 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10501 | vty_out(vty, | |
10502 | " Private AS numbers removed in updates to this neighbor\n"); | |
10503 | ||
dcc68b5e MS |
10504 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10505 | vty_out(vty, " %s\n", | |
10506 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10507 | ->human_description); | |
d62a17ae | 10508 | |
10509 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10510 | vty_out(vty, | |
10511 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10512 | ||
10513 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10514 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10515 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10516 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10517 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10518 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10519 | vty_out(vty, | |
10520 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10521 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10522 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10523 | vty_out(vty, | |
10524 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10525 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10526 | vty_out(vty, | |
10527 | " MED is propagated unchanged to this neighbor\n"); | |
10528 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10529 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10530 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10531 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10532 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10533 | vty_out(vty, | |
10534 | " Community attribute sent to this neighbor"); | |
10535 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10536 | PEER_FLAG_SEND_COMMUNITY) | |
10537 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10538 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10539 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10540 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10541 | vty_out(vty, "(all)\n"); | |
10542 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10543 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10544 | vty_out(vty, "(large)\n"); | |
10545 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10546 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10547 | vty_out(vty, "(extended)\n"); | |
10548 | else | |
10549 | vty_out(vty, "(standard)\n"); | |
10550 | } | |
10551 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10552 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10553 | vty_out(vty, " Default information originate,"); | |
10554 | ||
10555 | if (p->default_rmap[afi][safi].name) | |
10556 | vty_out(vty, " default route-map %s%s,", | |
10557 | p->default_rmap[afi][safi].map ? "*" | |
10558 | : "", | |
10559 | p->default_rmap[afi][safi].name); | |
10560 | if (paf && PAF_SUBGRP(paf) | |
10561 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10562 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10563 | vty_out(vty, " default sent\n"); | |
10564 | else | |
10565 | vty_out(vty, " default not sent\n"); | |
10566 | } | |
10567 | ||
dff8f48d MK |
10568 | /* advertise-vni-all */ |
10569 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10570 | if (is_evpn_enabled()) |
dff8f48d MK |
10571 | vty_out(vty, " advertise-all-vni\n"); |
10572 | } | |
10573 | ||
d62a17ae | 10574 | if (filter->plist[FILTER_IN].name |
10575 | || filter->dlist[FILTER_IN].name | |
10576 | || filter->aslist[FILTER_IN].name | |
10577 | || filter->map[RMAP_IN].name) | |
10578 | vty_out(vty, " Inbound path policy configured\n"); | |
10579 | if (filter->plist[FILTER_OUT].name | |
10580 | || filter->dlist[FILTER_OUT].name | |
10581 | || filter->aslist[FILTER_OUT].name | |
10582 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10583 | vty_out(vty, " Outbound path policy configured\n"); | |
10584 | ||
10585 | /* prefix-list */ | |
10586 | if (filter->plist[FILTER_IN].name) | |
10587 | vty_out(vty, | |
10588 | " Incoming update prefix filter list is %s%s\n", | |
10589 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10590 | filter->plist[FILTER_IN].name); | |
10591 | if (filter->plist[FILTER_OUT].name) | |
10592 | vty_out(vty, | |
10593 | " Outgoing update prefix filter list is %s%s\n", | |
10594 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10595 | filter->plist[FILTER_OUT].name); | |
10596 | ||
10597 | /* distribute-list */ | |
10598 | if (filter->dlist[FILTER_IN].name) | |
10599 | vty_out(vty, | |
10600 | " Incoming update network filter list is %s%s\n", | |
10601 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10602 | filter->dlist[FILTER_IN].name); | |
10603 | if (filter->dlist[FILTER_OUT].name) | |
10604 | vty_out(vty, | |
10605 | " Outgoing update network filter list is %s%s\n", | |
10606 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10607 | filter->dlist[FILTER_OUT].name); | |
10608 | ||
10609 | /* filter-list. */ | |
10610 | if (filter->aslist[FILTER_IN].name) | |
10611 | vty_out(vty, | |
10612 | " Incoming update AS path filter list is %s%s\n", | |
10613 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10614 | filter->aslist[FILTER_IN].name); | |
10615 | if (filter->aslist[FILTER_OUT].name) | |
10616 | vty_out(vty, | |
10617 | " Outgoing update AS path filter list is %s%s\n", | |
10618 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10619 | filter->aslist[FILTER_OUT].name); | |
10620 | ||
10621 | /* route-map. */ | |
10622 | if (filter->map[RMAP_IN].name) | |
10623 | vty_out(vty, | |
10624 | " Route map for incoming advertisements is %s%s\n", | |
10625 | filter->map[RMAP_IN].map ? "*" : "", | |
10626 | filter->map[RMAP_IN].name); | |
10627 | if (filter->map[RMAP_OUT].name) | |
10628 | vty_out(vty, | |
10629 | " Route map for outgoing advertisements is %s%s\n", | |
10630 | filter->map[RMAP_OUT].map ? "*" : "", | |
10631 | filter->map[RMAP_OUT].name); | |
10632 | ||
9dac9fc8 | 10633 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10634 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10635 | && !bgp_inbound_policy_exists(p, filter)) |
10636 | vty_out(vty, | |
10637 | " Inbound updates discarded due to missing policy\n"); | |
10638 | ||
10639 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10640 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10641 | && !bgp_outbound_policy_exists(p, filter)) |
10642 | vty_out(vty, | |
10643 | " Outbound updates discarded due to missing policy\n"); | |
10644 | ||
d62a17ae | 10645 | /* unsuppress-map */ |
10646 | if (filter->usmap.name) | |
10647 | vty_out(vty, | |
10648 | " Route map for selective unsuppress is %s%s\n", | |
10649 | filter->usmap.map ? "*" : "", | |
10650 | filter->usmap.name); | |
10651 | ||
10652 | /* Receive prefix count */ | |
a0a87037 DA |
10653 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10654 | p->pcount[afi][safi]); | |
d62a17ae | 10655 | |
fde246e8 DA |
10656 | /* maximum-prefix-out */ |
10657 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10658 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10659 | vty_out(vty, | |
10660 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10661 | p->pmax_out[afi][safi]); | |
10662 | ||
d62a17ae | 10663 | /* Maximum prefix */ |
10664 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10665 | vty_out(vty, |
10666 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10667 | p->pmax[afi][safi], |
10668 | CHECK_FLAG(p->af_flags[afi][safi], | |
10669 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10670 | ? " (warning-only)" | |
10671 | : ""); | |
10672 | vty_out(vty, " Threshold for warning message %d%%", | |
10673 | p->pmax_threshold[afi][safi]); | |
10674 | if (p->pmax_restart[afi][safi]) | |
10675 | vty_out(vty, ", restart interval %d min", | |
10676 | p->pmax_restart[afi][safi]); | |
10677 | vty_out(vty, "\n"); | |
10678 | } | |
10679 | ||
10680 | vty_out(vty, "\n"); | |
10681 | } | |
10682 | } | |
10683 | ||
9f049418 | 10684 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10685 | json_object *json) |
718e3744 | 10686 | { |
d62a17ae | 10687 | struct bgp *bgp; |
10688 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10689 | char timebuf[BGP_UPTIME_LEN]; | |
10690 | char dn_flag[2]; | |
d62a17ae | 10691 | afi_t afi; |
10692 | safi_t safi; | |
d7c0a89a QY |
10693 | uint16_t i; |
10694 | uint8_t *msg; | |
d62a17ae | 10695 | json_object *json_neigh = NULL; |
10696 | time_t epoch_tbuf; | |
718e3744 | 10697 | |
d62a17ae | 10698 | bgp = p->bgp; |
10699 | ||
10700 | if (use_json) | |
10701 | json_neigh = json_object_new_object(); | |
10702 | ||
10703 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10704 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10705 | dn_flag[0] = '*'; | |
10706 | ||
10707 | if (!use_json) { | |
10708 | if (p->conf_if) /* Configured interface name. */ | |
10709 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10710 | BGP_PEER_SU_UNSPEC(p) | |
10711 | ? "None" | |
10712 | : sockunion2str(&p->su, buf, | |
10713 | SU_ADDRSTRLEN)); | |
10714 | else /* Configured IP address. */ | |
10715 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10716 | p->host); | |
10717 | } | |
10718 | ||
10719 | if (use_json) { | |
10720 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10721 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10722 | "none"); | |
10723 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10724 | json_object_string_add( | |
10725 | json_neigh, "bgpNeighborAddr", | |
10726 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10727 | ||
10728 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10729 | ||
10730 | if (p->change_local_as) | |
10731 | json_object_int_add(json_neigh, "localAs", | |
10732 | p->change_local_as); | |
10733 | else | |
10734 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10735 | ||
10736 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10737 | json_object_boolean_true_add(json_neigh, | |
10738 | "localAsNoPrepend"); | |
10739 | ||
10740 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10741 | json_object_boolean_true_add(json_neigh, | |
10742 | "localAsReplaceAs"); | |
10743 | } else { | |
10744 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10745 | || (p->as_type == AS_INTERNAL)) | |
10746 | vty_out(vty, "remote AS %u, ", p->as); | |
10747 | else | |
10748 | vty_out(vty, "remote AS Unspecified, "); | |
10749 | vty_out(vty, "local AS %u%s%s, ", | |
10750 | p->change_local_as ? p->change_local_as : p->local_as, | |
10751 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10752 | ? " no-prepend" | |
10753 | : "", | |
10754 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10755 | ? " replace-as" | |
10756 | : ""); | |
10757 | } | |
faa16034 DS |
10758 | /* peer type internal or confed-internal */ |
10759 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10760 | if (use_json) { |
10761 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10762 | json_object_boolean_true_add( | |
10763 | json_neigh, "nbrConfedInternalLink"); | |
10764 | else | |
10765 | json_object_boolean_true_add(json_neigh, | |
10766 | "nbrInternalLink"); | |
10767 | } else { | |
10768 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10769 | vty_out(vty, "confed-internal link\n"); | |
10770 | else | |
10771 | vty_out(vty, "internal link\n"); | |
10772 | } | |
faa16034 DS |
10773 | /* peer type external or confed-external */ |
10774 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10775 | if (use_json) { |
10776 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10777 | json_object_boolean_true_add( | |
10778 | json_neigh, "nbrConfedExternalLink"); | |
10779 | else | |
10780 | json_object_boolean_true_add(json_neigh, | |
10781 | "nbrExternalLink"); | |
10782 | } else { | |
10783 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10784 | vty_out(vty, "confed-external link\n"); | |
10785 | else | |
10786 | vty_out(vty, "external link\n"); | |
10787 | } | |
faa16034 DS |
10788 | } else { |
10789 | if (use_json) | |
10790 | json_object_boolean_true_add(json_neigh, | |
10791 | "nbrUnspecifiedLink"); | |
10792 | else | |
10793 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10794 | } |
10795 | ||
10796 | /* Description. */ | |
10797 | if (p->desc) { | |
10798 | if (use_json) | |
10799 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10800 | else | |
10801 | vty_out(vty, " Description: %s\n", p->desc); | |
10802 | } | |
10803 | ||
10804 | if (p->hostname) { | |
10805 | if (use_json) { | |
10806 | if (p->hostname) | |
10807 | json_object_string_add(json_neigh, "hostname", | |
10808 | p->hostname); | |
10809 | ||
10810 | if (p->domainname) | |
10811 | json_object_string_add(json_neigh, "domainname", | |
10812 | p->domainname); | |
10813 | } else { | |
10814 | if (p->domainname && (p->domainname[0] != '\0')) | |
10815 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10816 | p->domainname); | |
10817 | else | |
10818 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10819 | } | |
10820 | } | |
10821 | ||
10822 | /* Peer-group */ | |
10823 | if (p->group) { | |
10824 | if (use_json) { | |
10825 | json_object_string_add(json_neigh, "peerGroup", | |
10826 | p->group->name); | |
10827 | ||
10828 | if (dn_flag[0]) { | |
10829 | struct prefix prefix, *range = NULL; | |
10830 | ||
10831 | sockunion2hostprefix(&(p->su), &prefix); | |
10832 | range = peer_group_lookup_dynamic_neighbor_range( | |
10833 | p->group, &prefix); | |
10834 | ||
10835 | if (range) { | |
10836 | prefix2str(range, buf1, sizeof(buf1)); | |
10837 | json_object_string_add( | |
10838 | json_neigh, | |
10839 | "peerSubnetRangeGroup", buf1); | |
10840 | } | |
10841 | } | |
10842 | } else { | |
10843 | vty_out(vty, | |
10844 | " Member of peer-group %s for session parameters\n", | |
10845 | p->group->name); | |
10846 | ||
10847 | if (dn_flag[0]) { | |
10848 | struct prefix prefix, *range = NULL; | |
10849 | ||
10850 | sockunion2hostprefix(&(p->su), &prefix); | |
10851 | range = peer_group_lookup_dynamic_neighbor_range( | |
10852 | p->group, &prefix); | |
10853 | ||
10854 | if (range) { | |
10855 | prefix2str(range, buf1, sizeof(buf1)); | |
10856 | vty_out(vty, | |
10857 | " Belongs to the subnet range group: %s\n", | |
10858 | buf1); | |
10859 | } | |
10860 | } | |
10861 | } | |
10862 | } | |
10863 | ||
10864 | if (use_json) { | |
10865 | /* Administrative shutdown. */ | |
10866 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10867 | json_object_boolean_true_add(json_neigh, | |
10868 | "adminShutDown"); | |
10869 | ||
10870 | /* BGP Version. */ | |
10871 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10872 | json_object_string_add( | |
10873 | json_neigh, "remoteRouterId", | |
10874 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10875 | json_object_string_add( |
10876 | json_neigh, "localRouterId", | |
10877 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10878 | sizeof(buf1))); | |
d62a17ae | 10879 | |
10880 | /* Confederation */ | |
10881 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10882 | && bgp_confederation_peers_check(bgp, p->as)) | |
10883 | json_object_boolean_true_add(json_neigh, | |
10884 | "nbrCommonAdmin"); | |
10885 | ||
10886 | /* Status. */ | |
10887 | json_object_string_add( | |
10888 | json_neigh, "bgpState", | |
10889 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10890 | ||
10891 | if (p->status == Established) { | |
10892 | time_t uptime; | |
d62a17ae | 10893 | |
10894 | uptime = bgp_clock(); | |
10895 | uptime -= p->uptime; | |
d62a17ae | 10896 | epoch_tbuf = time(NULL) - uptime; |
10897 | ||
d3c7efed DS |
10898 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10899 | uptime * 1000); | |
d62a17ae | 10900 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10901 | peer_uptime(p->uptime, timebuf, | |
10902 | BGP_UPTIME_LEN, 0, | |
10903 | NULL)); | |
10904 | json_object_int_add(json_neigh, | |
10905 | "bgpTimerUpEstablishedEpoch", | |
10906 | epoch_tbuf); | |
10907 | } | |
10908 | ||
10909 | else if (p->status == Active) { | |
10910 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10911 | json_object_string_add(json_neigh, "bgpStateIs", | |
10912 | "passive"); | |
10913 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10914 | json_object_string_add(json_neigh, "bgpStateIs", | |
10915 | "passiveNSF"); | |
10916 | } | |
10917 | ||
10918 | /* read timer */ | |
10919 | time_t uptime; | |
a2700b50 | 10920 | struct tm tm; |
d62a17ae | 10921 | |
10922 | uptime = bgp_clock(); | |
10923 | uptime -= p->readtime; | |
a2700b50 MS |
10924 | gmtime_r(&uptime, &tm); |
10925 | ||
d62a17ae | 10926 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
10927 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10928 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10929 | |
10930 | uptime = bgp_clock(); | |
10931 | uptime -= p->last_write; | |
a2700b50 MS |
10932 | gmtime_r(&uptime, &tm); |
10933 | ||
d62a17ae | 10934 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
10935 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10936 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10937 | |
10938 | uptime = bgp_clock(); | |
10939 | uptime -= p->update_time; | |
a2700b50 MS |
10940 | gmtime_r(&uptime, &tm); |
10941 | ||
d62a17ae | 10942 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
10943 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10944 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10945 | |
10946 | /* Configured timer values. */ | |
10947 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10948 | p->v_holdtime * 1000); | |
10949 | json_object_int_add(json_neigh, | |
10950 | "bgpTimerKeepAliveIntervalMsecs", | |
10951 | p->v_keepalive * 1000); | |
b90a8e13 | 10952 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10953 | json_object_int_add(json_neigh, |
10954 | "bgpTimerConfiguredHoldTimeMsecs", | |
10955 | p->holdtime * 1000); | |
10956 | json_object_int_add( | |
10957 | json_neigh, | |
10958 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10959 | p->keepalive * 1000); | |
5d5393b9 DL |
10960 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10961 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10962 | json_object_int_add(json_neigh, |
10963 | "bgpTimerConfiguredHoldTimeMsecs", | |
10964 | bgp->default_holdtime); | |
10965 | json_object_int_add( | |
10966 | json_neigh, | |
10967 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10968 | bgp->default_keepalive); | |
d62a17ae | 10969 | } |
10970 | } else { | |
10971 | /* Administrative shutdown. */ | |
10972 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10973 | vty_out(vty, " Administratively shut down\n"); | |
10974 | ||
10975 | /* BGP Version. */ | |
10976 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10977 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10978 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10979 | vty_out(vty, ", local router ID %s\n", |
10980 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10981 | sizeof(buf1))); | |
d62a17ae | 10982 | |
10983 | /* Confederation */ | |
10984 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10985 | && bgp_confederation_peers_check(bgp, p->as)) | |
10986 | vty_out(vty, | |
10987 | " Neighbor under common administration\n"); | |
10988 | ||
10989 | /* Status. */ | |
10990 | vty_out(vty, " BGP state = %s", | |
10991 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10992 | ||
10993 | if (p->status == Established) | |
10994 | vty_out(vty, ", up for %8s", | |
10995 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10996 | 0, NULL)); | |
10997 | ||
10998 | else if (p->status == Active) { | |
10999 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
11000 | vty_out(vty, " (passive)"); | |
11001 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
11002 | vty_out(vty, " (NSF passive)"); | |
11003 | } | |
11004 | vty_out(vty, "\n"); | |
11005 | ||
11006 | /* read timer */ | |
11007 | vty_out(vty, " Last read %s", | |
11008 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
11009 | NULL)); | |
11010 | vty_out(vty, ", Last write %s\n", | |
11011 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
11012 | NULL)); | |
11013 | ||
11014 | /* Configured timer values. */ | |
11015 | vty_out(vty, | |
11016 | " Hold time is %d, keepalive interval is %d seconds\n", | |
11017 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 11018 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 11019 | vty_out(vty, " Configured hold time is %d", |
11020 | p->holdtime); | |
11021 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11022 | p->keepalive); | |
5d5393b9 DL |
11023 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
11024 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
11025 | vty_out(vty, " Configured hold time is %d", |
11026 | bgp->default_holdtime); | |
11027 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
11028 | bgp->default_keepalive); | |
d62a17ae | 11029 | } |
11030 | } | |
11031 | /* Capability. */ | |
11032 | if (p->status == Established) { | |
11033 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
11034 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
11035 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
11036 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
11037 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
11038 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
11039 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
11040 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
11041 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
11042 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
11043 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
11044 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 11045 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
11046 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 11047 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
11048 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 11049 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
11050 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 11051 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
11052 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
11053 | if (use_json) { | |
11054 | json_object *json_cap = NULL; | |
11055 | ||
11056 | json_cap = json_object_new_object(); | |
11057 | ||
11058 | /* AS4 */ | |
11059 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11060 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11061 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
11062 | && CHECK_FLAG(p->cap, | |
11063 | PEER_CAP_AS4_RCV)) | |
11064 | json_object_string_add( | |
11065 | json_cap, "4byteAs", | |
11066 | "advertisedAndReceived"); | |
11067 | else if (CHECK_FLAG(p->cap, | |
11068 | PEER_CAP_AS4_ADV)) | |
11069 | json_object_string_add( | |
11070 | json_cap, "4byteAs", | |
11071 | "advertised"); | |
11072 | else if (CHECK_FLAG(p->cap, | |
11073 | PEER_CAP_AS4_RCV)) | |
11074 | json_object_string_add( | |
11075 | json_cap, "4byteAs", | |
11076 | "received"); | |
11077 | } | |
11078 | ||
11079 | /* AddPath */ | |
11080 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11081 | || CHECK_FLAG(p->cap, | |
11082 | PEER_CAP_ADDPATH_ADV)) { | |
11083 | json_object *json_add = NULL; | |
11084 | const char *print_store; | |
11085 | ||
11086 | json_add = json_object_new_object(); | |
11087 | ||
05c7a1cc QY |
11088 | FOREACH_AFI_SAFI (afi, safi) { |
11089 | json_object *json_sub = NULL; | |
11090 | json_sub = | |
11091 | json_object_new_object(); | |
5cb5f4d0 DD |
11092 | print_store = get_afi_safi_str( |
11093 | afi, safi, true); | |
d62a17ae | 11094 | |
05c7a1cc QY |
11095 | if (CHECK_FLAG( |
11096 | p->af_cap[afi] | |
11097 | [safi], | |
11098 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11099 | || CHECK_FLAG( | |
11100 | p->af_cap[afi] | |
11101 | [safi], | |
11102 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 11103 | if (CHECK_FLAG( |
11104 | p->af_cap | |
11105 | [afi] | |
11106 | [safi], | |
11107 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 11108 | && CHECK_FLAG( |
d62a17ae | 11109 | p->af_cap |
11110 | [afi] | |
11111 | [safi], | |
05c7a1cc QY |
11112 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
11113 | json_object_boolean_true_add( | |
11114 | json_sub, | |
11115 | "txAdvertisedAndReceived"); | |
11116 | else if ( | |
11117 | CHECK_FLAG( | |
11118 | p->af_cap | |
11119 | [afi] | |
11120 | [safi], | |
11121 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
11122 | json_object_boolean_true_add( | |
11123 | json_sub, | |
11124 | "txAdvertised"); | |
11125 | else if ( | |
11126 | CHECK_FLAG( | |
11127 | p->af_cap | |
11128 | [afi] | |
11129 | [safi], | |
11130 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11131 | json_object_boolean_true_add( | |
11132 | json_sub, | |
11133 | "txReceived"); | |
11134 | } | |
d62a17ae | 11135 | |
05c7a1cc QY |
11136 | if (CHECK_FLAG( |
11137 | p->af_cap[afi] | |
11138 | [safi], | |
11139 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11140 | || CHECK_FLAG( | |
11141 | p->af_cap[afi] | |
11142 | [safi], | |
11143 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 11144 | if (CHECK_FLAG( |
11145 | p->af_cap | |
11146 | [afi] | |
11147 | [safi], | |
11148 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 11149 | && CHECK_FLAG( |
d62a17ae | 11150 | p->af_cap |
11151 | [afi] | |
11152 | [safi], | |
11153 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
11154 | json_object_boolean_true_add( |
11155 | json_sub, | |
11156 | "rxAdvertisedAndReceived"); | |
11157 | else if ( | |
11158 | CHECK_FLAG( | |
11159 | p->af_cap | |
11160 | [afi] | |
11161 | [safi], | |
11162 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
11163 | json_object_boolean_true_add( | |
11164 | json_sub, | |
11165 | "rxAdvertised"); | |
11166 | else if ( | |
11167 | CHECK_FLAG( | |
11168 | p->af_cap | |
11169 | [afi] | |
11170 | [safi], | |
11171 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11172 | json_object_boolean_true_add( | |
11173 | json_sub, | |
11174 | "rxReceived"); | |
d62a17ae | 11175 | } |
11176 | ||
05c7a1cc QY |
11177 | if (CHECK_FLAG( |
11178 | p->af_cap[afi] | |
11179 | [safi], | |
11180 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11181 | || CHECK_FLAG( | |
11182 | p->af_cap[afi] | |
11183 | [safi], | |
11184 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
11185 | || CHECK_FLAG( | |
11186 | p->af_cap[afi] | |
11187 | [safi], | |
11188 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11189 | || CHECK_FLAG( | |
11190 | p->af_cap[afi] | |
11191 | [safi], | |
11192 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11193 | json_object_object_add( | |
11194 | json_add, | |
11195 | print_store, | |
11196 | json_sub); | |
11197 | else | |
11198 | json_object_free( | |
11199 | json_sub); | |
11200 | } | |
11201 | ||
d62a17ae | 11202 | json_object_object_add( |
11203 | json_cap, "addPath", json_add); | |
11204 | } | |
11205 | ||
11206 | /* Dynamic */ | |
11207 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11208 | || CHECK_FLAG(p->cap, | |
11209 | PEER_CAP_DYNAMIC_ADV)) { | |
11210 | if (CHECK_FLAG(p->cap, | |
11211 | PEER_CAP_DYNAMIC_ADV) | |
11212 | && CHECK_FLAG(p->cap, | |
11213 | PEER_CAP_DYNAMIC_RCV)) | |
11214 | json_object_string_add( | |
11215 | json_cap, "dynamic", | |
11216 | "advertisedAndReceived"); | |
11217 | else if (CHECK_FLAG( | |
11218 | p->cap, | |
11219 | PEER_CAP_DYNAMIC_ADV)) | |
11220 | json_object_string_add( | |
11221 | json_cap, "dynamic", | |
11222 | "advertised"); | |
11223 | else if (CHECK_FLAG( | |
11224 | p->cap, | |
11225 | PEER_CAP_DYNAMIC_RCV)) | |
11226 | json_object_string_add( | |
11227 | json_cap, "dynamic", | |
11228 | "received"); | |
11229 | } | |
11230 | ||
11231 | /* Extended nexthop */ | |
11232 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11233 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11234 | json_object *json_nxt = NULL; | |
11235 | const char *print_store; | |
11236 | ||
11237 | ||
11238 | if (CHECK_FLAG(p->cap, | |
11239 | PEER_CAP_ENHE_ADV) | |
11240 | && CHECK_FLAG(p->cap, | |
11241 | PEER_CAP_ENHE_RCV)) | |
11242 | json_object_string_add( | |
11243 | json_cap, | |
11244 | "extendedNexthop", | |
11245 | "advertisedAndReceived"); | |
11246 | else if (CHECK_FLAG(p->cap, | |
11247 | PEER_CAP_ENHE_ADV)) | |
11248 | json_object_string_add( | |
11249 | json_cap, | |
11250 | "extendedNexthop", | |
11251 | "advertised"); | |
11252 | else if (CHECK_FLAG(p->cap, | |
11253 | PEER_CAP_ENHE_RCV)) | |
11254 | json_object_string_add( | |
11255 | json_cap, | |
11256 | "extendedNexthop", | |
11257 | "received"); | |
11258 | ||
11259 | if (CHECK_FLAG(p->cap, | |
11260 | PEER_CAP_ENHE_RCV)) { | |
11261 | json_nxt = | |
11262 | json_object_new_object(); | |
11263 | ||
11264 | for (safi = SAFI_UNICAST; | |
11265 | safi < SAFI_MAX; safi++) { | |
11266 | if (CHECK_FLAG( | |
11267 | p->af_cap | |
11268 | [AFI_IP] | |
11269 | [safi], | |
11270 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11271 | print_store = get_afi_safi_str( |
d62a17ae | 11272 | AFI_IP, |
5cb5f4d0 | 11273 | safi, true); |
d62a17ae | 11274 | json_object_string_add( |
11275 | json_nxt, | |
11276 | print_store, | |
54f29523 | 11277 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11278 | } |
11279 | } | |
11280 | json_object_object_add( | |
11281 | json_cap, | |
11282 | "extendedNexthopFamililesByPeer", | |
11283 | json_nxt); | |
11284 | } | |
11285 | } | |
11286 | ||
11287 | /* Route Refresh */ | |
11288 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11289 | || CHECK_FLAG(p->cap, | |
11290 | PEER_CAP_REFRESH_NEW_RCV) | |
11291 | || CHECK_FLAG(p->cap, | |
11292 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11293 | if (CHECK_FLAG(p->cap, | |
11294 | PEER_CAP_REFRESH_ADV) | |
11295 | && (CHECK_FLAG( | |
11296 | p->cap, | |
11297 | PEER_CAP_REFRESH_NEW_RCV) | |
11298 | || CHECK_FLAG( | |
11299 | p->cap, | |
11300 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11301 | if (CHECK_FLAG( | |
11302 | p->cap, | |
11303 | PEER_CAP_REFRESH_OLD_RCV) | |
11304 | && CHECK_FLAG( | |
11305 | p->cap, | |
11306 | PEER_CAP_REFRESH_NEW_RCV)) | |
11307 | json_object_string_add( | |
11308 | json_cap, | |
11309 | "routeRefresh", | |
11310 | "advertisedAndReceivedOldNew"); | |
11311 | else { | |
11312 | if (CHECK_FLAG( | |
11313 | p->cap, | |
11314 | PEER_CAP_REFRESH_OLD_RCV)) | |
11315 | json_object_string_add( | |
11316 | json_cap, | |
11317 | "routeRefresh", | |
11318 | "advertisedAndReceivedOld"); | |
11319 | else | |
11320 | json_object_string_add( | |
11321 | json_cap, | |
11322 | "routeRefresh", | |
11323 | "advertisedAndReceivedNew"); | |
11324 | } | |
11325 | } else if ( | |
11326 | CHECK_FLAG( | |
11327 | p->cap, | |
11328 | PEER_CAP_REFRESH_ADV)) | |
11329 | json_object_string_add( | |
11330 | json_cap, | |
11331 | "routeRefresh", | |
11332 | "advertised"); | |
11333 | else if ( | |
11334 | CHECK_FLAG( | |
11335 | p->cap, | |
11336 | PEER_CAP_REFRESH_NEW_RCV) | |
11337 | || CHECK_FLAG( | |
11338 | p->cap, | |
11339 | PEER_CAP_REFRESH_OLD_RCV)) | |
11340 | json_object_string_add( | |
11341 | json_cap, | |
11342 | "routeRefresh", | |
11343 | "received"); | |
11344 | } | |
11345 | ||
11346 | /* Multiprotocol Extensions */ | |
11347 | json_object *json_multi = NULL; | |
11348 | json_multi = json_object_new_object(); | |
11349 | ||
05c7a1cc QY |
11350 | FOREACH_AFI_SAFI (afi, safi) { |
11351 | if (p->afc_adv[afi][safi] | |
11352 | || p->afc_recv[afi][safi]) { | |
11353 | json_object *json_exten = NULL; | |
11354 | json_exten = | |
11355 | json_object_new_object(); | |
11356 | ||
d62a17ae | 11357 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11358 | && p->afc_recv[afi][safi]) |
11359 | json_object_boolean_true_add( | |
11360 | json_exten, | |
11361 | "advertisedAndReceived"); | |
11362 | else if (p->afc_adv[afi][safi]) | |
11363 | json_object_boolean_true_add( | |
11364 | json_exten, | |
11365 | "advertised"); | |
11366 | else if (p->afc_recv[afi][safi]) | |
11367 | json_object_boolean_true_add( | |
11368 | json_exten, | |
11369 | "received"); | |
d62a17ae | 11370 | |
05c7a1cc QY |
11371 | json_object_object_add( |
11372 | json_multi, | |
5cb5f4d0 DD |
11373 | get_afi_safi_str(afi, |
11374 | safi, | |
11375 | true), | |
05c7a1cc | 11376 | json_exten); |
d62a17ae | 11377 | } |
11378 | } | |
11379 | json_object_object_add( | |
11380 | json_cap, "multiprotocolExtensions", | |
11381 | json_multi); | |
11382 | ||
d77114b7 | 11383 | /* Hostname capabilities */ |
60466a63 | 11384 | json_object *json_hname = NULL; |
d77114b7 MK |
11385 | |
11386 | json_hname = json_object_new_object(); | |
11387 | ||
11388 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11389 | json_object_string_add( | |
60466a63 QY |
11390 | json_hname, "advHostName", |
11391 | bgp->peer_self->hostname | |
11392 | ? bgp->peer_self | |
11393 | ->hostname | |
d77114b7 MK |
11394 | : "n/a"); |
11395 | json_object_string_add( | |
60466a63 QY |
11396 | json_hname, "advDomainName", |
11397 | bgp->peer_self->domainname | |
11398 | ? bgp->peer_self | |
11399 | ->domainname | |
d77114b7 MK |
11400 | : "n/a"); |
11401 | } | |
11402 | ||
11403 | ||
11404 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11405 | json_object_string_add( | |
60466a63 QY |
11406 | json_hname, "rcvHostName", |
11407 | p->hostname ? p->hostname | |
11408 | : "n/a"); | |
d77114b7 | 11409 | json_object_string_add( |
60466a63 QY |
11410 | json_hname, "rcvDomainName", |
11411 | p->domainname ? p->domainname | |
11412 | : "n/a"); | |
d77114b7 MK |
11413 | } |
11414 | ||
60466a63 | 11415 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11416 | json_hname); |
11417 | ||
d62a17ae | 11418 | /* Gracefull Restart */ |
11419 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11420 | || CHECK_FLAG(p->cap, | |
11421 | PEER_CAP_RESTART_ADV)) { | |
11422 | if (CHECK_FLAG(p->cap, | |
11423 | PEER_CAP_RESTART_ADV) | |
11424 | && CHECK_FLAG(p->cap, | |
11425 | PEER_CAP_RESTART_RCV)) | |
11426 | json_object_string_add( | |
11427 | json_cap, | |
11428 | "gracefulRestart", | |
11429 | "advertisedAndReceived"); | |
11430 | else if (CHECK_FLAG( | |
11431 | p->cap, | |
11432 | PEER_CAP_RESTART_ADV)) | |
11433 | json_object_string_add( | |
11434 | json_cap, | |
11435 | "gracefulRestartCapability", | |
11436 | "advertised"); | |
11437 | else if (CHECK_FLAG( | |
11438 | p->cap, | |
11439 | PEER_CAP_RESTART_RCV)) | |
11440 | json_object_string_add( | |
11441 | json_cap, | |
11442 | "gracefulRestartCapability", | |
11443 | "received"); | |
11444 | ||
11445 | if (CHECK_FLAG(p->cap, | |
11446 | PEER_CAP_RESTART_RCV)) { | |
11447 | int restart_af_count = 0; | |
11448 | json_object *json_restart = | |
11449 | NULL; | |
11450 | json_restart = | |
11451 | json_object_new_object(); | |
11452 | ||
11453 | json_object_int_add( | |
11454 | json_cap, | |
11455 | "gracefulRestartRemoteTimerMsecs", | |
11456 | p->v_gr_restart * 1000); | |
11457 | ||
05c7a1cc QY |
11458 | FOREACH_AFI_SAFI (afi, safi) { |
11459 | if (CHECK_FLAG( | |
11460 | p->af_cap | |
11461 | [afi] | |
11462 | [safi], | |
11463 | PEER_CAP_RESTART_AF_RCV)) { | |
11464 | json_object * | |
11465 | json_sub = | |
11466 | NULL; | |
11467 | json_sub = | |
11468 | json_object_new_object(); | |
11469 | ||
d62a17ae | 11470 | if (CHECK_FLAG( |
11471 | p->af_cap | |
11472 | [afi] | |
11473 | [safi], | |
05c7a1cc QY |
11474 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11475 | json_object_boolean_true_add( | |
11476 | json_sub, | |
11477 | "preserved"); | |
11478 | restart_af_count++; | |
11479 | json_object_object_add( | |
11480 | json_restart, | |
5cb5f4d0 | 11481 | get_afi_safi_str( |
05c7a1cc | 11482 | afi, |
5cb5f4d0 DD |
11483 | safi, |
11484 | true), | |
05c7a1cc | 11485 | json_sub); |
d62a17ae | 11486 | } |
11487 | } | |
11488 | if (!restart_af_count) { | |
11489 | json_object_string_add( | |
11490 | json_cap, | |
11491 | "addressFamiliesByPeer", | |
11492 | "none"); | |
11493 | json_object_free( | |
11494 | json_restart); | |
11495 | } else | |
11496 | json_object_object_add( | |
11497 | json_cap, | |
11498 | "addressFamiliesByPeer", | |
11499 | json_restart); | |
11500 | } | |
11501 | } | |
11502 | json_object_object_add(json_neigh, | |
11503 | "neighborCapabilities", | |
11504 | json_cap); | |
11505 | } else { | |
11506 | vty_out(vty, " Neighbor capabilities:\n"); | |
11507 | ||
11508 | /* AS4 */ | |
11509 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11510 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11511 | vty_out(vty, " 4 Byte AS:"); | |
11512 | if (CHECK_FLAG(p->cap, | |
11513 | PEER_CAP_AS4_ADV)) | |
11514 | vty_out(vty, " advertised"); | |
11515 | if (CHECK_FLAG(p->cap, | |
11516 | PEER_CAP_AS4_RCV)) | |
11517 | vty_out(vty, " %sreceived", | |
11518 | CHECK_FLAG( | |
11519 | p->cap, | |
11520 | PEER_CAP_AS4_ADV) | |
11521 | ? "and " | |
11522 | : ""); | |
11523 | vty_out(vty, "\n"); | |
11524 | } | |
11525 | ||
11526 | /* AddPath */ | |
11527 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11528 | || CHECK_FLAG(p->cap, | |
11529 | PEER_CAP_ADDPATH_ADV)) { | |
11530 | vty_out(vty, " AddPath:\n"); | |
11531 | ||
05c7a1cc QY |
11532 | FOREACH_AFI_SAFI (afi, safi) { |
11533 | if (CHECK_FLAG( | |
11534 | p->af_cap[afi] | |
11535 | [safi], | |
11536 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11537 | || CHECK_FLAG( | |
11538 | p->af_cap[afi] | |
11539 | [safi], | |
11540 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11541 | vty_out(vty, | |
11542 | " %s: TX ", | |
5cb5f4d0 | 11543 | get_afi_safi_str( |
05c7a1cc | 11544 | afi, |
5cb5f4d0 DD |
11545 | safi, |
11546 | false)); | |
05c7a1cc | 11547 | |
d62a17ae | 11548 | if (CHECK_FLAG( |
11549 | p->af_cap | |
11550 | [afi] | |
11551 | [safi], | |
05c7a1cc | 11552 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11553 | vty_out(vty, |
05c7a1cc | 11554 | "advertised %s", |
5cb5f4d0 | 11555 | get_afi_safi_str( |
d62a17ae | 11556 | afi, |
5cb5f4d0 DD |
11557 | safi, |
11558 | false)); | |
d62a17ae | 11559 | |
05c7a1cc QY |
11560 | if (CHECK_FLAG( |
11561 | p->af_cap | |
11562 | [afi] | |
11563 | [safi], | |
11564 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11565 | vty_out(vty, | |
11566 | "%sreceived", | |
11567 | CHECK_FLAG( | |
11568 | p->af_cap | |
11569 | [afi] | |
11570 | [safi], | |
11571 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11572 | ? " and " | |
11573 | : ""); | |
d62a17ae | 11574 | |
05c7a1cc QY |
11575 | vty_out(vty, "\n"); |
11576 | } | |
d62a17ae | 11577 | |
05c7a1cc QY |
11578 | if (CHECK_FLAG( |
11579 | p->af_cap[afi] | |
11580 | [safi], | |
11581 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11582 | || CHECK_FLAG( | |
11583 | p->af_cap[afi] | |
11584 | [safi], | |
11585 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11586 | vty_out(vty, | |
11587 | " %s: RX ", | |
5cb5f4d0 | 11588 | get_afi_safi_str( |
05c7a1cc | 11589 | afi, |
5cb5f4d0 DD |
11590 | safi, |
11591 | false)); | |
d62a17ae | 11592 | |
11593 | if (CHECK_FLAG( | |
11594 | p->af_cap | |
11595 | [afi] | |
11596 | [safi], | |
05c7a1cc | 11597 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11598 | vty_out(vty, |
05c7a1cc | 11599 | "advertised %s", |
5cb5f4d0 | 11600 | get_afi_safi_str( |
d62a17ae | 11601 | afi, |
5cb5f4d0 DD |
11602 | safi, |
11603 | false)); | |
d62a17ae | 11604 | |
05c7a1cc QY |
11605 | if (CHECK_FLAG( |
11606 | p->af_cap | |
11607 | [afi] | |
11608 | [safi], | |
11609 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11610 | vty_out(vty, |
05c7a1cc QY |
11611 | "%sreceived", |
11612 | CHECK_FLAG( | |
11613 | p->af_cap | |
11614 | [afi] | |
11615 | [safi], | |
11616 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11617 | ? " and " | |
11618 | : ""); | |
11619 | ||
11620 | vty_out(vty, "\n"); | |
d62a17ae | 11621 | } |
05c7a1cc | 11622 | } |
d62a17ae | 11623 | } |
11624 | ||
11625 | /* Dynamic */ | |
11626 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11627 | || CHECK_FLAG(p->cap, | |
11628 | PEER_CAP_DYNAMIC_ADV)) { | |
11629 | vty_out(vty, " Dynamic:"); | |
11630 | if (CHECK_FLAG(p->cap, | |
11631 | PEER_CAP_DYNAMIC_ADV)) | |
11632 | vty_out(vty, " advertised"); | |
11633 | if (CHECK_FLAG(p->cap, | |
11634 | PEER_CAP_DYNAMIC_RCV)) | |
11635 | vty_out(vty, " %sreceived", | |
11636 | CHECK_FLAG( | |
11637 | p->cap, | |
11638 | PEER_CAP_DYNAMIC_ADV) | |
11639 | ? "and " | |
11640 | : ""); | |
11641 | vty_out(vty, "\n"); | |
11642 | } | |
11643 | ||
11644 | /* Extended nexthop */ | |
11645 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11646 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11647 | vty_out(vty, " Extended nexthop:"); | |
11648 | if (CHECK_FLAG(p->cap, | |
11649 | PEER_CAP_ENHE_ADV)) | |
11650 | vty_out(vty, " advertised"); | |
11651 | if (CHECK_FLAG(p->cap, | |
11652 | PEER_CAP_ENHE_RCV)) | |
11653 | vty_out(vty, " %sreceived", | |
11654 | CHECK_FLAG( | |
11655 | p->cap, | |
11656 | PEER_CAP_ENHE_ADV) | |
11657 | ? "and " | |
11658 | : ""); | |
11659 | vty_out(vty, "\n"); | |
11660 | ||
11661 | if (CHECK_FLAG(p->cap, | |
11662 | PEER_CAP_ENHE_RCV)) { | |
11663 | vty_out(vty, | |
11664 | " Address families by peer:\n "); | |
11665 | for (safi = SAFI_UNICAST; | |
11666 | safi < SAFI_MAX; safi++) | |
11667 | if (CHECK_FLAG( | |
11668 | p->af_cap | |
11669 | [AFI_IP] | |
11670 | [safi], | |
11671 | PEER_CAP_ENHE_AF_RCV)) | |
11672 | vty_out(vty, | |
11673 | " %s\n", | |
5cb5f4d0 | 11674 | get_afi_safi_str( |
d62a17ae | 11675 | AFI_IP, |
5cb5f4d0 DD |
11676 | safi, |
11677 | false)); | |
d62a17ae | 11678 | } |
11679 | } | |
11680 | ||
11681 | /* Route Refresh */ | |
11682 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11683 | || CHECK_FLAG(p->cap, | |
11684 | PEER_CAP_REFRESH_NEW_RCV) | |
11685 | || CHECK_FLAG(p->cap, | |
11686 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11687 | vty_out(vty, " Route refresh:"); | |
11688 | if (CHECK_FLAG(p->cap, | |
11689 | PEER_CAP_REFRESH_ADV)) | |
11690 | vty_out(vty, " advertised"); | |
11691 | if (CHECK_FLAG(p->cap, | |
11692 | PEER_CAP_REFRESH_NEW_RCV) | |
11693 | || CHECK_FLAG( | |
11694 | p->cap, | |
11695 | PEER_CAP_REFRESH_OLD_RCV)) | |
11696 | vty_out(vty, " %sreceived(%s)", | |
11697 | CHECK_FLAG( | |
11698 | p->cap, | |
11699 | PEER_CAP_REFRESH_ADV) | |
11700 | ? "and " | |
11701 | : "", | |
11702 | (CHECK_FLAG( | |
11703 | p->cap, | |
11704 | PEER_CAP_REFRESH_OLD_RCV) | |
11705 | && CHECK_FLAG( | |
11706 | p->cap, | |
11707 | PEER_CAP_REFRESH_NEW_RCV)) | |
11708 | ? "old & new" | |
11709 | : CHECK_FLAG( | |
11710 | p->cap, | |
11711 | PEER_CAP_REFRESH_OLD_RCV) | |
11712 | ? "old" | |
11713 | : "new"); | |
11714 | ||
11715 | vty_out(vty, "\n"); | |
11716 | } | |
11717 | ||
11718 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11719 | FOREACH_AFI_SAFI (afi, safi) |
11720 | if (p->afc_adv[afi][safi] | |
11721 | || p->afc_recv[afi][safi]) { | |
11722 | vty_out(vty, | |
11723 | " Address Family %s:", | |
5cb5f4d0 DD |
11724 | get_afi_safi_str( |
11725 | afi, | |
11726 | safi, | |
11727 | false)); | |
05c7a1cc | 11728 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11729 | vty_out(vty, |
05c7a1cc QY |
11730 | " advertised"); |
11731 | if (p->afc_recv[afi][safi]) | |
11732 | vty_out(vty, | |
11733 | " %sreceived", | |
11734 | p->afc_adv[afi] | |
11735 | [safi] | |
11736 | ? "and " | |
11737 | : ""); | |
11738 | vty_out(vty, "\n"); | |
11739 | } | |
d62a17ae | 11740 | |
11741 | /* Hostname capability */ | |
60466a63 | 11742 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11743 | |
11744 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11745 | vty_out(vty, |
11746 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11747 | bgp->peer_self->hostname |
11748 | ? bgp->peer_self | |
11749 | ->hostname | |
d77114b7 | 11750 | : "n/a", |
60466a63 QY |
11751 | bgp->peer_self->domainname |
11752 | ? bgp->peer_self | |
11753 | ->domainname | |
d77114b7 MK |
11754 | : "n/a"); |
11755 | } else { | |
11756 | vty_out(vty, " not advertised"); | |
d62a17ae | 11757 | } |
11758 | ||
d77114b7 | 11759 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11760 | vty_out(vty, |
11761 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11762 | p->hostname ? p->hostname |
11763 | : "n/a", | |
11764 | p->domainname ? p->domainname | |
11765 | : "n/a"); | |
d77114b7 MK |
11766 | } else { |
11767 | vty_out(vty, " not received"); | |
11768 | } | |
11769 | ||
11770 | vty_out(vty, "\n"); | |
11771 | ||
61bfbd51 | 11772 | /* Graceful Restart */ |
d62a17ae | 11773 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
11774 | || CHECK_FLAG(p->cap, | |
11775 | PEER_CAP_RESTART_ADV)) { | |
11776 | vty_out(vty, | |
61bfbd51 | 11777 | " Graceful Restart Capability:"); |
d62a17ae | 11778 | if (CHECK_FLAG(p->cap, |
11779 | PEER_CAP_RESTART_ADV)) | |
11780 | vty_out(vty, " advertised"); | |
11781 | if (CHECK_FLAG(p->cap, | |
11782 | PEER_CAP_RESTART_RCV)) | |
11783 | vty_out(vty, " %sreceived", | |
11784 | CHECK_FLAG( | |
11785 | p->cap, | |
11786 | PEER_CAP_RESTART_ADV) | |
11787 | ? "and " | |
11788 | : ""); | |
11789 | vty_out(vty, "\n"); | |
11790 | ||
11791 | if (CHECK_FLAG(p->cap, | |
11792 | PEER_CAP_RESTART_RCV)) { | |
11793 | int restart_af_count = 0; | |
11794 | ||
11795 | vty_out(vty, | |
11796 | " Remote Restart timer is %d seconds\n", | |
11797 | p->v_gr_restart); | |
11798 | vty_out(vty, | |
11799 | " Address families by peer:\n "); | |
11800 | ||
05c7a1cc QY |
11801 | FOREACH_AFI_SAFI (afi, safi) |
11802 | if (CHECK_FLAG( | |
11803 | p->af_cap | |
11804 | [afi] | |
11805 | [safi], | |
11806 | PEER_CAP_RESTART_AF_RCV)) { | |
11807 | vty_out(vty, | |
11808 | "%s%s(%s)", | |
11809 | restart_af_count | |
11810 | ? ", " | |
11811 | : "", | |
5cb5f4d0 | 11812 | get_afi_safi_str( |
05c7a1cc | 11813 | afi, |
5cb5f4d0 DD |
11814 | safi, |
11815 | false), | |
05c7a1cc QY |
11816 | CHECK_FLAG( |
11817 | p->af_cap | |
11818 | [afi] | |
11819 | [safi], | |
11820 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11821 | ? "preserved" | |
11822 | : "not preserved"); | |
11823 | restart_af_count++; | |
11824 | } | |
d62a17ae | 11825 | if (!restart_af_count) |
11826 | vty_out(vty, "none"); | |
11827 | vty_out(vty, "\n"); | |
11828 | } | |
2986cac2 | 11829 | } /* Gracefull Restart */ |
d62a17ae | 11830 | } |
11831 | } | |
11832 | } | |
11833 | ||
11834 | /* graceful restart information */ | |
d62a17ae | 11835 | json_object *json_grace = NULL; |
11836 | json_object *json_grace_send = NULL; | |
11837 | json_object *json_grace_recv = NULL; | |
11838 | int eor_send_af_count = 0; | |
11839 | int eor_receive_af_count = 0; | |
11840 | ||
11841 | if (use_json) { | |
11842 | json_grace = json_object_new_object(); | |
11843 | json_grace_send = json_object_new_object(); | |
11844 | json_grace_recv = json_object_new_object(); | |
11845 | ||
36235319 QY |
11846 | if ((p->status == Established) |
11847 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11848 | FOREACH_AFI_SAFI (afi, safi) { |
11849 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11850 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11851 | json_object_boolean_true_add( |
11852 | json_grace_send, | |
5cb5f4d0 DD |
11853 | get_afi_safi_str(afi, |
11854 | safi, | |
11855 | true)); | |
05c7a1cc | 11856 | eor_send_af_count++; |
d62a17ae | 11857 | } |
11858 | } | |
05c7a1cc QY |
11859 | FOREACH_AFI_SAFI (afi, safi) { |
11860 | if (CHECK_FLAG( | |
36235319 QY |
11861 | p->af_sflags[afi][safi], |
11862 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11863 | json_object_boolean_true_add( |
11864 | json_grace_recv, | |
5cb5f4d0 DD |
11865 | get_afi_safi_str(afi, |
11866 | safi, | |
11867 | true)); | |
05c7a1cc | 11868 | eor_receive_af_count++; |
d62a17ae | 11869 | } |
11870 | } | |
11871 | } | |
36235319 QY |
11872 | json_object_object_add(json_grace, "endOfRibSend", |
11873 | json_grace_send); | |
11874 | json_object_object_add(json_grace, "endOfRibRecv", | |
11875 | json_grace_recv); | |
d62a17ae | 11876 | |
d62a17ae | 11877 | |
11878 | if (p->t_gr_restart) | |
11879 | json_object_int_add(json_grace, | |
11880 | "gracefulRestartTimerMsecs", | |
11881 | thread_timer_remain_second( | |
11882 | p->t_gr_restart) | |
11883 | * 1000); | |
11884 | ||
11885 | if (p->t_gr_stale) | |
11886 | json_object_int_add( | |
11887 | json_grace, | |
11888 | "gracefulStalepathTimerMsecs", | |
11889 | thread_timer_remain_second( | |
11890 | p->t_gr_stale) | |
11891 | * 1000); | |
2986cac2 | 11892 | /* more gr info in new format */ |
11893 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 11894 | json_grace); |
d62a17ae | 11895 | json_object_object_add( |
11896 | json_neigh, "gracefulRestartInfo", json_grace); | |
11897 | } else { | |
2089dd80 | 11898 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
11899 | if ((p->status == Established) |
11900 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11901 | |
d62a17ae | 11902 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11903 | FOREACH_AFI_SAFI (afi, safi) { |
11904 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11905 | PEER_STATUS_EOR_SEND)) { | |
11906 | vty_out(vty, "%s%s", | |
11907 | eor_send_af_count ? ", " | |
11908 | : "", | |
36235319 QY |
11909 | get_afi_safi_str( |
11910 | afi, safi, | |
11911 | false)); | |
05c7a1cc | 11912 | eor_send_af_count++; |
d62a17ae | 11913 | } |
11914 | } | |
11915 | vty_out(vty, "\n"); | |
11916 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11917 | FOREACH_AFI_SAFI (afi, safi) { |
11918 | if (CHECK_FLAG( | |
11919 | p->af_sflags[afi][safi], | |
11920 | PEER_STATUS_EOR_RECEIVED)) { | |
11921 | vty_out(vty, "%s%s", | |
11922 | eor_receive_af_count | |
11923 | ? ", " | |
11924 | : "", | |
5cb5f4d0 DD |
11925 | get_afi_safi_str(afi, |
11926 | safi, | |
11927 | false)); | |
05c7a1cc | 11928 | eor_receive_af_count++; |
d62a17ae | 11929 | } |
11930 | } | |
11931 | vty_out(vty, "\n"); | |
11932 | } | |
11933 | ||
11934 | if (p->t_gr_restart) | |
11935 | vty_out(vty, | |
11936 | " The remaining time of restart timer is %ld\n", | |
11937 | thread_timer_remain_second( | |
11938 | p->t_gr_restart)); | |
11939 | ||
11940 | if (p->t_gr_stale) | |
11941 | vty_out(vty, | |
11942 | " The remaining time of stalepath timer is %ld\n", | |
11943 | thread_timer_remain_second( | |
11944 | p->t_gr_stale)); | |
2986cac2 | 11945 | |
11946 | /* more gr info in new format */ | |
11947 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11948 | } |
2986cac2 | 11949 | |
d62a17ae | 11950 | if (use_json) { |
11951 | json_object *json_stat = NULL; | |
11952 | json_stat = json_object_new_object(); | |
11953 | /* Packet counts. */ | |
43aa5965 QY |
11954 | |
11955 | atomic_size_t outq_count, inq_count; | |
11956 | outq_count = atomic_load_explicit(&p->obuf->count, | |
11957 | memory_order_relaxed); | |
11958 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
11959 | memory_order_relaxed); | |
11960 | ||
11961 | json_object_int_add(json_stat, "depthInq", | |
11962 | (unsigned long)inq_count); | |
d62a17ae | 11963 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 11964 | (unsigned long)outq_count); |
0112e9e0 QY |
11965 | json_object_int_add(json_stat, "opensSent", |
11966 | atomic_load_explicit(&p->open_out, | |
11967 | memory_order_relaxed)); | |
11968 | json_object_int_add(json_stat, "opensRecv", | |
11969 | atomic_load_explicit(&p->open_in, | |
11970 | memory_order_relaxed)); | |
d62a17ae | 11971 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11972 | atomic_load_explicit(&p->notify_out, |
11973 | memory_order_relaxed)); | |
d62a17ae | 11974 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11975 | atomic_load_explicit(&p->notify_in, |
11976 | memory_order_relaxed)); | |
11977 | json_object_int_add(json_stat, "updatesSent", | |
11978 | atomic_load_explicit(&p->update_out, | |
11979 | memory_order_relaxed)); | |
11980 | json_object_int_add(json_stat, "updatesRecv", | |
11981 | atomic_load_explicit(&p->update_in, | |
11982 | memory_order_relaxed)); | |
d62a17ae | 11983 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11984 | atomic_load_explicit(&p->keepalive_out, |
11985 | memory_order_relaxed)); | |
d62a17ae | 11986 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11987 | atomic_load_explicit(&p->keepalive_in, |
11988 | memory_order_relaxed)); | |
d62a17ae | 11989 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11990 | atomic_load_explicit(&p->refresh_out, |
11991 | memory_order_relaxed)); | |
d62a17ae | 11992 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11993 | atomic_load_explicit(&p->refresh_in, |
11994 | memory_order_relaxed)); | |
d62a17ae | 11995 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11996 | atomic_load_explicit(&p->dynamic_cap_out, |
11997 | memory_order_relaxed)); | |
d62a17ae | 11998 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11999 | atomic_load_explicit(&p->dynamic_cap_in, |
12000 | memory_order_relaxed)); | |
12001 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
12002 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 12003 | json_object_object_add(json_neigh, "messageStats", json_stat); |
12004 | } else { | |
43aa5965 QY |
12005 | atomic_size_t outq_count, inq_count; |
12006 | outq_count = atomic_load_explicit(&p->obuf->count, | |
12007 | memory_order_relaxed); | |
12008 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
12009 | memory_order_relaxed); | |
12010 | ||
d62a17ae | 12011 | /* Packet counts. */ |
12012 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
12013 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
12014 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 12015 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
12016 | vty_out(vty, " Opens: %10d %10d\n", |
12017 | atomic_load_explicit(&p->open_out, | |
12018 | memory_order_relaxed), | |
12019 | atomic_load_explicit(&p->open_in, | |
12020 | memory_order_relaxed)); | |
12021 | vty_out(vty, " Notifications: %10d %10d\n", | |
12022 | atomic_load_explicit(&p->notify_out, | |
12023 | memory_order_relaxed), | |
12024 | atomic_load_explicit(&p->notify_in, | |
12025 | memory_order_relaxed)); | |
12026 | vty_out(vty, " Updates: %10d %10d\n", | |
12027 | atomic_load_explicit(&p->update_out, | |
12028 | memory_order_relaxed), | |
12029 | atomic_load_explicit(&p->update_in, | |
12030 | memory_order_relaxed)); | |
12031 | vty_out(vty, " Keepalives: %10d %10d\n", | |
12032 | atomic_load_explicit(&p->keepalive_out, | |
12033 | memory_order_relaxed), | |
12034 | atomic_load_explicit(&p->keepalive_in, | |
12035 | memory_order_relaxed)); | |
12036 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
12037 | atomic_load_explicit(&p->refresh_out, | |
12038 | memory_order_relaxed), | |
12039 | atomic_load_explicit(&p->refresh_in, | |
12040 | memory_order_relaxed)); | |
d62a17ae | 12041 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
12042 | atomic_load_explicit(&p->dynamic_cap_out, |
12043 | memory_order_relaxed), | |
12044 | atomic_load_explicit(&p->dynamic_cap_in, | |
12045 | memory_order_relaxed)); | |
12046 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
12047 | PEER_TOTAL_RX(p)); | |
d62a17ae | 12048 | } |
12049 | ||
12050 | if (use_json) { | |
12051 | /* advertisement-interval */ | |
12052 | json_object_int_add(json_neigh, | |
12053 | "minBtwnAdvertisementRunsTimerMsecs", | |
12054 | p->v_routeadv * 1000); | |
12055 | ||
12056 | /* Update-source. */ | |
12057 | if (p->update_if || p->update_source) { | |
12058 | if (p->update_if) | |
12059 | json_object_string_add(json_neigh, | |
12060 | "updateSource", | |
12061 | p->update_if); | |
12062 | else if (p->update_source) | |
12063 | json_object_string_add( | |
12064 | json_neigh, "updateSource", | |
12065 | sockunion2str(p->update_source, buf1, | |
12066 | SU_ADDRSTRLEN)); | |
12067 | } | |
12068 | } else { | |
12069 | /* advertisement-interval */ | |
12070 | vty_out(vty, | |
12071 | " Minimum time between advertisement runs is %d seconds\n", | |
12072 | p->v_routeadv); | |
12073 | ||
12074 | /* Update-source. */ | |
12075 | if (p->update_if || p->update_source) { | |
12076 | vty_out(vty, " Update source is "); | |
12077 | if (p->update_if) | |
12078 | vty_out(vty, "%s", p->update_if); | |
12079 | else if (p->update_source) | |
12080 | vty_out(vty, "%s", | |
12081 | sockunion2str(p->update_source, buf1, | |
12082 | SU_ADDRSTRLEN)); | |
12083 | vty_out(vty, "\n"); | |
12084 | } | |
12085 | ||
12086 | vty_out(vty, "\n"); | |
12087 | } | |
12088 | ||
12089 | /* Address Family Information */ | |
12090 | json_object *json_hold = NULL; | |
12091 | ||
12092 | if (use_json) | |
12093 | json_hold = json_object_new_object(); | |
12094 | ||
05c7a1cc QY |
12095 | FOREACH_AFI_SAFI (afi, safi) |
12096 | if (p->afc[afi][safi]) | |
12097 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
12098 | json_hold); | |
d62a17ae | 12099 | |
12100 | if (use_json) { | |
12101 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
12102 | json_hold); | |
12103 | json_object_int_add(json_neigh, "connectionsEstablished", | |
12104 | p->established); | |
12105 | json_object_int_add(json_neigh, "connectionsDropped", | |
12106 | p->dropped); | |
12107 | } else | |
12108 | vty_out(vty, " Connections established %d; dropped %d\n", | |
12109 | p->established, p->dropped); | |
12110 | ||
12111 | if (!p->last_reset) { | |
12112 | if (use_json) | |
12113 | json_object_string_add(json_neigh, "lastReset", | |
12114 | "never"); | |
12115 | else | |
12116 | vty_out(vty, " Last reset never\n"); | |
12117 | } else { | |
12118 | if (use_json) { | |
12119 | time_t uptime; | |
a2700b50 | 12120 | struct tm tm; |
d62a17ae | 12121 | |
12122 | uptime = bgp_clock(); | |
12123 | uptime -= p->resettime; | |
a2700b50 MS |
12124 | gmtime_r(&uptime, &tm); |
12125 | ||
d62a17ae | 12126 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
12127 | (tm.tm_sec * 1000) |
12128 | + (tm.tm_min * 60000) | |
12129 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 12130 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 12131 | } else { |
12132 | vty_out(vty, " Last reset %s, ", | |
12133 | peer_uptime(p->resettime, timebuf, | |
12134 | BGP_UPTIME_LEN, 0, NULL)); | |
12135 | ||
3577f1c5 | 12136 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 12137 | if (p->last_reset_cause_size) { |
12138 | msg = p->last_reset_cause; | |
12139 | vty_out(vty, | |
12140 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
12141 | for (i = 1; i <= p->last_reset_cause_size; | |
12142 | i++) { | |
12143 | vty_out(vty, "%02X", *msg++); | |
12144 | ||
12145 | if (i != p->last_reset_cause_size) { | |
12146 | if (i % 16 == 0) { | |
12147 | vty_out(vty, "\n "); | |
12148 | } else if (i % 4 == 0) { | |
12149 | vty_out(vty, " "); | |
12150 | } | |
12151 | } | |
12152 | } | |
12153 | vty_out(vty, "\n"); | |
12154 | } | |
12155 | } | |
12156 | } | |
12157 | ||
12158 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
12159 | if (use_json) | |
12160 | json_object_boolean_true_add(json_neigh, | |
12161 | "prefixesConfigExceedMax"); | |
12162 | else | |
12163 | vty_out(vty, | |
12164 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
12165 | ||
12166 | if (p->t_pmax_restart) { | |
12167 | if (use_json) { | |
12168 | json_object_boolean_true_add( | |
12169 | json_neigh, "reducePrefixNumFrom"); | |
12170 | json_object_int_add(json_neigh, | |
12171 | "restartInTimerMsec", | |
12172 | thread_timer_remain_second( | |
12173 | p->t_pmax_restart) | |
12174 | * 1000); | |
12175 | } else | |
12176 | vty_out(vty, | |
12177 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
12178 | p->host, thread_timer_remain_second( |
12179 | p->t_pmax_restart)); | |
d62a17ae | 12180 | } else { |
12181 | if (use_json) | |
12182 | json_object_boolean_true_add( | |
12183 | json_neigh, | |
12184 | "reducePrefixNumAndClearIpBgp"); | |
12185 | else | |
12186 | vty_out(vty, | |
12187 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
12188 | p->host); | |
12189 | } | |
12190 | } | |
12191 | ||
12192 | /* EBGP Multihop and GTSM */ | |
12193 | if (p->sort != BGP_PEER_IBGP) { | |
12194 | if (use_json) { | |
e2521429 | 12195 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12196 | json_object_int_add(json_neigh, |
12197 | "externalBgpNbrMaxHopsAway", | |
12198 | p->gtsm_hops); | |
c8d6f0d6 | 12199 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12200 | json_object_int_add(json_neigh, |
12201 | "externalBgpNbrMaxHopsAway", | |
12202 | p->ttl); | |
12203 | } else { | |
e2521429 | 12204 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12205 | vty_out(vty, |
12206 | " External BGP neighbor may be up to %d hops away.\n", | |
12207 | p->gtsm_hops); | |
c8d6f0d6 | 12208 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12209 | vty_out(vty, |
12210 | " External BGP neighbor may be up to %d hops away.\n", | |
12211 | p->ttl); | |
12212 | } | |
12213 | } else { | |
e2521429 | 12214 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 12215 | if (use_json) |
12216 | json_object_int_add(json_neigh, | |
12217 | "internalBgpNbrMaxHopsAway", | |
12218 | p->gtsm_hops); | |
12219 | else | |
12220 | vty_out(vty, | |
12221 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12222 | p->gtsm_hops); | |
12223 | } | |
12224 | } | |
12225 | ||
12226 | /* Local address. */ | |
12227 | if (p->su_local) { | |
12228 | if (use_json) { | |
12229 | json_object_string_add(json_neigh, "hostLocal", | |
12230 | sockunion2str(p->su_local, buf1, | |
12231 | SU_ADDRSTRLEN)); | |
12232 | json_object_int_add(json_neigh, "portLocal", | |
12233 | ntohs(p->su_local->sin.sin_port)); | |
12234 | } else | |
12235 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
12236 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
12237 | ntohs(p->su_local->sin.sin_port)); | |
12238 | } | |
12239 | ||
12240 | /* Remote address. */ | |
12241 | if (p->su_remote) { | |
12242 | if (use_json) { | |
12243 | json_object_string_add(json_neigh, "hostForeign", | |
12244 | sockunion2str(p->su_remote, buf1, | |
12245 | SU_ADDRSTRLEN)); | |
12246 | json_object_int_add(json_neigh, "portForeign", | |
12247 | ntohs(p->su_remote->sin.sin_port)); | |
12248 | } else | |
12249 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
12250 | sockunion2str(p->su_remote, buf1, | |
12251 | SU_ADDRSTRLEN), | |
12252 | ntohs(p->su_remote->sin.sin_port)); | |
12253 | } | |
12254 | ||
12255 | /* Nexthop display. */ | |
12256 | if (p->su_local) { | |
12257 | if (use_json) { | |
12258 | json_object_string_add(json_neigh, "nexthop", | |
12259 | inet_ntop(AF_INET, | |
12260 | &p->nexthop.v4, buf1, | |
12261 | sizeof(buf1))); | |
12262 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12263 | inet_ntop(AF_INET6, | |
12264 | &p->nexthop.v6_global, | |
12265 | buf1, sizeof(buf1))); | |
12266 | json_object_string_add(json_neigh, "nexthopLocal", | |
12267 | inet_ntop(AF_INET6, | |
12268 | &p->nexthop.v6_local, | |
12269 | buf1, sizeof(buf1))); | |
12270 | if (p->shared_network) | |
12271 | json_object_string_add(json_neigh, | |
12272 | "bgpConnection", | |
12273 | "sharedNetwork"); | |
12274 | else | |
12275 | json_object_string_add(json_neigh, | |
12276 | "bgpConnection", | |
12277 | "nonSharedNetwork"); | |
12278 | } else { | |
12279 | vty_out(vty, "Nexthop: %s\n", | |
12280 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12281 | sizeof(buf1))); | |
12282 | vty_out(vty, "Nexthop global: %s\n", | |
12283 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12284 | sizeof(buf1))); | |
12285 | vty_out(vty, "Nexthop local: %s\n", | |
12286 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12287 | sizeof(buf1))); | |
12288 | vty_out(vty, "BGP connection: %s\n", | |
12289 | p->shared_network ? "shared network" | |
12290 | : "non shared network"); | |
12291 | } | |
12292 | } | |
12293 | ||
12294 | /* Timer information. */ | |
12295 | if (use_json) { | |
12296 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12297 | p->v_connect); | |
12298 | if (p->status == Established && p->rtt) | |
12299 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12300 | p->rtt); | |
12301 | if (p->t_start) | |
12302 | json_object_int_add( | |
12303 | json_neigh, "nextStartTimerDueInMsecs", | |
12304 | thread_timer_remain_second(p->t_start) * 1000); | |
12305 | if (p->t_connect) | |
12306 | json_object_int_add( | |
12307 | json_neigh, "nextConnectTimerDueInMsecs", | |
12308 | thread_timer_remain_second(p->t_connect) | |
12309 | * 1000); | |
12310 | if (p->t_routeadv) { | |
12311 | json_object_int_add(json_neigh, "mraiInterval", | |
12312 | p->v_routeadv); | |
12313 | json_object_int_add( | |
12314 | json_neigh, "mraiTimerExpireInMsecs", | |
12315 | thread_timer_remain_second(p->t_routeadv) | |
12316 | * 1000); | |
12317 | } | |
12318 | if (p->password) | |
12319 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12320 | 1); | |
12321 | ||
12322 | if (p->t_read) | |
12323 | json_object_string_add(json_neigh, "readThread", "on"); | |
12324 | else | |
12325 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12326 | |
12327 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12328 | json_object_string_add(json_neigh, "writeThread", "on"); |
12329 | else | |
12330 | json_object_string_add(json_neigh, "writeThread", | |
12331 | "off"); | |
12332 | } else { | |
12333 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12334 | p->v_connect); | |
12335 | if (p->status == Established && p->rtt) | |
12336 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12337 | p->rtt); | |
12338 | if (p->t_start) | |
12339 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12340 | thread_timer_remain_second(p->t_start)); | |
12341 | if (p->t_connect) | |
12342 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12343 | thread_timer_remain_second(p->t_connect)); | |
12344 | if (p->t_routeadv) | |
12345 | vty_out(vty, | |
12346 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12347 | p->v_routeadv, | |
12348 | thread_timer_remain_second(p->t_routeadv)); | |
12349 | if (p->password) | |
12350 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12351 | ||
cac9e917 | 12352 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12353 | p->t_read ? "on" : "off", |
12354 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12355 | ? "on" | |
cac9e917 | 12356 | : "off", p->fd); |
d62a17ae | 12357 | } |
12358 | ||
12359 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12360 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12361 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12362 | ||
12363 | if (!use_json) | |
12364 | vty_out(vty, "\n"); | |
12365 | ||
12366 | /* BFD information. */ | |
12367 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12368 | ||
12369 | if (use_json) { | |
12370 | if (p->conf_if) /* Configured interface name. */ | |
12371 | json_object_object_add(json, p->conf_if, json_neigh); | |
12372 | else /* Configured IP address. */ | |
12373 | json_object_object_add(json, p->host, json_neigh); | |
12374 | } | |
12375 | } | |
12376 | ||
36235319 QY |
12377 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12378 | enum show_type type, | |
12379 | union sockunion *su, | |
12380 | const char *conf_if, afi_t afi, | |
74a630b6 | 12381 | bool use_json) |
2986cac2 | 12382 | { |
12383 | struct listnode *node, *nnode; | |
12384 | struct peer *peer; | |
12385 | int find = 0; | |
12386 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 12387 | json_object *json = NULL; |
2986cac2 | 12388 | json_object *json_neighbor = NULL; |
12389 | ||
74a630b6 NT |
12390 | if (use_json) { |
12391 | json = json_object_new_object(); | |
12392 | json_neighbor = json_object_new_object(); | |
12393 | } | |
12394 | ||
2986cac2 | 12395 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
12396 | ||
12397 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12398 | continue; | |
12399 | ||
12400 | if ((peer->afc[afi][safi]) == 0) | |
12401 | continue; | |
12402 | ||
2ba1fe69 | 12403 | if (type == show_all) { |
2986cac2 | 12404 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12405 | json_neighbor); |
2986cac2 | 12406 | |
74a630b6 | 12407 | if (use_json) { |
13909c4f DS |
12408 | json_object_object_add(json, peer->host, |
12409 | json_neighbor); | |
74a630b6 NT |
12410 | json_neighbor = NULL; |
12411 | } | |
2986cac2 | 12412 | |
2ba1fe69 | 12413 | } else if (type == show_peer) { |
2986cac2 | 12414 | if (conf_if) { |
12415 | if ((peer->conf_if | |
13909c4f DS |
12416 | && !strcmp(peer->conf_if, conf_if)) |
12417 | || (peer->hostname | |
2986cac2 | 12418 | && !strcmp(peer->hostname, conf_if))) { |
12419 | find = 1; | |
13909c4f DS |
12420 | bgp_show_peer_gr_status(vty, peer, |
12421 | use_json, | |
12422 | json_neighbor); | |
2986cac2 | 12423 | } |
12424 | } else { | |
12425 | if (sockunion_same(&peer->su, su)) { | |
12426 | find = 1; | |
13909c4f DS |
12427 | bgp_show_peer_gr_status(vty, peer, |
12428 | use_json, | |
12429 | json_neighbor); | |
2986cac2 | 12430 | } |
12431 | } | |
13909c4f DS |
12432 | if (use_json && find) |
12433 | json_object_object_add(json, peer->host, | |
12434 | json_neighbor); | |
2986cac2 | 12435 | } |
12436 | ||
74a630b6 NT |
12437 | if (find) { |
12438 | json_neighbor = NULL; | |
2986cac2 | 12439 | break; |
74a630b6 | 12440 | } |
2986cac2 | 12441 | } |
12442 | ||
12443 | if (type == show_peer && !find) { | |
12444 | if (use_json) | |
13909c4f | 12445 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12446 | else |
12447 | vty_out(vty, "%% No such neighbor\n"); | |
12448 | } | |
12449 | if (use_json) { | |
13909c4f DS |
12450 | vty_out(vty, "%s\n", |
12451 | json_object_to_json_string_ext( | |
12452 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
12453 | |
12454 | if (json_neighbor) | |
12455 | json_object_free(json_neighbor); | |
12456 | json_object_free(json); | |
2986cac2 | 12457 | } else { |
12458 | vty_out(vty, "\n"); | |
12459 | } | |
12460 | ||
12461 | return CMD_SUCCESS; | |
12462 | } | |
12463 | ||
d62a17ae | 12464 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12465 | enum show_type type, union sockunion *su, | |
9f049418 | 12466 | const char *conf_if, bool use_json, |
d62a17ae | 12467 | json_object *json) |
12468 | { | |
12469 | struct listnode *node, *nnode; | |
12470 | struct peer *peer; | |
12471 | int find = 0; | |
9f049418 | 12472 | bool nbr_output = false; |
d1927ebe AS |
12473 | afi_t afi = AFI_MAX; |
12474 | safi_t safi = SAFI_MAX; | |
12475 | ||
12476 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12477 | afi = AFI_IP; | |
12478 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12479 | afi = AFI_IP6; | |
12480 | } | |
d62a17ae | 12481 | |
12482 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12483 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12484 | continue; | |
12485 | ||
12486 | switch (type) { | |
12487 | case show_all: | |
12488 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12489 | nbr_output = true; |
d62a17ae | 12490 | break; |
12491 | case show_peer: | |
12492 | if (conf_if) { | |
12493 | if ((peer->conf_if | |
12494 | && !strcmp(peer->conf_if, conf_if)) | |
12495 | || (peer->hostname | |
12496 | && !strcmp(peer->hostname, conf_if))) { | |
12497 | find = 1; | |
12498 | bgp_show_peer(vty, peer, use_json, | |
12499 | json); | |
12500 | } | |
12501 | } else { | |
12502 | if (sockunion_same(&peer->su, su)) { | |
12503 | find = 1; | |
12504 | bgp_show_peer(vty, peer, use_json, | |
12505 | json); | |
12506 | } | |
12507 | } | |
12508 | break; | |
d1927ebe AS |
12509 | case show_ipv4_peer: |
12510 | case show_ipv6_peer: | |
12511 | FOREACH_SAFI (safi) { | |
12512 | if (peer->afc[afi][safi]) { | |
12513 | if (conf_if) { | |
12514 | if ((peer->conf_if | |
12515 | && !strcmp(peer->conf_if, conf_if)) | |
12516 | || (peer->hostname | |
12517 | && !strcmp(peer->hostname, conf_if))) { | |
12518 | find = 1; | |
12519 | bgp_show_peer(vty, peer, use_json, | |
12520 | json); | |
12521 | break; | |
12522 | } | |
12523 | } else { | |
12524 | if (sockunion_same(&peer->su, su)) { | |
12525 | find = 1; | |
12526 | bgp_show_peer(vty, peer, use_json, | |
12527 | json); | |
12528 | break; | |
12529 | } | |
12530 | } | |
12531 | } | |
12532 | } | |
12533 | break; | |
12534 | case show_ipv4_all: | |
12535 | case show_ipv6_all: | |
12536 | FOREACH_SAFI (safi) { | |
12537 | if (peer->afc[afi][safi]) { | |
12538 | bgp_show_peer(vty, peer, use_json, json); | |
12539 | nbr_output = true; | |
12540 | break; | |
12541 | } | |
12542 | } | |
12543 | break; | |
d62a17ae | 12544 | } |
12545 | } | |
12546 | ||
d1927ebe AS |
12547 | if ((type == show_peer || type == show_ipv4_peer || |
12548 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12549 | if (use_json) |
12550 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12551 | else | |
88b7d255 | 12552 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12553 | } |
12554 | ||
d1927ebe AS |
12555 | if (type != show_peer && type != show_ipv4_peer && |
12556 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12557 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12558 | |
d62a17ae | 12559 | if (use_json) { |
996c9314 LB |
12560 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12561 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12562 | } else { |
12563 | vty_out(vty, "\n"); | |
12564 | } | |
12565 | ||
12566 | return CMD_SUCCESS; | |
12567 | } | |
12568 | ||
36235319 QY |
12569 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12570 | enum show_type type, | |
12571 | const char *ip_str, | |
12572 | afi_t afi, bool use_json) | |
2986cac2 | 12573 | { |
12574 | ||
12575 | int ret; | |
12576 | struct bgp *bgp; | |
12577 | union sockunion su; | |
2986cac2 | 12578 | |
12579 | bgp = bgp_get_default(); | |
12580 | ||
13909c4f DS |
12581 | if (!bgp) |
12582 | return; | |
2986cac2 | 12583 | |
13909c4f DS |
12584 | if (!use_json) |
12585 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12586 | NULL); | |
2986cac2 | 12587 | |
13909c4f DS |
12588 | if (ip_str) { |
12589 | ret = str2sockunion(ip_str, &su); | |
12590 | if (ret < 0) | |
13909c4f | 12591 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
12592 | vty, bgp, type, NULL, ip_str, afi, use_json); |
12593 | else | |
12594 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
12595 | NULL, afi, use_json); | |
13909c4f DS |
12596 | } else |
12597 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 12598 | afi, use_json); |
2986cac2 | 12599 | } |
12600 | ||
d62a17ae | 12601 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12602 | enum show_type type, |
12603 | const char *ip_str, | |
9f049418 | 12604 | bool use_json) |
d62a17ae | 12605 | { |
0291c246 MK |
12606 | struct listnode *node, *nnode; |
12607 | struct bgp *bgp; | |
71aedaa3 | 12608 | union sockunion su; |
0291c246 | 12609 | json_object *json = NULL; |
71aedaa3 | 12610 | int ret, is_first = 1; |
9f049418 | 12611 | bool nbr_output = false; |
d62a17ae | 12612 | |
12613 | if (use_json) | |
12614 | vty_out(vty, "{\n"); | |
12615 | ||
12616 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12617 | nbr_output = true; |
d62a17ae | 12618 | if (use_json) { |
12619 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12620 | flog_err( |
e50f7cfd | 12621 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12622 | "Unable to allocate memory for JSON object"); |
12623 | vty_out(vty, | |
12624 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12625 | return; | |
12626 | } | |
12627 | ||
12628 | json_object_int_add(json, "vrfId", | |
12629 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12630 | ? -1 |
12631 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12632 | json_object_string_add( |
12633 | json, "vrfName", | |
12634 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12635 | ? VRF_DEFAULT_NAME |
d62a17ae | 12636 | : bgp->name); |
12637 | ||
12638 | if (!is_first) | |
12639 | vty_out(vty, ",\n"); | |
12640 | else | |
12641 | is_first = 0; | |
12642 | ||
12643 | vty_out(vty, "\"%s\":", | |
12644 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12645 | ? VRF_DEFAULT_NAME |
d62a17ae | 12646 | : bgp->name); |
12647 | } else { | |
12648 | vty_out(vty, "\nInstance %s:\n", | |
12649 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12650 | ? VRF_DEFAULT_NAME |
d62a17ae | 12651 | : bgp->name); |
12652 | } | |
71aedaa3 | 12653 | |
d1927ebe AS |
12654 | if (type == show_peer || type == show_ipv4_peer || |
12655 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12656 | ret = str2sockunion(ip_str, &su); |
12657 | if (ret < 0) | |
12658 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12659 | use_json, json); | |
12660 | else | |
12661 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12662 | use_json, json); | |
12663 | } else { | |
d1927ebe | 12664 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12665 | use_json, json); |
12666 | } | |
b77004d6 | 12667 | json_object_free(json); |
d62a17ae | 12668 | } |
12669 | ||
01cbfd04 | 12670 | if (use_json) { |
d62a17ae | 12671 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12672 | json_object_free(json); |
12673 | } | |
9f049418 DS |
12674 | else if (!nbr_output) |
12675 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12676 | } |
12677 | ||
12678 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12679 | enum show_type type, const char *ip_str, | |
9f049418 | 12680 | bool use_json) |
d62a17ae | 12681 | { |
12682 | int ret; | |
12683 | struct bgp *bgp; | |
12684 | union sockunion su; | |
12685 | json_object *json = NULL; | |
12686 | ||
12687 | if (name) { | |
12688 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12689 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12690 | use_json); | |
d62a17ae | 12691 | return CMD_SUCCESS; |
12692 | } else { | |
12693 | bgp = bgp_lookup_by_name(name); | |
12694 | if (!bgp) { | |
12695 | if (use_json) { | |
12696 | json = json_object_new_object(); | |
d62a17ae | 12697 | vty_out(vty, "%s\n", |
12698 | json_object_to_json_string_ext( | |
12699 | json, | |
12700 | JSON_C_TO_STRING_PRETTY)); | |
12701 | json_object_free(json); | |
12702 | } else | |
12703 | vty_out(vty, | |
9f049418 | 12704 | "%% BGP instance not found\n"); |
d62a17ae | 12705 | |
12706 | return CMD_WARNING; | |
12707 | } | |
12708 | } | |
12709 | } else { | |
12710 | bgp = bgp_get_default(); | |
12711 | } | |
12712 | ||
12713 | if (bgp) { | |
12714 | json = json_object_new_object(); | |
12715 | if (ip_str) { | |
12716 | ret = str2sockunion(ip_str, &su); | |
12717 | if (ret < 0) | |
12718 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12719 | use_json, json); | |
12720 | else | |
12721 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12722 | use_json, json); | |
12723 | } else { | |
12724 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12725 | json); | |
12726 | } | |
12727 | json_object_free(json); | |
ca61fd25 DS |
12728 | } else { |
12729 | if (use_json) | |
12730 | vty_out(vty, "{}\n"); | |
12731 | else | |
12732 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12733 | } |
12734 | ||
12735 | return CMD_SUCCESS; | |
4fb25c53 DW |
12736 | } |
12737 | ||
2986cac2 | 12738 | |
12739 | ||
12740 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12741 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12742 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12743 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12744 | SHOW_STR | |
12745 | BGP_STR | |
12746 | IP_STR | |
12747 | IPV6_STR | |
12748 | NEIGHBOR_STR | |
12749 | "Neighbor to display information about\n" | |
12750 | "Neighbor to display information about\n" | |
12751 | "Neighbor on BGP configured interface\n" | |
12752 | GR_SHOW | |
12753 | JSON_STR) | |
12754 | { | |
12755 | char *sh_arg = NULL; | |
12756 | enum show_type sh_type; | |
12757 | int idx = 0; | |
12758 | afi_t afi = AFI_MAX; | |
2986cac2 | 12759 | bool uj = use_json(argc, argv); |
12760 | ||
36235319 | 12761 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12762 | afi = AFI_MAX; |
12763 | ||
12764 | idx++; | |
12765 | ||
12766 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12767 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12768 | || argv_find(argv, argc, "WORD", &idx)) { | |
12769 | sh_type = show_peer; | |
12770 | sh_arg = argv[idx]->arg; | |
12771 | } else | |
12772 | sh_type = show_all; | |
12773 | ||
12774 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12775 | return CMD_SUCCESS; | |
12776 | ||
12777 | ||
36235319 QY |
12778 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12779 | afi, uj); | |
2986cac2 | 12780 | } |
12781 | ||
716b2d8a | 12782 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12783 | DEFUN (show_ip_bgp_neighbors, |
12784 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12785 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12786 | SHOW_STR |
12787 | IP_STR | |
12788 | BGP_STR | |
f2a8972b | 12789 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12790 | "Address Family\n" |
12791 | "Address Family\n" | |
718e3744 | 12792 | "Detailed information on TCP and BGP neighbor connections\n" |
12793 | "Neighbor to display information about\n" | |
a80beece | 12794 | "Neighbor to display information about\n" |
91d37724 | 12795 | "Neighbor on BGP configured interface\n" |
9973d184 | 12796 | JSON_STR) |
718e3744 | 12797 | { |
d62a17ae | 12798 | char *vrf = NULL; |
12799 | char *sh_arg = NULL; | |
12800 | enum show_type sh_type; | |
d1927ebe | 12801 | afi_t afi = AFI_MAX; |
718e3744 | 12802 | |
9f049418 | 12803 | bool uj = use_json(argc, argv); |
718e3744 | 12804 | |
d62a17ae | 12805 | int idx = 0; |
718e3744 | 12806 | |
9a8bdf1c PG |
12807 | /* [<vrf> VIEWVRFNAME] */ |
12808 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12809 | vrf = argv[idx + 1]->arg; | |
12810 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12811 | vrf = NULL; | |
12812 | } else if (argv_find(argv, argc, "view", &idx)) | |
12813 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12814 | vrf = argv[idx + 1]->arg; |
718e3744 | 12815 | |
d62a17ae | 12816 | idx++; |
d1927ebe AS |
12817 | |
12818 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12819 | sh_type = show_ipv4_all; | |
12820 | afi = AFI_IP; | |
12821 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12822 | sh_type = show_ipv6_all; | |
12823 | afi = AFI_IP6; | |
12824 | } else { | |
12825 | sh_type = show_all; | |
12826 | } | |
12827 | ||
d62a17ae | 12828 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12829 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12830 | || argv_find(argv, argc, "WORD", &idx)) { | |
12831 | sh_type = show_peer; | |
12832 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12833 | } |
12834 | ||
12835 | if (sh_type == show_peer && afi == AFI_IP) { | |
12836 | sh_type = show_ipv4_peer; | |
12837 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12838 | sh_type = show_ipv6_peer; | |
12839 | } | |
856ca177 | 12840 | |
d62a17ae | 12841 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12842 | } |
12843 | ||
716b2d8a | 12844 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12845 | paths' and `show ip mbgp paths'. Those functions results are the |
12846 | same.*/ | |
f412b39a | 12847 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12848 | show_ip_bgp_paths_cmd, |
46f296b4 | 12849 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12850 | SHOW_STR |
12851 | IP_STR | |
12852 | BGP_STR | |
46f296b4 | 12853 | BGP_SAFI_HELP_STR |
718e3744 | 12854 | "Path information\n") |
12855 | { | |
d62a17ae | 12856 | vty_out(vty, "Address Refcnt Path\n"); |
12857 | aspath_print_all_vty(vty); | |
12858 | return CMD_SUCCESS; | |
718e3744 | 12859 | } |
12860 | ||
718e3744 | 12861 | #include "hash.h" |
12862 | ||
e3b78da8 | 12863 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12864 | struct vty *vty) |
718e3744 | 12865 | { |
d62a17ae | 12866 | struct community *com; |
718e3744 | 12867 | |
e3b78da8 | 12868 | com = (struct community *)bucket->data; |
3f65c5b1 | 12869 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12870 | community_str(com, false)); |
718e3744 | 12871 | } |
12872 | ||
12873 | /* Show BGP's community internal data. */ | |
f412b39a | 12874 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12875 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12876 | "show [ip] bgp community-info", |
718e3744 | 12877 | SHOW_STR |
12878 | IP_STR | |
12879 | BGP_STR | |
12880 | "List all bgp community information\n") | |
12881 | { | |
d62a17ae | 12882 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12883 | |
d62a17ae | 12884 | hash_iterate(community_hash(), |
e3b78da8 | 12885 | (void (*)(struct hash_bucket *, |
d62a17ae | 12886 | void *))community_show_all_iterator, |
12887 | vty); | |
718e3744 | 12888 | |
d62a17ae | 12889 | return CMD_SUCCESS; |
718e3744 | 12890 | } |
12891 | ||
e3b78da8 | 12892 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12893 | struct vty *vty) |
57d187bc | 12894 | { |
d62a17ae | 12895 | struct lcommunity *lcom; |
57d187bc | 12896 | |
e3b78da8 | 12897 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12898 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12899 | lcommunity_str(lcom, false)); |
57d187bc JS |
12900 | } |
12901 | ||
12902 | /* Show BGP's community internal data. */ | |
12903 | DEFUN (show_ip_bgp_lcommunity_info, | |
12904 | show_ip_bgp_lcommunity_info_cmd, | |
12905 | "show ip bgp large-community-info", | |
12906 | SHOW_STR | |
12907 | IP_STR | |
12908 | BGP_STR | |
12909 | "List all bgp large-community information\n") | |
12910 | { | |
d62a17ae | 12911 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12912 | |
d62a17ae | 12913 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12914 | (void (*)(struct hash_bucket *, |
d62a17ae | 12915 | void *))lcommunity_show_all_iterator, |
12916 | vty); | |
57d187bc | 12917 | |
d62a17ae | 12918 | return CMD_SUCCESS; |
57d187bc | 12919 | } |
2986cac2 | 12920 | /* Graceful Restart */ |
12921 | ||
12922 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
12923 | struct bgp *bgp, |
12924 | bool use_json, | |
12925 | json_object *json) | |
2986cac2 | 12926 | { |
57d187bc JS |
12927 | |
12928 | ||
2986cac2 | 12929 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12930 | ||
7318ae88 | 12931 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 12932 | |
12933 | switch (bgp_global_gr_mode) { | |
12934 | ||
12935 | case GLOBAL_HELPER: | |
13909c4f | 12936 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 12937 | break; |
12938 | ||
12939 | case GLOBAL_GR: | |
13909c4f | 12940 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 12941 | break; |
12942 | ||
12943 | case GLOBAL_DISABLE: | |
13909c4f | 12944 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 12945 | break; |
12946 | ||
12947 | case GLOBAL_INVALID: | |
2986cac2 | 12948 | vty_out(vty, |
2ba1fe69 | 12949 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 12950 | break; |
12951 | } | |
12952 | vty_out(vty, "\n"); | |
12953 | } | |
12954 | ||
36235319 QY |
12955 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
12956 | enum show_type type, | |
12957 | const char *ip_str, | |
12958 | afi_t afi, bool use_json) | |
2986cac2 | 12959 | { |
12960 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12961 | afi = AFI_IP; | |
12962 | ||
12963 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12964 | ||
36235319 QY |
12965 | bgp_show_neighbor_graceful_restart_vty( |
12966 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 12967 | afi++; |
12968 | } | |
12969 | } else if (afi != AFI_MAX) { | |
36235319 QY |
12970 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
12971 | use_json); | |
2986cac2 | 12972 | } else { |
12973 | return CMD_ERR_INCOMPLETE; | |
12974 | } | |
12975 | ||
12976 | return CMD_SUCCESS; | |
12977 | } | |
12978 | /* Graceful Restart */ | |
12979 | ||
f412b39a | 12980 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12981 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12982 | "show [ip] bgp attribute-info", |
718e3744 | 12983 | SHOW_STR |
12984 | IP_STR | |
12985 | BGP_STR | |
12986 | "List all bgp attribute information\n") | |
12987 | { | |
d62a17ae | 12988 | attr_show_all(vty); |
12989 | return CMD_SUCCESS; | |
718e3744 | 12990 | } |
6b0655a2 | 12991 | |
03915806 CS |
12992 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12993 | afi_t afi, safi_t safi, | |
12994 | bool use_json, json_object *json) | |
53089bec | 12995 | { |
12996 | struct bgp *bgp; | |
12997 | struct listnode *node; | |
12998 | char *vname; | |
12999 | char buf1[INET6_ADDRSTRLEN]; | |
13000 | char *ecom_str; | |
13001 | vpn_policy_direction_t dir; | |
13002 | ||
03915806 | 13003 | if (json) { |
b46dfd20 DS |
13004 | json_object *json_import_vrfs = NULL; |
13005 | json_object *json_export_vrfs = NULL; | |
13006 | ||
b46dfd20 DS |
13007 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13008 | ||
53089bec | 13009 | if (!bgp) { |
b46dfd20 DS |
13010 | vty_out(vty, "%s\n", |
13011 | json_object_to_json_string_ext( | |
13012 | json, | |
13013 | JSON_C_TO_STRING_PRETTY)); | |
13014 | json_object_free(json); | |
13015 | ||
53089bec | 13016 | return CMD_WARNING; |
13017 | } | |
b46dfd20 | 13018 | |
94d4c685 DS |
13019 | /* Provide context for the block */ |
13020 | json_object_string_add(json, "vrf", name ? name : "default"); | |
13021 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 13022 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 13023 | |
b46dfd20 DS |
13024 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13025 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
13026 | json_object_string_add(json, "importFromVrfs", "none"); | |
13027 | json_object_string_add(json, "importRts", "none"); | |
13028 | } else { | |
6ce24e52 DS |
13029 | json_import_vrfs = json_object_new_array(); |
13030 | ||
b46dfd20 DS |
13031 | for (ALL_LIST_ELEMENTS_RO( |
13032 | bgp->vpn_policy[afi].import_vrf, | |
13033 | node, vname)) | |
13034 | json_object_array_add(json_import_vrfs, | |
13035 | json_object_new_string(vname)); | |
13036 | ||
b20875ea CS |
13037 | json_object_object_add(json, "importFromVrfs", |
13038 | json_import_vrfs); | |
b46dfd20 | 13039 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
13040 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13041 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13042 | bgp->vpn_policy[afi].rtlist[dir], |
13043 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13044 | json_object_string_add(json, "importRts", |
13045 | ecom_str); | |
13046 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13047 | } else | |
13048 | json_object_string_add(json, "importRts", | |
13049 | "none"); | |
b46dfd20 DS |
13050 | } |
13051 | ||
13052 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
13053 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
13054 | json_object_string_add(json, "exportToVrfs", "none"); | |
13055 | json_object_string_add(json, "routeDistinguisher", | |
13056 | "none"); | |
13057 | json_object_string_add(json, "exportRts", "none"); | |
13058 | } else { | |
6ce24e52 DS |
13059 | json_export_vrfs = json_object_new_array(); |
13060 | ||
b46dfd20 DS |
13061 | for (ALL_LIST_ELEMENTS_RO( |
13062 | bgp->vpn_policy[afi].export_vrf, | |
13063 | node, vname)) | |
13064 | json_object_array_add(json_export_vrfs, | |
13065 | json_object_new_string(vname)); | |
13066 | json_object_object_add(json, "exportToVrfs", | |
13067 | json_export_vrfs); | |
13068 | json_object_string_add(json, "routeDistinguisher", | |
13069 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13070 | buf1, RD_ADDRSTRLEN)); | |
13071 | ||
13072 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13073 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13074 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13075 | bgp->vpn_policy[afi].rtlist[dir], |
13076 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13077 | json_object_string_add(json, "exportRts", |
13078 | ecom_str); | |
13079 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13080 | } else | |
13081 | json_object_string_add(json, "exportRts", | |
13082 | "none"); | |
b46dfd20 DS |
13083 | } |
13084 | ||
03915806 CS |
13085 | if (use_json) { |
13086 | vty_out(vty, "%s\n", | |
13087 | json_object_to_json_string_ext(json, | |
b46dfd20 | 13088 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
13089 | json_object_free(json); |
13090 | } | |
53089bec | 13091 | } else { |
b46dfd20 DS |
13092 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
13093 | ||
53089bec | 13094 | if (!bgp) { |
b46dfd20 | 13095 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 13096 | return CMD_WARNING; |
13097 | } | |
53089bec | 13098 | |
b46dfd20 DS |
13099 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13100 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
13101 | vty_out(vty, | |
13102 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 13103 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13104 | else { |
13105 | vty_out(vty, | |
13106 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 13107 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13108 | |
13109 | for (ALL_LIST_ELEMENTS_RO( | |
13110 | bgp->vpn_policy[afi].import_vrf, | |
13111 | node, vname)) | |
13112 | vty_out(vty, " %s\n", vname); | |
13113 | ||
13114 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
13115 | ecom_str = NULL; |
13116 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
13117 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13118 | bgp->vpn_policy[afi].rtlist[dir], |
13119 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 13120 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 13121 | |
b20875ea CS |
13122 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
13123 | } else | |
13124 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13125 | } |
53089bec | 13126 | |
b46dfd20 DS |
13127 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
13128 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
13129 | vty_out(vty, | |
13130 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 13131 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13132 | else { |
13133 | vty_out(vty, | |
04c9077f | 13134 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 13135 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
13136 | |
13137 | for (ALL_LIST_ELEMENTS_RO( | |
13138 | bgp->vpn_policy[afi].export_vrf, | |
13139 | node, vname)) | |
13140 | vty_out(vty, " %s\n", vname); | |
13141 | ||
13142 | vty_out(vty, "RD: %s\n", | |
13143 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
13144 | buf1, RD_ADDRSTRLEN)); | |
13145 | ||
13146 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
13147 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
13148 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
13149 | bgp->vpn_policy[afi].rtlist[dir], |
13150 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
13151 | vty_out(vty, "Export RT: %s\n", ecom_str); |
13152 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
13153 | } else | |
13154 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 13155 | } |
53089bec | 13156 | } |
13157 | ||
13158 | return CMD_SUCCESS; | |
13159 | } | |
13160 | ||
03915806 CS |
13161 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
13162 | safi_t safi, bool use_json) | |
13163 | { | |
13164 | struct listnode *node, *nnode; | |
13165 | struct bgp *bgp; | |
13166 | char *vrf_name = NULL; | |
13167 | json_object *json = NULL; | |
13168 | json_object *json_vrf = NULL; | |
13169 | json_object *json_vrfs = NULL; | |
13170 | ||
13171 | if (use_json) { | |
13172 | json = json_object_new_object(); | |
13173 | json_vrfs = json_object_new_object(); | |
13174 | } | |
13175 | ||
13176 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
13177 | ||
13178 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
13179 | vrf_name = bgp->name; | |
13180 | ||
13181 | if (use_json) { | |
13182 | json_vrf = json_object_new_object(); | |
13183 | } else { | |
13184 | vty_out(vty, "\nInstance %s:\n", | |
13185 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13186 | ? VRF_DEFAULT_NAME : bgp->name); | |
13187 | } | |
13188 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
13189 | if (use_json) { | |
13190 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13191 | json_object_object_add(json_vrfs, | |
13192 | VRF_DEFAULT_NAME, json_vrf); | |
13193 | else | |
13194 | json_object_object_add(json_vrfs, vrf_name, | |
13195 | json_vrf); | |
13196 | } | |
13197 | } | |
13198 | ||
13199 | if (use_json) { | |
13200 | json_object_object_add(json, "vrfs", json_vrfs); | |
13201 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13202 | JSON_C_TO_STRING_PRETTY)); | |
13203 | json_object_free(json); | |
13204 | } | |
13205 | ||
13206 | return CMD_SUCCESS; | |
13207 | } | |
13208 | ||
53089bec | 13209 | /* "show [ip] bgp route-leak" command. */ |
13210 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13211 | show_ip_bgp_route_leak_cmd, |
13212 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13213 | SHOW_STR |
13214 | IP_STR | |
13215 | BGP_STR | |
13216 | BGP_INSTANCE_HELP_STR | |
13217 | BGP_AFI_HELP_STR | |
13218 | BGP_SAFI_HELP_STR | |
13219 | "Route leaking information\n" | |
13220 | JSON_STR) | |
53089bec | 13221 | { |
13222 | char *vrf = NULL; | |
13223 | afi_t afi = AFI_MAX; | |
13224 | safi_t safi = SAFI_MAX; | |
13225 | ||
9f049418 | 13226 | bool uj = use_json(argc, argv); |
53089bec | 13227 | int idx = 0; |
03915806 | 13228 | json_object *json = NULL; |
53089bec | 13229 | |
13230 | /* show [ip] bgp */ | |
13231 | if (argv_find(argv, argc, "ip", &idx)) { | |
13232 | afi = AFI_IP; | |
13233 | safi = SAFI_UNICAST; | |
13234 | } | |
13235 | /* [vrf VIEWVRFNAME] */ | |
13236 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
13237 | vty_out(vty, |
13238 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 13239 | return CMD_WARNING; |
13240 | } | |
13241 | ||
9a8bdf1c PG |
13242 | if (argv_find(argv, argc, "vrf", &idx)) { |
13243 | vrf = argv[idx + 1]->arg; | |
13244 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13245 | vrf = NULL; | |
13246 | } | |
53089bec | 13247 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13248 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13249 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13250 | } | |
13251 | ||
13252 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
13253 | vty_out(vty, |
13254 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 13255 | return CMD_WARNING; |
13256 | } | |
13257 | ||
03915806 CS |
13258 | if (vrf && strmatch(vrf, "all")) |
13259 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13260 | ||
13261 | if (uj) | |
13262 | json = json_object_new_object(); | |
13263 | ||
13264 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13265 | } |
13266 | ||
d62a17ae | 13267 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13268 | safi_t safi) | |
f186de26 | 13269 | { |
d62a17ae | 13270 | struct listnode *node, *nnode; |
13271 | struct bgp *bgp; | |
f186de26 | 13272 | |
d62a17ae | 13273 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13274 | vty_out(vty, "\nInstance %s:\n", | |
13275 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13276 | ? VRF_DEFAULT_NAME |
d62a17ae | 13277 | : bgp->name); |
13278 | update_group_show(bgp, afi, safi, vty, 0); | |
13279 | } | |
f186de26 | 13280 | } |
13281 | ||
d62a17ae | 13282 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13283 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13284 | { |
d62a17ae | 13285 | struct bgp *bgp; |
4fb25c53 | 13286 | |
d62a17ae | 13287 | if (name) { |
13288 | if (strmatch(name, "all")) { | |
13289 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13290 | return CMD_SUCCESS; | |
13291 | } else { | |
13292 | bgp = bgp_lookup_by_name(name); | |
13293 | } | |
13294 | } else { | |
13295 | bgp = bgp_get_default(); | |
13296 | } | |
4fb25c53 | 13297 | |
d62a17ae | 13298 | if (bgp) |
13299 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13300 | return CMD_SUCCESS; | |
4fb25c53 DW |
13301 | } |
13302 | ||
8fe8a7f6 DS |
13303 | DEFUN (show_ip_bgp_updgrps, |
13304 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13305 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13306 | SHOW_STR |
13307 | IP_STR | |
13308 | BGP_STR | |
13309 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13310 | BGP_AFI_HELP_STR |
9bedbb1e | 13311 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13312 | "Detailed info about dynamic update groups\n" |
13313 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13314 | { |
d62a17ae | 13315 | char *vrf = NULL; |
13316 | afi_t afi = AFI_IP6; | |
13317 | safi_t safi = SAFI_UNICAST; | |
13318 | uint64_t subgrp_id = 0; | |
13319 | ||
13320 | int idx = 0; | |
13321 | ||
13322 | /* show [ip] bgp */ | |
13323 | if (argv_find(argv, argc, "ip", &idx)) | |
13324 | afi = AFI_IP; | |
9a8bdf1c PG |
13325 | /* [<vrf> VIEWVRFNAME] */ |
13326 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13327 | vrf = argv[idx + 1]->arg; | |
13328 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13329 | vrf = NULL; | |
13330 | } else if (argv_find(argv, argc, "view", &idx)) | |
13331 | /* [<view> VIEWVRFNAME] */ | |
13332 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13333 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13334 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13335 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13336 | } | |
5bf15956 | 13337 | |
d62a17ae | 13338 | /* get subgroup id, if provided */ |
13339 | idx = argc - 1; | |
13340 | if (argv[idx]->type == VARIABLE_TKN) | |
13341 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13342 | |
d62a17ae | 13343 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13344 | } |
13345 | ||
f186de26 | 13346 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13347 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13348 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13349 | SHOW_STR |
716b2d8a | 13350 | IP_STR |
f186de26 | 13351 | BGP_STR |
13352 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13353 | "Detailed info about dynamic update groups\n") |
f186de26 | 13354 | { |
d62a17ae | 13355 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13356 | return CMD_SUCCESS; | |
f186de26 | 13357 | } |
13358 | ||
43d3f4fc DS |
13359 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13360 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13361 | "show [ip] bgp l2vpn evpn update-groups", | |
13362 | SHOW_STR | |
13363 | IP_STR | |
13364 | BGP_STR | |
13365 | "l2vpn address family\n" | |
13366 | "evpn sub-address family\n" | |
13367 | "Detailed info about dynamic update groups\n") | |
13368 | { | |
13369 | char *vrf = NULL; | |
13370 | uint64_t subgrp_id = 0; | |
13371 | ||
13372 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13373 | return CMD_SUCCESS; | |
13374 | } | |
13375 | ||
5bf15956 DW |
13376 | DEFUN (show_bgp_updgrps_stats, |
13377 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13378 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13379 | SHOW_STR |
716b2d8a | 13380 | IP_STR |
3f9c7369 | 13381 | BGP_STR |
0c7b1b01 | 13382 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13383 | "Statistics\n") |
13384 | { | |
d62a17ae | 13385 | struct bgp *bgp; |
3f9c7369 | 13386 | |
d62a17ae | 13387 | bgp = bgp_get_default(); |
13388 | if (bgp) | |
13389 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13390 | |
d62a17ae | 13391 | return CMD_SUCCESS; |
3f9c7369 DS |
13392 | } |
13393 | ||
8386ac43 | 13394 | DEFUN (show_bgp_instance_updgrps_stats, |
13395 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13396 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13397 | SHOW_STR |
716b2d8a | 13398 | IP_STR |
8386ac43 | 13399 | BGP_STR |
13400 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13401 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13402 | "Statistics\n") |
13403 | { | |
d62a17ae | 13404 | int idx_word = 3; |
13405 | struct bgp *bgp; | |
8386ac43 | 13406 | |
d62a17ae | 13407 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13408 | if (bgp) | |
13409 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13410 | |
d62a17ae | 13411 | return CMD_SUCCESS; |
8386ac43 | 13412 | } |
13413 | ||
d62a17ae | 13414 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13415 | afi_t afi, safi_t safi, | |
13416 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13417 | { |
d62a17ae | 13418 | struct bgp *bgp; |
8386ac43 | 13419 | |
d62a17ae | 13420 | if (name) |
13421 | bgp = bgp_lookup_by_name(name); | |
13422 | else | |
13423 | bgp = bgp_get_default(); | |
8386ac43 | 13424 | |
d62a17ae | 13425 | if (bgp) { |
13426 | if (!strcmp(what, "advertise-queue")) | |
13427 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13428 | subgrp_id); | |
13429 | else if (!strcmp(what, "advertised-routes")) | |
13430 | update_group_show_advertised(bgp, afi, safi, vty, | |
13431 | subgrp_id); | |
13432 | else if (!strcmp(what, "packet-queue")) | |
13433 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13434 | subgrp_id); | |
13435 | } | |
3f9c7369 DS |
13436 | } |
13437 | ||
dc64bdec QY |
13438 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13439 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13440 | "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", | |
13441 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13442 | BGP_SAFI_HELP_STR | |
13443 | "Detailed info about dynamic update groups\n" | |
13444 | "Specific subgroup to display info for\n" | |
13445 | "Advertisement queue\n" | |
13446 | "Announced routes\n" | |
13447 | "Packet queue\n") | |
3f9c7369 | 13448 | { |
dc64bdec QY |
13449 | uint64_t subgrp_id = 0; |
13450 | afi_t afiz; | |
13451 | safi_t safiz; | |
13452 | if (sgid) | |
13453 | subgrp_id = strtoull(sgid, NULL, 10); | |
13454 | ||
13455 | if (!ip && !afi) | |
13456 | afiz = AFI_IP6; | |
13457 | if (!ip && afi) | |
13458 | afiz = bgp_vty_afi_from_str(afi); | |
13459 | if (ip && !afi) | |
13460 | afiz = AFI_IP; | |
13461 | if (ip && afi) { | |
13462 | afiz = bgp_vty_afi_from_str(afi); | |
13463 | if (afiz != AFI_IP) | |
13464 | vty_out(vty, | |
13465 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13466 | return CMD_WARNING; | |
13467 | } | |
d62a17ae | 13468 | |
dc64bdec | 13469 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13470 | |
dc64bdec | 13471 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13472 | return CMD_SUCCESS; |
13473 | } | |
13474 | ||
d62a17ae | 13475 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13476 | { | |
13477 | struct listnode *node, *nnode; | |
13478 | struct prefix *range; | |
13479 | struct peer *conf; | |
13480 | struct peer *peer; | |
13481 | char buf[PREFIX2STR_BUFFER]; | |
13482 | afi_t afi; | |
13483 | safi_t safi; | |
13484 | const char *peer_status; | |
13485 | const char *af_str; | |
13486 | int lr_count; | |
13487 | int dynamic; | |
13488 | int af_cfgd; | |
13489 | ||
13490 | conf = group->conf; | |
13491 | ||
13492 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13493 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13494 | group->name, conf->as); | |
d62a17ae | 13495 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13496 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13497 | group->name, group->bgp->as); | |
d62a17ae | 13498 | } else { |
13499 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13500 | } | |
f14e6fdb | 13501 | |
d62a17ae | 13502 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13503 | vty_out(vty, " Peer-group type is internal\n"); | |
13504 | else | |
13505 | vty_out(vty, " Peer-group type is external\n"); | |
13506 | ||
13507 | /* Display AFs configured. */ | |
13508 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13509 | FOREACH_AFI_SAFI (afi, safi) { |
13510 | if (conf->afc[afi][safi]) { | |
13511 | af_cfgd = 1; | |
5cb5f4d0 | 13512 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13513 | } |
05c7a1cc | 13514 | } |
d62a17ae | 13515 | if (!af_cfgd) |
13516 | vty_out(vty, " none\n"); | |
13517 | else | |
13518 | vty_out(vty, "\n"); | |
13519 | ||
13520 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13521 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13522 | if (afi == AFI_IP) | |
13523 | af_str = "IPv4"; | |
13524 | else if (afi == AFI_IP6) | |
13525 | af_str = "IPv6"; | |
13526 | else | |
13527 | af_str = "???"; | |
13528 | lr_count = listcount(group->listen_range[afi]); | |
13529 | if (lr_count) { | |
13530 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13531 | af_str); | |
13532 | ||
13533 | ||
13534 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13535 | nnode, range)) { | |
13536 | prefix2str(range, buf, sizeof(buf)); | |
13537 | vty_out(vty, " %s\n", buf); | |
13538 | } | |
13539 | } | |
13540 | } | |
f14e6fdb | 13541 | |
d62a17ae | 13542 | /* Display group members and their status */ |
13543 | if (listcount(group->peer)) { | |
13544 | vty_out(vty, " Peer-group members:\n"); | |
13545 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13546 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13547 | peer_status = "Idle (Admin)"; | |
13548 | else if (CHECK_FLAG(peer->sflags, | |
13549 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13550 | peer_status = "Idle (PfxCt)"; | |
13551 | else | |
13552 | peer_status = lookup_msg(bgp_status_msg, | |
13553 | peer->status, NULL); | |
13554 | ||
13555 | dynamic = peer_dynamic_neighbor(peer); | |
13556 | vty_out(vty, " %s %s %s \n", peer->host, | |
13557 | dynamic ? "(dynamic)" : "", peer_status); | |
13558 | } | |
13559 | } | |
f14e6fdb | 13560 | |
d62a17ae | 13561 | return CMD_SUCCESS; |
13562 | } | |
13563 | ||
ff9959b0 QY |
13564 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13565 | const char *group_name) | |
d62a17ae | 13566 | { |
ff9959b0 | 13567 | struct bgp *bgp; |
d62a17ae | 13568 | struct listnode *node, *nnode; |
13569 | struct peer_group *group; | |
ff9959b0 QY |
13570 | bool found = false; |
13571 | ||
13572 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13573 | ||
13574 | if (!bgp) { | |
9f049418 | 13575 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13576 | return CMD_WARNING; |
13577 | } | |
d62a17ae | 13578 | |
13579 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13580 | if (group_name) { |
13581 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13582 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13583 | found = true; |
13584 | break; | |
d62a17ae | 13585 | } |
ff9959b0 QY |
13586 | } else { |
13587 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13588 | } |
f14e6fdb | 13589 | } |
f14e6fdb | 13590 | |
ff9959b0 | 13591 | if (group_name && !found) |
d62a17ae | 13592 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13593 | |
d62a17ae | 13594 | return CMD_SUCCESS; |
f14e6fdb DS |
13595 | } |
13596 | ||
f14e6fdb DS |
13597 | DEFUN (show_ip_bgp_peer_groups, |
13598 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13599 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13600 | SHOW_STR |
13601 | IP_STR | |
13602 | BGP_STR | |
8386ac43 | 13603 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13604 | "Detailed information on BGP peer groups\n" |
13605 | "Peer group name\n") | |
f14e6fdb | 13606 | { |
d62a17ae | 13607 | char *vrf, *pg; |
d62a17ae | 13608 | int idx = 0; |
f14e6fdb | 13609 | |
a4d82a8a PZ |
13610 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13611 | : NULL; | |
d62a17ae | 13612 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13613 | |
ff9959b0 | 13614 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13615 | } |
3f9c7369 | 13616 | |
d6e3c605 | 13617 | |
718e3744 | 13618 | /* Redistribute VTY commands. */ |
13619 | ||
718e3744 | 13620 | DEFUN (bgp_redistribute_ipv4, |
13621 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13622 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13623 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13624 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13625 | { |
d62a17ae | 13626 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13627 | int idx_protocol = 1; | |
13628 | int type; | |
718e3744 | 13629 | |
d62a17ae | 13630 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13631 | if (type < 0) { | |
13632 | vty_out(vty, "%% Invalid route type\n"); | |
13633 | return CMD_WARNING_CONFIG_FAILED; | |
13634 | } | |
7f323236 | 13635 | |
d62a17ae | 13636 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13637 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13638 | } |
13639 | ||
d62a17ae | 13640 | ALIAS_HIDDEN( |
13641 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13642 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13643 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13644 | |
718e3744 | 13645 | DEFUN (bgp_redistribute_ipv4_rmap, |
13646 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13647 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13648 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13649 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13650 | "Route map reference\n" |
13651 | "Pointer to route-map entries\n") | |
13652 | { | |
d62a17ae | 13653 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13654 | int idx_protocol = 1; | |
13655 | int idx_word = 3; | |
13656 | int type; | |
13657 | struct bgp_redist *red; | |
e923dd62 | 13658 | bool changed; |
1de27621 DA |
13659 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13660 | vty, argv[idx_word]->arg); | |
718e3744 | 13661 | |
d62a17ae | 13662 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13663 | if (type < 0) { | |
13664 | vty_out(vty, "%% Invalid route type\n"); | |
13665 | return CMD_WARNING_CONFIG_FAILED; | |
13666 | } | |
718e3744 | 13667 | |
d62a17ae | 13668 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13669 | changed = |
13670 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13671 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13672 | } |
13673 | ||
d62a17ae | 13674 | ALIAS_HIDDEN( |
13675 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13676 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13677 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13678 | "Route map reference\n" | |
13679 | "Pointer to route-map entries\n") | |
596c17ba | 13680 | |
718e3744 | 13681 | DEFUN (bgp_redistribute_ipv4_metric, |
13682 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13683 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13684 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13685 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13686 | "Metric for redistributed routes\n" |
13687 | "Default metric\n") | |
13688 | { | |
d62a17ae | 13689 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13690 | int idx_protocol = 1; | |
13691 | int idx_number = 3; | |
13692 | int type; | |
d7c0a89a | 13693 | uint32_t metric; |
d62a17ae | 13694 | struct bgp_redist *red; |
e923dd62 | 13695 | bool changed; |
d62a17ae | 13696 | |
13697 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13698 | if (type < 0) { | |
13699 | vty_out(vty, "%% Invalid route type\n"); | |
13700 | return CMD_WARNING_CONFIG_FAILED; | |
13701 | } | |
13702 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13703 | ||
13704 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13705 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13706 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13707 | } |
13708 | ||
13709 | ALIAS_HIDDEN( | |
13710 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13711 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13712 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13713 | "Metric for redistributed routes\n" | |
13714 | "Default metric\n") | |
596c17ba | 13715 | |
718e3744 | 13716 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13717 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13718 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13719 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13720 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13721 | "Route map reference\n" |
13722 | "Pointer to route-map entries\n" | |
13723 | "Metric for redistributed routes\n" | |
13724 | "Default metric\n") | |
13725 | { | |
d62a17ae | 13726 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13727 | int idx_protocol = 1; | |
13728 | int idx_word = 3; | |
13729 | int idx_number = 5; | |
13730 | int type; | |
d7c0a89a | 13731 | uint32_t metric; |
d62a17ae | 13732 | struct bgp_redist *red; |
e923dd62 | 13733 | bool changed; |
1de27621 DA |
13734 | struct route_map *route_map = |
13735 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13736 | |
13737 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13738 | if (type < 0) { | |
13739 | vty_out(vty, "%% Invalid route type\n"); | |
13740 | return CMD_WARNING_CONFIG_FAILED; | |
13741 | } | |
13742 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13743 | ||
13744 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13745 | changed = |
13746 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13747 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13748 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13749 | } |
13750 | ||
13751 | ALIAS_HIDDEN( | |
13752 | bgp_redistribute_ipv4_rmap_metric, | |
13753 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13754 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13755 | " route-map WORD metric (0-4294967295)", | |
13756 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13757 | "Route map reference\n" | |
13758 | "Pointer to route-map entries\n" | |
13759 | "Metric for redistributed routes\n" | |
13760 | "Default metric\n") | |
596c17ba | 13761 | |
718e3744 | 13762 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13763 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13764 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13765 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13766 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13767 | "Metric for redistributed routes\n" |
13768 | "Default metric\n" | |
13769 | "Route map reference\n" | |
13770 | "Pointer to route-map entries\n") | |
13771 | { | |
d62a17ae | 13772 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13773 | int idx_protocol = 1; | |
13774 | int idx_number = 3; | |
13775 | int idx_word = 5; | |
13776 | int type; | |
d7c0a89a | 13777 | uint32_t metric; |
d62a17ae | 13778 | struct bgp_redist *red; |
e923dd62 | 13779 | bool changed; |
1de27621 DA |
13780 | struct route_map *route_map = |
13781 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13782 | |
13783 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13784 | if (type < 0) { | |
13785 | vty_out(vty, "%% Invalid route type\n"); | |
13786 | return CMD_WARNING_CONFIG_FAILED; | |
13787 | } | |
13788 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13789 | ||
13790 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13791 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13792 | changed |= |
13793 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13794 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13795 | } |
13796 | ||
13797 | ALIAS_HIDDEN( | |
13798 | bgp_redistribute_ipv4_metric_rmap, | |
13799 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13800 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13801 | " metric (0-4294967295) route-map WORD", | |
13802 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13803 | "Metric for redistributed routes\n" | |
13804 | "Default metric\n" | |
13805 | "Route map reference\n" | |
13806 | "Pointer to route-map entries\n") | |
596c17ba | 13807 | |
7c8ff89e DS |
13808 | DEFUN (bgp_redistribute_ipv4_ospf, |
13809 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13810 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13811 | "Redistribute information from another routing protocol\n" |
13812 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13813 | "Non-main Kernel Routing Table\n" |
13814 | "Instance ID/Table ID\n") | |
7c8ff89e | 13815 | { |
d62a17ae | 13816 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13817 | int idx_ospf_table = 1; | |
13818 | int idx_number = 2; | |
d7c0a89a QY |
13819 | unsigned short instance; |
13820 | unsigned short protocol; | |
7c8ff89e | 13821 | |
d62a17ae | 13822 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13823 | |
d62a17ae | 13824 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13825 | protocol = ZEBRA_ROUTE_OSPF; | |
13826 | else | |
13827 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13828 | |
d62a17ae | 13829 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13830 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13831 | } |
13832 | ||
d62a17ae | 13833 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13834 | "redistribute <ospf|table> (1-65535)", | |
13835 | "Redistribute information from another routing protocol\n" | |
13836 | "Open Shortest Path First (OSPFv2)\n" | |
13837 | "Non-main Kernel Routing Table\n" | |
13838 | "Instance ID/Table ID\n") | |
596c17ba | 13839 | |
7c8ff89e DS |
13840 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13841 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13842 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13843 | "Redistribute information from another routing protocol\n" |
13844 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13845 | "Non-main Kernel Routing Table\n" |
13846 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13847 | "Route map reference\n" |
13848 | "Pointer to route-map entries\n") | |
13849 | { | |
d62a17ae | 13850 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13851 | int idx_ospf_table = 1; | |
13852 | int idx_number = 2; | |
13853 | int idx_word = 4; | |
13854 | struct bgp_redist *red; | |
d7c0a89a | 13855 | unsigned short instance; |
d62a17ae | 13856 | int protocol; |
e923dd62 | 13857 | bool changed; |
1de27621 DA |
13858 | struct route_map *route_map = |
13859 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13860 | |
13861 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13862 | protocol = ZEBRA_ROUTE_OSPF; | |
13863 | else | |
13864 | protocol = ZEBRA_ROUTE_TABLE; | |
13865 | ||
13866 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13867 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13868 | changed = |
13869 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13870 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13871 | } |
13872 | ||
13873 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13874 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13875 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13876 | "Redistribute information from another routing protocol\n" | |
13877 | "Open Shortest Path First (OSPFv2)\n" | |
13878 | "Non-main Kernel Routing Table\n" | |
13879 | "Instance ID/Table ID\n" | |
13880 | "Route map reference\n" | |
13881 | "Pointer to route-map entries\n") | |
596c17ba | 13882 | |
7c8ff89e DS |
13883 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13884 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13885 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13886 | "Redistribute information from another routing protocol\n" |
13887 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13888 | "Non-main Kernel Routing Table\n" |
13889 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13890 | "Metric for redistributed routes\n" |
13891 | "Default metric\n") | |
13892 | { | |
d62a17ae | 13893 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13894 | int idx_ospf_table = 1; | |
13895 | int idx_number = 2; | |
13896 | int idx_number_2 = 4; | |
d7c0a89a | 13897 | uint32_t metric; |
d62a17ae | 13898 | struct bgp_redist *red; |
d7c0a89a | 13899 | unsigned short instance; |
d62a17ae | 13900 | int protocol; |
e923dd62 | 13901 | bool changed; |
d62a17ae | 13902 | |
13903 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13904 | protocol = ZEBRA_ROUTE_OSPF; | |
13905 | else | |
13906 | protocol = ZEBRA_ROUTE_TABLE; | |
13907 | ||
13908 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13909 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13910 | ||
13911 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13912 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13913 | metric); | |
13914 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13915 | } |
13916 | ||
13917 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13918 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13919 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13920 | "Redistribute information from another routing protocol\n" | |
13921 | "Open Shortest Path First (OSPFv2)\n" | |
13922 | "Non-main Kernel Routing Table\n" | |
13923 | "Instance ID/Table ID\n" | |
13924 | "Metric for redistributed routes\n" | |
13925 | "Default metric\n") | |
596c17ba | 13926 | |
7c8ff89e DS |
13927 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13928 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13929 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13930 | "Redistribute information from another routing protocol\n" |
13931 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13932 | "Non-main Kernel Routing Table\n" |
13933 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13934 | "Route map reference\n" |
13935 | "Pointer to route-map entries\n" | |
13936 | "Metric for redistributed routes\n" | |
13937 | "Default metric\n") | |
13938 | { | |
d62a17ae | 13939 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13940 | int idx_ospf_table = 1; | |
13941 | int idx_number = 2; | |
13942 | int idx_word = 4; | |
13943 | int idx_number_2 = 6; | |
d7c0a89a | 13944 | uint32_t metric; |
d62a17ae | 13945 | struct bgp_redist *red; |
d7c0a89a | 13946 | unsigned short instance; |
d62a17ae | 13947 | int protocol; |
e923dd62 | 13948 | bool changed; |
1de27621 DA |
13949 | struct route_map *route_map = |
13950 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13951 | |
13952 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13953 | protocol = ZEBRA_ROUTE_OSPF; | |
13954 | else | |
13955 | protocol = ZEBRA_ROUTE_TABLE; | |
13956 | ||
13957 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13958 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13959 | ||
13960 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13961 | changed = |
13962 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13963 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13964 | metric); | |
13965 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13966 | } |
13967 | ||
13968 | ALIAS_HIDDEN( | |
13969 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13970 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13971 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13972 | "Redistribute information from another routing protocol\n" | |
13973 | "Open Shortest Path First (OSPFv2)\n" | |
13974 | "Non-main Kernel Routing Table\n" | |
13975 | "Instance ID/Table ID\n" | |
13976 | "Route map reference\n" | |
13977 | "Pointer to route-map entries\n" | |
13978 | "Metric for redistributed routes\n" | |
13979 | "Default metric\n") | |
596c17ba | 13980 | |
7c8ff89e DS |
13981 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13982 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13983 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13984 | "Redistribute information from another routing protocol\n" |
13985 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13986 | "Non-main Kernel Routing Table\n" |
13987 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13988 | "Metric for redistributed routes\n" |
13989 | "Default metric\n" | |
13990 | "Route map reference\n" | |
13991 | "Pointer to route-map entries\n") | |
13992 | { | |
d62a17ae | 13993 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13994 | int idx_ospf_table = 1; | |
13995 | int idx_number = 2; | |
13996 | int idx_number_2 = 4; | |
13997 | int idx_word = 6; | |
d7c0a89a | 13998 | uint32_t metric; |
d62a17ae | 13999 | struct bgp_redist *red; |
d7c0a89a | 14000 | unsigned short instance; |
d62a17ae | 14001 | int protocol; |
e923dd62 | 14002 | bool changed; |
1de27621 DA |
14003 | struct route_map *route_map = |
14004 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14005 | |
14006 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14007 | protocol = ZEBRA_ROUTE_OSPF; | |
14008 | else | |
14009 | protocol = ZEBRA_ROUTE_TABLE; | |
14010 | ||
14011 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14012 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
14013 | ||
14014 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 14015 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
14016 | metric); | |
1de27621 DA |
14017 | changed |= |
14018 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14019 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 14020 | } |
14021 | ||
14022 | ALIAS_HIDDEN( | |
14023 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
14024 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
14025 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
14026 | "Redistribute information from another routing protocol\n" | |
14027 | "Open Shortest Path First (OSPFv2)\n" | |
14028 | "Non-main Kernel Routing Table\n" | |
14029 | "Instance ID/Table ID\n" | |
14030 | "Metric for redistributed routes\n" | |
14031 | "Default metric\n" | |
14032 | "Route map reference\n" | |
14033 | "Pointer to route-map entries\n") | |
596c17ba | 14034 | |
7c8ff89e DS |
14035 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
14036 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 14037 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
14038 | NO_STR |
14039 | "Redistribute information from another routing protocol\n" | |
14040 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 14041 | "Non-main Kernel Routing Table\n" |
31500417 DW |
14042 | "Instance ID/Table ID\n" |
14043 | "Metric for redistributed routes\n" | |
14044 | "Default metric\n" | |
14045 | "Route map reference\n" | |
14046 | "Pointer to route-map entries\n") | |
7c8ff89e | 14047 | { |
d62a17ae | 14048 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14049 | int idx_ospf_table = 2; | |
14050 | int idx_number = 3; | |
d7c0a89a | 14051 | unsigned short instance; |
d62a17ae | 14052 | int protocol; |
14053 | ||
14054 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
14055 | protocol = ZEBRA_ROUTE_OSPF; | |
14056 | else | |
14057 | protocol = ZEBRA_ROUTE_TABLE; | |
14058 | ||
14059 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
14060 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
14061 | } | |
14062 | ||
14063 | ALIAS_HIDDEN( | |
14064 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 14065 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14066 | NO_STR |
14067 | "Redistribute information from another routing protocol\n" | |
14068 | "Open Shortest Path First (OSPFv2)\n" | |
14069 | "Non-main Kernel Routing Table\n" | |
14070 | "Instance ID/Table ID\n" | |
14071 | "Metric for redistributed routes\n" | |
14072 | "Default metric\n" | |
14073 | "Route map reference\n" | |
14074 | "Pointer to route-map entries\n") | |
596c17ba | 14075 | |
718e3744 | 14076 | DEFUN (no_bgp_redistribute_ipv4, |
14077 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 14078 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14079 | NO_STR |
14080 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14081 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
14082 | "Metric for redistributed routes\n" |
14083 | "Default metric\n" | |
14084 | "Route map reference\n" | |
14085 | "Pointer to route-map entries\n") | |
718e3744 | 14086 | { |
d62a17ae | 14087 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14088 | int idx_protocol = 2; | |
14089 | int type; | |
14090 | ||
14091 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
14092 | if (type < 0) { | |
14093 | vty_out(vty, "%% Invalid route type\n"); | |
14094 | return CMD_WARNING_CONFIG_FAILED; | |
14095 | } | |
14096 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
14097 | } | |
14098 | ||
14099 | ALIAS_HIDDEN( | |
14100 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
14101 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 14102 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 14103 | NO_STR |
14104 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
14105 | "Metric for redistributed routes\n" | |
14106 | "Default metric\n" | |
14107 | "Route map reference\n" | |
14108 | "Pointer to route-map entries\n") | |
596c17ba | 14109 | |
718e3744 | 14110 | DEFUN (bgp_redistribute_ipv6, |
14111 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 14112 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 14113 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14114 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 14115 | { |
d62a17ae | 14116 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14117 | int idx_protocol = 1; | |
14118 | int type; | |
718e3744 | 14119 | |
d62a17ae | 14120 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14121 | if (type < 0) { | |
14122 | vty_out(vty, "%% Invalid route type\n"); | |
14123 | return CMD_WARNING_CONFIG_FAILED; | |
14124 | } | |
718e3744 | 14125 | |
d62a17ae | 14126 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14127 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 14128 | } |
14129 | ||
14130 | DEFUN (bgp_redistribute_ipv6_rmap, | |
14131 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 14132 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 14133 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14134 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14135 | "Route map reference\n" |
14136 | "Pointer to route-map entries\n") | |
14137 | { | |
d62a17ae | 14138 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14139 | int idx_protocol = 1; | |
14140 | int idx_word = 3; | |
14141 | int type; | |
14142 | struct bgp_redist *red; | |
e923dd62 | 14143 | bool changed; |
1de27621 DA |
14144 | struct route_map *route_map = |
14145 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 14146 | |
d62a17ae | 14147 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14148 | if (type < 0) { | |
14149 | vty_out(vty, "%% Invalid route type\n"); | |
14150 | return CMD_WARNING_CONFIG_FAILED; | |
14151 | } | |
718e3744 | 14152 | |
d62a17ae | 14153 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14154 | changed = |
14155 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14156 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14157 | } |
14158 | ||
14159 | DEFUN (bgp_redistribute_ipv6_metric, | |
14160 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 14161 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 14162 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14163 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14164 | "Metric for redistributed routes\n" |
14165 | "Default metric\n") | |
14166 | { | |
d62a17ae | 14167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14168 | int idx_protocol = 1; | |
14169 | int idx_number = 3; | |
14170 | int type; | |
d7c0a89a | 14171 | uint32_t metric; |
d62a17ae | 14172 | struct bgp_redist *red; |
e923dd62 | 14173 | bool changed; |
d62a17ae | 14174 | |
14175 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14176 | if (type < 0) { | |
14177 | vty_out(vty, "%% Invalid route type\n"); | |
14178 | return CMD_WARNING_CONFIG_FAILED; | |
14179 | } | |
14180 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14181 | |
d62a17ae | 14182 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14183 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
14184 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14185 | } |
14186 | ||
14187 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
14188 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 14189 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14190 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14191 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14192 | "Route map reference\n" |
14193 | "Pointer to route-map entries\n" | |
14194 | "Metric for redistributed routes\n" | |
14195 | "Default metric\n") | |
14196 | { | |
d62a17ae | 14197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14198 | int idx_protocol = 1; | |
14199 | int idx_word = 3; | |
14200 | int idx_number = 5; | |
14201 | int type; | |
d7c0a89a | 14202 | uint32_t metric; |
d62a17ae | 14203 | struct bgp_redist *red; |
e923dd62 | 14204 | bool changed; |
1de27621 DA |
14205 | struct route_map *route_map = |
14206 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14207 | |
14208 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14209 | if (type < 0) { | |
14210 | vty_out(vty, "%% Invalid route type\n"); | |
14211 | return CMD_WARNING_CONFIG_FAILED; | |
14212 | } | |
14213 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14214 | |
d62a17ae | 14215 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14216 | changed = |
14217 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14218 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14219 | metric); | |
14220 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14221 | } |
14222 | ||
14223 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14224 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14225 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14226 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14227 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14228 | "Metric for redistributed routes\n" |
14229 | "Default metric\n" | |
14230 | "Route map reference\n" | |
14231 | "Pointer to route-map entries\n") | |
14232 | { | |
d62a17ae | 14233 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14234 | int idx_protocol = 1; | |
14235 | int idx_number = 3; | |
14236 | int idx_word = 5; | |
14237 | int type; | |
d7c0a89a | 14238 | uint32_t metric; |
d62a17ae | 14239 | struct bgp_redist *red; |
e923dd62 | 14240 | bool changed; |
1de27621 DA |
14241 | struct route_map *route_map = |
14242 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14243 | |
14244 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14245 | if (type < 0) { | |
14246 | vty_out(vty, "%% Invalid route type\n"); | |
14247 | return CMD_WARNING_CONFIG_FAILED; | |
14248 | } | |
14249 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14250 | |
d62a17ae | 14251 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14252 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
14253 | metric); | |
1de27621 DA |
14254 | changed |= |
14255 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14256 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14257 | } |
14258 | ||
14259 | DEFUN (no_bgp_redistribute_ipv6, | |
14260 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14261 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14262 | NO_STR |
14263 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14264 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14265 | "Metric for redistributed routes\n" |
14266 | "Default metric\n" | |
14267 | "Route map reference\n" | |
14268 | "Pointer to route-map entries\n") | |
718e3744 | 14269 | { |
d62a17ae | 14270 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14271 | int idx_protocol = 2; | |
14272 | int type; | |
718e3744 | 14273 | |
d62a17ae | 14274 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14275 | if (type < 0) { | |
14276 | vty_out(vty, "%% Invalid route type\n"); | |
14277 | return CMD_WARNING_CONFIG_FAILED; | |
14278 | } | |
718e3744 | 14279 | |
d62a17ae | 14280 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14281 | } | |
14282 | ||
dd65f45e DL |
14283 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14284 | afi_t afi, safi_t safi) | |
d62a17ae | 14285 | { |
14286 | int i; | |
14287 | ||
14288 | /* Unicast redistribution only. */ | |
14289 | if (safi != SAFI_UNICAST) | |
2b791107 | 14290 | return; |
d62a17ae | 14291 | |
14292 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14293 | /* Redistribute BGP does not make sense. */ | |
14294 | if (i != ZEBRA_ROUTE_BGP) { | |
14295 | struct list *red_list; | |
14296 | struct listnode *node; | |
14297 | struct bgp_redist *red; | |
14298 | ||
14299 | red_list = bgp->redist[afi][i]; | |
14300 | if (!red_list) | |
14301 | continue; | |
14302 | ||
14303 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14304 | /* "redistribute" configuration. */ |
14305 | vty_out(vty, " redistribute %s", | |
14306 | zebra_route_string(i)); | |
14307 | if (red->instance) | |
14308 | vty_out(vty, " %d", red->instance); | |
14309 | if (red->redist_metric_flag) | |
14310 | vty_out(vty, " metric %u", | |
14311 | red->redist_metric); | |
14312 | if (red->rmap.name) | |
14313 | vty_out(vty, " route-map %s", | |
14314 | red->rmap.name); | |
14315 | vty_out(vty, "\n"); | |
14316 | } | |
14317 | } | |
14318 | } | |
718e3744 | 14319 | } |
6b0655a2 | 14320 | |
dd65f45e DL |
14321 | /* peer-group helpers for config-write */ |
14322 | ||
14323 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14324 | { | |
14325 | if (!peer_group_active(peer)) { | |
14326 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14327 | return !CHECK_FLAG(peer->flags, flag); | |
14328 | else | |
14329 | return !!CHECK_FLAG(peer->flags, flag); | |
14330 | } | |
14331 | ||
14332 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14333 | } | |
14334 | ||
14335 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14336 | uint32_t flag) | |
14337 | { | |
14338 | if (!peer_group_active(peer)) { | |
14339 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14340 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14341 | else | |
14342 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14343 | } | |
14344 | ||
14345 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14346 | } | |
14347 | ||
14348 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14349 | uint8_t type, int direct) | |
14350 | { | |
14351 | struct bgp_filter *filter; | |
14352 | ||
14353 | if (peer_group_active(peer)) | |
14354 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14355 | type); | |
14356 | ||
14357 | filter = &peer->filter[afi][safi]; | |
14358 | switch (type) { | |
14359 | case PEER_FT_DISTRIBUTE_LIST: | |
14360 | return !!(filter->dlist[direct].name); | |
14361 | case PEER_FT_FILTER_LIST: | |
14362 | return !!(filter->aslist[direct].name); | |
14363 | case PEER_FT_PREFIX_LIST: | |
14364 | return !!(filter->plist[direct].name); | |
14365 | case PEER_FT_ROUTE_MAP: | |
14366 | return !!(filter->map[direct].name); | |
14367 | case PEER_FT_UNSUPPRESS_MAP: | |
14368 | return !!(filter->usmap.name); | |
14369 | default: | |
14370 | return false; | |
14371 | } | |
14372 | } | |
14373 | ||
14374 | /* Return true if the addpath type is set for peer and different from | |
14375 | * peer-group. | |
14376 | */ | |
3dc339cd DA |
14377 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
14378 | safi_t safi) | |
dd65f45e DL |
14379 | { |
14380 | enum bgp_addpath_strat type, g_type; | |
14381 | ||
14382 | type = peer->addpath_type[afi][safi]; | |
14383 | ||
14384 | if (type != BGP_ADDPATH_NONE) { | |
14385 | if (peer_group_active(peer)) { | |
14386 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14387 | ||
14388 | if (type != g_type) | |
3dc339cd | 14389 | return true; |
dd65f45e | 14390 | else |
3dc339cd | 14391 | return false; |
dd65f45e DL |
14392 | } |
14393 | ||
3dc339cd | 14394 | return true; |
dd65f45e DL |
14395 | } |
14396 | ||
3dc339cd | 14397 | return false; |
dd65f45e DL |
14398 | } |
14399 | ||
b9c7bc5a | 14400 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14401 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14402 | afi_t afi) |
14403 | { | |
b9c7bc5a | 14404 | int indent = 2; |
ddb5b488 | 14405 | |
8a066a70 | 14406 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
14407 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14408 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
14409 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
14410 | bgp->vpn_policy[afi] | |
bb4f6190 | 14411 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14412 | else |
14413 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14414 | bgp->vpn_policy[afi] | |
14415 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14416 | } | |
12a844a5 DS |
14417 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14418 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14419 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14420 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14421 | return; | |
14422 | ||
e70e9f8e PZ |
14423 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14424 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14425 | ||
14426 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14427 | ||
14428 | } else { | |
14429 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14430 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14431 | bgp->vpn_policy[afi].tovpn_label); | |
14432 | } | |
ddb5b488 PZ |
14433 | } |
14434 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14435 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14436 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14437 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14438 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14439 | sizeof(buf))); | |
14440 | } | |
14441 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14442 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14443 | ||
14444 | char buf[PREFIX_STRLEN]; | |
14445 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14446 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14447 | sizeof(buf))) { | |
14448 | ||
b9c7bc5a PZ |
14449 | vty_out(vty, "%*snexthop vpn export %s\n", |
14450 | indent, "", buf); | |
ddb5b488 PZ |
14451 | } |
14452 | } | |
14453 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14454 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14455 | && ecommunity_cmp( | |
14456 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14457 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14458 | ||
14459 | char *b = ecommunity_ecom2str( | |
14460 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14461 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14462 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14463 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14464 | } else { | |
14465 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14466 | char *b = ecommunity_ecom2str( | |
14467 | bgp->vpn_policy[afi] | |
14468 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14469 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14470 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14471 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14472 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14473 | } | |
14474 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14475 | char *b = ecommunity_ecom2str( | |
14476 | bgp->vpn_policy[afi] | |
14477 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14478 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14479 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14480 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14481 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14482 | } | |
14483 | } | |
bb4f6190 DS |
14484 | |
14485 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14486 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14487 | bgp->vpn_policy[afi] |
14488 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14489 | |
301ad80a PG |
14490 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14491 | char *b = ecommunity_ecom2str( | |
14492 | bgp->vpn_policy[afi] | |
14493 | .import_redirect_rtlist, | |
14494 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14495 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14496 | |
301ad80a PG |
14497 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14498 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14499 | } | |
ddb5b488 PZ |
14500 | } |
14501 | ||
dd65f45e DL |
14502 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14503 | afi_t afi, safi_t safi) | |
14504 | { | |
14505 | struct bgp_filter *filter; | |
14506 | char *addr; | |
14507 | ||
14508 | addr = peer->host; | |
14509 | filter = &peer->filter[afi][safi]; | |
14510 | ||
14511 | /* distribute-list. */ | |
14512 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14513 | FILTER_IN)) | |
14514 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14515 | filter->dlist[FILTER_IN].name); | |
14516 | ||
14517 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14518 | FILTER_OUT)) | |
14519 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14520 | filter->dlist[FILTER_OUT].name); | |
14521 | ||
14522 | /* prefix-list. */ | |
14523 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14524 | FILTER_IN)) | |
14525 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14526 | filter->plist[FILTER_IN].name); | |
14527 | ||
14528 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14529 | FILTER_OUT)) | |
14530 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14531 | filter->plist[FILTER_OUT].name); | |
14532 | ||
14533 | /* route-map. */ | |
14534 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14535 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14536 | filter->map[RMAP_IN].name); | |
14537 | ||
14538 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14539 | RMAP_OUT)) | |
14540 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14541 | filter->map[RMAP_OUT].name); | |
14542 | ||
14543 | /* unsuppress-map */ | |
14544 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14545 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14546 | filter->usmap.name); | |
14547 | ||
14548 | /* filter-list. */ | |
14549 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14550 | FILTER_IN)) | |
14551 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14552 | filter->aslist[FILTER_IN].name); | |
14553 | ||
14554 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14555 | FILTER_OUT)) | |
14556 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14557 | filter->aslist[FILTER_OUT].name); | |
14558 | } | |
14559 | ||
14560 | /* BGP peer configuration display function. */ | |
14561 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14562 | struct peer *peer) | |
14563 | { | |
14564 | struct peer *g_peer = NULL; | |
14565 | char buf[SU_ADDRSTRLEN]; | |
14566 | char *addr; | |
14567 | int if_pg_printed = false; | |
14568 | int if_ras_printed = false; | |
14569 | ||
14570 | /* Skip dynamic neighbors. */ | |
14571 | if (peer_dynamic_neighbor(peer)) | |
14572 | return; | |
14573 | ||
14574 | if (peer->conf_if) | |
14575 | addr = peer->conf_if; | |
14576 | else | |
14577 | addr = peer->host; | |
14578 | ||
14579 | /************************************ | |
14580 | ****** Global to the neighbor ****** | |
14581 | ************************************/ | |
14582 | if (peer->conf_if) { | |
14583 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14584 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14585 | else | |
14586 | vty_out(vty, " neighbor %s interface", addr); | |
14587 | ||
14588 | if (peer_group_active(peer)) { | |
14589 | vty_out(vty, " peer-group %s", peer->group->name); | |
14590 | if_pg_printed = true; | |
14591 | } else if (peer->as_type == AS_SPECIFIED) { | |
14592 | vty_out(vty, " remote-as %u", peer->as); | |
14593 | if_ras_printed = true; | |
14594 | } else if (peer->as_type == AS_INTERNAL) { | |
14595 | vty_out(vty, " remote-as internal"); | |
14596 | if_ras_printed = true; | |
14597 | } else if (peer->as_type == AS_EXTERNAL) { | |
14598 | vty_out(vty, " remote-as external"); | |
14599 | if_ras_printed = true; | |
14600 | } | |
14601 | ||
14602 | vty_out(vty, "\n"); | |
14603 | } | |
14604 | ||
14605 | /* remote-as and peer-group */ | |
14606 | /* peer is a member of a peer-group */ | |
14607 | if (peer_group_active(peer)) { | |
14608 | g_peer = peer->group->conf; | |
14609 | ||
14610 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14611 | if (peer->as_type == AS_SPECIFIED) { | |
14612 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14613 | addr, peer->as); | |
14614 | } else if (peer->as_type == AS_INTERNAL) { | |
14615 | vty_out(vty, | |
14616 | " neighbor %s remote-as internal\n", | |
14617 | addr); | |
14618 | } else if (peer->as_type == AS_EXTERNAL) { | |
14619 | vty_out(vty, | |
14620 | " neighbor %s remote-as external\n", | |
14621 | addr); | |
14622 | } | |
14623 | } | |
14624 | ||
14625 | /* For swpX peers we displayed the peer-group | |
14626 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14627 | if (!if_pg_printed) | |
14628 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14629 | peer->group->name); | |
14630 | } | |
14631 | ||
14632 | /* peer is NOT a member of a peer-group */ | |
14633 | else { | |
14634 | /* peer is a peer-group, declare the peer-group */ | |
14635 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14636 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14637 | } | |
14638 | ||
14639 | if (!if_ras_printed) { | |
14640 | if (peer->as_type == AS_SPECIFIED) { | |
14641 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14642 | addr, peer->as); | |
14643 | } else if (peer->as_type == AS_INTERNAL) { | |
14644 | vty_out(vty, | |
14645 | " neighbor %s remote-as internal\n", | |
14646 | addr); | |
14647 | } else if (peer->as_type == AS_EXTERNAL) { | |
14648 | vty_out(vty, | |
14649 | " neighbor %s remote-as external\n", | |
14650 | addr); | |
14651 | } | |
14652 | } | |
14653 | } | |
14654 | ||
14655 | /* local-as */ | |
14656 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14657 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14658 | peer->change_local_as); | |
14659 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14660 | vty_out(vty, " no-prepend"); | |
14661 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14662 | vty_out(vty, " replace-as"); | |
14663 | vty_out(vty, "\n"); | |
14664 | } | |
14665 | ||
14666 | /* description */ | |
14667 | if (peer->desc) { | |
14668 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14669 | } | |
14670 | ||
14671 | /* shutdown */ | |
14672 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14673 | if (peer->tx_shutdown_message) | |
14674 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14675 | peer->tx_shutdown_message); | |
14676 | else | |
14677 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14678 | } | |
14679 | ||
14680 | /* bfd */ | |
14681 | if (peer->bfd_info) { | |
14682 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14683 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14684 | } | |
14685 | } | |
14686 | ||
14687 | /* password */ | |
14688 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14689 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14690 | peer->password); | |
14691 | ||
14692 | /* neighbor solo */ | |
14693 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14694 | if (!peer_group_active(peer)) { | |
14695 | vty_out(vty, " neighbor %s solo\n", addr); | |
14696 | } | |
14697 | } | |
14698 | ||
14699 | /* BGP port */ | |
14700 | if (peer->port != BGP_PORT_DEFAULT) { | |
14701 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14702 | } | |
14703 | ||
14704 | /* Local interface name */ | |
14705 | if (peer->ifname) { | |
14706 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14707 | } | |
14708 | ||
14709 | /* passive */ | |
14710 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14711 | vty_out(vty, " neighbor %s passive\n", addr); | |
14712 | ||
14713 | /* ebgp-multihop */ | |
14714 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
14715 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
14716 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
14717 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
14718 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14719 | peer->ttl); | |
14720 | } | |
14721 | } | |
14722 | ||
14723 | /* ttl-security hops */ | |
e2521429 | 14724 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
14725 | if (!peer_group_active(peer) |
14726 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14727 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14728 | addr, peer->gtsm_hops); | |
14729 | } | |
14730 | } | |
14731 | ||
14732 | /* disable-connected-check */ | |
14733 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14734 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14735 | ||
14736 | /* enforce-first-as */ | |
14737 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14738 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14739 | ||
14740 | /* update-source */ | |
14741 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14742 | if (peer->update_source) | |
14743 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14744 | sockunion2str(peer->update_source, buf, | |
14745 | SU_ADDRSTRLEN)); | |
14746 | else if (peer->update_if) | |
14747 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14748 | peer->update_if); | |
14749 | } | |
14750 | ||
14751 | /* advertisement-interval */ | |
14752 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14753 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14754 | peer->routeadv); | |
14755 | ||
14756 | /* timers */ | |
14757 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14758 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14759 | peer->keepalive, peer->holdtime); | |
14760 | ||
14761 | /* timers connect */ | |
14762 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14763 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14764 | peer->connect); | |
5d5393b9 DL |
14765 | /* need special-case handling for changed default values due to |
14766 | * config profile / version (because there is no "timers bgp connect" | |
14767 | * command, we need to save this per-peer :/) | |
14768 | */ | |
14769 | else if (!peer_group_active(peer) && !peer->connect && | |
14770 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14771 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14772 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14773 | |
14774 | /* capability dynamic */ | |
14775 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14776 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14777 | ||
14778 | /* capability extended-nexthop */ | |
14779 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14780 | if (!peer->conf_if) { | |
14781 | if (CHECK_FLAG(peer->flags_invert, | |
14782 | PEER_FLAG_CAPABILITY_ENHE)) | |
14783 | vty_out(vty, | |
14784 | " no neighbor %s capability extended-nexthop\n", | |
14785 | addr); | |
14786 | else | |
14787 | vty_out(vty, | |
14788 | " neighbor %s capability extended-nexthop\n", | |
14789 | addr); | |
14790 | } | |
14791 | } | |
14792 | ||
14793 | /* dont-capability-negotiation */ | |
14794 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14795 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14796 | ||
14797 | /* override-capability */ | |
14798 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14799 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14800 | ||
14801 | /* strict-capability-match */ | |
14802 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14803 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14804 | ||
14805 | /* Sender side AS path loop detection. */ | |
14806 | if (peer->as_path_loop_detection) | |
14807 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14808 | addr); | |
cfd47646 | 14809 | |
14810 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14811 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14812 | |
14813 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14814 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14815 | vty_out(vty, |
14816 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14817 | } else if (CHECK_FLAG( |
14818 | peer->peer_gr_new_status_flag, | |
14819 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14820 | vty_out(vty, |
14821 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14822 | } else if ( |
14823 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14824 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14825 | && !(CHECK_FLAG( | |
14826 | peer->peer_gr_new_status_flag, | |
14827 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14828 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14829 | addr); | |
cfd47646 | 14830 | } |
14831 | } | |
dd65f45e DL |
14832 | } |
14833 | ||
14834 | /* BGP peer configuration display function. */ | |
14835 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14836 | struct peer *peer, afi_t afi, safi_t safi) | |
14837 | { | |
14838 | struct peer *g_peer = NULL; | |
14839 | char *addr; | |
14840 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14841 | ||
14842 | /* Skip dynamic neighbors. */ | |
14843 | if (peer_dynamic_neighbor(peer)) | |
14844 | return; | |
14845 | ||
14846 | if (peer->conf_if) | |
14847 | addr = peer->conf_if; | |
14848 | else | |
14849 | addr = peer->host; | |
14850 | ||
14851 | /************************************ | |
14852 | ****** Per AF to the neighbor ****** | |
14853 | ************************************/ | |
14854 | if (peer_group_active(peer)) { | |
14855 | g_peer = peer->group->conf; | |
14856 | ||
14857 | /* If the peer-group is active but peer is not, print a 'no | |
14858 | * activate' */ | |
14859 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14860 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14861 | } | |
14862 | ||
14863 | /* If the peer-group is not active but peer is, print an | |
14864 | 'activate' */ | |
14865 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14866 | vty_out(vty, " neighbor %s activate\n", addr); | |
14867 | } | |
14868 | } else { | |
14869 | if (peer->afc[afi][safi]) { | |
14870 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14871 | if (CHECK_FLAG(bgp->flags, |
14872 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14873 | vty_out(vty, " neighbor %s activate\n", |
14874 | addr); | |
14875 | } | |
14876 | } else | |
14877 | vty_out(vty, " neighbor %s activate\n", addr); | |
14878 | } else { | |
14879 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14880 | if (!CHECK_FLAG(bgp->flags, |
14881 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14882 | vty_out(vty, |
14883 | " no neighbor %s activate\n", | |
14884 | addr); | |
14885 | } | |
14886 | } | |
14887 | } | |
14888 | } | |
14889 | ||
14890 | /* addpath TX knobs */ | |
14891 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14892 | switch (peer->addpath_type[afi][safi]) { | |
14893 | case BGP_ADDPATH_ALL: | |
14894 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14895 | addr); | |
14896 | break; | |
14897 | case BGP_ADDPATH_BEST_PER_AS: | |
14898 | vty_out(vty, | |
14899 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14900 | addr); | |
14901 | break; | |
14902 | case BGP_ADDPATH_MAX: | |
14903 | case BGP_ADDPATH_NONE: | |
14904 | break; | |
14905 | } | |
14906 | } | |
14907 | ||
14908 | /* ORF capability. */ | |
14909 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14910 | || peergroup_af_flag_check(peer, afi, safi, | |
14911 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14912 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14913 | ||
14914 | if (peergroup_af_flag_check(peer, afi, safi, | |
14915 | PEER_FLAG_ORF_PREFIX_SM) | |
14916 | && peergroup_af_flag_check(peer, afi, safi, | |
14917 | PEER_FLAG_ORF_PREFIX_RM)) | |
14918 | vty_out(vty, " both"); | |
14919 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14920 | PEER_FLAG_ORF_PREFIX_SM)) | |
14921 | vty_out(vty, " send"); | |
14922 | else | |
14923 | vty_out(vty, " receive"); | |
14924 | vty_out(vty, "\n"); | |
14925 | } | |
14926 | ||
dd65f45e DL |
14927 | /* Route reflector client. */ |
14928 | if (peergroup_af_flag_check(peer, afi, safi, | |
14929 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14930 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14931 | } | |
14932 | ||
14933 | /* next-hop-self force */ | |
14934 | if (peergroup_af_flag_check(peer, afi, safi, | |
14935 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14936 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14937 | } | |
14938 | ||
14939 | /* next-hop-self */ | |
14940 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14941 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14942 | } | |
14943 | ||
14944 | /* remove-private-AS */ | |
14945 | if (peergroup_af_flag_check(peer, afi, safi, | |
14946 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14947 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14948 | addr); | |
14949 | } | |
14950 | ||
14951 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14952 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14953 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14954 | addr); | |
14955 | } | |
14956 | ||
14957 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14958 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14959 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14960 | } | |
14961 | ||
14962 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14963 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14964 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14965 | } | |
14966 | ||
14967 | /* as-override */ | |
14968 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14969 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14970 | } | |
14971 | ||
14972 | /* send-community print. */ | |
14973 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14974 | PEER_FLAG_SEND_COMMUNITY); | |
14975 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14976 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14977 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14978 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14979 | ||
14980 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14981 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14982 | } else { | |
14983 | if (flag_scomm) | |
14984 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14985 | if (flag_secomm) | |
14986 | vty_out(vty, | |
14987 | " no neighbor %s send-community extended\n", | |
14988 | addr); | |
14989 | ||
14990 | if (flag_slcomm) | |
14991 | vty_out(vty, " no neighbor %s send-community large\n", | |
14992 | addr); | |
14993 | } | |
14994 | ||
14995 | /* Default information */ | |
14996 | if (peergroup_af_flag_check(peer, afi, safi, | |
14997 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14998 | vty_out(vty, " neighbor %s default-originate", addr); | |
14999 | ||
15000 | if (peer->default_rmap[afi][safi].name) | |
15001 | vty_out(vty, " route-map %s", | |
15002 | peer->default_rmap[afi][safi].name); | |
15003 | ||
15004 | vty_out(vty, "\n"); | |
15005 | } | |
15006 | ||
15007 | /* Soft reconfiguration inbound. */ | |
15008 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
15009 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
15010 | addr); | |
15011 | } | |
15012 | ||
15013 | /* maximum-prefix. */ | |
15014 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
15015 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
15016 | peer->pmax[afi][safi]); | |
15017 | ||
15018 | if (peer->pmax_threshold[afi][safi] | |
15019 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
15020 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
15021 | if (peer_af_flag_check(peer, afi, safi, | |
15022 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
15023 | vty_out(vty, " warning-only"); | |
15024 | if (peer->pmax_restart[afi][safi]) | |
15025 | vty_out(vty, " restart %u", | |
15026 | peer->pmax_restart[afi][safi]); | |
15027 | ||
15028 | vty_out(vty, "\n"); | |
15029 | } | |
15030 | ||
fde246e8 DA |
15031 | /* maximum-prefix-out */ |
15032 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
15033 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
15034 | addr, peer->pmax_out[afi][safi]); | |
15035 | ||
dd65f45e DL |
15036 | /* Route server client. */ |
15037 | if (peergroup_af_flag_check(peer, afi, safi, | |
15038 | PEER_FLAG_RSERVER_CLIENT)) { | |
15039 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
15040 | } | |
15041 | ||
15042 | /* Nexthop-local unchanged. */ | |
15043 | if (peergroup_af_flag_check(peer, afi, safi, | |
15044 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
15045 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
15046 | } | |
15047 | ||
15048 | /* allowas-in <1-10> */ | |
15049 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
15050 | if (peer_af_flag_check(peer, afi, safi, | |
15051 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
15052 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
15053 | } else if (peer->allowas_in[afi][safi] == 3) { | |
15054 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
15055 | } else { | |
15056 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
15057 | peer->allowas_in[afi][safi]); | |
15058 | } | |
15059 | } | |
15060 | ||
15061 | /* weight */ | |
15062 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
15063 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
15064 | peer->weight[afi][safi]); | |
15065 | ||
15066 | /* Filter. */ | |
15067 | bgp_config_write_filter(vty, peer, afi, safi); | |
15068 | ||
15069 | /* atribute-unchanged. */ | |
15070 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
15071 | || (safi != SAFI_EVPN | |
15072 | && peer_af_flag_check(peer, afi, safi, | |
15073 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
15074 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
15075 | ||
15076 | if (!peer_group_active(peer) | |
15077 | || peergroup_af_flag_check(peer, afi, safi, | |
15078 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15079 | || peergroup_af_flag_check(peer, afi, safi, | |
15080 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15081 | || peergroup_af_flag_check(peer, afi, safi, | |
15082 | PEER_FLAG_MED_UNCHANGED)) { | |
15083 | ||
15084 | vty_out(vty, | |
15085 | " neighbor %s attribute-unchanged%s%s%s\n", | |
15086 | addr, | |
15087 | peer_af_flag_check(peer, afi, safi, | |
15088 | PEER_FLAG_AS_PATH_UNCHANGED) | |
15089 | ? " as-path" | |
15090 | : "", | |
15091 | peer_af_flag_check(peer, afi, safi, | |
15092 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
15093 | ? " next-hop" | |
15094 | : "", | |
15095 | peer_af_flag_check(peer, afi, safi, | |
15096 | PEER_FLAG_MED_UNCHANGED) | |
15097 | ? " med" | |
15098 | : ""); | |
15099 | } | |
15100 | } | |
15101 | } | |
15102 | ||
15103 | /* Address family based peer configuration display. */ | |
15104 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
15105 | safi_t safi) | |
15106 | { | |
15107 | struct peer *peer; | |
15108 | struct peer_group *group; | |
15109 | struct listnode *node, *nnode; | |
15110 | ||
15111 | ||
15112 | vty_frame(vty, " !\n address-family "); | |
15113 | if (afi == AFI_IP) { | |
15114 | if (safi == SAFI_UNICAST) | |
15115 | vty_frame(vty, "ipv4 unicast"); | |
15116 | else if (safi == SAFI_LABELED_UNICAST) | |
15117 | vty_frame(vty, "ipv4 labeled-unicast"); | |
15118 | else if (safi == SAFI_MULTICAST) | |
15119 | vty_frame(vty, "ipv4 multicast"); | |
15120 | else if (safi == SAFI_MPLS_VPN) | |
15121 | vty_frame(vty, "ipv4 vpn"); | |
15122 | else if (safi == SAFI_ENCAP) | |
15123 | vty_frame(vty, "ipv4 encap"); | |
15124 | else if (safi == SAFI_FLOWSPEC) | |
15125 | vty_frame(vty, "ipv4 flowspec"); | |
15126 | } else if (afi == AFI_IP6) { | |
15127 | if (safi == SAFI_UNICAST) | |
15128 | vty_frame(vty, "ipv6 unicast"); | |
15129 | else if (safi == SAFI_LABELED_UNICAST) | |
15130 | vty_frame(vty, "ipv6 labeled-unicast"); | |
15131 | else if (safi == SAFI_MULTICAST) | |
15132 | vty_frame(vty, "ipv6 multicast"); | |
15133 | else if (safi == SAFI_MPLS_VPN) | |
15134 | vty_frame(vty, "ipv6 vpn"); | |
15135 | else if (safi == SAFI_ENCAP) | |
15136 | vty_frame(vty, "ipv6 encap"); | |
15137 | else if (safi == SAFI_FLOWSPEC) | |
15138 | vty_frame(vty, "ipv6 flowspec"); | |
15139 | } else if (afi == AFI_L2VPN) { | |
15140 | if (safi == SAFI_EVPN) | |
15141 | vty_frame(vty, "l2vpn evpn"); | |
15142 | } | |
15143 | vty_frame(vty, "\n"); | |
15144 | ||
15145 | bgp_config_write_distance(vty, bgp, afi, safi); | |
15146 | ||
15147 | bgp_config_write_network(vty, bgp, afi, safi); | |
15148 | ||
15149 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
15150 | ||
8a4e7fe6 DA |
15151 | /* BGP flag dampening. */ |
15152 | if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
15153 | bgp_config_write_damp(vty, afi, safi); | |
15154 | ||
dd65f45e DL |
15155 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) |
15156 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
15157 | ||
15158 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15159 | /* Skip dynamic neighbors. */ | |
15160 | if (peer_dynamic_neighbor(peer)) | |
15161 | continue; | |
15162 | ||
15163 | /* Do not display doppelganger peers */ | |
15164 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15165 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
15166 | } | |
15167 | ||
15168 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
15169 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
15170 | ||
15171 | if (safi == SAFI_EVPN) | |
15172 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
15173 | ||
15174 | if (safi == SAFI_FLOWSPEC) | |
15175 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
15176 | ||
15177 | if (safi == SAFI_UNICAST) { | |
15178 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
15179 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15180 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
15181 | ||
15182 | vty_out(vty, " export vpn\n"); | |
15183 | } | |
15184 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15185 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
15186 | ||
15187 | vty_out(vty, " import vpn\n"); | |
15188 | } | |
15189 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15190 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15191 | char *name; | |
15192 | ||
15193 | for (ALL_LIST_ELEMENTS_RO( | |
15194 | bgp->vpn_policy[afi].import_vrf, node, | |
15195 | name)) | |
15196 | vty_out(vty, " import vrf %s\n", name); | |
15197 | } | |
15198 | } | |
15199 | ||
15200 | vty_endframe(vty, " exit-address-family\n"); | |
15201 | } | |
15202 | ||
15203 | int bgp_config_write(struct vty *vty) | |
15204 | { | |
15205 | struct bgp *bgp; | |
15206 | struct peer_group *group; | |
15207 | struct peer *peer; | |
15208 | struct listnode *node, *nnode; | |
15209 | struct listnode *mnode, *mnnode; | |
15210 | ||
15211 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
15212 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
15213 | bm->rmap_update_timer); | |
15214 | ||
15215 | /* BGP configuration. */ | |
15216 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
15217 | ||
15218 | /* skip all auto created vrf as they dont have user config */ | |
15219 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
15220 | continue; | |
15221 | ||
15222 | /* Router bgp ASN */ | |
15223 | vty_out(vty, "router bgp %u", bgp->as); | |
15224 | ||
15225 | if (bgp->name) | |
15226 | vty_out(vty, " %s %s", | |
15227 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
15228 | ? "view" : "vrf", bgp->name); | |
15229 | vty_out(vty, "\n"); | |
15230 | ||
15231 | /* BGP fast-external-failover. */ | |
15232 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
15233 | vty_out(vty, " no bgp fast-external-failover\n"); | |
15234 | ||
15235 | /* BGP router ID. */ | |
15236 | if (bgp->router_id_static.s_addr != 0) | |
15237 | vty_out(vty, " bgp router-id %s\n", | |
15238 | inet_ntoa(bgp->router_id_static)); | |
15239 | ||
15240 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 15241 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 15242 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 15243 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
15244 | CHECK_FLAG(bgp->flags, |
15245 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
15246 | ? "" |
15247 | : "no "); | |
15248 | ||
15249 | /* BGP configuration. */ | |
892fedb6 | 15250 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
15251 | vty_out(vty, " bgp always-compare-med\n"); |
15252 | ||
15253 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
15254 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
15255 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
15256 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
15257 | CHECK_FLAG(bgp->flags, | |
15258 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
15259 | ? "" | |
15260 | : "no "); | |
dd65f45e DL |
15261 | |
15262 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 15263 | if (bgp->reject_as_sets) |
dd65f45e DL |
15264 | vty_out(vty, " bgp reject-as-sets\n"); |
15265 | ||
15266 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 15267 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
15268 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
15269 | ||
15270 | /* BGP default local-preference. */ | |
15271 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15272 | vty_out(vty, " bgp default local-preference %u\n", | |
15273 | bgp->default_local_pref); | |
15274 | ||
15275 | /* BGP default show-hostname */ | |
892fedb6 | 15276 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 15277 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 15278 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 15279 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
15280 | ? "" |
15281 | : "no "); | |
15282 | ||
15283 | /* BGP default subgroup-pkt-queue-max. */ | |
15284 | if (bgp->default_subgroup_pkt_queue_max | |
15285 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15286 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15287 | bgp->default_subgroup_pkt_queue_max); | |
15288 | ||
15289 | /* BGP client-to-client reflection. */ | |
892fedb6 | 15290 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
15291 | vty_out(vty, " no bgp client-to-client reflection\n"); |
15292 | ||
15293 | /* BGP cluster ID. */ | |
15294 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15295 | vty_out(vty, " bgp cluster-id %s\n", | |
15296 | inet_ntoa(bgp->cluster_id)); | |
15297 | ||
15298 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 15299 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
15300 | vty_out(vty, |
15301 | " bgp disable-ebgp-connected-route-check\n"); | |
15302 | ||
15303 | /* Confederation identifier*/ | |
15304 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15305 | vty_out(vty, " bgp confederation identifier %u\n", | |
15306 | bgp->confed_id); | |
15307 | ||
15308 | /* Confederation peer */ | |
15309 | if (bgp->confed_peers_cnt > 0) { | |
15310 | int i; | |
15311 | ||
15312 | vty_out(vty, " bgp confederation peers"); | |
15313 | ||
15314 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15315 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15316 | ||
15317 | vty_out(vty, "\n"); | |
15318 | } | |
15319 | ||
15320 | /* BGP deterministic-med. */ | |
892fedb6 | 15321 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 15322 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 15323 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
15324 | CHECK_FLAG(bgp->flags, |
15325 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
15326 | ? "" |
15327 | : "no "); | |
15328 | ||
15329 | /* BGP update-delay. */ | |
15330 | bgp_config_write_update_delay(vty, bgp); | |
15331 | ||
15332 | if (bgp->v_maxmed_onstartup | |
15333 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15334 | vty_out(vty, " bgp max-med on-startup %u", | |
15335 | bgp->v_maxmed_onstartup); | |
15336 | if (bgp->maxmed_onstartup_value | |
15337 | != BGP_MAXMED_VALUE_DEFAULT) | |
15338 | vty_out(vty, " %u", | |
15339 | bgp->maxmed_onstartup_value); | |
15340 | vty_out(vty, "\n"); | |
15341 | } | |
15342 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15343 | vty_out(vty, " bgp max-med administrative"); | |
15344 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15345 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15346 | vty_out(vty, "\n"); | |
15347 | } | |
15348 | ||
15349 | /* write quanta */ | |
15350 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15351 | /* read quanta */ | |
15352 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15353 | ||
15354 | /* coalesce time */ | |
15355 | bgp_config_write_coalesce_time(vty, bgp); | |
15356 | ||
15357 | /* BGP graceful-restart. */ | |
15358 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15359 | vty_out(vty, | |
15360 | " bgp graceful-restart stalepath-time %u\n", | |
15361 | bgp->stalepath_time); | |
cfd47646 | 15362 | |
dd65f45e DL |
15363 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15364 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15365 | bgp->restart_time); | |
cfd47646 | 15366 | |
15367 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15368 | vty_out(vty, | |
15369 | " bgp graceful-restart select-defer-time %u\n", | |
15370 | bgp->select_defer_time); | |
15371 | ||
15372 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15373 | vty_out(vty, " bgp graceful-restart\n"); |
15374 | ||
cfd47646 | 15375 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15376 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15377 | ||
dd65f45e | 15378 | /* BGP graceful-shutdown */ |
892fedb6 | 15379 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) |
dd65f45e DL |
15380 | vty_out(vty, " bgp graceful-shutdown\n"); |
15381 | ||
15382 | /* BGP graceful-restart Preserve State F bit. */ | |
892fedb6 | 15383 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
15384 | vty_out(vty, |
15385 | " bgp graceful-restart preserve-fw-state\n"); | |
15386 | ||
dc95985f | 15387 | /* Stale timer for RIB */ |
15388 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15389 | vty_out(vty, | |
15390 | " bgp graceful-restart rib-stale-time %u\n", | |
15391 | bgp->rib_stale_time); | |
15392 | ||
dd65f45e | 15393 | /* BGP bestpath method. */ |
892fedb6 | 15394 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 15395 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 15396 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
15397 | vty_out(vty, " bgp bestpath as-path confed\n"); |
15398 | ||
892fedb6 DA |
15399 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
15400 | if (CHECK_FLAG(bgp->flags, | |
15401 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
15402 | vty_out(vty, |
15403 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15404 | } else { | |
15405 | vty_out(vty, | |
15406 | " bgp bestpath as-path multipath-relax\n"); | |
15407 | } | |
15408 | } | |
15409 | ||
892fedb6 | 15410 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
15411 | vty_out(vty, |
15412 | " bgp route-reflector allow-outbound-policy\n"); | |
15413 | } | |
892fedb6 | 15414 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 15415 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
15416 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
15417 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 15418 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 15419 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 15420 | vty_out(vty, " confed"); |
892fedb6 DA |
15421 | if (CHECK_FLAG(bgp->flags, |
15422 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
15423 | vty_out(vty, " missing-as-worst"); |
15424 | vty_out(vty, "\n"); | |
15425 | } | |
15426 | ||
f7e1c681 | 15427 | /* Link bandwidth handling. */ |
15428 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
15429 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
15430 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
15431 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
15432 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
15433 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
15434 | ||
dd65f45e | 15435 | /* BGP network import check. */ |
892fedb6 | 15436 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 15437 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 15438 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 15439 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
15440 | ? "" |
15441 | : "no "); | |
15442 | ||
15443 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15444 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15445 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15446 | vty_out(vty, " timers bgp %u %u\n", |
15447 | bgp->default_keepalive, bgp->default_holdtime); | |
15448 | ||
15449 | /* peer-group */ | |
15450 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15451 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15452 | } | |
15453 | ||
15454 | /* Normal neighbor configuration. */ | |
15455 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15456 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15457 | bgp_config_write_peer_global(vty, bgp, peer); | |
15458 | } | |
15459 | ||
15460 | /* listen range and limit for dynamic BGP neighbors */ | |
15461 | bgp_config_write_listen(vty, bgp); | |
15462 | ||
15463 | /* | |
15464 | * BGP default autoshutdown neighbors | |
15465 | * | |
15466 | * This must be placed after any peer and peer-group | |
15467 | * configuration, to avoid setting all peers to shutdown after | |
15468 | * a daemon restart, which is undesired behavior. (see #2286) | |
15469 | */ | |
15470 | if (bgp->autoshutdown) | |
15471 | vty_out(vty, " bgp default shutdown\n"); | |
15472 | ||
15473 | /* IPv4 unicast configuration. */ | |
15474 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15475 | ||
15476 | /* IPv4 multicast configuration. */ | |
15477 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15478 | ||
15479 | /* IPv4 labeled-unicast configuration. */ | |
15480 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15481 | ||
15482 | /* IPv4 VPN configuration. */ | |
15483 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15484 | ||
15485 | /* ENCAPv4 configuration. */ | |
15486 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15487 | ||
15488 | /* FLOWSPEC v4 configuration. */ | |
15489 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15490 | ||
15491 | /* IPv6 unicast configuration. */ | |
15492 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15493 | ||
15494 | /* IPv6 multicast configuration. */ | |
15495 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15496 | ||
15497 | /* IPv6 labeled-unicast configuration. */ | |
15498 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15499 | SAFI_LABELED_UNICAST); | |
15500 | ||
15501 | /* IPv6 VPN configuration. */ | |
15502 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15503 | ||
15504 | /* ENCAPv6 configuration. */ | |
15505 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15506 | ||
15507 | /* FLOWSPEC v6 configuration. */ | |
15508 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15509 | ||
15510 | /* EVPN configuration. */ | |
15511 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15512 | ||
15513 | hook_call(bgp_inst_config_write, bgp, vty); | |
15514 | ||
49e5a4a0 | 15515 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
15516 | bgp_rfapi_cfg_write(vty, bgp); |
15517 | #endif | |
15518 | ||
15519 | vty_out(vty, "!\n"); | |
15520 | } | |
15521 | return 0; | |
15522 | } | |
15523 | ||
ddb5b488 | 15524 | |
718e3744 | 15525 | /* BGP node structure. */ |
d62a17ae | 15526 | static struct cmd_node bgp_node = { |
f4b8291f | 15527 | .name = "bgp", |
62b346ee | 15528 | .node = BGP_NODE, |
24389580 | 15529 | .parent_node = CONFIG_NODE, |
62b346ee | 15530 | .prompt = "%s(config-router)# ", |
612c2c15 | 15531 | .config_write = bgp_config_write, |
718e3744 | 15532 | }; |
15533 | ||
d62a17ae | 15534 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 15535 | .name = "bgp ipv4 unicast", |
62b346ee | 15536 | .node = BGP_IPV4_NODE, |
24389580 | 15537 | .parent_node = BGP_NODE, |
62b346ee | 15538 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15539 | }; |
15540 | ||
d62a17ae | 15541 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 15542 | .name = "bgp ipv4 multicast", |
62b346ee | 15543 | .node = BGP_IPV4M_NODE, |
24389580 | 15544 | .parent_node = BGP_NODE, |
62b346ee | 15545 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15546 | }; |
15547 | ||
d62a17ae | 15548 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 15549 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 15550 | .node = BGP_IPV4L_NODE, |
24389580 | 15551 | .parent_node = BGP_NODE, |
62b346ee | 15552 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15553 | }; |
15554 | ||
d62a17ae | 15555 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 15556 | .name = "bgp ipv6", |
62b346ee | 15557 | .node = BGP_IPV6_NODE, |
24389580 | 15558 | .parent_node = BGP_NODE, |
62b346ee | 15559 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15560 | }; |
15561 | ||
d62a17ae | 15562 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 15563 | .name = "bgp ipv6 multicast", |
62b346ee | 15564 | .node = BGP_IPV6M_NODE, |
24389580 | 15565 | .parent_node = BGP_NODE, |
62b346ee | 15566 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 15567 | }; |
15568 | ||
d62a17ae | 15569 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 15570 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 15571 | .node = BGP_IPV6L_NODE, |
24389580 | 15572 | .parent_node = BGP_NODE, |
62b346ee | 15573 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15574 | }; |
15575 | ||
62b346ee | 15576 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 15577 | .name = "bgp vpnv4", |
62b346ee | 15578 | .node = BGP_VPNV4_NODE, |
24389580 | 15579 | .parent_node = BGP_NODE, |
62b346ee | 15580 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15581 | }; |
6b0655a2 | 15582 | |
62b346ee | 15583 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 15584 | .name = "bgp vpnv6", |
62b346ee | 15585 | .node = BGP_VPNV6_NODE, |
24389580 | 15586 | .parent_node = BGP_NODE, |
62b346ee | 15587 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15588 | }; |
8ecd3266 | 15589 | |
62b346ee | 15590 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 15591 | .name = "bgp evpn", |
62b346ee | 15592 | .node = BGP_EVPN_NODE, |
24389580 | 15593 | .parent_node = BGP_NODE, |
62b346ee | 15594 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 15595 | }; |
4e0b7b6d | 15596 | |
62b346ee | 15597 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 15598 | .name = "bgp evpn vni", |
62b346ee | 15599 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 15600 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 15601 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 15602 | }; |
90e60aa7 | 15603 | |
62b346ee | 15604 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 15605 | .name = "bgp ipv4 flowspec", |
62b346ee | 15606 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 15607 | .parent_node = BGP_NODE, |
62b346ee | 15608 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15609 | }; |
7c40bf39 | 15610 | |
62b346ee | 15611 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 15612 | .name = "bgp ipv6 flowspec", |
62b346ee | 15613 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 15614 | .parent_node = BGP_NODE, |
62b346ee | 15615 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15616 | }; |
7c40bf39 | 15617 | |
d62a17ae | 15618 | static void community_list_vty(void); |
1f8ae70b | 15619 | |
d62a17ae | 15620 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15621 | { |
d62a17ae | 15622 | struct bgp *bgp; |
15623 | struct peer *peer; | |
d62a17ae | 15624 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15625 | |
d62a17ae | 15626 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15627 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15628 | /* only provide suggestions on the appropriate input | |
15629 | * token type, | |
15630 | * they'll otherwise show up multiple times */ | |
15631 | enum cmd_token_type match_type; | |
15632 | char *name = peer->host; | |
d48ed3e0 | 15633 | |
d62a17ae | 15634 | if (peer->conf_if) { |
15635 | match_type = VARIABLE_TKN; | |
15636 | name = peer->conf_if; | |
15637 | } else if (strchr(peer->host, ':')) | |
15638 | match_type = IPV6_TKN; | |
15639 | else | |
15640 | match_type = IPV4_TKN; | |
d48ed3e0 | 15641 | |
d62a17ae | 15642 | if (token->type != match_type) |
15643 | continue; | |
d48ed3e0 | 15644 | |
d62a17ae | 15645 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15646 | } | |
d62a17ae | 15647 | } |
b8a815e5 DL |
15648 | } |
15649 | ||
15650 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15651 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15652 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15653 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15654 | {.completions = NULL}}; |
15655 | ||
47a306a0 DS |
15656 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15657 | { | |
15658 | struct bgp *bgp; | |
15659 | struct peer_group *group; | |
15660 | struct listnode *lnbgp, *lnpeer; | |
15661 | ||
15662 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15663 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15664 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15665 | group->name)); | |
15666 | } | |
15667 | } | |
15668 | ||
15669 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15670 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15671 | {.completions = NULL} }; | |
15672 | ||
d62a17ae | 15673 | void bgp_vty_init(void) |
15674 | { | |
15675 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15676 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15677 | |
15678 | /* Install bgp top node. */ | |
612c2c15 DL |
15679 | install_node(&bgp_node); |
15680 | install_node(&bgp_ipv4_unicast_node); | |
15681 | install_node(&bgp_ipv4_multicast_node); | |
15682 | install_node(&bgp_ipv4_labeled_unicast_node); | |
15683 | install_node(&bgp_ipv6_unicast_node); | |
15684 | install_node(&bgp_ipv6_multicast_node); | |
15685 | install_node(&bgp_ipv6_labeled_unicast_node); | |
15686 | install_node(&bgp_vpnv4_node); | |
15687 | install_node(&bgp_vpnv6_node); | |
15688 | install_node(&bgp_evpn_node); | |
15689 | install_node(&bgp_evpn_vni_node); | |
15690 | install_node(&bgp_flowspecv4_node); | |
15691 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 15692 | |
15693 | /* Install default VTY commands to new nodes. */ | |
15694 | install_default(BGP_NODE); | |
15695 | install_default(BGP_IPV4_NODE); | |
15696 | install_default(BGP_IPV4M_NODE); | |
15697 | install_default(BGP_IPV4L_NODE); | |
15698 | install_default(BGP_IPV6_NODE); | |
15699 | install_default(BGP_IPV6M_NODE); | |
15700 | install_default(BGP_IPV6L_NODE); | |
15701 | install_default(BGP_VPNV4_NODE); | |
15702 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15703 | install_default(BGP_FLOWSPECV4_NODE); |
15704 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15705 | install_default(BGP_EVPN_NODE); |
15706 | install_default(BGP_EVPN_VNI_NODE); | |
15707 | ||
8029b216 AK |
15708 | /* "bgp local-mac" hidden commands. */ |
15709 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15710 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15711 | ||
d62a17ae | 15712 | /* bgp route-map delay-timer commands. */ |
15713 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15714 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15715 | ||
15716 | /* Dummy commands (Currently not supported) */ | |
15717 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15718 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15719 | ||
15720 | /* "router bgp" commands. */ | |
15721 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15722 | ||
15723 | /* "no router bgp" commands. */ | |
15724 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15725 | ||
15726 | /* "bgp router-id" commands. */ | |
15727 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15728 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15729 | ||
15730 | /* "bgp cluster-id" commands. */ | |
15731 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15732 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15733 | ||
15734 | /* "bgp confederation" commands. */ | |
15735 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15736 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15737 | ||
15738 | /* "bgp confederation peers" commands. */ | |
15739 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15740 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15741 | ||
15742 | /* bgp max-med command */ | |
15743 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15744 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15745 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15746 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15747 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15748 | ||
15749 | /* bgp disable-ebgp-connected-nh-check */ | |
15750 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15751 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15752 | ||
15753 | /* bgp update-delay command */ | |
15754 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15755 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15756 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15757 | ||
15758 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15759 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15760 | |
15761 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15762 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15763 | ||
15764 | /* "maximum-paths" commands. */ | |
15765 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15766 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15767 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15768 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15769 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15770 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15771 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15772 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15773 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15774 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15775 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15776 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15777 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15778 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15779 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15780 | ||
39edabac PG |
15781 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_cmd); |
15782 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd); | |
15783 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15784 | install_element(BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15785 | install_element(BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
d62a17ae | 15786 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); |
15787 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15788 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15789 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15790 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15791 | ||
15792 | /* "timers bgp" commands. */ | |
15793 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15794 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15795 | ||
15796 | /* route-map delay-timer commands - per instance for backwards compat. | |
15797 | */ | |
15798 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15799 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15800 | ||
15801 | /* "bgp client-to-client reflection" commands */ | |
15802 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15803 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15804 | ||
15805 | /* "bgp always-compare-med" commands */ | |
15806 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15807 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15808 | ||
9dac9fc8 DA |
15809 | /* bgp ebgp-requires-policy */ |
15810 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15811 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15812 | ||
fb29348a DA |
15813 | /* bgp reject-as-sets */ |
15814 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15815 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15816 | ||
d62a17ae | 15817 | /* "bgp deterministic-med" commands */ |
15818 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15819 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15820 | ||
055679e9 | 15821 | /* "bgp graceful-restart" command */ |
36235319 QY |
15822 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15823 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15824 | |
15825 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15826 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15827 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15828 | |
15829 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15830 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15831 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15832 | |
15833 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15834 | install_element(BGP_NODE, | |
15835 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15836 | install_element(BGP_NODE, | |
15837 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15838 | ||
15839 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15840 | install_element(BGP_NODE, | |
15841 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15842 | install_element(BGP_NODE, | |
15843 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15844 | ||
d62a17ae | 15845 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15846 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15847 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15848 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15849 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15850 | install_element(BGP_NODE, |
15851 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15852 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15853 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15854 | ||
d6e3c15b | 15855 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15856 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15857 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15858 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15859 | |
7f323236 DW |
15860 | /* "bgp graceful-shutdown" commands */ |
15861 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15862 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15863 | ||
d62a17ae | 15864 | /* "bgp fast-external-failover" commands */ |
15865 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15866 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15867 | ||
d62a17ae | 15868 | /* "bgp bestpath compare-routerid" commands */ |
15869 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15870 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15871 | ||
15872 | /* "bgp bestpath as-path ignore" commands */ | |
15873 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15874 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15875 | ||
15876 | /* "bgp bestpath as-path confed" commands */ | |
15877 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15878 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15879 | ||
15880 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15881 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15882 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15883 | ||
15884 | /* "bgp log-neighbor-changes" commands */ | |
15885 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15886 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15887 | ||
15888 | /* "bgp bestpath med" commands */ | |
15889 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15890 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15891 | ||
f7e1c681 | 15892 | /* "bgp bestpath bandwidth" commands */ |
15893 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
ad36d216 | 15894 | install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); |
f7e1c681 | 15895 | |
d62a17ae | 15896 | /* "no bgp default ipv4-unicast" commands. */ |
15897 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15898 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15899 | ||
15900 | /* "bgp network import-check" commands. */ | |
15901 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15902 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15903 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15904 | ||
15905 | /* "bgp default local-preference" commands. */ | |
15906 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15907 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15908 | ||
15909 | /* bgp default show-hostname */ | |
15910 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15911 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15912 | ||
15913 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15914 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15915 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15916 | ||
15917 | /* bgp ibgp-allow-policy-mods command */ | |
15918 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15919 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15920 | ||
15921 | /* "bgp listen limit" commands. */ | |
15922 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15923 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15924 | ||
15925 | /* "bgp listen range" commands. */ | |
15926 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15927 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15928 | ||
8175f54a | 15929 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15930 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15931 | ||
d62a17ae | 15932 | /* "neighbor remote-as" commands. */ |
15933 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15934 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15935 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15936 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15937 | install_element(BGP_NODE, | |
15938 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15939 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15940 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15941 | ||
15942 | /* "neighbor peer-group" commands. */ | |
15943 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15944 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15945 | install_element(BGP_NODE, | |
15946 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15947 | ||
15948 | /* "neighbor local-as" commands. */ | |
15949 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15950 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15951 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15952 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15953 | ||
15954 | /* "neighbor solo" commands. */ | |
15955 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15956 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15957 | ||
15958 | /* "neighbor password" commands. */ | |
15959 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15960 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15961 | ||
15962 | /* "neighbor activate" commands. */ | |
15963 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15964 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15965 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15966 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15967 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15968 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15969 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15970 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15971 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15972 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15973 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15974 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15975 | ||
15976 | /* "no neighbor activate" commands. */ | |
15977 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15978 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15979 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15980 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15981 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15982 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15983 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15984 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15985 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15986 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15987 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15988 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15989 | ||
15990 | /* "neighbor peer-group" set commands. */ | |
15991 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15992 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15993 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15994 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15995 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15996 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15997 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15998 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15999 | install_element(BGP_FLOWSPECV4_NODE, |
16000 | &neighbor_set_peer_group_hidden_cmd); | |
16001 | install_element(BGP_FLOWSPECV6_NODE, | |
16002 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16003 | |
16004 | /* "no neighbor peer-group unset" commands. */ | |
16005 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
16006 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16007 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16008 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16009 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16010 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16011 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
16012 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 16013 | install_element(BGP_FLOWSPECV4_NODE, |
16014 | &no_neighbor_set_peer_group_hidden_cmd); | |
16015 | install_element(BGP_FLOWSPECV6_NODE, | |
16016 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 16017 | |
16018 | /* "neighbor softreconfiguration inbound" commands.*/ | |
16019 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
16020 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
16021 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16022 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16023 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16024 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16025 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16026 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16027 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16028 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16029 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
16030 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16031 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
16032 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16033 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
16034 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
16035 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
16036 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 16037 | install_element(BGP_FLOWSPECV4_NODE, |
16038 | &neighbor_soft_reconfiguration_cmd); | |
16039 | install_element(BGP_FLOWSPECV4_NODE, | |
16040 | &no_neighbor_soft_reconfiguration_cmd); | |
16041 | install_element(BGP_FLOWSPECV6_NODE, | |
16042 | &neighbor_soft_reconfiguration_cmd); | |
16043 | install_element(BGP_FLOWSPECV6_NODE, | |
16044 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
16045 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
16046 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 16047 | |
16048 | /* "neighbor attribute-unchanged" commands. */ | |
16049 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
16050 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
16051 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
16052 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16053 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
16054 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16055 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
16056 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16057 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
16058 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16059 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
16060 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
16061 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
16062 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
16063 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
16064 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
16065 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
16066 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
16067 | ||
16068 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
16069 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
16070 | ||
16071 | /* "nexthop-local unchanged" commands */ | |
16072 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
16073 | install_element(BGP_IPV6_NODE, | |
16074 | &no_neighbor_nexthop_local_unchanged_cmd); | |
16075 | ||
16076 | /* "neighbor next-hop-self" commands. */ | |
16077 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
16078 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
16079 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
16080 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16081 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
16082 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
16083 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
16084 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
16085 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
16086 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
16087 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
16088 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
16089 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
16090 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
16091 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
16092 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
16093 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
16094 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
16095 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
16096 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 16097 | |
16098 | /* "neighbor next-hop-self force" commands. */ | |
16099 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
16100 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
16101 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16102 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16103 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
16104 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16105 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16106 | install_element(BGP_IPV4_NODE, | |
16107 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16108 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
16109 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16110 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16111 | install_element(BGP_IPV4M_NODE, | |
16112 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16113 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
16114 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16115 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16116 | install_element(BGP_IPV4L_NODE, | |
16117 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16118 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
16119 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16120 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16121 | install_element(BGP_IPV6_NODE, | |
16122 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16123 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
16124 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16125 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16126 | install_element(BGP_IPV6M_NODE, | |
16127 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16128 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
16129 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16130 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16131 | install_element(BGP_IPV6L_NODE, | |
16132 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16133 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
16134 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16135 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16136 | install_element(BGP_VPNV4_NODE, | |
16137 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 16138 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
16139 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
16140 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
16141 | install_element(BGP_VPNV6_NODE, | |
16142 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
be7e1fa3 MS |
16143 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_force_cmd); |
16144 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_force_cmd); | |
d62a17ae | 16145 | |
16146 | /* "neighbor as-override" commands. */ | |
16147 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
16148 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
16149 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
16150 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
16151 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
16152 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
16153 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
16154 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
16155 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
16156 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
16157 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
16158 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
16159 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
16160 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
16161 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
16162 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
16163 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
16164 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
16165 | ||
16166 | /* "neighbor remove-private-AS" commands. */ | |
16167 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
16168 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
16169 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
16170 | install_element(BGP_NODE, | |
16171 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
16172 | install_element(BGP_NODE, | |
16173 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
16174 | install_element(BGP_NODE, | |
16175 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
16176 | install_element(BGP_NODE, | |
16177 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16178 | install_element( | |
16179 | BGP_NODE, | |
16180 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16181 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
16182 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16183 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16184 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16185 | install_element(BGP_IPV4_NODE, | |
16186 | &neighbor_remove_private_as_replace_as_cmd); | |
16187 | install_element(BGP_IPV4_NODE, | |
16188 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16189 | install_element(BGP_IPV4_NODE, | |
16190 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16191 | install_element(BGP_IPV4_NODE, | |
16192 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16193 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
16194 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
16195 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
16196 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16197 | install_element(BGP_IPV4M_NODE, | |
16198 | &neighbor_remove_private_as_replace_as_cmd); | |
16199 | install_element(BGP_IPV4M_NODE, | |
16200 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16201 | install_element(BGP_IPV4M_NODE, | |
16202 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16203 | install_element(BGP_IPV4M_NODE, | |
16204 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16205 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
16206 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
16207 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
16208 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16209 | install_element(BGP_IPV4L_NODE, | |
16210 | &neighbor_remove_private_as_replace_as_cmd); | |
16211 | install_element(BGP_IPV4L_NODE, | |
16212 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16213 | install_element(BGP_IPV4L_NODE, | |
16214 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16215 | install_element(BGP_IPV4L_NODE, | |
16216 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16217 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
16218 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16219 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16220 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16221 | install_element(BGP_IPV6_NODE, | |
16222 | &neighbor_remove_private_as_replace_as_cmd); | |
16223 | install_element(BGP_IPV6_NODE, | |
16224 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16225 | install_element(BGP_IPV6_NODE, | |
16226 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16227 | install_element(BGP_IPV6_NODE, | |
16228 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16229 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
16230 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
16231 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
16232 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16233 | install_element(BGP_IPV6M_NODE, | |
16234 | &neighbor_remove_private_as_replace_as_cmd); | |
16235 | install_element(BGP_IPV6M_NODE, | |
16236 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16237 | install_element(BGP_IPV6M_NODE, | |
16238 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16239 | install_element(BGP_IPV6M_NODE, | |
16240 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16241 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
16242 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
16243 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
16244 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16245 | install_element(BGP_IPV6L_NODE, | |
16246 | &neighbor_remove_private_as_replace_as_cmd); | |
16247 | install_element(BGP_IPV6L_NODE, | |
16248 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16249 | install_element(BGP_IPV6L_NODE, | |
16250 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16251 | install_element(BGP_IPV6L_NODE, | |
16252 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16253 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
16254 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16255 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16256 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16257 | install_element(BGP_VPNV4_NODE, | |
16258 | &neighbor_remove_private_as_replace_as_cmd); | |
16259 | install_element(BGP_VPNV4_NODE, | |
16260 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16261 | install_element(BGP_VPNV4_NODE, | |
16262 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16263 | install_element(BGP_VPNV4_NODE, | |
16264 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16265 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
16266 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16267 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16268 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16269 | install_element(BGP_VPNV6_NODE, | |
16270 | &neighbor_remove_private_as_replace_as_cmd); | |
16271 | install_element(BGP_VPNV6_NODE, | |
16272 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16273 | install_element(BGP_VPNV6_NODE, | |
16274 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16275 | install_element(BGP_VPNV6_NODE, | |
16276 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16277 | ||
16278 | /* "neighbor send-community" commands.*/ | |
16279 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
16280 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
16281 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
16282 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
16283 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
16284 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
16285 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
16286 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
16287 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
16288 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
16289 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
16290 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
16291 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
16292 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
16293 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
16294 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
16295 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
16296 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
16297 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
16298 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
16299 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
16300 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
16301 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
16302 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
16303 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
16304 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
16305 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
16306 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
16307 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
16308 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
16309 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
16310 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
16311 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
16312 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
16313 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
16314 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
16315 | ||
16316 | /* "neighbor route-reflector" commands.*/ | |
16317 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
16318 | install_element(BGP_NODE, | |
16319 | &no_neighbor_route_reflector_client_hidden_cmd); | |
16320 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
16321 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
16322 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
16323 | install_element(BGP_IPV4M_NODE, | |
16324 | &no_neighbor_route_reflector_client_cmd); | |
16325 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
16326 | install_element(BGP_IPV4L_NODE, | |
16327 | &no_neighbor_route_reflector_client_cmd); | |
16328 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
16329 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
16330 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
16331 | install_element(BGP_IPV6M_NODE, | |
16332 | &no_neighbor_route_reflector_client_cmd); | |
16333 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
16334 | install_element(BGP_IPV6L_NODE, | |
16335 | &no_neighbor_route_reflector_client_cmd); | |
16336 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16337 | install_element(BGP_VPNV4_NODE, | |
16338 | &no_neighbor_route_reflector_client_cmd); | |
16339 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16340 | install_element(BGP_VPNV6_NODE, | |
16341 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16342 | install_element(BGP_FLOWSPECV4_NODE, |
16343 | &neighbor_route_reflector_client_cmd); | |
16344 | install_element(BGP_FLOWSPECV4_NODE, | |
16345 | &no_neighbor_route_reflector_client_cmd); | |
16346 | install_element(BGP_FLOWSPECV6_NODE, | |
16347 | &neighbor_route_reflector_client_cmd); | |
16348 | install_element(BGP_FLOWSPECV6_NODE, | |
16349 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16350 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16351 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16352 | ||
16353 | /* "neighbor route-server" commands.*/ | |
16354 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16355 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16356 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16357 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16358 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16359 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16360 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16361 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16362 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16363 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16364 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16365 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16366 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16367 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16368 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16369 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16370 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16371 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16372 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16373 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16374 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16375 | install_element(BGP_FLOWSPECV4_NODE, | |
16376 | &no_neighbor_route_server_client_cmd); | |
16377 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16378 | install_element(BGP_FLOWSPECV6_NODE, | |
16379 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16380 | |
16381 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16382 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16383 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16384 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16385 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16386 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16387 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16388 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16389 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16390 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16391 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16392 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16393 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16394 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16395 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16396 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16397 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16398 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16399 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16400 | ||
16401 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16402 | install_element(BGP_NODE, | |
16403 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16404 | install_element(BGP_NODE, | |
16405 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16406 | install_element(BGP_IPV4_NODE, | |
16407 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16408 | install_element(BGP_IPV4_NODE, | |
16409 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16410 | install_element(BGP_IPV4M_NODE, | |
16411 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16412 | install_element(BGP_IPV4M_NODE, | |
16413 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16414 | install_element(BGP_IPV4L_NODE, | |
16415 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16416 | install_element(BGP_IPV4L_NODE, | |
16417 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16418 | install_element(BGP_IPV6_NODE, | |
16419 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16420 | install_element(BGP_IPV6_NODE, | |
16421 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16422 | install_element(BGP_IPV6M_NODE, | |
16423 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16424 | install_element(BGP_IPV6M_NODE, | |
16425 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16426 | install_element(BGP_IPV6L_NODE, | |
16427 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16428 | install_element(BGP_IPV6L_NODE, | |
16429 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16430 | install_element(BGP_VPNV4_NODE, | |
16431 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16432 | install_element(BGP_VPNV4_NODE, | |
16433 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16434 | install_element(BGP_VPNV6_NODE, | |
16435 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16436 | install_element(BGP_VPNV6_NODE, | |
16437 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16438 | ||
2b31007c RZ |
16439 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16440 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16441 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16442 | ||
d62a17ae | 16443 | /* "neighbor passive" commands. */ |
16444 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16445 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16446 | ||
16447 | ||
16448 | /* "neighbor shutdown" commands. */ | |
16449 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16450 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16451 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16452 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16453 | ||
16454 | /* "neighbor capability extended-nexthop" commands.*/ | |
16455 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16456 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16457 | ||
16458 | /* "neighbor capability orf prefix-list" commands.*/ | |
16459 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16460 | install_element(BGP_NODE, | |
16461 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16462 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16463 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16464 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16465 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16466 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16467 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16468 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16469 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16470 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16471 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16472 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16473 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16474 | ||
16475 | /* "neighbor capability dynamic" commands.*/ | |
16476 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16477 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16478 | ||
16479 | /* "neighbor dont-capability-negotiate" commands. */ | |
16480 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16481 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16482 | ||
16483 | /* "neighbor ebgp-multihop" commands. */ | |
16484 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16485 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16486 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16487 | ||
16488 | /* "neighbor disable-connected-check" commands. */ | |
16489 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16490 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16491 | ||
47cbc09b PM |
16492 | /* "neighbor enforce-first-as" commands. */ |
16493 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16494 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16495 | ||
d62a17ae | 16496 | /* "neighbor description" commands. */ |
16497 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16498 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16499 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16500 | |
16501 | /* "neighbor update-source" commands. "*/ | |
16502 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16503 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16504 | ||
16505 | /* "neighbor default-originate" commands. */ | |
16506 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16507 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16508 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16509 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16510 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16511 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16512 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16513 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16514 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16515 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16516 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16517 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16518 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16519 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16520 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16521 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16522 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16523 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16524 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16525 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16526 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16527 | ||
16528 | /* "neighbor port" commands. */ | |
16529 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16530 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16531 | ||
16532 | /* "neighbor weight" commands. */ | |
16533 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16534 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16535 | ||
16536 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16537 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16538 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16539 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16540 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16541 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16542 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16543 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16544 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16545 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16546 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16547 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16548 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16549 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16550 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16551 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16552 | ||
16553 | /* "neighbor override-capability" commands. */ | |
16554 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16555 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16556 | ||
16557 | /* "neighbor strict-capability-match" commands. */ | |
16558 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16559 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16560 | ||
16561 | /* "neighbor timers" commands. */ | |
16562 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16563 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16564 | ||
16565 | /* "neighbor timers connect" commands. */ | |
16566 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16567 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16568 | ||
16569 | /* "neighbor advertisement-interval" commands. */ | |
16570 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16571 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16572 | ||
16573 | /* "neighbor interface" commands. */ | |
16574 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16575 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16576 | ||
16577 | /* "neighbor distribute" commands. */ | |
16578 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16579 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16580 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16581 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16582 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16583 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16584 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16585 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16586 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16587 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16588 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16589 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16590 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16591 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16592 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16593 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16594 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16595 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16596 | ||
16597 | /* "neighbor prefix-list" commands. */ | |
16598 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16599 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16600 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16601 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16602 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16603 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16604 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16605 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16606 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16607 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16608 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16609 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16610 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16611 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16612 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16613 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16614 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16615 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16616 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16617 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16618 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16619 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16620 | |
16621 | /* "neighbor filter-list" commands. */ | |
16622 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16623 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16624 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16625 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16626 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16627 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16628 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16629 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16630 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16631 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16632 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16633 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16634 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16635 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16636 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16637 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16638 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16639 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16640 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16641 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16642 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16643 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16644 | |
16645 | /* "neighbor route-map" commands. */ | |
16646 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16647 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16648 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16649 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16650 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16651 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16652 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16653 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16654 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16655 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16656 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16657 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16658 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16659 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16660 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16661 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16662 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16663 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16664 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16665 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16666 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16667 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16668 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16669 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16670 | |
16671 | /* "neighbor unsuppress-map" commands. */ | |
16672 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16673 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16674 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16675 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16676 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16677 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16678 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16679 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16680 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16681 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16682 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16683 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16684 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16685 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16686 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16687 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16688 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16689 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16690 | ||
fde246e8 DA |
16691 | /* neighbor maximum-prefix-out commands. */ |
16692 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16693 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16694 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16695 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16696 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16697 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16698 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16699 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16700 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16701 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16702 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16703 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16704 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16705 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16706 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16707 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16708 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16709 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16710 | ||
d62a17ae | 16711 | /* "neighbor maximum-prefix" commands. */ |
16712 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16713 | install_element(BGP_NODE, | |
16714 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16715 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16716 | install_element(BGP_NODE, | |
16717 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16718 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16719 | install_element(BGP_NODE, | |
16720 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16721 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16722 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16723 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16724 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16725 | install_element(BGP_IPV4_NODE, | |
16726 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16727 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16728 | install_element(BGP_IPV4_NODE, | |
16729 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16730 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16731 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16732 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16733 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16734 | install_element(BGP_IPV4M_NODE, | |
16735 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16736 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16737 | install_element(BGP_IPV4M_NODE, | |
16738 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16739 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16740 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16741 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16742 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16743 | install_element(BGP_IPV4L_NODE, | |
16744 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16745 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16746 | install_element(BGP_IPV4L_NODE, | |
16747 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16748 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16749 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16750 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16751 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16752 | install_element(BGP_IPV6_NODE, | |
16753 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16754 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16755 | install_element(BGP_IPV6_NODE, | |
16756 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16757 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16758 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16759 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16760 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16761 | install_element(BGP_IPV6M_NODE, | |
16762 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16763 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16764 | install_element(BGP_IPV6M_NODE, | |
16765 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16766 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16767 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16768 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16769 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16770 | install_element(BGP_IPV6L_NODE, | |
16771 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16772 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16773 | install_element(BGP_IPV6L_NODE, | |
16774 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16775 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16776 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16777 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16778 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16779 | install_element(BGP_VPNV4_NODE, | |
16780 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16781 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16782 | install_element(BGP_VPNV4_NODE, | |
16783 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16784 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16785 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16786 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16787 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16788 | install_element(BGP_VPNV6_NODE, | |
16789 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16790 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16791 | install_element(BGP_VPNV6_NODE, | |
16792 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16793 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16794 | ||
16795 | /* "neighbor allowas-in" */ | |
16796 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16797 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16798 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16799 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16800 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16801 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16802 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16803 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16804 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16805 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16806 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16807 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16808 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16809 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16810 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16811 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16812 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16813 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16814 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16815 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16816 | ||
16817 | /* address-family commands. */ | |
16818 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16819 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16820 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16821 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16822 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16823 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16824 | |
d62a17ae | 16825 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16826 | ||
16827 | /* "exit-address-family" command. */ | |
16828 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16829 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16830 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16831 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16832 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16833 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16834 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16835 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16836 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16837 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16838 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16839 | ||
16840 | /* "clear ip bgp commands" */ | |
16841 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16842 | ||
16843 | /* clear ip bgp prefix */ | |
16844 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16845 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16846 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16847 | ||
16848 | /* "show [ip] bgp summary" commands. */ | |
16849 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16850 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16851 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16852 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16853 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16854 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16855 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16856 | ||
16857 | /* "show [ip] bgp neighbors" commands. */ | |
16858 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16859 | ||
36235319 | 16860 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 16861 | |
d62a17ae | 16862 | /* "show [ip] bgp peer-group" commands. */ |
16863 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16864 | ||
16865 | /* "show [ip] bgp paths" commands. */ | |
16866 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16867 | ||
16868 | /* "show [ip] bgp community" commands. */ | |
16869 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16870 | ||
16871 | /* "show ip bgp large-community" commands. */ | |
16872 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16873 | /* "show [ip] bgp attribute-info" commands. */ | |
16874 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16875 | /* "show [ip] bgp route-leak" command */ |
16876 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16877 | |
16878 | /* "redistribute" commands. */ | |
16879 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16880 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16881 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16882 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16883 | install_element(BGP_NODE, | |
16884 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16885 | install_element(BGP_NODE, | |
16886 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16887 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16888 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16889 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16890 | install_element(BGP_NODE, | |
16891 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16892 | install_element(BGP_NODE, | |
16893 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16894 | install_element(BGP_NODE, | |
16895 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16896 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16897 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16898 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16899 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16900 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16901 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16902 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16903 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16904 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16905 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16906 | install_element(BGP_IPV4_NODE, | |
16907 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16908 | install_element(BGP_IPV4_NODE, | |
16909 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16910 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16911 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16912 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16913 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16914 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16915 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16916 | ||
b9c7bc5a PZ |
16917 | /* import|export vpn [route-map WORD] */ |
16918 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16919 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16920 | |
12a844a5 DS |
16921 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16922 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16923 | ||
d62a17ae | 16924 | /* ttl_security commands */ |
16925 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16926 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16927 | ||
16928 | /* "show [ip] bgp memory" commands. */ | |
16929 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16930 | ||
acf71666 MK |
16931 | /* "show bgp martian next-hop" */ |
16932 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16933 | ||
48ecf8f5 DS |
16934 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16935 | ||
d62a17ae | 16936 | /* "show [ip] bgp views" commands. */ |
16937 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16938 | ||
16939 | /* "show [ip] bgp vrfs" commands. */ | |
16940 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16941 | ||
16942 | /* Community-list. */ | |
16943 | community_list_vty(); | |
ddb5b488 PZ |
16944 | |
16945 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16946 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16947 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16948 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16949 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16950 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16951 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16952 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16953 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16954 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16955 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16956 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16957 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16958 | |
301ad80a PG |
16959 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16960 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16961 | ||
b9c7bc5a PZ |
16962 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16963 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16964 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16965 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
16966 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
16967 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16968 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16969 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16970 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16971 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16972 | } |
6b0655a2 | 16973 | |
718e3744 | 16974 | #include "memory.h" |
16975 | #include "bgp_regex.h" | |
16976 | #include "bgp_clist.h" | |
16977 | #include "bgp_ecommunity.h" | |
16978 | ||
16979 | /* VTY functions. */ | |
16980 | ||
16981 | /* Direction value to string conversion. */ | |
d62a17ae | 16982 | static const char *community_direct_str(int direct) |
16983 | { | |
16984 | switch (direct) { | |
16985 | case COMMUNITY_DENY: | |
16986 | return "deny"; | |
16987 | case COMMUNITY_PERMIT: | |
16988 | return "permit"; | |
16989 | default: | |
16990 | return "unknown"; | |
16991 | } | |
718e3744 | 16992 | } |
16993 | ||
16994 | /* Display error string. */ | |
d62a17ae | 16995 | static void community_list_perror(struct vty *vty, int ret) |
16996 | { | |
16997 | switch (ret) { | |
16998 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16999 | vty_out(vty, "%% Can't find community-list\n"); | |
17000 | break; | |
17001 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
17002 | vty_out(vty, "%% Malformed community-list value\n"); | |
17003 | break; | |
17004 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
17005 | vty_out(vty, | |
17006 | "%% Community name conflict, previously defined as standard community\n"); | |
17007 | break; | |
17008 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
17009 | vty_out(vty, | |
17010 | "%% Community name conflict, previously defined as expanded community\n"); | |
17011 | break; | |
17012 | } | |
718e3744 | 17013 | } |
17014 | ||
5bf15956 DW |
17015 | /* "community-list" keyword help string. */ |
17016 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
17017 | ||
7336e101 SP |
17018 | /*community-list standard */ |
17019 | DEFUN (community_list_standard, | |
17020 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 17021 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17022 | BGP_STR |
718e3744 | 17023 | COMMUNITY_LIST_STR |
17024 | "Community list number (standard)\n" | |
5bf15956 | 17025 | "Add an standard community-list entry\n" |
718e3744 | 17026 | "Community list name\n" |
2f8cc0e5 DA |
17027 | "Sequence number of an entry\n" |
17028 | "Sequence number\n" | |
718e3744 | 17029 | "Specify community to reject\n" |
17030 | "Specify community to accept\n" | |
17031 | COMMUNITY_VAL_STR) | |
17032 | { | |
d62a17ae | 17033 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17034 | char *seq = NULL; |
d62a17ae | 17035 | int direct = 0; |
17036 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 17037 | int idx = 0; |
7336e101 | 17038 | |
2f8cc0e5 DA |
17039 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17040 | if (idx) | |
17041 | seq = argv[idx]->arg; | |
17042 | ||
17043 | idx = 0; | |
d62a17ae | 17044 | argv_find(argv, argc, "(1-99)", &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_standard_all, |
17067 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 17068 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17069 | NO_STR |
17070 | BGP_STR | |
17071 | COMMUNITY_LIST_STR | |
17072 | "Community list number (standard)\n" | |
17073 | "Add an standard 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; |
174b5cb9 | 17082 | char *str = NULL; |
d62a17ae | 17083 | int direct = 0; |
17084 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 17085 | char *seq = NULL; |
d62a17ae | 17086 | int idx = 0; |
7336e101 | 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); | |
17104 | } | |
17105 | ||
17106 | idx = 0; | |
d62a17ae | 17107 | argv_find(argv, argc, "(1-99)", &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 | } |
7336e101 | 17123 | |
174b5cb9 DA |
17124 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
17125 | "no bgp community-list <(1-99)|standard WORD>", | |
17126 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
17127 | "Community list number (standard)\n" | |
17128 | "Add an standard community-list entry\n" | |
17129 | "Community list name\n") | |
17130 | ||
7336e101 SP |
17131 | /*community-list expanded */ |
17132 | DEFUN (community_list_expanded_all, | |
17133 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17134 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17135 | BGP_STR |
17136 | COMMUNITY_LIST_STR | |
718e3744 | 17137 | "Community list number (expanded)\n" |
5bf15956 | 17138 | "Add an expanded community-list entry\n" |
718e3744 | 17139 | "Community list name\n" |
2f8cc0e5 DA |
17140 | "Sequence number of an entry\n" |
17141 | "Sequence number\n" | |
718e3744 | 17142 | "Specify community to reject\n" |
17143 | "Specify community to accept\n" | |
17144 | COMMUNITY_VAL_STR) | |
17145 | { | |
d62a17ae | 17146 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17147 | char *seq = NULL; |
d62a17ae | 17148 | int direct = 0; |
17149 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17150 | int idx = 0; |
7b9a4750 | 17151 | |
2f8cc0e5 DA |
17152 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17153 | if (idx) | |
17154 | seq = argv[idx]->arg; | |
17155 | ||
17156 | idx = 0; | |
17157 | ||
d62a17ae | 17158 | argv_find(argv, argc, "(100-500)", &idx); |
17159 | argv_find(argv, argc, "WORD", &idx); | |
17160 | cl_name_or_number = argv[idx]->arg; | |
17161 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
17162 | : COMMUNITY_DENY; | |
17163 | argv_find(argv, argc, "AA:NN", &idx); | |
17164 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17165 | |
2f8cc0e5 DA |
17166 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
17167 | direct, style); | |
42f914d4 | 17168 | |
d62a17ae | 17169 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17170 | |
d62a17ae | 17171 | if (ret < 0) { |
17172 | /* Display error string. */ | |
17173 | community_list_perror(vty, ret); | |
17174 | return CMD_WARNING_CONFIG_FAILED; | |
17175 | } | |
42f914d4 | 17176 | |
d62a17ae | 17177 | return CMD_SUCCESS; |
718e3744 | 17178 | } |
17179 | ||
7336e101 SP |
17180 | DEFUN (no_community_list_expanded_all, |
17181 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17182 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17183 | NO_STR |
17184 | BGP_STR | |
17185 | COMMUNITY_LIST_STR | |
17186 | "Community list number (expanded)\n" | |
17187 | "Add an expanded community-list entry\n" | |
17188 | "Community list name\n" | |
2f8cc0e5 DA |
17189 | "Sequence number of an entry\n" |
17190 | "Sequence number\n" | |
7336e101 SP |
17191 | "Specify community to reject\n" |
17192 | "Specify community to accept\n" | |
17193 | COMMUNITY_VAL_STR) | |
718e3744 | 17194 | { |
d62a17ae | 17195 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17196 | char *seq = NULL; |
174b5cb9 | 17197 | char *str = NULL; |
d62a17ae | 17198 | int direct = 0; |
17199 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17200 | int idx = 0; |
174b5cb9 | 17201 | |
2f8cc0e5 DA |
17202 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17203 | if (idx) | |
17204 | seq = argv[idx]->arg; | |
17205 | ||
17206 | idx = 0; | |
174b5cb9 DA |
17207 | argv_find(argv, argc, "permit", &idx); |
17208 | argv_find(argv, argc, "deny", &idx); | |
17209 | ||
17210 | if (idx) { | |
17211 | direct = argv_find(argv, argc, "permit", &idx) | |
17212 | ? COMMUNITY_PERMIT | |
17213 | : COMMUNITY_DENY; | |
17214 | ||
17215 | idx = 0; | |
17216 | argv_find(argv, argc, "AA:NN", &idx); | |
17217 | str = argv_concat(argv, argc, idx); | |
7336e101 | 17218 | } |
174b5cb9 DA |
17219 | |
17220 | idx = 0; | |
d62a17ae | 17221 | argv_find(argv, argc, "(100-500)", &idx); |
17222 | argv_find(argv, argc, "WORD", &idx); | |
17223 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17224 | |
2f8cc0e5 | 17225 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17226 | direct, style); |
42f914d4 | 17227 | |
d62a17ae | 17228 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17229 | |
d62a17ae | 17230 | if (ret < 0) { |
17231 | community_list_perror(vty, ret); | |
17232 | return CMD_WARNING_CONFIG_FAILED; | |
17233 | } | |
42f914d4 | 17234 | |
d62a17ae | 17235 | return CMD_SUCCESS; |
718e3744 | 17236 | } |
17237 | ||
174b5cb9 DA |
17238 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
17239 | "no bgp community-list <(100-500)|expanded WORD>", | |
17240 | NO_STR IP_STR COMMUNITY_LIST_STR | |
17241 | "Community list number (expanded)\n" | |
17242 | "Add an expanded community-list entry\n" | |
17243 | "Community list name\n") | |
17244 | ||
8d9b8ed9 PM |
17245 | /* Return configuration string of community-list entry. */ |
17246 | static const char *community_list_config_str(struct community_entry *entry) | |
17247 | { | |
17248 | const char *str; | |
17249 | ||
17250 | if (entry->any) | |
17251 | str = ""; | |
17252 | else { | |
17253 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
17254 | str = community_str(entry->u.com, false); | |
17255 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
17256 | str = lcommunity_str(entry->u.lcom, false); | |
17257 | else | |
17258 | str = entry->config; | |
17259 | } | |
17260 | return str; | |
17261 | } | |
17262 | ||
d62a17ae | 17263 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17264 | { |
d62a17ae | 17265 | struct community_entry *entry; |
718e3744 | 17266 | |
d62a17ae | 17267 | for (entry = list->head; entry; entry = entry->next) { |
17268 | if (entry == list->head) { | |
17269 | if (all_digit(list->name)) | |
17270 | vty_out(vty, "Community %s list %s\n", | |
17271 | entry->style == COMMUNITY_LIST_STANDARD | |
17272 | ? "standard" | |
17273 | : "(expanded) access", | |
17274 | list->name); | |
17275 | else | |
17276 | vty_out(vty, "Named Community %s list %s\n", | |
17277 | entry->style == COMMUNITY_LIST_STANDARD | |
17278 | ? "standard" | |
17279 | : "expanded", | |
17280 | list->name); | |
17281 | } | |
17282 | if (entry->any) | |
17283 | vty_out(vty, " %s\n", | |
17284 | community_direct_str(entry->direct)); | |
17285 | else | |
17286 | vty_out(vty, " %s %s\n", | |
17287 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17288 | community_list_config_str(entry)); |
d62a17ae | 17289 | } |
718e3744 | 17290 | } |
17291 | ||
7336e101 SP |
17292 | DEFUN (show_community_list, |
17293 | show_bgp_community_list_cmd, | |
17294 | "show bgp community-list", | |
718e3744 | 17295 | SHOW_STR |
7336e101 | 17296 | BGP_STR |
718e3744 | 17297 | "List community-list\n") |
17298 | { | |
d62a17ae | 17299 | struct community_list *list; |
17300 | struct community_list_master *cm; | |
718e3744 | 17301 | |
d62a17ae | 17302 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
17303 | if (!cm) | |
17304 | return CMD_SUCCESS; | |
718e3744 | 17305 | |
d62a17ae | 17306 | for (list = cm->num.head; list; list = list->next) |
17307 | community_list_show(vty, list); | |
718e3744 | 17308 | |
d62a17ae | 17309 | for (list = cm->str.head; list; list = list->next) |
17310 | community_list_show(vty, list); | |
718e3744 | 17311 | |
d62a17ae | 17312 | return CMD_SUCCESS; |
718e3744 | 17313 | } |
17314 | ||
7336e101 SP |
17315 | DEFUN (show_community_list_arg, |
17316 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 17317 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
17318 | SHOW_STR |
17319 | BGP_STR | |
718e3744 | 17320 | "List community-list\n" |
17321 | "Community-list number\n" | |
960b69b9 | 17322 | "Community-list name\n" |
17323 | "Detailed information on community-list\n") | |
718e3744 | 17324 | { |
d62a17ae | 17325 | int idx_comm_list = 3; |
17326 | struct community_list *list; | |
718e3744 | 17327 | |
e237b0d2 | 17328 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17329 | COMMUNITY_LIST_MASTER); |
17330 | if (!list) { | |
17331 | vty_out(vty, "%% Can't find community-list\n"); | |
17332 | return CMD_WARNING; | |
17333 | } | |
718e3744 | 17334 | |
d62a17ae | 17335 | community_list_show(vty, list); |
718e3744 | 17336 | |
d62a17ae | 17337 | return CMD_SUCCESS; |
718e3744 | 17338 | } |
6b0655a2 | 17339 | |
57d187bc JS |
17340 | /* |
17341 | * Large Community code. | |
17342 | */ | |
d62a17ae | 17343 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17344 | struct cmd_token **argv, int style, | |
17345 | int reject_all_digit_name) | |
17346 | { | |
17347 | int ret; | |
17348 | int direct; | |
17349 | char *str; | |
17350 | int idx = 0; | |
17351 | char *cl_name; | |
2f8cc0e5 DA |
17352 | char *seq = NULL; |
17353 | ||
947073e3 | 17354 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 17355 | seq = argv[idx]->arg; |
d62a17ae | 17356 | |
2f8cc0e5 | 17357 | idx = 0; |
d62a17ae | 17358 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17359 | : COMMUNITY_DENY; | |
17360 | ||
17361 | /* All digit name check. */ | |
17362 | idx = 0; | |
17363 | argv_find(argv, argc, "WORD", &idx); | |
17364 | argv_find(argv, argc, "(1-99)", &idx); | |
17365 | argv_find(argv, argc, "(100-500)", &idx); | |
17366 | cl_name = argv[idx]->arg; | |
17367 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17368 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17369 | return CMD_WARNING_CONFIG_FAILED; | |
17370 | } | |
17371 | ||
17372 | idx = 0; | |
17373 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17374 | argv_find(argv, argc, "LINE", &idx); | |
17375 | /* Concat community string argument. */ | |
17376 | if (idx) | |
17377 | str = argv_concat(argv, argc, idx); | |
17378 | else | |
17379 | str = NULL; | |
17380 | ||
2f8cc0e5 | 17381 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17382 | |
17383 | /* Free temporary community list string allocated by | |
17384 | argv_concat(). */ | |
0a22ddfb | 17385 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17386 | |
17387 | if (ret < 0) { | |
17388 | community_list_perror(vty, ret); | |
17389 | return CMD_WARNING_CONFIG_FAILED; | |
17390 | } | |
17391 | return CMD_SUCCESS; | |
17392 | } | |
17393 | ||
17394 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17395 | struct cmd_token **argv, int style) | |
17396 | { | |
17397 | int ret; | |
17398 | int direct = 0; | |
17399 | char *str = NULL; | |
17400 | int idx = 0; | |
2f8cc0e5 | 17401 | char *seq = NULL; |
d62a17ae | 17402 | |
947073e3 | 17403 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 | 17404 | seq = argv[idx]->arg; |
d62a17ae | 17405 | |
2f8cc0e5 | 17406 | idx = 0; |
d62a17ae | 17407 | argv_find(argv, argc, "permit", &idx); |
17408 | argv_find(argv, argc, "deny", &idx); | |
17409 | ||
17410 | if (idx) { | |
17411 | /* Check the list direct. */ | |
17412 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17413 | direct = COMMUNITY_PERMIT; | |
17414 | else | |
17415 | direct = COMMUNITY_DENY; | |
17416 | ||
17417 | idx = 0; | |
17418 | argv_find(argv, argc, "LINE", &idx); | |
17419 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17420 | /* Concat community string argument. */ | |
17421 | str = argv_concat(argv, argc, idx); | |
17422 | } | |
17423 | ||
17424 | idx = 0; | |
17425 | argv_find(argv, argc, "(1-99)", &idx); | |
17426 | argv_find(argv, argc, "(100-500)", &idx); | |
17427 | argv_find(argv, argc, "WORD", &idx); | |
17428 | ||
17429 | /* Unset community list. */ | |
2f8cc0e5 | 17430 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17431 | style); |
17432 | ||
17433 | /* Free temporary community list string allocated by | |
17434 | argv_concat(). */ | |
0a22ddfb | 17435 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17436 | |
17437 | if (ret < 0) { | |
17438 | community_list_perror(vty, ret); | |
17439 | return CMD_WARNING_CONFIG_FAILED; | |
17440 | } | |
17441 | ||
17442 | return CMD_SUCCESS; | |
57d187bc JS |
17443 | } |
17444 | ||
17445 | /* "large-community-list" keyword help string. */ | |
17446 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17447 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17448 | ||
7336e101 SP |
17449 | DEFUN (lcommunity_list_standard, |
17450 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17451 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17452 | BGP_STR |
17453 | LCOMMUNITY_LIST_STR | |
17454 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17455 | "Sequence number of an entry\n" |
17456 | "Sequence number\n" | |
7336e101 SP |
17457 | "Specify large community to reject\n" |
17458 | "Specify large community to accept\n" | |
17459 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17460 | { |
d62a17ae | 17461 | return lcommunity_list_set_vty(vty, argc, argv, |
17462 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17463 | } |
17464 | ||
7336e101 SP |
17465 | DEFUN (lcommunity_list_expanded, |
17466 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17467 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17468 | BGP_STR |
17469 | LCOMMUNITY_LIST_STR | |
17470 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17471 | "Sequence number of an entry\n" |
17472 | "Sequence number\n" | |
7336e101 SP |
17473 | "Specify large community to reject\n" |
17474 | "Specify large community to accept\n" | |
17475 | "An ordered list as a regular-expression\n") | |
57d187bc | 17476 | { |
d62a17ae | 17477 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17478 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17479 | } |
17480 | ||
7336e101 SP |
17481 | DEFUN (lcommunity_list_name_standard, |
17482 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17483 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17484 | BGP_STR |
17485 | LCOMMUNITY_LIST_STR | |
17486 | "Specify standard large-community-list\n" | |
17487 | "Large Community list name\n" | |
2f8cc0e5 DA |
17488 | "Sequence number of an entry\n" |
17489 | "Sequence number\n" | |
7336e101 SP |
17490 | "Specify large community to reject\n" |
17491 | "Specify large community to accept\n" | |
17492 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17493 | { |
d62a17ae | 17494 | return lcommunity_list_set_vty(vty, argc, argv, |
17495 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17496 | } |
17497 | ||
7336e101 SP |
17498 | DEFUN (lcommunity_list_name_expanded, |
17499 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17500 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17501 | BGP_STR |
17502 | LCOMMUNITY_LIST_STR | |
17503 | "Specify expanded large-community-list\n" | |
17504 | "Large Community list name\n" | |
2f8cc0e5 DA |
17505 | "Sequence number of an entry\n" |
17506 | "Sequence number\n" | |
7336e101 SP |
17507 | "Specify large community to reject\n" |
17508 | "Specify large community to accept\n" | |
17509 | "An ordered list as a regular-expression\n") | |
57d187bc | 17510 | { |
d62a17ae | 17511 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17512 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17513 | } |
17514 | ||
4378f57c DA |
17515 | DEFUN (no_lcommunity_list_all, |
17516 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17517 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17518 | NO_STR | |
17519 | BGP_STR | |
17520 | LCOMMUNITY_LIST_STR | |
17521 | "Large Community list number (standard)\n" | |
17522 | "Large Community list number (expanded)\n" | |
17523 | "Large Community list name\n") | |
57d187bc | 17524 | { |
7336e101 SP |
17525 | return lcommunity_list_unset_vty(vty, argc, argv, |
17526 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17527 | } |
17528 | ||
4378f57c DA |
17529 | DEFUN (no_lcommunity_list_name_standard_all, |
17530 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17531 | "no bgp large-community-list standard WORD", | |
17532 | NO_STR | |
17533 | BGP_STR | |
17534 | LCOMMUNITY_LIST_STR | |
17535 | "Specify standard large-community-list\n" | |
17536 | "Large Community list name\n") | |
17537 | { | |
17538 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17539 | LARGE_COMMUNITY_LIST_STANDARD); | |
17540 | } | |
17541 | ||
7336e101 SP |
17542 | DEFUN (no_lcommunity_list_name_expanded_all, |
17543 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17544 | "no bgp large-community-list expanded WORD", | |
17545 | NO_STR | |
17546 | BGP_STR | |
17547 | LCOMMUNITY_LIST_STR | |
17548 | "Specify expanded large-community-list\n" | |
17549 | "Large Community list name\n") | |
57d187bc | 17550 | { |
d62a17ae | 17551 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17552 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17553 | } |
17554 | ||
7336e101 SP |
17555 | DEFUN (no_lcommunity_list_standard, |
17556 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17557 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17558 | NO_STR |
17559 | BGP_STR | |
17560 | LCOMMUNITY_LIST_STR | |
17561 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17562 | "Sequence number of an entry\n" |
17563 | "Sequence number\n" | |
7336e101 SP |
17564 | "Specify large community to reject\n" |
17565 | "Specify large community to accept\n" | |
17566 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17567 | { |
d62a17ae | 17568 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17569 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17570 | } |
17571 | ||
7336e101 SP |
17572 | DEFUN (no_lcommunity_list_expanded, |
17573 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17574 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17575 | NO_STR |
17576 | BGP_STR | |
17577 | LCOMMUNITY_LIST_STR | |
17578 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17579 | "Sequence number of an entry\n" |
17580 | "Sequence number\n" | |
7336e101 SP |
17581 | "Specify large community to reject\n" |
17582 | "Specify large community to accept\n" | |
17583 | "An ordered list as a regular-expression\n") | |
57d187bc | 17584 | { |
d62a17ae | 17585 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17586 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17587 | } |
17588 | ||
7336e101 SP |
17589 | DEFUN (no_lcommunity_list_name_standard, |
17590 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17591 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17592 | NO_STR |
17593 | BGP_STR | |
17594 | LCOMMUNITY_LIST_STR | |
17595 | "Specify standard large-community-list\n" | |
17596 | "Large Community list name\n" | |
2f8cc0e5 DA |
17597 | "Sequence number of an entry\n" |
17598 | "Sequence number\n" | |
7336e101 SP |
17599 | "Specify large community to reject\n" |
17600 | "Specify large community to accept\n" | |
17601 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17602 | { |
d62a17ae | 17603 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17604 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17605 | } |
17606 | ||
7336e101 SP |
17607 | DEFUN (no_lcommunity_list_name_expanded, |
17608 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17609 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17610 | NO_STR |
17611 | BGP_STR | |
17612 | LCOMMUNITY_LIST_STR | |
17613 | "Specify expanded large-community-list\n" | |
17614 | "Large community list name\n" | |
2f8cc0e5 DA |
17615 | "Sequence number of an entry\n" |
17616 | "Sequence number\n" | |
7336e101 SP |
17617 | "Specify large community to reject\n" |
17618 | "Specify large community to accept\n" | |
17619 | "An ordered list as a regular-expression\n") | |
57d187bc | 17620 | { |
d62a17ae | 17621 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17622 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17623 | } |
17624 | ||
d62a17ae | 17625 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17626 | { | |
17627 | struct community_entry *entry; | |
17628 | ||
17629 | for (entry = list->head; entry; entry = entry->next) { | |
17630 | if (entry == list->head) { | |
17631 | if (all_digit(list->name)) | |
17632 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17633 | entry->style == |
17634 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17635 | ? "standard" |
17636 | : "(expanded) access", | |
17637 | list->name); | |
17638 | else | |
17639 | vty_out(vty, | |
17640 | "Named large community %s list %s\n", | |
169b72c8 | 17641 | entry->style == |
17642 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17643 | ? "standard" |
17644 | : "expanded", | |
17645 | list->name); | |
17646 | } | |
17647 | if (entry->any) | |
17648 | vty_out(vty, " %s\n", | |
17649 | community_direct_str(entry->direct)); | |
17650 | else | |
17651 | vty_out(vty, " %s %s\n", | |
17652 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17653 | community_list_config_str(entry)); |
d62a17ae | 17654 | } |
57d187bc JS |
17655 | } |
17656 | ||
7336e101 SP |
17657 | DEFUN (show_lcommunity_list, |
17658 | show_bgp_lcommunity_list_cmd, | |
17659 | "show bgp large-community-list", | |
57d187bc | 17660 | SHOW_STR |
7336e101 | 17661 | BGP_STR |
57d187bc JS |
17662 | "List large-community list\n") |
17663 | { | |
d62a17ae | 17664 | struct community_list *list; |
17665 | struct community_list_master *cm; | |
57d187bc | 17666 | |
d62a17ae | 17667 | cm = community_list_master_lookup(bgp_clist, |
17668 | LARGE_COMMUNITY_LIST_MASTER); | |
17669 | if (!cm) | |
17670 | return CMD_SUCCESS; | |
57d187bc | 17671 | |
d62a17ae | 17672 | for (list = cm->num.head; list; list = list->next) |
17673 | lcommunity_list_show(vty, list); | |
57d187bc | 17674 | |
d62a17ae | 17675 | for (list = cm->str.head; list; list = list->next) |
17676 | lcommunity_list_show(vty, list); | |
57d187bc | 17677 | |
d62a17ae | 17678 | return CMD_SUCCESS; |
57d187bc JS |
17679 | } |
17680 | ||
7336e101 SP |
17681 | DEFUN (show_lcommunity_list_arg, |
17682 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17683 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17684 | SHOW_STR |
17685 | BGP_STR | |
57d187bc | 17686 | "List large-community list\n" |
960b69b9 | 17687 | "Large-community-list number\n" |
17688 | "Large-community-list name\n" | |
17689 | "Detailed information on large-community-list\n") | |
57d187bc | 17690 | { |
d62a17ae | 17691 | struct community_list *list; |
57d187bc | 17692 | |
e237b0d2 | 17693 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17694 | LARGE_COMMUNITY_LIST_MASTER); |
17695 | if (!list) { | |
960b69b9 | 17696 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17697 | return CMD_WARNING; |
17698 | } | |
57d187bc | 17699 | |
d62a17ae | 17700 | lcommunity_list_show(vty, list); |
57d187bc | 17701 | |
d62a17ae | 17702 | return CMD_SUCCESS; |
57d187bc JS |
17703 | } |
17704 | ||
718e3744 | 17705 | /* "extcommunity-list" keyword help string. */ |
17706 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17707 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17708 | ||
7336e101 SP |
17709 | DEFUN (extcommunity_list_standard, |
17710 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17711 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17712 | BGP_STR |
718e3744 | 17713 | EXTCOMMUNITY_LIST_STR |
17714 | "Extended Community list number (standard)\n" | |
718e3744 | 17715 | "Specify standard extcommunity-list\n" |
5bf15956 | 17716 | "Community list name\n" |
2f8cc0e5 DA |
17717 | "Sequence number of an entry\n" |
17718 | "Sequence number\n" | |
718e3744 | 17719 | "Specify community to reject\n" |
17720 | "Specify community to accept\n" | |
17721 | EXTCOMMUNITY_VAL_STR) | |
17722 | { | |
d62a17ae | 17723 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17724 | int direct = 0; | |
17725 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17726 | char *seq = NULL; |
42f914d4 | 17727 | |
d62a17ae | 17728 | int idx = 0; |
7b9a4750 | 17729 | |
d62a17ae | 17730 | argv_find(argv, argc, "(1-99)", &idx); |
17731 | argv_find(argv, argc, "WORD", &idx); | |
17732 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17733 | |
409148f6 | 17734 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17735 | seq = argv[idx]->arg; |
17736 | ||
d62a17ae | 17737 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17738 | : COMMUNITY_DENY; | |
17739 | argv_find(argv, argc, "AA:NN", &idx); | |
17740 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17741 | |
2f8cc0e5 | 17742 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17743 | direct, style); |
42f914d4 | 17744 | |
d62a17ae | 17745 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17746 | |
d62a17ae | 17747 | if (ret < 0) { |
17748 | community_list_perror(vty, ret); | |
17749 | return CMD_WARNING_CONFIG_FAILED; | |
17750 | } | |
42f914d4 | 17751 | |
d62a17ae | 17752 | return CMD_SUCCESS; |
718e3744 | 17753 | } |
17754 | ||
7336e101 SP |
17755 | DEFUN (extcommunity_list_name_expanded, |
17756 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17757 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17758 | BGP_STR |
17759 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17760 | "Extended Community list number (expanded)\n" |
718e3744 | 17761 | "Specify expanded extcommunity-list\n" |
17762 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17763 | "Sequence number of an entry\n" |
17764 | "Sequence number\n" | |
718e3744 | 17765 | "Specify community to reject\n" |
17766 | "Specify community to accept\n" | |
17767 | "An ordered list as a regular-expression\n") | |
17768 | { | |
d62a17ae | 17769 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17770 | int direct = 0; | |
17771 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17772 | char *seq = NULL; |
d62a17ae | 17773 | int idx = 0; |
7336e101 | 17774 | |
d62a17ae | 17775 | argv_find(argv, argc, "(100-500)", &idx); |
17776 | argv_find(argv, argc, "WORD", &idx); | |
17777 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 | 17778 | |
409148f6 | 17779 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17780 | seq = argv[idx]->arg; |
17781 | ||
d62a17ae | 17782 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17783 | : COMMUNITY_DENY; | |
17784 | argv_find(argv, argc, "LINE", &idx); | |
17785 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17786 | |
2f8cc0e5 | 17787 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17788 | direct, style); |
42f914d4 | 17789 | |
d62a17ae | 17790 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17791 | |
d62a17ae | 17792 | if (ret < 0) { |
17793 | community_list_perror(vty, ret); | |
17794 | return CMD_WARNING_CONFIG_FAILED; | |
17795 | } | |
42f914d4 | 17796 | |
d62a17ae | 17797 | return CMD_SUCCESS; |
718e3744 | 17798 | } |
17799 | ||
7336e101 SP |
17800 | DEFUN (no_extcommunity_list_standard_all, |
17801 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17802 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17803 | NO_STR |
17804 | BGP_STR | |
17805 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17806 | "Extended Community list number (standard)\n" |
718e3744 | 17807 | "Specify standard extcommunity-list\n" |
5bf15956 | 17808 | "Community list name\n" |
2f8cc0e5 DA |
17809 | "Sequence number of an entry\n" |
17810 | "Sequence number\n" | |
718e3744 | 17811 | "Specify community to reject\n" |
17812 | "Specify community to accept\n" | |
17813 | EXTCOMMUNITY_VAL_STR) | |
17814 | { | |
d62a17ae | 17815 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17816 | int direct = 0; | |
17817 | char *cl_number_or_name = NULL; | |
d4455c89 | 17818 | char *str = NULL; |
2f8cc0e5 | 17819 | char *seq = NULL; |
d62a17ae | 17820 | int idx = 0; |
d4455c89 | 17821 | |
409148f6 | 17822 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17823 | seq = argv[idx]->arg; |
17824 | ||
17825 | idx = 0; | |
d4455c89 DA |
17826 | argv_find(argv, argc, "permit", &idx); |
17827 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17828 | if (idx) { |
17829 | direct = argv_find(argv, argc, "permit", &idx) | |
17830 | ? COMMUNITY_PERMIT | |
17831 | : COMMUNITY_DENY; | |
17832 | ||
17833 | idx = 0; | |
17834 | argv_find(argv, argc, "AA:NN", &idx); | |
17835 | str = argv_concat(argv, argc, idx); | |
17836 | } | |
17837 | ||
17838 | idx = 0; | |
d62a17ae | 17839 | argv_find(argv, argc, "(1-99)", &idx); |
17840 | argv_find(argv, argc, "WORD", &idx); | |
17841 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17842 | |
d62a17ae | 17843 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17844 | seq, direct, style); |
42f914d4 | 17845 | |
d62a17ae | 17846 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17847 | |
d62a17ae | 17848 | if (ret < 0) { |
17849 | community_list_perror(vty, ret); | |
17850 | return CMD_WARNING_CONFIG_FAILED; | |
17851 | } | |
42f914d4 | 17852 | |
d62a17ae | 17853 | return CMD_SUCCESS; |
718e3744 | 17854 | } |
17855 | ||
d4455c89 DA |
17856 | ALIAS(no_extcommunity_list_standard_all, |
17857 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17858 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17859 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17860 | "Extended Community list number (standard)\n" | |
17861 | "Specify standard extcommunity-list\n" | |
17862 | "Community list name\n") | |
17863 | ||
7336e101 SP |
17864 | DEFUN (no_extcommunity_list_expanded_all, |
17865 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 17866 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17867 | NO_STR |
17868 | BGP_STR | |
17869 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17870 | "Extended Community list number (expanded)\n" |
718e3744 | 17871 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17872 | "Extended Community list name\n" |
2f8cc0e5 DA |
17873 | "Sequence number of an entry\n" |
17874 | "Sequence number\n" | |
718e3744 | 17875 | "Specify community to reject\n" |
17876 | "Specify community to accept\n" | |
17877 | "An ordered list as a regular-expression\n") | |
17878 | { | |
d62a17ae | 17879 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17880 | int direct = 0; | |
17881 | char *cl_number_or_name = NULL; | |
d4455c89 | 17882 | char *str = NULL; |
2f8cc0e5 | 17883 | char *seq = NULL; |
d62a17ae | 17884 | int idx = 0; |
d4455c89 | 17885 | |
409148f6 | 17886 | if (argv_find(argv, argc, "(1-4294967295)", &idx)) |
2f8cc0e5 DA |
17887 | seq = argv[idx]->arg; |
17888 | ||
17889 | idx = 0; | |
d4455c89 DA |
17890 | argv_find(argv, argc, "permit", &idx); |
17891 | argv_find(argv, argc, "deny", &idx); | |
17892 | ||
17893 | if (idx) { | |
17894 | direct = argv_find(argv, argc, "permit", &idx) | |
17895 | ? COMMUNITY_PERMIT | |
17896 | : COMMUNITY_DENY; | |
17897 | ||
17898 | idx = 0; | |
17899 | argv_find(argv, argc, "LINE", &idx); | |
17900 | str = argv_concat(argv, argc, idx); | |
17901 | } | |
17902 | ||
17903 | idx = 0; | |
d62a17ae | 17904 | argv_find(argv, argc, "(100-500)", &idx); |
17905 | argv_find(argv, argc, "WORD", &idx); | |
17906 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17907 | |
d62a17ae | 17908 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17909 | seq, direct, style); |
42f914d4 | 17910 | |
d62a17ae | 17911 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17912 | |
d62a17ae | 17913 | if (ret < 0) { |
17914 | community_list_perror(vty, ret); | |
17915 | return CMD_WARNING_CONFIG_FAILED; | |
17916 | } | |
42f914d4 | 17917 | |
d62a17ae | 17918 | return CMD_SUCCESS; |
718e3744 | 17919 | } |
17920 | ||
d4455c89 DA |
17921 | ALIAS(no_extcommunity_list_expanded_all, |
17922 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17923 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17924 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17925 | "Extended Community list number (expanded)\n" | |
17926 | "Specify expanded extcommunity-list\n" | |
17927 | "Extended Community list name\n") | |
17928 | ||
d62a17ae | 17929 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17930 | { |
d62a17ae | 17931 | struct community_entry *entry; |
718e3744 | 17932 | |
d62a17ae | 17933 | for (entry = list->head; entry; entry = entry->next) { |
17934 | if (entry == list->head) { | |
17935 | if (all_digit(list->name)) | |
17936 | vty_out(vty, "Extended community %s list %s\n", | |
17937 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17938 | ? "standard" | |
17939 | : "(expanded) access", | |
17940 | list->name); | |
17941 | else | |
17942 | vty_out(vty, | |
17943 | "Named extended community %s list %s\n", | |
17944 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17945 | ? "standard" | |
17946 | : "expanded", | |
17947 | list->name); | |
17948 | } | |
17949 | if (entry->any) | |
17950 | vty_out(vty, " %s\n", | |
17951 | community_direct_str(entry->direct)); | |
17952 | else | |
17953 | vty_out(vty, " %s %s\n", | |
17954 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17955 | community_list_config_str(entry)); |
d62a17ae | 17956 | } |
718e3744 | 17957 | } |
17958 | ||
7336e101 SP |
17959 | DEFUN (show_extcommunity_list, |
17960 | show_bgp_extcommunity_list_cmd, | |
17961 | "show bgp extcommunity-list", | |
718e3744 | 17962 | SHOW_STR |
7336e101 | 17963 | BGP_STR |
718e3744 | 17964 | "List extended-community list\n") |
17965 | { | |
d62a17ae | 17966 | struct community_list *list; |
17967 | struct community_list_master *cm; | |
718e3744 | 17968 | |
d62a17ae | 17969 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17970 | if (!cm) | |
17971 | return CMD_SUCCESS; | |
718e3744 | 17972 | |
d62a17ae | 17973 | for (list = cm->num.head; list; list = list->next) |
17974 | extcommunity_list_show(vty, list); | |
718e3744 | 17975 | |
d62a17ae | 17976 | for (list = cm->str.head; list; list = list->next) |
17977 | extcommunity_list_show(vty, list); | |
718e3744 | 17978 | |
d62a17ae | 17979 | return CMD_SUCCESS; |
718e3744 | 17980 | } |
17981 | ||
7336e101 SP |
17982 | DEFUN (show_extcommunity_list_arg, |
17983 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17984 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17985 | SHOW_STR |
17986 | BGP_STR | |
718e3744 | 17987 | "List extended-community list\n" |
17988 | "Extcommunity-list number\n" | |
960b69b9 | 17989 | "Extcommunity-list name\n" |
17990 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17991 | { |
d62a17ae | 17992 | int idx_comm_list = 3; |
17993 | struct community_list *list; | |
718e3744 | 17994 | |
e237b0d2 | 17995 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17996 | EXTCOMMUNITY_LIST_MASTER); |
17997 | if (!list) { | |
17998 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17999 | return CMD_WARNING; | |
18000 | } | |
718e3744 | 18001 | |
d62a17ae | 18002 | extcommunity_list_show(vty, list); |
718e3744 | 18003 | |
d62a17ae | 18004 | return CMD_SUCCESS; |
718e3744 | 18005 | } |
6b0655a2 | 18006 | |
718e3744 | 18007 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 18008 | static int community_list_config_write(struct vty *vty) |
18009 | { | |
18010 | struct community_list *list; | |
18011 | struct community_entry *entry; | |
18012 | struct community_list_master *cm; | |
18013 | int write = 0; | |
18014 | ||
18015 | /* Community-list. */ | |
18016 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
18017 | ||
18018 | for (list = cm->num.head; list; list = list->next) | |
18019 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18020 | vty_out(vty, |
18021 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
18022 | list->name, entry->seq, | |
d62a17ae | 18023 | community_direct_str(entry->direct), |
18024 | community_list_config_str(entry)); | |
18025 | write++; | |
18026 | } | |
18027 | for (list = cm->str.head; list; list = list->next) | |
18028 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18029 | vty_out(vty, |
18030 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 18031 | entry->style == COMMUNITY_LIST_STANDARD |
18032 | ? "standard" | |
18033 | : "expanded", | |
2f8cc0e5 DA |
18034 | list->name, entry->seq, |
18035 | community_direct_str(entry->direct), | |
d62a17ae | 18036 | community_list_config_str(entry)); |
18037 | write++; | |
18038 | } | |
18039 | ||
18040 | /* Extcommunity-list. */ | |
18041 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
18042 | ||
18043 | for (list = cm->num.head; list; list = list->next) | |
18044 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18045 | vty_out(vty, |
18046 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
18047 | list->name, entry->seq, | |
18048 | community_direct_str(entry->direct), | |
d62a17ae | 18049 | community_list_config_str(entry)); |
18050 | write++; | |
18051 | } | |
18052 | for (list = cm->str.head; list; list = list->next) | |
18053 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18054 | vty_out(vty, |
18055 | "bgp extcommunity-list %s %s seq %" PRId64 | |
18056 | " %s %s\n", | |
d62a17ae | 18057 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
18058 | ? "standard" | |
18059 | : "expanded", | |
2f8cc0e5 DA |
18060 | list->name, entry->seq, |
18061 | community_direct_str(entry->direct), | |
d62a17ae | 18062 | community_list_config_str(entry)); |
18063 | write++; | |
18064 | } | |
18065 | ||
18066 | ||
18067 | /* lcommunity-list. */ | |
18068 | cm = community_list_master_lookup(bgp_clist, | |
18069 | LARGE_COMMUNITY_LIST_MASTER); | |
18070 | ||
18071 | for (list = cm->num.head; list; list = list->next) | |
18072 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18073 | vty_out(vty, |
18074 | "bgp large-community-list %s seq %" PRId64 | |
18075 | " %s %s\n", | |
18076 | list->name, entry->seq, | |
18077 | community_direct_str(entry->direct), | |
d62a17ae | 18078 | community_list_config_str(entry)); |
18079 | write++; | |
18080 | } | |
18081 | for (list = cm->str.head; list; list = list->next) | |
18082 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
18083 | vty_out(vty, |
18084 | "bgp large-community-list %s %s seq %" PRId64 | |
18085 | " %s %s\n", | |
18086 | ||
d62a17ae | 18087 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
18088 | ? "standard" | |
18089 | : "expanded", | |
2f8cc0e5 | 18090 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 18091 | community_list_config_str(entry)); |
18092 | write++; | |
18093 | } | |
18094 | ||
18095 | return write; | |
18096 | } | |
18097 | ||
612c2c15 | 18098 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 18099 | static struct cmd_node community_list_node = { |
f4b8291f | 18100 | .name = "community list", |
62b346ee DL |
18101 | .node = COMMUNITY_LIST_NODE, |
18102 | .prompt = "", | |
612c2c15 | 18103 | .config_write = community_list_config_write, |
718e3744 | 18104 | }; |
18105 | ||
d62a17ae | 18106 | static void community_list_vty(void) |
18107 | { | |
612c2c15 | 18108 | install_node(&community_list_node); |
d62a17ae | 18109 | |
18110 | /* Community-list. */ | |
7336e101 SP |
18111 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
18112 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
18113 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 18114 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 18115 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 18116 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
18117 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
18118 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 18119 | |
18120 | /* Extcommunity-list. */ | |
7336e101 SP |
18121 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
18122 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
18123 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
18124 | install_element(CONFIG_NODE, |
18125 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 18126 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
18127 | install_element(CONFIG_NODE, |
18128 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
18129 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
18130 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 18131 | |
18132 | /* Large Community List */ | |
7336e101 | 18133 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
18134 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
18135 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 18136 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
18137 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
18138 | install_element(CONFIG_NODE, | |
18139 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
18140 | install_element(CONFIG_NODE, |
18141 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
18142 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
18143 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
18144 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
18145 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
18146 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
18147 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 18148 | } |