]>
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, |
4c1458b5 DL |
76 | { .val_bool = true, .match_profile = "datacenter", }, |
77 | { .val_bool = false }, | |
5d5393b9 DL |
78 | ) |
79 | FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME, | |
4c1458b5 DL |
80 | { .val_bool = true, .match_profile = "datacenter", }, |
81 | { .val_bool = false }, | |
5d5393b9 DL |
82 | ) |
83 | FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES, | |
4c1458b5 DL |
84 | { .val_bool = true, .match_profile = "datacenter", }, |
85 | { .val_bool = false }, | |
5d5393b9 DL |
86 | ) |
87 | FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED, | |
4c1458b5 DL |
88 | { .val_bool = true, .match_profile = "datacenter", }, |
89 | { .val_bool = false }, | |
5d5393b9 DL |
90 | ) |
91 | FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY, | |
92 | { .val_ulong = 10, .match_profile = "datacenter", }, | |
93 | { .val_ulong = 120 }, | |
94 | ) | |
95 | FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME, | |
96 | { .val_ulong = 9, .match_profile = "datacenter", }, | |
97 | { .val_ulong = 180 }, | |
98 | ) | |
99 | FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE, | |
100 | { .val_ulong = 3, .match_profile = "datacenter", }, | |
101 | { .val_ulong = 60 }, | |
102 | ) | |
1d3fdccf DA |
103 | FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY, |
104 | { .val_bool = false, .match_profile = "datacenter", }, | |
105 | { .val_bool = false, .match_version = "< 7.4", }, | |
106 | { .val_bool = true }, | |
107 | ) | |
5d5393b9 | 108 | |
dd65f45e DL |
109 | DEFINE_HOOK(bgp_inst_config_write, |
110 | (struct bgp *bgp, struct vty *vty), | |
111 | (bgp, vty)) | |
718e3744 | 112 | |
36235319 QY |
113 | #define GR_NO_OPER \ |
114 | "The Graceful Restart No Operation was executed as cmd same as previous one." | |
115 | #define GR_INVALID \ | |
116 | "The Graceful Restart command used is not valid at this moment." | |
d62a17ae | 117 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
118 | struct prefix *range, int exact); | |
119 | ||
055679e9 | 120 | /* Show BGP peer's information. */ |
121 | enum show_type { | |
122 | show_all, | |
123 | show_peer, | |
124 | show_ipv4_all, | |
125 | show_ipv6_all, | |
126 | show_ipv4_peer, | |
127 | show_ipv6_peer | |
128 | }; | |
129 | ||
36235319 QY |
130 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
131 | struct prefix *range, int exact); | |
2986cac2 | 132 | |
36235319 QY |
133 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, |
134 | struct bgp *bgp, | |
135 | bool use_json, | |
136 | json_object *json); | |
2986cac2 | 137 | |
36235319 QY |
138 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
139 | enum show_type type, | |
140 | const char *ip_str, | |
141 | afi_t afi, bool use_json); | |
2986cac2 | 142 | |
d62a17ae | 143 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) |
144 | { | |
145 | switch (afi) { | |
146 | case AFI_IP: | |
147 | switch (safi) { | |
148 | case SAFI_UNICAST: | |
149 | return BGP_IPV4_NODE; | |
d62a17ae | 150 | case SAFI_MULTICAST: |
151 | return BGP_IPV4M_NODE; | |
d62a17ae | 152 | case SAFI_LABELED_UNICAST: |
153 | return BGP_IPV4L_NODE; | |
d62a17ae | 154 | case SAFI_MPLS_VPN: |
155 | return BGP_VPNV4_NODE; | |
7c40bf39 | 156 | case SAFI_FLOWSPEC: |
157 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
158 | default: |
159 | /* not expected */ | |
160 | return BGP_IPV4_NODE; | |
d62a17ae | 161 | } |
162 | break; | |
163 | case AFI_IP6: | |
164 | switch (safi) { | |
165 | case SAFI_UNICAST: | |
166 | return BGP_IPV6_NODE; | |
d62a17ae | 167 | case SAFI_MULTICAST: |
168 | return BGP_IPV6M_NODE; | |
d62a17ae | 169 | case SAFI_LABELED_UNICAST: |
170 | return BGP_IPV6L_NODE; | |
d62a17ae | 171 | case SAFI_MPLS_VPN: |
172 | return BGP_VPNV6_NODE; | |
7c40bf39 | 173 | case SAFI_FLOWSPEC: |
174 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
175 | default: |
176 | /* not expected */ | |
177 | return BGP_IPV4_NODE; | |
d62a17ae | 178 | } |
179 | break; | |
180 | case AFI_L2VPN: | |
181 | return BGP_EVPN_NODE; | |
b26f891d | 182 | case AFI_UNSPEC: |
d62a17ae | 183 | case AFI_MAX: |
184 | // We should never be here but to clarify the switch statement.. | |
185 | return BGP_IPV4_NODE; | |
d62a17ae | 186 | } |
187 | ||
188 | // Impossible to happen | |
189 | return BGP_IPV4_NODE; | |
f51bae9c | 190 | } |
20eb8864 | 191 | |
5cb5f4d0 DD |
192 | static const char *get_afi_safi_vty_str(afi_t afi, safi_t safi) |
193 | { | |
194 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
195 | return "IPv4 Unicast"; | |
196 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
197 | return "IPv4 Multicast"; | |
198 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
199 | return "IPv4 Labeled Unicast"; | |
200 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
201 | return "IPv4 VPN"; | |
202 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
203 | return "IPv4 Encap"; | |
204 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
205 | return "IPv4 Flowspec"; | |
206 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
207 | return "IPv6 Unicast"; | |
208 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
209 | return "IPv6 Multicast"; | |
210 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
211 | return "IPv6 Labeled Unicast"; | |
212 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
213 | return "IPv6 VPN"; | |
214 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
215 | return "IPv6 Encap"; | |
216 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
217 | return "IPv6 Flowspec"; | |
218 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
219 | return "L2VPN EVPN"; | |
8e5509b0 | 220 | else |
5cb5f4d0 | 221 | return "Unknown"; |
5cb5f4d0 DD |
222 | } |
223 | ||
224 | /* | |
225 | * Please note that we have intentionally camelCased | |
226 | * the return strings here. So if you want | |
227 | * to use this function, please ensure you | |
228 | * are doing this within json output | |
229 | */ | |
230 | static const char *get_afi_safi_json_str(afi_t afi, safi_t safi) | |
231 | { | |
232 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
233 | return "ipv4Unicast"; | |
234 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
235 | return "ipv4Multicast"; | |
236 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
237 | return "ipv4LabeledUnicast"; | |
238 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
239 | return "ipv4Vpn"; | |
240 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
241 | return "ipv4Encap"; | |
242 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) | |
243 | return "ipv4Flowspec"; | |
244 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
245 | return "ipv6Unicast"; | |
246 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
247 | return "ipv6Multicast"; | |
248 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
249 | return "ipv6LabeledUnicast"; | |
250 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
251 | return "ipv6Vpn"; | |
252 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
253 | return "ipv6Encap"; | |
254 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) | |
255 | return "ipv6Flowspec"; | |
256 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
257 | return "l2VpnEvpn"; | |
8e5509b0 | 258 | else |
5cb5f4d0 | 259 | return "Unknown"; |
5cb5f4d0 DD |
260 | } |
261 | ||
718e3744 | 262 | /* Utility function to get address family from current node. */ |
d62a17ae | 263 | afi_t bgp_node_afi(struct vty *vty) |
264 | { | |
265 | afi_t afi; | |
266 | switch (vty->node) { | |
267 | case BGP_IPV6_NODE: | |
268 | case BGP_IPV6M_NODE: | |
269 | case BGP_IPV6L_NODE: | |
270 | case BGP_VPNV6_NODE: | |
7c40bf39 | 271 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 272 | afi = AFI_IP6; |
273 | break; | |
274 | case BGP_EVPN_NODE: | |
275 | afi = AFI_L2VPN; | |
276 | break; | |
277 | default: | |
278 | afi = AFI_IP; | |
279 | break; | |
280 | } | |
281 | return afi; | |
718e3744 | 282 | } |
283 | ||
284 | /* Utility function to get subsequent address family from current | |
285 | node. */ | |
d62a17ae | 286 | safi_t bgp_node_safi(struct vty *vty) |
287 | { | |
288 | safi_t safi; | |
289 | switch (vty->node) { | |
290 | case BGP_VPNV4_NODE: | |
291 | case BGP_VPNV6_NODE: | |
292 | safi = SAFI_MPLS_VPN; | |
293 | break; | |
294 | case BGP_IPV4M_NODE: | |
295 | case BGP_IPV6M_NODE: | |
296 | safi = SAFI_MULTICAST; | |
297 | break; | |
298 | case BGP_EVPN_NODE: | |
299 | safi = SAFI_EVPN; | |
300 | break; | |
301 | case BGP_IPV4L_NODE: | |
302 | case BGP_IPV6L_NODE: | |
303 | safi = SAFI_LABELED_UNICAST; | |
304 | break; | |
7c40bf39 | 305 | case BGP_FLOWSPECV4_NODE: |
306 | case BGP_FLOWSPECV6_NODE: | |
307 | safi = SAFI_FLOWSPEC; | |
308 | break; | |
d62a17ae | 309 | default: |
310 | safi = SAFI_UNICAST; | |
311 | break; | |
312 | } | |
313 | return safi; | |
718e3744 | 314 | } |
315 | ||
55f91488 QY |
316 | /** |
317 | * Converts an AFI in string form to afi_t | |
318 | * | |
319 | * @param afi string, one of | |
320 | * - "ipv4" | |
321 | * - "ipv6" | |
81cf0de5 | 322 | * - "l2vpn" |
55f91488 QY |
323 | * @return the corresponding afi_t |
324 | */ | |
d62a17ae | 325 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
326 | { | |
327 | afi_t afi = AFI_MAX; /* unknown */ | |
328 | if (strmatch(afi_str, "ipv4")) | |
329 | afi = AFI_IP; | |
330 | else if (strmatch(afi_str, "ipv6")) | |
331 | afi = AFI_IP6; | |
81cf0de5 CS |
332 | else if (strmatch(afi_str, "l2vpn")) |
333 | afi = AFI_L2VPN; | |
d62a17ae | 334 | return afi; |
335 | } | |
336 | ||
337 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
338 | afi_t *afi) | |
339 | { | |
340 | int ret = 0; | |
341 | if (argv_find(argv, argc, "ipv4", index)) { | |
342 | ret = 1; | |
343 | if (afi) | |
344 | *afi = AFI_IP; | |
345 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
346 | ret = 1; | |
347 | if (afi) | |
348 | *afi = AFI_IP6; | |
8688b3e7 DS |
349 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
350 | ret = 1; | |
351 | if (afi) | |
352 | *afi = AFI_L2VPN; | |
d62a17ae | 353 | } |
354 | return ret; | |
46f296b4 LB |
355 | } |
356 | ||
375a2e67 | 357 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 358 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
359 | { | |
360 | safi_t safi = SAFI_MAX; /* unknown */ | |
361 | if (strmatch(safi_str, "multicast")) | |
362 | safi = SAFI_MULTICAST; | |
363 | else if (strmatch(safi_str, "unicast")) | |
364 | safi = SAFI_UNICAST; | |
365 | else if (strmatch(safi_str, "vpn")) | |
366 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
367 | else if (strmatch(safi_str, "evpn")) |
368 | safi = SAFI_EVPN; | |
d62a17ae | 369 | else if (strmatch(safi_str, "labeled-unicast")) |
370 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 371 | else if (strmatch(safi_str, "flowspec")) |
372 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 373 | return safi; |
374 | } | |
375 | ||
376 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
377 | safi_t *safi) | |
378 | { | |
379 | int ret = 0; | |
380 | if (argv_find(argv, argc, "unicast", index)) { | |
381 | ret = 1; | |
382 | if (safi) | |
383 | *safi = SAFI_UNICAST; | |
384 | } else if (argv_find(argv, argc, "multicast", index)) { | |
385 | ret = 1; | |
386 | if (safi) | |
387 | *safi = SAFI_MULTICAST; | |
388 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
389 | ret = 1; | |
390 | if (safi) | |
391 | *safi = SAFI_LABELED_UNICAST; | |
392 | } else if (argv_find(argv, argc, "vpn", index)) { | |
393 | ret = 1; | |
394 | if (safi) | |
395 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
396 | } else if (argv_find(argv, argc, "evpn", index)) { |
397 | ret = 1; | |
398 | if (safi) | |
399 | *safi = SAFI_EVPN; | |
7c40bf39 | 400 | } else if (argv_find(argv, argc, "flowspec", index)) { |
401 | ret = 1; | |
402 | if (safi) | |
403 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 404 | } |
405 | return ret; | |
46f296b4 LB |
406 | } |
407 | ||
5d5393b9 DL |
408 | int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name, |
409 | enum bgp_instance_type inst_type) | |
410 | { | |
411 | int ret = bgp_get(bgp, as, name, inst_type); | |
412 | ||
413 | if (ret == BGP_CREATED) { | |
414 | bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, | |
415 | DFLT_BGP_CONNECT_RETRY); | |
416 | ||
417 | if (DFLT_BGP_IMPORT_CHECK) | |
892fedb6 | 418 | SET_FLAG((*bgp)->flags, BGP_FLAG_IMPORT_CHECK); |
5d5393b9 | 419 | if (DFLT_BGP_SHOW_HOSTNAME) |
892fedb6 | 420 | SET_FLAG((*bgp)->flags, BGP_FLAG_SHOW_HOSTNAME); |
5d5393b9 | 421 | if (DFLT_BGP_LOG_NEIGHBOR_CHANGES) |
892fedb6 | 422 | SET_FLAG((*bgp)->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
5d5393b9 | 423 | if (DFLT_BGP_DETERMINISTIC_MED) |
892fedb6 | 424 | SET_FLAG((*bgp)->flags, BGP_FLAG_DETERMINISTIC_MED); |
1d3fdccf DA |
425 | if (DFLT_BGP_EBGP_REQUIRES_POLICY) |
426 | SET_FLAG((*bgp)->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); | |
5d5393b9 DL |
427 | |
428 | ret = BGP_SUCCESS; | |
429 | } | |
430 | return ret; | |
431 | } | |
432 | ||
7eeee51e | 433 | /* |
f212a857 | 434 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 435 | * |
f212a857 DS |
436 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
437 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
438 | * to appropriate values for the calling function. This is to allow the |
439 | * calling function to make decisions appropriate for the show command | |
440 | * that is being parsed. | |
441 | * | |
442 | * The show commands are generally of the form: | |
d62a17ae | 443 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
444 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
445 | * |
446 | * Since we use argv_find if the show command in particular doesn't have: | |
447 | * [ip] | |
18c57037 | 448 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 449 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
450 | * The command parsing should still be ok. |
451 | * | |
452 | * vty -> The vty for the command so we can output some useful data in | |
453 | * the event of a parse error in the vrf. | |
454 | * argv -> The command tokens | |
455 | * argc -> How many command tokens we have | |
d62a17ae | 456 | * idx -> The current place in the command, generally should be 0 for this |
457 | * function | |
7eeee51e DS |
458 | * afi -> The parsed afi if it was included in the show command, returned here |
459 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 460 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 461 | * use_json -> json is configured or not |
7eeee51e DS |
462 | * |
463 | * The function returns the correct location in the parse tree for the | |
464 | * last token found. | |
0e37c258 DS |
465 | * |
466 | * Returns 0 for failure to parse correctly, else the idx position of where | |
467 | * it found the last token. | |
7eeee51e | 468 | */ |
d62a17ae | 469 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
470 | struct cmd_token **argv, int argc, | |
471 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 472 | struct bgp **bgp, bool use_json) |
d62a17ae | 473 | { |
474 | char *vrf_name = NULL; | |
475 | ||
476 | assert(afi); | |
477 | assert(safi); | |
478 | assert(bgp); | |
479 | ||
480 | if (argv_find(argv, argc, "ip", idx)) | |
481 | *afi = AFI_IP; | |
482 | ||
9a8bdf1c | 483 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 484 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
485 | else if (argv_find(argv, argc, "vrf", idx)) { |
486 | vrf_name = argv[*idx + 1]->arg; | |
487 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
488 | vrf_name = NULL; | |
489 | } | |
490 | if (vrf_name) { | |
d62a17ae | 491 | if (strmatch(vrf_name, "all")) |
492 | *bgp = NULL; | |
493 | else { | |
494 | *bgp = bgp_lookup_by_name(vrf_name); | |
495 | if (!*bgp) { | |
52e5b8c4 SP |
496 | if (use_json) { |
497 | json_object *json = NULL; | |
498 | json = json_object_new_object(); | |
499 | json_object_string_add( | |
500 | json, "warning", | |
501 | "View/Vrf is unknown"); | |
502 | vty_out(vty, "%s\n", | |
503 | json_object_to_json_string_ext(json, | |
504 | JSON_C_TO_STRING_PRETTY)); | |
505 | json_object_free(json); | |
506 | } | |
ca61fd25 DS |
507 | else |
508 | vty_out(vty, "View/Vrf %s is unknown\n", | |
509 | vrf_name); | |
d62a17ae | 510 | *idx = 0; |
511 | return 0; | |
512 | } | |
513 | } | |
514 | } else { | |
515 | *bgp = bgp_get_default(); | |
516 | if (!*bgp) { | |
52e5b8c4 SP |
517 | if (use_json) { |
518 | json_object *json = NULL; | |
519 | json = json_object_new_object(); | |
520 | json_object_string_add( | |
521 | json, "warning", | |
522 | "Default BGP instance not found"); | |
523 | vty_out(vty, "%s\n", | |
524 | json_object_to_json_string_ext(json, | |
525 | JSON_C_TO_STRING_PRETTY)); | |
526 | json_object_free(json); | |
527 | } | |
ca61fd25 DS |
528 | else |
529 | vty_out(vty, | |
530 | "Default BGP instance not found\n"); | |
d62a17ae | 531 | *idx = 0; |
532 | return 0; | |
533 | } | |
534 | } | |
535 | ||
536 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
537 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
538 | ||
539 | *idx += 1; | |
540 | return *idx; | |
541 | } | |
542 | ||
3dc339cd | 543 | static bool peer_address_self_check(struct bgp *bgp, union sockunion *su) |
d62a17ae | 544 | { |
545 | struct interface *ifp = NULL; | |
546 | ||
547 | if (su->sa.sa_family == AF_INET) | |
548 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
549 | else if (su->sa.sa_family == AF_INET6) | |
550 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
551 | su->sin6.sin6_scope_id, | |
552 | bgp->vrf_id); | |
553 | ||
554 | if (ifp) | |
3dc339cd | 555 | return true; |
d62a17ae | 556 | |
3dc339cd | 557 | return false; |
718e3744 | 558 | } |
559 | ||
560 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
561 | /* This is used only for configuration, so disallow if attempted on |
562 | * a dynamic neighbor. | |
563 | */ | |
d62a17ae | 564 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
565 | { | |
566 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
567 | int ret; | |
568 | union sockunion su; | |
569 | struct peer *peer; | |
570 | ||
571 | if (!bgp) { | |
572 | return NULL; | |
573 | } | |
574 | ||
575 | ret = str2sockunion(ip_str, &su); | |
576 | if (ret < 0) { | |
577 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
578 | if (!peer) { | |
579 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
580 | == NULL) { | |
581 | vty_out(vty, | |
582 | "%% Malformed address or name: %s\n", | |
583 | ip_str); | |
584 | return NULL; | |
585 | } | |
586 | } | |
587 | } else { | |
588 | peer = peer_lookup(bgp, &su); | |
589 | if (!peer) { | |
590 | vty_out(vty, | |
591 | "%% Specify remote-as or peer-group commands first\n"); | |
592 | return NULL; | |
593 | } | |
594 | if (peer_dynamic_neighbor(peer)) { | |
595 | vty_out(vty, | |
596 | "%% Operation not allowed on a dynamic neighbor\n"); | |
597 | return NULL; | |
598 | } | |
599 | } | |
600 | return peer; | |
718e3744 | 601 | } |
602 | ||
603 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
604 | /* This is used only for configuration, so disallow if attempted on |
605 | * a dynamic neighbor. | |
606 | */ | |
d62a17ae | 607 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
608 | { | |
609 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
610 | int ret; | |
611 | union sockunion su; | |
612 | struct peer *peer = NULL; | |
613 | struct peer_group *group = NULL; | |
614 | ||
615 | if (!bgp) { | |
616 | return NULL; | |
617 | } | |
618 | ||
619 | ret = str2sockunion(peer_str, &su); | |
620 | if (ret == 0) { | |
621 | /* IP address, locate peer. */ | |
622 | peer = peer_lookup(bgp, &su); | |
623 | } else { | |
624 | /* Not IP, could match either peer configured on interface or a | |
625 | * group. */ | |
626 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
627 | if (!peer) | |
628 | group = peer_group_lookup(bgp, peer_str); | |
629 | } | |
630 | ||
631 | if (peer) { | |
632 | if (peer_dynamic_neighbor(peer)) { | |
633 | vty_out(vty, | |
634 | "%% Operation not allowed on a dynamic neighbor\n"); | |
635 | return NULL; | |
636 | } | |
637 | ||
638 | return peer; | |
639 | } | |
640 | ||
641 | if (group) | |
642 | return group->conf; | |
643 | ||
644 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
645 | ||
646 | return NULL; | |
647 | } | |
648 | ||
649 | int bgp_vty_return(struct vty *vty, int ret) | |
650 | { | |
651 | const char *str = NULL; | |
652 | ||
653 | switch (ret) { | |
654 | case BGP_ERR_INVALID_VALUE: | |
655 | str = "Invalid value"; | |
656 | break; | |
657 | case BGP_ERR_INVALID_FLAG: | |
658 | str = "Invalid flag"; | |
659 | break; | |
660 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
661 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
662 | break; | |
663 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
664 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
665 | break; | |
666 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
667 | str = "Specify remote-as or peer-group remote AS first"; | |
668 | break; | |
669 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
670 | str = "Cannot change the peer-group. Deconfigure first"; | |
671 | break; | |
672 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
673 | str = "Peer is not a member of this peer-group"; | |
674 | break; | |
675 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
676 | str = "Prefix/distribute list can not co-exist"; | |
677 | break; | |
678 | case BGP_ERR_NOT_INTERNAL_PEER: | |
679 | str = "Invalid command. Not an internal neighbor"; | |
680 | break; | |
681 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
682 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
683 | break; | |
684 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
685 | str = "Local-AS allowed only for EBGP peers"; | |
686 | break; | |
687 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
688 | str = "Cannot have local-as same as BGP AS number"; | |
689 | break; | |
690 | case BGP_ERR_TCPSIG_FAILED: | |
691 | str = "Error while applying TCP-Sig to session(s)"; | |
692 | break; | |
693 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
694 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
695 | break; | |
696 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
697 | str = "ttl-security only allowed for EBGP peers"; | |
698 | break; | |
699 | case BGP_ERR_AS_OVERRIDE: | |
700 | str = "as-override cannot be configured for IBGP peers"; | |
701 | break; | |
702 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
703 | str = "Invalid limit for number of dynamic neighbors"; | |
704 | break; | |
705 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
706 | str = "Dynamic neighbor listen range already exists"; | |
707 | break; | |
708 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
709 | str = "Operation not allowed on a dynamic neighbor"; | |
710 | break; | |
711 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
712 | str = "Operation not allowed on a directly connected neighbor"; | |
713 | break; | |
714 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
055679e9 | 715 | str = GR_INVALID; |
716 | break; | |
717 | case BGP_ERR_GR_INVALID_CMD: | |
718 | str = "The Graceful Restart command used is not valid at this moment."; | |
719 | break; | |
720 | case BGP_ERR_GR_OPERATION_FAILED: | |
721 | str = "The Graceful Restart Operation failed due to an err."; | |
722 | break; | |
723 | case BGP_GR_NO_OPERATION: | |
724 | str = GR_NO_OPER; | |
d62a17ae | 725 | break; |
726 | } | |
727 | if (str) { | |
728 | vty_out(vty, "%% %s\n", str); | |
729 | return CMD_WARNING_CONFIG_FAILED; | |
730 | } | |
731 | return CMD_SUCCESS; | |
718e3744 | 732 | } |
733 | ||
7aafcaca | 734 | /* BGP clear sort. */ |
d62a17ae | 735 | enum clear_sort { |
736 | clear_all, | |
737 | clear_peer, | |
738 | clear_group, | |
739 | clear_external, | |
740 | clear_as | |
7aafcaca DS |
741 | }; |
742 | ||
d62a17ae | 743 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
744 | safi_t safi, int error) | |
745 | { | |
746 | switch (error) { | |
747 | case BGP_ERR_AF_UNCONFIGURED: | |
748 | vty_out(vty, | |
749 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
5cb5f4d0 | 750 | get_afi_safi_str(afi, safi, false), peer->host); |
d62a17ae | 751 | break; |
752 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
753 | vty_out(vty, | |
754 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
755 | peer->host); | |
756 | break; | |
757 | default: | |
758 | break; | |
759 | } | |
7aafcaca DS |
760 | } |
761 | ||
dc912615 | 762 | static int bgp_peer_clear(struct peer *peer, afi_t afi, safi_t safi, |
c368171c | 763 | struct listnode **nnode, enum bgp_clear_type stype) |
dc912615 DS |
764 | { |
765 | int ret = 0; | |
766 | ||
767 | /* if afi/.safi not specified, spin thru all of them */ | |
768 | if ((afi == AFI_UNSPEC) && (safi == SAFI_UNSPEC)) { | |
769 | afi_t tmp_afi; | |
770 | safi_t tmp_safi; | |
771 | ||
772 | FOREACH_AFI_SAFI (tmp_afi, tmp_safi) { | |
773 | if (!peer->afc[tmp_afi][tmp_safi]) | |
774 | continue; | |
775 | ||
776 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 777 | ret = peer_clear(peer, nnode); |
dc912615 DS |
778 | else |
779 | ret = peer_clear_soft(peer, tmp_afi, tmp_safi, | |
780 | stype); | |
781 | } | |
782 | /* if afi specified and safi not, spin thru safis on this afi */ | |
783 | } else if (safi == SAFI_UNSPEC) { | |
784 | safi_t tmp_safi; | |
785 | ||
786 | for (tmp_safi = SAFI_UNICAST; | |
787 | tmp_safi < SAFI_MAX; tmp_safi++) { | |
788 | if (!peer->afc[afi][tmp_safi]) | |
789 | continue; | |
790 | ||
791 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 792 | ret = peer_clear(peer, nnode); |
dc912615 DS |
793 | else |
794 | ret = peer_clear_soft(peer, afi, | |
795 | tmp_safi, stype); | |
796 | } | |
797 | /* both afi/safi specified, let the caller know if not defined */ | |
798 | } else { | |
799 | if (!peer->afc[afi][safi]) | |
800 | return 1; | |
801 | ||
802 | if (stype == BGP_CLEAR_SOFT_NONE) | |
c368171c | 803 | ret = peer_clear(peer, nnode); |
dc912615 DS |
804 | else |
805 | ret = peer_clear_soft(peer, afi, safi, stype); | |
806 | } | |
807 | ||
808 | return ret; | |
809 | } | |
810 | ||
7aafcaca | 811 | /* `clear ip bgp' functions. */ |
d62a17ae | 812 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
813 | enum clear_sort sort, enum bgp_clear_type stype, | |
814 | const char *arg) | |
815 | { | |
dc912615 | 816 | int ret = 0; |
3ae8bfa5 | 817 | bool found = false; |
d62a17ae | 818 | struct peer *peer; |
dc95985f | 819 | |
820 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; | |
d62a17ae | 821 | |
822 | /* Clear all neighbors. */ | |
823 | /* | |
824 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
825 | * nodes on the BGP instance as that may get freed if it is a |
826 | * doppelganger | |
d62a17ae | 827 | */ |
828 | if (sort == clear_all) { | |
829 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
dc95985f | 830 | |
831 | bgp_peer_gr_flags_update(peer); | |
832 | ||
36235319 | 833 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
dc95985f | 834 | gr_router_detected = true; |
835 | ||
c368171c | 836 | ret = bgp_peer_clear(peer, afi, safi, &nnode, |
dc912615 | 837 | stype); |
d62a17ae | 838 | |
839 | if (ret < 0) | |
840 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
dc95985f | 841 | } |
842 | ||
36235319 QY |
843 | if (gr_router_detected |
844 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 845 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
846 | } else if (!gr_router_detected |
847 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 848 | bgp_zebra_send_capabilities(bgp, true); |
04b6bdc0 | 849 | } |
d62a17ae | 850 | |
851 | /* This is to apply read-only mode on this clear. */ | |
852 | if (stype == BGP_CLEAR_SOFT_NONE) | |
853 | bgp->update_delay_over = 0; | |
854 | ||
855 | return CMD_SUCCESS; | |
7aafcaca DS |
856 | } |
857 | ||
3ae8bfa5 | 858 | /* Clear specified neighbor. */ |
d62a17ae | 859 | if (sort == clear_peer) { |
860 | union sockunion su; | |
d62a17ae | 861 | |
862 | /* Make sockunion for lookup. */ | |
863 | ret = str2sockunion(arg, &su); | |
864 | if (ret < 0) { | |
865 | peer = peer_lookup_by_conf_if(bgp, arg); | |
866 | if (!peer) { | |
867 | peer = peer_lookup_by_hostname(bgp, arg); | |
868 | if (!peer) { | |
869 | vty_out(vty, | |
870 | "Malformed address or name: %s\n", | |
871 | arg); | |
872 | return CMD_WARNING; | |
873 | } | |
874 | } | |
875 | } else { | |
876 | peer = peer_lookup(bgp, &su); | |
877 | if (!peer) { | |
878 | vty_out(vty, | |
879 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
880 | arg); | |
881 | return CMD_WARNING; | |
882 | } | |
883 | } | |
7aafcaca | 884 | |
dc95985f | 885 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
886 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
887 | ||
dc912615 DS |
888 | ret = bgp_peer_clear(peer, afi, safi, NULL, stype); |
889 | ||
890 | /* if afi/safi not defined for this peer, let caller know */ | |
891 | if (ret == 1) | |
3ae8bfa5 | 892 | ret = BGP_ERR_AF_UNCONFIGURED; |
7aafcaca | 893 | |
d62a17ae | 894 | if (ret < 0) |
895 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 896 | |
d62a17ae | 897 | return CMD_SUCCESS; |
7aafcaca | 898 | } |
7aafcaca | 899 | |
3ae8bfa5 | 900 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 901 | if (sort == clear_group) { |
902 | struct peer_group *group; | |
7aafcaca | 903 | |
d62a17ae | 904 | group = peer_group_lookup(bgp, arg); |
905 | if (!group) { | |
906 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
907 | return CMD_WARNING; | |
908 | } | |
909 | ||
910 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
c368171c | 911 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 912 | |
d62a17ae | 913 | if (ret < 0) |
914 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
915 | else |
916 | found = true; | |
d62a17ae | 917 | } |
3ae8bfa5 PM |
918 | |
919 | if (!found) | |
920 | vty_out(vty, | |
921 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
5cb5f4d0 | 922 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 923 | |
d62a17ae | 924 | return CMD_SUCCESS; |
7aafcaca | 925 | } |
7aafcaca | 926 | |
3ae8bfa5 | 927 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 928 | if (sort == clear_external) { |
929 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
930 | if (peer->sort == BGP_PEER_IBGP) | |
931 | continue; | |
7aafcaca | 932 | |
dc95985f | 933 | bgp_peer_gr_flags_update(peer); |
934 | ||
36235319 | 935 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 936 | gr_router_detected = true; |
dc95985f | 937 | |
c368171c | 938 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
7aafcaca | 939 | |
d62a17ae | 940 | if (ret < 0) |
941 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
942 | else |
943 | found = true; | |
d62a17ae | 944 | } |
3ae8bfa5 | 945 | |
36235319 QY |
946 | if (gr_router_detected |
947 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 948 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
949 | } else if (!gr_router_detected |
950 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 951 | bgp_zebra_send_capabilities(bgp, true); |
952 | } | |
953 | ||
3ae8bfa5 PM |
954 | if (!found) |
955 | vty_out(vty, | |
956 | "%%BGP: No external %s peer is configured\n", | |
5cb5f4d0 | 957 | get_afi_safi_str(afi, safi, false)); |
3ae8bfa5 | 958 | |
d62a17ae | 959 | return CMD_SUCCESS; |
960 | } | |
961 | ||
3ae8bfa5 | 962 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 963 | if (sort == clear_as) { |
3ae8bfa5 | 964 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 965 | |
966 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
967 | if (peer->as != as) | |
968 | continue; | |
969 | ||
dc95985f | 970 | bgp_peer_gr_flags_update(peer); |
971 | ||
36235319 | 972 | if (CHECK_FLAG(peer->flags, PEER_FLAG_GRACEFUL_RESTART)) |
2ba1fe69 | 973 | gr_router_detected = true; |
dc95985f | 974 | |
c368171c | 975 | ret = bgp_peer_clear(peer, afi, safi, &nnode, stype); |
d62a17ae | 976 | |
977 | if (ret < 0) | |
978 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
979 | else |
980 | found = true; | |
d62a17ae | 981 | } |
3ae8bfa5 | 982 | |
36235319 QY |
983 | if (gr_router_detected |
984 | && bgp->present_zebra_gr_state == ZEBRA_GR_DISABLE) { | |
dc95985f | 985 | bgp_zebra_send_capabilities(bgp, false); |
36235319 QY |
986 | } else if (!gr_router_detected |
987 | && bgp->present_zebra_gr_state == ZEBRA_GR_ENABLE) { | |
dc95985f | 988 | bgp_zebra_send_capabilities(bgp, true); |
989 | } | |
990 | ||
3ae8bfa5 | 991 | if (!found) |
d62a17ae | 992 | vty_out(vty, |
3ae8bfa5 | 993 | "%%BGP: No %s peer is configured with AS %s\n", |
5cb5f4d0 | 994 | get_afi_safi_str(afi, safi, false), arg); |
3ae8bfa5 | 995 | |
d62a17ae | 996 | return CMD_SUCCESS; |
997 | } | |
998 | ||
999 | return CMD_SUCCESS; | |
1000 | } | |
1001 | ||
1002 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
1003 | safi_t safi, enum clear_sort sort, | |
1004 | enum bgp_clear_type stype, const char *arg) | |
1005 | { | |
1006 | struct bgp *bgp; | |
1007 | ||
1008 | /* BGP structure lookup. */ | |
1009 | if (name) { | |
1010 | bgp = bgp_lookup_by_name(name); | |
1011 | if (bgp == NULL) { | |
1012 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
1013 | return CMD_WARNING; | |
1014 | } | |
1015 | } else { | |
1016 | bgp = bgp_get_default(); | |
1017 | if (bgp == NULL) { | |
1018 | vty_out(vty, "No BGP process is configured\n"); | |
1019 | return CMD_WARNING; | |
1020 | } | |
1021 | } | |
1022 | ||
1023 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
1024 | } |
1025 | ||
1026 | /* clear soft inbound */ | |
d62a17ae | 1027 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 1028 | { |
99b3ebd3 NS |
1029 | afi_t afi; |
1030 | safi_t safi; | |
1031 | ||
1032 | FOREACH_AFI_SAFI (afi, safi) | |
1033 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1034 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
1035 | } |
1036 | ||
1037 | /* clear soft outbound */ | |
d62a17ae | 1038 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 1039 | { |
99b3ebd3 NS |
1040 | afi_t afi; |
1041 | safi_t safi; | |
1042 | ||
1043 | FOREACH_AFI_SAFI (afi, safi) | |
1044 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
1045 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
1046 | } |
1047 | ||
1048 | ||
f787d7a0 | 1049 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 1050 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
1051 | #endif |
1052 | ||
8029b216 AK |
1053 | DEFUN_HIDDEN (bgp_local_mac, |
1054 | bgp_local_mac_cmd, | |
093e3f23 | 1055 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
1056 | BGP_STR |
1057 | "Local MAC config\n" | |
1058 | "VxLAN Network Identifier\n" | |
1059 | "VNI number\n" | |
1060 | "local mac\n" | |
1061 | "mac address\n" | |
1062 | "mac-mobility sequence\n" | |
1063 | "seq number\n") | |
1064 | { | |
1065 | int rv; | |
1066 | vni_t vni; | |
1067 | struct ethaddr mac; | |
1068 | struct ipaddr ip; | |
1069 | uint32_t seq; | |
1070 | struct bgp *bgp; | |
1071 | ||
1072 | vni = strtoul(argv[3]->arg, NULL, 10); | |
1073 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
1074 | vty_out(vty, "%% Malformed MAC address\n"); | |
1075 | return CMD_WARNING; | |
1076 | } | |
1077 | memset(&ip, 0, sizeof(ip)); | |
1078 | seq = strtoul(argv[7]->arg, NULL, 10); | |
1079 | ||
1080 | bgp = bgp_get_default(); | |
1081 | if (!bgp) { | |
1082 | vty_out(vty, "Default BGP instance is not there\n"); | |
1083 | return CMD_WARNING; | |
1084 | } | |
1085 | ||
1086 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
1087 | if (rv < 0) { | |
1088 | vty_out(vty, "Internal error\n"); | |
1089 | return CMD_WARNING; | |
1090 | } | |
1091 | ||
1092 | return CMD_SUCCESS; | |
1093 | } | |
1094 | ||
1095 | DEFUN_HIDDEN (no_bgp_local_mac, | |
1096 | no_bgp_local_mac_cmd, | |
093e3f23 | 1097 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
1098 | NO_STR |
1099 | BGP_STR | |
1100 | "Local MAC config\n" | |
1101 | "VxLAN Network Identifier\n" | |
1102 | "VNI number\n" | |
1103 | "local mac\n" | |
1104 | "mac address\n") | |
1105 | { | |
1106 | int rv; | |
1107 | vni_t vni; | |
1108 | struct ethaddr mac; | |
1109 | struct ipaddr ip; | |
1110 | struct bgp *bgp; | |
1111 | ||
1112 | vni = strtoul(argv[4]->arg, NULL, 10); | |
1113 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
1114 | vty_out(vty, "%% Malformed MAC address\n"); | |
1115 | return CMD_WARNING; | |
1116 | } | |
1117 | memset(&ip, 0, sizeof(ip)); | |
1118 | ||
1119 | bgp = bgp_get_default(); | |
1120 | if (!bgp) { | |
1121 | vty_out(vty, "Default BGP instance is not there\n"); | |
1122 | return CMD_WARNING; | |
1123 | } | |
1124 | ||
ec0ab544 | 1125 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
1126 | if (rv < 0) { |
1127 | vty_out(vty, "Internal error\n"); | |
1128 | return CMD_WARNING; | |
1129 | } | |
1130 | ||
1131 | return CMD_SUCCESS; | |
1132 | } | |
1133 | ||
718e3744 | 1134 | DEFUN (no_synchronization, |
1135 | no_synchronization_cmd, | |
1136 | "no synchronization", | |
1137 | NO_STR | |
1138 | "Perform IGP synchronization\n") | |
1139 | { | |
d62a17ae | 1140 | return CMD_SUCCESS; |
718e3744 | 1141 | } |
1142 | ||
1143 | DEFUN (no_auto_summary, | |
1144 | no_auto_summary_cmd, | |
1145 | "no auto-summary", | |
1146 | NO_STR | |
1147 | "Enable automatic network number summarization\n") | |
1148 | { | |
d62a17ae | 1149 | return CMD_SUCCESS; |
718e3744 | 1150 | } |
3d515fd9 | 1151 | |
718e3744 | 1152 | /* "router bgp" commands. */ |
505e5056 | 1153 | DEFUN_NOSH (router_bgp, |
f412b39a | 1154 | router_bgp_cmd, |
2ed9fe4a | 1155 | "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1156 | ROUTER_STR |
1157 | BGP_STR | |
31500417 DW |
1158 | AS_STR |
1159 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1160 | { |
d62a17ae | 1161 | int idx_asn = 2; |
1162 | int idx_view_vrf = 3; | |
1163 | int idx_vrf = 4; | |
ecec9495 | 1164 | int is_new_bgp = 0; |
d62a17ae | 1165 | int ret; |
1166 | as_t as; | |
1167 | struct bgp *bgp; | |
1168 | const char *name = NULL; | |
1169 | enum bgp_instance_type inst_type; | |
1170 | ||
1171 | // "router bgp" without an ASN | |
1172 | if (argc == 2) { | |
1173 | // Pending: Make VRF option available for ASN less config | |
1174 | bgp = bgp_get_default(); | |
1175 | ||
1176 | if (bgp == NULL) { | |
1177 | vty_out(vty, "%% No BGP process is configured\n"); | |
1178 | return CMD_WARNING_CONFIG_FAILED; | |
1179 | } | |
1180 | ||
1181 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1182 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1183 | return CMD_WARNING_CONFIG_FAILED; |
1184 | } | |
1185 | } | |
1186 | ||
1187 | // "router bgp X" | |
1188 | else { | |
1189 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1190 | ||
1191 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1192 | if (argc > 3) { | |
1193 | name = argv[idx_vrf]->arg; | |
1194 | ||
9a8bdf1c PG |
1195 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1196 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1197 | name = NULL; | |
1198 | else | |
1199 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1200 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1201 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1202 | } | |
1203 | ||
ecec9495 AD |
1204 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1205 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1206 | ||
5d5393b9 | 1207 | ret = bgp_get_vty(&bgp, &as, name, inst_type); |
d62a17ae | 1208 | switch (ret) { |
d62a17ae | 1209 | case BGP_ERR_AS_MISMATCH: |
1210 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1211 | return CMD_WARNING_CONFIG_FAILED; | |
1212 | case BGP_ERR_INSTANCE_MISMATCH: | |
1213 | vty_out(vty, | |
1214 | "BGP instance name and AS number mismatch\n"); | |
1215 | vty_out(vty, | |
1216 | "BGP instance is already running; AS is %u\n", | |
1217 | as); | |
1218 | return CMD_WARNING_CONFIG_FAILED; | |
1219 | } | |
1220 | ||
3bd70bf8 PZ |
1221 | /* |
1222 | * If we just instantiated the default instance, complete | |
1223 | * any pending VRF-VPN leaking that was configured via | |
1224 | * earlier "router bgp X vrf FOO" blocks. | |
1225 | */ | |
ecec9495 | 1226 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1227 | vpn_leak_postchange_all(); |
1228 | ||
48381346 CS |
1229 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1230 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1231 | /* Pending: handle when user tries to change a view to vrf n vv. |
1232 | */ | |
1233 | } | |
1234 | ||
0b5131c9 MK |
1235 | /* unset the auto created flag as the user config is now present */ |
1236 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1237 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1238 | ||
1239 | return CMD_SUCCESS; | |
718e3744 | 1240 | } |
1241 | ||
718e3744 | 1242 | /* "no router bgp" commands. */ |
1243 | DEFUN (no_router_bgp, | |
1244 | no_router_bgp_cmd, | |
2ed9fe4a | 1245 | "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1246 | NO_STR |
1247 | ROUTER_STR | |
1248 | BGP_STR | |
31500417 DW |
1249 | AS_STR |
1250 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1251 | { |
d62a17ae | 1252 | int idx_asn = 3; |
1253 | int idx_vrf = 5; | |
1254 | as_t as; | |
1255 | struct bgp *bgp; | |
1256 | const char *name = NULL; | |
718e3744 | 1257 | |
d62a17ae | 1258 | // "no router bgp" without an ASN |
1259 | if (argc == 3) { | |
1260 | // Pending: Make VRF option available for ASN less config | |
1261 | bgp = bgp_get_default(); | |
718e3744 | 1262 | |
d62a17ae | 1263 | if (bgp == NULL) { |
1264 | vty_out(vty, "%% No BGP process is configured\n"); | |
1265 | return CMD_WARNING_CONFIG_FAILED; | |
1266 | } | |
7fb21a9f | 1267 | |
d62a17ae | 1268 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1269 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1270 | return CMD_WARNING_CONFIG_FAILED; |
1271 | } | |
0b5131c9 MK |
1272 | |
1273 | if (bgp->l3vni) { | |
1274 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1275 | bgp->l3vni); | |
1276 | return CMD_WARNING_CONFIG_FAILED; | |
1277 | } | |
d62a17ae | 1278 | } else { |
1279 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1280 | |
d62a17ae | 1281 | if (argc > 4) |
1282 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1283 | |
d62a17ae | 1284 | /* Lookup bgp structure. */ |
1285 | bgp = bgp_lookup(as, name); | |
1286 | if (!bgp) { | |
1287 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1288 | return CMD_WARNING_CONFIG_FAILED; | |
1289 | } | |
0b5131c9 MK |
1290 | |
1291 | if (bgp->l3vni) { | |
dd5868c2 | 1292 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1293 | bgp->l3vni); |
1294 | return CMD_WARNING_CONFIG_FAILED; | |
1295 | } | |
dd5868c2 DS |
1296 | |
1297 | /* Cannot delete default instance if vrf instances exist */ | |
1298 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1299 | struct listnode *node; | |
1300 | struct bgp *tmp_bgp; | |
1301 | ||
1302 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1303 | if (tmp_bgp->inst_type | |
1304 | == BGP_INSTANCE_TYPE_VRF) { | |
1305 | vty_out(vty, | |
1306 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1307 | return CMD_WARNING_CONFIG_FAILED; | |
1308 | } | |
1309 | } | |
1310 | } | |
d62a17ae | 1311 | } |
718e3744 | 1312 | |
9ecf931b CS |
1313 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1314 | return CMD_WARNING_CONFIG_FAILED; | |
1315 | ||
d62a17ae | 1316 | bgp_delete(bgp); |
718e3744 | 1317 | |
d62a17ae | 1318 | return CMD_SUCCESS; |
718e3744 | 1319 | } |
1320 | ||
6b0655a2 | 1321 | |
718e3744 | 1322 | /* BGP router-id. */ |
1323 | ||
f787d7a0 | 1324 | DEFPY (bgp_router_id, |
718e3744 | 1325 | bgp_router_id_cmd, |
1326 | "bgp router-id A.B.C.D", | |
1327 | BGP_STR | |
1328 | "Override configured router identifier\n" | |
1329 | "Manually configured router identifier\n") | |
1330 | { | |
d62a17ae | 1331 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1332 | bgp_router_id_static_set(bgp, router_id); | |
1333 | return CMD_SUCCESS; | |
718e3744 | 1334 | } |
1335 | ||
f787d7a0 | 1336 | DEFPY (no_bgp_router_id, |
718e3744 | 1337 | no_bgp_router_id_cmd, |
31500417 | 1338 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1339 | NO_STR |
1340 | BGP_STR | |
31500417 DW |
1341 | "Override configured router identifier\n" |
1342 | "Manually configured router identifier\n") | |
718e3744 | 1343 | { |
d62a17ae | 1344 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1345 | |
d62a17ae | 1346 | if (router_id_str) { |
1347 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1348 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1349 | return CMD_WARNING_CONFIG_FAILED; | |
1350 | } | |
e018c7cc | 1351 | } |
718e3744 | 1352 | |
d62a17ae | 1353 | router_id.s_addr = 0; |
1354 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1355 | |
d62a17ae | 1356 | return CMD_SUCCESS; |
718e3744 | 1357 | } |
1358 | ||
6b0655a2 | 1359 | |
718e3744 | 1360 | /* BGP Cluster ID. */ |
718e3744 | 1361 | DEFUN (bgp_cluster_id, |
1362 | bgp_cluster_id_cmd, | |
838758ac | 1363 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1364 | BGP_STR |
1365 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1366 | "Route-Reflector Cluster-id in IP address format\n" |
1367 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1368 | { |
d62a17ae | 1369 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1370 | int idx_ipv4 = 2; | |
1371 | int ret; | |
1372 | struct in_addr cluster; | |
718e3744 | 1373 | |
d62a17ae | 1374 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1375 | if (!ret) { | |
1376 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1377 | return CMD_WARNING_CONFIG_FAILED; | |
1378 | } | |
718e3744 | 1379 | |
d62a17ae | 1380 | bgp_cluster_id_set(bgp, &cluster); |
1381 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1382 | |
d62a17ae | 1383 | return CMD_SUCCESS; |
718e3744 | 1384 | } |
1385 | ||
718e3744 | 1386 | DEFUN (no_bgp_cluster_id, |
1387 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1388 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1389 | NO_STR |
1390 | BGP_STR | |
838758ac DW |
1391 | "Configure Route-Reflector Cluster-id\n" |
1392 | "Route-Reflector Cluster-id in IP address format\n" | |
1393 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1394 | { |
d62a17ae | 1395 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1396 | bgp_cluster_id_unset(bgp); | |
1397 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1398 | |
d62a17ae | 1399 | return CMD_SUCCESS; |
718e3744 | 1400 | } |
1401 | ||
718e3744 | 1402 | DEFUN (bgp_confederation_identifier, |
1403 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1404 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1405 | "BGP specific commands\n" |
1406 | "AS confederation parameters\n" | |
1407 | "AS number\n" | |
1408 | "Set routing domain confederation AS\n") | |
1409 | { | |
d62a17ae | 1410 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1411 | int idx_number = 3; | |
1412 | as_t as; | |
718e3744 | 1413 | |
d62a17ae | 1414 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1415 | |
d62a17ae | 1416 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1417 | |
d62a17ae | 1418 | return CMD_SUCCESS; |
718e3744 | 1419 | } |
1420 | ||
1421 | DEFUN (no_bgp_confederation_identifier, | |
1422 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1423 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1424 | NO_STR |
1425 | "BGP specific commands\n" | |
1426 | "AS confederation parameters\n" | |
3a2d747c QY |
1427 | "AS number\n" |
1428 | "Set routing domain confederation AS\n") | |
718e3744 | 1429 | { |
d62a17ae | 1430 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1431 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1432 | |
d62a17ae | 1433 | return CMD_SUCCESS; |
718e3744 | 1434 | } |
1435 | ||
718e3744 | 1436 | DEFUN (bgp_confederation_peers, |
1437 | bgp_confederation_peers_cmd, | |
12dcf78e | 1438 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1439 | "BGP specific commands\n" |
1440 | "AS confederation parameters\n" | |
1441 | "Peer ASs in BGP confederation\n" | |
1442 | AS_STR) | |
1443 | { | |
d62a17ae | 1444 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1445 | int idx_asn = 3; | |
1446 | as_t as; | |
1447 | int i; | |
718e3744 | 1448 | |
d62a17ae | 1449 | for (i = idx_asn; i < argc; i++) { |
1450 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1451 | |
d62a17ae | 1452 | if (bgp->as == as) { |
1453 | vty_out(vty, | |
1454 | "%% Local member-AS not allowed in confed peer list\n"); | |
1455 | continue; | |
1456 | } | |
718e3744 | 1457 | |
d62a17ae | 1458 | bgp_confederation_peers_add(bgp, as); |
1459 | } | |
1460 | return CMD_SUCCESS; | |
718e3744 | 1461 | } |
1462 | ||
1463 | DEFUN (no_bgp_confederation_peers, | |
1464 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1465 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1466 | NO_STR |
1467 | "BGP specific commands\n" | |
1468 | "AS confederation parameters\n" | |
1469 | "Peer ASs in BGP confederation\n" | |
1470 | AS_STR) | |
1471 | { | |
d62a17ae | 1472 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1473 | int idx_asn = 4; | |
1474 | as_t as; | |
1475 | int i; | |
718e3744 | 1476 | |
d62a17ae | 1477 | for (i = idx_asn; i < argc; i++) { |
1478 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1479 | |
d62a17ae | 1480 | bgp_confederation_peers_remove(bgp, as); |
1481 | } | |
1482 | return CMD_SUCCESS; | |
718e3744 | 1483 | } |
6b0655a2 | 1484 | |
5e242b0d DS |
1485 | /** |
1486 | * Central routine for maximum-paths configuration. | |
1487 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1488 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1489 | */ | |
d62a17ae | 1490 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1491 | const char *mpaths, uint16_t options, |
d62a17ae | 1492 | int set) |
1493 | { | |
1494 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1495 | uint16_t maxpaths = 0; |
d62a17ae | 1496 | int ret; |
1497 | afi_t afi; | |
1498 | safi_t safi; | |
1499 | ||
1500 | afi = bgp_node_afi(vty); | |
1501 | safi = bgp_node_safi(vty); | |
1502 | ||
1503 | if (set) { | |
1504 | maxpaths = strtol(mpaths, NULL, 10); | |
1505 | if (maxpaths > multipath_num) { | |
1506 | vty_out(vty, | |
1507 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1508 | maxpaths, multipath_num); | |
1509 | return CMD_WARNING_CONFIG_FAILED; | |
1510 | } | |
1511 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1512 | options); | |
1513 | } else | |
1514 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1515 | ||
1516 | if (ret < 0) { | |
1517 | vty_out(vty, | |
1518 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1519 | (set == 1) ? "" : "un", | |
1520 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1521 | maxpaths, afi, safi); | |
1522 | return CMD_WARNING_CONFIG_FAILED; | |
1523 | } | |
1524 | ||
1525 | bgp_recalculate_all_bestpaths(bgp); | |
1526 | ||
1527 | return CMD_SUCCESS; | |
165b5fff JB |
1528 | } |
1529 | ||
abc920f8 DS |
1530 | DEFUN (bgp_maxmed_admin, |
1531 | bgp_maxmed_admin_cmd, | |
1532 | "bgp max-med administrative ", | |
1533 | BGP_STR | |
1534 | "Advertise routes with max-med\n" | |
1535 | "Administratively applied, for an indefinite period\n") | |
1536 | { | |
d62a17ae | 1537 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1538 | |
d62a17ae | 1539 | bgp->v_maxmed_admin = 1; |
1540 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1541 | |
d62a17ae | 1542 | bgp_maxmed_update(bgp); |
abc920f8 | 1543 | |
d62a17ae | 1544 | return CMD_SUCCESS; |
abc920f8 DS |
1545 | } |
1546 | ||
1547 | DEFUN (bgp_maxmed_admin_medv, | |
1548 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1549 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1550 | BGP_STR |
1551 | "Advertise routes with max-med\n" | |
1552 | "Administratively applied, for an indefinite period\n" | |
1553 | "Max MED value to be used\n") | |
1554 | { | |
d62a17ae | 1555 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1556 | int idx_number = 3; | |
abc920f8 | 1557 | |
d62a17ae | 1558 | bgp->v_maxmed_admin = 1; |
1559 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1560 | |
d62a17ae | 1561 | bgp_maxmed_update(bgp); |
abc920f8 | 1562 | |
d62a17ae | 1563 | return CMD_SUCCESS; |
abc920f8 DS |
1564 | } |
1565 | ||
1566 | DEFUN (no_bgp_maxmed_admin, | |
1567 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1568 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1569 | NO_STR |
1570 | BGP_STR | |
1571 | "Advertise routes with max-med\n" | |
838758ac DW |
1572 | "Administratively applied, for an indefinite period\n" |
1573 | "Max MED value to be used\n") | |
abc920f8 | 1574 | { |
d62a17ae | 1575 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1576 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1577 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1578 | bgp_maxmed_update(bgp); | |
abc920f8 | 1579 | |
d62a17ae | 1580 | return CMD_SUCCESS; |
abc920f8 DS |
1581 | } |
1582 | ||
abc920f8 DS |
1583 | DEFUN (bgp_maxmed_onstartup, |
1584 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1585 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1586 | BGP_STR |
1587 | "Advertise routes with max-med\n" | |
1588 | "Effective on a startup\n" | |
1589 | "Time (seconds) period for max-med\n" | |
1590 | "Max MED value to be used\n") | |
1591 | { | |
d62a17ae | 1592 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1593 | int idx = 0; | |
4668a151 | 1594 | |
d62a17ae | 1595 | argv_find(argv, argc, "(5-86400)", &idx); |
1596 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1597 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1598 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1599 | else | |
1600 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1601 | |
d62a17ae | 1602 | bgp_maxmed_update(bgp); |
abc920f8 | 1603 | |
d62a17ae | 1604 | return CMD_SUCCESS; |
abc920f8 DS |
1605 | } |
1606 | ||
1607 | DEFUN (no_bgp_maxmed_onstartup, | |
1608 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1609 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1610 | NO_STR |
1611 | BGP_STR | |
1612 | "Advertise routes with max-med\n" | |
838758ac DW |
1613 | "Effective on a startup\n" |
1614 | "Time (seconds) period for max-med\n" | |
1615 | "Max MED value to be used\n") | |
abc920f8 | 1616 | { |
d62a17ae | 1617 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1618 | |
d62a17ae | 1619 | /* Cancel max-med onstartup if its on */ |
1620 | if (bgp->t_maxmed_onstartup) { | |
1621 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1622 | bgp->maxmed_onstartup_over = 1; | |
1623 | } | |
abc920f8 | 1624 | |
d62a17ae | 1625 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1626 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1627 | |
d62a17ae | 1628 | bgp_maxmed_update(bgp); |
abc920f8 | 1629 | |
d62a17ae | 1630 | return CMD_SUCCESS; |
abc920f8 DS |
1631 | } |
1632 | ||
d62a17ae | 1633 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1634 | const char *wait) | |
f188f2c4 | 1635 | { |
d62a17ae | 1636 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1637 | uint16_t update_delay; |
1638 | uint16_t establish_wait; | |
f188f2c4 | 1639 | |
d62a17ae | 1640 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1641 | |
d62a17ae | 1642 | if (!wait) /* update-delay <delay> */ |
1643 | { | |
1644 | bgp->v_update_delay = update_delay; | |
1645 | bgp->v_establish_wait = bgp->v_update_delay; | |
1646 | return CMD_SUCCESS; | |
1647 | } | |
f188f2c4 | 1648 | |
d62a17ae | 1649 | /* update-delay <delay> <establish-wait> */ |
1650 | establish_wait = atoi(wait); | |
1651 | if (update_delay < establish_wait) { | |
1652 | vty_out(vty, | |
1653 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1654 | return CMD_WARNING_CONFIG_FAILED; | |
1655 | } | |
f188f2c4 | 1656 | |
d62a17ae | 1657 | bgp->v_update_delay = update_delay; |
1658 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1659 | |
d62a17ae | 1660 | return CMD_SUCCESS; |
f188f2c4 DS |
1661 | } |
1662 | ||
d62a17ae | 1663 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1664 | { |
d62a17ae | 1665 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1666 | |
d62a17ae | 1667 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1668 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1669 | |
d62a17ae | 1670 | return CMD_SUCCESS; |
f188f2c4 DS |
1671 | } |
1672 | ||
2b791107 | 1673 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1674 | { |
d62a17ae | 1675 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1676 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1677 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1678 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1679 | vty_out(vty, "\n"); | |
1680 | } | |
f188f2c4 DS |
1681 | } |
1682 | ||
1683 | ||
1684 | /* Update-delay configuration */ | |
1685 | DEFUN (bgp_update_delay, | |
1686 | bgp_update_delay_cmd, | |
6147e2c6 | 1687 | "update-delay (0-3600)", |
f188f2c4 DS |
1688 | "Force initial delay for best-path and updates\n" |
1689 | "Seconds\n") | |
1690 | { | |
d62a17ae | 1691 | int idx_number = 1; |
1692 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1693 | } |
1694 | ||
1695 | DEFUN (bgp_update_delay_establish_wait, | |
1696 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1697 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1698 | "Force initial delay for best-path and updates\n" |
1699 | "Seconds\n" | |
f188f2c4 DS |
1700 | "Seconds\n") |
1701 | { | |
d62a17ae | 1702 | int idx_number = 1; |
1703 | int idx_number_2 = 2; | |
1704 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1705 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1706 | } |
1707 | ||
1708 | /* Update-delay deconfiguration */ | |
1709 | DEFUN (no_bgp_update_delay, | |
1710 | no_bgp_update_delay_cmd, | |
838758ac DW |
1711 | "no update-delay [(0-3600) [(1-3600)]]", |
1712 | NO_STR | |
f188f2c4 | 1713 | "Force initial delay for best-path and updates\n" |
838758ac | 1714 | "Seconds\n" |
7111c1a0 | 1715 | "Seconds\n") |
f188f2c4 | 1716 | { |
d62a17ae | 1717 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1718 | } |
1719 | ||
5e242b0d | 1720 | |
8fa7732f QY |
1721 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1722 | bool set) | |
cb1faec9 | 1723 | { |
d62a17ae | 1724 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1725 | |
8fa7732f QY |
1726 | quanta = set ? quanta : BGP_WRITE_PACKET_MAX; |
1727 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, memory_order_relaxed); | |
555e09d4 QY |
1728 | |
1729 | return CMD_SUCCESS; | |
1730 | } | |
1731 | ||
8fa7732f QY |
1732 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, uint32_t quanta, |
1733 | bool set) | |
555e09d4 QY |
1734 | { |
1735 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1736 | ||
8fa7732f QY |
1737 | quanta = set ? quanta : BGP_READ_PACKET_MAX; |
1738 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, memory_order_relaxed); | |
cb1faec9 | 1739 | |
d62a17ae | 1740 | return CMD_SUCCESS; |
cb1faec9 DS |
1741 | } |
1742 | ||
2b791107 | 1743 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1744 | { |
555e09d4 QY |
1745 | uint32_t quanta = |
1746 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1747 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1748 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1749 | } |
1750 | ||
555e09d4 QY |
1751 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1752 | { | |
1753 | uint32_t quanta = | |
1754 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1755 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1756 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1757 | } |
cb1faec9 | 1758 | |
8fa7732f QY |
1759 | /* Packet quanta configuration |
1760 | * | |
1761 | * XXX: The value set here controls the size of a stack buffer in the IO | |
1762 | * thread. When changing these limits be careful to prevent stack overflow. | |
1763 | * | |
1764 | * Furthermore, the maximums used here should correspond to | |
1765 | * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX. | |
1766 | */ | |
1767 | DEFPY (bgp_wpkt_quanta, | |
cb1faec9 | 1768 | bgp_wpkt_quanta_cmd, |
8fa7732f | 1769 | "[no] write-quanta (1-64)$quanta", |
d7fa34c1 | 1770 | NO_STR |
8fa7732f | 1771 | "How many packets to write to peer socket per run\n" |
cb1faec9 DS |
1772 | "Number of packets\n") |
1773 | { | |
8fa7732f | 1774 | return bgp_wpkt_quanta_config_vty(vty, quanta, !no); |
cb1faec9 DS |
1775 | } |
1776 | ||
8fa7732f | 1777 | DEFPY (bgp_rpkt_quanta, |
555e09d4 | 1778 | bgp_rpkt_quanta_cmd, |
8fa7732f | 1779 | "[no] read-quanta (1-10)$quanta", |
555e09d4 QY |
1780 | NO_STR |
1781 | "How many packets to read from peer socket per I/O cycle\n" | |
1782 | "Number of packets\n") | |
1783 | { | |
8fa7732f | 1784 | return bgp_rpkt_quanta_config_vty(vty, quanta, !no); |
555e09d4 QY |
1785 | } |
1786 | ||
2b791107 | 1787 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1788 | { |
37a333fe | 1789 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1790 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1791 | } |
1792 | ||
1793 | ||
1794 | DEFUN (bgp_coalesce_time, | |
1795 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1796 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1797 | "Subgroup coalesce timer\n" |
1798 | "Subgroup coalesce timer value (in ms)\n") | |
1799 | { | |
d62a17ae | 1800 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1801 | |
d62a17ae | 1802 | int idx = 0; |
1803 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1804 | bgp->heuristic_coalesce = false; |
d62a17ae | 1805 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1806 | return CMD_SUCCESS; | |
3f9c7369 DS |
1807 | } |
1808 | ||
1809 | DEFUN (no_bgp_coalesce_time, | |
1810 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1811 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1812 | NO_STR |
3f9c7369 DS |
1813 | "Subgroup coalesce timer\n" |
1814 | "Subgroup coalesce timer value (in ms)\n") | |
1815 | { | |
d62a17ae | 1816 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1817 | |
37a333fe | 1818 | bgp->heuristic_coalesce = true; |
d62a17ae | 1819 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1820 | return CMD_SUCCESS; | |
3f9c7369 DS |
1821 | } |
1822 | ||
5e242b0d DS |
1823 | /* Maximum-paths configuration */ |
1824 | DEFUN (bgp_maxpaths, | |
1825 | bgp_maxpaths_cmd, | |
6319fd63 | 1826 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1827 | "Forward packets over multiple paths\n" |
1828 | "Number of paths\n") | |
1829 | { | |
d62a17ae | 1830 | int idx_number = 1; |
1831 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1832 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1833 | } |
1834 | ||
d62a17ae | 1835 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1836 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1837 | "Forward packets over multiple paths\n" | |
1838 | "Number of paths\n") | |
596c17ba | 1839 | |
165b5fff JB |
1840 | DEFUN (bgp_maxpaths_ibgp, |
1841 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1842 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1843 | "Forward packets over multiple paths\n" |
1844 | "iBGP-multipath\n" | |
1845 | "Number of paths\n") | |
1846 | { | |
d62a17ae | 1847 | int idx_number = 2; |
1848 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1849 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1850 | } |
165b5fff | 1851 | |
d62a17ae | 1852 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1853 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1854 | "Forward packets over multiple paths\n" | |
1855 | "iBGP-multipath\n" | |
1856 | "Number of paths\n") | |
596c17ba | 1857 | |
5e242b0d DS |
1858 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1859 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1860 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1861 | "Forward packets over multiple paths\n" |
1862 | "iBGP-multipath\n" | |
1863 | "Number of paths\n" | |
1864 | "Match the cluster length\n") | |
1865 | { | |
d62a17ae | 1866 | int idx_number = 2; |
1867 | return bgp_maxpaths_config_vty( | |
1868 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1869 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1870 | } |
1871 | ||
d62a17ae | 1872 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1873 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1874 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1875 | "Forward packets over multiple paths\n" | |
1876 | "iBGP-multipath\n" | |
1877 | "Number of paths\n" | |
1878 | "Match the cluster length\n") | |
596c17ba | 1879 | |
165b5fff JB |
1880 | DEFUN (no_bgp_maxpaths, |
1881 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1882 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1883 | NO_STR |
1884 | "Forward packets over multiple paths\n" | |
1885 | "Number of paths\n") | |
1886 | { | |
d62a17ae | 1887 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1888 | } |
1889 | ||
d62a17ae | 1890 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1891 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1892 | "Forward packets over multiple paths\n" |
1893 | "Number of paths\n") | |
596c17ba | 1894 | |
165b5fff JB |
1895 | DEFUN (no_bgp_maxpaths_ibgp, |
1896 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1897 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1898 | NO_STR |
1899 | "Forward packets over multiple paths\n" | |
1900 | "iBGP-multipath\n" | |
838758ac DW |
1901 | "Number of paths\n" |
1902 | "Match the cluster length\n") | |
165b5fff | 1903 | { |
d62a17ae | 1904 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1905 | } |
1906 | ||
d62a17ae | 1907 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1908 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1909 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1910 | NO_STR | |
1911 | "Forward packets over multiple paths\n" | |
1912 | "iBGP-multipath\n" | |
1913 | "Number of paths\n" | |
1914 | "Match the cluster length\n") | |
596c17ba | 1915 | |
dd65f45e DL |
1916 | static void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, |
1917 | afi_t afi, safi_t safi) | |
165b5fff | 1918 | { |
d62a17ae | 1919 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1920 | vty_out(vty, " maximum-paths %d\n", |
1921 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1922 | } | |
165b5fff | 1923 | |
d62a17ae | 1924 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1925 | vty_out(vty, " maximum-paths ibgp %d", |
1926 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1927 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1928 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1929 | vty_out(vty, " equal-cluster-length"); | |
1930 | vty_out(vty, "\n"); | |
1931 | } | |
165b5fff | 1932 | } |
6b0655a2 | 1933 | |
718e3744 | 1934 | /* BGP timers. */ |
1935 | ||
1936 | DEFUN (bgp_timers, | |
1937 | bgp_timers_cmd, | |
6147e2c6 | 1938 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1939 | "Adjust routing timers\n" |
1940 | "BGP timers\n" | |
1941 | "Keepalive interval\n" | |
1942 | "Holdtime\n") | |
1943 | { | |
d62a17ae | 1944 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1945 | int idx_number = 2; | |
1946 | int idx_number_2 = 3; | |
1947 | unsigned long keepalive = 0; | |
1948 | unsigned long holdtime = 0; | |
718e3744 | 1949 | |
d62a17ae | 1950 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1951 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1952 | |
d62a17ae | 1953 | /* Holdtime value check. */ |
1954 | if (holdtime < 3 && holdtime != 0) { | |
1955 | vty_out(vty, | |
1956 | "%% hold time value must be either 0 or greater than 3\n"); | |
1957 | return CMD_WARNING_CONFIG_FAILED; | |
1958 | } | |
718e3744 | 1959 | |
5d5393b9 | 1960 | bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY); |
718e3744 | 1961 | |
d62a17ae | 1962 | return CMD_SUCCESS; |
718e3744 | 1963 | } |
1964 | ||
1965 | DEFUN (no_bgp_timers, | |
1966 | no_bgp_timers_cmd, | |
838758ac | 1967 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1968 | NO_STR |
1969 | "Adjust routing timers\n" | |
838758ac DW |
1970 | "BGP timers\n" |
1971 | "Keepalive interval\n" | |
1972 | "Holdtime\n") | |
718e3744 | 1973 | { |
d62a17ae | 1974 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
5d5393b9 DL |
1975 | bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME, |
1976 | DFLT_BGP_CONNECT_RETRY); | |
718e3744 | 1977 | |
d62a17ae | 1978 | return CMD_SUCCESS; |
718e3744 | 1979 | } |
1980 | ||
6b0655a2 | 1981 | |
718e3744 | 1982 | DEFUN (bgp_client_to_client_reflection, |
1983 | bgp_client_to_client_reflection_cmd, | |
1984 | "bgp client-to-client reflection", | |
1985 | "BGP specific commands\n" | |
1986 | "Configure client to client route reflection\n" | |
1987 | "reflection of routes allowed\n") | |
1988 | { | |
d62a17ae | 1989 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 1990 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 1991 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 1992 | |
d62a17ae | 1993 | return CMD_SUCCESS; |
718e3744 | 1994 | } |
1995 | ||
1996 | DEFUN (no_bgp_client_to_client_reflection, | |
1997 | no_bgp_client_to_client_reflection_cmd, | |
1998 | "no bgp client-to-client reflection", | |
1999 | NO_STR | |
2000 | "BGP specific commands\n" | |
2001 | "Configure client to client route reflection\n" | |
2002 | "reflection of routes allowed\n") | |
2003 | { | |
d62a17ae | 2004 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2005 | SET_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
d62a17ae | 2006 | bgp_clear_star_soft_out(vty, bgp->name); |
7aafcaca | 2007 | |
d62a17ae | 2008 | return CMD_SUCCESS; |
718e3744 | 2009 | } |
2010 | ||
2011 | /* "bgp always-compare-med" configuration. */ | |
2012 | DEFUN (bgp_always_compare_med, | |
2013 | bgp_always_compare_med_cmd, | |
2014 | "bgp always-compare-med", | |
2015 | "BGP specific commands\n" | |
2016 | "Allow comparing MED from different neighbors\n") | |
2017 | { | |
d62a17ae | 2018 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2019 | SET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2020 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2021 | |
d62a17ae | 2022 | return CMD_SUCCESS; |
718e3744 | 2023 | } |
2024 | ||
2025 | DEFUN (no_bgp_always_compare_med, | |
2026 | no_bgp_always_compare_med_cmd, | |
2027 | "no bgp always-compare-med", | |
2028 | NO_STR | |
2029 | "BGP specific commands\n" | |
2030 | "Allow comparing MED from different neighbors\n") | |
2031 | { | |
d62a17ae | 2032 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2033 | UNSET_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED); |
d62a17ae | 2034 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2035 | |
d62a17ae | 2036 | return CMD_SUCCESS; |
718e3744 | 2037 | } |
6b0655a2 | 2038 | |
9dac9fc8 DA |
2039 | |
2040 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
2041 | "bgp ebgp-requires-policy", | |
2042 | "BGP specific commands\n" | |
2043 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2044 | { | |
2045 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1d3fdccf | 2046 | SET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); |
9dac9fc8 DA |
2047 | return CMD_SUCCESS; |
2048 | } | |
2049 | ||
2050 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
2051 | "no bgp ebgp-requires-policy", | |
2052 | NO_STR | |
2053 | "BGP specific commands\n" | |
2054 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
2055 | { | |
2056 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1d3fdccf | 2057 | UNSET_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY); |
9dac9fc8 DA |
2058 | return CMD_SUCCESS; |
2059 | } | |
2060 | ||
fb29348a DA |
2061 | DEFUN(bgp_reject_as_sets, bgp_reject_as_sets_cmd, |
2062 | "bgp reject-as-sets", | |
2063 | "BGP specific commands\n" | |
2064 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2065 | { | |
2066 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2067 | struct listnode *node, *nnode; | |
2068 | struct peer *peer; | |
2069 | ||
7f972cd8 | 2070 | bgp->reject_as_sets = true; |
fb29348a DA |
2071 | |
2072 | /* Reset existing BGP sessions to reject routes | |
2073 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2074 | */ | |
2075 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2076 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2077 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2078 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2079 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2080 | } | |
2081 | } | |
2082 | ||
2083 | return CMD_SUCCESS; | |
2084 | } | |
2085 | ||
2086 | DEFUN(no_bgp_reject_as_sets, no_bgp_reject_as_sets_cmd, | |
2087 | "no bgp reject-as-sets", | |
2088 | NO_STR | |
2089 | "BGP specific commands\n" | |
2090 | "Reject routes with AS_SET or AS_CONFED_SET flag\n") | |
2091 | { | |
2092 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2093 | struct listnode *node, *nnode; | |
2094 | struct peer *peer; | |
2095 | ||
7f972cd8 | 2096 | bgp->reject_as_sets = false; |
fb29348a DA |
2097 | |
2098 | /* Reset existing BGP sessions to reject routes | |
2099 | * with aspath containing AS_SET or AS_CONFED_SET. | |
2100 | */ | |
2101 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
2102 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2103 | peer->last_reset = PEER_DOWN_AS_SETS_REJECT; | |
2104 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2105 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2106 | } | |
2107 | } | |
2108 | ||
2109 | return CMD_SUCCESS; | |
2110 | } | |
9dac9fc8 | 2111 | |
718e3744 | 2112 | /* "bgp deterministic-med" configuration. */ |
2113 | DEFUN (bgp_deterministic_med, | |
2114 | bgp_deterministic_med_cmd, | |
2115 | "bgp deterministic-med", | |
2116 | "BGP specific commands\n" | |
2117 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2118 | { | |
d62a17ae | 2119 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 2120 | |
892fedb6 DA |
2121 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
2122 | SET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); | |
d62a17ae | 2123 | bgp_recalculate_all_bestpaths(bgp); |
2124 | } | |
7aafcaca | 2125 | |
d62a17ae | 2126 | return CMD_SUCCESS; |
718e3744 | 2127 | } |
2128 | ||
2129 | DEFUN (no_bgp_deterministic_med, | |
2130 | no_bgp_deterministic_med_cmd, | |
2131 | "no bgp deterministic-med", | |
2132 | NO_STR | |
2133 | "BGP specific commands\n" | |
2134 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
2135 | { | |
d62a17ae | 2136 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2137 | int bestpath_per_as_used; | |
2138 | afi_t afi; | |
2139 | safi_t safi; | |
2140 | struct peer *peer; | |
2141 | struct listnode *node, *nnode; | |
2142 | ||
892fedb6 | 2143 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED)) { |
d62a17ae | 2144 | bestpath_per_as_used = 0; |
2145 | ||
2146 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 2147 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
2148 | if (bgp_addpath_dmed_required( |
2149 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
2150 | bestpath_per_as_used = 1; |
2151 | break; | |
2152 | } | |
d62a17ae | 2153 | |
2154 | if (bestpath_per_as_used) | |
2155 | break; | |
2156 | } | |
2157 | ||
2158 | if (bestpath_per_as_used) { | |
2159 | vty_out(vty, | |
2160 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
2161 | return CMD_WARNING_CONFIG_FAILED; | |
2162 | } else { | |
892fedb6 | 2163 | UNSET_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED); |
d62a17ae | 2164 | bgp_recalculate_all_bestpaths(bgp); |
2165 | } | |
2166 | } | |
2167 | ||
2168 | return CMD_SUCCESS; | |
718e3744 | 2169 | } |
538621f2 | 2170 | |
055679e9 | 2171 | /* "bgp graceful-restart mode" configuration. */ |
538621f2 | 2172 | DEFUN (bgp_graceful_restart, |
2ba1fe69 | 2173 | bgp_graceful_restart_cmd, |
2174 | "bgp graceful-restart", | |
2175 | "BGP specific commands\n" | |
2176 | GR_CMD | |
055679e9 | 2177 | ) |
538621f2 | 2178 | { |
055679e9 | 2179 | int ret = BGP_GR_FAILURE; |
2180 | ||
2181 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2182 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START "); |
dc95985f | 2183 | |
d62a17ae | 2184 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2185 | |
2186 | ret = bgp_gr_update_all(bgp, GLOBAL_GR_CMD); | |
2187 | ||
36235319 QY |
2188 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2189 | ret); | |
5cce3f05 | 2190 | |
055679e9 | 2191 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2192 | zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END "); |
dc95985f | 2193 | vty_out(vty, |
2194 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2195 | return bgp_vty_return(vty, ret); |
538621f2 | 2196 | } |
2197 | ||
2198 | DEFUN (no_bgp_graceful_restart, | |
2ba1fe69 | 2199 | no_bgp_graceful_restart_cmd, |
2200 | "no bgp graceful-restart", | |
2201 | NO_STR | |
2202 | "BGP specific commands\n" | |
2203 | NO_GR_CMD | |
055679e9 | 2204 | ) |
538621f2 | 2205 | { |
d62a17ae | 2206 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
055679e9 | 2207 | |
2208 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2ba1fe69 | 2209 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START "); |
055679e9 | 2210 | |
2211 | int ret = BGP_GR_FAILURE; | |
2212 | ||
2213 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_GR_CMD); | |
2214 | ||
36235319 QY |
2215 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2216 | ret); | |
5cce3f05 | 2217 | |
055679e9 | 2218 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2ba1fe69 | 2219 | zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END "); |
dc95985f | 2220 | vty_out(vty, |
2221 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2222 | |
2223 | return bgp_vty_return(vty, ret); | |
538621f2 | 2224 | } |
2225 | ||
93406d87 | 2226 | DEFUN (bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2227 | bgp_graceful_restart_stalepath_time_cmd, |
2228 | "bgp graceful-restart stalepath-time (1-4095)", | |
2229 | "BGP specific commands\n" | |
2230 | "Graceful restart capability parameters\n" | |
2231 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2232 | "Delay value (seconds)\n") | |
93406d87 | 2233 | { |
d62a17ae | 2234 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2235 | int idx_number = 3; | |
d7c0a89a | 2236 | uint32_t stalepath; |
93406d87 | 2237 | |
d62a17ae | 2238 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2239 | bgp->stalepath_time = stalepath; | |
2240 | return CMD_SUCCESS; | |
93406d87 | 2241 | } |
2242 | ||
eb6f1b41 | 2243 | DEFUN (bgp_graceful_restart_restart_time, |
2ba1fe69 | 2244 | bgp_graceful_restart_restart_time_cmd, |
2245 | "bgp graceful-restart restart-time (1-4095)", | |
2246 | "BGP specific commands\n" | |
2247 | "Graceful restart capability parameters\n" | |
2248 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2249 | "Delay value (seconds)\n") | |
eb6f1b41 | 2250 | { |
d62a17ae | 2251 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2252 | int idx_number = 3; | |
d7c0a89a | 2253 | uint32_t restart; |
eb6f1b41 | 2254 | |
d62a17ae | 2255 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2256 | bgp->restart_time = restart; | |
2257 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2258 | } |
2259 | ||
cfd47646 | 2260 | DEFUN (bgp_graceful_restart_select_defer_time, |
2261 | bgp_graceful_restart_select_defer_time_cmd, | |
2262 | "bgp graceful-restart select-defer-time (0-3600)", | |
2263 | "BGP specific commands\n" | |
2264 | "Graceful restart capability parameters\n" | |
2265 | "Set the time to defer the BGP route selection after restart\n" | |
2266 | "Delay value (seconds, 0 - disable)\n") | |
2267 | { | |
2268 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2269 | int idx_number = 3; | |
2270 | uint32_t defer_time; | |
2271 | ||
2272 | defer_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2273 | bgp->select_defer_time = defer_time; | |
2274 | if (defer_time == 0) | |
892fedb6 | 2275 | SET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2276 | else |
892fedb6 | 2277 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2278 | |
2279 | return CMD_SUCCESS; | |
2280 | } | |
2281 | ||
93406d87 | 2282 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2ba1fe69 | 2283 | no_bgp_graceful_restart_stalepath_time_cmd, |
2284 | "no bgp graceful-restart stalepath-time [(1-4095)]", | |
2285 | NO_STR | |
2286 | "BGP specific commands\n" | |
2287 | "Graceful restart capability parameters\n" | |
2288 | "Set the max time to hold onto restarting peer's stale paths\n" | |
2289 | "Delay value (seconds)\n") | |
93406d87 | 2290 | { |
d62a17ae | 2291 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2292 | |
d62a17ae | 2293 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2294 | return CMD_SUCCESS; | |
93406d87 | 2295 | } |
2296 | ||
eb6f1b41 | 2297 | DEFUN (no_bgp_graceful_restart_restart_time, |
2ba1fe69 | 2298 | no_bgp_graceful_restart_restart_time_cmd, |
2299 | "no bgp graceful-restart restart-time [(1-4095)]", | |
2300 | NO_STR | |
2301 | "BGP specific commands\n" | |
2302 | "Graceful restart capability parameters\n" | |
2303 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2304 | "Delay value (seconds)\n") | |
eb6f1b41 | 2305 | { |
d62a17ae | 2306 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2307 | |
d62a17ae | 2308 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2309 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2310 | } |
2311 | ||
cfd47646 | 2312 | DEFUN (no_bgp_graceful_restart_select_defer_time, |
2313 | no_bgp_graceful_restart_select_defer_time_cmd, | |
2314 | "no bgp graceful-restart select-defer-time [(0-3600)]", | |
2315 | NO_STR | |
2316 | "BGP specific commands\n" | |
2317 | "Graceful restart capability parameters\n" | |
2318 | "Set the time to defer the BGP route selection after restart\n" | |
2319 | "Delay value (seconds)\n") | |
2320 | { | |
2321 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2322 | ||
2323 | bgp->select_defer_time = BGP_DEFAULT_SELECT_DEFERRAL_TIME; | |
892fedb6 | 2324 | UNSET_FLAG(bgp->flags, BGP_FLAG_SELECT_DEFER_DISABLE); |
cfd47646 | 2325 | |
2326 | return CMD_SUCCESS; | |
2327 | } | |
2328 | ||
43fc21b3 | 2329 | DEFUN (bgp_graceful_restart_preserve_fw, |
2ba1fe69 | 2330 | bgp_graceful_restart_preserve_fw_cmd, |
2331 | "bgp graceful-restart preserve-fw-state", | |
2332 | "BGP specific commands\n" | |
2333 | "Graceful restart capability parameters\n" | |
2334 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2335 | { |
d62a17ae | 2336 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2337 | SET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2338 | return CMD_SUCCESS; |
43fc21b3 JC |
2339 | } |
2340 | ||
2341 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2ba1fe69 | 2342 | no_bgp_graceful_restart_preserve_fw_cmd, |
2343 | "no bgp graceful-restart preserve-fw-state", | |
2344 | NO_STR | |
2345 | "BGP specific commands\n" | |
2346 | "Graceful restart capability parameters\n" | |
2347 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
43fc21b3 | 2348 | { |
d62a17ae | 2349 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2350 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD); |
d62a17ae | 2351 | return CMD_SUCCESS; |
43fc21b3 JC |
2352 | } |
2353 | ||
055679e9 | 2354 | DEFUN (bgp_graceful_restart_disable, |
2ba1fe69 | 2355 | bgp_graceful_restart_disable_cmd, |
2356 | "bgp graceful-restart-disable", | |
2357 | "BGP specific commands\n" | |
2358 | GR_DISABLE) | |
055679e9 | 2359 | { |
2360 | int ret = BGP_GR_FAILURE; | |
2361 | ||
2362 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2363 | zlog_debug( | |
2ba1fe69 | 2364 | "[BGP_GR] bgp_graceful_restart_disable_cmd : START "); |
dc95985f | 2365 | |
055679e9 | 2366 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2367 | ||
2368 | ret = bgp_gr_update_all(bgp, GLOBAL_DISABLE_CMD); | |
2369 | ||
dc95985f | 2370 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, |
2371 | bgp->peer, ret); | |
5cce3f05 | 2372 | |
055679e9 | 2373 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2374 | zlog_debug( | |
2ba1fe69 | 2375 | "[BGP_GR] bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2376 | vty_out(vty, |
2377 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
2378 | ||
055679e9 | 2379 | return bgp_vty_return(vty, ret); |
2380 | } | |
2381 | ||
2382 | DEFUN (no_bgp_graceful_restart_disable, | |
2ba1fe69 | 2383 | no_bgp_graceful_restart_disable_cmd, |
2384 | "no bgp graceful-restart-disable", | |
2385 | NO_STR | |
2386 | "BGP specific commands\n" | |
2387 | NO_GR_DISABLE | |
055679e9 | 2388 | ) |
2389 | { | |
2390 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2391 | ||
2392 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2393 | zlog_debug( | |
2ba1fe69 | 2394 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START "); |
055679e9 | 2395 | |
2396 | int ret = BGP_GR_FAILURE; | |
2397 | ||
2398 | ret = bgp_gr_update_all(bgp, NO_GLOBAL_DISABLE_CMD); | |
2399 | ||
36235319 QY |
2400 | VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp, bgp->peer, |
2401 | ret); | |
5cce3f05 | 2402 | |
055679e9 | 2403 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2404 | zlog_debug( | |
2ba1fe69 | 2405 | "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END "); |
dc95985f | 2406 | vty_out(vty, |
2407 | "Graceful restart configuration changed, reset all peers to take effect\n"); | |
055679e9 | 2408 | |
2409 | return bgp_vty_return(vty, ret); | |
2410 | } | |
2411 | ||
2412 | DEFUN (bgp_neighbor_graceful_restart_set, | |
2ba1fe69 | 2413 | bgp_neighbor_graceful_restart_set_cmd, |
2414 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2415 | NEIGHBOR_STR | |
2416 | NEIGHBOR_ADDR_STR2 | |
2417 | GR_NEIGHBOR_CMD | |
055679e9 | 2418 | ) |
2419 | { | |
2420 | int idx_peer = 1; | |
2421 | struct peer *peer; | |
2422 | int ret = BGP_GR_FAILURE; | |
2423 | ||
dc95985f | 2424 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2425 | ||
055679e9 | 2426 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2427 | zlog_debug( | |
2ba1fe69 | 2428 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START "); |
dc95985f | 2429 | |
055679e9 | 2430 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2431 | if (!peer) | |
2432 | return CMD_WARNING_CONFIG_FAILED; | |
2433 | ||
2434 | ret = bgp_neighbor_graceful_restart(peer, PEER_GR_CMD); | |
2435 | ||
dc95985f | 2436 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2437 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2438 | |
2439 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2440 | zlog_debug( | |
2ba1fe69 | 2441 | "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2442 | vty_out(vty, |
2443 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2444 | |
2445 | return bgp_vty_return(vty, ret); | |
2446 | } | |
2447 | ||
2448 | DEFUN (no_bgp_neighbor_graceful_restart, | |
2ba1fe69 | 2449 | no_bgp_neighbor_graceful_restart_set_cmd, |
2450 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart", | |
2451 | NO_STR | |
2452 | NEIGHBOR_STR | |
2453 | NEIGHBOR_ADDR_STR2 | |
2454 | NO_GR_NEIGHBOR_CMD | |
055679e9 | 2455 | ) |
2456 | { | |
2457 | int idx_peer = 2; | |
2458 | int ret = BGP_GR_FAILURE; | |
2459 | struct peer *peer; | |
2460 | ||
dc95985f | 2461 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2462 | ||
055679e9 | 2463 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2464 | if (!peer) | |
2465 | return CMD_WARNING_CONFIG_FAILED; | |
2466 | ||
2467 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2468 | zlog_debug( | |
2ba1fe69 | 2469 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START "); |
055679e9 | 2470 | |
2471 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_GR_CMD); | |
2472 | ||
dc95985f | 2473 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2474 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2475 | |
2476 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2477 | zlog_debug( | |
2ba1fe69 | 2478 | "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END "); |
dc95985f | 2479 | vty_out(vty, |
2480 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2481 | |
2482 | return bgp_vty_return(vty, ret); | |
2483 | } | |
2484 | ||
2485 | DEFUN (bgp_neighbor_graceful_restart_helper_set, | |
2ba1fe69 | 2486 | bgp_neighbor_graceful_restart_helper_set_cmd, |
2487 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2488 | NEIGHBOR_STR | |
2489 | NEIGHBOR_ADDR_STR2 | |
2490 | GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2491 | ) |
2492 | { | |
2493 | int idx_peer = 1; | |
2494 | struct peer *peer; | |
2495 | int ret = BGP_GR_FAILURE; | |
2496 | ||
dc95985f | 2497 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2498 | ||
055679e9 | 2499 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2500 | zlog_debug( | |
2ba1fe69 | 2501 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
dc95985f | 2502 | |
055679e9 | 2503 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2504 | ||
055679e9 | 2505 | if (!peer) |
2506 | return CMD_WARNING_CONFIG_FAILED; | |
2507 | ||
2508 | ||
2509 | ret = bgp_neighbor_graceful_restart(peer, PEER_HELPER_CMD); | |
5cce3f05 | 2510 | |
dc95985f | 2511 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2512 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
5cce3f05 | 2513 | |
055679e9 | 2514 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2515 | zlog_debug( | |
2ba1fe69 | 2516 | "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2517 | vty_out(vty, |
2518 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2519 | |
2520 | return bgp_vty_return(vty, ret); | |
2521 | } | |
2522 | ||
2523 | DEFUN (no_bgp_neighbor_graceful_restart_helper, | |
2ba1fe69 | 2524 | no_bgp_neighbor_graceful_restart_helper_set_cmd, |
2525 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper", | |
2526 | NO_STR | |
2527 | NEIGHBOR_STR | |
2528 | NEIGHBOR_ADDR_STR2 | |
2529 | NO_GR_NEIGHBOR_HELPER_CMD | |
055679e9 | 2530 | ) |
2531 | { | |
2532 | int idx_peer = 2; | |
2533 | int ret = BGP_GR_FAILURE; | |
2534 | struct peer *peer; | |
2535 | ||
dc95985f | 2536 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2537 | ||
055679e9 | 2538 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2539 | if (!peer) | |
2540 | return CMD_WARNING_CONFIG_FAILED; | |
2541 | ||
2542 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2543 | zlog_debug( | |
2ba1fe69 | 2544 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START "); |
055679e9 | 2545 | |
36235319 | 2546 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_HELPER_CMD); |
055679e9 | 2547 | |
dc95985f | 2548 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2549 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2550 | |
2551 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2552 | zlog_debug( | |
2ba1fe69 | 2553 | "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END "); |
dc95985f | 2554 | vty_out(vty, |
2555 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2556 | |
2557 | return bgp_vty_return(vty, ret); | |
2558 | } | |
2559 | ||
2560 | DEFUN (bgp_neighbor_graceful_restart_disable_set, | |
2ba1fe69 | 2561 | bgp_neighbor_graceful_restart_disable_set_cmd, |
2562 | "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2563 | NEIGHBOR_STR | |
2564 | NEIGHBOR_ADDR_STR2 | |
2565 | GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2566 | ) |
2567 | { | |
2568 | int idx_peer = 1; | |
2569 | struct peer *peer; | |
2570 | int ret = BGP_GR_FAILURE; | |
2571 | ||
dc95985f | 2572 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2573 | ||
055679e9 | 2574 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2575 | zlog_debug( | |
2ba1fe69 | 2576 | "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2577 | |
2578 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
2579 | if (!peer) | |
2580 | return CMD_WARNING_CONFIG_FAILED; | |
2581 | ||
36235319 | 2582 | ret = bgp_neighbor_graceful_restart(peer, PEER_DISABLE_CMD); |
055679e9 | 2583 | |
2584 | if (peer->bgp->t_startup) | |
2585 | bgp_peer_gr_flags_update(peer); | |
2586 | ||
dc95985f | 2587 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2588 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
2589 | ||
055679e9 | 2590 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) |
2591 | zlog_debug( | |
2ba1fe69 | 2592 | "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2593 | vty_out(vty, |
2594 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2595 | |
2596 | return bgp_vty_return(vty, ret); | |
2597 | } | |
2598 | ||
2599 | DEFUN (no_bgp_neighbor_graceful_restart_disable, | |
2ba1fe69 | 2600 | no_bgp_neighbor_graceful_restart_disable_set_cmd, |
2601 | "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable", | |
2602 | NO_STR | |
2603 | NEIGHBOR_STR | |
2604 | NEIGHBOR_ADDR_STR2 | |
2605 | NO_GR_NEIGHBOR_DISABLE_CMD | |
055679e9 | 2606 | ) |
2607 | { | |
2608 | int idx_peer = 2; | |
2609 | int ret = BGP_GR_FAILURE; | |
2610 | struct peer *peer; | |
2611 | ||
dc95985f | 2612 | VTY_BGP_GR_DEFINE_LOOP_VARIABLE; |
2613 | ||
055679e9 | 2614 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2615 | if (!peer) | |
2616 | return CMD_WARNING_CONFIG_FAILED; | |
2617 | ||
2618 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2619 | zlog_debug( | |
2ba1fe69 | 2620 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START "); |
055679e9 | 2621 | |
2622 | ret = bgp_neighbor_graceful_restart(peer, NO_PEER_DISABLE_CMD); | |
2623 | ||
dc95985f | 2624 | VTY_BGP_GR_ROUTER_DETECT(bgp, peer, peer->bgp->peer); |
2625 | VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer->bgp, ret); | |
055679e9 | 2626 | |
2627 | if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) | |
2628 | zlog_debug( | |
2ba1fe69 | 2629 | "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END "); |
dc95985f | 2630 | vty_out(vty, |
2631 | "Graceful restart configuration changed, reset this peer to take effect\n"); | |
055679e9 | 2632 | |
2633 | return bgp_vty_return(vty, ret); | |
2634 | } | |
2635 | ||
d6e3c15b | 2636 | DEFUN_HIDDEN (bgp_graceful_restart_disable_eor, |
2637 | bgp_graceful_restart_disable_eor_cmd, | |
2638 | "bgp graceful-restart disable-eor", | |
2639 | "BGP specific commands\n" | |
2640 | "Graceful restart configuration parameters\n" | |
2641 | "Disable EOR Check\n") | |
2642 | { | |
2643 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2644 | SET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2645 | |
d6e3c15b | 2646 | return CMD_SUCCESS; |
2647 | } | |
2648 | ||
2649 | DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor, | |
2650 | no_bgp_graceful_restart_disable_eor_cmd, | |
2651 | "no bgp graceful-restart disable-eor", | |
2652 | NO_STR | |
2653 | "BGP specific commands\n" | |
2654 | "Graceful restart configuration parameters\n" | |
2655 | "Disable EOR Check\n") | |
2656 | { | |
2657 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
892fedb6 | 2658 | UNSET_FLAG(bgp->flags, BGP_FLAG_GR_DISABLE_EOR); |
dc95985f | 2659 | |
2660 | return CMD_SUCCESS; | |
2661 | } | |
2662 | ||
2663 | DEFUN (bgp_graceful_restart_rib_stale_time, | |
2664 | bgp_graceful_restart_rib_stale_time_cmd, | |
2665 | "bgp graceful-restart rib-stale-time (1-3600)", | |
2666 | "BGP specific commands\n" | |
2667 | "Graceful restart configuration parameters\n" | |
2668 | "Specify the stale route removal timer in rib\n" | |
2669 | "Delay value (seconds)\n") | |
2670 | { | |
2671 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2672 | int idx_number = 3; | |
2673 | uint32_t stale_time; | |
2674 | ||
2675 | stale_time = strtoul(argv[idx_number]->arg, NULL, 10); | |
2676 | bgp->rib_stale_time = stale_time; | |
2677 | /* Send the stale timer update message to RIB */ | |
2678 | if (bgp_zebra_stale_timer_update(bgp)) | |
2679 | return CMD_WARNING; | |
2680 | ||
2681 | return CMD_SUCCESS; | |
2682 | } | |
2683 | ||
2684 | DEFUN (no_bgp_graceful_restart_rib_stale_time, | |
2685 | no_bgp_graceful_restart_rib_stale_time_cmd, | |
2686 | "no bgp graceful-restart rib-stale-time [(1-3600)]", | |
2687 | NO_STR | |
2688 | "BGP specific commands\n" | |
2689 | "Graceful restart configuration parameters\n" | |
2690 | "Specify the stale route removal timer in rib\n" | |
2691 | "Delay value (seconds)\n") | |
2692 | { | |
2693 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2694 | ||
2695 | bgp->rib_stale_time = BGP_DEFAULT_RIB_STALE_TIME; | |
2696 | /* Send the stale timer update message to RIB */ | |
2697 | if (bgp_zebra_stale_timer_update(bgp)) | |
2698 | return CMD_WARNING; | |
2699 | ||
d6e3c15b | 2700 | return CMD_SUCCESS; |
2701 | } | |
2702 | ||
7f323236 DW |
2703 | /* "bgp graceful-shutdown" configuration */ |
2704 | DEFUN (bgp_graceful_shutdown, | |
2705 | bgp_graceful_shutdown_cmd, | |
2706 | "bgp graceful-shutdown", | |
2707 | BGP_STR | |
2708 | "Graceful shutdown parameters\n") | |
2709 | { | |
2710 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2711 | ||
892fedb6 DA |
2712 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2713 | SET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2714 | bgp_static_redo_import_check(bgp); |
2715 | bgp_redistribute_redo(bgp); | |
2716 | bgp_clear_star_soft_out(vty, bgp->name); | |
2717 | bgp_clear_star_soft_in(vty, bgp->name); | |
2718 | } | |
2719 | ||
2720 | return CMD_SUCCESS; | |
2721 | } | |
2722 | ||
2723 | DEFUN (no_bgp_graceful_shutdown, | |
2724 | no_bgp_graceful_shutdown_cmd, | |
2725 | "no bgp graceful-shutdown", | |
2726 | NO_STR | |
2727 | BGP_STR | |
2728 | "Graceful shutdown parameters\n") | |
2729 | { | |
2730 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2731 | ||
892fedb6 DA |
2732 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) { |
2733 | UNSET_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
7f323236 DW |
2734 | bgp_static_redo_import_check(bgp); |
2735 | bgp_redistribute_redo(bgp); | |
2736 | bgp_clear_star_soft_out(vty, bgp->name); | |
2737 | bgp_clear_star_soft_in(vty, bgp->name); | |
2738 | } | |
2739 | ||
2740 | return CMD_SUCCESS; | |
2741 | } | |
2742 | ||
718e3744 | 2743 | /* "bgp fast-external-failover" configuration. */ |
2744 | DEFUN (bgp_fast_external_failover, | |
2745 | bgp_fast_external_failover_cmd, | |
2746 | "bgp fast-external-failover", | |
2747 | BGP_STR | |
2748 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2749 | { | |
d62a17ae | 2750 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2751 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2752 | return CMD_SUCCESS; |
718e3744 | 2753 | } |
2754 | ||
2755 | DEFUN (no_bgp_fast_external_failover, | |
2756 | no_bgp_fast_external_failover_cmd, | |
2757 | "no bgp fast-external-failover", | |
2758 | NO_STR | |
2759 | BGP_STR | |
2760 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2761 | { | |
d62a17ae | 2762 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2763 | SET_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
d62a17ae | 2764 | return CMD_SUCCESS; |
718e3744 | 2765 | } |
6b0655a2 | 2766 | |
718e3744 | 2767 | /* "bgp bestpath compare-routerid" configuration. */ |
2768 | DEFUN (bgp_bestpath_compare_router_id, | |
2769 | bgp_bestpath_compare_router_id_cmd, | |
2770 | "bgp bestpath compare-routerid", | |
2771 | "BGP specific commands\n" | |
2772 | "Change the default bestpath selection\n" | |
2773 | "Compare router-id for identical EBGP paths\n") | |
2774 | { | |
d62a17ae | 2775 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2776 | SET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2777 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2778 | |
d62a17ae | 2779 | return CMD_SUCCESS; |
718e3744 | 2780 | } |
2781 | ||
2782 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2783 | no_bgp_bestpath_compare_router_id_cmd, | |
2784 | "no bgp bestpath compare-routerid", | |
2785 | NO_STR | |
2786 | "BGP specific commands\n" | |
2787 | "Change the default bestpath selection\n" | |
2788 | "Compare router-id for identical EBGP paths\n") | |
2789 | { | |
d62a17ae | 2790 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2791 | UNSET_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID); |
d62a17ae | 2792 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2793 | |
d62a17ae | 2794 | return CMD_SUCCESS; |
718e3744 | 2795 | } |
6b0655a2 | 2796 | |
718e3744 | 2797 | /* "bgp bestpath as-path ignore" configuration. */ |
2798 | DEFUN (bgp_bestpath_aspath_ignore, | |
2799 | bgp_bestpath_aspath_ignore_cmd, | |
2800 | "bgp bestpath as-path ignore", | |
2801 | "BGP specific commands\n" | |
2802 | "Change the default bestpath selection\n" | |
2803 | "AS-path attribute\n" | |
2804 | "Ignore as-path length in selecting a route\n") | |
2805 | { | |
d62a17ae | 2806 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2807 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2808 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2809 | |
d62a17ae | 2810 | return CMD_SUCCESS; |
718e3744 | 2811 | } |
2812 | ||
2813 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2814 | no_bgp_bestpath_aspath_ignore_cmd, | |
2815 | "no bgp bestpath as-path ignore", | |
2816 | NO_STR | |
2817 | "BGP specific commands\n" | |
2818 | "Change the default bestpath selection\n" | |
2819 | "AS-path attribute\n" | |
2820 | "Ignore as-path length in selecting a route\n") | |
2821 | { | |
d62a17ae | 2822 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2823 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE); |
d62a17ae | 2824 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2825 | |
d62a17ae | 2826 | return CMD_SUCCESS; |
718e3744 | 2827 | } |
6b0655a2 | 2828 | |
6811845b | 2829 | /* "bgp bestpath as-path confed" configuration. */ |
2830 | DEFUN (bgp_bestpath_aspath_confed, | |
2831 | bgp_bestpath_aspath_confed_cmd, | |
2832 | "bgp bestpath as-path confed", | |
2833 | "BGP specific commands\n" | |
2834 | "Change the default bestpath selection\n" | |
2835 | "AS-path attribute\n" | |
2836 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2837 | { | |
d62a17ae | 2838 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2839 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2840 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2841 | |
d62a17ae | 2842 | return CMD_SUCCESS; |
6811845b | 2843 | } |
2844 | ||
2845 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2846 | no_bgp_bestpath_aspath_confed_cmd, | |
2847 | "no bgp bestpath as-path confed", | |
2848 | NO_STR | |
2849 | "BGP specific commands\n" | |
2850 | "Change the default bestpath selection\n" | |
2851 | "AS-path attribute\n" | |
2852 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2853 | { | |
d62a17ae | 2854 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2855 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED); |
d62a17ae | 2856 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2857 | |
d62a17ae | 2858 | return CMD_SUCCESS; |
6811845b | 2859 | } |
6b0655a2 | 2860 | |
2fdd455c PM |
2861 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2862 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2863 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2864 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2865 | "BGP specific commands\n" |
2866 | "Change the default bestpath selection\n" | |
2867 | "AS-path attribute\n" | |
2868 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2869 | "Generate an AS_SET\n" |
16fc1eec DS |
2870 | "Do not generate an AS_SET\n") |
2871 | { | |
d62a17ae | 2872 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2873 | int idx = 0; | |
892fedb6 | 2874 | SET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 2875 | |
d62a17ae | 2876 | /* no-as-set is now the default behavior so we can silently |
2877 | * ignore it */ | |
2878 | if (argv_find(argv, argc, "as-set", &idx)) | |
892fedb6 | 2879 | SET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
d62a17ae | 2880 | else |
892fedb6 | 2881 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
219178b6 | 2882 | |
d62a17ae | 2883 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2884 | |
d62a17ae | 2885 | return CMD_SUCCESS; |
16fc1eec DS |
2886 | } |
2887 | ||
219178b6 DW |
2888 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2889 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2890 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2891 | NO_STR |
2892 | "BGP specific commands\n" | |
2893 | "Change the default bestpath selection\n" | |
2894 | "AS-path attribute\n" | |
2895 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2896 | "Generate an AS_SET\n" |
16fc1eec DS |
2897 | "Do not generate an AS_SET\n") |
2898 | { | |
d62a17ae | 2899 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
2900 | UNSET_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
2901 | UNSET_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
d62a17ae | 2902 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2903 | |
d62a17ae | 2904 | return CMD_SUCCESS; |
2fdd455c | 2905 | } |
6b0655a2 | 2906 | |
848973c7 | 2907 | /* "bgp log-neighbor-changes" configuration. */ |
2908 | DEFUN (bgp_log_neighbor_changes, | |
2909 | bgp_log_neighbor_changes_cmd, | |
2910 | "bgp log-neighbor-changes", | |
2911 | "BGP specific commands\n" | |
2912 | "Log neighbor up/down and reset reason\n") | |
2913 | { | |
d62a17ae | 2914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2915 | SET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2916 | return CMD_SUCCESS; |
848973c7 | 2917 | } |
2918 | ||
2919 | DEFUN (no_bgp_log_neighbor_changes, | |
2920 | no_bgp_log_neighbor_changes_cmd, | |
2921 | "no bgp log-neighbor-changes", | |
2922 | NO_STR | |
2923 | "BGP specific commands\n" | |
2924 | "Log neighbor up/down and reset reason\n") | |
2925 | { | |
d62a17ae | 2926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 2927 | UNSET_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
d62a17ae | 2928 | return CMD_SUCCESS; |
848973c7 | 2929 | } |
6b0655a2 | 2930 | |
718e3744 | 2931 | /* "bgp bestpath med" configuration. */ |
2932 | DEFUN (bgp_bestpath_med, | |
2933 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2934 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2935 | "BGP specific commands\n" |
2936 | "Change the default bestpath selection\n" | |
2937 | "MED attribute\n" | |
2938 | "Compare MED among confederation paths\n" | |
838758ac DW |
2939 | "Treat missing MED as the least preferred one\n" |
2940 | "Treat missing MED as the least preferred one\n" | |
2941 | "Compare MED among confederation paths\n") | |
718e3744 | 2942 | { |
d62a17ae | 2943 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2944 | |
d62a17ae | 2945 | int idx = 0; |
2946 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2947 | SET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2948 | idx = 0; |
2949 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2950 | SET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
e52702f2 | 2951 | |
d62a17ae | 2952 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2953 | |
d62a17ae | 2954 | return CMD_SUCCESS; |
718e3744 | 2955 | } |
2956 | ||
718e3744 | 2957 | DEFUN (no_bgp_bestpath_med, |
2958 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2959 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2960 | NO_STR |
2961 | "BGP specific commands\n" | |
2962 | "Change the default bestpath selection\n" | |
2963 | "MED attribute\n" | |
2964 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2965 | "Treat missing MED as the least preferred one\n" |
2966 | "Treat missing MED as the least preferred one\n" | |
2967 | "Compare MED among confederation paths\n") | |
718e3744 | 2968 | { |
d62a17ae | 2969 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2970 | |
d62a17ae | 2971 | int idx = 0; |
2972 | if (argv_find(argv, argc, "confed", &idx)) | |
892fedb6 | 2973 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_CONFED); |
d62a17ae | 2974 | idx = 0; |
2975 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
892fedb6 | 2976 | UNSET_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST); |
718e3744 | 2977 | |
d62a17ae | 2978 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2979 | |
d62a17ae | 2980 | return CMD_SUCCESS; |
718e3744 | 2981 | } |
2982 | ||
f7e1c681 | 2983 | /* "bgp bestpath bandwidth" configuration. */ |
2984 | DEFPY (bgp_bestpath_bw, | |
2985 | bgp_bestpath_bw_cmd, | |
2986 | "[no$no] bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]", | |
2987 | NO_STR | |
2988 | "BGP specific commands\n" | |
2989 | "Change the default bestpath selection\n" | |
2990 | "Link Bandwidth attribute\n" | |
2991 | "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" | |
2992 | "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" | |
2993 | "Assign a low default weight (value 1) to paths not having link bandwidth\n") | |
2994 | { | |
2995 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2996 | afi_t afi; | |
2997 | safi_t safi; | |
2998 | ||
2999 | if (no) { | |
3000 | bgp->lb_handling = BGP_LINK_BW_ECMP; | |
3001 | } else { | |
3002 | if (!bw_cfg) { | |
3003 | vty_out(vty, "%% Bandwidth configuration must be specified\n"); | |
3004 | return CMD_ERR_INCOMPLETE; | |
3005 | } | |
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; | |
3014 | } | |
3015 | ||
3016 | /* This config is used in route install, so redo that. */ | |
3017 | FOREACH_AFI_SAFI (afi, safi) { | |
3018 | if (!bgp_fibupd_safi(safi)) | |
3019 | continue; | |
3020 | bgp_zebra_announce_table(bgp, afi, safi); | |
3021 | } | |
3022 | ||
3023 | return CMD_SUCCESS; | |
3024 | } | |
3025 | ||
718e3744 | 3026 | /* "no bgp default ipv4-unicast". */ |
3027 | DEFUN (no_bgp_default_ipv4_unicast, | |
3028 | no_bgp_default_ipv4_unicast_cmd, | |
3029 | "no bgp default ipv4-unicast", | |
3030 | NO_STR | |
3031 | "BGP specific commands\n" | |
3032 | "Configure BGP defaults\n" | |
3033 | "Activate ipv4-unicast for a peer by default\n") | |
3034 | { | |
d62a17ae | 3035 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3036 | SET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3037 | return CMD_SUCCESS; |
718e3744 | 3038 | } |
3039 | ||
3040 | DEFUN (bgp_default_ipv4_unicast, | |
3041 | bgp_default_ipv4_unicast_cmd, | |
3042 | "bgp default ipv4-unicast", | |
3043 | "BGP specific commands\n" | |
3044 | "Configure BGP defaults\n" | |
3045 | "Activate ipv4-unicast for a peer by default\n") | |
3046 | { | |
d62a17ae | 3047 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3048 | UNSET_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4); |
d62a17ae | 3049 | return CMD_SUCCESS; |
718e3744 | 3050 | } |
6b0655a2 | 3051 | |
04b6bdc0 DW |
3052 | /* Display hostname in certain command outputs */ |
3053 | DEFUN (bgp_default_show_hostname, | |
3054 | bgp_default_show_hostname_cmd, | |
3055 | "bgp default show-hostname", | |
3056 | "BGP specific commands\n" | |
3057 | "Configure BGP defaults\n" | |
0437e105 | 3058 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3059 | { |
d62a17ae | 3060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3061 | SET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3062 | return CMD_SUCCESS; |
04b6bdc0 DW |
3063 | } |
3064 | ||
3065 | DEFUN (no_bgp_default_show_hostname, | |
3066 | no_bgp_default_show_hostname_cmd, | |
3067 | "no bgp default show-hostname", | |
3068 | NO_STR | |
3069 | "BGP specific commands\n" | |
3070 | "Configure BGP defaults\n" | |
0437e105 | 3071 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 3072 | { |
d62a17ae | 3073 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3074 | UNSET_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME); |
d62a17ae | 3075 | return CMD_SUCCESS; |
04b6bdc0 DW |
3076 | } |
3077 | ||
8233ef81 | 3078 | /* "bgp network import-check" configuration. */ |
718e3744 | 3079 | DEFUN (bgp_network_import_check, |
3080 | bgp_network_import_check_cmd, | |
5623e905 | 3081 | "bgp network import-check", |
718e3744 | 3082 | "BGP specific commands\n" |
3083 | "BGP network command\n" | |
5623e905 | 3084 | "Check BGP network route exists in IGP\n") |
718e3744 | 3085 | { |
d62a17ae | 3086 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3087 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3088 | SET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3089 | bgp_static_redo_import_check(bgp); |
3090 | } | |
078430f6 | 3091 | |
d62a17ae | 3092 | return CMD_SUCCESS; |
718e3744 | 3093 | } |
3094 | ||
d62a17ae | 3095 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
3096 | "bgp network import-check exact", | |
3097 | "BGP specific commands\n" | |
3098 | "BGP network command\n" | |
3099 | "Check BGP network route exists in IGP\n" | |
3100 | "Match route precisely\n") | |
8233ef81 | 3101 | |
718e3744 | 3102 | DEFUN (no_bgp_network_import_check, |
3103 | no_bgp_network_import_check_cmd, | |
5623e905 | 3104 | "no bgp network import-check", |
718e3744 | 3105 | NO_STR |
3106 | "BGP specific commands\n" | |
3107 | "BGP network command\n" | |
3108 | "Check BGP network route exists in IGP\n") | |
3109 | { | |
d62a17ae | 3110 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 DA |
3111 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { |
3112 | UNSET_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK); | |
d62a17ae | 3113 | bgp_static_redo_import_check(bgp); |
3114 | } | |
5623e905 | 3115 | |
d62a17ae | 3116 | return CMD_SUCCESS; |
718e3744 | 3117 | } |
6b0655a2 | 3118 | |
718e3744 | 3119 | DEFUN (bgp_default_local_preference, |
3120 | bgp_default_local_preference_cmd, | |
6147e2c6 | 3121 | "bgp default local-preference (0-4294967295)", |
718e3744 | 3122 | "BGP specific commands\n" |
3123 | "Configure BGP defaults\n" | |
3124 | "local preference (higher=more preferred)\n" | |
3125 | "Configure default local preference value\n") | |
3126 | { | |
d62a17ae | 3127 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3128 | int idx_number = 3; | |
d7c0a89a | 3129 | uint32_t local_pref; |
718e3744 | 3130 | |
d62a17ae | 3131 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 3132 | |
d62a17ae | 3133 | bgp_default_local_preference_set(bgp, local_pref); |
3134 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 3135 | |
d62a17ae | 3136 | return CMD_SUCCESS; |
718e3744 | 3137 | } |
3138 | ||
3139 | DEFUN (no_bgp_default_local_preference, | |
3140 | no_bgp_default_local_preference_cmd, | |
838758ac | 3141 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 3142 | NO_STR |
3143 | "BGP specific commands\n" | |
3144 | "Configure BGP defaults\n" | |
838758ac DW |
3145 | "local preference (higher=more preferred)\n" |
3146 | "Configure default local preference value\n") | |
718e3744 | 3147 | { |
d62a17ae | 3148 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3149 | bgp_default_local_preference_unset(bgp); | |
3150 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 3151 | |
d62a17ae | 3152 | return CMD_SUCCESS; |
718e3744 | 3153 | } |
3154 | ||
6b0655a2 | 3155 | |
3f9c7369 DS |
3156 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
3157 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 3158 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
3159 | "BGP specific commands\n" |
3160 | "Configure BGP defaults\n" | |
3161 | "subgroup-pkt-queue-max\n" | |
3162 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 3163 | { |
d62a17ae | 3164 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3165 | int idx_number = 3; | |
d7c0a89a | 3166 | uint32_t max_size; |
8bd9d948 | 3167 | |
d62a17ae | 3168 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 3169 | |
d62a17ae | 3170 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 3171 | |
d62a17ae | 3172 | return CMD_SUCCESS; |
3f9c7369 DS |
3173 | } |
3174 | ||
3175 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
3176 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 3177 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
3178 | NO_STR |
3179 | "BGP specific commands\n" | |
3180 | "Configure BGP defaults\n" | |
838758ac DW |
3181 | "subgroup-pkt-queue-max\n" |
3182 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 3183 | { |
d62a17ae | 3184 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3185 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
3186 | return CMD_SUCCESS; | |
8bd9d948 DS |
3187 | } |
3188 | ||
813d4307 | 3189 | |
8bd9d948 DS |
3190 | DEFUN (bgp_rr_allow_outbound_policy, |
3191 | bgp_rr_allow_outbound_policy_cmd, | |
3192 | "bgp route-reflector allow-outbound-policy", | |
3193 | "BGP specific commands\n" | |
3194 | "Allow modifications made by out route-map\n" | |
3195 | "on ibgp neighbors\n") | |
3196 | { | |
d62a17ae | 3197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3198 | |
892fedb6 DA |
3199 | if (!CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3200 | SET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3201 | update_group_announce_rrclients(bgp); |
3202 | bgp_clear_star_soft_out(vty, bgp->name); | |
3203 | } | |
8bd9d948 | 3204 | |
d62a17ae | 3205 | return CMD_SUCCESS; |
8bd9d948 DS |
3206 | } |
3207 | ||
3208 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
3209 | no_bgp_rr_allow_outbound_policy_cmd, | |
3210 | "no bgp route-reflector allow-outbound-policy", | |
3211 | NO_STR | |
3212 | "BGP specific commands\n" | |
3213 | "Allow modifications made by out route-map\n" | |
3214 | "on ibgp neighbors\n") | |
3215 | { | |
d62a17ae | 3216 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 3217 | |
892fedb6 DA |
3218 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
3219 | UNSET_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
d62a17ae | 3220 | update_group_announce_rrclients(bgp); |
3221 | bgp_clear_star_soft_out(vty, bgp->name); | |
3222 | } | |
8bd9d948 | 3223 | |
d62a17ae | 3224 | return CMD_SUCCESS; |
8bd9d948 DS |
3225 | } |
3226 | ||
f14e6fdb DS |
3227 | DEFUN (bgp_listen_limit, |
3228 | bgp_listen_limit_cmd, | |
9ccf14f7 | 3229 | "bgp listen limit (1-5000)", |
f14e6fdb | 3230 | "BGP specific commands\n" |
1601a46f | 3231 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3232 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
f14e6fdb DS |
3233 | "Configure Dynamic Neighbors listen limit value\n") |
3234 | { | |
d62a17ae | 3235 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3236 | int idx_number = 3; | |
3237 | int listen_limit; | |
f14e6fdb | 3238 | |
d62a17ae | 3239 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 3240 | |
d62a17ae | 3241 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 3242 | |
d62a17ae | 3243 | return CMD_SUCCESS; |
f14e6fdb DS |
3244 | } |
3245 | ||
3246 | DEFUN (no_bgp_listen_limit, | |
3247 | no_bgp_listen_limit_cmd, | |
838758ac | 3248 | "no bgp listen limit [(1-5000)]", |
1601a46f | 3249 | NO_STR |
f14e6fdb | 3250 | "BGP specific commands\n" |
1601a46f | 3251 | "BGP Dynamic Neighbors listen commands\n" |
85bb4595 | 3252 | "Maximum number of BGP Dynamic Neighbors that can be created\n" |
838758ac | 3253 | "Configure Dynamic Neighbors listen limit value\n") |
f14e6fdb | 3254 | { |
d62a17ae | 3255 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3256 | bgp_listen_limit_unset(bgp); | |
3257 | return CMD_SUCCESS; | |
f14e6fdb DS |
3258 | } |
3259 | ||
3260 | ||
20eb8864 | 3261 | /* |
3262 | * Check if this listen range is already configured. Check for exact | |
3263 | * match or overlap based on input. | |
3264 | */ | |
d62a17ae | 3265 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
3266 | struct prefix *range, int exact) | |
3267 | { | |
3268 | struct listnode *node, *nnode; | |
3269 | struct listnode *node1, *nnode1; | |
3270 | struct peer_group *group; | |
3271 | struct prefix *lr; | |
3272 | afi_t afi; | |
3273 | int match; | |
3274 | ||
3275 | afi = family2afi(range->family); | |
3276 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3277 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
3278 | lr)) { | |
3279 | if (exact) | |
3280 | match = prefix_same(range, lr); | |
3281 | else | |
3282 | match = (prefix_match(range, lr) | |
3283 | || prefix_match(lr, range)); | |
3284 | if (match) | |
3285 | return group; | |
3286 | } | |
3287 | } | |
3288 | ||
3289 | return NULL; | |
20eb8864 | 3290 | } |
3291 | ||
f14e6fdb DS |
3292 | DEFUN (bgp_listen_range, |
3293 | bgp_listen_range_cmd, | |
d7b9898c | 3294 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 3295 | "BGP specific commands\n" |
d7fa34c1 QY |
3296 | "Configure BGP dynamic neighbors listen range\n" |
3297 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
3298 | NEIGHBOR_ADDR_STR |
3299 | "Member of the peer-group\n" | |
3300 | "Peer-group name\n") | |
f14e6fdb | 3301 | { |
d62a17ae | 3302 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3303 | struct prefix range; | |
3304 | struct peer_group *group, *existing_group; | |
3305 | afi_t afi; | |
3306 | int ret; | |
3307 | int idx = 0; | |
3308 | ||
3309 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3310 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3311 | char *prefix = argv[idx]->arg; | |
d7b9898c | 3312 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3313 | char *peergroup = argv[idx]->arg; |
3314 | ||
3315 | /* Convert IP prefix string to struct prefix. */ | |
3316 | ret = str2prefix(prefix, &range); | |
3317 | if (!ret) { | |
3318 | vty_out(vty, "%% Malformed listen range\n"); | |
3319 | return CMD_WARNING_CONFIG_FAILED; | |
3320 | } | |
3321 | ||
3322 | afi = family2afi(range.family); | |
3323 | ||
3324 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3325 | vty_out(vty, | |
3326 | "%% Malformed listen range (link-local address)\n"); | |
3327 | return CMD_WARNING_CONFIG_FAILED; | |
3328 | } | |
3329 | ||
3330 | apply_mask(&range); | |
3331 | ||
3332 | /* Check if same listen range is already configured. */ | |
3333 | existing_group = listen_range_exists(bgp, &range, 1); | |
3334 | if (existing_group) { | |
3335 | if (strcmp(existing_group->name, peergroup) == 0) | |
3336 | return CMD_SUCCESS; | |
3337 | else { | |
3338 | vty_out(vty, | |
3339 | "%% Same listen range is attached to peer-group %s\n", | |
3340 | existing_group->name); | |
3341 | return CMD_WARNING_CONFIG_FAILED; | |
3342 | } | |
3343 | } | |
3344 | ||
3345 | /* Check if an overlapping listen range exists. */ | |
3346 | if (listen_range_exists(bgp, &range, 0)) { | |
3347 | vty_out(vty, | |
3348 | "%% Listen range overlaps with existing listen range\n"); | |
3349 | return CMD_WARNING_CONFIG_FAILED; | |
3350 | } | |
3351 | ||
3352 | group = peer_group_lookup(bgp, peergroup); | |
3353 | if (!group) { | |
3354 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3355 | return CMD_WARNING_CONFIG_FAILED; | |
3356 | } | |
3357 | ||
3358 | ret = peer_group_listen_range_add(group, &range); | |
3359 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
3360 | } |
3361 | ||
3362 | DEFUN (no_bgp_listen_range, | |
3363 | no_bgp_listen_range_cmd, | |
d7b9898c | 3364 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 3365 | NO_STR |
f14e6fdb | 3366 | "BGP specific commands\n" |
d7fa34c1 QY |
3367 | "Unconfigure BGP dynamic neighbors listen range\n" |
3368 | "Unconfigure BGP dynamic neighbors listen range\n" | |
3369 | NEIGHBOR_ADDR_STR | |
3370 | "Member of the peer-group\n" | |
3371 | "Peer-group name\n") | |
f14e6fdb | 3372 | { |
d62a17ae | 3373 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3374 | struct prefix range; | |
3375 | struct peer_group *group; | |
3376 | afi_t afi; | |
3377 | int ret; | |
3378 | int idx = 0; | |
3379 | ||
3380 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
3381 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
3382 | char *prefix = argv[idx]->arg; | |
21d88a71 | 3383 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 3384 | char *peergroup = argv[idx]->arg; |
3385 | ||
3386 | /* Convert IP prefix string to struct prefix. */ | |
3387 | ret = str2prefix(prefix, &range); | |
3388 | if (!ret) { | |
3389 | vty_out(vty, "%% Malformed listen range\n"); | |
3390 | return CMD_WARNING_CONFIG_FAILED; | |
3391 | } | |
3392 | ||
3393 | afi = family2afi(range.family); | |
3394 | ||
3395 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
3396 | vty_out(vty, | |
3397 | "%% Malformed listen range (link-local address)\n"); | |
3398 | return CMD_WARNING_CONFIG_FAILED; | |
3399 | } | |
3400 | ||
3401 | apply_mask(&range); | |
3402 | ||
3403 | group = peer_group_lookup(bgp, peergroup); | |
3404 | if (!group) { | |
3405 | vty_out(vty, "%% Peer-group does not exist\n"); | |
3406 | return CMD_WARNING_CONFIG_FAILED; | |
3407 | } | |
3408 | ||
3409 | ret = peer_group_listen_range_del(group, &range); | |
3410 | return bgp_vty_return(vty, ret); | |
3411 | } | |
3412 | ||
2b791107 | 3413 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 3414 | { |
3415 | struct peer_group *group; | |
3416 | struct listnode *node, *nnode, *rnode, *nrnode; | |
3417 | struct prefix *range; | |
3418 | afi_t afi; | |
3419 | char buf[PREFIX2STR_BUFFER]; | |
3420 | ||
3421 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
3422 | vty_out(vty, " bgp listen limit %d\n", | |
3423 | bgp->dynamic_neighbors_limit); | |
3424 | ||
3425 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
3426 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
3427 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
3428 | nrnode, range)) { | |
3429 | prefix2str(range, buf, sizeof(buf)); | |
3430 | vty_out(vty, | |
3431 | " bgp listen range %s peer-group %s\n", | |
3432 | buf, group->name); | |
3433 | } | |
3434 | } | |
3435 | } | |
f14e6fdb DS |
3436 | } |
3437 | ||
3438 | ||
907f92c8 DS |
3439 | DEFUN (bgp_disable_connected_route_check, |
3440 | bgp_disable_connected_route_check_cmd, | |
3441 | "bgp disable-ebgp-connected-route-check", | |
3442 | "BGP specific commands\n" | |
3443 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3444 | { | |
d62a17ae | 3445 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3446 | SET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3447 | bgp_clear_star_soft_in(vty, bgp->name); |
7aafcaca | 3448 | |
d62a17ae | 3449 | return CMD_SUCCESS; |
907f92c8 DS |
3450 | } |
3451 | ||
3452 | DEFUN (no_bgp_disable_connected_route_check, | |
3453 | no_bgp_disable_connected_route_check_cmd, | |
3454 | "no bgp disable-ebgp-connected-route-check", | |
3455 | NO_STR | |
3456 | "BGP specific commands\n" | |
3457 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
3458 | { | |
d62a17ae | 3459 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
892fedb6 | 3460 | UNSET_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
d62a17ae | 3461 | bgp_clear_star_soft_in(vty, bgp->name); |
3462 | ||
3463 | return CMD_SUCCESS; | |
3464 | } | |
3465 | ||
3466 | ||
3467 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
3468 | const char *as_str, afi_t afi, safi_t safi) | |
3469 | { | |
3470 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3471 | int ret; | |
3472 | as_t as; | |
3473 | int as_type = AS_SPECIFIED; | |
3474 | union sockunion su; | |
3475 | ||
3476 | if (as_str[0] == 'i') { | |
3477 | as = 0; | |
3478 | as_type = AS_INTERNAL; | |
3479 | } else if (as_str[0] == 'e') { | |
3480 | as = 0; | |
3481 | as_type = AS_EXTERNAL; | |
3482 | } else { | |
3483 | /* Get AS number. */ | |
3484 | as = strtoul(as_str, NULL, 10); | |
3485 | } | |
3486 | ||
390485fd | 3487 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 3488 | ret = str2sockunion(peer_str, &su); |
3489 | if (ret < 0) { | |
390485fd DS |
3490 | struct peer *peer; |
3491 | ||
3492 | /* Check if existing interface peer */ | |
3493 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
3494 | ||
d62a17ae | 3495 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
3496 | safi); | |
390485fd DS |
3497 | |
3498 | /* if not interface peer, check peer-group settings */ | |
3499 | if (ret < 0 && !peer) { | |
d62a17ae | 3500 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
3501 | if (ret < 0) { | |
3502 | vty_out(vty, | |
390485fd | 3503 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 3504 | return CMD_WARNING_CONFIG_FAILED; |
3505 | } | |
3506 | return CMD_SUCCESS; | |
3507 | } | |
3508 | } else { | |
3509 | if (peer_address_self_check(bgp, &su)) { | |
3510 | vty_out(vty, | |
3511 | "%% Can not configure the local system as neighbor\n"); | |
3512 | return CMD_WARNING_CONFIG_FAILED; | |
3513 | } | |
3514 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
3515 | } | |
3516 | ||
3517 | /* This peer belongs to peer group. */ | |
3518 | switch (ret) { | |
3519 | case BGP_ERR_PEER_GROUP_MEMBER: | |
3520 | vty_out(vty, | |
faa16034 | 3521 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 3522 | return CMD_WARNING_CONFIG_FAILED; |
3523 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
3524 | vty_out(vty, | |
faa16034 | 3525 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 3526 | return CMD_WARNING_CONFIG_FAILED; |
3527 | } | |
3528 | return bgp_vty_return(vty, ret); | |
718e3744 | 3529 | } |
3530 | ||
f26845f9 QY |
3531 | DEFUN (bgp_default_shutdown, |
3532 | bgp_default_shutdown_cmd, | |
3533 | "[no] bgp default shutdown", | |
3534 | NO_STR | |
3535 | BGP_STR | |
3536 | "Configure BGP defaults\n" | |
b012cbe2 | 3537 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
3538 | { |
3539 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3540 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
3541 | return CMD_SUCCESS; | |
3542 | } | |
3543 | ||
718e3744 | 3544 | DEFUN (neighbor_remote_as, |
3545 | neighbor_remote_as_cmd, | |
3a2d747c | 3546 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3547 | NEIGHBOR_STR |
3548 | NEIGHBOR_ADDR_STR2 | |
3549 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 3550 | AS_STR |
3a2d747c QY |
3551 | "Internal BGP peer\n" |
3552 | "External BGP peer\n") | |
718e3744 | 3553 | { |
d62a17ae | 3554 | int idx_peer = 1; |
3555 | int idx_remote_as = 3; | |
3556 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
3557 | argv[idx_remote_as]->arg, AFI_IP, | |
3558 | SAFI_UNICAST); | |
3559 | } | |
3560 | ||
3561 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
3562 | afi_t afi, safi_t safi, int v6only, | |
3563 | const char *peer_group_name, | |
3564 | const char *as_str) | |
3565 | { | |
3566 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
3567 | as_t as = 0; | |
3568 | int as_type = AS_UNSPECIFIED; | |
3569 | struct peer *peer; | |
3570 | struct peer_group *group; | |
3571 | int ret = 0; | |
3572 | union sockunion su; | |
3573 | ||
3574 | group = peer_group_lookup(bgp, conf_if); | |
3575 | ||
3576 | if (group) { | |
3577 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
3578 | return CMD_WARNING_CONFIG_FAILED; | |
3579 | } | |
3580 | ||
3581 | if (as_str) { | |
3582 | if (as_str[0] == 'i') { | |
3583 | as_type = AS_INTERNAL; | |
3584 | } else if (as_str[0] == 'e') { | |
3585 | as_type = AS_EXTERNAL; | |
3586 | } else { | |
3587 | /* Get AS number. */ | |
3588 | as = strtoul(as_str, NULL, 10); | |
3589 | as_type = AS_SPECIFIED; | |
3590 | } | |
3591 | } | |
3592 | ||
3593 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
3594 | if (peer) { | |
3595 | if (as_str) | |
cc4d4ce8 | 3596 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 3597 | afi, safi); |
3598 | } else { | |
892fedb6 | 3599 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4) |
d62a17ae | 3600 | && afi == AFI_IP && safi == SAFI_UNICAST) |
3601 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3602 | as_type, 0, 0, NULL); | |
3603 | else | |
3604 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
3605 | as_type, afi, safi, NULL); | |
3606 | ||
3607 | if (!peer) { | |
3608 | vty_out(vty, "%% BGP failed to create peer\n"); | |
3609 | return CMD_WARNING_CONFIG_FAILED; | |
3610 | } | |
3611 | ||
3612 | if (v6only) | |
527de3dc | 3613 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3614 | |
3615 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
3616 | * this | |
3617 | * any unnumbered peer in order to not worry about run-time | |
3618 | * transitions | |
3619 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
3620 | * address | |
3621 | * gets deleted later etc.) | |
3622 | */ | |
3623 | if (peer->ifp) | |
3624 | bgp_zebra_initiate_radv(bgp, peer); | |
3625 | } | |
3626 | ||
3627 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
3628 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
3629 | if (v6only) | |
527de3dc | 3630 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3631 | else |
527de3dc | 3632 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 3633 | |
3634 | /* v6only flag changed. Reset bgp seesion */ | |
3635 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
3636 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
3637 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
3638 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
3639 | } else | |
3640 | bgp_session_reset(peer); | |
3641 | } | |
3642 | ||
9fb964de PM |
3643 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3644 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3645 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3646 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3647 | } |
d62a17ae | 3648 | |
3649 | if (peer_group_name) { | |
3650 | group = peer_group_lookup(bgp, peer_group_name); | |
3651 | if (!group) { | |
3652 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3653 | return CMD_WARNING_CONFIG_FAILED; | |
3654 | } | |
3655 | ||
3656 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3657 | } | |
3658 | ||
3659 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3660 | } |
3661 | ||
4c48cf63 DW |
3662 | DEFUN (neighbor_interface_config, |
3663 | neighbor_interface_config_cmd, | |
d7b9898c | 3664 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3665 | NEIGHBOR_STR |
3666 | "Interface name or neighbor tag\n" | |
31500417 DW |
3667 | "Enable BGP on interface\n" |
3668 | "Member of the peer-group\n" | |
16cedbb0 | 3669 | "Peer-group name\n") |
4c48cf63 | 3670 | { |
d62a17ae | 3671 | int idx_word = 1; |
3672 | int idx_peer_group_word = 4; | |
31500417 | 3673 | |
d62a17ae | 3674 | if (argc > idx_peer_group_word) |
3675 | return peer_conf_interface_get( | |
3676 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3677 | argv[idx_peer_group_word]->arg, NULL); | |
3678 | else | |
3679 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3680 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3681 | } |
3682 | ||
4c48cf63 DW |
3683 | DEFUN (neighbor_interface_config_v6only, |
3684 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 3685 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3686 | NEIGHBOR_STR |
3687 | "Interface name or neighbor tag\n" | |
3688 | "Enable BGP on interface\n" | |
31500417 DW |
3689 | "Enable BGP with v6 link-local only\n" |
3690 | "Member of the peer-group\n" | |
16cedbb0 | 3691 | "Peer-group name\n") |
4c48cf63 | 3692 | { |
d62a17ae | 3693 | int idx_word = 1; |
3694 | int idx_peer_group_word = 5; | |
31500417 | 3695 | |
d62a17ae | 3696 | if (argc > idx_peer_group_word) |
3697 | return peer_conf_interface_get( | |
3698 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3699 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3700 | |
d62a17ae | 3701 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3702 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3703 | } |
3704 | ||
a80beece | 3705 | |
b3a39dc5 DD |
3706 | DEFUN (neighbor_interface_config_remote_as, |
3707 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3708 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3709 | NEIGHBOR_STR |
3710 | "Interface name or neighbor tag\n" | |
3711 | "Enable BGP on interface\n" | |
3a2d747c | 3712 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3713 | AS_STR |
3a2d747c QY |
3714 | "Internal BGP peer\n" |
3715 | "External BGP peer\n") | |
b3a39dc5 | 3716 | { |
d62a17ae | 3717 | int idx_word = 1; |
3718 | int idx_remote_as = 4; | |
3719 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3720 | SAFI_UNICAST, 0, NULL, | |
3721 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3722 | } |
3723 | ||
3724 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3725 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3726 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3727 | NEIGHBOR_STR |
3728 | "Interface name or neighbor tag\n" | |
3a2d747c | 3729 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3730 | "Enable BGP on interface\n" |
3a2d747c | 3731 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3732 | AS_STR |
3a2d747c QY |
3733 | "Internal BGP peer\n" |
3734 | "External BGP peer\n") | |
b3a39dc5 | 3735 | { |
d62a17ae | 3736 | int idx_word = 1; |
3737 | int idx_remote_as = 5; | |
3738 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3739 | SAFI_UNICAST, 1, NULL, | |
3740 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3741 | } |
3742 | ||
718e3744 | 3743 | DEFUN (neighbor_peer_group, |
3744 | neighbor_peer_group_cmd, | |
3745 | "neighbor WORD peer-group", | |
3746 | NEIGHBOR_STR | |
a80beece | 3747 | "Interface name or neighbor tag\n" |
718e3744 | 3748 | "Configure peer-group\n") |
3749 | { | |
d62a17ae | 3750 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3751 | int idx_word = 1; | |
3752 | struct peer *peer; | |
3753 | struct peer_group *group; | |
718e3744 | 3754 | |
d62a17ae | 3755 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3756 | if (peer) { | |
3757 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3758 | return CMD_WARNING_CONFIG_FAILED; | |
3759 | } | |
718e3744 | 3760 | |
d62a17ae | 3761 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3762 | if (!group) { | |
3763 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3764 | return CMD_WARNING_CONFIG_FAILED; | |
3765 | } | |
718e3744 | 3766 | |
d62a17ae | 3767 | return CMD_SUCCESS; |
718e3744 | 3768 | } |
3769 | ||
3770 | DEFUN (no_neighbor, | |
3771 | no_neighbor_cmd, | |
dab8cd00 | 3772 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3773 | NO_STR |
3774 | NEIGHBOR_STR | |
3a2d747c QY |
3775 | NEIGHBOR_ADDR_STR2 |
3776 | "Specify a BGP neighbor\n" | |
3777 | AS_STR | |
3778 | "Internal BGP peer\n" | |
3779 | "External BGP peer\n") | |
718e3744 | 3780 | { |
d62a17ae | 3781 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3782 | int idx_peer = 2; | |
3783 | int ret; | |
3784 | union sockunion su; | |
3785 | struct peer_group *group; | |
3786 | struct peer *peer; | |
3787 | struct peer *other; | |
3788 | ||
3789 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3790 | if (ret < 0) { | |
3791 | /* look up for neighbor by interface name config. */ | |
3792 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3793 | if (peer) { | |
3794 | /* Request zebra to terminate IPv6 RAs on this | |
3795 | * interface. */ | |
3796 | if (peer->ifp) | |
3797 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3798 | peer_notify_unconfig(peer); |
d62a17ae | 3799 | peer_delete(peer); |
3800 | return CMD_SUCCESS; | |
3801 | } | |
f14e6fdb | 3802 | |
d62a17ae | 3803 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
4e2786df DA |
3804 | if (group) { |
3805 | peer_group_notify_unconfig(group); | |
d62a17ae | 3806 | peer_group_delete(group); |
4e2786df | 3807 | } else { |
d62a17ae | 3808 | vty_out(vty, "%% Create the peer-group first\n"); |
3809 | return CMD_WARNING_CONFIG_FAILED; | |
3810 | } | |
3811 | } else { | |
3812 | peer = peer_lookup(bgp, &su); | |
3813 | if (peer) { | |
3814 | if (peer_dynamic_neighbor(peer)) { | |
3815 | vty_out(vty, | |
3816 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3817 | return CMD_WARNING_CONFIG_FAILED; | |
3818 | } | |
3819 | ||
3820 | other = peer->doppelganger; | |
4e2786df | 3821 | peer_notify_unconfig(peer); |
d62a17ae | 3822 | peer_delete(peer); |
4e2786df DA |
3823 | if (other && other->status != Deleted) { |
3824 | peer_notify_unconfig(other); | |
d62a17ae | 3825 | peer_delete(other); |
4e2786df | 3826 | } |
d62a17ae | 3827 | } |
1ff9a340 | 3828 | } |
718e3744 | 3829 | |
d62a17ae | 3830 | return CMD_SUCCESS; |
718e3744 | 3831 | } |
3832 | ||
a80beece DS |
3833 | DEFUN (no_neighbor_interface_config, |
3834 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3835 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3836 | NO_STR |
3837 | NEIGHBOR_STR | |
3838 | "Interface name\n" | |
31500417 DW |
3839 | "Configure BGP on interface\n" |
3840 | "Enable BGP with v6 link-local only\n" | |
3841 | "Member of the peer-group\n" | |
16cedbb0 | 3842 | "Peer-group name\n" |
3a2d747c QY |
3843 | "Specify a BGP neighbor\n" |
3844 | AS_STR | |
3845 | "Internal BGP peer\n" | |
3846 | "External BGP peer\n") | |
a80beece | 3847 | { |
d62a17ae | 3848 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3849 | int idx_word = 2; | |
3850 | struct peer *peer; | |
3851 | ||
3852 | /* look up for neighbor by interface name config. */ | |
3853 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3854 | if (peer) { | |
3855 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3856 | if (peer->ifp) | |
3857 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
4e2786df | 3858 | peer_notify_unconfig(peer); |
d62a17ae | 3859 | peer_delete(peer); |
3860 | } else { | |
3861 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3862 | return CMD_WARNING_CONFIG_FAILED; | |
3863 | } | |
3864 | return CMD_SUCCESS; | |
a80beece DS |
3865 | } |
3866 | ||
718e3744 | 3867 | DEFUN (no_neighbor_peer_group, |
3868 | no_neighbor_peer_group_cmd, | |
3869 | "no neighbor WORD peer-group", | |
3870 | NO_STR | |
3871 | NEIGHBOR_STR | |
3872 | "Neighbor tag\n" | |
3873 | "Configure peer-group\n") | |
3874 | { | |
d62a17ae | 3875 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3876 | int idx_word = 2; | |
3877 | struct peer_group *group; | |
718e3744 | 3878 | |
d62a17ae | 3879 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
4e2786df DA |
3880 | if (group) { |
3881 | peer_group_notify_unconfig(group); | |
d62a17ae | 3882 | peer_group_delete(group); |
4e2786df | 3883 | } else { |
d62a17ae | 3884 | vty_out(vty, "%% Create the peer-group first\n"); |
3885 | return CMD_WARNING_CONFIG_FAILED; | |
3886 | } | |
3887 | return CMD_SUCCESS; | |
718e3744 | 3888 | } |
3889 | ||
a80beece DS |
3890 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3891 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3892 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3893 | NO_STR |
3894 | NEIGHBOR_STR | |
a80beece | 3895 | "Interface name or neighbor tag\n" |
718e3744 | 3896 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3897 | AS_STR |
3898 | "Internal BGP peer\n" | |
3899 | "External BGP peer\n") | |
718e3744 | 3900 | { |
d62a17ae | 3901 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3902 | int idx_word = 2; | |
3903 | struct peer_group *group; | |
3904 | struct peer *peer; | |
3905 | ||
3906 | /* look up for neighbor by interface name config. */ | |
3907 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3908 | if (peer) { | |
390485fd | 3909 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3910 | return CMD_SUCCESS; |
3911 | } | |
3912 | ||
3913 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3914 | if (group) | |
3915 | peer_group_remote_as_delete(group); | |
3916 | else { | |
3917 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3918 | return CMD_WARNING_CONFIG_FAILED; | |
3919 | } | |
3920 | return CMD_SUCCESS; | |
718e3744 | 3921 | } |
6b0655a2 | 3922 | |
718e3744 | 3923 | DEFUN (neighbor_local_as, |
3924 | neighbor_local_as_cmd, | |
9ccf14f7 | 3925 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3926 | NEIGHBOR_STR |
3927 | NEIGHBOR_ADDR_STR2 | |
3928 | "Specify a local-as number\n" | |
3929 | "AS number used as local AS\n") | |
3930 | { | |
d62a17ae | 3931 | int idx_peer = 1; |
3932 | int idx_number = 3; | |
3933 | struct peer *peer; | |
3934 | int ret; | |
3935 | as_t as; | |
718e3744 | 3936 | |
d62a17ae | 3937 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3938 | if (!peer) | |
3939 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3940 | |
d62a17ae | 3941 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3942 | ret = peer_local_as_set(peer, as, 0, 0); | |
3943 | return bgp_vty_return(vty, ret); | |
718e3744 | 3944 | } |
3945 | ||
3946 | DEFUN (neighbor_local_as_no_prepend, | |
3947 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3948 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3949 | NEIGHBOR_STR |
3950 | NEIGHBOR_ADDR_STR2 | |
3951 | "Specify a local-as number\n" | |
3952 | "AS number used as local AS\n" | |
3953 | "Do not prepend local-as to updates from ebgp peers\n") | |
3954 | { | |
d62a17ae | 3955 | int idx_peer = 1; |
3956 | int idx_number = 3; | |
3957 | struct peer *peer; | |
3958 | int ret; | |
3959 | as_t as; | |
718e3744 | 3960 | |
d62a17ae | 3961 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3962 | if (!peer) | |
3963 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3964 | |
d62a17ae | 3965 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3966 | ret = peer_local_as_set(peer, as, 1, 0); | |
3967 | return bgp_vty_return(vty, ret); | |
718e3744 | 3968 | } |
3969 | ||
9d3f9705 AC |
3970 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3971 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3972 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3973 | NEIGHBOR_STR |
3974 | NEIGHBOR_ADDR_STR2 | |
3975 | "Specify a local-as number\n" | |
3976 | "AS number used as local AS\n" | |
3977 | "Do not prepend local-as to updates from ebgp peers\n" | |
3978 | "Do not prepend local-as to updates from ibgp peers\n") | |
3979 | { | |
d62a17ae | 3980 | int idx_peer = 1; |
3981 | int idx_number = 3; | |
3982 | struct peer *peer; | |
3983 | int ret; | |
3984 | as_t as; | |
9d3f9705 | 3985 | |
d62a17ae | 3986 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3987 | if (!peer) | |
3988 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3989 | |
d62a17ae | 3990 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3991 | ret = peer_local_as_set(peer, as, 1, 1); | |
3992 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3993 | } |
3994 | ||
718e3744 | 3995 | DEFUN (no_neighbor_local_as, |
3996 | no_neighbor_local_as_cmd, | |
a636c635 | 3997 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3998 | NO_STR |
3999 | NEIGHBOR_STR | |
4000 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4001 | "Specify a local-as number\n" |
4002 | "AS number used as local AS\n" | |
4003 | "Do not prepend local-as to updates from ebgp peers\n" | |
4004 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 4005 | { |
d62a17ae | 4006 | int idx_peer = 2; |
4007 | struct peer *peer; | |
4008 | int ret; | |
718e3744 | 4009 | |
d62a17ae | 4010 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4011 | if (!peer) | |
4012 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4013 | |
d62a17ae | 4014 | ret = peer_local_as_unset(peer); |
4015 | return bgp_vty_return(vty, ret); | |
718e3744 | 4016 | } |
4017 | ||
718e3744 | 4018 | |
3f9c7369 DS |
4019 | DEFUN (neighbor_solo, |
4020 | neighbor_solo_cmd, | |
9ccf14f7 | 4021 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4022 | NEIGHBOR_STR |
4023 | NEIGHBOR_ADDR_STR2 | |
4024 | "Solo peer - part of its own update group\n") | |
4025 | { | |
d62a17ae | 4026 | int idx_peer = 1; |
4027 | struct peer *peer; | |
4028 | int ret; | |
3f9c7369 | 4029 | |
d62a17ae | 4030 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4031 | if (!peer) | |
4032 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4033 | |
d62a17ae | 4034 | ret = update_group_adjust_soloness(peer, 1); |
4035 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4036 | } |
4037 | ||
4038 | DEFUN (no_neighbor_solo, | |
4039 | no_neighbor_solo_cmd, | |
9ccf14f7 | 4040 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
4041 | NO_STR |
4042 | NEIGHBOR_STR | |
4043 | NEIGHBOR_ADDR_STR2 | |
4044 | "Solo peer - part of its own update group\n") | |
4045 | { | |
d62a17ae | 4046 | int idx_peer = 2; |
4047 | struct peer *peer; | |
4048 | int ret; | |
3f9c7369 | 4049 | |
d62a17ae | 4050 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4051 | if (!peer) | |
4052 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 4053 | |
d62a17ae | 4054 | ret = update_group_adjust_soloness(peer, 0); |
4055 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
4056 | } |
4057 | ||
0df7c91f PJ |
4058 | DEFUN (neighbor_password, |
4059 | neighbor_password_cmd, | |
9ccf14f7 | 4060 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
4061 | NEIGHBOR_STR |
4062 | NEIGHBOR_ADDR_STR2 | |
4063 | "Set a password\n" | |
4064 | "The password\n") | |
4065 | { | |
d62a17ae | 4066 | int idx_peer = 1; |
4067 | int idx_line = 3; | |
4068 | struct peer *peer; | |
4069 | int ret; | |
0df7c91f | 4070 | |
d62a17ae | 4071 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4072 | if (!peer) | |
4073 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4074 | |
d62a17ae | 4075 | ret = peer_password_set(peer, argv[idx_line]->arg); |
4076 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
4077 | } |
4078 | ||
4079 | DEFUN (no_neighbor_password, | |
4080 | no_neighbor_password_cmd, | |
a636c635 | 4081 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
4082 | NO_STR |
4083 | NEIGHBOR_STR | |
4084 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
4085 | "Set a password\n" |
4086 | "The password\n") | |
0df7c91f | 4087 | { |
d62a17ae | 4088 | int idx_peer = 2; |
4089 | struct peer *peer; | |
4090 | int ret; | |
0df7c91f | 4091 | |
d62a17ae | 4092 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4093 | if (!peer) | |
4094 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 4095 | |
d62a17ae | 4096 | ret = peer_password_unset(peer); |
4097 | return bgp_vty_return(vty, ret); | |
0df7c91f | 4098 | } |
6b0655a2 | 4099 | |
718e3744 | 4100 | DEFUN (neighbor_activate, |
4101 | neighbor_activate_cmd, | |
9ccf14f7 | 4102 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4103 | NEIGHBOR_STR |
4104 | NEIGHBOR_ADDR_STR2 | |
4105 | "Enable the Address Family for this Neighbor\n") | |
4106 | { | |
d62a17ae | 4107 | int idx_peer = 1; |
4108 | int ret; | |
4109 | struct peer *peer; | |
718e3744 | 4110 | |
d62a17ae | 4111 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4112 | if (!peer) | |
4113 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4114 | |
d62a17ae | 4115 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4116 | return bgp_vty_return(vty, ret); | |
718e3744 | 4117 | } |
4118 | ||
d62a17ae | 4119 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
4120 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4121 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4122 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4123 | |
718e3744 | 4124 | DEFUN (no_neighbor_activate, |
4125 | no_neighbor_activate_cmd, | |
9ccf14f7 | 4126 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 4127 | NO_STR |
4128 | NEIGHBOR_STR | |
4129 | NEIGHBOR_ADDR_STR2 | |
4130 | "Enable the Address Family for this Neighbor\n") | |
4131 | { | |
d62a17ae | 4132 | int idx_peer = 2; |
4133 | int ret; | |
4134 | struct peer *peer; | |
718e3744 | 4135 | |
d62a17ae | 4136 | /* Lookup peer. */ |
4137 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4138 | if (!peer) | |
4139 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4140 | |
d62a17ae | 4141 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
4142 | return bgp_vty_return(vty, ret); | |
718e3744 | 4143 | } |
6b0655a2 | 4144 | |
d62a17ae | 4145 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
4146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
4147 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4148 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 4149 | |
718e3744 | 4150 | DEFUN (neighbor_set_peer_group, |
4151 | neighbor_set_peer_group_cmd, | |
d7b9898c | 4152 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4153 | NEIGHBOR_STR |
a80beece | 4154 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4155 | "Member of the peer-group\n" |
16cedbb0 | 4156 | "Peer-group name\n") |
718e3744 | 4157 | { |
d62a17ae | 4158 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4159 | int idx_peer = 1; | |
4160 | int idx_word = 3; | |
4161 | int ret; | |
4162 | as_t as; | |
4163 | union sockunion su; | |
4164 | struct peer *peer; | |
4165 | struct peer_group *group; | |
4166 | ||
d62a17ae | 4167 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
4168 | if (ret < 0) { | |
4169 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
4170 | if (!peer) { | |
4171 | vty_out(vty, "%% Malformed address or name: %s\n", | |
4172 | argv[idx_peer]->arg); | |
4173 | return CMD_WARNING_CONFIG_FAILED; | |
4174 | } | |
4175 | } else { | |
4176 | if (peer_address_self_check(bgp, &su)) { | |
4177 | vty_out(vty, | |
4178 | "%% Can not configure the local system as neighbor\n"); | |
4179 | return CMD_WARNING_CONFIG_FAILED; | |
4180 | } | |
4181 | ||
4182 | /* Disallow for dynamic neighbor. */ | |
4183 | peer = peer_lookup(bgp, &su); | |
4184 | if (peer && peer_dynamic_neighbor(peer)) { | |
4185 | vty_out(vty, | |
4186 | "%% Operation not allowed on a dynamic neighbor\n"); | |
4187 | return CMD_WARNING_CONFIG_FAILED; | |
4188 | } | |
4189 | } | |
4190 | ||
4191 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4192 | if (!group) { | |
4193 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4194 | return CMD_WARNING_CONFIG_FAILED; | |
4195 | } | |
4196 | ||
4197 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
4198 | ||
4199 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
4200 | vty_out(vty, | |
4201 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
4202 | as); | |
4203 | return CMD_WARNING_CONFIG_FAILED; | |
4204 | } | |
4205 | ||
4206 | return bgp_vty_return(vty, ret); | |
4207 | } | |
4208 | ||
4209 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 4210 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4211 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4212 | "Member of the peer-group\n" | |
4213 | "Peer-group name\n") | |
596c17ba | 4214 | |
718e3744 | 4215 | DEFUN (no_neighbor_set_peer_group, |
4216 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 4217 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 4218 | NO_STR |
4219 | NEIGHBOR_STR | |
a80beece | 4220 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4221 | "Member of the peer-group\n" |
16cedbb0 | 4222 | "Peer-group name\n") |
718e3744 | 4223 | { |
d62a17ae | 4224 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4225 | int idx_peer = 2; | |
4226 | int idx_word = 4; | |
4227 | int ret; | |
4228 | struct peer *peer; | |
4229 | struct peer_group *group; | |
4230 | ||
4231 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
4232 | if (!peer) | |
4233 | return CMD_WARNING_CONFIG_FAILED; | |
4234 | ||
4235 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
4236 | if (!group) { | |
4237 | vty_out(vty, "%% Configure the peer-group first\n"); | |
4238 | return CMD_WARNING_CONFIG_FAILED; | |
4239 | } | |
718e3744 | 4240 | |
4e2786df | 4241 | peer_notify_unconfig(peer); |
827ed707 | 4242 | ret = peer_delete(peer); |
718e3744 | 4243 | |
d62a17ae | 4244 | return bgp_vty_return(vty, ret); |
718e3744 | 4245 | } |
6b0655a2 | 4246 | |
d62a17ae | 4247 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 4248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 4249 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
4250 | "Member of the peer-group\n" | |
4251 | "Peer-group name\n") | |
596c17ba | 4252 | |
d62a17ae | 4253 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4254 | uint32_t flag, int set) |
718e3744 | 4255 | { |
d62a17ae | 4256 | int ret; |
4257 | struct peer *peer; | |
718e3744 | 4258 | |
d62a17ae | 4259 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4260 | if (!peer) | |
4261 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4262 | |
7ebe625c QY |
4263 | /* |
4264 | * If 'neighbor <interface>', then this is for directly connected peers, | |
4265 | * we should not accept disable-connected-check. | |
4266 | */ | |
4267 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
4268 | vty_out(vty, | |
4269 | "%s is directly connected peer, cannot accept disable-" | |
4270 | "connected-check\n", | |
4271 | ip_str); | |
4272 | return CMD_WARNING_CONFIG_FAILED; | |
4273 | } | |
4274 | ||
d62a17ae | 4275 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
4276 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 4277 | |
d62a17ae | 4278 | if (set) |
4279 | ret = peer_flag_set(peer, flag); | |
4280 | else | |
4281 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 4282 | |
d62a17ae | 4283 | return bgp_vty_return(vty, ret); |
718e3744 | 4284 | } |
4285 | ||
47cbc09b | 4286 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 4287 | { |
d62a17ae | 4288 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 4289 | } |
4290 | ||
d62a17ae | 4291 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 4292 | uint32_t flag) |
718e3744 | 4293 | { |
d62a17ae | 4294 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 4295 | } |
4296 | ||
4297 | /* neighbor passive. */ | |
4298 | DEFUN (neighbor_passive, | |
4299 | neighbor_passive_cmd, | |
9ccf14f7 | 4300 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4301 | NEIGHBOR_STR |
4302 | NEIGHBOR_ADDR_STR2 | |
4303 | "Don't send open messages to this neighbor\n") | |
4304 | { | |
d62a17ae | 4305 | int idx_peer = 1; |
4306 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4307 | } |
4308 | ||
4309 | DEFUN (no_neighbor_passive, | |
4310 | no_neighbor_passive_cmd, | |
9ccf14f7 | 4311 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 4312 | NO_STR |
4313 | NEIGHBOR_STR | |
4314 | NEIGHBOR_ADDR_STR2 | |
4315 | "Don't send open messages to this neighbor\n") | |
4316 | { | |
d62a17ae | 4317 | int idx_peer = 2; |
4318 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 4319 | } |
6b0655a2 | 4320 | |
718e3744 | 4321 | /* neighbor shutdown. */ |
73d70fa6 DL |
4322 | DEFUN (neighbor_shutdown_msg, |
4323 | neighbor_shutdown_msg_cmd, | |
4324 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 4325 | NEIGHBOR_STR |
4326 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
4327 | "Administratively shut down this neighbor\n" |
4328 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4329 | "Shutdown message\n") | |
718e3744 | 4330 | { |
d62a17ae | 4331 | int idx_peer = 1; |
73d70fa6 | 4332 | |
d62a17ae | 4333 | if (argc >= 5) { |
4334 | struct peer *peer = | |
4335 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
4336 | char *message; | |
73d70fa6 | 4337 | |
d62a17ae | 4338 | if (!peer) |
4339 | return CMD_WARNING_CONFIG_FAILED; | |
4340 | message = argv_concat(argv, argc, 4); | |
4341 | peer_tx_shutdown_message_set(peer, message); | |
4342 | XFREE(MTYPE_TMP, message); | |
4343 | } | |
73d70fa6 | 4344 | |
d62a17ae | 4345 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 4346 | } |
4347 | ||
d62a17ae | 4348 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
4349 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4350 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4351 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
4352 | |
4353 | DEFUN (no_neighbor_shutdown_msg, | |
4354 | no_neighbor_shutdown_msg_cmd, | |
4355 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
4356 | NO_STR | |
4357 | NEIGHBOR_STR | |
4358 | NEIGHBOR_ADDR_STR2 | |
4359 | "Administratively shut down this neighbor\n" | |
4360 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
4361 | "Shutdown message\n") | |
718e3744 | 4362 | { |
d62a17ae | 4363 | int idx_peer = 2; |
73d70fa6 | 4364 | |
d62a17ae | 4365 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
4366 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 4367 | } |
6b0655a2 | 4368 | |
d62a17ae | 4369 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
4370 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
4371 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4372 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 4373 | |
718e3744 | 4374 | /* neighbor capability dynamic. */ |
4375 | DEFUN (neighbor_capability_dynamic, | |
4376 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4377 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4378 | NEIGHBOR_STR |
4379 | NEIGHBOR_ADDR_STR2 | |
4380 | "Advertise capability to the peer\n" | |
4381 | "Advertise dynamic capability to this neighbor\n") | |
4382 | { | |
d62a17ae | 4383 | int idx_peer = 1; |
4384 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4385 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4386 | } |
4387 | ||
4388 | DEFUN (no_neighbor_capability_dynamic, | |
4389 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 4390 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 4391 | NO_STR |
4392 | NEIGHBOR_STR | |
4393 | NEIGHBOR_ADDR_STR2 | |
4394 | "Advertise capability to the peer\n" | |
4395 | "Advertise dynamic capability to this neighbor\n") | |
4396 | { | |
d62a17ae | 4397 | int idx_peer = 2; |
4398 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4399 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 4400 | } |
6b0655a2 | 4401 | |
718e3744 | 4402 | /* neighbor dont-capability-negotiate */ |
4403 | DEFUN (neighbor_dont_capability_negotiate, | |
4404 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4405 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4406 | NEIGHBOR_STR |
4407 | NEIGHBOR_ADDR_STR2 | |
4408 | "Do not perform capability negotiation\n") | |
4409 | { | |
d62a17ae | 4410 | int idx_peer = 1; |
4411 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4412 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4413 | } |
4414 | ||
4415 | DEFUN (no_neighbor_dont_capability_negotiate, | |
4416 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 4417 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 4418 | NO_STR |
4419 | NEIGHBOR_STR | |
4420 | NEIGHBOR_ADDR_STR2 | |
4421 | "Do not perform capability negotiation\n") | |
4422 | { | |
d62a17ae | 4423 | int idx_peer = 2; |
4424 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4425 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 4426 | } |
6b0655a2 | 4427 | |
8a92a8a0 DS |
4428 | /* neighbor capability extended next hop encoding */ |
4429 | DEFUN (neighbor_capability_enhe, | |
4430 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4431 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4432 | NEIGHBOR_STR |
4433 | NEIGHBOR_ADDR_STR2 | |
4434 | "Advertise capability to the peer\n" | |
4435 | "Advertise extended next-hop capability to the peer\n") | |
4436 | { | |
d62a17ae | 4437 | int idx_peer = 1; |
4438 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4439 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4440 | } |
4441 | ||
4442 | DEFUN (no_neighbor_capability_enhe, | |
4443 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 4444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
4445 | NO_STR |
4446 | NEIGHBOR_STR | |
4447 | NEIGHBOR_ADDR_STR2 | |
4448 | "Advertise capability to the peer\n" | |
4449 | "Advertise extended next-hop capability to the peer\n") | |
4450 | { | |
d62a17ae | 4451 | int idx_peer = 2; |
4452 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4453 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
4454 | } |
4455 | ||
d62a17ae | 4456 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4457 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 4458 | int set) |
718e3744 | 4459 | { |
d62a17ae | 4460 | int ret; |
4461 | struct peer *peer; | |
718e3744 | 4462 | |
d62a17ae | 4463 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4464 | if (!peer) | |
4465 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4466 | |
d62a17ae | 4467 | if (set) |
4468 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
4469 | else | |
4470 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 4471 | |
d62a17ae | 4472 | return bgp_vty_return(vty, ret); |
718e3744 | 4473 | } |
4474 | ||
d62a17ae | 4475 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4476 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4477 | { |
d62a17ae | 4478 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 4479 | } |
4480 | ||
d62a17ae | 4481 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 4482 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 4483 | { |
d62a17ae | 4484 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 4485 | } |
6b0655a2 | 4486 | |
718e3744 | 4487 | /* neighbor capability orf prefix-list. */ |
4488 | DEFUN (neighbor_capability_orf_prefix, | |
4489 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4490 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4491 | NEIGHBOR_STR |
4492 | NEIGHBOR_ADDR_STR2 | |
4493 | "Advertise capability to the peer\n" | |
4494 | "Advertise ORF capability to the peer\n" | |
4495 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4496 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4497 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4498 | "Capability to SEND the ORF to this neighbor\n") | |
4499 | { | |
d62a17ae | 4500 | int idx_peer = 1; |
4501 | int idx_send_recv = 5; | |
d7c0a89a | 4502 | uint16_t flag = 0; |
d62a17ae | 4503 | |
4504 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4505 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4506 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4507 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4508 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4509 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4510 | else { | |
4511 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4512 | return CMD_WARNING_CONFIG_FAILED; | |
4513 | } | |
4514 | ||
4515 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4516 | bgp_node_safi(vty), flag); | |
4517 | } | |
4518 | ||
4519 | ALIAS_HIDDEN( | |
4520 | neighbor_capability_orf_prefix, | |
4521 | neighbor_capability_orf_prefix_hidden_cmd, | |
4522 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4523 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4524 | "Advertise capability to the peer\n" | |
4525 | "Advertise ORF capability to the peer\n" | |
4526 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4527 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4528 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4529 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4530 | |
718e3744 | 4531 | DEFUN (no_neighbor_capability_orf_prefix, |
4532 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 4533 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 4534 | NO_STR |
4535 | NEIGHBOR_STR | |
4536 | NEIGHBOR_ADDR_STR2 | |
4537 | "Advertise capability to the peer\n" | |
4538 | "Advertise ORF capability to the peer\n" | |
4539 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4540 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4541 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4542 | "Capability to SEND the ORF to this neighbor\n") | |
4543 | { | |
d62a17ae | 4544 | int idx_peer = 2; |
4545 | int idx_send_recv = 6; | |
d7c0a89a | 4546 | uint16_t flag = 0; |
d62a17ae | 4547 | |
4548 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
4549 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
4550 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
4551 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
4552 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
4553 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
4554 | else { | |
4555 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
4556 | return CMD_WARNING_CONFIG_FAILED; | |
4557 | } | |
4558 | ||
4559 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4560 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4561 | flag); | |
4562 | } | |
4563 | ||
4564 | ALIAS_HIDDEN( | |
4565 | no_neighbor_capability_orf_prefix, | |
4566 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
4567 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
4568 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4569 | "Advertise capability to the peer\n" | |
4570 | "Advertise ORF capability to the peer\n" | |
4571 | "Advertise prefixlist ORF capability to this neighbor\n" | |
4572 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
4573 | "Capability to RECEIVE the ORF from this neighbor\n" | |
4574 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 4575 | |
718e3744 | 4576 | /* neighbor next-hop-self. */ |
4577 | DEFUN (neighbor_nexthop_self, | |
4578 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4579 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4580 | NEIGHBOR_STR |
4581 | NEIGHBOR_ADDR_STR2 | |
a538debe | 4582 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 4583 | { |
d62a17ae | 4584 | int idx_peer = 1; |
4585 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4586 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 4587 | } |
9e7a53c1 | 4588 | |
d62a17ae | 4589 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
4590 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4591 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4592 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4593 | |
a538debe DS |
4594 | /* neighbor next-hop-self. */ |
4595 | DEFUN (neighbor_nexthop_self_force, | |
4596 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 4597 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4598 | NEIGHBOR_STR |
4599 | NEIGHBOR_ADDR_STR2 | |
4600 | "Disable the next hop calculation for this neighbor\n" | |
4601 | "Set the next hop to self for reflected routes\n") | |
4602 | { | |
d62a17ae | 4603 | int idx_peer = 1; |
4604 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4605 | bgp_node_safi(vty), | |
4606 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 4607 | } |
4608 | ||
d62a17ae | 4609 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4610 | neighbor_nexthop_self_force_hidden_cmd, | |
4611 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4612 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4613 | "Disable the next hop calculation for this neighbor\n" | |
4614 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4615 | |
1bc4e531 DA |
4616 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
4617 | neighbor_nexthop_self_all_hidden_cmd, | |
4618 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4619 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4620 | "Disable the next hop calculation for this neighbor\n" | |
4621 | "Set the next hop to self for reflected routes\n") | |
4622 | ||
718e3744 | 4623 | DEFUN (no_neighbor_nexthop_self, |
4624 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 4625 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 4626 | NO_STR |
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 = 2; |
4632 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4633 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4634 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 4635 | } |
6b0655a2 | 4636 | |
d62a17ae | 4637 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
4638 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
4639 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4640 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 4641 | |
88b8ed8d | 4642 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 4643 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 4644 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
4645 | NO_STR |
4646 | NEIGHBOR_STR | |
4647 | NEIGHBOR_ADDR_STR2 | |
4648 | "Disable the next hop calculation for this neighbor\n" | |
4649 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 4650 | { |
d62a17ae | 4651 | int idx_peer = 2; |
4652 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4653 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4654 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4655 | } |
a538debe | 4656 | |
d62a17ae | 4657 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4658 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4659 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4660 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4661 | "Disable the next hop calculation for this neighbor\n" | |
4662 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4663 | |
1bc4e531 DA |
4664 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4665 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4666 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4667 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4668 | "Disable the next hop calculation for this neighbor\n" | |
4669 | "Set the next hop to self for reflected routes\n") | |
4670 | ||
c7122e14 DS |
4671 | /* neighbor as-override */ |
4672 | DEFUN (neighbor_as_override, | |
4673 | neighbor_as_override_cmd, | |
9ccf14f7 | 4674 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4675 | NEIGHBOR_STR |
4676 | NEIGHBOR_ADDR_STR2 | |
4677 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4678 | { | |
d62a17ae | 4679 | int idx_peer = 1; |
4680 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4681 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4682 | } |
4683 | ||
d62a17ae | 4684 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4685 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4686 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4687 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4688 | |
c7122e14 DS |
4689 | DEFUN (no_neighbor_as_override, |
4690 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4692 | NO_STR |
4693 | NEIGHBOR_STR | |
4694 | NEIGHBOR_ADDR_STR2 | |
4695 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4696 | { | |
d62a17ae | 4697 | int idx_peer = 2; |
4698 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4699 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4700 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4701 | } |
4702 | ||
d62a17ae | 4703 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4704 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4705 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4706 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4707 | |
718e3744 | 4708 | /* neighbor remove-private-AS. */ |
4709 | DEFUN (neighbor_remove_private_as, | |
4710 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4711 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4712 | NEIGHBOR_STR |
4713 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4714 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4715 | { |
d62a17ae | 4716 | int idx_peer = 1; |
4717 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4718 | bgp_node_safi(vty), | |
4719 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4720 | } |
4721 | ||
d62a17ae | 4722 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4723 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4724 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4725 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4726 | |
5000f21c DS |
4727 | DEFUN (neighbor_remove_private_as_all, |
4728 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4729 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4730 | NEIGHBOR_STR |
4731 | NEIGHBOR_ADDR_STR2 | |
4732 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4733 | "Apply to all AS numbers\n") |
5000f21c | 4734 | { |
d62a17ae | 4735 | int idx_peer = 1; |
4736 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4737 | bgp_node_safi(vty), | |
4738 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4739 | } |
4740 | ||
d62a17ae | 4741 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4742 | neighbor_remove_private_as_all_hidden_cmd, | |
4743 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4744 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4745 | "Remove private ASNs in outbound updates\n" | |
4746 | "Apply to all AS numbers") | |
596c17ba | 4747 | |
5000f21c DS |
4748 | DEFUN (neighbor_remove_private_as_replace_as, |
4749 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4750 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4751 | NEIGHBOR_STR |
4752 | NEIGHBOR_ADDR_STR2 | |
4753 | "Remove private ASNs in outbound updates\n" | |
4754 | "Replace private ASNs with our ASN in outbound updates\n") | |
4755 | { | |
d62a17ae | 4756 | int idx_peer = 1; |
4757 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4758 | bgp_node_safi(vty), | |
4759 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4760 | } |
4761 | ||
d62a17ae | 4762 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4763 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4764 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4765 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4766 | "Remove private ASNs in outbound updates\n" | |
4767 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4768 | |
5000f21c DS |
4769 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4770 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4771 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4772 | NEIGHBOR_STR |
4773 | NEIGHBOR_ADDR_STR2 | |
4774 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4775 | "Apply to all AS numbers\n" |
5000f21c DS |
4776 | "Replace private ASNs with our ASN in outbound updates\n") |
4777 | { | |
d62a17ae | 4778 | int idx_peer = 1; |
4779 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4780 | bgp_node_safi(vty), | |
4781 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4782 | } |
4783 | ||
d62a17ae | 4784 | ALIAS_HIDDEN( |
4785 | neighbor_remove_private_as_all_replace_as, | |
4786 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4787 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4788 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4789 | "Remove private ASNs in outbound updates\n" | |
4790 | "Apply to all AS numbers\n" | |
4791 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4792 | |
718e3744 | 4793 | DEFUN (no_neighbor_remove_private_as, |
4794 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4795 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4796 | NO_STR |
4797 | NEIGHBOR_STR | |
4798 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4799 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4800 | { |
d62a17ae | 4801 | int idx_peer = 2; |
4802 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4803 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4804 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4805 | } |
6b0655a2 | 4806 | |
d62a17ae | 4807 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4808 | no_neighbor_remove_private_as_hidden_cmd, | |
4809 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4810 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4811 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4812 | |
88b8ed8d | 4813 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4814 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4815 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4816 | NO_STR |
4817 | NEIGHBOR_STR | |
4818 | NEIGHBOR_ADDR_STR2 | |
4819 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4820 | "Apply to all AS numbers\n") |
88b8ed8d | 4821 | { |
d62a17ae | 4822 | int idx_peer = 2; |
4823 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4824 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4825 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4826 | } |
5000f21c | 4827 | |
d62a17ae | 4828 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4829 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4830 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4831 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4832 | "Remove private ASNs in outbound updates\n" | |
4833 | "Apply to all AS numbers\n") | |
596c17ba | 4834 | |
88b8ed8d | 4835 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4836 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4837 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4838 | NO_STR |
4839 | NEIGHBOR_STR | |
4840 | NEIGHBOR_ADDR_STR2 | |
4841 | "Remove private ASNs in outbound updates\n" | |
4842 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4843 | { |
d62a17ae | 4844 | int idx_peer = 2; |
4845 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4846 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4847 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4848 | } |
5000f21c | 4849 | |
d62a17ae | 4850 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4851 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4852 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4853 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4854 | "Remove private ASNs in outbound updates\n" | |
4855 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4856 | |
88b8ed8d | 4857 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4858 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4859 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4860 | NO_STR |
4861 | NEIGHBOR_STR | |
4862 | NEIGHBOR_ADDR_STR2 | |
4863 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4864 | "Apply to all AS numbers\n" |
5000f21c | 4865 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4866 | { |
d62a17ae | 4867 | int idx_peer = 2; |
4868 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4869 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4870 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4871 | } |
5000f21c | 4872 | |
d62a17ae | 4873 | ALIAS_HIDDEN( |
4874 | no_neighbor_remove_private_as_all_replace_as, | |
4875 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4876 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4877 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4878 | "Remove private ASNs in outbound updates\n" | |
4879 | "Apply to all AS numbers\n" | |
4880 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4881 | |
5000f21c | 4882 | |
718e3744 | 4883 | /* neighbor send-community. */ |
4884 | DEFUN (neighbor_send_community, | |
4885 | neighbor_send_community_cmd, | |
9ccf14f7 | 4886 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4887 | NEIGHBOR_STR |
4888 | NEIGHBOR_ADDR_STR2 | |
4889 | "Send Community attribute to this neighbor\n") | |
4890 | { | |
d62a17ae | 4891 | int idx_peer = 1; |
27c05d4d | 4892 | |
d62a17ae | 4893 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4894 | bgp_node_safi(vty), | |
4895 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4896 | } |
4897 | ||
d62a17ae | 4898 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4899 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4900 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4901 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4902 | |
718e3744 | 4903 | DEFUN (no_neighbor_send_community, |
4904 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4906 | NO_STR |
4907 | NEIGHBOR_STR | |
4908 | NEIGHBOR_ADDR_STR2 | |
4909 | "Send Community attribute to this neighbor\n") | |
4910 | { | |
d62a17ae | 4911 | int idx_peer = 2; |
27c05d4d | 4912 | |
d62a17ae | 4913 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4914 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4915 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4916 | } |
6b0655a2 | 4917 | |
d62a17ae | 4918 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4919 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4920 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4921 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4922 | |
718e3744 | 4923 | /* neighbor send-community extended. */ |
4924 | DEFUN (neighbor_send_community_type, | |
4925 | neighbor_send_community_type_cmd, | |
57d187bc | 4926 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4927 | NEIGHBOR_STR |
4928 | NEIGHBOR_ADDR_STR2 | |
4929 | "Send Community attribute to this neighbor\n" | |
4930 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4931 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4932 | "Send Extended Community attributes\n" |
57d187bc JS |
4933 | "Send Standard Community attributes\n" |
4934 | "Send Large Community attributes\n") | |
718e3744 | 4935 | { |
27c05d4d | 4936 | int idx_peer = 1; |
d7c0a89a | 4937 | uint32_t flag = 0; |
27c05d4d | 4938 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4939 | |
27c05d4d | 4940 | if (strmatch(type, "standard")) { |
d62a17ae | 4941 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4942 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4943 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4944 | } else if (strmatch(type, "large")) { |
d62a17ae | 4945 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4946 | } else if (strmatch(type, "both")) { |
d62a17ae | 4947 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4948 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4949 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4950 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4951 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4952 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4953 | } | |
4954 | ||
27c05d4d | 4955 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4956 | bgp_node_safi(vty), flag); |
4957 | } | |
4958 | ||
4959 | ALIAS_HIDDEN( | |
4960 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4961 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4962 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4963 | "Send Community attribute to this neighbor\n" | |
4964 | "Send Standard and Extended Community attributes\n" | |
4965 | "Send Standard, Large and Extended Community attributes\n" | |
4966 | "Send Extended Community attributes\n" | |
4967 | "Send Standard Community attributes\n" | |
4968 | "Send Large Community attributes\n") | |
596c17ba | 4969 | |
718e3744 | 4970 | DEFUN (no_neighbor_send_community_type, |
4971 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4972 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4973 | NO_STR |
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 | { |
d62a17ae | 4983 | int idx_peer = 2; |
27c05d4d | 4984 | uint32_t flag = 0; |
d62a17ae | 4985 | const char *type = argv[argc - 1]->text; |
4986 | ||
27c05d4d PM |
4987 | if (strmatch(type, "standard")) { |
4988 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4989 | } else if (strmatch(type, "extended")) { | |
4990 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4991 | } else if (strmatch(type, "large")) { | |
4992 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4993 | } else if (strmatch(type, "both")) { | |
4994 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4995 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4996 | } else { /* if (strmatch(type, "all")) */ | |
4997 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4998 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4999 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
5000 | } | |
5001 | ||
5002 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5003 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5004 | flag); | |
d62a17ae | 5005 | } |
5006 | ||
5007 | ALIAS_HIDDEN( | |
5008 | no_neighbor_send_community_type, | |
5009 | no_neighbor_send_community_type_hidden_cmd, | |
5010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
5011 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5012 | "Send Community attribute to this neighbor\n" | |
5013 | "Send Standard and Extended Community attributes\n" | |
5014 | "Send Standard, Large and Extended Community attributes\n" | |
5015 | "Send Extended Community attributes\n" | |
5016 | "Send Standard Community attributes\n" | |
5017 | "Send Large Community attributes\n") | |
596c17ba | 5018 | |
718e3744 | 5019 | /* neighbor soft-reconfig. */ |
5020 | DEFUN (neighbor_soft_reconfiguration, | |
5021 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5022 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5023 | NEIGHBOR_STR |
5024 | NEIGHBOR_ADDR_STR2 | |
5025 | "Per neighbor soft reconfiguration\n" | |
5026 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5027 | { | |
d62a17ae | 5028 | int idx_peer = 1; |
5029 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5030 | bgp_node_safi(vty), | |
5031 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5032 | } |
5033 | ||
d62a17ae | 5034 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
5035 | neighbor_soft_reconfiguration_hidden_cmd, | |
5036 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5037 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5038 | "Per neighbor soft reconfiguration\n" | |
5039 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5040 | |
718e3744 | 5041 | DEFUN (no_neighbor_soft_reconfiguration, |
5042 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 5043 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 5044 | NO_STR |
5045 | NEIGHBOR_STR | |
5046 | NEIGHBOR_ADDR_STR2 | |
5047 | "Per neighbor soft reconfiguration\n" | |
5048 | "Allow inbound soft reconfiguration for this neighbor\n") | |
5049 | { | |
d62a17ae | 5050 | int idx_peer = 2; |
5051 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5052 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5053 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 5054 | } |
6b0655a2 | 5055 | |
d62a17ae | 5056 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
5057 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
5058 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
5059 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5060 | "Per neighbor soft reconfiguration\n" | |
5061 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 5062 | |
718e3744 | 5063 | DEFUN (neighbor_route_reflector_client, |
5064 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5065 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5066 | NEIGHBOR_STR |
5067 | NEIGHBOR_ADDR_STR2 | |
5068 | "Configure a neighbor as Route Reflector client\n") | |
5069 | { | |
d62a17ae | 5070 | int idx_peer = 1; |
5071 | struct peer *peer; | |
718e3744 | 5072 | |
5073 | ||
d62a17ae | 5074 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5075 | if (!peer) | |
5076 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5077 | |
d62a17ae | 5078 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5079 | bgp_node_safi(vty), | |
5080 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5081 | } |
5082 | ||
d62a17ae | 5083 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
5084 | neighbor_route_reflector_client_hidden_cmd, | |
5085 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5086 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5087 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5088 | |
718e3744 | 5089 | DEFUN (no_neighbor_route_reflector_client, |
5090 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 5091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 5092 | NO_STR |
5093 | NEIGHBOR_STR | |
5094 | NEIGHBOR_ADDR_STR2 | |
5095 | "Configure a neighbor as Route Reflector client\n") | |
5096 | { | |
d62a17ae | 5097 | int idx_peer = 2; |
5098 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5099 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5100 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 5101 | } |
6b0655a2 | 5102 | |
d62a17ae | 5103 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
5104 | no_neighbor_route_reflector_client_hidden_cmd, | |
5105 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
5106 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5107 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 5108 | |
718e3744 | 5109 | /* neighbor route-server-client. */ |
5110 | DEFUN (neighbor_route_server_client, | |
5111 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 5112 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5113 | NEIGHBOR_STR |
5114 | NEIGHBOR_ADDR_STR2 | |
5115 | "Configure a neighbor as Route Server client\n") | |
5116 | { | |
d62a17ae | 5117 | int idx_peer = 1; |
5118 | struct peer *peer; | |
2a3d5731 | 5119 | |
d62a17ae | 5120 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5121 | if (!peer) | |
5122 | return CMD_WARNING_CONFIG_FAILED; | |
5123 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5124 | bgp_node_safi(vty), | |
5125 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 5126 | } |
5127 | ||
d62a17ae | 5128 | ALIAS_HIDDEN(neighbor_route_server_client, |
5129 | neighbor_route_server_client_hidden_cmd, | |
5130 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5131 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5132 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5133 | |
718e3744 | 5134 | DEFUN (no_neighbor_route_server_client, |
5135 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 5136 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 5137 | NO_STR |
5138 | NEIGHBOR_STR | |
5139 | NEIGHBOR_ADDR_STR2 | |
5140 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 5141 | { |
d62a17ae | 5142 | int idx_peer = 2; |
5143 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5144 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5145 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 5146 | } |
6b0655a2 | 5147 | |
d62a17ae | 5148 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
5149 | no_neighbor_route_server_client_hidden_cmd, | |
5150 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
5151 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5152 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 5153 | |
fee0f4c6 | 5154 | DEFUN (neighbor_nexthop_local_unchanged, |
5155 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5156 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5157 | NEIGHBOR_STR |
5158 | NEIGHBOR_ADDR_STR2 | |
5159 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
5160 | "Leave link-local nexthop unchanged for this peer\n") | |
5161 | { | |
d62a17ae | 5162 | int idx_peer = 1; |
5163 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5164 | bgp_node_safi(vty), | |
5165 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 5166 | } |
6b0655a2 | 5167 | |
fee0f4c6 | 5168 | DEFUN (no_neighbor_nexthop_local_unchanged, |
5169 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 5170 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 5171 | NO_STR |
5172 | NEIGHBOR_STR | |
5173 | NEIGHBOR_ADDR_STR2 | |
5174 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
5175 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 5176 | { |
d62a17ae | 5177 | int idx_peer = 2; |
5178 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5179 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5180 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 5181 | } |
6b0655a2 | 5182 | |
718e3744 | 5183 | DEFUN (neighbor_attr_unchanged, |
5184 | neighbor_attr_unchanged_cmd, | |
a8206004 | 5185 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 5186 | NEIGHBOR_STR |
5187 | NEIGHBOR_ADDR_STR2 | |
5188 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5189 | "As-path attribute\n" | |
5190 | "Nexthop attribute\n" | |
a8206004 | 5191 | "Med attribute\n") |
718e3744 | 5192 | { |
d62a17ae | 5193 | int idx = 0; |
8eeb0335 DW |
5194 | char *peer_str = argv[1]->arg; |
5195 | struct peer *peer; | |
d7c0a89a | 5196 | uint16_t flags = 0; |
8eeb0335 DW |
5197 | afi_t afi = bgp_node_afi(vty); |
5198 | safi_t safi = bgp_node_safi(vty); | |
5199 | ||
5200 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5201 | if (!peer) | |
5202 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 5203 | |
5204 | if (argv_find(argv, argc, "as-path", &idx)) | |
5205 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5206 | idx = 0; | |
5207 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5208 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5209 | idx = 0; | |
5210 | if (argv_find(argv, argc, "med", &idx)) | |
5211 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5212 | ||
8eeb0335 DW |
5213 | /* no flags means all of them! */ |
5214 | if (!flags) { | |
d62a17ae | 5215 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
5216 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5217 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 5218 | } else { |
a4d82a8a PZ |
5219 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
5220 | && peer_af_flag_check(peer, afi, safi, | |
5221 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
5222 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5223 | PEER_FLAG_AS_PATH_UNCHANGED); | |
5224 | } | |
5225 | ||
a4d82a8a PZ |
5226 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
5227 | && peer_af_flag_check(peer, afi, safi, | |
5228 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
5229 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5230 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
5231 | } | |
5232 | ||
a4d82a8a PZ |
5233 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
5234 | && peer_af_flag_check(peer, afi, safi, | |
5235 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
5236 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
5237 | PEER_FLAG_MED_UNCHANGED); | |
5238 | } | |
d62a17ae | 5239 | } |
5240 | ||
8eeb0335 | 5241 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 5242 | } |
5243 | ||
5244 | ALIAS_HIDDEN( | |
5245 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
5246 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5247 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5248 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5249 | "As-path attribute\n" | |
5250 | "Nexthop attribute\n" | |
5251 | "Med attribute\n") | |
596c17ba | 5252 | |
718e3744 | 5253 | DEFUN (no_neighbor_attr_unchanged, |
5254 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 5255 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 5256 | NO_STR |
718e3744 | 5257 | NEIGHBOR_STR |
5258 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
5259 | "BGP attribute is propagated unchanged to this neighbor\n" |
5260 | "As-path attribute\n" | |
40e718b5 | 5261 | "Nexthop attribute\n" |
a8206004 | 5262 | "Med attribute\n") |
718e3744 | 5263 | { |
d62a17ae | 5264 | int idx = 0; |
5265 | char *peer = argv[2]->arg; | |
d7c0a89a | 5266 | uint16_t flags = 0; |
d62a17ae | 5267 | |
5268 | if (argv_find(argv, argc, "as-path", &idx)) | |
5269 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5270 | idx = 0; | |
5271 | if (argv_find(argv, argc, "next-hop", &idx)) | |
5272 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5273 | idx = 0; | |
5274 | if (argv_find(argv, argc, "med", &idx)) | |
5275 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5276 | ||
5277 | if (!flags) // no flags means all of them! | |
5278 | { | |
5279 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
5280 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
5281 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
5282 | } | |
5283 | ||
5284 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
5285 | bgp_node_safi(vty), flags); | |
5286 | } | |
5287 | ||
5288 | ALIAS_HIDDEN( | |
5289 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
5290 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
5291 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5292 | "BGP attribute is propagated unchanged to this neighbor\n" | |
5293 | "As-path attribute\n" | |
5294 | "Nexthop attribute\n" | |
5295 | "Med attribute\n") | |
718e3744 | 5296 | |
718e3744 | 5297 | /* EBGP multihop configuration. */ |
d62a17ae | 5298 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
5299 | const char *ttl_str) | |
718e3744 | 5300 | { |
d62a17ae | 5301 | struct peer *peer; |
5302 | unsigned int ttl; | |
718e3744 | 5303 | |
d62a17ae | 5304 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5305 | if (!peer) | |
5306 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5307 | |
d62a17ae | 5308 | if (peer->conf_if) |
5309 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 5310 | |
d62a17ae | 5311 | if (!ttl_str) |
5312 | ttl = MAXTTL; | |
5313 | else | |
5314 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 5315 | |
d62a17ae | 5316 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 5317 | } |
5318 | ||
d62a17ae | 5319 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5320 | { |
d62a17ae | 5321 | struct peer *peer; |
718e3744 | 5322 | |
d62a17ae | 5323 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5324 | if (!peer) | |
5325 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5326 | |
d62a17ae | 5327 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 5328 | } |
5329 | ||
5330 | /* neighbor ebgp-multihop. */ | |
5331 | DEFUN (neighbor_ebgp_multihop, | |
5332 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 5333 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 5334 | NEIGHBOR_STR |
5335 | NEIGHBOR_ADDR_STR2 | |
5336 | "Allow EBGP neighbors not on directly connected networks\n") | |
5337 | { | |
d62a17ae | 5338 | int idx_peer = 1; |
5339 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5340 | } |
5341 | ||
5342 | DEFUN (neighbor_ebgp_multihop_ttl, | |
5343 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 5344 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 5345 | NEIGHBOR_STR |
5346 | NEIGHBOR_ADDR_STR2 | |
5347 | "Allow EBGP neighbors not on directly connected networks\n" | |
5348 | "maximum hop count\n") | |
5349 | { | |
d62a17ae | 5350 | int idx_peer = 1; |
5351 | int idx_number = 3; | |
5352 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
5353 | argv[idx_number]->arg); | |
718e3744 | 5354 | } |
5355 | ||
5356 | DEFUN (no_neighbor_ebgp_multihop, | |
5357 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 5358 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 5359 | NO_STR |
5360 | NEIGHBOR_STR | |
5361 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5362 | "Allow EBGP neighbors not on directly connected networks\n" |
5363 | "maximum hop count\n") | |
718e3744 | 5364 | { |
d62a17ae | 5365 | int idx_peer = 2; |
5366 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5367 | } |
5368 | ||
6b0655a2 | 5369 | |
6ffd2079 | 5370 | /* disable-connected-check */ |
5371 | DEFUN (neighbor_disable_connected_check, | |
5372 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 5373 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5374 | NEIGHBOR_STR |
7ebe625c | 5375 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5376 | "one-hop away EBGP peer using loopback address\n" |
5377 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5378 | { |
d62a17ae | 5379 | int idx_peer = 1; |
5380 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5381 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5382 | } |
5383 | ||
5384 | DEFUN (no_neighbor_disable_connected_check, | |
5385 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 5386 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 5387 | NO_STR |
5388 | NEIGHBOR_STR | |
7ebe625c | 5389 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
5390 | "one-hop away EBGP peer using loopback address\n" |
5391 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 5392 | { |
d62a17ae | 5393 | int idx_peer = 2; |
5394 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5395 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 5396 | } |
5397 | ||
47cbc09b PM |
5398 | |
5399 | /* enforce-first-as */ | |
5400 | DEFUN (neighbor_enforce_first_as, | |
5401 | neighbor_enforce_first_as_cmd, | |
5402 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5403 | NEIGHBOR_STR | |
5404 | NEIGHBOR_ADDR_STR2 | |
5405 | "Enforce the first AS for EBGP routes\n") | |
5406 | { | |
5407 | int idx_peer = 1; | |
5408 | ||
5409 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5410 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5411 | } | |
5412 | ||
5413 | DEFUN (no_neighbor_enforce_first_as, | |
5414 | no_neighbor_enforce_first_as_cmd, | |
5415 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
5416 | NO_STR | |
5417 | NEIGHBOR_STR | |
5418 | NEIGHBOR_ADDR_STR2 | |
5419 | "Enforce the first AS for EBGP routes\n") | |
5420 | { | |
5421 | int idx_peer = 2; | |
5422 | ||
5423 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5424 | PEER_FLAG_ENFORCE_FIRST_AS); | |
5425 | } | |
5426 | ||
5427 | ||
718e3744 | 5428 | DEFUN (neighbor_description, |
5429 | neighbor_description_cmd, | |
e961923c | 5430 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 5431 | NEIGHBOR_STR |
5432 | NEIGHBOR_ADDR_STR2 | |
5433 | "Neighbor specific description\n" | |
5434 | "Up to 80 characters describing this neighbor\n") | |
5435 | { | |
d62a17ae | 5436 | int idx_peer = 1; |
5437 | int idx_line = 3; | |
5438 | struct peer *peer; | |
5439 | char *str; | |
718e3744 | 5440 | |
d62a17ae | 5441 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5442 | if (!peer) | |
5443 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5444 | |
d62a17ae | 5445 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 5446 | |
d62a17ae | 5447 | peer_description_set(peer, str); |
718e3744 | 5448 | |
d62a17ae | 5449 | XFREE(MTYPE_TMP, str); |
718e3744 | 5450 | |
d62a17ae | 5451 | return CMD_SUCCESS; |
718e3744 | 5452 | } |
5453 | ||
5454 | DEFUN (no_neighbor_description, | |
5455 | no_neighbor_description_cmd, | |
a14810f4 | 5456 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 5457 | NO_STR |
5458 | NEIGHBOR_STR | |
5459 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 5460 | "Neighbor specific description\n") |
718e3744 | 5461 | { |
d62a17ae | 5462 | int idx_peer = 2; |
5463 | struct peer *peer; | |
718e3744 | 5464 | |
d62a17ae | 5465 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5466 | if (!peer) | |
5467 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5468 | |
d62a17ae | 5469 | peer_description_unset(peer); |
718e3744 | 5470 | |
d62a17ae | 5471 | return CMD_SUCCESS; |
718e3744 | 5472 | } |
5473 | ||
a14810f4 PM |
5474 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
5475 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
5476 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5477 | "Neighbor specific description\n" | |
5478 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 5479 | |
718e3744 | 5480 | /* Neighbor update-source. */ |
d62a17ae | 5481 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
5482 | const char *source_str) | |
5483 | { | |
5484 | struct peer *peer; | |
5485 | struct prefix p; | |
a14810f4 | 5486 | union sockunion su; |
d62a17ae | 5487 | |
5488 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
5489 | if (!peer) | |
5490 | return CMD_WARNING_CONFIG_FAILED; | |
5491 | ||
5492 | if (peer->conf_if) | |
5493 | return CMD_WARNING; | |
5494 | ||
5495 | if (source_str) { | |
a14810f4 | 5496 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 5497 | peer_update_source_addr_set(peer, &su); |
5498 | else { | |
5499 | if (str2prefix(source_str, &p)) { | |
5500 | vty_out(vty, | |
5501 | "%% Invalid update-source, remove prefix length \n"); | |
5502 | return CMD_WARNING_CONFIG_FAILED; | |
5503 | } else | |
5504 | peer_update_source_if_set(peer, source_str); | |
5505 | } | |
5506 | } else | |
5507 | peer_update_source_unset(peer); | |
5508 | ||
5509 | return CMD_SUCCESS; | |
5510 | } | |
5511 | ||
5512 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
5513 | "IPv4 address\n" \ | |
5514 | "IPv6 address\n" \ | |
5515 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 5516 | |
718e3744 | 5517 | DEFUN (neighbor_update_source, |
5518 | neighbor_update_source_cmd, | |
9ccf14f7 | 5519 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 5520 | NEIGHBOR_STR |
5521 | NEIGHBOR_ADDR_STR2 | |
5522 | "Source of routing updates\n" | |
369688c0 | 5523 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 5524 | { |
d62a17ae | 5525 | int idx_peer = 1; |
5526 | int idx_peer_2 = 3; | |
5527 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
5528 | argv[idx_peer_2]->arg); | |
718e3744 | 5529 | } |
5530 | ||
5531 | DEFUN (no_neighbor_update_source, | |
5532 | no_neighbor_update_source_cmd, | |
c7178fe7 | 5533 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 5534 | NO_STR |
5535 | NEIGHBOR_STR | |
5536 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
5537 | "Source of routing updates\n" |
5538 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 5539 | { |
d62a17ae | 5540 | int idx_peer = 2; |
5541 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5542 | } |
6b0655a2 | 5543 | |
d62a17ae | 5544 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
5545 | afi_t afi, safi_t safi, | |
5546 | const char *rmap, int set) | |
718e3744 | 5547 | { |
d62a17ae | 5548 | int ret; |
5549 | struct peer *peer; | |
80912664 | 5550 | struct route_map *route_map = NULL; |
718e3744 | 5551 | |
d62a17ae | 5552 | peer = peer_and_group_lookup_vty(vty, peer_str); |
5553 | if (!peer) | |
5554 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5555 | |
1de27621 | 5556 | if (set) { |
80912664 DS |
5557 | if (rmap) |
5558 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
5559 | ret = peer_default_originate_set(peer, afi, safi, |
5560 | rmap, route_map); | |
5561 | } else | |
d62a17ae | 5562 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 5563 | |
d62a17ae | 5564 | return bgp_vty_return(vty, ret); |
718e3744 | 5565 | } |
5566 | ||
5567 | /* neighbor default-originate. */ | |
5568 | DEFUN (neighbor_default_originate, | |
5569 | neighbor_default_originate_cmd, | |
9ccf14f7 | 5570 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 5571 | NEIGHBOR_STR |
5572 | NEIGHBOR_ADDR_STR2 | |
5573 | "Originate default route to this neighbor\n") | |
5574 | { | |
d62a17ae | 5575 | int idx_peer = 1; |
5576 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5577 | bgp_node_afi(vty), | |
5578 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 5579 | } |
5580 | ||
d62a17ae | 5581 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
5582 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
5583 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5584 | "Originate default route to this neighbor\n") | |
596c17ba | 5585 | |
718e3744 | 5586 | DEFUN (neighbor_default_originate_rmap, |
5587 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 5588 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 5589 | NEIGHBOR_STR |
5590 | NEIGHBOR_ADDR_STR2 | |
5591 | "Originate default route to this neighbor\n" | |
5592 | "Route-map to specify criteria to originate default\n" | |
5593 | "route-map name\n") | |
5594 | { | |
d62a17ae | 5595 | int idx_peer = 1; |
5596 | int idx_word = 4; | |
5597 | return peer_default_originate_set_vty( | |
5598 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5599 | argv[idx_word]->arg, 1); | |
718e3744 | 5600 | } |
5601 | ||
d62a17ae | 5602 | ALIAS_HIDDEN( |
5603 | neighbor_default_originate_rmap, | |
5604 | neighbor_default_originate_rmap_hidden_cmd, | |
5605 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
5606 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5607 | "Originate default route to this neighbor\n" | |
5608 | "Route-map to specify criteria to originate default\n" | |
5609 | "route-map name\n") | |
596c17ba | 5610 | |
718e3744 | 5611 | DEFUN (no_neighbor_default_originate, |
5612 | no_neighbor_default_originate_cmd, | |
a636c635 | 5613 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 5614 | NO_STR |
5615 | NEIGHBOR_STR | |
5616 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
5617 | "Originate default route to this neighbor\n" |
5618 | "Route-map to specify criteria to originate default\n" | |
5619 | "route-map name\n") | |
718e3744 | 5620 | { |
d62a17ae | 5621 | int idx_peer = 2; |
5622 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
5623 | bgp_node_afi(vty), | |
5624 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 5625 | } |
5626 | ||
d62a17ae | 5627 | ALIAS_HIDDEN( |
5628 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
5629 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
5630 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5631 | "Originate default route to this neighbor\n" | |
5632 | "Route-map to specify criteria to originate default\n" | |
5633 | "route-map name\n") | |
596c17ba | 5634 | |
6b0655a2 | 5635 | |
718e3744 | 5636 | /* Set neighbor's BGP port. */ |
d62a17ae | 5637 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
5638 | const char *port_str) | |
5639 | { | |
5640 | struct peer *peer; | |
d7c0a89a | 5641 | uint16_t port; |
d62a17ae | 5642 | struct servent *sp; |
5643 | ||
5644 | peer = peer_lookup_vty(vty, ip_str); | |
5645 | if (!peer) | |
5646 | return CMD_WARNING_CONFIG_FAILED; | |
5647 | ||
5648 | if (!port_str) { | |
5649 | sp = getservbyname("bgp", "tcp"); | |
5650 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
5651 | } else { | |
5652 | port = strtoul(port_str, NULL, 10); | |
5653 | } | |
718e3744 | 5654 | |
d62a17ae | 5655 | peer_port_set(peer, port); |
718e3744 | 5656 | |
d62a17ae | 5657 | return CMD_SUCCESS; |
718e3744 | 5658 | } |
5659 | ||
f418446b | 5660 | /* Set specified peer's BGP port. */ |
718e3744 | 5661 | DEFUN (neighbor_port, |
5662 | neighbor_port_cmd, | |
9ccf14f7 | 5663 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5664 | NEIGHBOR_STR |
5665 | NEIGHBOR_ADDR_STR | |
5666 | "Neighbor's BGP port\n" | |
5667 | "TCP port number\n") | |
5668 | { | |
d62a17ae | 5669 | int idx_ip = 1; |
5670 | int idx_number = 3; | |
5671 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5672 | argv[idx_number]->arg); | |
718e3744 | 5673 | } |
5674 | ||
5675 | DEFUN (no_neighbor_port, | |
5676 | no_neighbor_port_cmd, | |
9ccf14f7 | 5677 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5678 | NO_STR |
5679 | NEIGHBOR_STR | |
5680 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5681 | "Neighbor's BGP port\n" |
5682 | "TCP port number\n") | |
718e3744 | 5683 | { |
d62a17ae | 5684 | int idx_ip = 2; |
5685 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5686 | } |
5687 | ||
6b0655a2 | 5688 | |
718e3744 | 5689 | /* neighbor weight. */ |
d62a17ae | 5690 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5691 | safi_t safi, const char *weight_str) | |
718e3744 | 5692 | { |
d62a17ae | 5693 | int ret; |
5694 | struct peer *peer; | |
5695 | unsigned long weight; | |
718e3744 | 5696 | |
d62a17ae | 5697 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5698 | if (!peer) | |
5699 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5700 | |
d62a17ae | 5701 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5702 | |
d62a17ae | 5703 | ret = peer_weight_set(peer, afi, safi, weight); |
5704 | return bgp_vty_return(vty, ret); | |
718e3744 | 5705 | } |
5706 | ||
d62a17ae | 5707 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5708 | safi_t safi) | |
718e3744 | 5709 | { |
d62a17ae | 5710 | int ret; |
5711 | struct peer *peer; | |
718e3744 | 5712 | |
d62a17ae | 5713 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5714 | if (!peer) | |
5715 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5716 | |
d62a17ae | 5717 | ret = peer_weight_unset(peer, afi, safi); |
5718 | return bgp_vty_return(vty, ret); | |
718e3744 | 5719 | } |
5720 | ||
5721 | DEFUN (neighbor_weight, | |
5722 | neighbor_weight_cmd, | |
9ccf14f7 | 5723 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5724 | NEIGHBOR_STR |
5725 | NEIGHBOR_ADDR_STR2 | |
5726 | "Set default weight for routes from this neighbor\n" | |
5727 | "default weight\n") | |
5728 | { | |
d62a17ae | 5729 | int idx_peer = 1; |
5730 | int idx_number = 3; | |
5731 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5732 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5733 | } |
5734 | ||
d62a17ae | 5735 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5736 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5737 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5738 | "Set default weight for routes from this neighbor\n" | |
5739 | "default weight\n") | |
596c17ba | 5740 | |
718e3744 | 5741 | DEFUN (no_neighbor_weight, |
5742 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5743 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5744 | NO_STR |
5745 | NEIGHBOR_STR | |
5746 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5747 | "Set default weight for routes from this neighbor\n" |
5748 | "default weight\n") | |
718e3744 | 5749 | { |
d62a17ae | 5750 | int idx_peer = 2; |
5751 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5752 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5753 | } |
5754 | ||
d62a17ae | 5755 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5756 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5757 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5758 | "Set default weight for routes from this neighbor\n" | |
5759 | "default weight\n") | |
596c17ba | 5760 | |
6b0655a2 | 5761 | |
718e3744 | 5762 | /* Override capability negotiation. */ |
5763 | DEFUN (neighbor_override_capability, | |
5764 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5765 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5766 | NEIGHBOR_STR |
5767 | NEIGHBOR_ADDR_STR2 | |
5768 | "Override capability negotiation result\n") | |
5769 | { | |
d62a17ae | 5770 | int idx_peer = 1; |
5771 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5772 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5773 | } |
5774 | ||
5775 | DEFUN (no_neighbor_override_capability, | |
5776 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5777 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5778 | NO_STR |
5779 | NEIGHBOR_STR | |
5780 | NEIGHBOR_ADDR_STR2 | |
5781 | "Override capability negotiation result\n") | |
5782 | { | |
d62a17ae | 5783 | int idx_peer = 2; |
5784 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5785 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5786 | } |
6b0655a2 | 5787 | |
718e3744 | 5788 | DEFUN (neighbor_strict_capability, |
5789 | neighbor_strict_capability_cmd, | |
9fb964de | 5790 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5791 | NEIGHBOR_STR |
9fb964de | 5792 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5793 | "Strict capability negotiation match\n") |
5794 | { | |
9fb964de PM |
5795 | int idx_peer = 1; |
5796 | ||
5797 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5798 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5799 | } |
5800 | ||
5801 | DEFUN (no_neighbor_strict_capability, | |
5802 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5803 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5804 | NO_STR |
5805 | NEIGHBOR_STR | |
9fb964de | 5806 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5807 | "Strict capability negotiation match\n") |
5808 | { | |
9fb964de PM |
5809 | int idx_peer = 2; |
5810 | ||
5811 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5812 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5813 | } |
6b0655a2 | 5814 | |
d62a17ae | 5815 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5816 | const char *keep_str, const char *hold_str) | |
718e3744 | 5817 | { |
d62a17ae | 5818 | int ret; |
5819 | struct peer *peer; | |
d7c0a89a QY |
5820 | uint32_t keepalive; |
5821 | uint32_t holdtime; | |
718e3744 | 5822 | |
d62a17ae | 5823 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5824 | if (!peer) | |
5825 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5826 | |
d62a17ae | 5827 | keepalive = strtoul(keep_str, NULL, 10); |
5828 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5829 | |
d62a17ae | 5830 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5831 | |
d62a17ae | 5832 | return bgp_vty_return(vty, ret); |
718e3744 | 5833 | } |
6b0655a2 | 5834 | |
d62a17ae | 5835 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5836 | { |
d62a17ae | 5837 | int ret; |
5838 | struct peer *peer; | |
718e3744 | 5839 | |
d62a17ae | 5840 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5841 | if (!peer) | |
5842 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5843 | |
d62a17ae | 5844 | ret = peer_timers_unset(peer); |
718e3744 | 5845 | |
d62a17ae | 5846 | return bgp_vty_return(vty, ret); |
718e3744 | 5847 | } |
5848 | ||
5849 | DEFUN (neighbor_timers, | |
5850 | neighbor_timers_cmd, | |
9ccf14f7 | 5851 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5852 | NEIGHBOR_STR |
5853 | NEIGHBOR_ADDR_STR2 | |
5854 | "BGP per neighbor timers\n" | |
5855 | "Keepalive interval\n" | |
5856 | "Holdtime\n") | |
5857 | { | |
d62a17ae | 5858 | int idx_peer = 1; |
5859 | int idx_number = 3; | |
5860 | int idx_number_2 = 4; | |
5861 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5862 | argv[idx_number]->arg, | |
5863 | argv[idx_number_2]->arg); | |
718e3744 | 5864 | } |
5865 | ||
5866 | DEFUN (no_neighbor_timers, | |
5867 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5868 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5869 | NO_STR |
5870 | NEIGHBOR_STR | |
5871 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5872 | "BGP per neighbor timers\n" |
5873 | "Keepalive interval\n" | |
5874 | "Holdtime\n") | |
718e3744 | 5875 | { |
d62a17ae | 5876 | int idx_peer = 2; |
5877 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5878 | } |
6b0655a2 | 5879 | |
813d4307 | 5880 | |
d62a17ae | 5881 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5882 | const char *time_str) | |
718e3744 | 5883 | { |
d62a17ae | 5884 | int ret; |
5885 | struct peer *peer; | |
d7c0a89a | 5886 | uint32_t connect; |
718e3744 | 5887 | |
d62a17ae | 5888 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5889 | if (!peer) | |
5890 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5891 | |
d62a17ae | 5892 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5893 | |
d62a17ae | 5894 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5895 | |
d62a17ae | 5896 | return bgp_vty_return(vty, ret); |
718e3744 | 5897 | } |
5898 | ||
d62a17ae | 5899 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5900 | { |
d62a17ae | 5901 | int ret; |
5902 | struct peer *peer; | |
718e3744 | 5903 | |
d62a17ae | 5904 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5905 | if (!peer) | |
5906 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5907 | |
d62a17ae | 5908 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5909 | |
d62a17ae | 5910 | return bgp_vty_return(vty, ret); |
718e3744 | 5911 | } |
5912 | ||
5913 | DEFUN (neighbor_timers_connect, | |
5914 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5915 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5916 | NEIGHBOR_STR |
966f821c | 5917 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5918 | "BGP per neighbor timers\n" |
5919 | "BGP connect timer\n" | |
5920 | "Connect timer\n") | |
5921 | { | |
d62a17ae | 5922 | int idx_peer = 1; |
5923 | int idx_number = 4; | |
5924 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5925 | argv[idx_number]->arg); | |
718e3744 | 5926 | } |
5927 | ||
5928 | DEFUN (no_neighbor_timers_connect, | |
5929 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5930 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5931 | NO_STR |
5932 | NEIGHBOR_STR | |
966f821c | 5933 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5934 | "BGP per neighbor timers\n" |
8334fd5a DW |
5935 | "BGP connect timer\n" |
5936 | "Connect timer\n") | |
718e3744 | 5937 | { |
d62a17ae | 5938 | int idx_peer = 2; |
5939 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5940 | } |
5941 | ||
6b0655a2 | 5942 | |
d62a17ae | 5943 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5944 | const char *time_str, int set) | |
718e3744 | 5945 | { |
d62a17ae | 5946 | int ret; |
5947 | struct peer *peer; | |
d7c0a89a | 5948 | uint32_t routeadv = 0; |
718e3744 | 5949 | |
d62a17ae | 5950 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5951 | if (!peer) | |
5952 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5953 | |
d62a17ae | 5954 | if (time_str) |
5955 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5956 | |
d62a17ae | 5957 | if (set) |
5958 | ret = peer_advertise_interval_set(peer, routeadv); | |
5959 | else | |
5960 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5961 | |
d62a17ae | 5962 | return bgp_vty_return(vty, ret); |
718e3744 | 5963 | } |
5964 | ||
5965 | DEFUN (neighbor_advertise_interval, | |
5966 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5967 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5968 | NEIGHBOR_STR |
966f821c | 5969 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5970 | "Minimum interval between sending BGP routing updates\n" |
5971 | "time in seconds\n") | |
5972 | { | |
d62a17ae | 5973 | int idx_peer = 1; |
5974 | int idx_number = 3; | |
5975 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5976 | argv[idx_number]->arg, 1); | |
718e3744 | 5977 | } |
5978 | ||
5979 | DEFUN (no_neighbor_advertise_interval, | |
5980 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5981 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5982 | NO_STR |
5983 | NEIGHBOR_STR | |
966f821c | 5984 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5985 | "Minimum interval between sending BGP routing updates\n" |
5986 | "time in seconds\n") | |
718e3744 | 5987 | { |
d62a17ae | 5988 | int idx_peer = 2; |
5989 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5990 | } |
5991 | ||
6b0655a2 | 5992 | |
518f0eb1 DS |
5993 | /* Time to wait before processing route-map updates */ |
5994 | DEFUN (bgp_set_route_map_delay_timer, | |
5995 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5996 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5997 | SET_STR |
5998 | "BGP route-map delay timer\n" | |
5999 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 6000 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 6001 | { |
d62a17ae | 6002 | int idx_number = 3; |
d7c0a89a | 6003 | uint32_t rmap_delay_timer; |
d62a17ae | 6004 | |
6005 | if (argv[idx_number]->arg) { | |
6006 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
6007 | bm->rmap_update_timer = rmap_delay_timer; | |
6008 | ||
6009 | /* if the dynamic update handling is being disabled, and a timer | |
6010 | * is | |
6011 | * running, stop the timer and act as if the timer has already | |
6012 | * fired. | |
6013 | */ | |
6014 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
6015 | BGP_TIMER_OFF(bm->t_rmap_update); | |
6016 | thread_execute(bm->master, bgp_route_map_update_timer, | |
6017 | NULL, 0); | |
6018 | } | |
6019 | return CMD_SUCCESS; | |
6020 | } else { | |
6021 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
6022 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 6023 | } |
518f0eb1 DS |
6024 | } |
6025 | ||
6026 | DEFUN (no_bgp_set_route_map_delay_timer, | |
6027 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 6028 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 6029 | NO_STR |
3a2d747c | 6030 | BGP_STR |
518f0eb1 | 6031 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
6032 | "Reset to default time to wait for processing route-map changes\n" |
6033 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 6034 | { |
518f0eb1 | 6035 | |
d62a17ae | 6036 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 6037 | |
d62a17ae | 6038 | return CMD_SUCCESS; |
518f0eb1 DS |
6039 | } |
6040 | ||
f414725f | 6041 | |
718e3744 | 6042 | /* neighbor interface */ |
d62a17ae | 6043 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
6044 | const char *str) | |
718e3744 | 6045 | { |
d62a17ae | 6046 | struct peer *peer; |
718e3744 | 6047 | |
d62a17ae | 6048 | peer = peer_lookup_vty(vty, ip_str); |
6049 | if (!peer || peer->conf_if) { | |
6050 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
6051 | return CMD_WARNING_CONFIG_FAILED; | |
6052 | } | |
718e3744 | 6053 | |
d62a17ae | 6054 | if (str) |
6055 | peer_interface_set(peer, str); | |
6056 | else | |
6057 | peer_interface_unset(peer); | |
718e3744 | 6058 | |
d62a17ae | 6059 | return CMD_SUCCESS; |
718e3744 | 6060 | } |
6061 | ||
6062 | DEFUN (neighbor_interface, | |
6063 | neighbor_interface_cmd, | |
9ccf14f7 | 6064 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 6065 | NEIGHBOR_STR |
6066 | NEIGHBOR_ADDR_STR | |
6067 | "Interface\n" | |
6068 | "Interface name\n") | |
6069 | { | |
d62a17ae | 6070 | int idx_ip = 1; |
6071 | int idx_word = 3; | |
6072 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 6073 | } |
6074 | ||
6075 | DEFUN (no_neighbor_interface, | |
6076 | no_neighbor_interface_cmd, | |
9ccf14f7 | 6077 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 6078 | NO_STR |
6079 | NEIGHBOR_STR | |
16cedbb0 | 6080 | NEIGHBOR_ADDR_STR2 |
718e3744 | 6081 | "Interface\n" |
6082 | "Interface name\n") | |
6083 | { | |
d62a17ae | 6084 | int idx_peer = 2; |
6085 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 6086 | } |
6b0655a2 | 6087 | |
718e3744 | 6088 | DEFUN (neighbor_distribute_list, |
6089 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 6090 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6091 | NEIGHBOR_STR |
6092 | NEIGHBOR_ADDR_STR2 | |
6093 | "Filter updates to/from this neighbor\n" | |
6094 | "IP access-list number\n" | |
6095 | "IP access-list number (expanded range)\n" | |
6096 | "IP Access-list name\n" | |
6097 | "Filter incoming updates\n" | |
6098 | "Filter outgoing updates\n") | |
6099 | { | |
d62a17ae | 6100 | int idx_peer = 1; |
6101 | int idx_acl = 3; | |
6102 | int direct, ret; | |
6103 | struct peer *peer; | |
a8206004 | 6104 | |
d62a17ae | 6105 | const char *pstr = argv[idx_peer]->arg; |
6106 | const char *acl = argv[idx_acl]->arg; | |
6107 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6108 | |
d62a17ae | 6109 | peer = peer_and_group_lookup_vty(vty, pstr); |
6110 | if (!peer) | |
6111 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6112 | |
d62a17ae | 6113 | /* Check filter direction. */ |
6114 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6115 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6116 | direct, acl); | |
a8206004 | 6117 | |
d62a17ae | 6118 | return bgp_vty_return(vty, ret); |
718e3744 | 6119 | } |
6120 | ||
d62a17ae | 6121 | ALIAS_HIDDEN( |
6122 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
6123 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6124 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6125 | "Filter updates to/from this neighbor\n" | |
6126 | "IP access-list number\n" | |
6127 | "IP access-list number (expanded range)\n" | |
6128 | "IP Access-list name\n" | |
6129 | "Filter incoming updates\n" | |
6130 | "Filter outgoing updates\n") | |
596c17ba | 6131 | |
718e3744 | 6132 | DEFUN (no_neighbor_distribute_list, |
6133 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 6134 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 6135 | NO_STR |
6136 | NEIGHBOR_STR | |
6137 | NEIGHBOR_ADDR_STR2 | |
6138 | "Filter updates to/from this neighbor\n" | |
6139 | "IP access-list number\n" | |
6140 | "IP access-list number (expanded range)\n" | |
6141 | "IP Access-list name\n" | |
6142 | "Filter incoming updates\n" | |
6143 | "Filter outgoing updates\n") | |
6144 | { | |
d62a17ae | 6145 | int idx_peer = 2; |
6146 | int direct, ret; | |
6147 | struct peer *peer; | |
a8206004 | 6148 | |
d62a17ae | 6149 | const char *pstr = argv[idx_peer]->arg; |
6150 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 6151 | |
d62a17ae | 6152 | peer = peer_and_group_lookup_vty(vty, pstr); |
6153 | if (!peer) | |
6154 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 6155 | |
d62a17ae | 6156 | /* Check filter direction. */ |
6157 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
6158 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6159 | direct); | |
a8206004 | 6160 | |
d62a17ae | 6161 | return bgp_vty_return(vty, ret); |
718e3744 | 6162 | } |
6b0655a2 | 6163 | |
d62a17ae | 6164 | ALIAS_HIDDEN( |
6165 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
6166 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
6167 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6168 | "Filter updates to/from this neighbor\n" | |
6169 | "IP access-list number\n" | |
6170 | "IP access-list number (expanded range)\n" | |
6171 | "IP Access-list name\n" | |
6172 | "Filter incoming updates\n" | |
6173 | "Filter outgoing updates\n") | |
596c17ba | 6174 | |
718e3744 | 6175 | /* Set prefix list to the peer. */ |
d62a17ae | 6176 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
6177 | afi_t afi, safi_t safi, | |
6178 | const char *name_str, | |
6179 | const char *direct_str) | |
718e3744 | 6180 | { |
d62a17ae | 6181 | int ret; |
d62a17ae | 6182 | int direct = FILTER_IN; |
cf9ac8bf | 6183 | struct peer *peer; |
718e3744 | 6184 | |
d62a17ae | 6185 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6186 | if (!peer) | |
6187 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6188 | |
d62a17ae | 6189 | /* Check filter direction. */ |
6190 | if (strncmp(direct_str, "i", 1) == 0) | |
6191 | direct = FILTER_IN; | |
6192 | else if (strncmp(direct_str, "o", 1) == 0) | |
6193 | direct = FILTER_OUT; | |
718e3744 | 6194 | |
d62a17ae | 6195 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 6196 | |
d62a17ae | 6197 | return bgp_vty_return(vty, ret); |
718e3744 | 6198 | } |
6199 | ||
d62a17ae | 6200 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
6201 | afi_t afi, safi_t safi, | |
6202 | const char *direct_str) | |
718e3744 | 6203 | { |
d62a17ae | 6204 | int ret; |
6205 | struct peer *peer; | |
6206 | int direct = FILTER_IN; | |
718e3744 | 6207 | |
d62a17ae | 6208 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6209 | if (!peer) | |
6210 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 6211 | |
d62a17ae | 6212 | /* Check filter direction. */ |
6213 | if (strncmp(direct_str, "i", 1) == 0) | |
6214 | direct = FILTER_IN; | |
6215 | else if (strncmp(direct_str, "o", 1) == 0) | |
6216 | direct = FILTER_OUT; | |
718e3744 | 6217 | |
d62a17ae | 6218 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 6219 | |
d62a17ae | 6220 | return bgp_vty_return(vty, ret); |
718e3744 | 6221 | } |
6222 | ||
6223 | DEFUN (neighbor_prefix_list, | |
6224 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 6225 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6226 | NEIGHBOR_STR |
6227 | NEIGHBOR_ADDR_STR2 | |
6228 | "Filter updates to/from this neighbor\n" | |
6229 | "Name of a prefix list\n" | |
6230 | "Filter incoming updates\n" | |
6231 | "Filter outgoing updates\n") | |
6232 | { | |
d62a17ae | 6233 | int idx_peer = 1; |
6234 | int idx_word = 3; | |
6235 | int idx_in_out = 4; | |
6236 | return peer_prefix_list_set_vty( | |
6237 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6238 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6239 | } |
6240 | ||
d62a17ae | 6241 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
6242 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6243 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6244 | "Filter updates to/from this neighbor\n" | |
6245 | "Name of a prefix list\n" | |
6246 | "Filter incoming updates\n" | |
6247 | "Filter outgoing updates\n") | |
596c17ba | 6248 | |
718e3744 | 6249 | DEFUN (no_neighbor_prefix_list, |
6250 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 6251 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 6252 | NO_STR |
6253 | NEIGHBOR_STR | |
6254 | NEIGHBOR_ADDR_STR2 | |
6255 | "Filter updates to/from this neighbor\n" | |
6256 | "Name of a prefix list\n" | |
6257 | "Filter incoming updates\n" | |
6258 | "Filter outgoing updates\n") | |
6259 | { | |
d62a17ae | 6260 | int idx_peer = 2; |
6261 | int idx_in_out = 5; | |
6262 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
6263 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6264 | argv[idx_in_out]->arg); | |
718e3744 | 6265 | } |
6b0655a2 | 6266 | |
d62a17ae | 6267 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
6268 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
6269 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6270 | "Filter updates to/from this neighbor\n" | |
6271 | "Name of a prefix list\n" | |
6272 | "Filter incoming updates\n" | |
6273 | "Filter outgoing updates\n") | |
596c17ba | 6274 | |
d62a17ae | 6275 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6276 | safi_t safi, const char *name_str, | |
6277 | const char *direct_str) | |
718e3744 | 6278 | { |
d62a17ae | 6279 | int ret; |
6280 | struct peer *peer; | |
6281 | int direct = FILTER_IN; | |
718e3744 | 6282 | |
d62a17ae | 6283 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6284 | if (!peer) | |
6285 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6286 | |
d62a17ae | 6287 | /* Check filter direction. */ |
6288 | if (strncmp(direct_str, "i", 1) == 0) | |
6289 | direct = FILTER_IN; | |
6290 | else if (strncmp(direct_str, "o", 1) == 0) | |
6291 | direct = FILTER_OUT; | |
718e3744 | 6292 | |
d62a17ae | 6293 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 6294 | |
d62a17ae | 6295 | return bgp_vty_return(vty, ret); |
718e3744 | 6296 | } |
6297 | ||
d62a17ae | 6298 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
6299 | safi_t safi, const char *direct_str) | |
718e3744 | 6300 | { |
d62a17ae | 6301 | int ret; |
6302 | struct peer *peer; | |
6303 | int direct = FILTER_IN; | |
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_aslist_unset(peer, afi, safi, direct); |
718e3744 | 6316 | |
d62a17ae | 6317 | return bgp_vty_return(vty, ret); |
718e3744 | 6318 | } |
6319 | ||
6320 | DEFUN (neighbor_filter_list, | |
6321 | neighbor_filter_list_cmd, | |
9ccf14f7 | 6322 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6323 | NEIGHBOR_STR |
6324 | NEIGHBOR_ADDR_STR2 | |
6325 | "Establish BGP filters\n" | |
6326 | "AS path access-list name\n" | |
6327 | "Filter incoming routes\n" | |
6328 | "Filter outgoing routes\n") | |
6329 | { | |
d62a17ae | 6330 | int idx_peer = 1; |
6331 | int idx_word = 3; | |
6332 | int idx_in_out = 4; | |
6333 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
6334 | bgp_node_safi(vty), argv[idx_word]->arg, | |
6335 | argv[idx_in_out]->arg); | |
718e3744 | 6336 | } |
6337 | ||
d62a17ae | 6338 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
6339 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6340 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6341 | "Establish BGP filters\n" | |
6342 | "AS path access-list name\n" | |
6343 | "Filter incoming routes\n" | |
6344 | "Filter outgoing routes\n") | |
596c17ba | 6345 | |
718e3744 | 6346 | DEFUN (no_neighbor_filter_list, |
6347 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 6348 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 6349 | NO_STR |
6350 | NEIGHBOR_STR | |
6351 | NEIGHBOR_ADDR_STR2 | |
6352 | "Establish BGP filters\n" | |
6353 | "AS path access-list name\n" | |
6354 | "Filter incoming routes\n" | |
6355 | "Filter outgoing routes\n") | |
6356 | { | |
d62a17ae | 6357 | int idx_peer = 2; |
6358 | int idx_in_out = 5; | |
6359 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
6360 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6361 | argv[idx_in_out]->arg); | |
718e3744 | 6362 | } |
6b0655a2 | 6363 | |
d62a17ae | 6364 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
6365 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
6366 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6367 | "Establish BGP filters\n" | |
6368 | "AS path access-list name\n" | |
6369 | "Filter incoming routes\n" | |
6370 | "Filter outgoing routes\n") | |
596c17ba | 6371 | |
718e3744 | 6372 | /* Set route-map to the peer. */ |
d62a17ae | 6373 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
6374 | afi_t afi, safi_t safi, const char *name_str, | |
6375 | const char *direct_str) | |
718e3744 | 6376 | { |
d62a17ae | 6377 | int ret; |
6378 | struct peer *peer; | |
6379 | int direct = RMAP_IN; | |
1de27621 | 6380 | struct route_map *route_map; |
718e3744 | 6381 | |
d62a17ae | 6382 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6383 | if (!peer) | |
6384 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6385 | |
d62a17ae | 6386 | /* Check filter direction. */ |
6387 | if (strncmp(direct_str, "in", 2) == 0) | |
6388 | direct = RMAP_IN; | |
6389 | else if (strncmp(direct_str, "o", 1) == 0) | |
6390 | direct = RMAP_OUT; | |
718e3744 | 6391 | |
1de27621 DA |
6392 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6393 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 6394 | |
d62a17ae | 6395 | return bgp_vty_return(vty, ret); |
718e3744 | 6396 | } |
6397 | ||
d62a17ae | 6398 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
6399 | afi_t afi, safi_t safi, | |
6400 | const char *direct_str) | |
718e3744 | 6401 | { |
d62a17ae | 6402 | int ret; |
6403 | struct peer *peer; | |
6404 | int direct = RMAP_IN; | |
718e3744 | 6405 | |
d62a17ae | 6406 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6407 | if (!peer) | |
6408 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6409 | |
d62a17ae | 6410 | /* Check filter direction. */ |
6411 | if (strncmp(direct_str, "in", 2) == 0) | |
6412 | direct = RMAP_IN; | |
6413 | else if (strncmp(direct_str, "o", 1) == 0) | |
6414 | direct = RMAP_OUT; | |
718e3744 | 6415 | |
d62a17ae | 6416 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 6417 | |
d62a17ae | 6418 | return bgp_vty_return(vty, ret); |
718e3744 | 6419 | } |
6420 | ||
6421 | DEFUN (neighbor_route_map, | |
6422 | neighbor_route_map_cmd, | |
9ccf14f7 | 6423 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6424 | NEIGHBOR_STR |
6425 | NEIGHBOR_ADDR_STR2 | |
6426 | "Apply route map to neighbor\n" | |
6427 | "Name of route map\n" | |
6428 | "Apply map to incoming routes\n" | |
2a3d5731 | 6429 | "Apply map to outbound routes\n") |
718e3744 | 6430 | { |
d62a17ae | 6431 | int idx_peer = 1; |
6432 | int idx_word = 3; | |
6433 | int idx_in_out = 4; | |
6434 | return peer_route_map_set_vty( | |
6435 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6436 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 6437 | } |
6438 | ||
d62a17ae | 6439 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
6440 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6441 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6442 | "Apply route map to neighbor\n" | |
6443 | "Name of route map\n" | |
6444 | "Apply map to incoming routes\n" | |
6445 | "Apply map to outbound routes\n") | |
596c17ba | 6446 | |
718e3744 | 6447 | DEFUN (no_neighbor_route_map, |
6448 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 6449 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 6450 | NO_STR |
6451 | NEIGHBOR_STR | |
6452 | NEIGHBOR_ADDR_STR2 | |
6453 | "Apply route map to neighbor\n" | |
6454 | "Name of route map\n" | |
6455 | "Apply map to incoming routes\n" | |
2a3d5731 | 6456 | "Apply map to outbound routes\n") |
718e3744 | 6457 | { |
d62a17ae | 6458 | int idx_peer = 2; |
6459 | int idx_in_out = 5; | |
6460 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
6461 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6462 | argv[idx_in_out]->arg); | |
718e3744 | 6463 | } |
6b0655a2 | 6464 | |
d62a17ae | 6465 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
6466 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
6467 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6468 | "Apply route map to neighbor\n" | |
6469 | "Name of route map\n" | |
6470 | "Apply map to incoming routes\n" | |
6471 | "Apply map to outbound routes\n") | |
596c17ba | 6472 | |
718e3744 | 6473 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 6474 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
6475 | afi_t afi, safi_t safi, | |
6476 | const char *name_str) | |
718e3744 | 6477 | { |
d62a17ae | 6478 | int ret; |
6479 | struct peer *peer; | |
1de27621 | 6480 | struct route_map *route_map; |
718e3744 | 6481 | |
d62a17ae | 6482 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6483 | if (!peer) | |
6484 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6485 | |
1de27621 DA |
6486 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
6487 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 6488 | |
d62a17ae | 6489 | return bgp_vty_return(vty, ret); |
718e3744 | 6490 | } |
6491 | ||
6492 | /* Unset route-map from the peer. */ | |
d62a17ae | 6493 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
6494 | afi_t afi, safi_t safi) | |
718e3744 | 6495 | { |
d62a17ae | 6496 | int ret; |
6497 | struct peer *peer; | |
718e3744 | 6498 | |
d62a17ae | 6499 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6500 | if (!peer) | |
6501 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6502 | |
d62a17ae | 6503 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 6504 | |
d62a17ae | 6505 | return bgp_vty_return(vty, ret); |
718e3744 | 6506 | } |
6507 | ||
6508 | DEFUN (neighbor_unsuppress_map, | |
6509 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6510 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6511 | NEIGHBOR_STR |
6512 | NEIGHBOR_ADDR_STR2 | |
6513 | "Route-map to selectively unsuppress suppressed routes\n" | |
6514 | "Name of route map\n") | |
6515 | { | |
d62a17ae | 6516 | int idx_peer = 1; |
6517 | int idx_word = 3; | |
6518 | return peer_unsuppress_map_set_vty( | |
6519 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6520 | argv[idx_word]->arg); | |
718e3744 | 6521 | } |
6522 | ||
d62a17ae | 6523 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
6524 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6525 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6526 | "Route-map to selectively unsuppress suppressed routes\n" | |
6527 | "Name of route map\n") | |
596c17ba | 6528 | |
718e3744 | 6529 | DEFUN (no_neighbor_unsuppress_map, |
6530 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 6531 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 6532 | NO_STR |
6533 | NEIGHBOR_STR | |
6534 | NEIGHBOR_ADDR_STR2 | |
6535 | "Route-map to selectively unsuppress suppressed routes\n" | |
6536 | "Name of route map\n") | |
6537 | { | |
d62a17ae | 6538 | int idx_peer = 2; |
6539 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
6540 | bgp_node_afi(vty), | |
6541 | bgp_node_safi(vty)); | |
718e3744 | 6542 | } |
6b0655a2 | 6543 | |
d62a17ae | 6544 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
6545 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
6546 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6547 | "Route-map to selectively unsuppress suppressed routes\n" | |
6548 | "Name of route map\n") | |
596c17ba | 6549 | |
d62a17ae | 6550 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
6551 | afi_t afi, safi_t safi, | |
6552 | const char *num_str, | |
6553 | const char *threshold_str, int warning, | |
6554 | const char *restart_str) | |
718e3744 | 6555 | { |
d62a17ae | 6556 | int ret; |
6557 | struct peer *peer; | |
d7c0a89a QY |
6558 | uint32_t max; |
6559 | uint8_t threshold; | |
6560 | uint16_t restart; | |
718e3744 | 6561 | |
d62a17ae | 6562 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6563 | if (!peer) | |
6564 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6565 | |
d62a17ae | 6566 | max = strtoul(num_str, NULL, 10); |
6567 | if (threshold_str) | |
6568 | threshold = atoi(threshold_str); | |
6569 | else | |
6570 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 6571 | |
d62a17ae | 6572 | if (restart_str) |
6573 | restart = atoi(restart_str); | |
6574 | else | |
6575 | restart = 0; | |
0a486e5f | 6576 | |
d62a17ae | 6577 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
6578 | restart); | |
718e3744 | 6579 | |
d62a17ae | 6580 | return bgp_vty_return(vty, ret); |
718e3744 | 6581 | } |
6582 | ||
d62a17ae | 6583 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
6584 | afi_t afi, safi_t safi) | |
718e3744 | 6585 | { |
d62a17ae | 6586 | int ret; |
6587 | struct peer *peer; | |
718e3744 | 6588 | |
d62a17ae | 6589 | peer = peer_and_group_lookup_vty(vty, ip_str); |
6590 | if (!peer) | |
6591 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6592 | |
d62a17ae | 6593 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 6594 | |
d62a17ae | 6595 | return bgp_vty_return(vty, ret); |
718e3744 | 6596 | } |
6597 | ||
fde246e8 DA |
6598 | /* Maximum number of prefix to be sent to the neighbor. */ |
6599 | DEFUN(neighbor_maximum_prefix_out, | |
6600 | neighbor_maximum_prefix_out_cmd, | |
6601 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)", | |
6602 | NEIGHBOR_STR | |
6603 | NEIGHBOR_ADDR_STR2 | |
6604 | "Maximum number of prefixes to be sent to this peer\n" | |
6605 | "Maximum no. of prefix limit\n") | |
6606 | { | |
6607 | int idx_peer = 1; | |
6608 | int idx_number = 3; | |
6609 | struct peer *peer; | |
6610 | uint32_t max; | |
6611 | afi_t afi = bgp_node_afi(vty); | |
6612 | safi_t safi = bgp_node_safi(vty); | |
6613 | ||
6614 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6615 | if (!peer) | |
6616 | return CMD_WARNING_CONFIG_FAILED; | |
6617 | ||
6618 | max = strtoul(argv[idx_number]->arg, NULL, 10); | |
6619 | ||
6620 | SET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); | |
6621 | peer->pmax_out[afi][safi] = max; | |
6622 | ||
6623 | return CMD_SUCCESS; | |
6624 | } | |
6625 | ||
6626 | DEFUN(no_neighbor_maximum_prefix_out, | |
6627 | no_neighbor_maximum_prefix_out_cmd, | |
6628 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out", | |
6629 | NO_STR | |
6630 | NEIGHBOR_STR | |
6631 | NEIGHBOR_ADDR_STR2 | |
6632 | "Maximum number of prefixes to be sent to this peer\n") | |
6633 | { | |
6634 | int idx_peer = 2; | |
6635 | struct peer *peer; | |
6636 | afi_t afi = bgp_node_afi(vty); | |
6637 | safi_t safi = bgp_node_safi(vty); | |
6638 | ||
6639 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6640 | if (!peer) | |
6641 | return CMD_WARNING_CONFIG_FAILED; | |
6642 | ||
ae00326a | 6643 | UNSET_FLAG(peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT); |
fde246e8 DA |
6644 | peer->pmax_out[afi][safi] = 0; |
6645 | ||
6646 | return CMD_SUCCESS; | |
6647 | } | |
6648 | ||
718e3744 | 6649 | /* Maximum number of prefix configuration. prefix count is different |
6650 | for each peer configuration. So this configuration can be set for | |
6651 | each peer configuration. */ | |
6652 | DEFUN (neighbor_maximum_prefix, | |
6653 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 6654 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 6655 | NEIGHBOR_STR |
6656 | NEIGHBOR_ADDR_STR2 | |
6657 | "Maximum number of prefix accept from this peer\n" | |
6658 | "maximum no. of prefix limit\n") | |
6659 | { | |
d62a17ae | 6660 | int idx_peer = 1; |
6661 | int idx_number = 3; | |
6662 | return peer_maximum_prefix_set_vty( | |
6663 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6664 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 6665 | } |
6666 | ||
d62a17ae | 6667 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
6668 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
6669 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6670 | "Maximum number of prefix accept from this peer\n" | |
6671 | "maximum no. of prefix limit\n") | |
596c17ba | 6672 | |
e0701b79 | 6673 | DEFUN (neighbor_maximum_prefix_threshold, |
6674 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 6675 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 6676 | NEIGHBOR_STR |
6677 | NEIGHBOR_ADDR_STR2 | |
6678 | "Maximum number of prefix accept from this peer\n" | |
6679 | "maximum no. of prefix limit\n" | |
6680 | "Threshold value (%) at which to generate a warning msg\n") | |
6681 | { | |
d62a17ae | 6682 | int idx_peer = 1; |
6683 | int idx_number = 3; | |
6684 | int idx_number_2 = 4; | |
6685 | return peer_maximum_prefix_set_vty( | |
6686 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6687 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 6688 | } |
e0701b79 | 6689 | |
d62a17ae | 6690 | ALIAS_HIDDEN( |
6691 | neighbor_maximum_prefix_threshold, | |
6692 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
6693 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
6694 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6695 | "Maximum number of prefix accept from this peer\n" | |
6696 | "maximum no. of prefix limit\n" | |
6697 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 6698 | |
718e3744 | 6699 | DEFUN (neighbor_maximum_prefix_warning, |
6700 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 6701 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 6702 | NEIGHBOR_STR |
6703 | NEIGHBOR_ADDR_STR2 | |
6704 | "Maximum number of prefix accept from this peer\n" | |
6705 | "maximum no. of prefix limit\n" | |
6706 | "Only give warning message when limit is exceeded\n") | |
6707 | { | |
d62a17ae | 6708 | int idx_peer = 1; |
6709 | int idx_number = 3; | |
6710 | return peer_maximum_prefix_set_vty( | |
6711 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6712 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6713 | } |
6714 | ||
d62a17ae | 6715 | ALIAS_HIDDEN( |
6716 | neighbor_maximum_prefix_warning, | |
6717 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6718 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6719 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6720 | "Maximum number of prefix accept from this peer\n" | |
6721 | "maximum no. of prefix limit\n" | |
6722 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6723 | |
e0701b79 | 6724 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6725 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6726 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6727 | NEIGHBOR_STR |
6728 | NEIGHBOR_ADDR_STR2 | |
6729 | "Maximum number of prefix accept from this peer\n" | |
6730 | "maximum no. of prefix limit\n" | |
6731 | "Threshold value (%) at which to generate a warning msg\n" | |
6732 | "Only give warning message when limit is exceeded\n") | |
6733 | { | |
d62a17ae | 6734 | int idx_peer = 1; |
6735 | int idx_number = 3; | |
6736 | int idx_number_2 = 4; | |
6737 | return peer_maximum_prefix_set_vty( | |
6738 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6739 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6740 | } |
6741 | ||
d62a17ae | 6742 | ALIAS_HIDDEN( |
6743 | neighbor_maximum_prefix_threshold_warning, | |
6744 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6745 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6746 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6747 | "Maximum number of prefix accept from this peer\n" | |
6748 | "maximum no. of prefix limit\n" | |
6749 | "Threshold value (%) at which to generate a warning msg\n" | |
6750 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6751 | |
0a486e5f | 6752 | DEFUN (neighbor_maximum_prefix_restart, |
6753 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6754 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6755 | NEIGHBOR_STR |
6756 | NEIGHBOR_ADDR_STR2 | |
6757 | "Maximum number of prefix accept from this peer\n" | |
6758 | "maximum no. of prefix limit\n" | |
6759 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6760 | "Restart interval in minutes\n") |
0a486e5f | 6761 | { |
d62a17ae | 6762 | int idx_peer = 1; |
6763 | int idx_number = 3; | |
6764 | int idx_number_2 = 5; | |
6765 | return peer_maximum_prefix_set_vty( | |
6766 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6767 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6768 | } |
6769 | ||
d62a17ae | 6770 | ALIAS_HIDDEN( |
6771 | neighbor_maximum_prefix_restart, | |
6772 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6773 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6774 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6775 | "Maximum number of prefix accept from this peer\n" | |
6776 | "maximum no. of prefix limit\n" | |
6777 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6778 | "Restart interval in minutes\n") |
596c17ba | 6779 | |
0a486e5f | 6780 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6781 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6782 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6783 | NEIGHBOR_STR |
6784 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6785 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6786 | "maximum no. of prefix limit\n" |
6787 | "Threshold value (%) at which to generate a warning msg\n" | |
6788 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6789 | "Restart interval in minutes\n") |
0a486e5f | 6790 | { |
d62a17ae | 6791 | int idx_peer = 1; |
6792 | int idx_number = 3; | |
6793 | int idx_number_2 = 4; | |
6794 | int idx_number_3 = 6; | |
6795 | return peer_maximum_prefix_set_vty( | |
6796 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6797 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6798 | argv[idx_number_3]->arg); | |
6799 | } | |
6800 | ||
6801 | ALIAS_HIDDEN( | |
6802 | neighbor_maximum_prefix_threshold_restart, | |
6803 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6804 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6805 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6806 | "Maximum number of prefixes to accept from this peer\n" | |
6807 | "maximum no. of prefix limit\n" | |
6808 | "Threshold value (%) at which to generate a warning msg\n" | |
6809 | "Restart bgp connection after limit is exceeded\n" | |
6810 | "Restart interval in minutes\n") | |
596c17ba | 6811 | |
718e3744 | 6812 | DEFUN (no_neighbor_maximum_prefix, |
6813 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6815 | NO_STR |
6816 | NEIGHBOR_STR | |
6817 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6818 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6819 | "maximum no. of prefix limit\n" |
6820 | "Threshold value (%) at which to generate a warning msg\n" | |
6821 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6822 | "Restart interval in minutes\n" |
31500417 | 6823 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6824 | { |
d62a17ae | 6825 | int idx_peer = 2; |
6826 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6827 | bgp_node_afi(vty), | |
6828 | bgp_node_safi(vty)); | |
718e3744 | 6829 | } |
e52702f2 | 6830 | |
d62a17ae | 6831 | ALIAS_HIDDEN( |
6832 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6833 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6834 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6835 | "Maximum number of prefixes to accept from this peer\n" | |
6836 | "maximum no. of prefix limit\n" | |
6837 | "Threshold value (%) at which to generate a warning msg\n" | |
6838 | "Restart bgp connection after limit is exceeded\n" | |
6839 | "Restart interval in minutes\n" | |
6840 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6841 | |
718e3744 | 6842 | |
718e3744 | 6843 | /* "neighbor allowas-in" */ |
6844 | DEFUN (neighbor_allowas_in, | |
6845 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6846 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6847 | NEIGHBOR_STR |
6848 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6849 | "Accept as-path with my AS present in it\n" |
f79f7a7b | 6850 | "Number of occurrences of AS number\n" |
fd8503f5 | 6851 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6852 | { |
d62a17ae | 6853 | int idx_peer = 1; |
6854 | int idx_number_origin = 3; | |
6855 | int ret; | |
6856 | int origin = 0; | |
6857 | struct peer *peer; | |
6858 | int allow_num = 0; | |
6859 | ||
6860 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6861 | if (!peer) | |
6862 | return CMD_WARNING_CONFIG_FAILED; | |
6863 | ||
6864 | if (argc <= idx_number_origin) | |
6865 | allow_num = 3; | |
6866 | else { | |
6867 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6868 | origin = 1; | |
6869 | else | |
6870 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6871 | } | |
6872 | ||
6873 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6874 | allow_num, origin); | |
6875 | ||
6876 | return bgp_vty_return(vty, ret); | |
6877 | } | |
6878 | ||
6879 | ALIAS_HIDDEN( | |
6880 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6881 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6882 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6883 | "Accept as-path with my AS present in it\n" | |
f79f7a7b | 6884 | "Number of occurrences of AS number\n" |
d62a17ae | 6885 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6886 | |
718e3744 | 6887 | DEFUN (no_neighbor_allowas_in, |
6888 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6889 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6890 | NO_STR |
6891 | NEIGHBOR_STR | |
6892 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6893 | "allow local ASN appears in aspath attribute\n" |
f79f7a7b | 6894 | "Number of occurrences of AS number\n" |
fd8503f5 | 6895 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6896 | { |
d62a17ae | 6897 | int idx_peer = 2; |
6898 | int ret; | |
6899 | struct peer *peer; | |
718e3744 | 6900 | |
d62a17ae | 6901 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6902 | if (!peer) | |
6903 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6904 | |
d62a17ae | 6905 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6906 | bgp_node_safi(vty)); | |
718e3744 | 6907 | |
d62a17ae | 6908 | return bgp_vty_return(vty, ret); |
718e3744 | 6909 | } |
6b0655a2 | 6910 | |
d62a17ae | 6911 | ALIAS_HIDDEN( |
6912 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6913 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6914 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6915 | "allow local ASN appears in aspath attribute\n" | |
f79f7a7b | 6916 | "Number of occurrences of AS number\n" |
d62a17ae | 6917 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6918 | |
fa411a21 NH |
6919 | DEFUN (neighbor_ttl_security, |
6920 | neighbor_ttl_security_cmd, | |
7ebe625c | 6921 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6922 | NEIGHBOR_STR |
7ebe625c | 6923 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6924 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6925 | "Specify the maximum number of hops to the BGP peer\n" |
6926 | "Number of hops to BGP peer\n") | |
fa411a21 | 6927 | { |
d62a17ae | 6928 | int idx_peer = 1; |
6929 | int idx_number = 4; | |
6930 | struct peer *peer; | |
6931 | int gtsm_hops; | |
6932 | ||
6933 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6934 | if (!peer) | |
6935 | return CMD_WARNING_CONFIG_FAILED; | |
6936 | ||
6937 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6938 | ||
7ebe625c QY |
6939 | /* |
6940 | * If 'neighbor swpX', then this is for directly connected peers, | |
6941 | * we should not accept a ttl-security hops value greater than 1. | |
6942 | */ | |
e2521429 | 6943 | if (peer->conf_if && (gtsm_hops > BGP_GTSM_HOPS_CONNECTED)) { |
7ebe625c QY |
6944 | vty_out(vty, |
6945 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6946 | argv[idx_peer]->arg); | |
6947 | return CMD_WARNING_CONFIG_FAILED; | |
6948 | } | |
6949 | ||
d62a17ae | 6950 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6951 | } |
6952 | ||
6953 | DEFUN (no_neighbor_ttl_security, | |
6954 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6955 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6956 | NO_STR |
6957 | NEIGHBOR_STR | |
7ebe625c | 6958 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6959 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6960 | "Specify the maximum number of hops to the BGP peer\n" |
6961 | "Number of hops to BGP peer\n") | |
fa411a21 | 6962 | { |
d62a17ae | 6963 | int idx_peer = 2; |
6964 | struct peer *peer; | |
fa411a21 | 6965 | |
d62a17ae | 6966 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6967 | if (!peer) | |
6968 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6969 | |
d62a17ae | 6970 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6971 | } |
6b0655a2 | 6972 | |
adbac85e DW |
6973 | DEFUN (neighbor_addpath_tx_all_paths, |
6974 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6975 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6976 | NEIGHBOR_STR |
6977 | NEIGHBOR_ADDR_STR2 | |
6978 | "Use addpath to advertise all paths to a neighbor\n") | |
6979 | { | |
d62a17ae | 6980 | int idx_peer = 1; |
6981 | struct peer *peer; | |
adbac85e | 6982 | |
d62a17ae | 6983 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6984 | if (!peer) | |
6985 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6986 | |
dcc68b5e MS |
6987 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6988 | BGP_ADDPATH_ALL); | |
6989 | return CMD_SUCCESS; | |
adbac85e DW |
6990 | } |
6991 | ||
d62a17ae | 6992 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6993 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6994 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6995 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6996 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6997 | |
adbac85e DW |
6998 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6999 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 7000 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
7001 | NO_STR |
7002 | NEIGHBOR_STR | |
7003 | NEIGHBOR_ADDR_STR2 | |
7004 | "Use addpath to advertise all paths to a neighbor\n") | |
7005 | { | |
d62a17ae | 7006 | int idx_peer = 2; |
dcc68b5e MS |
7007 | struct peer *peer; |
7008 | ||
7009 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7010 | if (!peer) | |
7011 | return CMD_WARNING_CONFIG_FAILED; | |
7012 | ||
7013 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7014 | != BGP_ADDPATH_ALL) { | |
7015 | vty_out(vty, | |
7016 | "%% Peer not currently configured to transmit all paths."); | |
7017 | return CMD_WARNING_CONFIG_FAILED; | |
7018 | } | |
7019 | ||
7020 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7021 | BGP_ADDPATH_NONE); | |
7022 | ||
7023 | return CMD_SUCCESS; | |
adbac85e DW |
7024 | } |
7025 | ||
d62a17ae | 7026 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
7027 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
7028 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
7029 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7030 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 7031 | |
06370dac DW |
7032 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
7033 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7034 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7035 | NEIGHBOR_STR |
7036 | NEIGHBOR_ADDR_STR2 | |
7037 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7038 | { | |
d62a17ae | 7039 | int idx_peer = 1; |
7040 | struct peer *peer; | |
06370dac | 7041 | |
d62a17ae | 7042 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
7043 | if (!peer) | |
7044 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 7045 | |
dcc68b5e MS |
7046 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
7047 | BGP_ADDPATH_BEST_PER_AS); | |
7048 | ||
7049 | return CMD_SUCCESS; | |
06370dac DW |
7050 | } |
7051 | ||
d62a17ae | 7052 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
7053 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7054 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7055 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7056 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7057 | |
06370dac DW |
7058 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
7059 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 7060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
7061 | NO_STR |
7062 | NEIGHBOR_STR | |
7063 | NEIGHBOR_ADDR_STR2 | |
7064 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
7065 | { | |
d62a17ae | 7066 | int idx_peer = 2; |
dcc68b5e MS |
7067 | struct peer *peer; |
7068 | ||
7069 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
7070 | if (!peer) | |
7071 | return CMD_WARNING_CONFIG_FAILED; | |
7072 | ||
7073 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
7074 | != BGP_ADDPATH_BEST_PER_AS) { | |
7075 | vty_out(vty, | |
7076 | "%% Peer not currently configured to transmit all best path per as."); | |
7077 | return CMD_WARNING_CONFIG_FAILED; | |
7078 | } | |
7079 | ||
7080 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
7081 | BGP_ADDPATH_NONE); | |
7082 | ||
7083 | return CMD_SUCCESS; | |
06370dac DW |
7084 | } |
7085 | ||
d62a17ae | 7086 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
7087 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
7088 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
7089 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
7090 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 7091 | |
2b31007c RZ |
7092 | DEFPY( |
7093 | neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd, | |
7094 | "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7095 | NEIGHBOR_STR | |
7096 | NEIGHBOR_ADDR_STR2 | |
7097 | "Detect AS loops before sending to neighbor\n") | |
7098 | { | |
7099 | struct peer *peer; | |
7100 | ||
7101 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7102 | if (!peer) | |
7103 | return CMD_WARNING_CONFIG_FAILED; | |
7104 | ||
7105 | peer->as_path_loop_detection = true; | |
7106 | ||
7107 | return CMD_SUCCESS; | |
7108 | } | |
7109 | ||
7110 | DEFPY( | |
7111 | no_neighbor_aspath_loop_detection, | |
7112 | no_neighbor_aspath_loop_detection_cmd, | |
7113 | "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection", | |
7114 | NO_STR | |
7115 | NEIGHBOR_STR | |
7116 | NEIGHBOR_ADDR_STR2 | |
7117 | "Detect AS loops before sending to neighbor\n") | |
7118 | { | |
7119 | struct peer *peer; | |
7120 | ||
7121 | peer = peer_and_group_lookup_vty(vty, neighbor); | |
7122 | if (!peer) | |
7123 | return CMD_WARNING_CONFIG_FAILED; | |
7124 | ||
7125 | peer->as_path_loop_detection = false; | |
7126 | ||
7127 | return CMD_SUCCESS; | |
7128 | } | |
7129 | ||
b9c7bc5a PZ |
7130 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
7131 | struct ecommunity **list) | |
ddb5b488 | 7132 | { |
b9c7bc5a PZ |
7133 | struct ecommunity *ecom = NULL; |
7134 | struct ecommunity *ecomadd; | |
ddb5b488 | 7135 | |
b9c7bc5a | 7136 | for (; argc; --argc, ++argv) { |
ddb5b488 | 7137 | |
b9c7bc5a PZ |
7138 | ecomadd = ecommunity_str2com(argv[0]->arg, |
7139 | ECOMMUNITY_ROUTE_TARGET, 0); | |
7140 | if (!ecomadd) { | |
7141 | vty_out(vty, "Malformed community-list value\n"); | |
7142 | if (ecom) | |
7143 | ecommunity_free(&ecom); | |
7144 | return CMD_WARNING_CONFIG_FAILED; | |
7145 | } | |
ddb5b488 | 7146 | |
b9c7bc5a PZ |
7147 | if (ecom) { |
7148 | ecommunity_merge(ecom, ecomadd); | |
7149 | ecommunity_free(&ecomadd); | |
7150 | } else { | |
7151 | ecom = ecomadd; | |
7152 | } | |
7153 | } | |
7154 | ||
7155 | if (*list) { | |
7156 | ecommunity_free(&*list); | |
ddb5b488 | 7157 | } |
b9c7bc5a PZ |
7158 | *list = ecom; |
7159 | ||
7160 | return CMD_SUCCESS; | |
ddb5b488 PZ |
7161 | } |
7162 | ||
0ca70ba5 DS |
7163 | /* |
7164 | * v2vimport is true if we are handling a `import vrf ...` command | |
7165 | */ | |
7166 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 7167 | { |
0ca70ba5 DS |
7168 | afi_t afi; |
7169 | ||
ddb5b488 | 7170 | switch (vty->node) { |
b9c7bc5a | 7171 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
7172 | afi = AFI_IP; |
7173 | break; | |
b9c7bc5a | 7174 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
7175 | afi = AFI_IP6; |
7176 | break; | |
ddb5b488 PZ |
7177 | default: |
7178 | vty_out(vty, | |
b9c7bc5a | 7179 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 7180 | return AFI_MAX; |
ddb5b488 | 7181 | } |
69b07479 | 7182 | |
0ca70ba5 DS |
7183 | if (!v2vimport) { |
7184 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7185 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
7186 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7187 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
7188 | vty_out(vty, | |
7189 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
7190 | return AFI_MAX; | |
7191 | } | |
7192 | } else { | |
7193 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7194 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
7195 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7196 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
7197 | vty_out(vty, | |
7198 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
7199 | return AFI_MAX; | |
7200 | } | |
7201 | } | |
7202 | return afi; | |
ddb5b488 PZ |
7203 | } |
7204 | ||
b9c7bc5a PZ |
7205 | DEFPY (af_rd_vpn_export, |
7206 | af_rd_vpn_export_cmd, | |
7207 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
7208 | NO_STR | |
ddb5b488 | 7209 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
7210 | "Between current address-family and vpn\n" |
7211 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7212 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
7213 | { | |
7214 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7215 | struct prefix_rd prd; | |
7216 | int ret; | |
ddb5b488 | 7217 | afi_t afi; |
b9c7bc5a PZ |
7218 | int idx = 0; |
7219 | int yes = 1; | |
ddb5b488 | 7220 | |
b9c7bc5a | 7221 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7222 | yes = 0; |
b9c7bc5a PZ |
7223 | |
7224 | if (yes) { | |
7225 | ret = str2prefix_rd(rd_str, &prd); | |
7226 | if (!ret) { | |
7227 | vty_out(vty, "%% Malformed rd\n"); | |
7228 | return CMD_WARNING_CONFIG_FAILED; | |
7229 | } | |
ddb5b488 PZ |
7230 | } |
7231 | ||
0ca70ba5 | 7232 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7233 | if (afi == AFI_MAX) |
7234 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7235 | |
69b07479 DS |
7236 | /* |
7237 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7238 | */ | |
7239 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7240 | bgp_get_default(), bgp); | |
ddb5b488 | 7241 | |
69b07479 DS |
7242 | if (yes) { |
7243 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
7244 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7245 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
7246 | } else { | |
7247 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7248 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
7249 | } |
7250 | ||
69b07479 DS |
7251 | /* post-change: re-export vpn routes */ |
7252 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7253 | bgp_get_default(), bgp); | |
7254 | ||
ddb5b488 PZ |
7255 | return CMD_SUCCESS; |
7256 | } | |
7257 | ||
b9c7bc5a PZ |
7258 | ALIAS (af_rd_vpn_export, |
7259 | af_no_rd_vpn_export_cmd, | |
7260 | "no rd vpn export", | |
ddb5b488 | 7261 | NO_STR |
b9c7bc5a PZ |
7262 | "Specify route distinguisher\n" |
7263 | "Between current address-family and vpn\n" | |
7264 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7265 | |
b9c7bc5a PZ |
7266 | DEFPY (af_label_vpn_export, |
7267 | af_label_vpn_export_cmd, | |
e70e9f8e | 7268 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 7269 | NO_STR |
ddb5b488 | 7270 | "label value for VRF\n" |
b9c7bc5a PZ |
7271 | "Between current address-family and vpn\n" |
7272 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
7273 | "Label Value <0-1048575>\n" |
7274 | "Automatically assign a label\n") | |
ddb5b488 PZ |
7275 | { |
7276 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7277 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 7278 | afi_t afi; |
b9c7bc5a PZ |
7279 | int idx = 0; |
7280 | int yes = 1; | |
7281 | ||
7282 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 7283 | yes = 0; |
ddb5b488 | 7284 | |
21a16cc2 PZ |
7285 | /* If "no ...", squash trailing parameter */ |
7286 | if (!yes) | |
7287 | label_auto = NULL; | |
7288 | ||
e70e9f8e PZ |
7289 | if (yes) { |
7290 | if (!label_auto) | |
7291 | label = label_val; /* parser should force unsigned */ | |
7292 | } | |
ddb5b488 | 7293 | |
0ca70ba5 | 7294 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7295 | if (afi == AFI_MAX) |
7296 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 7297 | |
e70e9f8e | 7298 | |
69b07479 DS |
7299 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
7300 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
7301 | /* no change */ | |
7302 | return CMD_SUCCESS; | |
e70e9f8e | 7303 | |
69b07479 DS |
7304 | /* |
7305 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7306 | */ | |
7307 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7308 | bgp_get_default(), bgp); | |
7309 | ||
7310 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
7311 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
7312 | ||
7313 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
7314 | ||
7315 | /* | |
7316 | * label has previously been automatically | |
7317 | * assigned by labelpool: release it | |
7318 | * | |
7319 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
7320 | * means the automatic assignment is in flight | |
7321 | * and therefore the labelpool callback must | |
7322 | * detect that the auto label is not needed. | |
7323 | */ | |
7324 | ||
7325 | bgp_lp_release(LP_TYPE_VRF, | |
7326 | &bgp->vpn_policy[afi], | |
7327 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 7328 | } |
69b07479 DS |
7329 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
7330 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7331 | } | |
ddb5b488 | 7332 | |
69b07479 DS |
7333 | bgp->vpn_policy[afi].tovpn_label = label; |
7334 | if (label_auto) { | |
7335 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7336 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
7337 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
7338 | vpn_leak_label_callback); | |
ddb5b488 PZ |
7339 | } |
7340 | ||
69b07479 DS |
7341 | /* post-change: re-export vpn routes */ |
7342 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7343 | bgp_get_default(), bgp); | |
7344 | ||
ddb5b488 PZ |
7345 | return CMD_SUCCESS; |
7346 | } | |
7347 | ||
b9c7bc5a PZ |
7348 | ALIAS (af_label_vpn_export, |
7349 | af_no_label_vpn_export_cmd, | |
7350 | "no label vpn export", | |
7351 | NO_STR | |
7352 | "label value for VRF\n" | |
7353 | "Between current address-family and vpn\n" | |
7354 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 7355 | |
b9c7bc5a PZ |
7356 | DEFPY (af_nexthop_vpn_export, |
7357 | af_nexthop_vpn_export_cmd, | |
8c85ca28 | 7358 | "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]", |
b9c7bc5a | 7359 | NO_STR |
ddb5b488 | 7360 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
7361 | "Between current address-family and vpn\n" |
7362 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7363 | "IPv4 prefix\n" |
7364 | "IPv6 prefix\n") | |
7365 | { | |
7366 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 7367 | afi_t afi; |
ddb5b488 PZ |
7368 | struct prefix p; |
7369 | ||
8c85ca28 QY |
7370 | if (!no) { |
7371 | if (!nexthop_su) { | |
7372 | vty_out(vty, "%% Nexthop required\n"); | |
7373 | return CMD_WARNING_CONFIG_FAILED; | |
7374 | } | |
b9c7bc5a | 7375 | |
8c85ca28 | 7376 | if (!sockunion2hostprefix(nexthop_su, &p)) |
b9c7bc5a PZ |
7377 | return CMD_WARNING_CONFIG_FAILED; |
7378 | } | |
ddb5b488 | 7379 | |
0ca70ba5 | 7380 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7381 | if (afi == AFI_MAX) |
7382 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7383 | |
69b07479 DS |
7384 | /* |
7385 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
7386 | */ | |
7387 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7388 | bgp_get_default(), bgp); | |
ddb5b488 | 7389 | |
8c85ca28 | 7390 | if (!no) { |
69b07479 DS |
7391 | bgp->vpn_policy[afi].tovpn_nexthop = p; |
7392 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
7393 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
7394 | } else { | |
7395 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
7396 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
7397 | } |
7398 | ||
69b07479 DS |
7399 | /* post-change: re-export vpn routes */ |
7400 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
7401 | bgp_get_default(), bgp); | |
7402 | ||
ddb5b488 PZ |
7403 | return CMD_SUCCESS; |
7404 | } | |
7405 | ||
b9c7bc5a | 7406 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 7407 | { |
b9c7bc5a PZ |
7408 | if (!strcmp(dstr, "import")) { |
7409 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7410 | } else if (!strcmp(dstr, "export")) { | |
7411 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7412 | } else if (!strcmp(dstr, "both")) { | |
7413 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
7414 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
7415 | } else { | |
7416 | vty_out(vty, "%% direction parse error\n"); | |
7417 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7418 | } |
ddb5b488 PZ |
7419 | return CMD_SUCCESS; |
7420 | } | |
7421 | ||
b9c7bc5a PZ |
7422 | DEFPY (af_rt_vpn_imexport, |
7423 | af_rt_vpn_imexport_cmd, | |
7424 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
7425 | NO_STR | |
7426 | "Specify route target list\n" | |
ddb5b488 | 7427 | "Specify route target list\n" |
b9c7bc5a PZ |
7428 | "Between current address-family and vpn\n" |
7429 | "For routes leaked from vpn to current address-family: match any\n" | |
7430 | "For routes leaked from current address-family to vpn: set\n" | |
7431 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
7432 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
7433 | { | |
7434 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7435 | int ret; | |
7436 | struct ecommunity *ecom = NULL; | |
7437 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7438 | vpn_policy_direction_t dir; |
7439 | afi_t afi; | |
7440 | int idx = 0; | |
b9c7bc5a | 7441 | int yes = 1; |
ddb5b488 | 7442 | |
b9c7bc5a | 7443 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7444 | yes = 0; |
b9c7bc5a | 7445 | |
0ca70ba5 | 7446 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7447 | if (afi == AFI_MAX) |
7448 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7449 | |
b9c7bc5a | 7450 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7451 | if (ret != CMD_SUCCESS) |
7452 | return ret; | |
7453 | ||
b9c7bc5a PZ |
7454 | if (yes) { |
7455 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7456 | vty_out(vty, "%% Missing RTLIST\n"); | |
7457 | return CMD_WARNING_CONFIG_FAILED; | |
7458 | } | |
7459 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7460 | if (ret != CMD_SUCCESS) { | |
7461 | return ret; | |
7462 | } | |
ddb5b488 PZ |
7463 | } |
7464 | ||
69b07479 DS |
7465 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7466 | if (!dodir[dir]) | |
ddb5b488 | 7467 | continue; |
ddb5b488 | 7468 | |
69b07479 | 7469 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7470 | |
69b07479 DS |
7471 | if (yes) { |
7472 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7473 | ecommunity_free( | |
7474 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7475 | bgp->vpn_policy[afi].rtlist[dir] = | |
7476 | ecommunity_dup(ecom); | |
7477 | } else { | |
7478 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
7479 | ecommunity_free( | |
7480 | &bgp->vpn_policy[afi].rtlist[dir]); | |
7481 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 7482 | } |
69b07479 DS |
7483 | |
7484 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 7485 | } |
69b07479 | 7486 | |
d555f3e9 PZ |
7487 | if (ecom) |
7488 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
7489 | |
7490 | return CMD_SUCCESS; | |
7491 | } | |
7492 | ||
b9c7bc5a PZ |
7493 | ALIAS (af_rt_vpn_imexport, |
7494 | af_no_rt_vpn_imexport_cmd, | |
7495 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
7496 | NO_STR |
7497 | "Specify route target list\n" | |
b9c7bc5a PZ |
7498 | "Specify route target list\n" |
7499 | "Between current address-family and vpn\n" | |
7500 | "For routes leaked from vpn to current address-family\n" | |
7501 | "For routes leaked from current address-family to vpn\n" | |
7502 | "both import and export\n") | |
7503 | ||
7504 | DEFPY (af_route_map_vpn_imexport, | |
7505 | af_route_map_vpn_imexport_cmd, | |
7506 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
7507 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
7508 | NO_STR | |
ddb5b488 | 7509 | "Specify route map\n" |
b9c7bc5a PZ |
7510 | "Between current address-family and vpn\n" |
7511 | "For routes leaked from vpn to current address-family\n" | |
7512 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
7513 | "name of route-map\n") |
7514 | { | |
7515 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7516 | int ret; | |
7517 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
7518 | vpn_policy_direction_t dir; |
7519 | afi_t afi; | |
ddb5b488 | 7520 | int idx = 0; |
b9c7bc5a | 7521 | int yes = 1; |
ddb5b488 | 7522 | |
b9c7bc5a | 7523 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7524 | yes = 0; |
b9c7bc5a | 7525 | |
0ca70ba5 | 7526 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7527 | if (afi == AFI_MAX) |
7528 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 7529 | |
b9c7bc5a | 7530 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
7531 | if (ret != CMD_SUCCESS) |
7532 | return ret; | |
7533 | ||
69b07479 DS |
7534 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
7535 | if (!dodir[dir]) | |
ddb5b488 | 7536 | continue; |
ddb5b488 | 7537 | |
69b07479 | 7538 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 7539 | |
69b07479 DS |
7540 | if (yes) { |
7541 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7542 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7543 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7544 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
7545 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7546 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 7547 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
7548 | if (!bgp->vpn_policy[afi].rmap[dir]) |
7549 | return CMD_SUCCESS; | |
7550 | } else { | |
7551 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7552 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7553 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7554 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7555 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 7556 | } |
69b07479 DS |
7557 | |
7558 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
7559 | } |
7560 | ||
7561 | return CMD_SUCCESS; | |
7562 | } | |
7563 | ||
b9c7bc5a PZ |
7564 | ALIAS (af_route_map_vpn_imexport, |
7565 | af_no_route_map_vpn_imexport_cmd, | |
7566 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
7567 | NO_STR |
7568 | "Specify route map\n" | |
b9c7bc5a PZ |
7569 | "Between current address-family and vpn\n" |
7570 | "For routes leaked from vpn to current address-family\n" | |
7571 | "For routes leaked from current address-family to vpn\n") | |
7572 | ||
bb4f6190 | 7573 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
ae6a6fb4 | 7574 | "import vrf route-map RMAP$rmap_str", |
bb4f6190 DS |
7575 | "Import routes from another VRF\n" |
7576 | "Vrf routes being filtered\n" | |
7577 | "Specify route map\n" | |
7578 | "name of route-map\n") | |
7579 | { | |
7580 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
7581 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
7582 | afi_t afi; | |
bb4f6190 DS |
7583 | struct bgp *bgp_default; |
7584 | ||
0ca70ba5 | 7585 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
7586 | if (afi == AFI_MAX) |
7587 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
7588 | |
7589 | bgp_default = bgp_get_default(); | |
7590 | if (!bgp_default) { | |
7591 | int32_t ret; | |
7592 | as_t as = bgp->as; | |
7593 | ||
7594 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7595 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7596 | BGP_INSTANCE_TYPE_DEFAULT); | |
bb4f6190 DS |
7597 | |
7598 | if (ret) { | |
7599 | vty_out(vty, | |
7600 | "VRF default is not configured as a bgp instance\n"); | |
7601 | return CMD_WARNING; | |
7602 | } | |
7603 | } | |
7604 | ||
69b07479 | 7605 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 7606 | |
ae6a6fb4 DS |
7607 | if (bgp->vpn_policy[afi].rmap_name[dir]) |
7608 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7609 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7610 | bgp->vpn_policy[afi].rmap_name[dir] = | |
7611 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
7612 | bgp->vpn_policy[afi].rmap[dir] = | |
7613 | route_map_lookup_warn_noexist(vty, rmap_str); | |
7614 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
7615 | return CMD_SUCCESS; | |
7616 | ||
7617 | SET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7618 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
bb4f6190 | 7619 | |
69b07479 DS |
7620 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7621 | ||
bb4f6190 DS |
7622 | return CMD_SUCCESS; |
7623 | } | |
7624 | ||
ae6a6fb4 DS |
7625 | DEFPY(af_no_import_vrf_route_map, af_no_import_vrf_route_map_cmd, |
7626 | "no import vrf route-map [RMAP$rmap_str]", | |
bb4f6190 DS |
7627 | NO_STR |
7628 | "Import routes from another VRF\n" | |
7629 | "Vrf routes being filtered\n" | |
ae6a6fb4 DS |
7630 | "Specify route map\n" |
7631 | "name of route-map\n") | |
7632 | { | |
7633 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7634 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7635 | afi_t afi; | |
7636 | ||
7637 | afi = vpn_policy_getafi(vty, bgp, true); | |
7638 | if (afi == AFI_MAX) | |
7639 | return CMD_WARNING_CONFIG_FAILED; | |
7640 | ||
7641 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7642 | ||
7643 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
7644 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
7645 | bgp->vpn_policy[afi].rmap_name[dir]); | |
7646 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
7647 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
7648 | ||
7649 | if (bgp->vpn_policy[afi].import_vrf->count == 0) | |
7650 | UNSET_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
7651 | BGP_CONFIG_VRF_TO_VRF_IMPORT); | |
7652 | ||
7653 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
7654 | ||
7655 | return CMD_SUCCESS; | |
7656 | } | |
bb4f6190 | 7657 | |
4d1b335c DA |
7658 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
7659 | "[no] import vrf VIEWVRFNAME$import_name", | |
7660 | NO_STR | |
7661 | "Import routes from another VRF\n" | |
7662 | "VRF to import from\n" | |
7663 | "The name of the VRF\n") | |
12a844a5 DS |
7664 | { |
7665 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7666 | struct listnode *node; | |
79ef8664 DS |
7667 | struct bgp *vrf_bgp, *bgp_default; |
7668 | int32_t ret = 0; | |
7669 | as_t as = bgp->as; | |
12a844a5 DS |
7670 | bool remove = false; |
7671 | int32_t idx = 0; | |
7672 | char *vname; | |
a8dadcf6 | 7673 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
7674 | safi_t safi; |
7675 | afi_t afi; | |
7676 | ||
867f0cca | 7677 | if (import_name == NULL) { |
7678 | vty_out(vty, "%% Missing import name\n"); | |
7679 | return CMD_WARNING; | |
7680 | } | |
7681 | ||
ae6a6fb4 DS |
7682 | if (strcmp(import_name, "route-map") == 0) { |
7683 | vty_out(vty, "%% Must include route-map name\n"); | |
7684 | return CMD_WARNING; | |
7685 | } | |
7686 | ||
12a844a5 DS |
7687 | if (argv_find(argv, argc, "no", &idx)) |
7688 | remove = true; | |
7689 | ||
0ca70ba5 DS |
7690 | afi = vpn_policy_getafi(vty, bgp, true); |
7691 | if (afi == AFI_MAX) | |
7692 | return CMD_WARNING_CONFIG_FAILED; | |
7693 | ||
12a844a5 DS |
7694 | safi = bgp_node_safi(vty); |
7695 | ||
25679caa | 7696 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 7697 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
7698 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
7699 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
7700 | remove ? "unimport" : "import", import_name); | |
7701 | return CMD_WARNING; | |
7702 | } | |
7703 | ||
79ef8664 DS |
7704 | bgp_default = bgp_get_default(); |
7705 | if (!bgp_default) { | |
7706 | /* Auto-create assuming the same AS */ | |
5d5393b9 DL |
7707 | ret = bgp_get_vty(&bgp_default, &as, NULL, |
7708 | BGP_INSTANCE_TYPE_DEFAULT); | |
79ef8664 DS |
7709 | |
7710 | if (ret) { | |
7711 | vty_out(vty, | |
7712 | "VRF default is not configured as a bgp instance\n"); | |
7713 | return CMD_WARNING; | |
7714 | } | |
7715 | } | |
7716 | ||
12a844a5 DS |
7717 | vrf_bgp = bgp_lookup_by_name(import_name); |
7718 | if (!vrf_bgp) { | |
5742e42b | 7719 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
7720 | vrf_bgp = bgp_default; |
7721 | else | |
0fb8d6e6 | 7722 | /* Auto-create assuming the same AS */ |
5d5393b9 | 7723 | ret = bgp_get_vty(&vrf_bgp, &as, import_name, bgp_type); |
a8dadcf6 | 7724 | |
6e2c7fe6 | 7725 | if (ret) { |
020a3f60 DS |
7726 | vty_out(vty, |
7727 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
7728 | import_name); |
7729 | return CMD_WARNING; | |
7730 | } | |
12a844a5 DS |
7731 | } |
7732 | ||
12a844a5 | 7733 | if (remove) { |
44338987 | 7734 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 7735 | } else { |
44338987 | 7736 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
7737 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
7738 | vname)) { | |
7739 | if (strcmp(vname, import_name) == 0) | |
7740 | return CMD_WARNING; | |
7741 | } | |
7742 | ||
44338987 | 7743 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
7744 | } |
7745 | ||
7746 | return CMD_SUCCESS; | |
7747 | } | |
7748 | ||
b9c7bc5a PZ |
7749 | /* This command is valid only in a bgp vrf instance or the default instance */ |
7750 | DEFPY (bgp_imexport_vpn, | |
7751 | bgp_imexport_vpn_cmd, | |
7752 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7753 | NO_STR |
7754 | "Import routes to this address-family\n" | |
7755 | "Export routes from this address-family\n" | |
7756 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7757 | { |
7758 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7759 | int previous_state; |
ddb5b488 | 7760 | afi_t afi; |
b9c7bc5a | 7761 | safi_t safi; |
ddb5b488 | 7762 | int idx = 0; |
b9c7bc5a PZ |
7763 | int yes = 1; |
7764 | int flag; | |
7765 | vpn_policy_direction_t dir; | |
ddb5b488 | 7766 | |
b9c7bc5a | 7767 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7768 | yes = 0; |
ddb5b488 | 7769 | |
b9c7bc5a PZ |
7770 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7771 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7772 | |
b9c7bc5a PZ |
7773 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7774 | return CMD_WARNING_CONFIG_FAILED; | |
7775 | } | |
ddb5b488 | 7776 | |
b9c7bc5a PZ |
7777 | afi = bgp_node_afi(vty); |
7778 | safi = bgp_node_safi(vty); | |
7779 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7780 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7781 | return CMD_WARNING_CONFIG_FAILED; | |
7782 | } | |
ddb5b488 | 7783 | |
b9c7bc5a PZ |
7784 | if (!strcmp(direction_str, "import")) { |
7785 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7786 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7787 | } else if (!strcmp(direction_str, "export")) { | |
7788 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7789 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7790 | } else { | |
7791 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7792 | return CMD_WARNING_CONFIG_FAILED; | |
7793 | } | |
7794 | ||
7795 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7796 | |
b9c7bc5a PZ |
7797 | if (yes) { |
7798 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7799 | if (!previous_state) { | |
7800 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7801 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7802 | } | |
b9c7bc5a PZ |
7803 | } else { |
7804 | if (previous_state) { | |
7805 | /* trigger un-export current vrf */ | |
7806 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7807 | } | |
7808 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7809 | } |
7810 | ||
7811 | return CMD_SUCCESS; | |
7812 | } | |
7813 | ||
301ad80a PG |
7814 | DEFPY (af_routetarget_import, |
7815 | af_routetarget_import_cmd, | |
7816 | "[no] <rt|route-target> redirect import RTLIST...", | |
7817 | NO_STR | |
7818 | "Specify route target list\n" | |
7819 | "Specify route target list\n" | |
7820 | "Flow-spec redirect type route target\n" | |
7821 | "Import routes to this address-family\n" | |
7822 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7823 | { | |
7824 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7825 | int ret; | |
7826 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7827 | afi_t afi; |
7828 | int idx = 0; | |
7829 | int yes = 1; | |
7830 | ||
7831 | if (argv_find(argv, argc, "no", &idx)) | |
7832 | yes = 0; | |
7833 | ||
0ca70ba5 | 7834 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7835 | if (afi == AFI_MAX) |
7836 | return CMD_WARNING_CONFIG_FAILED; | |
7837 | ||
301ad80a PG |
7838 | if (yes) { |
7839 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7840 | vty_out(vty, "%% Missing RTLIST\n"); | |
7841 | return CMD_WARNING_CONFIG_FAILED; | |
7842 | } | |
7843 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7844 | if (ret != CMD_SUCCESS) | |
7845 | return ret; | |
7846 | } | |
69b07479 DS |
7847 | |
7848 | if (yes) { | |
7849 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7850 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7851 | .import_redirect_rtlist); |
69b07479 DS |
7852 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7853 | ecommunity_dup(ecom); | |
7854 | } else { | |
7855 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7856 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7857 | .import_redirect_rtlist); |
69b07479 | 7858 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7859 | } |
69b07479 | 7860 | |
301ad80a PG |
7861 | if (ecom) |
7862 | ecommunity_free(&ecom); | |
7863 | ||
7864 | return CMD_SUCCESS; | |
7865 | } | |
7866 | ||
505e5056 | 7867 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7868 | address_family_ipv4_safi_cmd, |
7869 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7870 | "Enter Address Family command mode\n" | |
7871 | "Address Family\n" | |
7872 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7873 | { |
f51bae9c | 7874 | |
d62a17ae | 7875 | if (argc == 3) { |
2131d5cf | 7876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7877 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7878 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7879 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7880 | && safi != SAFI_EVPN) { |
31947174 MK |
7881 | vty_out(vty, |
7882 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7883 | return CMD_WARNING_CONFIG_FAILED; |
7884 | } | |
d62a17ae | 7885 | vty->node = bgp_node_type(AFI_IP, safi); |
7886 | } else | |
7887 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7888 | |
d62a17ae | 7889 | return CMD_SUCCESS; |
718e3744 | 7890 | } |
7891 | ||
505e5056 | 7892 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7893 | address_family_ipv6_safi_cmd, |
7894 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7895 | "Enter Address Family command mode\n" | |
7896 | "Address Family\n" | |
7897 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7898 | { |
d62a17ae | 7899 | if (argc == 3) { |
2131d5cf | 7900 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7901 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7902 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7903 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7904 | && safi != SAFI_EVPN) { |
31947174 MK |
7905 | vty_out(vty, |
7906 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7907 | return CMD_WARNING_CONFIG_FAILED; |
7908 | } | |
d62a17ae | 7909 | vty->node = bgp_node_type(AFI_IP6, safi); |
7910 | } else | |
7911 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7912 | |
d62a17ae | 7913 | return CMD_SUCCESS; |
25ffbdc1 | 7914 | } |
718e3744 | 7915 | |
d6902373 | 7916 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7917 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7918 | address_family_vpnv4_cmd, |
8334fd5a | 7919 | "address-family vpnv4 [unicast]", |
718e3744 | 7920 | "Enter Address Family command mode\n" |
8c3deaae | 7921 | "Address Family\n" |
3a2d747c | 7922 | "Address Family modifier\n") |
718e3744 | 7923 | { |
d62a17ae | 7924 | vty->node = BGP_VPNV4_NODE; |
7925 | return CMD_SUCCESS; | |
718e3744 | 7926 | } |
7927 | ||
505e5056 | 7928 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7929 | address_family_vpnv6_cmd, |
8334fd5a | 7930 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7931 | "Enter Address Family command mode\n" |
8c3deaae | 7932 | "Address Family\n" |
3a2d747c | 7933 | "Address Family modifier\n") |
8ecd3266 | 7934 | { |
d62a17ae | 7935 | vty->node = BGP_VPNV6_NODE; |
7936 | return CMD_SUCCESS; | |
8ecd3266 | 7937 | } |
64e4a6c5 | 7938 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7939 | |
505e5056 | 7940 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7941 | address_family_evpn_cmd, |
7111c1a0 | 7942 | "address-family l2vpn evpn", |
4e0b7b6d | 7943 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7944 | "Address Family\n" |
7945 | "Address Family modifier\n") | |
4e0b7b6d | 7946 | { |
2131d5cf | 7947 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7948 | vty->node = BGP_EVPN_NODE; |
7949 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7950 | } |
7951 | ||
505e5056 | 7952 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7953 | exit_address_family_cmd, |
7954 | "exit-address-family", | |
7955 | "Exit from Address Family configuration mode\n") | |
7956 | { | |
d62a17ae | 7957 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7958 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7959 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7960 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7961 | || vty->node == BGP_EVPN_NODE |
7962 | || vty->node == BGP_FLOWSPECV4_NODE | |
7963 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7964 | vty->node = BGP_NODE; |
7965 | return CMD_SUCCESS; | |
718e3744 | 7966 | } |
6b0655a2 | 7967 | |
8ad7271d | 7968 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7969 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7970 | const char *ip_str, afi_t afi, safi_t safi, | |
7971 | struct prefix_rd *prd) | |
7972 | { | |
7973 | int ret; | |
7974 | struct prefix match; | |
7975 | struct bgp_node *rn; | |
7976 | struct bgp_node *rm; | |
7977 | struct bgp *bgp; | |
7978 | struct bgp_table *table; | |
7979 | struct bgp_table *rib; | |
7980 | ||
7981 | /* BGP structure lookup. */ | |
7982 | if (view_name) { | |
7983 | bgp = bgp_lookup_by_name(view_name); | |
7984 | if (bgp == NULL) { | |
7985 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7986 | view_name); | |
7987 | return CMD_WARNING; | |
7988 | } | |
7989 | } else { | |
7990 | bgp = bgp_get_default(); | |
7991 | if (bgp == NULL) { | |
7992 | vty_out(vty, "%% No BGP process is configured\n"); | |
7993 | return CMD_WARNING; | |
7994 | } | |
7995 | } | |
7996 | ||
7997 | /* Check IP address argument. */ | |
7998 | ret = str2prefix(ip_str, &match); | |
7999 | if (!ret) { | |
8000 | vty_out(vty, "%% address is malformed\n"); | |
8001 | return CMD_WARNING; | |
8002 | } | |
8003 | ||
8004 | match.family = afi2family(afi); | |
8005 | rib = bgp->rib[afi][safi]; | |
8006 | ||
8007 | if (safi == SAFI_MPLS_VPN) { | |
8008 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
b54892e0 DS |
8009 | const struct prefix *rn_p = bgp_node_get_prefix(rn); |
8010 | ||
8011 | if (prd && memcmp(rn_p->u.val, prd->val, 8) != 0) | |
d62a17ae | 8012 | continue; |
8013 | ||
67009e22 | 8014 | table = bgp_node_get_bgp_table_info(rn); |
b54892e0 DS |
8015 | if (table == NULL) |
8016 | continue; | |
8017 | ||
8018 | if ((rm = bgp_node_match(table, &match)) != NULL) { | |
8019 | const struct prefix *rm_p = | |
8020 | bgp_node_get_prefix(rm); | |
8021 | ||
8022 | if (rm_p->prefixlen == match.prefixlen) { | |
8023 | SET_FLAG(rm->flags, | |
8024 | BGP_NODE_USER_CLEAR); | |
8025 | bgp_process(bgp, rm, afi, safi); | |
d62a17ae | 8026 | } |
b54892e0 | 8027 | bgp_unlock_node(rm); |
d62a17ae | 8028 | } |
8029 | } | |
8030 | } else { | |
8031 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
b54892e0 DS |
8032 | const struct prefix *rn_p = bgp_node_get_prefix(rn); |
8033 | ||
8034 | if (rn_p->prefixlen == match.prefixlen) { | |
d62a17ae | 8035 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); |
8036 | bgp_process(bgp, rn, afi, safi); | |
8037 | } | |
8038 | bgp_unlock_node(rn); | |
8039 | } | |
8040 | } | |
8041 | ||
8042 | return CMD_SUCCESS; | |
8ad7271d DS |
8043 | } |
8044 | ||
b09b5ae0 | 8045 | /* one clear bgp command to rule them all */ |
718e3744 | 8046 | DEFUN (clear_ip_bgp_all, |
8047 | clear_ip_bgp_all_cmd, | |
453c92f6 | 8048 | "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 | 8049 | CLEAR_STR |
8050 | IP_STR | |
8051 | BGP_STR | |
838758ac | 8052 | BGP_INSTANCE_HELP_STR |
510afcd6 | 8053 | BGP_AFI_HELP_STR |
fd5e7b70 | 8054 | "Address Family\n" |
510afcd6 | 8055 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 8056 | "Address Family modifier\n" |
b09b5ae0 | 8057 | "Clear all peers\n" |
453c92f6 | 8058 | "BGP IPv4 neighbor to clear\n" |
a80beece | 8059 | "BGP IPv6 neighbor to clear\n" |
838758ac | 8060 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
8061 | "Clear peers with the AS number\n" |
8062 | "Clear all external peers\n" | |
718e3744 | 8063 | "Clear all members of peer-group\n" |
b09b5ae0 | 8064 | "BGP peer-group name\n" |
b09b5ae0 DW |
8065 | BGP_SOFT_STR |
8066 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
8067 | BGP_SOFT_OUT_STR |
8068 | BGP_SOFT_IN_STR | |
8069 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 8070 | BGP_SOFT_OUT_STR) |
718e3744 | 8071 | { |
d62a17ae | 8072 | char *vrf = NULL; |
8073 | ||
dc912615 DS |
8074 | afi_t afi = AFI_UNSPEC; |
8075 | safi_t safi = SAFI_UNSPEC; | |
d62a17ae | 8076 | enum clear_sort clr_sort = clear_peer; |
8077 | enum bgp_clear_type clr_type; | |
8078 | char *clr_arg = NULL; | |
8079 | ||
8080 | int idx = 0; | |
8081 | ||
8082 | /* clear [ip] bgp */ | |
8083 | if (argv_find(argv, argc, "ip", &idx)) | |
8084 | afi = AFI_IP; | |
8085 | ||
9a8bdf1c PG |
8086 | /* [<vrf> VIEWVRFNAME] */ |
8087 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8088 | vrf = argv[idx + 1]->arg; | |
8089 | idx += 2; | |
8090 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8091 | vrf = NULL; | |
8092 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8093 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 8094 | vrf = argv[idx + 1]->arg; |
8095 | idx += 2; | |
8096 | } | |
d62a17ae | 8097 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8098 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
8099 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8100 | ||
d7b9898c | 8101 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 8102 | if (argv_find(argv, argc, "*", &idx)) { |
8103 | clr_sort = clear_all; | |
8104 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
8105 | clr_sort = clear_peer; | |
8106 | clr_arg = argv[idx]->arg; | |
8107 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
8108 | clr_sort = clear_peer; | |
8109 | clr_arg = argv[idx]->arg; | |
8110 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
8111 | clr_sort = clear_group; | |
8112 | idx++; | |
8113 | clr_arg = argv[idx]->arg; | |
d7b9898c | 8114 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 8115 | clr_sort = clear_peer; |
8116 | clr_arg = argv[idx]->arg; | |
8fa7d444 DS |
8117 | } else if (argv_find(argv, argc, "WORD", &idx)) { |
8118 | clr_sort = clear_peer; | |
8119 | clr_arg = argv[idx]->arg; | |
d62a17ae | 8120 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { |
8121 | clr_sort = clear_as; | |
8122 | clr_arg = argv[idx]->arg; | |
8123 | } else if (argv_find(argv, argc, "external", &idx)) { | |
8124 | clr_sort = clear_external; | |
8125 | } | |
8126 | ||
8127 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
8128 | if (argv_find(argv, argc, "soft", &idx)) { | |
8129 | if (argv_find(argv, argc, "in", &idx) | |
8130 | || argv_find(argv, argc, "out", &idx)) | |
8131 | clr_type = strmatch(argv[idx]->text, "in") | |
8132 | ? BGP_CLEAR_SOFT_IN | |
8133 | : BGP_CLEAR_SOFT_OUT; | |
8134 | else | |
8135 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
8136 | } else if (argv_find(argv, argc, "in", &idx)) { | |
8137 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
8138 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
8139 | : BGP_CLEAR_SOFT_IN; | |
8140 | } else if (argv_find(argv, argc, "out", &idx)) { | |
8141 | clr_type = BGP_CLEAR_SOFT_OUT; | |
8142 | } else | |
8143 | clr_type = BGP_CLEAR_SOFT_NONE; | |
8144 | ||
8145 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 8146 | } |
01080f7c | 8147 | |
8ad7271d DS |
8148 | DEFUN (clear_ip_bgp_prefix, |
8149 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 8150 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
8151 | CLEAR_STR |
8152 | IP_STR | |
8153 | BGP_STR | |
838758ac | 8154 | BGP_INSTANCE_HELP_STR |
8ad7271d | 8155 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8156 | "IPv4 prefix\n") |
8ad7271d | 8157 | { |
d62a17ae | 8158 | char *vrf = NULL; |
8159 | char *prefix = NULL; | |
8ad7271d | 8160 | |
d62a17ae | 8161 | int idx = 0; |
01080f7c | 8162 | |
d62a17ae | 8163 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
8164 | if (argv_find(argv, argc, "vrf", &idx)) { |
8165 | vrf = argv[idx + 1]->arg; | |
8166 | idx += 2; | |
8167 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8168 | vrf = NULL; | |
8169 | } else if (argv_find(argv, argc, "view", &idx)) { | |
8170 | /* [<view> VIEWVRFNAME] */ | |
8171 | vrf = argv[idx + 1]->arg; | |
8172 | idx += 2; | |
8173 | } | |
0c7b1b01 | 8174 | |
d62a17ae | 8175 | prefix = argv[argc - 1]->arg; |
8ad7271d | 8176 | |
d62a17ae | 8177 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 8178 | } |
8ad7271d | 8179 | |
b09b5ae0 DW |
8180 | DEFUN (clear_bgp_ipv6_safi_prefix, |
8181 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 8182 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8183 | CLEAR_STR |
3a2d747c | 8184 | IP_STR |
718e3744 | 8185 | BGP_STR |
8c3deaae | 8186 | "Address Family\n" |
46f296b4 | 8187 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8188 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8189 | "IPv6 prefix\n") |
718e3744 | 8190 | { |
9b475e76 PG |
8191 | int idx_safi = 0; |
8192 | int idx_ipv6_prefix = 0; | |
8193 | safi_t safi = SAFI_UNICAST; | |
8194 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8195 | argv[idx_ipv6_prefix]->arg : NULL; | |
8196 | ||
8197 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 8198 | return bgp_clear_prefix( |
9b475e76 PG |
8199 | vty, NULL, prefix, AFI_IP6, |
8200 | safi, NULL); | |
838758ac | 8201 | } |
01080f7c | 8202 | |
b09b5ae0 DW |
8203 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
8204 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 8205 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 8206 | CLEAR_STR |
3a2d747c | 8207 | IP_STR |
718e3744 | 8208 | BGP_STR |
838758ac | 8209 | BGP_INSTANCE_HELP_STR |
8c3deaae | 8210 | "Address Family\n" |
46f296b4 | 8211 | BGP_SAFI_HELP_STR |
b09b5ae0 | 8212 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 8213 | "IPv6 prefix\n") |
718e3744 | 8214 | { |
9b475e76 | 8215 | int idx_safi = 0; |
9a8bdf1c | 8216 | int idx_vrfview = 0; |
9b475e76 PG |
8217 | int idx_ipv6_prefix = 0; |
8218 | safi_t safi = SAFI_UNICAST; | |
8219 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
8220 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 8221 | char *vrfview = NULL; |
9b475e76 | 8222 | |
9a8bdf1c PG |
8223 | /* [<view|vrf> VIEWVRFNAME] */ |
8224 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
8225 | vrfview = argv[idx_vrfview + 1]->arg; | |
8226 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
8227 | vrfview = NULL; | |
8228 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
8229 | /* [<view> VIEWVRFNAME] */ | |
8230 | vrfview = argv[idx_vrfview + 1]->arg; | |
8231 | } | |
9b475e76 PG |
8232 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
8233 | ||
d62a17ae | 8234 | return bgp_clear_prefix( |
9b475e76 PG |
8235 | vty, vrfview, prefix, |
8236 | AFI_IP6, safi, NULL); | |
718e3744 | 8237 | } |
8238 | ||
b09b5ae0 DW |
8239 | DEFUN (show_bgp_views, |
8240 | show_bgp_views_cmd, | |
d6e3c605 | 8241 | "show [ip] bgp views", |
b09b5ae0 | 8242 | SHOW_STR |
d6e3c605 | 8243 | IP_STR |
01080f7c | 8244 | BGP_STR |
b09b5ae0 | 8245 | "Show the defined BGP views\n") |
01080f7c | 8246 | { |
d62a17ae | 8247 | struct list *inst = bm->bgp; |
8248 | struct listnode *node; | |
8249 | struct bgp *bgp; | |
01080f7c | 8250 | |
d62a17ae | 8251 | vty_out(vty, "Defined BGP views:\n"); |
8252 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8253 | /* Skip VRFs. */ | |
8254 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
8255 | continue; | |
8256 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
8257 | bgp->as); | |
8258 | } | |
e52702f2 | 8259 | |
d62a17ae | 8260 | return CMD_SUCCESS; |
e0081f70 ML |
8261 | } |
8262 | ||
8386ac43 | 8263 | DEFUN (show_bgp_vrfs, |
8264 | show_bgp_vrfs_cmd, | |
d6e3c605 | 8265 | "show [ip] bgp vrfs [json]", |
8386ac43 | 8266 | SHOW_STR |
d6e3c605 | 8267 | IP_STR |
8386ac43 | 8268 | BGP_STR |
8269 | "Show BGP VRFs\n" | |
9973d184 | 8270 | JSON_STR) |
8386ac43 | 8271 | { |
fe1dc5a3 | 8272 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 8273 | struct list *inst = bm->bgp; |
8274 | struct listnode *node; | |
8275 | struct bgp *bgp; | |
9f049418 | 8276 | bool uj = use_json(argc, argv); |
d62a17ae | 8277 | json_object *json = NULL; |
8278 | json_object *json_vrfs = NULL; | |
8279 | int count = 0; | |
d62a17ae | 8280 | |
d62a17ae | 8281 | if (uj) { |
8282 | json = json_object_new_object(); | |
8283 | json_vrfs = json_object_new_object(); | |
8284 | } | |
8285 | ||
8286 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
8287 | const char *name, *type; | |
8288 | struct peer *peer; | |
7fe96307 | 8289 | struct listnode *node2, *nnode2; |
d62a17ae | 8290 | int peers_cfg, peers_estb; |
8291 | json_object *json_vrf = NULL; | |
d62a17ae | 8292 | |
8293 | /* Skip Views. */ | |
8294 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
8295 | continue; | |
8296 | ||
8297 | count++; | |
efb4077a | 8298 | if (!uj && count == 1) { |
fe1dc5a3 | 8299 | vty_out(vty, |
efb4077a | 8300 | "%4s %-5s %-16s %9s %10s %-37s\n", |
3c0e7aa4 | 8301 | "Type", "Id", "routerId", "#PeersCfg", |
efb4077a CS |
8302 | "#PeersEstb", "Name"); |
8303 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
8304 | "L3-VNI", "RouterMAC", "Interface"); | |
8305 | } | |
d62a17ae | 8306 | |
8307 | peers_cfg = peers_estb = 0; | |
8308 | if (uj) | |
8309 | json_vrf = json_object_new_object(); | |
8310 | ||
8311 | ||
7fe96307 | 8312 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 8313 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8314 | continue; | |
8315 | peers_cfg++; | |
8316 | if (peer->status == Established) | |
8317 | peers_estb++; | |
8318 | } | |
8319 | ||
8320 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 8321 | name = VRF_DEFAULT_NAME; |
d62a17ae | 8322 | type = "DFLT"; |
8323 | } else { | |
8324 | name = bgp->name; | |
8325 | type = "VRF"; | |
8326 | } | |
8327 | ||
a8bf7d9c | 8328 | |
d62a17ae | 8329 | if (uj) { |
a4d82a8a PZ |
8330 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8331 | ? -1 | |
8332 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 8333 | json_object_string_add(json_vrf, "type", type); |
8334 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
8335 | json_object_string_add(json_vrf, "routerId", | |
8336 | inet_ntoa(bgp->router_id)); | |
8337 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
8338 | peers_cfg); | |
8339 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
8340 | peers_estb); | |
8341 | ||
fe1dc5a3 | 8342 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
8343 | json_object_string_add( |
8344 | json_vrf, "rmac", | |
8345 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
8346 | json_object_string_add(json_vrf, "interface", |
8347 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8348 | bgp->vrf_id)); | |
d62a17ae | 8349 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 8350 | } else { |
fe1dc5a3 | 8351 | vty_out(vty, |
efb4077a | 8352 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
8353 | type, |
8354 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
8355 | : (int)bgp->vrf_id, | |
8356 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
8357 | peers_estb, name); |
8358 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
8359 | bgp->l3vni, | |
8360 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
8361 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
8362 | bgp->vrf_id)); | |
8363 | } | |
d62a17ae | 8364 | } |
8365 | ||
8366 | if (uj) { | |
8367 | json_object_object_add(json, "vrfs", json_vrfs); | |
8368 | ||
8369 | json_object_int_add(json, "totalVrfs", count); | |
8370 | ||
996c9314 LB |
8371 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8372 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8373 | json_object_free(json); |
8374 | } else { | |
8375 | if (count) | |
8376 | vty_out(vty, | |
8377 | "\nTotal number of VRFs (including default): %d\n", | |
8378 | count); | |
8379 | } | |
8380 | ||
8381 | return CMD_SUCCESS; | |
8386ac43 | 8382 | } |
8383 | ||
48ecf8f5 DS |
8384 | DEFUN (show_bgp_mac_hash, |
8385 | show_bgp_mac_hash_cmd, | |
8386 | "show bgp mac hash", | |
8387 | SHOW_STR | |
8388 | BGP_STR | |
8389 | "Mac Address\n" | |
8390 | "Mac Address database\n") | |
8391 | { | |
8392 | bgp_mac_dump_table(vty); | |
8393 | ||
8394 | return CMD_SUCCESS; | |
8395 | } | |
acf71666 | 8396 | |
e3b78da8 | 8397 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 8398 | { |
0291c246 | 8399 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 8400 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 8401 | |
60466a63 | 8402 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
8403 | tip->refcnt); |
8404 | } | |
8405 | ||
8406 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
8407 | { | |
8408 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 8409 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
8410 | |
8411 | vty_out(vty, "Tunnel-ip database:\n"); | |
8412 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 8413 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
8414 | vty); |
8415 | } | |
8416 | ||
15c81ca4 DS |
8417 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
8418 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
8419 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
8420 | "martian next-hops\n" |
8421 | "martian next-hop database\n") | |
acf71666 | 8422 | { |
0291c246 | 8423 | struct bgp *bgp = NULL; |
15c81ca4 | 8424 | int idx = 0; |
9a8bdf1c PG |
8425 | char *name = NULL; |
8426 | ||
8427 | /* [<vrf> VIEWVRFNAME] */ | |
8428 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8429 | name = argv[idx + 1]->arg; | |
8430 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
8431 | name = NULL; | |
8432 | } else if (argv_find(argv, argc, "view", &idx)) | |
8433 | /* [<view> VIEWVRFNAME] */ | |
8434 | name = argv[idx + 1]->arg; | |
8435 | if (name) | |
8436 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
8437 | else |
8438 | bgp = bgp_get_default(); | |
acf71666 | 8439 | |
acf71666 MK |
8440 | if (!bgp) { |
8441 | vty_out(vty, "%% No BGP process is configured\n"); | |
8442 | return CMD_WARNING; | |
8443 | } | |
8444 | bgp_show_martian_nexthops(vty, bgp); | |
8445 | ||
8446 | return CMD_SUCCESS; | |
8447 | } | |
8448 | ||
f412b39a | 8449 | DEFUN (show_bgp_memory, |
4bf6a362 | 8450 | show_bgp_memory_cmd, |
7fa12b13 | 8451 | "show [ip] bgp memory", |
4bf6a362 | 8452 | SHOW_STR |
3a2d747c | 8453 | IP_STR |
4bf6a362 PJ |
8454 | BGP_STR |
8455 | "Global BGP memory statistics\n") | |
8456 | { | |
d62a17ae | 8457 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
8458 | unsigned long count; | |
8459 | ||
8460 | /* RIB related usage stats */ | |
8461 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
8462 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
8463 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8464 | count * sizeof(struct bgp_node))); | |
8465 | ||
8466 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
8467 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
8468 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 8469 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 8470 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
8471 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
8472 | count, | |
4b7e6066 DS |
8473 | mtype_memstr( |
8474 | memstrbuf, sizeof(memstrbuf), | |
8475 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 8476 | |
8477 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
8478 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
8479 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8480 | count * sizeof(struct bgp_static))); | |
8481 | ||
8482 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
8483 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
8484 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8485 | count * sizeof(struct bpacket))); | |
8486 | ||
8487 | /* Adj-In/Out */ | |
8488 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
8489 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
8490 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8491 | count * sizeof(struct bgp_adj_in))); | |
8492 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
8493 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
8494 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8495 | count * sizeof(struct bgp_adj_out))); | |
8496 | ||
8497 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
8498 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
8499 | count, | |
8500 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8501 | count * sizeof(struct bgp_nexthop_cache))); | |
8502 | ||
8503 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
8504 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
8505 | count, | |
8506 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8507 | count * sizeof(struct bgp_damp_info))); | |
8508 | ||
8509 | /* Attributes */ | |
8510 | count = attr_count(); | |
8511 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
8512 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8513 | count * sizeof(struct attr))); | |
8514 | ||
8515 | if ((count = attr_unknown_count())) | |
8516 | vty_out(vty, "%ld unknown attributes\n", count); | |
8517 | ||
8518 | /* AS_PATH attributes */ | |
8519 | count = aspath_count(); | |
8520 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
8521 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8522 | count * sizeof(struct aspath))); | |
8523 | ||
8524 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
8525 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
8526 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8527 | count * sizeof(struct assegment))); | |
8528 | ||
8529 | /* Other attributes */ | |
8530 | if ((count = community_count())) | |
8531 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8532 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8533 | count * sizeof(struct community))); | |
d62a17ae | 8534 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
8535 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
8536 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8537 | count * sizeof(struct ecommunity))); | |
d62a17ae | 8538 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
8539 | vty_out(vty, | |
8540 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
8541 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8542 | count * sizeof(struct lcommunity))); | |
d62a17ae | 8543 | |
8544 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
8545 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
8546 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8547 | count * sizeof(struct cluster_list))); | |
8548 | ||
8549 | /* Peer related usage */ | |
8550 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
8551 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
8552 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8553 | count * sizeof(struct peer))); | |
8554 | ||
8555 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
8556 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
8557 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
8558 | count * sizeof(struct peer_group))); | |
8559 | ||
8560 | /* Other */ | |
d62a17ae | 8561 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
8562 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
8563 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
8564 | count * sizeof(regex_t))); | |
d62a17ae | 8565 | return CMD_SUCCESS; |
4bf6a362 | 8566 | } |
fee0f4c6 | 8567 | |
57a9c8a8 DS |
8568 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
8569 | { | |
8570 | json_object *bestpath = json_object_new_object(); | |
8571 | ||
892fedb6 | 8572 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
57a9c8a8 DS |
8573 | json_object_string_add(bestpath, "asPath", "ignore"); |
8574 | ||
892fedb6 | 8575 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
57a9c8a8 DS |
8576 | json_object_string_add(bestpath, "asPath", "confed"); |
8577 | ||
892fedb6 DA |
8578 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
8579 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
a4d82a8a | 8580 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8581 | "as-set"); |
8582 | else | |
a4d82a8a | 8583 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
8584 | "true"); |
8585 | } else | |
a4d82a8a | 8586 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 | 8587 | |
892fedb6 | 8588 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
57a9c8a8 | 8589 | json_object_string_add(bestpath, "compareRouterId", "true"); |
892fedb6 DA |
8590 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
8591 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
8592 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 8593 | json_object_string_add(bestpath, "med", "confed"); |
892fedb6 | 8594 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) |
57a9c8a8 DS |
8595 | json_object_string_add(bestpath, "med", |
8596 | "missing-as-worst"); | |
8597 | else | |
8598 | json_object_string_add(bestpath, "med", "true"); | |
8599 | } | |
8600 | ||
8601 | json_object_object_add(json, "bestPath", bestpath); | |
8602 | } | |
8603 | ||
3577f1c5 DD |
8604 | /* Print the error code/subcode for why the peer is down */ |
8605 | static void bgp_show_peer_reset(struct vty * vty, struct peer *peer, | |
8606 | json_object *json_peer, bool use_json) | |
8607 | { | |
8608 | const char *code_str; | |
8609 | const char *subcode_str; | |
8610 | ||
8611 | if (use_json) { | |
8612 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8613 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8614 | char errorcodesubcode_hexstr[5]; | |
8615 | char errorcodesubcode_str[256]; | |
8616 | ||
8617 | code_str = bgp_notify_code_str(peer->notify.code); | |
8618 | subcode_str = bgp_notify_subcode_str( | |
8619 | peer->notify.code, | |
8620 | peer->notify.subcode); | |
8621 | ||
772270f3 QY |
8622 | snprintf(errorcodesubcode_hexstr, |
8623 | sizeof(errorcodesubcode_hexstr), "%02X%02X", | |
8624 | peer->notify.code, peer->notify.subcode); | |
3577f1c5 DD |
8625 | json_object_string_add(json_peer, |
8626 | "lastErrorCodeSubcode", | |
8627 | errorcodesubcode_hexstr); | |
8628 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
8629 | code_str, subcode_str); | |
8630 | json_object_string_add(json_peer, | |
8631 | "lastNotificationReason", | |
8632 | errorcodesubcode_str); | |
8633 | if (peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
8634 | && peer->notify.code == BGP_NOTIFY_CEASE | |
8635 | && (peer->notify.subcode | |
8636 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
8637 | || peer->notify.subcode | |
8638 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
8639 | && peer->notify.length) { | |
8640 | char msgbuf[1024]; | |
8641 | const char *msg_str; | |
8642 | ||
8643 | msg_str = bgp_notify_admin_message( | |
8644 | msgbuf, sizeof(msgbuf), | |
8645 | (uint8_t *)peer->notify.data, | |
8646 | peer->notify.length); | |
8647 | if (msg_str) | |
8648 | json_object_string_add( | |
8649 | json_peer, | |
8650 | "lastShutdownDescription", | |
8651 | msg_str); | |
8652 | } | |
8653 | ||
c258527b | 8654 | } |
3577f1c5 DD |
8655 | json_object_string_add(json_peer, "lastResetDueTo", |
8656 | peer_down_str[(int)peer->last_reset]); | |
05912a17 DD |
8657 | json_object_int_add(json_peer, "lastResetCode", |
8658 | peer->last_reset); | |
3577f1c5 DD |
8659 | } else { |
8660 | if (peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8661 | || peer->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
8662 | code_str = bgp_notify_code_str(peer->notify.code); | |
8663 | subcode_str = | |
8664 | bgp_notify_subcode_str(peer->notify.code, | |
8665 | peer->notify.subcode); | |
8666 | vty_out(vty, " Notification %s (%s%s)\n", | |
8667 | peer->last_reset == PEER_DOWN_NOTIFY_SEND | |
8668 | ? "sent" | |
8669 | : "received", | |
8670 | code_str, subcode_str); | |
8671 | } else { | |
e91c24c8 | 8672 | vty_out(vty, " %s\n", |
3577f1c5 DD |
8673 | peer_down_str[(int)peer->last_reset]); |
8674 | } | |
8675 | } | |
8676 | } | |
8677 | ||
8678 | static inline bool bgp_has_peer_failed(struct peer *peer, afi_t afi, | |
8679 | safi_t safi) | |
8680 | { | |
8681 | return ((peer->status != Established) || | |
8682 | !peer->afc_recv[afi][safi]); | |
8683 | } | |
8684 | ||
8685 | static void bgp_show_failed_summary(struct vty *vty, struct bgp *bgp, | |
8686 | struct peer *peer, json_object *json_peer, | |
8687 | int max_neighbor_width, bool use_json) | |
8688 | { | |
8689 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8690 | int len; | |
8691 | ||
8692 | if (use_json) { | |
8693 | if (peer_dynamic_neighbor(peer)) | |
8694 | json_object_boolean_true_add(json_peer, | |
8695 | "dynamicPeer"); | |
8696 | if (peer->hostname) | |
8697 | json_object_string_add(json_peer, "hostname", | |
8698 | peer->hostname); | |
8699 | ||
8700 | if (peer->domainname) | |
8701 | json_object_string_add(json_peer, "domainname", | |
8702 | peer->domainname); | |
8703 | json_object_int_add(json_peer, "connectionsEstablished", | |
8704 | peer->established); | |
8705 | json_object_int_add(json_peer, "connectionsDropped", | |
8706 | peer->dropped); | |
8707 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, | |
8708 | use_json, json_peer); | |
8709 | if (peer->status == Established) | |
8710 | json_object_string_add(json_peer, "lastResetDueTo", | |
8711 | "AFI/SAFI Not Negotiated"); | |
8712 | else | |
8713 | bgp_show_peer_reset(NULL, peer, json_peer, true); | |
8714 | } else { | |
8715 | dn_flag[1] = '\0'; | |
8716 | dn_flag[0] = peer_dynamic_neighbor(peer) ? '*' : '\0'; | |
8717 | if (peer->hostname | |
892fedb6 | 8718 | && CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME)) |
3577f1c5 DD |
8719 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
8720 | peer->hostname, peer->host); | |
8721 | else | |
8722 | len = vty_out(vty, "%s%s", dn_flag, peer->host); | |
8723 | ||
8724 | /* pad the neighbor column with spaces */ | |
8725 | if (len < max_neighbor_width) | |
8726 | vty_out(vty, "%*s", max_neighbor_width - len, | |
8727 | " "); | |
e91c24c8 | 8728 | vty_out(vty, "%7d %7d %9s", peer->established, |
3577f1c5 DD |
8729 | peer->dropped, |
8730 | peer_uptime(peer->uptime, timebuf, | |
8731 | BGP_UPTIME_LEN, 0, NULL)); | |
8732 | if (peer->status == Established) | |
8733 | vty_out(vty, " AFI/SAFI Not Negotiated\n"); | |
8734 | else | |
8735 | bgp_show_peer_reset(vty, peer, NULL, | |
8736 | false); | |
8737 | } | |
8738 | } | |
c258527b | 8739 | |
3577f1c5 | 8740 | |
718e3744 | 8741 | /* Show BGP peer's summary information. */ |
d62a17ae | 8742 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
3577f1c5 | 8743 | bool show_failed, bool use_json) |
d62a17ae | 8744 | { |
8745 | struct peer *peer; | |
8746 | struct listnode *node, *nnode; | |
8747 | unsigned int count = 0, dn_count = 0; | |
8748 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
8749 | char neighbor_buf[VTY_BUFSIZ]; | |
8750 | int neighbor_col_default_width = 16; | |
3577f1c5 | 8751 | int len, failed_count = 0; |
d62a17ae | 8752 | int max_neighbor_width = 0; |
8753 | int pfx_rcd_safi; | |
3c13337d | 8754 | json_object *json = NULL; |
d62a17ae | 8755 | json_object *json_peer = NULL; |
8756 | json_object *json_peers = NULL; | |
50e05855 | 8757 | struct peer_af *paf; |
d62a17ae | 8758 | |
8759 | /* labeled-unicast routes are installed in the unicast table so in order | |
8760 | * to | |
8761 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
8762 | */ | |
3577f1c5 | 8763 | |
d62a17ae | 8764 | if (safi == SAFI_LABELED_UNICAST) |
8765 | pfx_rcd_safi = SAFI_UNICAST; | |
8766 | else | |
8767 | pfx_rcd_safi = safi; | |
8768 | ||
8769 | if (use_json) { | |
3c13337d | 8770 | json = json_object_new_object(); |
d62a17ae | 8771 | json_peers = json_object_new_object(); |
3577f1c5 DD |
8772 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8773 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8774 | continue; | |
8775 | ||
8776 | if (peer->afc[afi][safi]) { | |
8777 | /* See if we have at least a single failed peer */ | |
8778 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8779 | failed_count++; | |
8780 | count++; | |
8781 | } | |
8782 | if (peer_dynamic_neighbor(peer)) | |
8783 | dn_count++; | |
8784 | } | |
c258527b | 8785 | |
d62a17ae | 8786 | } else { |
8787 | /* Loop over all neighbors that will be displayed to determine | |
8788 | * how many | |
8789 | * characters are needed for the Neighbor column | |
8790 | */ | |
8791 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
8792 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8793 | continue; | |
8794 | ||
8795 | if (peer->afc[afi][safi]) { | |
8796 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8797 | if (peer_dynamic_neighbor(peer)) | |
8798 | dn_flag[0] = '*'; | |
8799 | ||
8800 | if (peer->hostname | |
892fedb6 DA |
8801 | && CHECK_FLAG(bgp->flags, |
8802 | BGP_FLAG_SHOW_HOSTNAME)) | |
772270f3 QY |
8803 | snprintf(neighbor_buf, |
8804 | sizeof(neighbor_buf), | |
8805 | "%s%s(%s) ", dn_flag, | |
8806 | peer->hostname, peer->host); | |
d62a17ae | 8807 | else |
772270f3 QY |
8808 | snprintf(neighbor_buf, |
8809 | sizeof(neighbor_buf), "%s%s ", | |
8810 | dn_flag, peer->host); | |
d62a17ae | 8811 | |
8812 | len = strlen(neighbor_buf); | |
8813 | ||
8814 | if (len > max_neighbor_width) | |
8815 | max_neighbor_width = len; | |
c258527b | 8816 | |
3577f1c5 DD |
8817 | /* See if we have at least a single failed peer */ |
8818 | if (bgp_has_peer_failed(peer, afi, safi)) | |
8819 | failed_count++; | |
8820 | count++; | |
d62a17ae | 8821 | } |
8822 | } | |
f933309e | 8823 | |
d62a17ae | 8824 | /* Originally we displayed the Neighbor column as 16 |
8825 | * characters wide so make that the default | |
8826 | */ | |
8827 | if (max_neighbor_width < neighbor_col_default_width) | |
8828 | max_neighbor_width = neighbor_col_default_width; | |
8829 | } | |
f933309e | 8830 | |
3577f1c5 DD |
8831 | if (show_failed && !failed_count) { |
8832 | if (use_json) { | |
8833 | json_object_int_add(json, "failedPeersCount", 0); | |
8834 | json_object_int_add(json, "dynamicPeers", dn_count); | |
c258527b | 8835 | json_object_int_add(json, "totalPeers", count); |
3577f1c5 DD |
8836 | |
8837 | vty_out(vty, "%s\n", json_object_to_json_string_ext( | |
8838 | json, JSON_C_TO_STRING_PRETTY)); | |
8839 | json_object_free(json); | |
8840 | } else { | |
8841 | vty_out(vty, "%% No failed BGP neighbors found\n"); | |
8842 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8843 | } | |
8844 | return CMD_SUCCESS; | |
8845 | } | |
c258527b | 8846 | |
3577f1c5 | 8847 | count = 0; /* Reset the value as its used again */ |
d62a17ae | 8848 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
8849 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
8850 | continue; | |
8851 | ||
ea47320b DL |
8852 | if (!peer->afc[afi][safi]) |
8853 | continue; | |
d62a17ae | 8854 | |
ea47320b DL |
8855 | if (!count) { |
8856 | unsigned long ents; | |
8857 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 8858 | int64_t vrf_id_ui; |
d62a17ae | 8859 | |
a4d82a8a PZ |
8860 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
8861 | ? -1 | |
8862 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
8863 | |
8864 | /* Usage summary and header */ | |
8865 | if (use_json) { | |
8866 | json_object_string_add( | |
8867 | json, "routerId", | |
8868 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
8869 | json_object_int_add(json, "as", bgp->as); |
8870 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
8871 | json_object_string_add( |
8872 | json, "vrfName", | |
8873 | (bgp->inst_type | |
8874 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8875 | ? VRF_DEFAULT_NAME |
ea47320b DL |
8876 | : bgp->name); |
8877 | } else { | |
8878 | vty_out(vty, | |
8879 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 8880 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
8881 | bgp->vrf_id == VRF_UNKNOWN |
8882 | ? -1 | |
8883 | : (int)bgp->vrf_id); | |
ea47320b DL |
8884 | vty_out(vty, "\n"); |
8885 | } | |
d62a17ae | 8886 | |
ea47320b | 8887 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 8888 | if (use_json) { |
ea47320b | 8889 | json_object_int_add( |
60466a63 | 8890 | json, "updateDelayLimit", |
ea47320b | 8891 | bgp->v_update_delay); |
d62a17ae | 8892 | |
ea47320b DL |
8893 | if (bgp->v_update_delay |
8894 | != bgp->v_establish_wait) | |
d62a17ae | 8895 | json_object_int_add( |
8896 | json, | |
ea47320b DL |
8897 | "updateDelayEstablishWait", |
8898 | bgp->v_establish_wait); | |
d62a17ae | 8899 | |
60466a63 | 8900 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8901 | json_object_string_add( |
8902 | json, | |
8903 | "updateDelayFirstNeighbor", | |
8904 | bgp->update_delay_begin_time); | |
8905 | json_object_boolean_true_add( | |
8906 | json, | |
8907 | "updateDelayInProgress"); | |
8908 | } else { | |
8909 | if (bgp->update_delay_over) { | |
d62a17ae | 8910 | json_object_string_add( |
8911 | json, | |
8912 | "updateDelayFirstNeighbor", | |
8913 | bgp->update_delay_begin_time); | |
ea47320b | 8914 | json_object_string_add( |
d62a17ae | 8915 | json, |
ea47320b DL |
8916 | "updateDelayBestpathResumed", |
8917 | bgp->update_delay_end_time); | |
8918 | json_object_string_add( | |
d62a17ae | 8919 | json, |
ea47320b DL |
8920 | "updateDelayZebraUpdateResume", |
8921 | bgp->update_delay_zebra_resume_time); | |
8922 | json_object_string_add( | |
8923 | json, | |
8924 | "updateDelayPeerUpdateResume", | |
8925 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8926 | } |
ea47320b DL |
8927 | } |
8928 | } else { | |
8929 | vty_out(vty, | |
8930 | "Read-only mode update-delay limit: %d seconds\n", | |
8931 | bgp->v_update_delay); | |
8932 | if (bgp->v_update_delay | |
8933 | != bgp->v_establish_wait) | |
d62a17ae | 8934 | vty_out(vty, |
ea47320b DL |
8935 | " Establish wait: %d seconds\n", |
8936 | bgp->v_establish_wait); | |
d62a17ae | 8937 | |
60466a63 | 8938 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8939 | vty_out(vty, |
8940 | " First neighbor established: %s\n", | |
8941 | bgp->update_delay_begin_time); | |
8942 | vty_out(vty, | |
8943 | " Delay in progress\n"); | |
8944 | } else { | |
8945 | if (bgp->update_delay_over) { | |
d62a17ae | 8946 | vty_out(vty, |
8947 | " First neighbor established: %s\n", | |
8948 | bgp->update_delay_begin_time); | |
8949 | vty_out(vty, | |
ea47320b DL |
8950 | " Best-paths resumed: %s\n", |
8951 | bgp->update_delay_end_time); | |
8952 | vty_out(vty, | |
8953 | " zebra update resumed: %s\n", | |
8954 | bgp->update_delay_zebra_resume_time); | |
8955 | vty_out(vty, | |
8956 | " peers update resumed: %s\n", | |
8957 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8958 | } |
8959 | } | |
8960 | } | |
ea47320b | 8961 | } |
d62a17ae | 8962 | |
ea47320b DL |
8963 | if (use_json) { |
8964 | if (bgp_maxmed_onstartup_configured(bgp) | |
8965 | && bgp->maxmed_active) | |
8966 | json_object_boolean_true_add( | |
60466a63 | 8967 | json, "maxMedOnStartup"); |
ea47320b DL |
8968 | if (bgp->v_maxmed_admin) |
8969 | json_object_boolean_true_add( | |
60466a63 | 8970 | json, "maxMedAdministrative"); |
d62a17ae | 8971 | |
ea47320b DL |
8972 | json_object_int_add( |
8973 | json, "tableVersion", | |
60466a63 | 8974 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8975 | |
60466a63 QY |
8976 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8977 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8978 | json_object_int_add( |
8979 | json, "ribMemory", | |
8980 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8981 | |
210ec2a0 | 8982 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8983 | json_object_int_add(json, "peerCount", ents); |
8984 | json_object_int_add(json, "peerMemory", | |
8985 | ents * sizeof(struct peer)); | |
d62a17ae | 8986 | |
ea47320b DL |
8987 | if ((ents = listcount(bgp->group))) { |
8988 | json_object_int_add( | |
60466a63 | 8989 | json, "peerGroupCount", ents); |
ea47320b DL |
8990 | json_object_int_add( |
8991 | json, "peerGroupMemory", | |
996c9314 LB |
8992 | ents * sizeof(struct |
8993 | peer_group)); | |
ea47320b | 8994 | } |
d62a17ae | 8995 | |
ea47320b DL |
8996 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8997 | BGP_CONFIG_DAMPENING)) | |
8998 | json_object_boolean_true_add( | |
60466a63 | 8999 | json, "dampeningEnabled"); |
ea47320b DL |
9000 | } else { |
9001 | if (bgp_maxmed_onstartup_configured(bgp) | |
9002 | && bgp->maxmed_active) | |
d62a17ae | 9003 | vty_out(vty, |
ea47320b DL |
9004 | "Max-med on-startup active\n"); |
9005 | if (bgp->v_maxmed_admin) | |
d62a17ae | 9006 | vty_out(vty, |
ea47320b | 9007 | "Max-med administrative active\n"); |
d62a17ae | 9008 | |
60466a63 QY |
9009 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
9010 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 9011 | |
60466a63 | 9012 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
9013 | vty_out(vty, |
9014 | "RIB entries %ld, using %s of memory\n", | |
9015 | ents, | |
996c9314 LB |
9016 | mtype_memstr(memstrbuf, |
9017 | sizeof(memstrbuf), | |
9018 | ents * sizeof(struct | |
9019 | bgp_node))); | |
ea47320b DL |
9020 | |
9021 | /* Peer related usage */ | |
210ec2a0 | 9022 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 9023 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
9024 | ents, |
9025 | mtype_memstr( | |
60466a63 QY |
9026 | memstrbuf, sizeof(memstrbuf), |
9027 | ents * sizeof(struct peer))); | |
ea47320b DL |
9028 | |
9029 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 9030 | vty_out(vty, |
ea47320b | 9031 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 9032 | ents, |
9033 | mtype_memstr( | |
9034 | memstrbuf, | |
9035 | sizeof(memstrbuf), | |
996c9314 LB |
9036 | ents * sizeof(struct |
9037 | peer_group))); | |
d62a17ae | 9038 | |
ea47320b DL |
9039 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
9040 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 9041 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 9042 | vty_out(vty, "\n"); |
d62a17ae | 9043 | |
ea47320b DL |
9044 | /* Subtract 8 here because 'Neighbor' is |
9045 | * 8 characters */ | |
9046 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
9047 | vty_out(vty, "%*s", max_neighbor_width - 8, |
9048 | " "); | |
3577f1c5 DD |
9049 | if (show_failed) |
9050 | vty_out(vty, "EstdCnt DropCnt ResetTime Reason\n"); | |
9051 | else | |
9052 | vty_out(vty, | |
9da4aaa3 | 9053 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); |
d62a17ae | 9054 | } |
ea47320b | 9055 | } |
d62a17ae | 9056 | |
ea47320b | 9057 | count++; |
3577f1c5 DD |
9058 | /* Works for both failed & successful cases */ |
9059 | if (peer_dynamic_neighbor(peer)) | |
9060 | dn_count++; | |
d62a17ae | 9061 | |
ea47320b | 9062 | if (use_json) { |
3577f1c5 DD |
9063 | json_peer = NULL; |
9064 | ||
9065 | if (show_failed && | |
9066 | bgp_has_peer_failed(peer, afi, safi)) { | |
9067 | json_peer = json_object_new_object(); | |
9068 | bgp_show_failed_summary(vty, bgp, peer, | |
9069 | json_peer, 0, use_json); | |
9070 | } else if (!show_failed) { | |
9071 | json_peer = json_object_new_object(); | |
9072 | if (peer_dynamic_neighbor(peer)) { | |
9073 | json_object_boolean_true_add(json_peer, | |
9074 | "dynamicPeer"); | |
9075 | } | |
d62a17ae | 9076 | |
3577f1c5 DD |
9077 | if (peer->hostname) |
9078 | json_object_string_add(json_peer, "hostname", | |
9079 | peer->hostname); | |
9080 | ||
9081 | if (peer->domainname) | |
9082 | json_object_string_add(json_peer, "domainname", | |
9083 | peer->domainname); | |
9084 | ||
9085 | json_object_int_add(json_peer, "remoteAs", peer->as); | |
9086 | json_object_int_add(json_peer, "version", 4); | |
9087 | json_object_int_add(json_peer, "msgRcvd", | |
9088 | PEER_TOTAL_RX(peer)); | |
9089 | json_object_int_add(json_peer, "msgSent", | |
9090 | PEER_TOTAL_TX(peer)); | |
9091 | ||
43aa5965 QY |
9092 | atomic_size_t outq_count, inq_count; |
9093 | outq_count = atomic_load_explicit( | |
9094 | &peer->obuf->count, | |
9095 | memory_order_relaxed); | |
9096 | inq_count = atomic_load_explicit( | |
9097 | &peer->ibuf->count, | |
9098 | memory_order_relaxed); | |
9099 | ||
3577f1c5 DD |
9100 | json_object_int_add(json_peer, "tableVersion", |
9101 | peer->version[afi][safi]); | |
9102 | json_object_int_add(json_peer, "outq", | |
43aa5965 QY |
9103 | outq_count); |
9104 | json_object_int_add(json_peer, "inq", | |
9105 | inq_count); | |
3577f1c5 DD |
9106 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
9107 | use_json, json_peer); | |
9108 | ||
3577f1c5 DD |
9109 | json_object_int_add(json_peer, "pfxRcd", |
9110 | peer->pcount[afi][pfx_rcd_safi]); | |
9111 | ||
9da4aaa3 | 9112 | paf = peer_af_find(peer, afi, pfx_rcd_safi); |
3577f1c5 DD |
9113 | if (paf && PAF_SUBGRP(paf)) |
9114 | json_object_int_add(json_peer, | |
9115 | "pfxSnt", | |
9116 | (PAF_SUBGRP(paf))->scount); | |
9117 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
9118 | json_object_string_add(json_peer, "state", | |
9119 | "Idle (Admin)"); | |
9120 | else if (peer->afc_recv[afi][safi]) | |
9121 | json_object_string_add( | |
9122 | json_peer, "state", | |
9123 | lookup_msg(bgp_status_msg, peer->status, | |
9124 | NULL)); | |
9125 | else if (CHECK_FLAG(peer->sflags, | |
9126 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9127 | json_object_string_add(json_peer, "state", | |
9128 | "Idle (PfxCt)"); | |
9129 | else | |
9130 | json_object_string_add( | |
9131 | json_peer, "state", | |
9132 | lookup_msg(bgp_status_msg, peer->status, | |
9133 | NULL)); | |
200116db DD |
9134 | json_object_int_add(json_peer, "connectionsEstablished", |
9135 | peer->established); | |
9136 | json_object_int_add(json_peer, "connectionsDropped", | |
9137 | peer->dropped); | |
b4e9dcba | 9138 | } |
3577f1c5 DD |
9139 | /* Avoid creating empty peer dicts in JSON */ |
9140 | if (json_peer == NULL) | |
9141 | continue; | |
ea47320b DL |
9142 | |
9143 | if (peer->conf_if) | |
60466a63 | 9144 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
9145 | "interface"); |
9146 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
9147 | json_object_string_add(json_peer, "idType", |
9148 | "ipv4"); | |
ea47320b | 9149 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
9150 | json_object_string_add(json_peer, "idType", |
9151 | "ipv6"); | |
ea47320b DL |
9152 | json_object_object_add(json_peers, peer->host, |
9153 | json_peer); | |
9154 | } else { | |
3577f1c5 DD |
9155 | if (show_failed && |
9156 | bgp_has_peer_failed(peer, afi, safi)) { | |
9157 | bgp_show_failed_summary(vty, bgp, peer, NULL, | |
9158 | max_neighbor_width, | |
9159 | use_json); | |
9160 | } else if (!show_failed) { | |
9161 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9162 | if (peer_dynamic_neighbor(peer)) { | |
9163 | dn_flag[0] = '*'; | |
9164 | } | |
d62a17ae | 9165 | |
3577f1c5 | 9166 | if (peer->hostname |
892fedb6 DA |
9167 | && CHECK_FLAG(bgp->flags, |
9168 | BGP_FLAG_SHOW_HOSTNAME)) | |
3577f1c5 | 9169 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
892fedb6 DA |
9170 | peer->hostname, |
9171 | peer->host); | |
d62a17ae | 9172 | else |
3577f1c5 DD |
9173 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
9174 | ||
9175 | /* pad the neighbor column with spaces */ | |
9176 | if (len < max_neighbor_width) | |
9177 | vty_out(vty, "%*s", max_neighbor_width - len, | |
9178 | " "); | |
9179 | ||
43aa5965 QY |
9180 | atomic_size_t outq_count, inq_count; |
9181 | outq_count = atomic_load_explicit( | |
9182 | &peer->obuf->count, | |
9183 | memory_order_relaxed); | |
9184 | inq_count = atomic_load_explicit( | |
9185 | &peer->ibuf->count, | |
9186 | memory_order_relaxed); | |
9187 | ||
566bdaf6 | 9188 | vty_out(vty, |
43aa5965 QY |
9189 | "4 %10u %9u %9u %8" PRIu64 |
9190 | " %4zu %4zu %8s", | |
3577f1c5 | 9191 | peer->as, PEER_TOTAL_RX(peer), |
566bdaf6 | 9192 | PEER_TOTAL_TX(peer), |
43aa5965 QY |
9193 | peer->version[afi][safi], inq_count, |
9194 | outq_count, | |
3577f1c5 DD |
9195 | peer_uptime(peer->uptime, timebuf, |
9196 | BGP_UPTIME_LEN, 0, NULL)); | |
9197 | ||
9da4aaa3 | 9198 | if (peer->status == Established) |
3577f1c5 | 9199 | if (peer->afc_recv[afi][safi]) |
a0a87037 DA |
9200 | vty_out(vty, " %12" PRIu32, |
9201 | peer->pcount | |
9202 | [afi] | |
9203 | [pfx_rcd_safi]); | |
3577f1c5 DD |
9204 | else |
9205 | vty_out(vty, " NoNeg"); | |
9da4aaa3 | 9206 | else { |
3577f1c5 DD |
9207 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
9208 | vty_out(vty, " Idle (Admin)"); | |
9209 | else if (CHECK_FLAG( | |
9210 | peer->sflags, | |
9211 | PEER_STATUS_PREFIX_OVERFLOW)) | |
9212 | vty_out(vty, " Idle (PfxCt)"); | |
9213 | else | |
9214 | vty_out(vty, " %12s", | |
9215 | lookup_msg(bgp_status_msg, | |
9216 | peer->status, NULL)); | |
9217 | } | |
9218 | vty_out(vty, "\n"); | |
d62a17ae | 9219 | } |
3577f1c5 | 9220 | |
d62a17ae | 9221 | } |
9222 | } | |
f933309e | 9223 | |
d62a17ae | 9224 | if (use_json) { |
9225 | json_object_object_add(json, "peers", json_peers); | |
3577f1c5 | 9226 | json_object_int_add(json, "failedPeers", failed_count); |
d62a17ae | 9227 | json_object_int_add(json, "totalPeers", count); |
9228 | json_object_int_add(json, "dynamicPeers", dn_count); | |
9229 | ||
3577f1c5 DD |
9230 | if (!show_failed) |
9231 | bgp_show_bestpath_json(bgp, json); | |
57a9c8a8 | 9232 | |
996c9314 LB |
9233 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9234 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9235 | json_object_free(json); |
9236 | } else { | |
9237 | if (count) | |
9238 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
9239 | else { | |
d6ceaca3 | 9240 | vty_out(vty, "No %s neighbor is configured\n", |
5cb5f4d0 | 9241 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 9242 | } |
b05a1c8b | 9243 | |
d6ceaca3 | 9244 | if (dn_count) { |
d62a17ae | 9245 | vty_out(vty, "* - dynamic neighbor\n"); |
9246 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
9247 | dn_count, bgp->dynamic_neighbors_limit); | |
9248 | } | |
9249 | } | |
1ff9a340 | 9250 | |
d62a17ae | 9251 | return CMD_SUCCESS; |
718e3744 | 9252 | } |
9253 | ||
d62a17ae | 9254 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
3577f1c5 | 9255 | int safi, bool show_failed, bool use_json) |
d62a17ae | 9256 | { |
9257 | int is_first = 1; | |
9258 | int afi_wildcard = (afi == AFI_MAX); | |
9259 | int safi_wildcard = (safi == SAFI_MAX); | |
9260 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 9261 | bool nbr_output = false; |
d62a17ae | 9262 | |
9263 | if (use_json && is_wildcard) | |
9264 | vty_out(vty, "{\n"); | |
9265 | if (afi_wildcard) | |
9266 | afi = 1; /* AFI_IP */ | |
9267 | while (afi < AFI_MAX) { | |
9268 | if (safi_wildcard) | |
9269 | safi = 1; /* SAFI_UNICAST */ | |
9270 | while (safi < SAFI_MAX) { | |
318cac96 | 9271 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 9272 | nbr_output = true; |
f86897b9 | 9273 | |
d62a17ae | 9274 | if (is_wildcard) { |
9275 | /* | |
9276 | * So limit output to those afi/safi | |
9277 | * pairs that | |
9278 | * actualy have something interesting in | |
9279 | * them | |
9280 | */ | |
9281 | if (use_json) { | |
d62a17ae | 9282 | if (!is_first) |
9283 | vty_out(vty, ",\n"); | |
9284 | else | |
9285 | is_first = 0; | |
9286 | ||
9287 | vty_out(vty, "\"%s\":", | |
5cb5f4d0 DD |
9288 | get_afi_safi_str(afi, |
9289 | safi, | |
9290 | true)); | |
d62a17ae | 9291 | } else { |
9292 | vty_out(vty, "\n%s Summary:\n", | |
5cb5f4d0 DD |
9293 | get_afi_safi_str(afi, |
9294 | safi, | |
9295 | false)); | |
d62a17ae | 9296 | } |
9297 | } | |
3577f1c5 DD |
9298 | bgp_show_summary(vty, bgp, afi, safi, show_failed, |
9299 | use_json); | |
d62a17ae | 9300 | } |
9301 | safi++; | |
d62a17ae | 9302 | if (!safi_wildcard) |
9303 | safi = SAFI_MAX; | |
9304 | } | |
9305 | afi++; | |
ee851c8c | 9306 | if (!afi_wildcard) |
d62a17ae | 9307 | afi = AFI_MAX; |
9308 | } | |
9309 | ||
9310 | if (use_json && is_wildcard) | |
9311 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
9312 | else if (!nbr_output) { |
9313 | if (use_json) | |
9314 | vty_out(vty, "{}\n"); | |
9315 | else | |
9316 | vty_out(vty, "%% No BGP neighbors found\n"); | |
9317 | } | |
d62a17ae | 9318 | } |
9319 | ||
9320 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
3577f1c5 DD |
9321 | safi_t safi, bool show_failed, |
9322 | bool use_json) | |
d62a17ae | 9323 | { |
9324 | struct listnode *node, *nnode; | |
9325 | struct bgp *bgp; | |
d62a17ae | 9326 | int is_first = 1; |
9f049418 | 9327 | bool nbr_output = false; |
d62a17ae | 9328 | |
9329 | if (use_json) | |
9330 | vty_out(vty, "{\n"); | |
9331 | ||
9332 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 9333 | nbr_output = true; |
d62a17ae | 9334 | if (use_json) { |
d62a17ae | 9335 | if (!is_first) |
9336 | vty_out(vty, ",\n"); | |
9337 | else | |
9338 | is_first = 0; | |
9339 | ||
9340 | vty_out(vty, "\"%s\":", | |
9341 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9342 | ? VRF_DEFAULT_NAME |
d62a17ae | 9343 | : bgp->name); |
9344 | } else { | |
9345 | vty_out(vty, "\nInstance %s:\n", | |
9346 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 9347 | ? VRF_DEFAULT_NAME |
d62a17ae | 9348 | : bgp->name); |
9349 | } | |
3577f1c5 DD |
9350 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9351 | use_json); | |
d62a17ae | 9352 | } |
9353 | ||
9354 | if (use_json) | |
9355 | vty_out(vty, "}\n"); | |
9f049418 DS |
9356 | else if (!nbr_output) |
9357 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 9358 | } |
9359 | ||
9360 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
3577f1c5 | 9361 | safi_t safi, bool show_failed, bool use_json) |
d62a17ae | 9362 | { |
9363 | struct bgp *bgp; | |
9364 | ||
9365 | if (name) { | |
9366 | if (strmatch(name, "all")) { | |
9367 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
3577f1c5 | 9368 | show_failed, |
d62a17ae | 9369 | use_json); |
9370 | return CMD_SUCCESS; | |
9371 | } else { | |
9372 | bgp = bgp_lookup_by_name(name); | |
9373 | ||
9374 | if (!bgp) { | |
9375 | if (use_json) | |
9376 | vty_out(vty, "{}\n"); | |
9377 | else | |
9378 | vty_out(vty, | |
ca61fd25 | 9379 | "%% BGP instance not found\n"); |
d62a17ae | 9380 | return CMD_WARNING; |
9381 | } | |
9382 | ||
f86897b9 | 9383 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, |
3577f1c5 | 9384 | show_failed, use_json); |
d62a17ae | 9385 | return CMD_SUCCESS; |
9386 | } | |
9387 | } | |
9388 | ||
9389 | bgp = bgp_get_default(); | |
9390 | ||
9391 | if (bgp) | |
3577f1c5 DD |
9392 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, show_failed, |
9393 | use_json); | |
9f049418 | 9394 | else { |
ca61fd25 DS |
9395 | if (use_json) |
9396 | vty_out(vty, "{}\n"); | |
9397 | else | |
9398 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
9399 | return CMD_WARNING; |
9400 | } | |
d62a17ae | 9401 | |
9402 | return CMD_SUCCESS; | |
4fb25c53 DW |
9403 | } |
9404 | ||
716b2d8a | 9405 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 9406 | DEFUN (show_ip_bgp_summary, |
718e3744 | 9407 | show_ip_bgp_summary_cmd, |
3577f1c5 | 9408 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [failed] [json]", |
718e3744 | 9409 | SHOW_STR |
9410 | IP_STR | |
9411 | BGP_STR | |
8386ac43 | 9412 | BGP_INSTANCE_HELP_STR |
46f296b4 | 9413 | BGP_AFI_HELP_STR |
dd6bd0f1 | 9414 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 9415 | "Summary of BGP neighbor status\n" |
3577f1c5 | 9416 | "Show only sessions not in Established state\n" |
9973d184 | 9417 | JSON_STR) |
718e3744 | 9418 | { |
d62a17ae | 9419 | char *vrf = NULL; |
9420 | afi_t afi = AFI_MAX; | |
9421 | safi_t safi = SAFI_MAX; | |
3577f1c5 | 9422 | bool show_failed = false; |
d62a17ae | 9423 | |
9424 | int idx = 0; | |
9425 | ||
9426 | /* show [ip] bgp */ | |
9427 | if (argv_find(argv, argc, "ip", &idx)) | |
9428 | afi = AFI_IP; | |
9a8bdf1c PG |
9429 | /* [<vrf> VIEWVRFNAME] */ |
9430 | if (argv_find(argv, argc, "vrf", &idx)) { | |
9431 | vrf = argv[idx + 1]->arg; | |
9432 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
9433 | vrf = NULL; | |
9434 | } else if (argv_find(argv, argc, "view", &idx)) | |
9435 | /* [<view> VIEWVRFNAME] */ | |
9436 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 9437 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
9438 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9439 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9440 | } | |
9441 | ||
3577f1c5 DD |
9442 | if (argv_find(argv, argc, "failed", &idx)) |
9443 | show_failed = true; | |
9444 | ||
9f049418 | 9445 | bool uj = use_json(argc, argv); |
d62a17ae | 9446 | |
3577f1c5 | 9447 | return bgp_show_summary_vty(vty, vrf, afi, safi, show_failed, uj); |
d62a17ae | 9448 | } |
9449 | ||
5cb5f4d0 | 9450 | const char *get_afi_safi_str(afi_t afi, safi_t safi, bool for_json) |
d62a17ae | 9451 | { |
5cb5f4d0 DD |
9452 | if (for_json) |
9453 | return get_afi_safi_json_str(afi, safi); | |
d62a17ae | 9454 | else |
5cb5f4d0 | 9455 | return get_afi_safi_vty_str(afi, safi); |
27162734 LB |
9456 | } |
9457 | ||
d62a17ae | 9458 | |
9459 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
9460 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
9461 | uint16_t adv_smcap, uint16_t adv_rmcap, |
9462 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 9463 | bool use_json, json_object *json_pref) |
d62a17ae | 9464 | { |
9465 | /* Send-Mode */ | |
9466 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9467 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
9468 | if (use_json) { | |
9469 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
9470 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9471 | json_object_string_add(json_pref, "sendMode", | |
9472 | "advertisedAndReceived"); | |
9473 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9474 | json_object_string_add(json_pref, "sendMode", | |
9475 | "advertised"); | |
9476 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9477 | json_object_string_add(json_pref, "sendMode", | |
9478 | "received"); | |
9479 | } else { | |
9480 | vty_out(vty, " Send-mode: "); | |
9481 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
9482 | vty_out(vty, "advertised"); | |
9483 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
9484 | vty_out(vty, "%sreceived", | |
9485 | CHECK_FLAG(p->af_cap[afi][safi], | |
9486 | adv_smcap) | |
9487 | ? ", " | |
9488 | : ""); | |
9489 | vty_out(vty, "\n"); | |
9490 | } | |
9491 | } | |
9492 | ||
9493 | /* Receive-Mode */ | |
9494 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9495 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
9496 | if (use_json) { | |
9497 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
9498 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9499 | json_object_string_add(json_pref, "recvMode", | |
9500 | "advertisedAndReceived"); | |
9501 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9502 | json_object_string_add(json_pref, "recvMode", | |
9503 | "advertised"); | |
9504 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9505 | json_object_string_add(json_pref, "recvMode", | |
9506 | "received"); | |
9507 | } else { | |
9508 | vty_out(vty, " Receive-mode: "); | |
9509 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
9510 | vty_out(vty, "advertised"); | |
9511 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
9512 | vty_out(vty, "%sreceived", | |
9513 | CHECK_FLAG(p->af_cap[afi][safi], | |
9514 | adv_rmcap) | |
9515 | ? ", " | |
9516 | : ""); | |
9517 | vty_out(vty, "\n"); | |
9518 | } | |
9519 | } | |
9520 | } | |
9521 | ||
13909c4f DS |
9522 | static void bgp_show_neighnor_graceful_restart_rbit(struct vty *vty, |
9523 | struct peer *p, | |
9524 | bool use_json, | |
9525 | json_object *json) | |
2986cac2 | 9526 | { |
08c2d52a | 9527 | bool rbit_status = false; |
2986cac2 | 9528 | |
9529 | if (!use_json) | |
a53ca37b | 9530 | vty_out(vty, "\n R bit: "); |
2986cac2 | 9531 | |
13909c4f DS |
9532 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_ADV) |
9533 | && (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) | |
9534 | && (p->status == Established)) { | |
2986cac2 | 9535 | |
9536 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_BIT_RCV)) | |
08c2d52a | 9537 | rbit_status = true; |
2986cac2 | 9538 | else |
08c2d52a | 9539 | rbit_status = false; |
2986cac2 | 9540 | } |
9541 | ||
9542 | if (rbit_status) { | |
9543 | if (use_json) | |
13909c4f | 9544 | json_object_boolean_true_add(json, "rBit"); |
2986cac2 | 9545 | else |
9546 | vty_out(vty, "True\n"); | |
9547 | } else { | |
9548 | if (use_json) | |
13909c4f | 9549 | json_object_boolean_false_add(json, "rBit"); |
2986cac2 | 9550 | else |
9551 | vty_out(vty, "False\n"); | |
9552 | } | |
9553 | } | |
9554 | ||
13909c4f DS |
9555 | static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, |
9556 | struct peer *peer, | |
9557 | bool use_json, | |
9558 | json_object *json) | |
2986cac2 | 9559 | { |
2bb5d39b | 9560 | const char *mode = "NotApplicable"; |
2986cac2 | 9561 | |
9562 | if (!use_json) | |
a53ca37b | 9563 | vty_out(vty, "\n Remote GR Mode: "); |
2986cac2 | 9564 | |
13909c4f DS |
9565 | if (CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9566 | && (peer->status == Established)) { | |
2986cac2 | 9567 | |
13909c4f DS |
9568 | if ((peer->nsf_af_count == 0) |
9569 | && !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9570 | |
2986cac2 | 9571 | mode = "Disable"; |
9572 | ||
13909c4f DS |
9573 | } else if (peer->nsf_af_count == 0 |
9574 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9575 | |
2986cac2 | 9576 | mode = "Helper"; |
9577 | ||
13909c4f DS |
9578 | } else if (peer->nsf_af_count != 0 |
9579 | && CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 9580 | |
2986cac2 | 9581 | mode = "Restart"; |
2986cac2 | 9582 | } |
9583 | } | |
9584 | ||
9585 | if (use_json) { | |
13909c4f | 9586 | json_object_string_add(json, "remoteGrMode", mode); |
2986cac2 | 9587 | } else |
9588 | vty_out(vty, mode, "\n"); | |
9589 | } | |
9590 | ||
13909c4f DS |
9591 | static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, |
9592 | struct peer *p, | |
9593 | bool use_json, | |
9594 | json_object *json) | |
2986cac2 | 9595 | { |
9596 | const char *mode = "Invalid"; | |
9597 | ||
9598 | if (!use_json) | |
a53ca37b | 9599 | vty_out(vty, " Local GR Mode: "); |
2986cac2 | 9600 | |
9601 | if (bgp_peer_gr_mode_get(p) == PEER_HELPER) | |
9602 | mode = "Helper"; | |
9603 | else if (bgp_peer_gr_mode_get(p) == PEER_GR) | |
9604 | mode = "Restart"; | |
9605 | else if (bgp_peer_gr_mode_get(p) == PEER_DISABLE) | |
9606 | mode = "Disable"; | |
2ba1fe69 | 9607 | else if (bgp_peer_gr_mode_get(p) == PEER_GLOBAL_INHERIT) { |
2986cac2 | 9608 | if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_HELPER) |
9609 | mode = "Helper*"; | |
9610 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_GR) | |
9611 | mode = "Restart*"; | |
9612 | else if (bgp_global_gr_mode_get(p->bgp) == GLOBAL_DISABLE) | |
9613 | mode = "Disable*"; | |
9614 | else | |
9615 | mode = "Invalid*"; | |
2ba1fe69 | 9616 | } |
2986cac2 | 9617 | |
9618 | if (use_json) { | |
13909c4f | 9619 | json_object_string_add(json, "localGrMode", mode); |
2986cac2 | 9620 | } else { |
9621 | vty_out(vty, mode, "\n"); | |
9622 | } | |
9623 | } | |
9624 | ||
13909c4f DS |
9625 | static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( |
9626 | struct vty *vty, struct peer *peer, bool use_json, json_object *json) | |
2986cac2 | 9627 | { |
2ba1fe69 | 9628 | afi_t afi; |
9629 | safi_t safi; | |
2986cac2 | 9630 | json_object *json_afi_safi = NULL; |
9631 | json_object *json_timer = NULL; | |
9632 | json_object *json_endofrib_status = NULL; | |
9e3b51a7 | 9633 | bool eor_flag = false; |
2986cac2 | 9634 | |
9635 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9636 | for (safi = SAFI_UNICAST; safi <= SAFI_MPLS_VPN; safi++) { | |
13909c4f DS |
9637 | if (!peer->afc[afi][safi]) |
9638 | continue; | |
2986cac2 | 9639 | |
13909c4f DS |
9640 | if (!CHECK_FLAG(peer->cap, PEER_CAP_RESTART_ADV) |
9641 | || !CHECK_FLAG(peer->cap, PEER_CAP_RESTART_RCV)) | |
9642 | continue; | |
9e3b51a7 | 9643 | |
13909c4f DS |
9644 | if (use_json) { |
9645 | json_afi_safi = json_object_new_object(); | |
9646 | json_endofrib_status = json_object_new_object(); | |
9647 | json_timer = json_object_new_object(); | |
9648 | } | |
2986cac2 | 9649 | |
13909c4f DS |
9650 | if (peer->eor_stime[afi][safi] |
9651 | >= peer->pkt_stime[afi][safi]) | |
9652 | eor_flag = true; | |
9653 | else | |
9654 | eor_flag = false; | |
2986cac2 | 9655 | |
13909c4f | 9656 | if (!use_json) { |
a53ca37b | 9657 | vty_out(vty, " %s:\n", |
13909c4f | 9658 | get_afi_safi_str(afi, safi, false)); |
2986cac2 | 9659 | |
a53ca37b | 9660 | vty_out(vty, " F bit: "); |
698ba8d0 | 9661 | } |
2986cac2 | 9662 | |
13909c4f DS |
9663 | if (peer->nsf[afi][safi] |
9664 | && CHECK_FLAG(peer->af_cap[afi][safi], | |
9665 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) { | |
2986cac2 | 9666 | |
13909c4f DS |
9667 | if (use_json) { |
9668 | json_object_boolean_true_add( | |
2986cac2 | 9669 | json_afi_safi, "fBit"); |
13909c4f DS |
9670 | } else |
9671 | vty_out(vty, "True\n"); | |
9672 | } else { | |
9673 | if (use_json) | |
9674 | json_object_boolean_false_add( | |
9675 | json_afi_safi, "fBit"); | |
9676 | else | |
9677 | vty_out(vty, "False\n"); | |
9678 | } | |
2986cac2 | 9679 | |
13909c4f | 9680 | if (!use_json) |
a53ca37b | 9681 | vty_out(vty, " End-of-RIB sent: "); |
2986cac2 | 9682 | |
13909c4f DS |
9683 | if (CHECK_FLAG(peer->af_sflags[afi][safi], |
9684 | PEER_STATUS_EOR_SEND)) { | |
9685 | if (use_json) { | |
9686 | json_object_boolean_true_add( | |
2986cac2 | 9687 | json_endofrib_status, |
13909c4f | 9688 | "endOfRibSend"); |
9e3b51a7 | 9689 | |
13909c4f DS |
9690 | PRINT_EOR_JSON(eor_flag); |
9691 | } else { | |
9692 | vty_out(vty, "Yes\n"); | |
9693 | vty_out(vty, | |
a53ca37b | 9694 | " End-of-RIB sent after update: "); |
2986cac2 | 9695 | |
13909c4f DS |
9696 | PRINT_EOR(eor_flag); |
9697 | } | |
9698 | } else { | |
9699 | if (use_json) { | |
9700 | json_object_boolean_false_add( | |
2986cac2 | 9701 | json_endofrib_status, |
13909c4f DS |
9702 | "endOfRibSend"); |
9703 | json_object_boolean_false_add( | |
9e3b51a7 | 9704 | json_endofrib_status, |
13909c4f DS |
9705 | "endOfRibSentAfterUpdate"); |
9706 | } else { | |
9707 | vty_out(vty, "No\n"); | |
9708 | vty_out(vty, | |
a53ca37b | 9709 | " End-of-RIB sent after update: "); |
13909c4f | 9710 | vty_out(vty, "No\n"); |
2986cac2 | 9711 | } |
13909c4f | 9712 | } |
2986cac2 | 9713 | |
a53ca37b DA |
9714 | if (!use_json) |
9715 | vty_out(vty, " End-of-RIB received: "); | |
9716 | ||
9717 | if (CHECK_FLAG(peer->af_sflags[afi][safi], | |
9718 | PEER_STATUS_EOR_RECEIVED)) { | |
9719 | if (use_json) | |
9720 | json_object_boolean_true_add( | |
9721 | json_endofrib_status, | |
9722 | "endOfRibRecv"); | |
9723 | else | |
9724 | vty_out(vty, "Yes\n"); | |
9725 | } else { | |
9726 | if (use_json) | |
9727 | json_object_boolean_false_add( | |
9728 | json_endofrib_status, | |
9729 | "endOfRibRecv"); | |
9730 | else | |
9731 | vty_out(vty, "No\n"); | |
9732 | } | |
9733 | ||
13909c4f DS |
9734 | if (use_json) { |
9735 | json_object_int_add(json_timer, | |
9736 | "stalePathTimer", | |
9737 | peer->bgp->stalepath_time); | |
2986cac2 | 9738 | |
13909c4f DS |
9739 | if (peer->t_gr_stale != NULL) { |
9740 | json_object_int_add( | |
2986cac2 | 9741 | json_timer, |
9742 | "stalePathTimerRemaining", | |
9743 | thread_timer_remain_second( | |
13909c4f DS |
9744 | peer->t_gr_stale)); |
9745 | } | |
3a75afa4 | 9746 | |
13909c4f DS |
9747 | /* Display Configured Selection |
9748 | * Deferral only when when | |
9749 | * Gr mode is enabled. | |
9750 | */ | |
9751 | if (CHECK_FLAG(peer->flags, | |
9752 | PEER_FLAG_GRACEFUL_RESTART)) { | |
9753 | json_object_int_add( | |
3a75afa4 | 9754 | json_timer, |
2986cac2 | 9755 | "selectionDeferralTimer", |
9756 | peer->bgp->stalepath_time); | |
13909c4f | 9757 | } |
2986cac2 | 9758 | |
13909c4f DS |
9759 | if (peer->bgp->gr_info[afi][safi] |
9760 | .t_select_deferral | |
9761 | != NULL) { | |
2986cac2 | 9762 | |
13909c4f | 9763 | json_object_int_add( |
2986cac2 | 9764 | json_timer, |
9765 | "selectionDeferralTimerRemaining", | |
9766 | thread_timer_remain_second( | |
13909c4f DS |
9767 | peer->bgp |
9768 | ->gr_info[afi] | |
9769 | [safi] | |
9770 | .t_select_deferral)); | |
9771 | } | |
9772 | } else { | |
a53ca37b | 9773 | vty_out(vty, " Timers:\n"); |
13909c4f | 9774 | vty_out(vty, |
a53ca37b DA |
9775 | " Configured Stale Path Time(sec): %u\n", |
9776 | peer->bgp->stalepath_time); | |
2986cac2 | 9777 | |
a53ca37b | 9778 | if (peer->t_gr_stale != NULL) |
2986cac2 | 9779 | vty_out(vty, |
a53ca37b | 9780 | " Stale Path Remaining(sec): %ld\n", |
2986cac2 | 9781 | thread_timer_remain_second( |
13909c4f | 9782 | peer->t_gr_stale)); |
13909c4f DS |
9783 | /* Display Configured Selection |
9784 | * Deferral only when when | |
9785 | * Gr mode is enabled. | |
9786 | */ | |
9787 | if (CHECK_FLAG(peer->flags, | |
a53ca37b | 9788 | PEER_FLAG_GRACEFUL_RESTART)) |
13909c4f | 9789 | vty_out(vty, |
a53ca37b | 9790 | " Configured Selection Deferral Time(sec): %u\n", |
3a75afa4 | 9791 | peer->bgp->select_defer_time); |
2986cac2 | 9792 | |
13909c4f DS |
9793 | if (peer->bgp->gr_info[afi][safi] |
9794 | .t_select_deferral | |
a53ca37b | 9795 | != NULL) |
13909c4f | 9796 | vty_out(vty, |
a53ca37b | 9797 | " Selection Deferral Time Remaining(sec): %ld\n", |
2986cac2 | 9798 | thread_timer_remain_second( |
13909c4f DS |
9799 | peer->bgp |
9800 | ->gr_info[afi] | |
9801 | [safi] | |
9802 | .t_select_deferral)); | |
2986cac2 | 9803 | } |
13909c4f DS |
9804 | if (use_json) { |
9805 | json_object_object_add(json_afi_safi, | |
9806 | "endOfRibStatus", | |
9807 | json_endofrib_status); | |
9808 | json_object_object_add(json_afi_safi, "timers", | |
9809 | json_timer); | |
9810 | json_object_object_add( | |
9811 | json, get_afi_safi_str(afi, safi, true), | |
9812 | json_afi_safi); | |
9813 | } | |
2986cac2 | 9814 | } |
9815 | } | |
9816 | } | |
9817 | ||
36235319 QY |
9818 | static void bgp_show_neighbor_graceful_restart_time(struct vty *vty, |
9819 | struct peer *p, | |
9820 | bool use_json, | |
9821 | json_object *json) | |
2986cac2 | 9822 | { |
9823 | if (use_json) { | |
9824 | json_object *json_timer = NULL; | |
9825 | ||
9826 | json_timer = json_object_new_object(); | |
9827 | ||
13909c4f DS |
9828 | json_object_int_add(json_timer, "configuredRestartTimer", |
9829 | p->bgp->restart_time); | |
2986cac2 | 9830 | |
13909c4f DS |
9831 | json_object_int_add(json_timer, "receivedRestartTimer", |
9832 | p->v_gr_restart); | |
2986cac2 | 9833 | |
13909c4f DS |
9834 | if (p->t_gr_restart != NULL) |
9835 | json_object_int_add( | |
9836 | json_timer, "restartTimerRemaining", | |
9837 | thread_timer_remain_second(p->t_gr_restart)); | |
2986cac2 | 9838 | |
9839 | json_object_object_add(json, "timers", json_timer); | |
9840 | } else { | |
9841 | ||
a53ca37b DA |
9842 | vty_out(vty, " Timers:\n"); |
9843 | vty_out(vty, " Configured Restart Time(sec): %u\n", | |
13909c4f | 9844 | p->bgp->restart_time); |
2986cac2 | 9845 | |
a53ca37b | 9846 | vty_out(vty, " Received Restart Time(sec): %u\n", |
13909c4f DS |
9847 | p->v_gr_restart); |
9848 | if (p->t_gr_restart != NULL) | |
a53ca37b | 9849 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
13909c4f | 9850 | thread_timer_remain_second(p->t_gr_restart)); |
36235319 | 9851 | if (p->t_gr_restart != NULL) { |
a53ca37b | 9852 | vty_out(vty, " Restart Time Remaining(sec): %ld\n", |
36235319 QY |
9853 | thread_timer_remain_second(p->t_gr_restart)); |
9854 | } | |
2986cac2 | 9855 | } |
9856 | } | |
9857 | ||
9858 | static void bgp_show_peer_gr_status(struct vty *vty, struct peer *p, | |
36235319 | 9859 | bool use_json, json_object *json) |
2986cac2 | 9860 | { |
9861 | char buf[SU_ADDRSTRLEN] = {0}; | |
9862 | char dn_flag[2] = {0}; | |
2b7165e7 QY |
9863 | /* '*' + v6 address of neighbor */ |
9864 | char neighborAddr[INET6_ADDRSTRLEN + 1] = {0}; | |
2986cac2 | 9865 | |
2986cac2 | 9866 | if (!p->conf_if && peer_dynamic_neighbor(p)) |
9867 | dn_flag[0] = '*'; | |
9868 | ||
9869 | if (p->conf_if) { | |
9870 | if (use_json) | |
13909c4f DS |
9871 | json_object_string_add( |
9872 | json, "neighborAddr", | |
2986cac2 | 9873 | BGP_PEER_SU_UNSPEC(p) |
13909c4f DS |
9874 | ? "none" |
9875 | : sockunion2str(&p->su, buf, | |
9876 | SU_ADDRSTRLEN)); | |
2986cac2 | 9877 | else |
13909c4f | 9878 | vty_out(vty, "BGP neighbor on %s: %s\n", p->conf_if, |
2986cac2 | 9879 | BGP_PEER_SU_UNSPEC(p) |
9880 | ? "none" | |
9881 | : sockunion2str(&p->su, buf, | |
9882 | SU_ADDRSTRLEN)); | |
9883 | } else { | |
772270f3 QY |
9884 | snprintf(neighborAddr, sizeof(neighborAddr), "%s%s", dn_flag, |
9885 | p->host); | |
2986cac2 | 9886 | |
9887 | if (use_json) | |
36235319 QY |
9888 | json_object_string_add(json, "neighborAddr", |
9889 | neighborAddr); | |
2986cac2 | 9890 | else |
36235319 | 9891 | vty_out(vty, "BGP neighbor is %s\n", neighborAddr); |
2986cac2 | 9892 | } |
9893 | ||
9894 | /* more gr info in new format */ | |
9895 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, json); | |
9896 | } | |
9897 | ||
d62a17ae | 9898 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, |
9f049418 | 9899 | safi_t safi, bool use_json, |
d62a17ae | 9900 | json_object *json_neigh) |
9901 | { | |
0291c246 MK |
9902 | struct bgp_filter *filter; |
9903 | struct peer_af *paf; | |
9904 | char orf_pfx_name[BUFSIZ]; | |
9905 | int orf_pfx_count; | |
9906 | json_object *json_af = NULL; | |
9907 | json_object *json_prefA = NULL; | |
9908 | json_object *json_prefB = NULL; | |
9909 | json_object *json_addr = NULL; | |
d62a17ae | 9910 | |
9911 | if (use_json) { | |
9912 | json_addr = json_object_new_object(); | |
9913 | json_af = json_object_new_object(); | |
9914 | filter = &p->filter[afi][safi]; | |
9915 | ||
9916 | if (peer_group_active(p)) | |
9917 | json_object_string_add(json_addr, "peerGroupMember", | |
9918 | p->group->name); | |
9919 | ||
9920 | paf = peer_af_find(p, afi, safi); | |
9921 | if (paf && PAF_SUBGRP(paf)) { | |
9922 | json_object_int_add(json_addr, "updateGroupId", | |
9923 | PAF_UPDGRP(paf)->id); | |
9924 | json_object_int_add(json_addr, "subGroupId", | |
9925 | PAF_SUBGRP(paf)->id); | |
9926 | json_object_int_add(json_addr, "packetQueueLength", | |
9927 | bpacket_queue_virtual_length(paf)); | |
9928 | } | |
9929 | ||
9930 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9931 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9932 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9933 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9934 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9935 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9936 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
9937 | json_object_int_add(json_af, "orfType", | |
9938 | ORF_TYPE_PREFIX); | |
9939 | json_prefA = json_object_new_object(); | |
9940 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
9941 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
9942 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9943 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
9944 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
9945 | use_json, json_prefA); | |
9946 | json_object_object_add(json_af, "orfPrefixList", | |
9947 | json_prefA); | |
9948 | } | |
9949 | ||
9950 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9951 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9952 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9953 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9954 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9955 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9956 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
9957 | json_object_int_add(json_af, "orfOldType", | |
9958 | ORF_TYPE_PREFIX_OLD); | |
9959 | json_prefB = json_object_new_object(); | |
9960 | bgp_show_peer_afi_orf_cap( | |
9961 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
9962 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
9963 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
9964 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
9965 | json_prefB); | |
9966 | json_object_object_add(json_af, "orfOldPrefixList", | |
9967 | json_prefB); | |
9968 | } | |
9969 | ||
9970 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
9971 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9972 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
9973 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9974 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
9975 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9976 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
9977 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9978 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
9979 | || CHECK_FLAG(p->af_cap[afi][safi], | |
9980 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
9981 | json_object_object_add(json_addr, "afDependentCap", | |
9982 | json_af); | |
9983 | else | |
9984 | json_object_free(json_af); | |
9985 | ||
772270f3 QY |
9986 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
9987 | p->host, afi, safi); | |
d62a17ae | 9988 | orf_pfx_count = prefix_bgp_show_prefix_list( |
9989 | NULL, afi, orf_pfx_name, use_json); | |
9990 | ||
9991 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9992 | PEER_STATUS_ORF_PREFIX_SEND) | |
9993 | || orf_pfx_count) { | |
9994 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9995 | PEER_STATUS_ORF_PREFIX_SEND)) | |
9996 | json_object_boolean_true_add(json_neigh, | |
9997 | "orfSent"); | |
9998 | if (orf_pfx_count) | |
9999 | json_object_int_add(json_addr, "orfRecvCounter", | |
10000 | orf_pfx_count); | |
10001 | } | |
10002 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10003 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10004 | json_object_string_add( | |
10005 | json_addr, "orfFirstUpdate", | |
10006 | "deferredUntilORFOrRouteRefreshRecvd"); | |
10007 | ||
10008 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10009 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10010 | json_object_boolean_true_add(json_addr, | |
10011 | "routeReflectorClient"); | |
10012 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10013 | PEER_FLAG_RSERVER_CLIENT)) | |
10014 | json_object_boolean_true_add(json_addr, | |
10015 | "routeServerClient"); | |
10016 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10017 | json_object_boolean_true_add(json_addr, | |
10018 | "inboundSoftConfigPermit"); | |
10019 | ||
10020 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10021 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10022 | json_object_boolean_true_add( | |
10023 | json_addr, | |
10024 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
10025 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10026 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10027 | json_object_boolean_true_add( | |
10028 | json_addr, | |
10029 | "privateAsNumsReplacedInUpdatesToNbr"); | |
10030 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10031 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10032 | json_object_boolean_true_add( | |
10033 | json_addr, | |
10034 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
10035 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10036 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10037 | json_object_boolean_true_add( | |
10038 | json_addr, | |
10039 | "privateAsNumsRemovedInUpdatesToNbr"); | |
10040 | ||
dcc68b5e MS |
10041 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10042 | json_object_boolean_true_add( | |
10043 | json_addr, | |
10044 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10045 | ->type_json_name); | |
d62a17ae | 10046 | |
10047 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10048 | json_object_string_add(json_addr, | |
10049 | "overrideASNsInOutboundUpdates", | |
10050 | "ifAspathEqualRemoteAs"); | |
10051 | ||
10052 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10053 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10054 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10055 | json_object_boolean_true_add(json_addr, | |
10056 | "routerAlwaysNextHop"); | |
10057 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10058 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10059 | json_object_boolean_true_add( | |
10060 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
10061 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10062 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10063 | json_object_boolean_true_add( | |
10064 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
10065 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10066 | json_object_boolean_true_add( | |
10067 | json_addr, "unchangedMedPropogatedToNbr"); | |
10068 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10069 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10070 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
10071 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10072 | PEER_FLAG_SEND_COMMUNITY) | |
10073 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10074 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10075 | json_object_string_add(json_addr, | |
10076 | "commAttriSentToNbr", | |
10077 | "extendedAndStandard"); | |
10078 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10079 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10080 | json_object_string_add(json_addr, | |
10081 | "commAttriSentToNbr", | |
10082 | "extended"); | |
10083 | else | |
10084 | json_object_string_add(json_addr, | |
10085 | "commAttriSentToNbr", | |
10086 | "standard"); | |
10087 | } | |
10088 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10089 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10090 | if (p->default_rmap[afi][safi].name) | |
10091 | json_object_string_add( | |
10092 | json_addr, "defaultRouteMap", | |
10093 | p->default_rmap[afi][safi].name); | |
10094 | ||
10095 | if (paf && PAF_SUBGRP(paf) | |
10096 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10097 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10098 | json_object_boolean_true_add(json_addr, | |
10099 | "defaultSent"); | |
10100 | else | |
10101 | json_object_boolean_true_add(json_addr, | |
10102 | "defaultNotSent"); | |
10103 | } | |
10104 | ||
dff8f48d | 10105 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 10106 | if (is_evpn_enabled()) |
60466a63 QY |
10107 | json_object_boolean_true_add( |
10108 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
10109 | } |
10110 | ||
d62a17ae | 10111 | if (filter->plist[FILTER_IN].name |
10112 | || filter->dlist[FILTER_IN].name | |
10113 | || filter->aslist[FILTER_IN].name | |
10114 | || filter->map[RMAP_IN].name) | |
10115 | json_object_boolean_true_add(json_addr, | |
10116 | "inboundPathPolicyConfig"); | |
10117 | if (filter->plist[FILTER_OUT].name | |
10118 | || filter->dlist[FILTER_OUT].name | |
10119 | || filter->aslist[FILTER_OUT].name | |
10120 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10121 | json_object_boolean_true_add( | |
10122 | json_addr, "outboundPathPolicyConfig"); | |
10123 | ||
10124 | /* prefix-list */ | |
10125 | if (filter->plist[FILTER_IN].name) | |
10126 | json_object_string_add(json_addr, | |
10127 | "incomingUpdatePrefixFilterList", | |
10128 | filter->plist[FILTER_IN].name); | |
10129 | if (filter->plist[FILTER_OUT].name) | |
10130 | json_object_string_add(json_addr, | |
10131 | "outgoingUpdatePrefixFilterList", | |
10132 | filter->plist[FILTER_OUT].name); | |
10133 | ||
10134 | /* distribute-list */ | |
10135 | if (filter->dlist[FILTER_IN].name) | |
10136 | json_object_string_add( | |
10137 | json_addr, "incomingUpdateNetworkFilterList", | |
10138 | filter->dlist[FILTER_IN].name); | |
10139 | if (filter->dlist[FILTER_OUT].name) | |
10140 | json_object_string_add( | |
10141 | json_addr, "outgoingUpdateNetworkFilterList", | |
10142 | filter->dlist[FILTER_OUT].name); | |
10143 | ||
10144 | /* filter-list. */ | |
10145 | if (filter->aslist[FILTER_IN].name) | |
10146 | json_object_string_add(json_addr, | |
10147 | "incomingUpdateAsPathFilterList", | |
10148 | filter->aslist[FILTER_IN].name); | |
10149 | if (filter->aslist[FILTER_OUT].name) | |
10150 | json_object_string_add(json_addr, | |
10151 | "outgoingUpdateAsPathFilterList", | |
10152 | filter->aslist[FILTER_OUT].name); | |
10153 | ||
10154 | /* route-map. */ | |
10155 | if (filter->map[RMAP_IN].name) | |
10156 | json_object_string_add( | |
10157 | json_addr, "routeMapForIncomingAdvertisements", | |
10158 | filter->map[RMAP_IN].name); | |
10159 | if (filter->map[RMAP_OUT].name) | |
10160 | json_object_string_add( | |
10161 | json_addr, "routeMapForOutgoingAdvertisements", | |
10162 | filter->map[RMAP_OUT].name); | |
10163 | ||
9dac9fc8 | 10164 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10165 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10166 | && !bgp_inbound_policy_exists(p, filter)) |
10167 | json_object_string_add( | |
10168 | json_addr, "inboundEbgpRequiresPolicy", | |
10169 | "Inbound updates discarded due to missing policy"); | |
10170 | ||
10171 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10172 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10173 | && (!bgp_outbound_policy_exists(p, filter))) |
10174 | json_object_string_add( | |
10175 | json_addr, "outboundEbgpRequiresPolicy", | |
10176 | "Outbound updates discarded due to missing policy"); | |
10177 | ||
d62a17ae | 10178 | /* unsuppress-map */ |
10179 | if (filter->usmap.name) | |
10180 | json_object_string_add(json_addr, | |
10181 | "selectiveUnsuppressRouteMap", | |
10182 | filter->usmap.name); | |
10183 | ||
10184 | /* Receive prefix count */ | |
10185 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
10186 | p->pcount[afi][safi]); | |
50e05855 AD |
10187 | if (paf && PAF_SUBGRP(paf)) |
10188 | json_object_int_add(json_addr, "sentPrefixCounter", | |
10189 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 10190 | |
fde246e8 DA |
10191 | /* Maximum prefix */ |
10192 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_OUT)) | |
10193 | json_object_int_add(json_addr, "prefixOutAllowedMax", | |
10194 | p->pmax_out[afi][safi]); | |
10195 | ||
d62a17ae | 10196 | /* Maximum prefix */ |
10197 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
10198 | json_object_int_add(json_addr, "prefixAllowedMax", | |
10199 | p->pmax[afi][safi]); | |
10200 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10201 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
10202 | json_object_boolean_true_add( | |
10203 | json_addr, "prefixAllowedMaxWarning"); | |
10204 | json_object_int_add(json_addr, | |
10205 | "prefixAllowedWarningThresh", | |
10206 | p->pmax_threshold[afi][safi]); | |
10207 | if (p->pmax_restart[afi][safi]) | |
10208 | json_object_int_add( | |
10209 | json_addr, | |
10210 | "prefixAllowedRestartIntervalMsecs", | |
10211 | p->pmax_restart[afi][safi] * 60000); | |
10212 | } | |
2986cac2 | 10213 | json_object_object_add(json_neigh, |
36235319 | 10214 | get_afi_safi_str(afi, safi, true), |
d62a17ae | 10215 | json_addr); |
10216 | ||
10217 | } else { | |
10218 | filter = &p->filter[afi][safi]; | |
10219 | ||
10220 | vty_out(vty, " For address family: %s\n", | |
5cb5f4d0 | 10221 | get_afi_safi_str(afi, safi, false)); |
d62a17ae | 10222 | |
10223 | if (peer_group_active(p)) | |
10224 | vty_out(vty, " %s peer-group member\n", | |
10225 | p->group->name); | |
10226 | ||
10227 | paf = peer_af_find(p, afi, safi); | |
10228 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
10229 | vty_out(vty, " Update group %" PRIu64 |
10230 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 10231 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
10232 | vty_out(vty, " Packet Queue length %d\n", | |
10233 | bpacket_queue_virtual_length(paf)); | |
10234 | } else { | |
10235 | vty_out(vty, " Not part of any update group\n"); | |
10236 | } | |
10237 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10238 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10239 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10240 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10241 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10242 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10243 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10244 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10245 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
10246 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10247 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
10248 | vty_out(vty, " AF-dependant capabilities:\n"); | |
10249 | ||
10250 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10251 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10252 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
10253 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10254 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10255 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10256 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
10257 | vty_out(vty, | |
10258 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10259 | ORF_TYPE_PREFIX); | |
10260 | bgp_show_peer_afi_orf_cap( | |
10261 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10262 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10263 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
10264 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
10265 | } | |
10266 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
10267 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10268 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
10269 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10270 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
10271 | || CHECK_FLAG(p->af_cap[afi][safi], | |
10272 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
10273 | vty_out(vty, | |
10274 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
10275 | ORF_TYPE_PREFIX_OLD); | |
10276 | bgp_show_peer_afi_orf_cap( | |
10277 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
10278 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
10279 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
10280 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
10281 | } | |
10282 | ||
772270f3 QY |
10283 | snprintf(orf_pfx_name, sizeof(orf_pfx_name), "%s.%d.%d", |
10284 | p->host, afi, safi); | |
d62a17ae | 10285 | orf_pfx_count = prefix_bgp_show_prefix_list( |
10286 | NULL, afi, orf_pfx_name, use_json); | |
10287 | ||
10288 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10289 | PEER_STATUS_ORF_PREFIX_SEND) | |
10290 | || orf_pfx_count) { | |
10291 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
10292 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10293 | PEER_STATUS_ORF_PREFIX_SEND)) | |
10294 | vty_out(vty, " sent;"); | |
10295 | if (orf_pfx_count) | |
10296 | vty_out(vty, " received (%d entries)", | |
10297 | orf_pfx_count); | |
10298 | vty_out(vty, "\n"); | |
10299 | } | |
10300 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10301 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
10302 | vty_out(vty, | |
10303 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
10304 | ||
10305 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10306 | PEER_FLAG_REFLECTOR_CLIENT)) | |
10307 | vty_out(vty, " Route-Reflector Client\n"); | |
10308 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10309 | PEER_FLAG_RSERVER_CLIENT)) | |
10310 | vty_out(vty, " Route-Server Client\n"); | |
10311 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
10312 | vty_out(vty, | |
10313 | " Inbound soft reconfiguration allowed\n"); | |
10314 | ||
10315 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10316 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
10317 | vty_out(vty, | |
10318 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
10319 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10320 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
10321 | vty_out(vty, | |
10322 | " Private AS numbers replaced in updates to this neighbor\n"); | |
10323 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10324 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
10325 | vty_out(vty, | |
10326 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
10327 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10328 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
10329 | vty_out(vty, | |
10330 | " Private AS numbers removed in updates to this neighbor\n"); | |
10331 | ||
dcc68b5e MS |
10332 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
10333 | vty_out(vty, " %s\n", | |
10334 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
10335 | ->human_description); | |
d62a17ae | 10336 | |
10337 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
10338 | vty_out(vty, | |
10339 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
10340 | ||
10341 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
10342 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10343 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
10344 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
10345 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10346 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
10347 | vty_out(vty, | |
10348 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
10349 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10350 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
10351 | vty_out(vty, | |
10352 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
10353 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
10354 | vty_out(vty, | |
10355 | " MED is propagated unchanged to this neighbor\n"); | |
10356 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
10357 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10358 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10359 | || CHECK_FLAG(p->af_flags[afi][safi], | |
10360 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
10361 | vty_out(vty, | |
10362 | " Community attribute sent to this neighbor"); | |
10363 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10364 | PEER_FLAG_SEND_COMMUNITY) | |
10365 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10366 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
10367 | && CHECK_FLAG(p->af_flags[afi][safi], | |
10368 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10369 | vty_out(vty, "(all)\n"); | |
10370 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10371 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
10372 | vty_out(vty, "(large)\n"); | |
10373 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
10374 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
10375 | vty_out(vty, "(extended)\n"); | |
10376 | else | |
10377 | vty_out(vty, "(standard)\n"); | |
10378 | } | |
10379 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10380 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
10381 | vty_out(vty, " Default information originate,"); | |
10382 | ||
10383 | if (p->default_rmap[afi][safi].name) | |
10384 | vty_out(vty, " default route-map %s%s,", | |
10385 | p->default_rmap[afi][safi].map ? "*" | |
10386 | : "", | |
10387 | p->default_rmap[afi][safi].name); | |
10388 | if (paf && PAF_SUBGRP(paf) | |
10389 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
10390 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
10391 | vty_out(vty, " default sent\n"); | |
10392 | else | |
10393 | vty_out(vty, " default not sent\n"); | |
10394 | } | |
10395 | ||
dff8f48d MK |
10396 | /* advertise-vni-all */ |
10397 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 10398 | if (is_evpn_enabled()) |
dff8f48d MK |
10399 | vty_out(vty, " advertise-all-vni\n"); |
10400 | } | |
10401 | ||
d62a17ae | 10402 | if (filter->plist[FILTER_IN].name |
10403 | || filter->dlist[FILTER_IN].name | |
10404 | || filter->aslist[FILTER_IN].name | |
10405 | || filter->map[RMAP_IN].name) | |
10406 | vty_out(vty, " Inbound path policy configured\n"); | |
10407 | if (filter->plist[FILTER_OUT].name | |
10408 | || filter->dlist[FILTER_OUT].name | |
10409 | || filter->aslist[FILTER_OUT].name | |
10410 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
10411 | vty_out(vty, " Outbound path policy configured\n"); | |
10412 | ||
10413 | /* prefix-list */ | |
10414 | if (filter->plist[FILTER_IN].name) | |
10415 | vty_out(vty, | |
10416 | " Incoming update prefix filter list is %s%s\n", | |
10417 | filter->plist[FILTER_IN].plist ? "*" : "", | |
10418 | filter->plist[FILTER_IN].name); | |
10419 | if (filter->plist[FILTER_OUT].name) | |
10420 | vty_out(vty, | |
10421 | " Outgoing update prefix filter list is %s%s\n", | |
10422 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
10423 | filter->plist[FILTER_OUT].name); | |
10424 | ||
10425 | /* distribute-list */ | |
10426 | if (filter->dlist[FILTER_IN].name) | |
10427 | vty_out(vty, | |
10428 | " Incoming update network filter list is %s%s\n", | |
10429 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
10430 | filter->dlist[FILTER_IN].name); | |
10431 | if (filter->dlist[FILTER_OUT].name) | |
10432 | vty_out(vty, | |
10433 | " Outgoing update network filter list is %s%s\n", | |
10434 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
10435 | filter->dlist[FILTER_OUT].name); | |
10436 | ||
10437 | /* filter-list. */ | |
10438 | if (filter->aslist[FILTER_IN].name) | |
10439 | vty_out(vty, | |
10440 | " Incoming update AS path filter list is %s%s\n", | |
10441 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
10442 | filter->aslist[FILTER_IN].name); | |
10443 | if (filter->aslist[FILTER_OUT].name) | |
10444 | vty_out(vty, | |
10445 | " Outgoing update AS path filter list is %s%s\n", | |
10446 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
10447 | filter->aslist[FILTER_OUT].name); | |
10448 | ||
10449 | /* route-map. */ | |
10450 | if (filter->map[RMAP_IN].name) | |
10451 | vty_out(vty, | |
10452 | " Route map for incoming advertisements is %s%s\n", | |
10453 | filter->map[RMAP_IN].map ? "*" : "", | |
10454 | filter->map[RMAP_IN].name); | |
10455 | if (filter->map[RMAP_OUT].name) | |
10456 | vty_out(vty, | |
10457 | " Route map for outgoing advertisements is %s%s\n", | |
10458 | filter->map[RMAP_OUT].map ? "*" : "", | |
10459 | filter->map[RMAP_OUT].name); | |
10460 | ||
9dac9fc8 | 10461 | /* ebgp-requires-policy (inbound) */ |
1d3fdccf | 10462 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10463 | && !bgp_inbound_policy_exists(p, filter)) |
10464 | vty_out(vty, | |
10465 | " Inbound updates discarded due to missing policy\n"); | |
10466 | ||
10467 | /* ebgp-requires-policy (outbound) */ | |
1d3fdccf | 10468 | if (CHECK_FLAG(p->bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
9dac9fc8 DA |
10469 | && !bgp_outbound_policy_exists(p, filter)) |
10470 | vty_out(vty, | |
10471 | " Outbound updates discarded due to missing policy\n"); | |
10472 | ||
d62a17ae | 10473 | /* unsuppress-map */ |
10474 | if (filter->usmap.name) | |
10475 | vty_out(vty, | |
10476 | " Route map for selective unsuppress is %s%s\n", | |
10477 | filter->usmap.map ? "*" : "", | |
10478 | filter->usmap.name); | |
10479 | ||
10480 | /* Receive prefix count */ | |
a0a87037 DA |
10481 | vty_out(vty, " %" PRIu32 " accepted prefixes\n", |
10482 | p->pcount[afi][safi]); | |
d62a17ae | 10483 | |
fde246e8 DA |
10484 | /* maximum-prefix-out */ |
10485 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
10486 | PEER_FLAG_MAX_PREFIX_OUT)) | |
10487 | vty_out(vty, | |
10488 | " Maximum allowed prefixes sent %" PRIu32 "\n", | |
10489 | p->pmax_out[afi][safi]); | |
10490 | ||
d62a17ae | 10491 | /* Maximum prefix */ |
10492 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
a0a87037 DA |
10493 | vty_out(vty, |
10494 | " Maximum prefixes allowed %" PRIu32 "%s\n", | |
d62a17ae | 10495 | p->pmax[afi][safi], |
10496 | CHECK_FLAG(p->af_flags[afi][safi], | |
10497 | PEER_FLAG_MAX_PREFIX_WARNING) | |
10498 | ? " (warning-only)" | |
10499 | : ""); | |
10500 | vty_out(vty, " Threshold for warning message %d%%", | |
10501 | p->pmax_threshold[afi][safi]); | |
10502 | if (p->pmax_restart[afi][safi]) | |
10503 | vty_out(vty, ", restart interval %d min", | |
10504 | p->pmax_restart[afi][safi]); | |
10505 | vty_out(vty, "\n"); | |
10506 | } | |
10507 | ||
10508 | vty_out(vty, "\n"); | |
10509 | } | |
10510 | } | |
10511 | ||
9f049418 | 10512 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 10513 | json_object *json) |
718e3744 | 10514 | { |
d62a17ae | 10515 | struct bgp *bgp; |
10516 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
10517 | char timebuf[BGP_UPTIME_LEN]; | |
10518 | char dn_flag[2]; | |
d62a17ae | 10519 | afi_t afi; |
10520 | safi_t safi; | |
d7c0a89a QY |
10521 | uint16_t i; |
10522 | uint8_t *msg; | |
d62a17ae | 10523 | json_object *json_neigh = NULL; |
10524 | time_t epoch_tbuf; | |
718e3744 | 10525 | |
d62a17ae | 10526 | bgp = p->bgp; |
10527 | ||
10528 | if (use_json) | |
10529 | json_neigh = json_object_new_object(); | |
10530 | ||
10531 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
10532 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
10533 | dn_flag[0] = '*'; | |
10534 | ||
10535 | if (!use_json) { | |
10536 | if (p->conf_if) /* Configured interface name. */ | |
10537 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
10538 | BGP_PEER_SU_UNSPEC(p) | |
10539 | ? "None" | |
10540 | : sockunion2str(&p->su, buf, | |
10541 | SU_ADDRSTRLEN)); | |
10542 | else /* Configured IP address. */ | |
10543 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
10544 | p->host); | |
10545 | } | |
10546 | ||
10547 | if (use_json) { | |
10548 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
10549 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
10550 | "none"); | |
10551 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
10552 | json_object_string_add( | |
10553 | json_neigh, "bgpNeighborAddr", | |
10554 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
10555 | ||
10556 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
10557 | ||
10558 | if (p->change_local_as) | |
10559 | json_object_int_add(json_neigh, "localAs", | |
10560 | p->change_local_as); | |
10561 | else | |
10562 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
10563 | ||
10564 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
10565 | json_object_boolean_true_add(json_neigh, | |
10566 | "localAsNoPrepend"); | |
10567 | ||
10568 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
10569 | json_object_boolean_true_add(json_neigh, | |
10570 | "localAsReplaceAs"); | |
10571 | } else { | |
10572 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
10573 | || (p->as_type == AS_INTERNAL)) | |
10574 | vty_out(vty, "remote AS %u, ", p->as); | |
10575 | else | |
10576 | vty_out(vty, "remote AS Unspecified, "); | |
10577 | vty_out(vty, "local AS %u%s%s, ", | |
10578 | p->change_local_as ? p->change_local_as : p->local_as, | |
10579 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
10580 | ? " no-prepend" | |
10581 | : "", | |
10582 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
10583 | ? " replace-as" | |
10584 | : ""); | |
10585 | } | |
faa16034 DS |
10586 | /* peer type internal or confed-internal */ |
10587 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 10588 | if (use_json) { |
10589 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10590 | json_object_boolean_true_add( | |
10591 | json_neigh, "nbrConfedInternalLink"); | |
10592 | else | |
10593 | json_object_boolean_true_add(json_neigh, | |
10594 | "nbrInternalLink"); | |
10595 | } else { | |
10596 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10597 | vty_out(vty, "confed-internal link\n"); | |
10598 | else | |
10599 | vty_out(vty, "internal link\n"); | |
10600 | } | |
faa16034 DS |
10601 | /* peer type external or confed-external */ |
10602 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 10603 | if (use_json) { |
10604 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
10605 | json_object_boolean_true_add( | |
10606 | json_neigh, "nbrConfedExternalLink"); | |
10607 | else | |
10608 | json_object_boolean_true_add(json_neigh, | |
10609 | "nbrExternalLink"); | |
10610 | } else { | |
10611 | if (bgp_confederation_peers_check(bgp, p->as)) | |
10612 | vty_out(vty, "confed-external link\n"); | |
10613 | else | |
10614 | vty_out(vty, "external link\n"); | |
10615 | } | |
faa16034 DS |
10616 | } else { |
10617 | if (use_json) | |
10618 | json_object_boolean_true_add(json_neigh, | |
10619 | "nbrUnspecifiedLink"); | |
10620 | else | |
10621 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 10622 | } |
10623 | ||
10624 | /* Description. */ | |
10625 | if (p->desc) { | |
10626 | if (use_json) | |
10627 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
10628 | else | |
10629 | vty_out(vty, " Description: %s\n", p->desc); | |
10630 | } | |
10631 | ||
10632 | if (p->hostname) { | |
10633 | if (use_json) { | |
10634 | if (p->hostname) | |
10635 | json_object_string_add(json_neigh, "hostname", | |
10636 | p->hostname); | |
10637 | ||
10638 | if (p->domainname) | |
10639 | json_object_string_add(json_neigh, "domainname", | |
10640 | p->domainname); | |
10641 | } else { | |
10642 | if (p->domainname && (p->domainname[0] != '\0')) | |
10643 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
10644 | p->domainname); | |
10645 | else | |
10646 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
10647 | } | |
10648 | } | |
10649 | ||
10650 | /* Peer-group */ | |
10651 | if (p->group) { | |
10652 | if (use_json) { | |
10653 | json_object_string_add(json_neigh, "peerGroup", | |
10654 | p->group->name); | |
10655 | ||
10656 | if (dn_flag[0]) { | |
10657 | struct prefix prefix, *range = NULL; | |
10658 | ||
10659 | sockunion2hostprefix(&(p->su), &prefix); | |
10660 | range = peer_group_lookup_dynamic_neighbor_range( | |
10661 | p->group, &prefix); | |
10662 | ||
10663 | if (range) { | |
10664 | prefix2str(range, buf1, sizeof(buf1)); | |
10665 | json_object_string_add( | |
10666 | json_neigh, | |
10667 | "peerSubnetRangeGroup", buf1); | |
10668 | } | |
10669 | } | |
10670 | } else { | |
10671 | vty_out(vty, | |
10672 | " Member of peer-group %s for session parameters\n", | |
10673 | p->group->name); | |
10674 | ||
10675 | if (dn_flag[0]) { | |
10676 | struct prefix prefix, *range = NULL; | |
10677 | ||
10678 | sockunion2hostprefix(&(p->su), &prefix); | |
10679 | range = peer_group_lookup_dynamic_neighbor_range( | |
10680 | p->group, &prefix); | |
10681 | ||
10682 | if (range) { | |
10683 | prefix2str(range, buf1, sizeof(buf1)); | |
10684 | vty_out(vty, | |
10685 | " Belongs to the subnet range group: %s\n", | |
10686 | buf1); | |
10687 | } | |
10688 | } | |
10689 | } | |
10690 | } | |
10691 | ||
10692 | if (use_json) { | |
10693 | /* Administrative shutdown. */ | |
10694 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10695 | json_object_boolean_true_add(json_neigh, | |
10696 | "adminShutDown"); | |
10697 | ||
10698 | /* BGP Version. */ | |
10699 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
10700 | json_object_string_add( | |
10701 | json_neigh, "remoteRouterId", | |
10702 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
10703 | json_object_string_add( |
10704 | json_neigh, "localRouterId", | |
10705 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10706 | sizeof(buf1))); | |
d62a17ae | 10707 | |
10708 | /* Confederation */ | |
10709 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10710 | && bgp_confederation_peers_check(bgp, p->as)) | |
10711 | json_object_boolean_true_add(json_neigh, | |
10712 | "nbrCommonAdmin"); | |
10713 | ||
10714 | /* Status. */ | |
10715 | json_object_string_add( | |
10716 | json_neigh, "bgpState", | |
10717 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10718 | ||
10719 | if (p->status == Established) { | |
10720 | time_t uptime; | |
d62a17ae | 10721 | |
10722 | uptime = bgp_clock(); | |
10723 | uptime -= p->uptime; | |
d62a17ae | 10724 | epoch_tbuf = time(NULL) - uptime; |
10725 | ||
d3c7efed DS |
10726 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
10727 | uptime * 1000); | |
d62a17ae | 10728 | json_object_string_add(json_neigh, "bgpTimerUpString", |
10729 | peer_uptime(p->uptime, timebuf, | |
10730 | BGP_UPTIME_LEN, 0, | |
10731 | NULL)); | |
10732 | json_object_int_add(json_neigh, | |
10733 | "bgpTimerUpEstablishedEpoch", | |
10734 | epoch_tbuf); | |
10735 | } | |
10736 | ||
10737 | else if (p->status == Active) { | |
10738 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10739 | json_object_string_add(json_neigh, "bgpStateIs", | |
10740 | "passive"); | |
10741 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10742 | json_object_string_add(json_neigh, "bgpStateIs", | |
10743 | "passiveNSF"); | |
10744 | } | |
10745 | ||
10746 | /* read timer */ | |
10747 | time_t uptime; | |
a2700b50 | 10748 | struct tm tm; |
d62a17ae | 10749 | |
10750 | uptime = bgp_clock(); | |
10751 | uptime -= p->readtime; | |
a2700b50 MS |
10752 | gmtime_r(&uptime, &tm); |
10753 | ||
d62a17ae | 10754 | json_object_int_add(json_neigh, "bgpTimerLastRead", |
a2700b50 MS |
10755 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10756 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10757 | |
10758 | uptime = bgp_clock(); | |
10759 | uptime -= p->last_write; | |
a2700b50 MS |
10760 | gmtime_r(&uptime, &tm); |
10761 | ||
d62a17ae | 10762 | json_object_int_add(json_neigh, "bgpTimerLastWrite", |
a2700b50 MS |
10763 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10764 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10765 | |
10766 | uptime = bgp_clock(); | |
10767 | uptime -= p->update_time; | |
a2700b50 MS |
10768 | gmtime_r(&uptime, &tm); |
10769 | ||
d62a17ae | 10770 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", |
a2700b50 MS |
10771 | (tm.tm_sec * 1000) + (tm.tm_min * 60000) |
10772 | + (tm.tm_hour * 3600000)); | |
d62a17ae | 10773 | |
10774 | /* Configured timer values. */ | |
10775 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
10776 | p->v_holdtime * 1000); | |
10777 | json_object_int_add(json_neigh, | |
10778 | "bgpTimerKeepAliveIntervalMsecs", | |
10779 | p->v_keepalive * 1000); | |
b90a8e13 | 10780 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10781 | json_object_int_add(json_neigh, |
10782 | "bgpTimerConfiguredHoldTimeMsecs", | |
10783 | p->holdtime * 1000); | |
10784 | json_object_int_add( | |
10785 | json_neigh, | |
10786 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10787 | p->keepalive * 1000); | |
5d5393b9 DL |
10788 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10789 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10790 | json_object_int_add(json_neigh, |
10791 | "bgpTimerConfiguredHoldTimeMsecs", | |
10792 | bgp->default_holdtime); | |
10793 | json_object_int_add( | |
10794 | json_neigh, | |
10795 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
10796 | bgp->default_keepalive); | |
d62a17ae | 10797 | } |
10798 | } else { | |
10799 | /* Administrative shutdown. */ | |
10800 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
10801 | vty_out(vty, " Administratively shut down\n"); | |
10802 | ||
10803 | /* BGP Version. */ | |
10804 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 10805 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 10806 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
10807 | vty_out(vty, ", local router ID %s\n", |
10808 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
10809 | sizeof(buf1))); | |
d62a17ae | 10810 | |
10811 | /* Confederation */ | |
10812 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
10813 | && bgp_confederation_peers_check(bgp, p->as)) | |
10814 | vty_out(vty, | |
10815 | " Neighbor under common administration\n"); | |
10816 | ||
10817 | /* Status. */ | |
10818 | vty_out(vty, " BGP state = %s", | |
10819 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
10820 | ||
10821 | if (p->status == Established) | |
10822 | vty_out(vty, ", up for %8s", | |
10823 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
10824 | 0, NULL)); | |
10825 | ||
10826 | else if (p->status == Active) { | |
10827 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
10828 | vty_out(vty, " (passive)"); | |
10829 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
10830 | vty_out(vty, " (NSF passive)"); | |
10831 | } | |
10832 | vty_out(vty, "\n"); | |
10833 | ||
10834 | /* read timer */ | |
10835 | vty_out(vty, " Last read %s", | |
10836 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
10837 | NULL)); | |
10838 | vty_out(vty, ", Last write %s\n", | |
10839 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
10840 | NULL)); | |
10841 | ||
10842 | /* Configured timer values. */ | |
10843 | vty_out(vty, | |
10844 | " Hold time is %d, keepalive interval is %d seconds\n", | |
10845 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 10846 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 10847 | vty_out(vty, " Configured hold time is %d", |
10848 | p->holdtime); | |
10849 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10850 | p->keepalive); | |
5d5393b9 DL |
10851 | } else if ((bgp->default_holdtime != SAVE_BGP_HOLDTIME) |
10852 | || (bgp->default_keepalive != SAVE_BGP_KEEPALIVE)) { | |
d25e4efc DS |
10853 | vty_out(vty, " Configured hold time is %d", |
10854 | bgp->default_holdtime); | |
10855 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
10856 | bgp->default_keepalive); | |
d62a17ae | 10857 | } |
10858 | } | |
10859 | /* Capability. */ | |
10860 | if (p->status == Established) { | |
10861 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
10862 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
10863 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
10864 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
10865 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
10866 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
10867 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
10868 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
10869 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
10870 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
10871 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
10872 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 10873 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
10874 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 10875 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
10876 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 10877 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
10878 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 10879 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
10880 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
10881 | if (use_json) { | |
10882 | json_object *json_cap = NULL; | |
10883 | ||
10884 | json_cap = json_object_new_object(); | |
10885 | ||
10886 | /* AS4 */ | |
10887 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10888 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10889 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
10890 | && CHECK_FLAG(p->cap, | |
10891 | PEER_CAP_AS4_RCV)) | |
10892 | json_object_string_add( | |
10893 | json_cap, "4byteAs", | |
10894 | "advertisedAndReceived"); | |
10895 | else if (CHECK_FLAG(p->cap, | |
10896 | PEER_CAP_AS4_ADV)) | |
10897 | json_object_string_add( | |
10898 | json_cap, "4byteAs", | |
10899 | "advertised"); | |
10900 | else if (CHECK_FLAG(p->cap, | |
10901 | PEER_CAP_AS4_RCV)) | |
10902 | json_object_string_add( | |
10903 | json_cap, "4byteAs", | |
10904 | "received"); | |
10905 | } | |
10906 | ||
10907 | /* AddPath */ | |
10908 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10909 | || CHECK_FLAG(p->cap, | |
10910 | PEER_CAP_ADDPATH_ADV)) { | |
10911 | json_object *json_add = NULL; | |
10912 | const char *print_store; | |
10913 | ||
10914 | json_add = json_object_new_object(); | |
10915 | ||
05c7a1cc QY |
10916 | FOREACH_AFI_SAFI (afi, safi) { |
10917 | json_object *json_sub = NULL; | |
10918 | json_sub = | |
10919 | json_object_new_object(); | |
5cb5f4d0 DD |
10920 | print_store = get_afi_safi_str( |
10921 | afi, safi, true); | |
d62a17ae | 10922 | |
05c7a1cc QY |
10923 | if (CHECK_FLAG( |
10924 | p->af_cap[afi] | |
10925 | [safi], | |
10926 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10927 | || CHECK_FLAG( | |
10928 | p->af_cap[afi] | |
10929 | [safi], | |
10930 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 10931 | if (CHECK_FLAG( |
10932 | p->af_cap | |
10933 | [afi] | |
10934 | [safi], | |
10935 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 10936 | && CHECK_FLAG( |
d62a17ae | 10937 | p->af_cap |
10938 | [afi] | |
10939 | [safi], | |
05c7a1cc QY |
10940 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
10941 | json_object_boolean_true_add( | |
10942 | json_sub, | |
10943 | "txAdvertisedAndReceived"); | |
10944 | else if ( | |
10945 | CHECK_FLAG( | |
10946 | p->af_cap | |
10947 | [afi] | |
10948 | [safi], | |
10949 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
10950 | json_object_boolean_true_add( | |
10951 | json_sub, | |
10952 | "txAdvertised"); | |
10953 | else if ( | |
10954 | CHECK_FLAG( | |
10955 | p->af_cap | |
10956 | [afi] | |
10957 | [safi], | |
10958 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10959 | json_object_boolean_true_add( | |
10960 | json_sub, | |
10961 | "txReceived"); | |
10962 | } | |
d62a17ae | 10963 | |
05c7a1cc QY |
10964 | if (CHECK_FLAG( |
10965 | p->af_cap[afi] | |
10966 | [safi], | |
10967 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10968 | || CHECK_FLAG( | |
10969 | p->af_cap[afi] | |
10970 | [safi], | |
10971 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 10972 | if (CHECK_FLAG( |
10973 | p->af_cap | |
10974 | [afi] | |
10975 | [safi], | |
10976 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 10977 | && CHECK_FLAG( |
d62a17ae | 10978 | p->af_cap |
10979 | [afi] | |
10980 | [safi], | |
10981 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
10982 | json_object_boolean_true_add( |
10983 | json_sub, | |
10984 | "rxAdvertisedAndReceived"); | |
10985 | else if ( | |
10986 | CHECK_FLAG( | |
10987 | p->af_cap | |
10988 | [afi] | |
10989 | [safi], | |
10990 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
10991 | json_object_boolean_true_add( | |
10992 | json_sub, | |
10993 | "rxAdvertised"); | |
10994 | else if ( | |
10995 | CHECK_FLAG( | |
10996 | p->af_cap | |
10997 | [afi] | |
10998 | [safi], | |
10999 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11000 | json_object_boolean_true_add( | |
11001 | json_sub, | |
11002 | "rxReceived"); | |
d62a17ae | 11003 | } |
11004 | ||
05c7a1cc QY |
11005 | if (CHECK_FLAG( |
11006 | p->af_cap[afi] | |
11007 | [safi], | |
11008 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11009 | || CHECK_FLAG( | |
11010 | p->af_cap[afi] | |
11011 | [safi], | |
11012 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
11013 | || CHECK_FLAG( | |
11014 | p->af_cap[afi] | |
11015 | [safi], | |
11016 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11017 | || CHECK_FLAG( | |
11018 | p->af_cap[afi] | |
11019 | [safi], | |
11020 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
11021 | json_object_object_add( | |
11022 | json_add, | |
11023 | print_store, | |
11024 | json_sub); | |
11025 | else | |
11026 | json_object_free( | |
11027 | json_sub); | |
11028 | } | |
11029 | ||
d62a17ae | 11030 | json_object_object_add( |
11031 | json_cap, "addPath", json_add); | |
11032 | } | |
11033 | ||
11034 | /* Dynamic */ | |
11035 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11036 | || CHECK_FLAG(p->cap, | |
11037 | PEER_CAP_DYNAMIC_ADV)) { | |
11038 | if (CHECK_FLAG(p->cap, | |
11039 | PEER_CAP_DYNAMIC_ADV) | |
11040 | && CHECK_FLAG(p->cap, | |
11041 | PEER_CAP_DYNAMIC_RCV)) | |
11042 | json_object_string_add( | |
11043 | json_cap, "dynamic", | |
11044 | "advertisedAndReceived"); | |
11045 | else if (CHECK_FLAG( | |
11046 | p->cap, | |
11047 | PEER_CAP_DYNAMIC_ADV)) | |
11048 | json_object_string_add( | |
11049 | json_cap, "dynamic", | |
11050 | "advertised"); | |
11051 | else if (CHECK_FLAG( | |
11052 | p->cap, | |
11053 | PEER_CAP_DYNAMIC_RCV)) | |
11054 | json_object_string_add( | |
11055 | json_cap, "dynamic", | |
11056 | "received"); | |
11057 | } | |
11058 | ||
11059 | /* Extended nexthop */ | |
11060 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11061 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11062 | json_object *json_nxt = NULL; | |
11063 | const char *print_store; | |
11064 | ||
11065 | ||
11066 | if (CHECK_FLAG(p->cap, | |
11067 | PEER_CAP_ENHE_ADV) | |
11068 | && CHECK_FLAG(p->cap, | |
11069 | PEER_CAP_ENHE_RCV)) | |
11070 | json_object_string_add( | |
11071 | json_cap, | |
11072 | "extendedNexthop", | |
11073 | "advertisedAndReceived"); | |
11074 | else if (CHECK_FLAG(p->cap, | |
11075 | PEER_CAP_ENHE_ADV)) | |
11076 | json_object_string_add( | |
11077 | json_cap, | |
11078 | "extendedNexthop", | |
11079 | "advertised"); | |
11080 | else if (CHECK_FLAG(p->cap, | |
11081 | PEER_CAP_ENHE_RCV)) | |
11082 | json_object_string_add( | |
11083 | json_cap, | |
11084 | "extendedNexthop", | |
11085 | "received"); | |
11086 | ||
11087 | if (CHECK_FLAG(p->cap, | |
11088 | PEER_CAP_ENHE_RCV)) { | |
11089 | json_nxt = | |
11090 | json_object_new_object(); | |
11091 | ||
11092 | for (safi = SAFI_UNICAST; | |
11093 | safi < SAFI_MAX; safi++) { | |
11094 | if (CHECK_FLAG( | |
11095 | p->af_cap | |
11096 | [AFI_IP] | |
11097 | [safi], | |
11098 | PEER_CAP_ENHE_AF_RCV)) { | |
5cb5f4d0 | 11099 | print_store = get_afi_safi_str( |
d62a17ae | 11100 | AFI_IP, |
5cb5f4d0 | 11101 | safi, true); |
d62a17ae | 11102 | json_object_string_add( |
11103 | json_nxt, | |
11104 | print_store, | |
54f29523 | 11105 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 11106 | } |
11107 | } | |
11108 | json_object_object_add( | |
11109 | json_cap, | |
11110 | "extendedNexthopFamililesByPeer", | |
11111 | json_nxt); | |
11112 | } | |
11113 | } | |
11114 | ||
11115 | /* Route Refresh */ | |
11116 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11117 | || CHECK_FLAG(p->cap, | |
11118 | PEER_CAP_REFRESH_NEW_RCV) | |
11119 | || CHECK_FLAG(p->cap, | |
11120 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11121 | if (CHECK_FLAG(p->cap, | |
11122 | PEER_CAP_REFRESH_ADV) | |
11123 | && (CHECK_FLAG( | |
11124 | p->cap, | |
11125 | PEER_CAP_REFRESH_NEW_RCV) | |
11126 | || CHECK_FLAG( | |
11127 | p->cap, | |
11128 | PEER_CAP_REFRESH_OLD_RCV))) { | |
11129 | if (CHECK_FLAG( | |
11130 | p->cap, | |
11131 | PEER_CAP_REFRESH_OLD_RCV) | |
11132 | && CHECK_FLAG( | |
11133 | p->cap, | |
11134 | PEER_CAP_REFRESH_NEW_RCV)) | |
11135 | json_object_string_add( | |
11136 | json_cap, | |
11137 | "routeRefresh", | |
11138 | "advertisedAndReceivedOldNew"); | |
11139 | else { | |
11140 | if (CHECK_FLAG( | |
11141 | p->cap, | |
11142 | PEER_CAP_REFRESH_OLD_RCV)) | |
11143 | json_object_string_add( | |
11144 | json_cap, | |
11145 | "routeRefresh", | |
11146 | "advertisedAndReceivedOld"); | |
11147 | else | |
11148 | json_object_string_add( | |
11149 | json_cap, | |
11150 | "routeRefresh", | |
11151 | "advertisedAndReceivedNew"); | |
11152 | } | |
11153 | } else if ( | |
11154 | CHECK_FLAG( | |
11155 | p->cap, | |
11156 | PEER_CAP_REFRESH_ADV)) | |
11157 | json_object_string_add( | |
11158 | json_cap, | |
11159 | "routeRefresh", | |
11160 | "advertised"); | |
11161 | else if ( | |
11162 | CHECK_FLAG( | |
11163 | p->cap, | |
11164 | PEER_CAP_REFRESH_NEW_RCV) | |
11165 | || CHECK_FLAG( | |
11166 | p->cap, | |
11167 | PEER_CAP_REFRESH_OLD_RCV)) | |
11168 | json_object_string_add( | |
11169 | json_cap, | |
11170 | "routeRefresh", | |
11171 | "received"); | |
11172 | } | |
11173 | ||
11174 | /* Multiprotocol Extensions */ | |
11175 | json_object *json_multi = NULL; | |
11176 | json_multi = json_object_new_object(); | |
11177 | ||
05c7a1cc QY |
11178 | FOREACH_AFI_SAFI (afi, safi) { |
11179 | if (p->afc_adv[afi][safi] | |
11180 | || p->afc_recv[afi][safi]) { | |
11181 | json_object *json_exten = NULL; | |
11182 | json_exten = | |
11183 | json_object_new_object(); | |
11184 | ||
d62a17ae | 11185 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
11186 | && p->afc_recv[afi][safi]) |
11187 | json_object_boolean_true_add( | |
11188 | json_exten, | |
11189 | "advertisedAndReceived"); | |
11190 | else if (p->afc_adv[afi][safi]) | |
11191 | json_object_boolean_true_add( | |
11192 | json_exten, | |
11193 | "advertised"); | |
11194 | else if (p->afc_recv[afi][safi]) | |
11195 | json_object_boolean_true_add( | |
11196 | json_exten, | |
11197 | "received"); | |
d62a17ae | 11198 | |
05c7a1cc QY |
11199 | json_object_object_add( |
11200 | json_multi, | |
5cb5f4d0 DD |
11201 | get_afi_safi_str(afi, |
11202 | safi, | |
11203 | true), | |
05c7a1cc | 11204 | json_exten); |
d62a17ae | 11205 | } |
11206 | } | |
11207 | json_object_object_add( | |
11208 | json_cap, "multiprotocolExtensions", | |
11209 | json_multi); | |
11210 | ||
d77114b7 | 11211 | /* Hostname capabilities */ |
60466a63 | 11212 | json_object *json_hname = NULL; |
d77114b7 MK |
11213 | |
11214 | json_hname = json_object_new_object(); | |
11215 | ||
11216 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
11217 | json_object_string_add( | |
60466a63 QY |
11218 | json_hname, "advHostName", |
11219 | bgp->peer_self->hostname | |
11220 | ? bgp->peer_self | |
11221 | ->hostname | |
d77114b7 MK |
11222 | : "n/a"); |
11223 | json_object_string_add( | |
60466a63 QY |
11224 | json_hname, "advDomainName", |
11225 | bgp->peer_self->domainname | |
11226 | ? bgp->peer_self | |
11227 | ->domainname | |
d77114b7 MK |
11228 | : "n/a"); |
11229 | } | |
11230 | ||
11231 | ||
11232 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
11233 | json_object_string_add( | |
60466a63 QY |
11234 | json_hname, "rcvHostName", |
11235 | p->hostname ? p->hostname | |
11236 | : "n/a"); | |
d77114b7 | 11237 | json_object_string_add( |
60466a63 QY |
11238 | json_hname, "rcvDomainName", |
11239 | p->domainname ? p->domainname | |
11240 | : "n/a"); | |
d77114b7 MK |
11241 | } |
11242 | ||
60466a63 | 11243 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
11244 | json_hname); |
11245 | ||
d62a17ae | 11246 | /* Gracefull Restart */ |
11247 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
11248 | || CHECK_FLAG(p->cap, | |
11249 | PEER_CAP_RESTART_ADV)) { | |
11250 | if (CHECK_FLAG(p->cap, | |
11251 | PEER_CAP_RESTART_ADV) | |
11252 | && CHECK_FLAG(p->cap, | |
11253 | PEER_CAP_RESTART_RCV)) | |
11254 | json_object_string_add( | |
11255 | json_cap, | |
11256 | "gracefulRestart", | |
11257 | "advertisedAndReceived"); | |
11258 | else if (CHECK_FLAG( | |
11259 | p->cap, | |
11260 | PEER_CAP_RESTART_ADV)) | |
11261 | json_object_string_add( | |
11262 | json_cap, | |
11263 | "gracefulRestartCapability", | |
11264 | "advertised"); | |
11265 | else if (CHECK_FLAG( | |
11266 | p->cap, | |
11267 | PEER_CAP_RESTART_RCV)) | |
11268 | json_object_string_add( | |
11269 | json_cap, | |
11270 | "gracefulRestartCapability", | |
11271 | "received"); | |
11272 | ||
11273 | if (CHECK_FLAG(p->cap, | |
11274 | PEER_CAP_RESTART_RCV)) { | |
11275 | int restart_af_count = 0; | |
11276 | json_object *json_restart = | |
11277 | NULL; | |
11278 | json_restart = | |
11279 | json_object_new_object(); | |
11280 | ||
11281 | json_object_int_add( | |
11282 | json_cap, | |
11283 | "gracefulRestartRemoteTimerMsecs", | |
11284 | p->v_gr_restart * 1000); | |
11285 | ||
05c7a1cc QY |
11286 | FOREACH_AFI_SAFI (afi, safi) { |
11287 | if (CHECK_FLAG( | |
11288 | p->af_cap | |
11289 | [afi] | |
11290 | [safi], | |
11291 | PEER_CAP_RESTART_AF_RCV)) { | |
11292 | json_object * | |
11293 | json_sub = | |
11294 | NULL; | |
11295 | json_sub = | |
11296 | json_object_new_object(); | |
11297 | ||
d62a17ae | 11298 | if (CHECK_FLAG( |
11299 | p->af_cap | |
11300 | [afi] | |
11301 | [safi], | |
05c7a1cc QY |
11302 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
11303 | json_object_boolean_true_add( | |
11304 | json_sub, | |
11305 | "preserved"); | |
11306 | restart_af_count++; | |
11307 | json_object_object_add( | |
11308 | json_restart, | |
5cb5f4d0 | 11309 | get_afi_safi_str( |
05c7a1cc | 11310 | afi, |
5cb5f4d0 DD |
11311 | safi, |
11312 | true), | |
05c7a1cc | 11313 | json_sub); |
d62a17ae | 11314 | } |
11315 | } | |
11316 | if (!restart_af_count) { | |
11317 | json_object_string_add( | |
11318 | json_cap, | |
11319 | "addressFamiliesByPeer", | |
11320 | "none"); | |
11321 | json_object_free( | |
11322 | json_restart); | |
11323 | } else | |
11324 | json_object_object_add( | |
11325 | json_cap, | |
11326 | "addressFamiliesByPeer", | |
11327 | json_restart); | |
11328 | } | |
11329 | } | |
11330 | json_object_object_add(json_neigh, | |
11331 | "neighborCapabilities", | |
11332 | json_cap); | |
11333 | } else { | |
11334 | vty_out(vty, " Neighbor capabilities:\n"); | |
11335 | ||
11336 | /* AS4 */ | |
11337 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
11338 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
11339 | vty_out(vty, " 4 Byte AS:"); | |
11340 | if (CHECK_FLAG(p->cap, | |
11341 | PEER_CAP_AS4_ADV)) | |
11342 | vty_out(vty, " advertised"); | |
11343 | if (CHECK_FLAG(p->cap, | |
11344 | PEER_CAP_AS4_RCV)) | |
11345 | vty_out(vty, " %sreceived", | |
11346 | CHECK_FLAG( | |
11347 | p->cap, | |
11348 | PEER_CAP_AS4_ADV) | |
11349 | ? "and " | |
11350 | : ""); | |
11351 | vty_out(vty, "\n"); | |
11352 | } | |
11353 | ||
11354 | /* AddPath */ | |
11355 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
11356 | || CHECK_FLAG(p->cap, | |
11357 | PEER_CAP_ADDPATH_ADV)) { | |
11358 | vty_out(vty, " AddPath:\n"); | |
11359 | ||
05c7a1cc QY |
11360 | FOREACH_AFI_SAFI (afi, safi) { |
11361 | if (CHECK_FLAG( | |
11362 | p->af_cap[afi] | |
11363 | [safi], | |
11364 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11365 | || CHECK_FLAG( | |
11366 | p->af_cap[afi] | |
11367 | [safi], | |
11368 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
11369 | vty_out(vty, | |
11370 | " %s: TX ", | |
5cb5f4d0 | 11371 | get_afi_safi_str( |
05c7a1cc | 11372 | afi, |
5cb5f4d0 DD |
11373 | safi, |
11374 | false)); | |
05c7a1cc | 11375 | |
d62a17ae | 11376 | if (CHECK_FLAG( |
11377 | p->af_cap | |
11378 | [afi] | |
11379 | [safi], | |
05c7a1cc | 11380 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 11381 | vty_out(vty, |
05c7a1cc | 11382 | "advertised %s", |
5cb5f4d0 | 11383 | get_afi_safi_str( |
d62a17ae | 11384 | afi, |
5cb5f4d0 DD |
11385 | safi, |
11386 | false)); | |
d62a17ae | 11387 | |
05c7a1cc QY |
11388 | if (CHECK_FLAG( |
11389 | p->af_cap | |
11390 | [afi] | |
11391 | [safi], | |
11392 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
11393 | vty_out(vty, | |
11394 | "%sreceived", | |
11395 | CHECK_FLAG( | |
11396 | p->af_cap | |
11397 | [afi] | |
11398 | [safi], | |
11399 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
11400 | ? " and " | |
11401 | : ""); | |
d62a17ae | 11402 | |
05c7a1cc QY |
11403 | vty_out(vty, "\n"); |
11404 | } | |
d62a17ae | 11405 | |
05c7a1cc QY |
11406 | if (CHECK_FLAG( |
11407 | p->af_cap[afi] | |
11408 | [safi], | |
11409 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11410 | || CHECK_FLAG( | |
11411 | p->af_cap[afi] | |
11412 | [safi], | |
11413 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
11414 | vty_out(vty, | |
11415 | " %s: RX ", | |
5cb5f4d0 | 11416 | get_afi_safi_str( |
05c7a1cc | 11417 | afi, |
5cb5f4d0 DD |
11418 | safi, |
11419 | false)); | |
d62a17ae | 11420 | |
11421 | if (CHECK_FLAG( | |
11422 | p->af_cap | |
11423 | [afi] | |
11424 | [safi], | |
05c7a1cc | 11425 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 11426 | vty_out(vty, |
05c7a1cc | 11427 | "advertised %s", |
5cb5f4d0 | 11428 | get_afi_safi_str( |
d62a17ae | 11429 | afi, |
5cb5f4d0 DD |
11430 | safi, |
11431 | false)); | |
d62a17ae | 11432 | |
05c7a1cc QY |
11433 | if (CHECK_FLAG( |
11434 | p->af_cap | |
11435 | [afi] | |
11436 | [safi], | |
11437 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 11438 | vty_out(vty, |
05c7a1cc QY |
11439 | "%sreceived", |
11440 | CHECK_FLAG( | |
11441 | p->af_cap | |
11442 | [afi] | |
11443 | [safi], | |
11444 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
11445 | ? " and " | |
11446 | : ""); | |
11447 | ||
11448 | vty_out(vty, "\n"); | |
d62a17ae | 11449 | } |
05c7a1cc | 11450 | } |
d62a17ae | 11451 | } |
11452 | ||
11453 | /* Dynamic */ | |
11454 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
11455 | || CHECK_FLAG(p->cap, | |
11456 | PEER_CAP_DYNAMIC_ADV)) { | |
11457 | vty_out(vty, " Dynamic:"); | |
11458 | if (CHECK_FLAG(p->cap, | |
11459 | PEER_CAP_DYNAMIC_ADV)) | |
11460 | vty_out(vty, " advertised"); | |
11461 | if (CHECK_FLAG(p->cap, | |
11462 | PEER_CAP_DYNAMIC_RCV)) | |
11463 | vty_out(vty, " %sreceived", | |
11464 | CHECK_FLAG( | |
11465 | p->cap, | |
11466 | PEER_CAP_DYNAMIC_ADV) | |
11467 | ? "and " | |
11468 | : ""); | |
11469 | vty_out(vty, "\n"); | |
11470 | } | |
11471 | ||
11472 | /* Extended nexthop */ | |
11473 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
11474 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
11475 | vty_out(vty, " Extended nexthop:"); | |
11476 | if (CHECK_FLAG(p->cap, | |
11477 | PEER_CAP_ENHE_ADV)) | |
11478 | vty_out(vty, " advertised"); | |
11479 | if (CHECK_FLAG(p->cap, | |
11480 | PEER_CAP_ENHE_RCV)) | |
11481 | vty_out(vty, " %sreceived", | |
11482 | CHECK_FLAG( | |
11483 | p->cap, | |
11484 | PEER_CAP_ENHE_ADV) | |
11485 | ? "and " | |
11486 | : ""); | |
11487 | vty_out(vty, "\n"); | |
11488 | ||
11489 | if (CHECK_FLAG(p->cap, | |
11490 | PEER_CAP_ENHE_RCV)) { | |
11491 | vty_out(vty, | |
11492 | " Address families by peer:\n "); | |
11493 | for (safi = SAFI_UNICAST; | |
11494 | safi < SAFI_MAX; safi++) | |
11495 | if (CHECK_FLAG( | |
11496 | p->af_cap | |
11497 | [AFI_IP] | |
11498 | [safi], | |
11499 | PEER_CAP_ENHE_AF_RCV)) | |
11500 | vty_out(vty, | |
11501 | " %s\n", | |
5cb5f4d0 | 11502 | get_afi_safi_str( |
d62a17ae | 11503 | AFI_IP, |
5cb5f4d0 DD |
11504 | safi, |
11505 | false)); | |
d62a17ae | 11506 | } |
11507 | } | |
11508 | ||
11509 | /* Route Refresh */ | |
11510 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
11511 | || CHECK_FLAG(p->cap, | |
11512 | PEER_CAP_REFRESH_NEW_RCV) | |
11513 | || CHECK_FLAG(p->cap, | |
11514 | PEER_CAP_REFRESH_OLD_RCV)) { | |
11515 | vty_out(vty, " Route refresh:"); | |
11516 | if (CHECK_FLAG(p->cap, | |
11517 | PEER_CAP_REFRESH_ADV)) | |
11518 | vty_out(vty, " advertised"); | |
11519 | if (CHECK_FLAG(p->cap, | |
11520 | PEER_CAP_REFRESH_NEW_RCV) | |
11521 | || CHECK_FLAG( | |
11522 | p->cap, | |
11523 | PEER_CAP_REFRESH_OLD_RCV)) | |
11524 | vty_out(vty, " %sreceived(%s)", | |
11525 | CHECK_FLAG( | |
11526 | p->cap, | |
11527 | PEER_CAP_REFRESH_ADV) | |
11528 | ? "and " | |
11529 | : "", | |
11530 | (CHECK_FLAG( | |
11531 | p->cap, | |
11532 | PEER_CAP_REFRESH_OLD_RCV) | |
11533 | && CHECK_FLAG( | |
11534 | p->cap, | |
11535 | PEER_CAP_REFRESH_NEW_RCV)) | |
11536 | ? "old & new" | |
11537 | : CHECK_FLAG( | |
11538 | p->cap, | |
11539 | PEER_CAP_REFRESH_OLD_RCV) | |
11540 | ? "old" | |
11541 | : "new"); | |
11542 | ||
11543 | vty_out(vty, "\n"); | |
11544 | } | |
11545 | ||
11546 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
11547 | FOREACH_AFI_SAFI (afi, safi) |
11548 | if (p->afc_adv[afi][safi] | |
11549 | || p->afc_recv[afi][safi]) { | |
11550 | vty_out(vty, | |
11551 | " Address Family %s:", | |
5cb5f4d0 DD |
11552 | get_afi_safi_str( |
11553 | afi, | |
11554 | safi, | |
11555 | false)); | |
05c7a1cc | 11556 | if (p->afc_adv[afi][safi]) |
d62a17ae | 11557 | vty_out(vty, |
05c7a1cc QY |
11558 | " advertised"); |
11559 | if (p->afc_recv[afi][safi]) | |
11560 | vty_out(vty, | |
11561 | " %sreceived", | |
11562 | p->afc_adv[afi] | |
11563 | [safi] | |
11564 | ? "and " | |
11565 | : ""); | |
11566 | vty_out(vty, "\n"); | |
11567 | } | |
d62a17ae | 11568 | |
11569 | /* Hostname capability */ | |
60466a63 | 11570 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
11571 | |
11572 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
11573 | vty_out(vty, |
11574 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
11575 | bgp->peer_self->hostname |
11576 | ? bgp->peer_self | |
11577 | ->hostname | |
d77114b7 | 11578 | : "n/a", |
60466a63 QY |
11579 | bgp->peer_self->domainname |
11580 | ? bgp->peer_self | |
11581 | ->domainname | |
d77114b7 MK |
11582 | : "n/a"); |
11583 | } else { | |
11584 | vty_out(vty, " not advertised"); | |
d62a17ae | 11585 | } |
11586 | ||
d77114b7 | 11587 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
11588 | vty_out(vty, |
11589 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
11590 | p->hostname ? p->hostname |
11591 | : "n/a", | |
11592 | p->domainname ? p->domainname | |
11593 | : "n/a"); | |
d77114b7 MK |
11594 | } else { |
11595 | vty_out(vty, " not received"); | |
11596 | } | |
11597 | ||
11598 | vty_out(vty, "\n"); | |
11599 | ||
61bfbd51 | 11600 | /* Graceful Restart */ |
d62a17ae | 11601 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) |
11602 | || CHECK_FLAG(p->cap, | |
11603 | PEER_CAP_RESTART_ADV)) { | |
11604 | vty_out(vty, | |
61bfbd51 | 11605 | " Graceful Restart Capability:"); |
d62a17ae | 11606 | if (CHECK_FLAG(p->cap, |
11607 | PEER_CAP_RESTART_ADV)) | |
11608 | vty_out(vty, " advertised"); | |
11609 | if (CHECK_FLAG(p->cap, | |
11610 | PEER_CAP_RESTART_RCV)) | |
11611 | vty_out(vty, " %sreceived", | |
11612 | CHECK_FLAG( | |
11613 | p->cap, | |
11614 | PEER_CAP_RESTART_ADV) | |
11615 | ? "and " | |
11616 | : ""); | |
11617 | vty_out(vty, "\n"); | |
11618 | ||
11619 | if (CHECK_FLAG(p->cap, | |
11620 | PEER_CAP_RESTART_RCV)) { | |
11621 | int restart_af_count = 0; | |
11622 | ||
11623 | vty_out(vty, | |
11624 | " Remote Restart timer is %d seconds\n", | |
11625 | p->v_gr_restart); | |
11626 | vty_out(vty, | |
11627 | " Address families by peer:\n "); | |
11628 | ||
05c7a1cc QY |
11629 | FOREACH_AFI_SAFI (afi, safi) |
11630 | if (CHECK_FLAG( | |
11631 | p->af_cap | |
11632 | [afi] | |
11633 | [safi], | |
11634 | PEER_CAP_RESTART_AF_RCV)) { | |
11635 | vty_out(vty, | |
11636 | "%s%s(%s)", | |
11637 | restart_af_count | |
11638 | ? ", " | |
11639 | : "", | |
5cb5f4d0 | 11640 | get_afi_safi_str( |
05c7a1cc | 11641 | afi, |
5cb5f4d0 DD |
11642 | safi, |
11643 | false), | |
05c7a1cc QY |
11644 | CHECK_FLAG( |
11645 | p->af_cap | |
11646 | [afi] | |
11647 | [safi], | |
11648 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
11649 | ? "preserved" | |
11650 | : "not preserved"); | |
11651 | restart_af_count++; | |
11652 | } | |
d62a17ae | 11653 | if (!restart_af_count) |
11654 | vty_out(vty, "none"); | |
11655 | vty_out(vty, "\n"); | |
11656 | } | |
2986cac2 | 11657 | } /* Gracefull Restart */ |
d62a17ae | 11658 | } |
11659 | } | |
11660 | } | |
11661 | ||
11662 | /* graceful restart information */ | |
d62a17ae | 11663 | json_object *json_grace = NULL; |
11664 | json_object *json_grace_send = NULL; | |
11665 | json_object *json_grace_recv = NULL; | |
11666 | int eor_send_af_count = 0; | |
11667 | int eor_receive_af_count = 0; | |
11668 | ||
11669 | if (use_json) { | |
11670 | json_grace = json_object_new_object(); | |
11671 | json_grace_send = json_object_new_object(); | |
11672 | json_grace_recv = json_object_new_object(); | |
11673 | ||
36235319 QY |
11674 | if ((p->status == Established) |
11675 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
05c7a1cc QY |
11676 | FOREACH_AFI_SAFI (afi, safi) { |
11677 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
36235319 | 11678 | PEER_STATUS_EOR_SEND)) { |
05c7a1cc QY |
11679 | json_object_boolean_true_add( |
11680 | json_grace_send, | |
5cb5f4d0 DD |
11681 | get_afi_safi_str(afi, |
11682 | safi, | |
11683 | true)); | |
05c7a1cc | 11684 | eor_send_af_count++; |
d62a17ae | 11685 | } |
11686 | } | |
05c7a1cc QY |
11687 | FOREACH_AFI_SAFI (afi, safi) { |
11688 | if (CHECK_FLAG( | |
36235319 QY |
11689 | p->af_sflags[afi][safi], |
11690 | PEER_STATUS_EOR_RECEIVED)) { | |
05c7a1cc QY |
11691 | json_object_boolean_true_add( |
11692 | json_grace_recv, | |
5cb5f4d0 DD |
11693 | get_afi_safi_str(afi, |
11694 | safi, | |
11695 | true)); | |
05c7a1cc | 11696 | eor_receive_af_count++; |
d62a17ae | 11697 | } |
11698 | } | |
11699 | } | |
36235319 QY |
11700 | json_object_object_add(json_grace, "endOfRibSend", |
11701 | json_grace_send); | |
11702 | json_object_object_add(json_grace, "endOfRibRecv", | |
11703 | json_grace_recv); | |
d62a17ae | 11704 | |
d62a17ae | 11705 | |
11706 | if (p->t_gr_restart) | |
11707 | json_object_int_add(json_grace, | |
11708 | "gracefulRestartTimerMsecs", | |
11709 | thread_timer_remain_second( | |
11710 | p->t_gr_restart) | |
11711 | * 1000); | |
11712 | ||
11713 | if (p->t_gr_stale) | |
11714 | json_object_int_add( | |
11715 | json_grace, | |
11716 | "gracefulStalepathTimerMsecs", | |
11717 | thread_timer_remain_second( | |
11718 | p->t_gr_stale) | |
11719 | * 1000); | |
2986cac2 | 11720 | /* more gr info in new format */ |
11721 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, | |
36235319 | 11722 | json_grace); |
d62a17ae | 11723 | json_object_object_add( |
11724 | json_neigh, "gracefulRestartInfo", json_grace); | |
11725 | } else { | |
2089dd80 | 11726 | vty_out(vty, " Graceful restart information:\n"); |
36235319 QY |
11727 | if ((p->status == Established) |
11728 | && CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV)) { | |
2986cac2 | 11729 | |
d62a17ae | 11730 | vty_out(vty, " End-of-RIB send: "); |
05c7a1cc QY |
11731 | FOREACH_AFI_SAFI (afi, safi) { |
11732 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
11733 | PEER_STATUS_EOR_SEND)) { | |
11734 | vty_out(vty, "%s%s", | |
11735 | eor_send_af_count ? ", " | |
11736 | : "", | |
36235319 QY |
11737 | get_afi_safi_str( |
11738 | afi, safi, | |
11739 | false)); | |
05c7a1cc | 11740 | eor_send_af_count++; |
d62a17ae | 11741 | } |
11742 | } | |
11743 | vty_out(vty, "\n"); | |
11744 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
11745 | FOREACH_AFI_SAFI (afi, safi) { |
11746 | if (CHECK_FLAG( | |
11747 | p->af_sflags[afi][safi], | |
11748 | PEER_STATUS_EOR_RECEIVED)) { | |
11749 | vty_out(vty, "%s%s", | |
11750 | eor_receive_af_count | |
11751 | ? ", " | |
11752 | : "", | |
5cb5f4d0 DD |
11753 | get_afi_safi_str(afi, |
11754 | safi, | |
11755 | false)); | |
05c7a1cc | 11756 | eor_receive_af_count++; |
d62a17ae | 11757 | } |
11758 | } | |
11759 | vty_out(vty, "\n"); | |
11760 | } | |
11761 | ||
11762 | if (p->t_gr_restart) | |
11763 | vty_out(vty, | |
11764 | " The remaining time of restart timer is %ld\n", | |
11765 | thread_timer_remain_second( | |
11766 | p->t_gr_restart)); | |
11767 | ||
11768 | if (p->t_gr_stale) | |
11769 | vty_out(vty, | |
11770 | " The remaining time of stalepath timer is %ld\n", | |
11771 | thread_timer_remain_second( | |
11772 | p->t_gr_stale)); | |
2986cac2 | 11773 | |
11774 | /* more gr info in new format */ | |
11775 | BGP_SHOW_PEER_GR_CAPABILITY(vty, p, use_json, NULL); | |
d62a17ae | 11776 | } |
2986cac2 | 11777 | |
d62a17ae | 11778 | if (use_json) { |
11779 | json_object *json_stat = NULL; | |
11780 | json_stat = json_object_new_object(); | |
11781 | /* Packet counts. */ | |
43aa5965 QY |
11782 | |
11783 | atomic_size_t outq_count, inq_count; | |
11784 | outq_count = atomic_load_explicit(&p->obuf->count, | |
11785 | memory_order_relaxed); | |
11786 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
11787 | memory_order_relaxed); | |
11788 | ||
11789 | json_object_int_add(json_stat, "depthInq", | |
11790 | (unsigned long)inq_count); | |
d62a17ae | 11791 | json_object_int_add(json_stat, "depthOutq", |
43aa5965 | 11792 | (unsigned long)outq_count); |
0112e9e0 QY |
11793 | json_object_int_add(json_stat, "opensSent", |
11794 | atomic_load_explicit(&p->open_out, | |
11795 | memory_order_relaxed)); | |
11796 | json_object_int_add(json_stat, "opensRecv", | |
11797 | atomic_load_explicit(&p->open_in, | |
11798 | memory_order_relaxed)); | |
d62a17ae | 11799 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
11800 | atomic_load_explicit(&p->notify_out, |
11801 | memory_order_relaxed)); | |
d62a17ae | 11802 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
11803 | atomic_load_explicit(&p->notify_in, |
11804 | memory_order_relaxed)); | |
11805 | json_object_int_add(json_stat, "updatesSent", | |
11806 | atomic_load_explicit(&p->update_out, | |
11807 | memory_order_relaxed)); | |
11808 | json_object_int_add(json_stat, "updatesRecv", | |
11809 | atomic_load_explicit(&p->update_in, | |
11810 | memory_order_relaxed)); | |
d62a17ae | 11811 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
11812 | atomic_load_explicit(&p->keepalive_out, |
11813 | memory_order_relaxed)); | |
d62a17ae | 11814 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
11815 | atomic_load_explicit(&p->keepalive_in, |
11816 | memory_order_relaxed)); | |
d62a17ae | 11817 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
11818 | atomic_load_explicit(&p->refresh_out, |
11819 | memory_order_relaxed)); | |
d62a17ae | 11820 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
11821 | atomic_load_explicit(&p->refresh_in, |
11822 | memory_order_relaxed)); | |
d62a17ae | 11823 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
11824 | atomic_load_explicit(&p->dynamic_cap_out, |
11825 | memory_order_relaxed)); | |
d62a17ae | 11826 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
11827 | atomic_load_explicit(&p->dynamic_cap_in, |
11828 | memory_order_relaxed)); | |
11829 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
11830 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 11831 | json_object_object_add(json_neigh, "messageStats", json_stat); |
11832 | } else { | |
43aa5965 QY |
11833 | atomic_size_t outq_count, inq_count; |
11834 | outq_count = atomic_load_explicit(&p->obuf->count, | |
11835 | memory_order_relaxed); | |
11836 | inq_count = atomic_load_explicit(&p->ibuf->count, | |
11837 | memory_order_relaxed); | |
11838 | ||
d62a17ae | 11839 | /* Packet counts. */ |
11840 | vty_out(vty, " Message statistics:\n"); | |
43aa5965 QY |
11841 | vty_out(vty, " Inq depth is %zu\n", inq_count); |
11842 | vty_out(vty, " Outq depth is %zu\n", outq_count); | |
d62a17ae | 11843 | vty_out(vty, " Sent Rcvd\n"); |
0112e9e0 QY |
11844 | vty_out(vty, " Opens: %10d %10d\n", |
11845 | atomic_load_explicit(&p->open_out, | |
11846 | memory_order_relaxed), | |
11847 | atomic_load_explicit(&p->open_in, | |
11848 | memory_order_relaxed)); | |
11849 | vty_out(vty, " Notifications: %10d %10d\n", | |
11850 | atomic_load_explicit(&p->notify_out, | |
11851 | memory_order_relaxed), | |
11852 | atomic_load_explicit(&p->notify_in, | |
11853 | memory_order_relaxed)); | |
11854 | vty_out(vty, " Updates: %10d %10d\n", | |
11855 | atomic_load_explicit(&p->update_out, | |
11856 | memory_order_relaxed), | |
11857 | atomic_load_explicit(&p->update_in, | |
11858 | memory_order_relaxed)); | |
11859 | vty_out(vty, " Keepalives: %10d %10d\n", | |
11860 | atomic_load_explicit(&p->keepalive_out, | |
11861 | memory_order_relaxed), | |
11862 | atomic_load_explicit(&p->keepalive_in, | |
11863 | memory_order_relaxed)); | |
11864 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
11865 | atomic_load_explicit(&p->refresh_out, | |
11866 | memory_order_relaxed), | |
11867 | atomic_load_explicit(&p->refresh_in, | |
11868 | memory_order_relaxed)); | |
d62a17ae | 11869 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
11870 | atomic_load_explicit(&p->dynamic_cap_out, |
11871 | memory_order_relaxed), | |
11872 | atomic_load_explicit(&p->dynamic_cap_in, | |
11873 | memory_order_relaxed)); | |
11874 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
11875 | PEER_TOTAL_RX(p)); | |
d62a17ae | 11876 | } |
11877 | ||
11878 | if (use_json) { | |
11879 | /* advertisement-interval */ | |
11880 | json_object_int_add(json_neigh, | |
11881 | "minBtwnAdvertisementRunsTimerMsecs", | |
11882 | p->v_routeadv * 1000); | |
11883 | ||
11884 | /* Update-source. */ | |
11885 | if (p->update_if || p->update_source) { | |
11886 | if (p->update_if) | |
11887 | json_object_string_add(json_neigh, | |
11888 | "updateSource", | |
11889 | p->update_if); | |
11890 | else if (p->update_source) | |
11891 | json_object_string_add( | |
11892 | json_neigh, "updateSource", | |
11893 | sockunion2str(p->update_source, buf1, | |
11894 | SU_ADDRSTRLEN)); | |
11895 | } | |
11896 | } else { | |
11897 | /* advertisement-interval */ | |
11898 | vty_out(vty, | |
11899 | " Minimum time between advertisement runs is %d seconds\n", | |
11900 | p->v_routeadv); | |
11901 | ||
11902 | /* Update-source. */ | |
11903 | if (p->update_if || p->update_source) { | |
11904 | vty_out(vty, " Update source is "); | |
11905 | if (p->update_if) | |
11906 | vty_out(vty, "%s", p->update_if); | |
11907 | else if (p->update_source) | |
11908 | vty_out(vty, "%s", | |
11909 | sockunion2str(p->update_source, buf1, | |
11910 | SU_ADDRSTRLEN)); | |
11911 | vty_out(vty, "\n"); | |
11912 | } | |
11913 | ||
11914 | vty_out(vty, "\n"); | |
11915 | } | |
11916 | ||
11917 | /* Address Family Information */ | |
11918 | json_object *json_hold = NULL; | |
11919 | ||
11920 | if (use_json) | |
11921 | json_hold = json_object_new_object(); | |
11922 | ||
05c7a1cc QY |
11923 | FOREACH_AFI_SAFI (afi, safi) |
11924 | if (p->afc[afi][safi]) | |
11925 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
11926 | json_hold); | |
d62a17ae | 11927 | |
11928 | if (use_json) { | |
11929 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
11930 | json_hold); | |
11931 | json_object_int_add(json_neigh, "connectionsEstablished", | |
11932 | p->established); | |
11933 | json_object_int_add(json_neigh, "connectionsDropped", | |
11934 | p->dropped); | |
11935 | } else | |
11936 | vty_out(vty, " Connections established %d; dropped %d\n", | |
11937 | p->established, p->dropped); | |
11938 | ||
11939 | if (!p->last_reset) { | |
11940 | if (use_json) | |
11941 | json_object_string_add(json_neigh, "lastReset", | |
11942 | "never"); | |
11943 | else | |
11944 | vty_out(vty, " Last reset never\n"); | |
11945 | } else { | |
11946 | if (use_json) { | |
11947 | time_t uptime; | |
a2700b50 | 11948 | struct tm tm; |
d62a17ae | 11949 | |
11950 | uptime = bgp_clock(); | |
11951 | uptime -= p->resettime; | |
a2700b50 MS |
11952 | gmtime_r(&uptime, &tm); |
11953 | ||
d62a17ae | 11954 | json_object_int_add(json_neigh, "lastResetTimerMsecs", |
a2700b50 MS |
11955 | (tm.tm_sec * 1000) |
11956 | + (tm.tm_min * 60000) | |
11957 | + (tm.tm_hour * 3600000)); | |
3577f1c5 | 11958 | bgp_show_peer_reset(NULL, p, json_neigh, true); |
d62a17ae | 11959 | } else { |
11960 | vty_out(vty, " Last reset %s, ", | |
11961 | peer_uptime(p->resettime, timebuf, | |
11962 | BGP_UPTIME_LEN, 0, NULL)); | |
11963 | ||
3577f1c5 | 11964 | bgp_show_peer_reset(vty, p, NULL, false); |
d62a17ae | 11965 | if (p->last_reset_cause_size) { |
11966 | msg = p->last_reset_cause; | |
11967 | vty_out(vty, | |
11968 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
11969 | for (i = 1; i <= p->last_reset_cause_size; | |
11970 | i++) { | |
11971 | vty_out(vty, "%02X", *msg++); | |
11972 | ||
11973 | if (i != p->last_reset_cause_size) { | |
11974 | if (i % 16 == 0) { | |
11975 | vty_out(vty, "\n "); | |
11976 | } else if (i % 4 == 0) { | |
11977 | vty_out(vty, " "); | |
11978 | } | |
11979 | } | |
11980 | } | |
11981 | vty_out(vty, "\n"); | |
11982 | } | |
11983 | } | |
11984 | } | |
11985 | ||
11986 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
11987 | if (use_json) | |
11988 | json_object_boolean_true_add(json_neigh, | |
11989 | "prefixesConfigExceedMax"); | |
11990 | else | |
11991 | vty_out(vty, | |
11992 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
11993 | ||
11994 | if (p->t_pmax_restart) { | |
11995 | if (use_json) { | |
11996 | json_object_boolean_true_add( | |
11997 | json_neigh, "reducePrefixNumFrom"); | |
11998 | json_object_int_add(json_neigh, | |
11999 | "restartInTimerMsec", | |
12000 | thread_timer_remain_second( | |
12001 | p->t_pmax_restart) | |
12002 | * 1000); | |
12003 | } else | |
12004 | vty_out(vty, | |
12005 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
12006 | p->host, thread_timer_remain_second( |
12007 | p->t_pmax_restart)); | |
d62a17ae | 12008 | } else { |
12009 | if (use_json) | |
12010 | json_object_boolean_true_add( | |
12011 | json_neigh, | |
12012 | "reducePrefixNumAndClearIpBgp"); | |
12013 | else | |
12014 | vty_out(vty, | |
12015 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
12016 | p->host); | |
12017 | } | |
12018 | } | |
12019 | ||
12020 | /* EBGP Multihop and GTSM */ | |
12021 | if (p->sort != BGP_PEER_IBGP) { | |
12022 | if (use_json) { | |
e2521429 | 12023 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12024 | json_object_int_add(json_neigh, |
12025 | "externalBgpNbrMaxHopsAway", | |
12026 | p->gtsm_hops); | |
c8d6f0d6 | 12027 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12028 | json_object_int_add(json_neigh, |
12029 | "externalBgpNbrMaxHopsAway", | |
12030 | p->ttl); | |
12031 | } else { | |
e2521429 | 12032 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) |
d62a17ae | 12033 | vty_out(vty, |
12034 | " External BGP neighbor may be up to %d hops away.\n", | |
12035 | p->gtsm_hops); | |
c8d6f0d6 | 12036 | else if (p->ttl > BGP_DEFAULT_TTL) |
d62a17ae | 12037 | vty_out(vty, |
12038 | " External BGP neighbor may be up to %d hops away.\n", | |
12039 | p->ttl); | |
12040 | } | |
12041 | } else { | |
e2521429 | 12042 | if (p->gtsm_hops > BGP_GTSM_HOPS_DISABLED) { |
d62a17ae | 12043 | if (use_json) |
12044 | json_object_int_add(json_neigh, | |
12045 | "internalBgpNbrMaxHopsAway", | |
12046 | p->gtsm_hops); | |
12047 | else | |
12048 | vty_out(vty, | |
12049 | " Internal BGP neighbor may be up to %d hops away.\n", | |
12050 | p->gtsm_hops); | |
12051 | } | |
12052 | } | |
12053 | ||
12054 | /* Local address. */ | |
12055 | if (p->su_local) { | |
12056 | if (use_json) { | |
12057 | json_object_string_add(json_neigh, "hostLocal", | |
12058 | sockunion2str(p->su_local, buf1, | |
12059 | SU_ADDRSTRLEN)); | |
12060 | json_object_int_add(json_neigh, "portLocal", | |
12061 | ntohs(p->su_local->sin.sin_port)); | |
12062 | } else | |
12063 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
12064 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
12065 | ntohs(p->su_local->sin.sin_port)); | |
12066 | } | |
12067 | ||
12068 | /* Remote address. */ | |
12069 | if (p->su_remote) { | |
12070 | if (use_json) { | |
12071 | json_object_string_add(json_neigh, "hostForeign", | |
12072 | sockunion2str(p->su_remote, buf1, | |
12073 | SU_ADDRSTRLEN)); | |
12074 | json_object_int_add(json_neigh, "portForeign", | |
12075 | ntohs(p->su_remote->sin.sin_port)); | |
12076 | } else | |
12077 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
12078 | sockunion2str(p->su_remote, buf1, | |
12079 | SU_ADDRSTRLEN), | |
12080 | ntohs(p->su_remote->sin.sin_port)); | |
12081 | } | |
12082 | ||
12083 | /* Nexthop display. */ | |
12084 | if (p->su_local) { | |
12085 | if (use_json) { | |
12086 | json_object_string_add(json_neigh, "nexthop", | |
12087 | inet_ntop(AF_INET, | |
12088 | &p->nexthop.v4, buf1, | |
12089 | sizeof(buf1))); | |
12090 | json_object_string_add(json_neigh, "nexthopGlobal", | |
12091 | inet_ntop(AF_INET6, | |
12092 | &p->nexthop.v6_global, | |
12093 | buf1, sizeof(buf1))); | |
12094 | json_object_string_add(json_neigh, "nexthopLocal", | |
12095 | inet_ntop(AF_INET6, | |
12096 | &p->nexthop.v6_local, | |
12097 | buf1, sizeof(buf1))); | |
12098 | if (p->shared_network) | |
12099 | json_object_string_add(json_neigh, | |
12100 | "bgpConnection", | |
12101 | "sharedNetwork"); | |
12102 | else | |
12103 | json_object_string_add(json_neigh, | |
12104 | "bgpConnection", | |
12105 | "nonSharedNetwork"); | |
12106 | } else { | |
12107 | vty_out(vty, "Nexthop: %s\n", | |
12108 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
12109 | sizeof(buf1))); | |
12110 | vty_out(vty, "Nexthop global: %s\n", | |
12111 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
12112 | sizeof(buf1))); | |
12113 | vty_out(vty, "Nexthop local: %s\n", | |
12114 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
12115 | sizeof(buf1))); | |
12116 | vty_out(vty, "BGP connection: %s\n", | |
12117 | p->shared_network ? "shared network" | |
12118 | : "non shared network"); | |
12119 | } | |
12120 | } | |
12121 | ||
12122 | /* Timer information. */ | |
12123 | if (use_json) { | |
12124 | json_object_int_add(json_neigh, "connectRetryTimer", | |
12125 | p->v_connect); | |
12126 | if (p->status == Established && p->rtt) | |
12127 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
12128 | p->rtt); | |
12129 | if (p->t_start) | |
12130 | json_object_int_add( | |
12131 | json_neigh, "nextStartTimerDueInMsecs", | |
12132 | thread_timer_remain_second(p->t_start) * 1000); | |
12133 | if (p->t_connect) | |
12134 | json_object_int_add( | |
12135 | json_neigh, "nextConnectTimerDueInMsecs", | |
12136 | thread_timer_remain_second(p->t_connect) | |
12137 | * 1000); | |
12138 | if (p->t_routeadv) { | |
12139 | json_object_int_add(json_neigh, "mraiInterval", | |
12140 | p->v_routeadv); | |
12141 | json_object_int_add( | |
12142 | json_neigh, "mraiTimerExpireInMsecs", | |
12143 | thread_timer_remain_second(p->t_routeadv) | |
12144 | * 1000); | |
12145 | } | |
12146 | if (p->password) | |
12147 | json_object_int_add(json_neigh, "authenticationEnabled", | |
12148 | 1); | |
12149 | ||
12150 | if (p->t_read) | |
12151 | json_object_string_add(json_neigh, "readThread", "on"); | |
12152 | else | |
12153 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
12154 | |
12155 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 12156 | json_object_string_add(json_neigh, "writeThread", "on"); |
12157 | else | |
12158 | json_object_string_add(json_neigh, "writeThread", | |
12159 | "off"); | |
12160 | } else { | |
12161 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
12162 | p->v_connect); | |
12163 | if (p->status == Established && p->rtt) | |
12164 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
12165 | p->rtt); | |
12166 | if (p->t_start) | |
12167 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
12168 | thread_timer_remain_second(p->t_start)); | |
12169 | if (p->t_connect) | |
12170 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
12171 | thread_timer_remain_second(p->t_connect)); | |
12172 | if (p->t_routeadv) | |
12173 | vty_out(vty, | |
12174 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
12175 | p->v_routeadv, | |
12176 | thread_timer_remain_second(p->t_routeadv)); | |
12177 | if (p->password) | |
12178 | vty_out(vty, "Peer Authentication Enabled\n"); | |
12179 | ||
cac9e917 | 12180 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
12181 | p->t_read ? "on" : "off", |
12182 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
12183 | ? "on" | |
cac9e917 | 12184 | : "off", p->fd); |
d62a17ae | 12185 | } |
12186 | ||
12187 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
12188 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
12189 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
12190 | ||
12191 | if (!use_json) | |
12192 | vty_out(vty, "\n"); | |
12193 | ||
12194 | /* BFD information. */ | |
12195 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
12196 | ||
12197 | if (use_json) { | |
12198 | if (p->conf_if) /* Configured interface name. */ | |
12199 | json_object_object_add(json, p->conf_if, json_neigh); | |
12200 | else /* Configured IP address. */ | |
12201 | json_object_object_add(json, p->host, json_neigh); | |
12202 | } | |
12203 | } | |
12204 | ||
36235319 QY |
12205 | static int bgp_show_neighbor_graceful_restart(struct vty *vty, struct bgp *bgp, |
12206 | enum show_type type, | |
12207 | union sockunion *su, | |
12208 | const char *conf_if, afi_t afi, | |
74a630b6 | 12209 | bool use_json) |
2986cac2 | 12210 | { |
12211 | struct listnode *node, *nnode; | |
12212 | struct peer *peer; | |
12213 | int find = 0; | |
12214 | safi_t safi = SAFI_UNICAST; | |
74a630b6 | 12215 | json_object *json = NULL; |
2986cac2 | 12216 | json_object *json_neighbor = NULL; |
12217 | ||
74a630b6 NT |
12218 | if (use_json) { |
12219 | json = json_object_new_object(); | |
12220 | json_neighbor = json_object_new_object(); | |
12221 | } | |
12222 | ||
2986cac2 | 12223 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
12224 | ||
12225 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12226 | continue; | |
12227 | ||
12228 | if ((peer->afc[afi][safi]) == 0) | |
12229 | continue; | |
12230 | ||
2ba1fe69 | 12231 | if (type == show_all) { |
2986cac2 | 12232 | bgp_show_peer_gr_status(vty, peer, use_json, |
13909c4f | 12233 | json_neighbor); |
2986cac2 | 12234 | |
74a630b6 | 12235 | if (use_json) { |
13909c4f DS |
12236 | json_object_object_add(json, peer->host, |
12237 | json_neighbor); | |
74a630b6 NT |
12238 | json_neighbor = NULL; |
12239 | } | |
2986cac2 | 12240 | |
2ba1fe69 | 12241 | } else if (type == show_peer) { |
2986cac2 | 12242 | if (conf_if) { |
12243 | if ((peer->conf_if | |
13909c4f DS |
12244 | && !strcmp(peer->conf_if, conf_if)) |
12245 | || (peer->hostname | |
2986cac2 | 12246 | && !strcmp(peer->hostname, conf_if))) { |
12247 | find = 1; | |
13909c4f DS |
12248 | bgp_show_peer_gr_status(vty, peer, |
12249 | use_json, | |
12250 | json_neighbor); | |
2986cac2 | 12251 | } |
12252 | } else { | |
12253 | if (sockunion_same(&peer->su, su)) { | |
12254 | find = 1; | |
13909c4f DS |
12255 | bgp_show_peer_gr_status(vty, peer, |
12256 | use_json, | |
12257 | json_neighbor); | |
2986cac2 | 12258 | } |
12259 | } | |
13909c4f DS |
12260 | if (use_json && find) |
12261 | json_object_object_add(json, peer->host, | |
12262 | json_neighbor); | |
2986cac2 | 12263 | } |
12264 | ||
74a630b6 NT |
12265 | if (find) { |
12266 | json_neighbor = NULL; | |
2986cac2 | 12267 | break; |
74a630b6 | 12268 | } |
2986cac2 | 12269 | } |
12270 | ||
12271 | if (type == show_peer && !find) { | |
12272 | if (use_json) | |
13909c4f | 12273 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); |
2986cac2 | 12274 | else |
12275 | vty_out(vty, "%% No such neighbor\n"); | |
12276 | } | |
12277 | if (use_json) { | |
13909c4f DS |
12278 | vty_out(vty, "%s\n", |
12279 | json_object_to_json_string_ext( | |
12280 | json, JSON_C_TO_STRING_PRETTY)); | |
74a630b6 NT |
12281 | |
12282 | if (json_neighbor) | |
12283 | json_object_free(json_neighbor); | |
12284 | json_object_free(json); | |
2986cac2 | 12285 | } else { |
12286 | vty_out(vty, "\n"); | |
12287 | } | |
12288 | ||
12289 | return CMD_SUCCESS; | |
12290 | } | |
12291 | ||
d62a17ae | 12292 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, |
12293 | enum show_type type, union sockunion *su, | |
9f049418 | 12294 | const char *conf_if, bool use_json, |
d62a17ae | 12295 | json_object *json) |
12296 | { | |
12297 | struct listnode *node, *nnode; | |
12298 | struct peer *peer; | |
12299 | int find = 0; | |
9f049418 | 12300 | bool nbr_output = false; |
d1927ebe AS |
12301 | afi_t afi = AFI_MAX; |
12302 | safi_t safi = SAFI_MAX; | |
12303 | ||
12304 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
12305 | afi = AFI_IP; | |
12306 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
12307 | afi = AFI_IP6; | |
12308 | } | |
d62a17ae | 12309 | |
12310 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
12311 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
12312 | continue; | |
12313 | ||
12314 | switch (type) { | |
12315 | case show_all: | |
12316 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 12317 | nbr_output = true; |
d62a17ae | 12318 | break; |
12319 | case show_peer: | |
12320 | if (conf_if) { | |
12321 | if ((peer->conf_if | |
12322 | && !strcmp(peer->conf_if, conf_if)) | |
12323 | || (peer->hostname | |
12324 | && !strcmp(peer->hostname, conf_if))) { | |
12325 | find = 1; | |
12326 | bgp_show_peer(vty, peer, use_json, | |
12327 | json); | |
12328 | } | |
12329 | } else { | |
12330 | if (sockunion_same(&peer->su, su)) { | |
12331 | find = 1; | |
12332 | bgp_show_peer(vty, peer, use_json, | |
12333 | json); | |
12334 | } | |
12335 | } | |
12336 | break; | |
d1927ebe AS |
12337 | case show_ipv4_peer: |
12338 | case show_ipv6_peer: | |
12339 | FOREACH_SAFI (safi) { | |
12340 | if (peer->afc[afi][safi]) { | |
12341 | if (conf_if) { | |
12342 | if ((peer->conf_if | |
12343 | && !strcmp(peer->conf_if, conf_if)) | |
12344 | || (peer->hostname | |
12345 | && !strcmp(peer->hostname, conf_if))) { | |
12346 | find = 1; | |
12347 | bgp_show_peer(vty, peer, use_json, | |
12348 | json); | |
12349 | break; | |
12350 | } | |
12351 | } else { | |
12352 | if (sockunion_same(&peer->su, su)) { | |
12353 | find = 1; | |
12354 | bgp_show_peer(vty, peer, use_json, | |
12355 | json); | |
12356 | break; | |
12357 | } | |
12358 | } | |
12359 | } | |
12360 | } | |
12361 | break; | |
12362 | case show_ipv4_all: | |
12363 | case show_ipv6_all: | |
12364 | FOREACH_SAFI (safi) { | |
12365 | if (peer->afc[afi][safi]) { | |
12366 | bgp_show_peer(vty, peer, use_json, json); | |
12367 | nbr_output = true; | |
12368 | break; | |
12369 | } | |
12370 | } | |
12371 | break; | |
d62a17ae | 12372 | } |
12373 | } | |
12374 | ||
d1927ebe AS |
12375 | if ((type == show_peer || type == show_ipv4_peer || |
12376 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 12377 | if (use_json) |
12378 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
12379 | else | |
88b7d255 | 12380 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 12381 | } |
12382 | ||
d1927ebe AS |
12383 | if (type != show_peer && type != show_ipv4_peer && |
12384 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 12385 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 12386 | |
d62a17ae | 12387 | if (use_json) { |
996c9314 LB |
12388 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
12389 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 12390 | } else { |
12391 | vty_out(vty, "\n"); | |
12392 | } | |
12393 | ||
12394 | return CMD_SUCCESS; | |
12395 | } | |
12396 | ||
36235319 QY |
12397 | static void bgp_show_neighbor_graceful_restart_vty(struct vty *vty, |
12398 | enum show_type type, | |
12399 | const char *ip_str, | |
12400 | afi_t afi, bool use_json) | |
2986cac2 | 12401 | { |
12402 | ||
12403 | int ret; | |
12404 | struct bgp *bgp; | |
12405 | union sockunion su; | |
2986cac2 | 12406 | |
12407 | bgp = bgp_get_default(); | |
12408 | ||
13909c4f DS |
12409 | if (!bgp) |
12410 | return; | |
2986cac2 | 12411 | |
13909c4f DS |
12412 | if (!use_json) |
12413 | bgp_show_global_graceful_restart_mode_vty(vty, bgp, use_json, | |
12414 | NULL); | |
2986cac2 | 12415 | |
13909c4f DS |
12416 | if (ip_str) { |
12417 | ret = str2sockunion(ip_str, &su); | |
12418 | if (ret < 0) | |
13909c4f | 12419 | bgp_show_neighbor_graceful_restart( |
74a630b6 NT |
12420 | vty, bgp, type, NULL, ip_str, afi, use_json); |
12421 | else | |
12422 | bgp_show_neighbor_graceful_restart(vty, bgp, type, &su, | |
12423 | NULL, afi, use_json); | |
13909c4f DS |
12424 | } else |
12425 | bgp_show_neighbor_graceful_restart(vty, bgp, type, NULL, NULL, | |
74a630b6 | 12426 | afi, use_json); |
2986cac2 | 12427 | } |
12428 | ||
d62a17ae | 12429 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, |
71aedaa3 DS |
12430 | enum show_type type, |
12431 | const char *ip_str, | |
9f049418 | 12432 | bool use_json) |
d62a17ae | 12433 | { |
0291c246 MK |
12434 | struct listnode *node, *nnode; |
12435 | struct bgp *bgp; | |
71aedaa3 | 12436 | union sockunion su; |
0291c246 | 12437 | json_object *json = NULL; |
71aedaa3 | 12438 | int ret, is_first = 1; |
9f049418 | 12439 | bool nbr_output = false; |
d62a17ae | 12440 | |
12441 | if (use_json) | |
12442 | vty_out(vty, "{\n"); | |
12443 | ||
12444 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 12445 | nbr_output = true; |
d62a17ae | 12446 | if (use_json) { |
12447 | if (!(json = json_object_new_object())) { | |
af4c2728 | 12448 | flog_err( |
e50f7cfd | 12449 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 12450 | "Unable to allocate memory for JSON object"); |
12451 | vty_out(vty, | |
12452 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
12453 | return; | |
12454 | } | |
12455 | ||
12456 | json_object_int_add(json, "vrfId", | |
12457 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
12458 | ? -1 |
12459 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 12460 | json_object_string_add( |
12461 | json, "vrfName", | |
12462 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12463 | ? VRF_DEFAULT_NAME |
d62a17ae | 12464 | : bgp->name); |
12465 | ||
12466 | if (!is_first) | |
12467 | vty_out(vty, ",\n"); | |
12468 | else | |
12469 | is_first = 0; | |
12470 | ||
12471 | vty_out(vty, "\"%s\":", | |
12472 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12473 | ? VRF_DEFAULT_NAME |
d62a17ae | 12474 | : bgp->name); |
12475 | } else { | |
12476 | vty_out(vty, "\nInstance %s:\n", | |
12477 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 12478 | ? VRF_DEFAULT_NAME |
d62a17ae | 12479 | : bgp->name); |
12480 | } | |
71aedaa3 | 12481 | |
d1927ebe AS |
12482 | if (type == show_peer || type == show_ipv4_peer || |
12483 | type == show_ipv6_peer) { | |
71aedaa3 DS |
12484 | ret = str2sockunion(ip_str, &su); |
12485 | if (ret < 0) | |
12486 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12487 | use_json, json); | |
12488 | else | |
12489 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12490 | use_json, json); | |
12491 | } else { | |
d1927ebe | 12492 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
12493 | use_json, json); |
12494 | } | |
b77004d6 | 12495 | json_object_free(json); |
d62a17ae | 12496 | } |
12497 | ||
01cbfd04 | 12498 | if (use_json) { |
d62a17ae | 12499 | vty_out(vty, "}\n"); |
01cbfd04 QY |
12500 | json_object_free(json); |
12501 | } | |
9f049418 DS |
12502 | else if (!nbr_output) |
12503 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12504 | } |
12505 | ||
12506 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
12507 | enum show_type type, const char *ip_str, | |
9f049418 | 12508 | bool use_json) |
d62a17ae | 12509 | { |
12510 | int ret; | |
12511 | struct bgp *bgp; | |
12512 | union sockunion su; | |
12513 | json_object *json = NULL; | |
12514 | ||
12515 | if (name) { | |
12516 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
12517 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
12518 | use_json); | |
d62a17ae | 12519 | return CMD_SUCCESS; |
12520 | } else { | |
12521 | bgp = bgp_lookup_by_name(name); | |
12522 | if (!bgp) { | |
12523 | if (use_json) { | |
12524 | json = json_object_new_object(); | |
d62a17ae | 12525 | vty_out(vty, "%s\n", |
12526 | json_object_to_json_string_ext( | |
12527 | json, | |
12528 | JSON_C_TO_STRING_PRETTY)); | |
12529 | json_object_free(json); | |
12530 | } else | |
12531 | vty_out(vty, | |
9f049418 | 12532 | "%% BGP instance not found\n"); |
d62a17ae | 12533 | |
12534 | return CMD_WARNING; | |
12535 | } | |
12536 | } | |
12537 | } else { | |
12538 | bgp = bgp_get_default(); | |
12539 | } | |
12540 | ||
12541 | if (bgp) { | |
12542 | json = json_object_new_object(); | |
12543 | if (ip_str) { | |
12544 | ret = str2sockunion(ip_str, &su); | |
12545 | if (ret < 0) | |
12546 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
12547 | use_json, json); | |
12548 | else | |
12549 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
12550 | use_json, json); | |
12551 | } else { | |
12552 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
12553 | json); | |
12554 | } | |
12555 | json_object_free(json); | |
ca61fd25 DS |
12556 | } else { |
12557 | if (use_json) | |
12558 | vty_out(vty, "{}\n"); | |
12559 | else | |
12560 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 12561 | } |
12562 | ||
12563 | return CMD_SUCCESS; | |
4fb25c53 DW |
12564 | } |
12565 | ||
2986cac2 | 12566 | |
12567 | ||
12568 | /* "show [ip] bgp neighbors graceful-restart" commands. */ | |
12569 | DEFUN (show_ip_bgp_neighbors_gracrful_restart, | |
12570 | show_ip_bgp_neighbors_graceful_restart_cmd, | |
12571 | "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]", | |
12572 | SHOW_STR | |
12573 | BGP_STR | |
12574 | IP_STR | |
12575 | IPV6_STR | |
12576 | NEIGHBOR_STR | |
12577 | "Neighbor to display information about\n" | |
12578 | "Neighbor to display information about\n" | |
12579 | "Neighbor on BGP configured interface\n" | |
12580 | GR_SHOW | |
12581 | JSON_STR) | |
12582 | { | |
12583 | char *sh_arg = NULL; | |
12584 | enum show_type sh_type; | |
12585 | int idx = 0; | |
12586 | afi_t afi = AFI_MAX; | |
2986cac2 | 12587 | bool uj = use_json(argc, argv); |
12588 | ||
36235319 | 12589 | if (!argv_find_and_parse_afi(argv, argc, &idx, &afi)) |
2986cac2 | 12590 | afi = AFI_MAX; |
12591 | ||
12592 | idx++; | |
12593 | ||
12594 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
12595 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12596 | || argv_find(argv, argc, "WORD", &idx)) { | |
12597 | sh_type = show_peer; | |
12598 | sh_arg = argv[idx]->arg; | |
12599 | } else | |
12600 | sh_type = show_all; | |
12601 | ||
12602 | if (!argv_find(argv, argc, "graceful-restart", &idx)) | |
12603 | return CMD_SUCCESS; | |
12604 | ||
12605 | ||
36235319 QY |
12606 | return bgp_show_neighbor_graceful_restart_afi_all(vty, sh_type, sh_arg, |
12607 | afi, uj); | |
2986cac2 | 12608 | } |
12609 | ||
716b2d8a | 12610 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 12611 | DEFUN (show_ip_bgp_neighbors, |
12612 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 12613 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 12614 | SHOW_STR |
12615 | IP_STR | |
12616 | BGP_STR | |
f2a8972b | 12617 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
12618 | "Address Family\n" |
12619 | "Address Family\n" | |
718e3744 | 12620 | "Detailed information on TCP and BGP neighbor connections\n" |
12621 | "Neighbor to display information about\n" | |
a80beece | 12622 | "Neighbor to display information about\n" |
91d37724 | 12623 | "Neighbor on BGP configured interface\n" |
9973d184 | 12624 | JSON_STR) |
718e3744 | 12625 | { |
d62a17ae | 12626 | char *vrf = NULL; |
12627 | char *sh_arg = NULL; | |
12628 | enum show_type sh_type; | |
d1927ebe | 12629 | afi_t afi = AFI_MAX; |
718e3744 | 12630 | |
9f049418 | 12631 | bool uj = use_json(argc, argv); |
718e3744 | 12632 | |
d62a17ae | 12633 | int idx = 0; |
718e3744 | 12634 | |
9a8bdf1c PG |
12635 | /* [<vrf> VIEWVRFNAME] */ |
12636 | if (argv_find(argv, argc, "vrf", &idx)) { | |
12637 | vrf = argv[idx + 1]->arg; | |
12638 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
12639 | vrf = NULL; | |
12640 | } else if (argv_find(argv, argc, "view", &idx)) | |
12641 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 12642 | vrf = argv[idx + 1]->arg; |
718e3744 | 12643 | |
d62a17ae | 12644 | idx++; |
d1927ebe AS |
12645 | |
12646 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
12647 | sh_type = show_ipv4_all; | |
12648 | afi = AFI_IP; | |
12649 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
12650 | sh_type = show_ipv6_all; | |
12651 | afi = AFI_IP6; | |
12652 | } else { | |
12653 | sh_type = show_all; | |
12654 | } | |
12655 | ||
d62a17ae | 12656 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
12657 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
12658 | || argv_find(argv, argc, "WORD", &idx)) { | |
12659 | sh_type = show_peer; | |
12660 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
12661 | } |
12662 | ||
12663 | if (sh_type == show_peer && afi == AFI_IP) { | |
12664 | sh_type = show_ipv4_peer; | |
12665 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
12666 | sh_type = show_ipv6_peer; | |
12667 | } | |
856ca177 | 12668 | |
d62a17ae | 12669 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 12670 | } |
12671 | ||
716b2d8a | 12672 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 12673 | paths' and `show ip mbgp paths'. Those functions results are the |
12674 | same.*/ | |
f412b39a | 12675 | DEFUN (show_ip_bgp_paths, |
718e3744 | 12676 | show_ip_bgp_paths_cmd, |
46f296b4 | 12677 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 12678 | SHOW_STR |
12679 | IP_STR | |
12680 | BGP_STR | |
46f296b4 | 12681 | BGP_SAFI_HELP_STR |
718e3744 | 12682 | "Path information\n") |
12683 | { | |
d62a17ae | 12684 | vty_out(vty, "Address Refcnt Path\n"); |
12685 | aspath_print_all_vty(vty); | |
12686 | return CMD_SUCCESS; | |
718e3744 | 12687 | } |
12688 | ||
718e3744 | 12689 | #include "hash.h" |
12690 | ||
e3b78da8 | 12691 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12692 | struct vty *vty) |
718e3744 | 12693 | { |
d62a17ae | 12694 | struct community *com; |
718e3744 | 12695 | |
e3b78da8 | 12696 | com = (struct community *)bucket->data; |
3f65c5b1 | 12697 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 12698 | community_str(com, false)); |
718e3744 | 12699 | } |
12700 | ||
12701 | /* Show BGP's community internal data. */ | |
f412b39a | 12702 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 12703 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 12704 | "show [ip] bgp community-info", |
718e3744 | 12705 | SHOW_STR |
12706 | IP_STR | |
12707 | BGP_STR | |
12708 | "List all bgp community information\n") | |
12709 | { | |
d62a17ae | 12710 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 12711 | |
d62a17ae | 12712 | hash_iterate(community_hash(), |
e3b78da8 | 12713 | (void (*)(struct hash_bucket *, |
d62a17ae | 12714 | void *))community_show_all_iterator, |
12715 | vty); | |
718e3744 | 12716 | |
d62a17ae | 12717 | return CMD_SUCCESS; |
718e3744 | 12718 | } |
12719 | ||
e3b78da8 | 12720 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 12721 | struct vty *vty) |
57d187bc | 12722 | { |
d62a17ae | 12723 | struct lcommunity *lcom; |
57d187bc | 12724 | |
e3b78da8 | 12725 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 12726 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 12727 | lcommunity_str(lcom, false)); |
57d187bc JS |
12728 | } |
12729 | ||
12730 | /* Show BGP's community internal data. */ | |
12731 | DEFUN (show_ip_bgp_lcommunity_info, | |
12732 | show_ip_bgp_lcommunity_info_cmd, | |
12733 | "show ip bgp large-community-info", | |
12734 | SHOW_STR | |
12735 | IP_STR | |
12736 | BGP_STR | |
12737 | "List all bgp large-community information\n") | |
12738 | { | |
d62a17ae | 12739 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 12740 | |
d62a17ae | 12741 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 12742 | (void (*)(struct hash_bucket *, |
d62a17ae | 12743 | void *))lcommunity_show_all_iterator, |
12744 | vty); | |
57d187bc | 12745 | |
d62a17ae | 12746 | return CMD_SUCCESS; |
57d187bc | 12747 | } |
2986cac2 | 12748 | /* Graceful Restart */ |
12749 | ||
12750 | static void bgp_show_global_graceful_restart_mode_vty(struct vty *vty, | |
36235319 QY |
12751 | struct bgp *bgp, |
12752 | bool use_json, | |
12753 | json_object *json) | |
2986cac2 | 12754 | { |
57d187bc JS |
12755 | |
12756 | ||
2986cac2 | 12757 | vty_out(vty, "\n%s", SHOW_GR_HEADER); |
12758 | ||
7318ae88 | 12759 | enum global_mode bgp_global_gr_mode = bgp_global_gr_mode_get(bgp); |
2986cac2 | 12760 | |
12761 | switch (bgp_global_gr_mode) { | |
12762 | ||
12763 | case GLOBAL_HELPER: | |
13909c4f | 12764 | vty_out(vty, "Global BGP GR Mode : Helper\n"); |
2986cac2 | 12765 | break; |
12766 | ||
12767 | case GLOBAL_GR: | |
13909c4f | 12768 | vty_out(vty, "Global BGP GR Mode : Restart\n"); |
2986cac2 | 12769 | break; |
12770 | ||
12771 | case GLOBAL_DISABLE: | |
13909c4f | 12772 | vty_out(vty, "Global BGP GR Mode : Disable\n"); |
2986cac2 | 12773 | break; |
12774 | ||
12775 | case GLOBAL_INVALID: | |
2986cac2 | 12776 | vty_out(vty, |
2ba1fe69 | 12777 | "Global BGP GR Mode Invalid\n"); |
2986cac2 | 12778 | break; |
12779 | } | |
12780 | vty_out(vty, "\n"); | |
12781 | } | |
12782 | ||
36235319 QY |
12783 | static int bgp_show_neighbor_graceful_restart_afi_all(struct vty *vty, |
12784 | enum show_type type, | |
12785 | const char *ip_str, | |
12786 | afi_t afi, bool use_json) | |
2986cac2 | 12787 | { |
12788 | if ((afi == AFI_MAX) && (ip_str == NULL)) { | |
12789 | afi = AFI_IP; | |
12790 | ||
12791 | while ((afi != AFI_L2VPN) && (afi < AFI_MAX)) { | |
12792 | ||
36235319 QY |
12793 | bgp_show_neighbor_graceful_restart_vty( |
12794 | vty, type, ip_str, afi, use_json); | |
2986cac2 | 12795 | afi++; |
12796 | } | |
12797 | } else if (afi != AFI_MAX) { | |
36235319 QY |
12798 | bgp_show_neighbor_graceful_restart_vty(vty, type, ip_str, afi, |
12799 | use_json); | |
2986cac2 | 12800 | } else { |
12801 | return CMD_ERR_INCOMPLETE; | |
12802 | } | |
12803 | ||
12804 | return CMD_SUCCESS; | |
12805 | } | |
12806 | /* Graceful Restart */ | |
12807 | ||
f412b39a | 12808 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 12809 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 12810 | "show [ip] bgp attribute-info", |
718e3744 | 12811 | SHOW_STR |
12812 | IP_STR | |
12813 | BGP_STR | |
12814 | "List all bgp attribute information\n") | |
12815 | { | |
d62a17ae | 12816 | attr_show_all(vty); |
12817 | return CMD_SUCCESS; | |
718e3744 | 12818 | } |
6b0655a2 | 12819 | |
03915806 CS |
12820 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
12821 | afi_t afi, safi_t safi, | |
12822 | bool use_json, json_object *json) | |
53089bec | 12823 | { |
12824 | struct bgp *bgp; | |
12825 | struct listnode *node; | |
12826 | char *vname; | |
12827 | char buf1[INET6_ADDRSTRLEN]; | |
12828 | char *ecom_str; | |
12829 | vpn_policy_direction_t dir; | |
12830 | ||
03915806 | 12831 | if (json) { |
b46dfd20 DS |
12832 | json_object *json_import_vrfs = NULL; |
12833 | json_object *json_export_vrfs = NULL; | |
12834 | ||
b46dfd20 DS |
12835 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12836 | ||
53089bec | 12837 | if (!bgp) { |
b46dfd20 DS |
12838 | vty_out(vty, "%s\n", |
12839 | json_object_to_json_string_ext( | |
12840 | json, | |
12841 | JSON_C_TO_STRING_PRETTY)); | |
12842 | json_object_free(json); | |
12843 | ||
53089bec | 12844 | return CMD_WARNING; |
12845 | } | |
b46dfd20 | 12846 | |
94d4c685 DS |
12847 | /* Provide context for the block */ |
12848 | json_object_string_add(json, "vrf", name ? name : "default"); | |
12849 | json_object_string_add(json, "afiSafi", | |
5cb5f4d0 | 12850 | get_afi_safi_str(afi, safi, true)); |
94d4c685 | 12851 | |
b46dfd20 DS |
12852 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12853 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
12854 | json_object_string_add(json, "importFromVrfs", "none"); | |
12855 | json_object_string_add(json, "importRts", "none"); | |
12856 | } else { | |
6ce24e52 DS |
12857 | json_import_vrfs = json_object_new_array(); |
12858 | ||
b46dfd20 DS |
12859 | for (ALL_LIST_ELEMENTS_RO( |
12860 | bgp->vpn_policy[afi].import_vrf, | |
12861 | node, vname)) | |
12862 | json_object_array_add(json_import_vrfs, | |
12863 | json_object_new_string(vname)); | |
12864 | ||
b20875ea CS |
12865 | json_object_object_add(json, "importFromVrfs", |
12866 | json_import_vrfs); | |
b46dfd20 | 12867 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
12868 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12869 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12870 | bgp->vpn_policy[afi].rtlist[dir], |
12871 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12872 | json_object_string_add(json, "importRts", |
12873 | ecom_str); | |
12874 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12875 | } else | |
12876 | json_object_string_add(json, "importRts", | |
12877 | "none"); | |
b46dfd20 DS |
12878 | } |
12879 | ||
12880 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
12881 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
12882 | json_object_string_add(json, "exportToVrfs", "none"); | |
12883 | json_object_string_add(json, "routeDistinguisher", | |
12884 | "none"); | |
12885 | json_object_string_add(json, "exportRts", "none"); | |
12886 | } else { | |
6ce24e52 DS |
12887 | json_export_vrfs = json_object_new_array(); |
12888 | ||
b46dfd20 DS |
12889 | for (ALL_LIST_ELEMENTS_RO( |
12890 | bgp->vpn_policy[afi].export_vrf, | |
12891 | node, vname)) | |
12892 | json_object_array_add(json_export_vrfs, | |
12893 | json_object_new_string(vname)); | |
12894 | json_object_object_add(json, "exportToVrfs", | |
12895 | json_export_vrfs); | |
12896 | json_object_string_add(json, "routeDistinguisher", | |
12897 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12898 | buf1, RD_ADDRSTRLEN)); | |
12899 | ||
12900 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12901 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12902 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12903 | bgp->vpn_policy[afi].rtlist[dir], |
12904 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12905 | json_object_string_add(json, "exportRts", |
12906 | ecom_str); | |
12907 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12908 | } else | |
12909 | json_object_string_add(json, "exportRts", | |
12910 | "none"); | |
b46dfd20 DS |
12911 | } |
12912 | ||
03915806 CS |
12913 | if (use_json) { |
12914 | vty_out(vty, "%s\n", | |
12915 | json_object_to_json_string_ext(json, | |
b46dfd20 | 12916 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
12917 | json_object_free(json); |
12918 | } | |
53089bec | 12919 | } else { |
b46dfd20 DS |
12920 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
12921 | ||
53089bec | 12922 | if (!bgp) { |
b46dfd20 | 12923 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 12924 | return CMD_WARNING; |
12925 | } | |
53089bec | 12926 | |
b46dfd20 DS |
12927 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12928 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
12929 | vty_out(vty, | |
12930 | "This VRF is not importing %s routes from any other VRF\n", | |
5cb5f4d0 | 12931 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12932 | else { |
12933 | vty_out(vty, | |
12934 | "This VRF is importing %s routes from the following VRFs:\n", | |
5cb5f4d0 | 12935 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12936 | |
12937 | for (ALL_LIST_ELEMENTS_RO( | |
12938 | bgp->vpn_policy[afi].import_vrf, | |
12939 | node, vname)) | |
12940 | vty_out(vty, " %s\n", vname); | |
12941 | ||
12942 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
12943 | ecom_str = NULL; |
12944 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
12945 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12946 | bgp->vpn_policy[afi].rtlist[dir], |
12947 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 12948 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 12949 | |
b20875ea CS |
12950 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
12951 | } else | |
12952 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12953 | } |
53089bec | 12954 | |
b46dfd20 DS |
12955 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
12956 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12957 | vty_out(vty, | |
12958 | "This VRF is not exporting %s routes to any other VRF\n", | |
5cb5f4d0 | 12959 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12960 | else { |
12961 | vty_out(vty, | |
04c9077f | 12962 | "This VRF is exporting %s routes to the following VRFs:\n", |
5cb5f4d0 | 12963 | get_afi_safi_str(afi, safi, false)); |
b46dfd20 DS |
12964 | |
12965 | for (ALL_LIST_ELEMENTS_RO( | |
12966 | bgp->vpn_policy[afi].export_vrf, | |
12967 | node, vname)) | |
12968 | vty_out(vty, " %s\n", vname); | |
12969 | ||
12970 | vty_out(vty, "RD: %s\n", | |
12971 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
12972 | buf1, RD_ADDRSTRLEN)); | |
12973 | ||
12974 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
12975 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
12976 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
12977 | bgp->vpn_policy[afi].rtlist[dir], |
12978 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
12979 | vty_out(vty, "Export RT: %s\n", ecom_str); |
12980 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
12981 | } else | |
12982 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 12983 | } |
53089bec | 12984 | } |
12985 | ||
12986 | return CMD_SUCCESS; | |
12987 | } | |
12988 | ||
03915806 CS |
12989 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
12990 | safi_t safi, bool use_json) | |
12991 | { | |
12992 | struct listnode *node, *nnode; | |
12993 | struct bgp *bgp; | |
12994 | char *vrf_name = NULL; | |
12995 | json_object *json = NULL; | |
12996 | json_object *json_vrf = NULL; | |
12997 | json_object *json_vrfs = NULL; | |
12998 | ||
12999 | if (use_json) { | |
13000 | json = json_object_new_object(); | |
13001 | json_vrfs = json_object_new_object(); | |
13002 | } | |
13003 | ||
13004 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
13005 | ||
13006 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
13007 | vrf_name = bgp->name; | |
13008 | ||
13009 | if (use_json) { | |
13010 | json_vrf = json_object_new_object(); | |
13011 | } else { | |
13012 | vty_out(vty, "\nInstance %s:\n", | |
13013 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13014 | ? VRF_DEFAULT_NAME : bgp->name); | |
13015 | } | |
13016 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
13017 | if (use_json) { | |
13018 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
13019 | json_object_object_add(json_vrfs, | |
13020 | VRF_DEFAULT_NAME, json_vrf); | |
13021 | else | |
13022 | json_object_object_add(json_vrfs, vrf_name, | |
13023 | json_vrf); | |
13024 | } | |
13025 | } | |
13026 | ||
13027 | if (use_json) { | |
13028 | json_object_object_add(json, "vrfs", json_vrfs); | |
13029 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
13030 | JSON_C_TO_STRING_PRETTY)); | |
13031 | json_object_free(json); | |
13032 | } | |
13033 | ||
13034 | return CMD_SUCCESS; | |
13035 | } | |
13036 | ||
53089bec | 13037 | /* "show [ip] bgp route-leak" command. */ |
13038 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
13039 | show_ip_bgp_route_leak_cmd, |
13040 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
13041 | SHOW_STR |
13042 | IP_STR | |
13043 | BGP_STR | |
13044 | BGP_INSTANCE_HELP_STR | |
13045 | BGP_AFI_HELP_STR | |
13046 | BGP_SAFI_HELP_STR | |
13047 | "Route leaking information\n" | |
13048 | JSON_STR) | |
53089bec | 13049 | { |
13050 | char *vrf = NULL; | |
13051 | afi_t afi = AFI_MAX; | |
13052 | safi_t safi = SAFI_MAX; | |
13053 | ||
9f049418 | 13054 | bool uj = use_json(argc, argv); |
53089bec | 13055 | int idx = 0; |
03915806 | 13056 | json_object *json = NULL; |
53089bec | 13057 | |
13058 | /* show [ip] bgp */ | |
13059 | if (argv_find(argv, argc, "ip", &idx)) { | |
13060 | afi = AFI_IP; | |
13061 | safi = SAFI_UNICAST; | |
13062 | } | |
13063 | /* [vrf VIEWVRFNAME] */ | |
13064 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
13065 | vty_out(vty, |
13066 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 13067 | return CMD_WARNING; |
13068 | } | |
13069 | ||
9a8bdf1c PG |
13070 | if (argv_find(argv, argc, "vrf", &idx)) { |
13071 | vrf = argv[idx + 1]->arg; | |
13072 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13073 | vrf = NULL; | |
13074 | } | |
53089bec | 13075 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13076 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13077 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13078 | } | |
13079 | ||
13080 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
13081 | vty_out(vty, |
13082 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 13083 | return CMD_WARNING; |
13084 | } | |
13085 | ||
03915806 CS |
13086 | if (vrf && strmatch(vrf, "all")) |
13087 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
13088 | ||
13089 | if (uj) | |
13090 | json = json_object_new_object(); | |
13091 | ||
13092 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 13093 | } |
13094 | ||
d62a17ae | 13095 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
13096 | safi_t safi) | |
f186de26 | 13097 | { |
d62a17ae | 13098 | struct listnode *node, *nnode; |
13099 | struct bgp *bgp; | |
f186de26 | 13100 | |
d62a17ae | 13101 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
13102 | vty_out(vty, "\nInstance %s:\n", | |
13103 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 13104 | ? VRF_DEFAULT_NAME |
d62a17ae | 13105 | : bgp->name); |
13106 | update_group_show(bgp, afi, safi, vty, 0); | |
13107 | } | |
f186de26 | 13108 | } |
13109 | ||
d62a17ae | 13110 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
13111 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 13112 | { |
d62a17ae | 13113 | struct bgp *bgp; |
4fb25c53 | 13114 | |
d62a17ae | 13115 | if (name) { |
13116 | if (strmatch(name, "all")) { | |
13117 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
13118 | return CMD_SUCCESS; | |
13119 | } else { | |
13120 | bgp = bgp_lookup_by_name(name); | |
13121 | } | |
13122 | } else { | |
13123 | bgp = bgp_get_default(); | |
13124 | } | |
4fb25c53 | 13125 | |
d62a17ae | 13126 | if (bgp) |
13127 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
13128 | return CMD_SUCCESS; | |
4fb25c53 DW |
13129 | } |
13130 | ||
8fe8a7f6 DS |
13131 | DEFUN (show_ip_bgp_updgrps, |
13132 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 13133 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 13134 | SHOW_STR |
13135 | IP_STR | |
13136 | BGP_STR | |
13137 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 13138 | BGP_AFI_HELP_STR |
9bedbb1e | 13139 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
13140 | "Detailed info about dynamic update groups\n" |
13141 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 13142 | { |
d62a17ae | 13143 | char *vrf = NULL; |
13144 | afi_t afi = AFI_IP6; | |
13145 | safi_t safi = SAFI_UNICAST; | |
13146 | uint64_t subgrp_id = 0; | |
13147 | ||
13148 | int idx = 0; | |
13149 | ||
13150 | /* show [ip] bgp */ | |
13151 | if (argv_find(argv, argc, "ip", &idx)) | |
13152 | afi = AFI_IP; | |
9a8bdf1c PG |
13153 | /* [<vrf> VIEWVRFNAME] */ |
13154 | if (argv_find(argv, argc, "vrf", &idx)) { | |
13155 | vrf = argv[idx + 1]->arg; | |
13156 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
13157 | vrf = NULL; | |
13158 | } else if (argv_find(argv, argc, "view", &idx)) | |
13159 | /* [<view> VIEWVRFNAME] */ | |
13160 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 13161 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
13162 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
13163 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
13164 | } | |
5bf15956 | 13165 | |
d62a17ae | 13166 | /* get subgroup id, if provided */ |
13167 | idx = argc - 1; | |
13168 | if (argv[idx]->type == VARIABLE_TKN) | |
13169 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 13170 | |
d62a17ae | 13171 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
13172 | } |
13173 | ||
f186de26 | 13174 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
13175 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 13176 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 13177 | SHOW_STR |
716b2d8a | 13178 | IP_STR |
f186de26 | 13179 | BGP_STR |
13180 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 13181 | "Detailed info about dynamic update groups\n") |
f186de26 | 13182 | { |
d62a17ae | 13183 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
13184 | return CMD_SUCCESS; | |
f186de26 | 13185 | } |
13186 | ||
43d3f4fc DS |
13187 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
13188 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
13189 | "show [ip] bgp l2vpn evpn update-groups", | |
13190 | SHOW_STR | |
13191 | IP_STR | |
13192 | BGP_STR | |
13193 | "l2vpn address family\n" | |
13194 | "evpn sub-address family\n" | |
13195 | "Detailed info about dynamic update groups\n") | |
13196 | { | |
13197 | char *vrf = NULL; | |
13198 | uint64_t subgrp_id = 0; | |
13199 | ||
13200 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
13201 | return CMD_SUCCESS; | |
13202 | } | |
13203 | ||
5bf15956 DW |
13204 | DEFUN (show_bgp_updgrps_stats, |
13205 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 13206 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 13207 | SHOW_STR |
716b2d8a | 13208 | IP_STR |
3f9c7369 | 13209 | BGP_STR |
0c7b1b01 | 13210 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
13211 | "Statistics\n") |
13212 | { | |
d62a17ae | 13213 | struct bgp *bgp; |
3f9c7369 | 13214 | |
d62a17ae | 13215 | bgp = bgp_get_default(); |
13216 | if (bgp) | |
13217 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 13218 | |
d62a17ae | 13219 | return CMD_SUCCESS; |
3f9c7369 DS |
13220 | } |
13221 | ||
8386ac43 | 13222 | DEFUN (show_bgp_instance_updgrps_stats, |
13223 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 13224 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 13225 | SHOW_STR |
716b2d8a | 13226 | IP_STR |
8386ac43 | 13227 | BGP_STR |
13228 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 13229 | "Detailed info about dynamic update groups\n" |
8386ac43 | 13230 | "Statistics\n") |
13231 | { | |
d62a17ae | 13232 | int idx_word = 3; |
13233 | struct bgp *bgp; | |
8386ac43 | 13234 | |
d62a17ae | 13235 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
13236 | if (bgp) | |
13237 | update_group_show_stats(bgp, vty); | |
8386ac43 | 13238 | |
d62a17ae | 13239 | return CMD_SUCCESS; |
8386ac43 | 13240 | } |
13241 | ||
d62a17ae | 13242 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
13243 | afi_t afi, safi_t safi, | |
13244 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 13245 | { |
d62a17ae | 13246 | struct bgp *bgp; |
8386ac43 | 13247 | |
d62a17ae | 13248 | if (name) |
13249 | bgp = bgp_lookup_by_name(name); | |
13250 | else | |
13251 | bgp = bgp_get_default(); | |
8386ac43 | 13252 | |
d62a17ae | 13253 | if (bgp) { |
13254 | if (!strcmp(what, "advertise-queue")) | |
13255 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
13256 | subgrp_id); | |
13257 | else if (!strcmp(what, "advertised-routes")) | |
13258 | update_group_show_advertised(bgp, afi, safi, vty, | |
13259 | subgrp_id); | |
13260 | else if (!strcmp(what, "packet-queue")) | |
13261 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
13262 | subgrp_id); | |
13263 | } | |
3f9c7369 DS |
13264 | } |
13265 | ||
dc64bdec QY |
13266 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
13267 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
13268 | "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", | |
13269 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
13270 | BGP_SAFI_HELP_STR | |
13271 | "Detailed info about dynamic update groups\n" | |
13272 | "Specific subgroup to display info for\n" | |
13273 | "Advertisement queue\n" | |
13274 | "Announced routes\n" | |
13275 | "Packet queue\n") | |
3f9c7369 | 13276 | { |
dc64bdec QY |
13277 | uint64_t subgrp_id = 0; |
13278 | afi_t afiz; | |
13279 | safi_t safiz; | |
13280 | if (sgid) | |
13281 | subgrp_id = strtoull(sgid, NULL, 10); | |
13282 | ||
13283 | if (!ip && !afi) | |
13284 | afiz = AFI_IP6; | |
13285 | if (!ip && afi) | |
13286 | afiz = bgp_vty_afi_from_str(afi); | |
13287 | if (ip && !afi) | |
13288 | afiz = AFI_IP; | |
13289 | if (ip && afi) { | |
13290 | afiz = bgp_vty_afi_from_str(afi); | |
13291 | if (afiz != AFI_IP) | |
13292 | vty_out(vty, | |
13293 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
13294 | return CMD_WARNING; | |
13295 | } | |
d62a17ae | 13296 | |
dc64bdec | 13297 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 13298 | |
dc64bdec | 13299 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 13300 | return CMD_SUCCESS; |
13301 | } | |
13302 | ||
d62a17ae | 13303 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
13304 | { | |
13305 | struct listnode *node, *nnode; | |
13306 | struct prefix *range; | |
13307 | struct peer *conf; | |
13308 | struct peer *peer; | |
13309 | char buf[PREFIX2STR_BUFFER]; | |
13310 | afi_t afi; | |
13311 | safi_t safi; | |
13312 | const char *peer_status; | |
13313 | const char *af_str; | |
13314 | int lr_count; | |
13315 | int dynamic; | |
13316 | int af_cfgd; | |
13317 | ||
13318 | conf = group->conf; | |
13319 | ||
13320 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
13321 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13322 | group->name, conf->as); | |
d62a17ae | 13323 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
13324 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
13325 | group->name, group->bgp->as); | |
d62a17ae | 13326 | } else { |
13327 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
13328 | } | |
f14e6fdb | 13329 | |
d62a17ae | 13330 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
13331 | vty_out(vty, " Peer-group type is internal\n"); | |
13332 | else | |
13333 | vty_out(vty, " Peer-group type is external\n"); | |
13334 | ||
13335 | /* Display AFs configured. */ | |
13336 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
13337 | FOREACH_AFI_SAFI (afi, safi) { |
13338 | if (conf->afc[afi][safi]) { | |
13339 | af_cfgd = 1; | |
5cb5f4d0 | 13340 | vty_out(vty, " %s;", get_afi_safi_str(afi, safi, false)); |
d62a17ae | 13341 | } |
05c7a1cc | 13342 | } |
d62a17ae | 13343 | if (!af_cfgd) |
13344 | vty_out(vty, " none\n"); | |
13345 | else | |
13346 | vty_out(vty, "\n"); | |
13347 | ||
13348 | /* Display listen ranges (for dynamic neighbors), if any */ | |
13349 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
13350 | if (afi == AFI_IP) | |
13351 | af_str = "IPv4"; | |
13352 | else if (afi == AFI_IP6) | |
13353 | af_str = "IPv6"; | |
13354 | else | |
13355 | af_str = "???"; | |
13356 | lr_count = listcount(group->listen_range[afi]); | |
13357 | if (lr_count) { | |
13358 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
13359 | af_str); | |
13360 | ||
13361 | ||
13362 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
13363 | nnode, range)) { | |
13364 | prefix2str(range, buf, sizeof(buf)); | |
13365 | vty_out(vty, " %s\n", buf); | |
13366 | } | |
13367 | } | |
13368 | } | |
f14e6fdb | 13369 | |
d62a17ae | 13370 | /* Display group members and their status */ |
13371 | if (listcount(group->peer)) { | |
13372 | vty_out(vty, " Peer-group members:\n"); | |
13373 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
13374 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
13375 | peer_status = "Idle (Admin)"; | |
13376 | else if (CHECK_FLAG(peer->sflags, | |
13377 | PEER_STATUS_PREFIX_OVERFLOW)) | |
13378 | peer_status = "Idle (PfxCt)"; | |
13379 | else | |
13380 | peer_status = lookup_msg(bgp_status_msg, | |
13381 | peer->status, NULL); | |
13382 | ||
13383 | dynamic = peer_dynamic_neighbor(peer); | |
13384 | vty_out(vty, " %s %s %s \n", peer->host, | |
13385 | dynamic ? "(dynamic)" : "", peer_status); | |
13386 | } | |
13387 | } | |
f14e6fdb | 13388 | |
d62a17ae | 13389 | return CMD_SUCCESS; |
13390 | } | |
13391 | ||
ff9959b0 QY |
13392 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
13393 | const char *group_name) | |
d62a17ae | 13394 | { |
ff9959b0 | 13395 | struct bgp *bgp; |
d62a17ae | 13396 | struct listnode *node, *nnode; |
13397 | struct peer_group *group; | |
ff9959b0 QY |
13398 | bool found = false; |
13399 | ||
13400 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
13401 | ||
13402 | if (!bgp) { | |
9f049418 | 13403 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
13404 | return CMD_WARNING; |
13405 | } | |
d62a17ae | 13406 | |
13407 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
13408 | if (group_name) { |
13409 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 13410 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
13411 | found = true; |
13412 | break; | |
d62a17ae | 13413 | } |
ff9959b0 QY |
13414 | } else { |
13415 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 13416 | } |
f14e6fdb | 13417 | } |
f14e6fdb | 13418 | |
ff9959b0 | 13419 | if (group_name && !found) |
d62a17ae | 13420 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 13421 | |
d62a17ae | 13422 | return CMD_SUCCESS; |
f14e6fdb DS |
13423 | } |
13424 | ||
f14e6fdb DS |
13425 | DEFUN (show_ip_bgp_peer_groups, |
13426 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 13427 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
13428 | SHOW_STR |
13429 | IP_STR | |
13430 | BGP_STR | |
8386ac43 | 13431 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
13432 | "Detailed information on BGP peer groups\n" |
13433 | "Peer group name\n") | |
f14e6fdb | 13434 | { |
d62a17ae | 13435 | char *vrf, *pg; |
d62a17ae | 13436 | int idx = 0; |
f14e6fdb | 13437 | |
a4d82a8a PZ |
13438 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
13439 | : NULL; | |
d62a17ae | 13440 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 13441 | |
ff9959b0 | 13442 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 13443 | } |
3f9c7369 | 13444 | |
d6e3c605 | 13445 | |
718e3744 | 13446 | /* Redistribute VTY commands. */ |
13447 | ||
718e3744 | 13448 | DEFUN (bgp_redistribute_ipv4, |
13449 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 13450 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 13451 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13452 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 13453 | { |
d62a17ae | 13454 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13455 | int idx_protocol = 1; | |
13456 | int type; | |
718e3744 | 13457 | |
d62a17ae | 13458 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13459 | if (type < 0) { | |
13460 | vty_out(vty, "%% Invalid route type\n"); | |
13461 | return CMD_WARNING_CONFIG_FAILED; | |
13462 | } | |
7f323236 | 13463 | |
d62a17ae | 13464 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 13465 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 13466 | } |
13467 | ||
d62a17ae | 13468 | ALIAS_HIDDEN( |
13469 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
13470 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
13471 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 13472 | |
718e3744 | 13473 | DEFUN (bgp_redistribute_ipv4_rmap, |
13474 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 13475 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13476 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13477 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13478 | "Route map reference\n" |
13479 | "Pointer to route-map entries\n") | |
13480 | { | |
d62a17ae | 13481 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13482 | int idx_protocol = 1; | |
13483 | int idx_word = 3; | |
13484 | int type; | |
13485 | struct bgp_redist *red; | |
e923dd62 | 13486 | bool changed; |
1de27621 DA |
13487 | struct route_map *route_map = route_map_lookup_warn_noexist( |
13488 | vty, argv[idx_word]->arg); | |
718e3744 | 13489 | |
d62a17ae | 13490 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
13491 | if (type < 0) { | |
13492 | vty_out(vty, "%% Invalid route type\n"); | |
13493 | return CMD_WARNING_CONFIG_FAILED; | |
13494 | } | |
718e3744 | 13495 | |
d62a17ae | 13496 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
13497 | changed = |
13498 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13499 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 13500 | } |
13501 | ||
d62a17ae | 13502 | ALIAS_HIDDEN( |
13503 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
13504 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
13505 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13506 | "Route map reference\n" | |
13507 | "Pointer to route-map entries\n") | |
596c17ba | 13508 | |
718e3744 | 13509 | DEFUN (bgp_redistribute_ipv4_metric, |
13510 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 13511 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13512 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13513 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13514 | "Metric for redistributed routes\n" |
13515 | "Default metric\n") | |
13516 | { | |
d62a17ae | 13517 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13518 | int idx_protocol = 1; | |
13519 | int idx_number = 3; | |
13520 | int type; | |
d7c0a89a | 13521 | uint32_t metric; |
d62a17ae | 13522 | struct bgp_redist *red; |
e923dd62 | 13523 | bool changed; |
d62a17ae | 13524 | |
13525 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13526 | if (type < 0) { | |
13527 | vty_out(vty, "%% Invalid route type\n"); | |
13528 | return CMD_WARNING_CONFIG_FAILED; | |
13529 | } | |
13530 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13531 | ||
13532 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13533 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13534 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13535 | } |
13536 | ||
13537 | ALIAS_HIDDEN( | |
13538 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
13539 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
13540 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13541 | "Metric for redistributed routes\n" | |
13542 | "Default metric\n") | |
596c17ba | 13543 | |
718e3744 | 13544 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
13545 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 13546 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 13547 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13548 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13549 | "Route map reference\n" |
13550 | "Pointer to route-map entries\n" | |
13551 | "Metric for redistributed routes\n" | |
13552 | "Default metric\n") | |
13553 | { | |
d62a17ae | 13554 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13555 | int idx_protocol = 1; | |
13556 | int idx_word = 3; | |
13557 | int idx_number = 5; | |
13558 | int type; | |
d7c0a89a | 13559 | uint32_t metric; |
d62a17ae | 13560 | struct bgp_redist *red; |
e923dd62 | 13561 | bool changed; |
1de27621 DA |
13562 | struct route_map *route_map = |
13563 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13564 | |
13565 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13566 | if (type < 0) { | |
13567 | vty_out(vty, "%% Invalid route type\n"); | |
13568 | return CMD_WARNING_CONFIG_FAILED; | |
13569 | } | |
13570 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13571 | ||
13572 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
13573 | changed = |
13574 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13575 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
13576 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 13577 | } |
13578 | ||
13579 | ALIAS_HIDDEN( | |
13580 | bgp_redistribute_ipv4_rmap_metric, | |
13581 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
13582 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13583 | " route-map WORD metric (0-4294967295)", | |
13584 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13585 | "Route map reference\n" | |
13586 | "Pointer to route-map entries\n" | |
13587 | "Metric for redistributed routes\n" | |
13588 | "Default metric\n") | |
596c17ba | 13589 | |
718e3744 | 13590 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
13591 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 13592 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 13593 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13594 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 13595 | "Metric for redistributed routes\n" |
13596 | "Default metric\n" | |
13597 | "Route map reference\n" | |
13598 | "Pointer to route-map entries\n") | |
13599 | { | |
d62a17ae | 13600 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13601 | int idx_protocol = 1; | |
13602 | int idx_number = 3; | |
13603 | int idx_word = 5; | |
13604 | int type; | |
d7c0a89a | 13605 | uint32_t metric; |
d62a17ae | 13606 | struct bgp_redist *red; |
e923dd62 | 13607 | bool changed; |
1de27621 DA |
13608 | struct route_map *route_map = |
13609 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13610 | |
13611 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13612 | if (type < 0) { | |
13613 | vty_out(vty, "%% Invalid route type\n"); | |
13614 | return CMD_WARNING_CONFIG_FAILED; | |
13615 | } | |
13616 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
13617 | ||
13618 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 13619 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
13620 | changed |= |
13621 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13622 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 13623 | } |
13624 | ||
13625 | ALIAS_HIDDEN( | |
13626 | bgp_redistribute_ipv4_metric_rmap, | |
13627 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
13628 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
13629 | " metric (0-4294967295) route-map WORD", | |
13630 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13631 | "Metric for redistributed routes\n" | |
13632 | "Default metric\n" | |
13633 | "Route map reference\n" | |
13634 | "Pointer to route-map entries\n") | |
596c17ba | 13635 | |
7c8ff89e DS |
13636 | DEFUN (bgp_redistribute_ipv4_ospf, |
13637 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 13638 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
13639 | "Redistribute information from another routing protocol\n" |
13640 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13641 | "Non-main Kernel Routing Table\n" |
13642 | "Instance ID/Table ID\n") | |
7c8ff89e | 13643 | { |
d62a17ae | 13644 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13645 | int idx_ospf_table = 1; | |
13646 | int idx_number = 2; | |
d7c0a89a QY |
13647 | unsigned short instance; |
13648 | unsigned short protocol; | |
7c8ff89e | 13649 | |
d62a17ae | 13650 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 13651 | |
d62a17ae | 13652 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
13653 | protocol = ZEBRA_ROUTE_OSPF; | |
13654 | else | |
13655 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 13656 | |
d62a17ae | 13657 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 13658 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
13659 | } |
13660 | ||
d62a17ae | 13661 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
13662 | "redistribute <ospf|table> (1-65535)", | |
13663 | "Redistribute information from another routing protocol\n" | |
13664 | "Open Shortest Path First (OSPFv2)\n" | |
13665 | "Non-main Kernel Routing Table\n" | |
13666 | "Instance ID/Table ID\n") | |
596c17ba | 13667 | |
7c8ff89e DS |
13668 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
13669 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 13670 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
13671 | "Redistribute information from another routing protocol\n" |
13672 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13673 | "Non-main Kernel Routing Table\n" |
13674 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13675 | "Route map reference\n" |
13676 | "Pointer to route-map entries\n") | |
13677 | { | |
d62a17ae | 13678 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13679 | int idx_ospf_table = 1; | |
13680 | int idx_number = 2; | |
13681 | int idx_word = 4; | |
13682 | struct bgp_redist *red; | |
d7c0a89a | 13683 | unsigned short instance; |
d62a17ae | 13684 | int protocol; |
e923dd62 | 13685 | bool changed; |
1de27621 DA |
13686 | struct route_map *route_map = |
13687 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13688 | |
13689 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13690 | protocol = ZEBRA_ROUTE_OSPF; | |
13691 | else | |
13692 | protocol = ZEBRA_ROUTE_TABLE; | |
13693 | ||
13694 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13695 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13696 | changed = |
13697 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13698 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13699 | } |
13700 | ||
13701 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
13702 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
13703 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
13704 | "Redistribute information from another routing protocol\n" | |
13705 | "Open Shortest Path First (OSPFv2)\n" | |
13706 | "Non-main Kernel Routing Table\n" | |
13707 | "Instance ID/Table ID\n" | |
13708 | "Route map reference\n" | |
13709 | "Pointer to route-map entries\n") | |
596c17ba | 13710 | |
7c8ff89e DS |
13711 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
13712 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 13713 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
13714 | "Redistribute information from another routing protocol\n" |
13715 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13716 | "Non-main Kernel Routing Table\n" |
13717 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13718 | "Metric for redistributed routes\n" |
13719 | "Default metric\n") | |
13720 | { | |
d62a17ae | 13721 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13722 | int idx_ospf_table = 1; | |
13723 | int idx_number = 2; | |
13724 | int idx_number_2 = 4; | |
d7c0a89a | 13725 | uint32_t metric; |
d62a17ae | 13726 | struct bgp_redist *red; |
d7c0a89a | 13727 | unsigned short instance; |
d62a17ae | 13728 | int protocol; |
e923dd62 | 13729 | bool changed; |
d62a17ae | 13730 | |
13731 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13732 | protocol = ZEBRA_ROUTE_OSPF; | |
13733 | else | |
13734 | protocol = ZEBRA_ROUTE_TABLE; | |
13735 | ||
13736 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13737 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13738 | ||
13739 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13740 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13741 | metric); | |
13742 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13743 | } |
13744 | ||
13745 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
13746 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
13747 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
13748 | "Redistribute information from another routing protocol\n" | |
13749 | "Open Shortest Path First (OSPFv2)\n" | |
13750 | "Non-main Kernel Routing Table\n" | |
13751 | "Instance ID/Table ID\n" | |
13752 | "Metric for redistributed routes\n" | |
13753 | "Default metric\n") | |
596c17ba | 13754 | |
7c8ff89e DS |
13755 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
13756 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 13757 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
13758 | "Redistribute information from another routing protocol\n" |
13759 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13760 | "Non-main Kernel Routing Table\n" |
13761 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13762 | "Route map reference\n" |
13763 | "Pointer to route-map entries\n" | |
13764 | "Metric for redistributed routes\n" | |
13765 | "Default metric\n") | |
13766 | { | |
d62a17ae | 13767 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13768 | int idx_ospf_table = 1; | |
13769 | int idx_number = 2; | |
13770 | int idx_word = 4; | |
13771 | int idx_number_2 = 6; | |
d7c0a89a | 13772 | uint32_t metric; |
d62a17ae | 13773 | struct bgp_redist *red; |
d7c0a89a | 13774 | unsigned short instance; |
d62a17ae | 13775 | int protocol; |
e923dd62 | 13776 | bool changed; |
1de27621 DA |
13777 | struct route_map *route_map = |
13778 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13779 | |
13780 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13781 | protocol = ZEBRA_ROUTE_OSPF; | |
13782 | else | |
13783 | protocol = ZEBRA_ROUTE_TABLE; | |
13784 | ||
13785 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13786 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13787 | ||
13788 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
13789 | changed = |
13790 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13791 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13792 | metric); | |
13793 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 13794 | } |
13795 | ||
13796 | ALIAS_HIDDEN( | |
13797 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
13798 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
13799 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
13800 | "Redistribute information from another routing protocol\n" | |
13801 | "Open Shortest Path First (OSPFv2)\n" | |
13802 | "Non-main Kernel Routing Table\n" | |
13803 | "Instance ID/Table ID\n" | |
13804 | "Route map reference\n" | |
13805 | "Pointer to route-map entries\n" | |
13806 | "Metric for redistributed routes\n" | |
13807 | "Default metric\n") | |
596c17ba | 13808 | |
7c8ff89e DS |
13809 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
13810 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 13811 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
13812 | "Redistribute information from another routing protocol\n" |
13813 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
13814 | "Non-main Kernel Routing Table\n" |
13815 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
13816 | "Metric for redistributed routes\n" |
13817 | "Default metric\n" | |
13818 | "Route map reference\n" | |
13819 | "Pointer to route-map entries\n") | |
13820 | { | |
d62a17ae | 13821 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13822 | int idx_ospf_table = 1; | |
13823 | int idx_number = 2; | |
13824 | int idx_number_2 = 4; | |
13825 | int idx_word = 6; | |
d7c0a89a | 13826 | uint32_t metric; |
d62a17ae | 13827 | struct bgp_redist *red; |
d7c0a89a | 13828 | unsigned short instance; |
d62a17ae | 13829 | int protocol; |
e923dd62 | 13830 | bool changed; |
1de27621 DA |
13831 | struct route_map *route_map = |
13832 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 13833 | |
13834 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13835 | protocol = ZEBRA_ROUTE_OSPF; | |
13836 | else | |
13837 | protocol = ZEBRA_ROUTE_TABLE; | |
13838 | ||
13839 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13840 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
13841 | ||
13842 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 13843 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
13844 | metric); | |
1de27621 DA |
13845 | changed |= |
13846 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13847 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 13848 | } |
13849 | ||
13850 | ALIAS_HIDDEN( | |
13851 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
13852 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
13853 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
13854 | "Redistribute information from another routing protocol\n" | |
13855 | "Open Shortest Path First (OSPFv2)\n" | |
13856 | "Non-main Kernel Routing Table\n" | |
13857 | "Instance ID/Table ID\n" | |
13858 | "Metric for redistributed routes\n" | |
13859 | "Default metric\n" | |
13860 | "Route map reference\n" | |
13861 | "Pointer to route-map entries\n") | |
596c17ba | 13862 | |
7c8ff89e DS |
13863 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
13864 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 13865 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
13866 | NO_STR |
13867 | "Redistribute information from another routing protocol\n" | |
13868 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 13869 | "Non-main Kernel Routing Table\n" |
31500417 DW |
13870 | "Instance ID/Table ID\n" |
13871 | "Metric for redistributed routes\n" | |
13872 | "Default metric\n" | |
13873 | "Route map reference\n" | |
13874 | "Pointer to route-map entries\n") | |
7c8ff89e | 13875 | { |
d62a17ae | 13876 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13877 | int idx_ospf_table = 2; | |
13878 | int idx_number = 3; | |
d7c0a89a | 13879 | unsigned short instance; |
d62a17ae | 13880 | int protocol; |
13881 | ||
13882 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
13883 | protocol = ZEBRA_ROUTE_OSPF; | |
13884 | else | |
13885 | protocol = ZEBRA_ROUTE_TABLE; | |
13886 | ||
13887 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
13888 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
13889 | } | |
13890 | ||
13891 | ALIAS_HIDDEN( | |
13892 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 13893 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13894 | NO_STR |
13895 | "Redistribute information from another routing protocol\n" | |
13896 | "Open Shortest Path First (OSPFv2)\n" | |
13897 | "Non-main Kernel Routing Table\n" | |
13898 | "Instance ID/Table ID\n" | |
13899 | "Metric for redistributed routes\n" | |
13900 | "Default metric\n" | |
13901 | "Route map reference\n" | |
13902 | "Pointer to route-map entries\n") | |
596c17ba | 13903 | |
718e3744 | 13904 | DEFUN (no_bgp_redistribute_ipv4, |
13905 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 13906 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 13907 | NO_STR |
13908 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 13909 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
13910 | "Metric for redistributed routes\n" |
13911 | "Default metric\n" | |
13912 | "Route map reference\n" | |
13913 | "Pointer to route-map entries\n") | |
718e3744 | 13914 | { |
d62a17ae | 13915 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13916 | int idx_protocol = 2; | |
13917 | int type; | |
13918 | ||
13919 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
13920 | if (type < 0) { | |
13921 | vty_out(vty, "%% Invalid route type\n"); | |
13922 | return CMD_WARNING_CONFIG_FAILED; | |
13923 | } | |
13924 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
13925 | } | |
13926 | ||
13927 | ALIAS_HIDDEN( | |
13928 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
13929 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 13930 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 13931 | NO_STR |
13932 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
13933 | "Metric for redistributed routes\n" | |
13934 | "Default metric\n" | |
13935 | "Route map reference\n" | |
13936 | "Pointer to route-map entries\n") | |
596c17ba | 13937 | |
718e3744 | 13938 | DEFUN (bgp_redistribute_ipv6, |
13939 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 13940 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 13941 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13942 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 13943 | { |
d62a17ae | 13944 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13945 | int idx_protocol = 1; | |
13946 | int type; | |
718e3744 | 13947 | |
d62a17ae | 13948 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13949 | if (type < 0) { | |
13950 | vty_out(vty, "%% Invalid route type\n"); | |
13951 | return CMD_WARNING_CONFIG_FAILED; | |
13952 | } | |
718e3744 | 13953 | |
d62a17ae | 13954 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 13955 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 13956 | } |
13957 | ||
13958 | DEFUN (bgp_redistribute_ipv6_rmap, | |
13959 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 13960 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 13961 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13962 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13963 | "Route map reference\n" |
13964 | "Pointer to route-map entries\n") | |
13965 | { | |
d62a17ae | 13966 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13967 | int idx_protocol = 1; | |
13968 | int idx_word = 3; | |
13969 | int type; | |
13970 | struct bgp_redist *red; | |
e923dd62 | 13971 | bool changed; |
1de27621 DA |
13972 | struct route_map *route_map = |
13973 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 13974 | |
d62a17ae | 13975 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
13976 | if (type < 0) { | |
13977 | vty_out(vty, "%% Invalid route type\n"); | |
13978 | return CMD_WARNING_CONFIG_FAILED; | |
13979 | } | |
718e3744 | 13980 | |
d62a17ae | 13981 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
13982 | changed = |
13983 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 13984 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 13985 | } |
13986 | ||
13987 | DEFUN (bgp_redistribute_ipv6_metric, | |
13988 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 13989 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 13990 | "Redistribute information from another routing protocol\n" |
ab0181ee | 13991 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 13992 | "Metric for redistributed routes\n" |
13993 | "Default metric\n") | |
13994 | { | |
d62a17ae | 13995 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
13996 | int idx_protocol = 1; | |
13997 | int idx_number = 3; | |
13998 | int type; | |
d7c0a89a | 13999 | uint32_t metric; |
d62a17ae | 14000 | struct bgp_redist *red; |
e923dd62 | 14001 | bool changed; |
d62a17ae | 14002 | |
14003 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14004 | if (type < 0) { | |
14005 | vty_out(vty, "%% Invalid route type\n"); | |
14006 | return CMD_WARNING_CONFIG_FAILED; | |
14007 | } | |
14008 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14009 | |
d62a17ae | 14010 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14011 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
14012 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14013 | } |
14014 | ||
14015 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
14016 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 14017 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 14018 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14019 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14020 | "Route map reference\n" |
14021 | "Pointer to route-map entries\n" | |
14022 | "Metric for redistributed routes\n" | |
14023 | "Default metric\n") | |
14024 | { | |
d62a17ae | 14025 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14026 | int idx_protocol = 1; | |
14027 | int idx_word = 3; | |
14028 | int idx_number = 5; | |
14029 | int type; | |
d7c0a89a | 14030 | uint32_t metric; |
d62a17ae | 14031 | struct bgp_redist *red; |
e923dd62 | 14032 | bool changed; |
1de27621 DA |
14033 | struct route_map *route_map = |
14034 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14035 | |
14036 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14037 | if (type < 0) { | |
14038 | vty_out(vty, "%% Invalid route type\n"); | |
14039 | return CMD_WARNING_CONFIG_FAILED; | |
14040 | } | |
14041 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14042 | |
d62a17ae | 14043 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
14044 | changed = |
14045 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14046 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
14047 | metric); | |
14048 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 14049 | } |
14050 | ||
14051 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
14052 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 14053 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 14054 | "Redistribute information from another routing protocol\n" |
ab0181ee | 14055 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 14056 | "Metric for redistributed routes\n" |
14057 | "Default metric\n" | |
14058 | "Route map reference\n" | |
14059 | "Pointer to route-map entries\n") | |
14060 | { | |
d62a17ae | 14061 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14062 | int idx_protocol = 1; | |
14063 | int idx_number = 3; | |
14064 | int idx_word = 5; | |
14065 | int type; | |
d7c0a89a | 14066 | uint32_t metric; |
d62a17ae | 14067 | struct bgp_redist *red; |
e923dd62 | 14068 | bool changed; |
1de27621 DA |
14069 | struct route_map *route_map = |
14070 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 14071 | |
14072 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
14073 | if (type < 0) { | |
14074 | vty_out(vty, "%% Invalid route type\n"); | |
14075 | return CMD_WARNING_CONFIG_FAILED; | |
14076 | } | |
14077 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 14078 | |
d62a17ae | 14079 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 14080 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
14081 | metric); | |
1de27621 DA |
14082 | changed |= |
14083 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 14084 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 14085 | } |
14086 | ||
14087 | DEFUN (no_bgp_redistribute_ipv6, | |
14088 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 14089 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 14090 | NO_STR |
14091 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 14092 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
14093 | "Metric for redistributed routes\n" |
14094 | "Default metric\n" | |
14095 | "Route map reference\n" | |
14096 | "Pointer to route-map entries\n") | |
718e3744 | 14097 | { |
d62a17ae | 14098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
14099 | int idx_protocol = 2; | |
14100 | int type; | |
718e3744 | 14101 | |
d62a17ae | 14102 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
14103 | if (type < 0) { | |
14104 | vty_out(vty, "%% Invalid route type\n"); | |
14105 | return CMD_WARNING_CONFIG_FAILED; | |
14106 | } | |
718e3744 | 14107 | |
d62a17ae | 14108 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
14109 | } | |
14110 | ||
dd65f45e DL |
14111 | static void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, |
14112 | afi_t afi, safi_t safi) | |
d62a17ae | 14113 | { |
14114 | int i; | |
14115 | ||
14116 | /* Unicast redistribution only. */ | |
14117 | if (safi != SAFI_UNICAST) | |
2b791107 | 14118 | return; |
d62a17ae | 14119 | |
14120 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
14121 | /* Redistribute BGP does not make sense. */ | |
14122 | if (i != ZEBRA_ROUTE_BGP) { | |
14123 | struct list *red_list; | |
14124 | struct listnode *node; | |
14125 | struct bgp_redist *red; | |
14126 | ||
14127 | red_list = bgp->redist[afi][i]; | |
14128 | if (!red_list) | |
14129 | continue; | |
14130 | ||
14131 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 14132 | /* "redistribute" configuration. */ |
14133 | vty_out(vty, " redistribute %s", | |
14134 | zebra_route_string(i)); | |
14135 | if (red->instance) | |
14136 | vty_out(vty, " %d", red->instance); | |
14137 | if (red->redist_metric_flag) | |
14138 | vty_out(vty, " metric %u", | |
14139 | red->redist_metric); | |
14140 | if (red->rmap.name) | |
14141 | vty_out(vty, " route-map %s", | |
14142 | red->rmap.name); | |
14143 | vty_out(vty, "\n"); | |
14144 | } | |
14145 | } | |
14146 | } | |
718e3744 | 14147 | } |
6b0655a2 | 14148 | |
dd65f45e DL |
14149 | /* peer-group helpers for config-write */ |
14150 | ||
14151 | static bool peergroup_flag_check(struct peer *peer, uint32_t flag) | |
14152 | { | |
14153 | if (!peer_group_active(peer)) { | |
14154 | if (CHECK_FLAG(peer->flags_invert, flag)) | |
14155 | return !CHECK_FLAG(peer->flags, flag); | |
14156 | else | |
14157 | return !!CHECK_FLAG(peer->flags, flag); | |
14158 | } | |
14159 | ||
14160 | return !!CHECK_FLAG(peer->flags_override, flag); | |
14161 | } | |
14162 | ||
14163 | static bool peergroup_af_flag_check(struct peer *peer, afi_t afi, safi_t safi, | |
14164 | uint32_t flag) | |
14165 | { | |
14166 | if (!peer_group_active(peer)) { | |
14167 | if (CHECK_FLAG(peer->af_flags_invert[afi][safi], flag)) | |
14168 | return !peer_af_flag_check(peer, afi, safi, flag); | |
14169 | else | |
14170 | return !!peer_af_flag_check(peer, afi, safi, flag); | |
14171 | } | |
14172 | ||
14173 | return !!CHECK_FLAG(peer->af_flags_override[afi][safi], flag); | |
14174 | } | |
14175 | ||
14176 | static bool peergroup_filter_check(struct peer *peer, afi_t afi, safi_t safi, | |
14177 | uint8_t type, int direct) | |
14178 | { | |
14179 | struct bgp_filter *filter; | |
14180 | ||
14181 | if (peer_group_active(peer)) | |
14182 | return !!CHECK_FLAG(peer->filter_override[afi][safi][direct], | |
14183 | type); | |
14184 | ||
14185 | filter = &peer->filter[afi][safi]; | |
14186 | switch (type) { | |
14187 | case PEER_FT_DISTRIBUTE_LIST: | |
14188 | return !!(filter->dlist[direct].name); | |
14189 | case PEER_FT_FILTER_LIST: | |
14190 | return !!(filter->aslist[direct].name); | |
14191 | case PEER_FT_PREFIX_LIST: | |
14192 | return !!(filter->plist[direct].name); | |
14193 | case PEER_FT_ROUTE_MAP: | |
14194 | return !!(filter->map[direct].name); | |
14195 | case PEER_FT_UNSUPPRESS_MAP: | |
14196 | return !!(filter->usmap.name); | |
14197 | default: | |
14198 | return false; | |
14199 | } | |
14200 | } | |
14201 | ||
14202 | /* Return true if the addpath type is set for peer and different from | |
14203 | * peer-group. | |
14204 | */ | |
3dc339cd DA |
14205 | static bool peergroup_af_addpath_check(struct peer *peer, afi_t afi, |
14206 | safi_t safi) | |
dd65f45e DL |
14207 | { |
14208 | enum bgp_addpath_strat type, g_type; | |
14209 | ||
14210 | type = peer->addpath_type[afi][safi]; | |
14211 | ||
14212 | if (type != BGP_ADDPATH_NONE) { | |
14213 | if (peer_group_active(peer)) { | |
14214 | g_type = peer->group->conf->addpath_type[afi][safi]; | |
14215 | ||
14216 | if (type != g_type) | |
3dc339cd | 14217 | return true; |
dd65f45e | 14218 | else |
3dc339cd | 14219 | return false; |
dd65f45e DL |
14220 | } |
14221 | ||
3dc339cd | 14222 | return true; |
dd65f45e DL |
14223 | } |
14224 | ||
3dc339cd | 14225 | return false; |
dd65f45e DL |
14226 | } |
14227 | ||
b9c7bc5a | 14228 | /* This is part of the address-family block (unicast only) */ |
dd65f45e | 14229 | static void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, |
ddb5b488 PZ |
14230 | afi_t afi) |
14231 | { | |
b9c7bc5a | 14232 | int indent = 2; |
ddb5b488 | 14233 | |
8a066a70 | 14234 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
ae6a6fb4 DS |
14235 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14236 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
8a066a70 PG |
14237 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", |
14238 | bgp->vpn_policy[afi] | |
bb4f6190 | 14239 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
14240 | else |
14241 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
14242 | bgp->vpn_policy[afi] | |
14243 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
14244 | } | |
12a844a5 DS |
14245 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
14246 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
14247 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
14248 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
14249 | return; | |
14250 | ||
e70e9f8e PZ |
14251 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
14252 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
14253 | ||
14254 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
14255 | ||
14256 | } else { | |
14257 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
14258 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
14259 | bgp->vpn_policy[afi].tovpn_label); | |
14260 | } | |
ddb5b488 PZ |
14261 | } |
14262 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14263 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
14264 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 14265 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
14266 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
14267 | sizeof(buf))); | |
14268 | } | |
14269 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
14270 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
14271 | ||
14272 | char buf[PREFIX_STRLEN]; | |
14273 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
14274 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
14275 | sizeof(buf))) { | |
14276 | ||
b9c7bc5a PZ |
14277 | vty_out(vty, "%*snexthop vpn export %s\n", |
14278 | indent, "", buf); | |
ddb5b488 PZ |
14279 | } |
14280 | } | |
14281 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
14282 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
14283 | && ecommunity_cmp( | |
14284 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14285 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
14286 | ||
14287 | char *b = ecommunity_ecom2str( | |
14288 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14289 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14290 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
14291 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14292 | } else { | |
14293 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
14294 | char *b = ecommunity_ecom2str( | |
14295 | bgp->vpn_policy[afi] | |
14296 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
14297 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14298 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14299 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
14300 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14301 | } | |
14302 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
14303 | char *b = ecommunity_ecom2str( | |
14304 | bgp->vpn_policy[afi] | |
14305 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
14306 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14307 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 14308 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
14309 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
14310 | } | |
14311 | } | |
bb4f6190 DS |
14312 | |
14313 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 14314 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
14315 | bgp->vpn_policy[afi] |
14316 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 14317 | |
301ad80a PG |
14318 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
14319 | char *b = ecommunity_ecom2str( | |
14320 | bgp->vpn_policy[afi] | |
14321 | .import_redirect_rtlist, | |
14322 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
14323 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 14324 | |
301ad80a PG |
14325 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
14326 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
14327 | } | |
ddb5b488 PZ |
14328 | } |
14329 | ||
dd65f45e DL |
14330 | static void bgp_config_write_filter(struct vty *vty, struct peer *peer, |
14331 | afi_t afi, safi_t safi) | |
14332 | { | |
14333 | struct bgp_filter *filter; | |
14334 | char *addr; | |
14335 | ||
14336 | addr = peer->host; | |
14337 | filter = &peer->filter[afi][safi]; | |
14338 | ||
14339 | /* distribute-list. */ | |
14340 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14341 | FILTER_IN)) | |
14342 | vty_out(vty, " neighbor %s distribute-list %s in\n", addr, | |
14343 | filter->dlist[FILTER_IN].name); | |
14344 | ||
14345 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_DISTRIBUTE_LIST, | |
14346 | FILTER_OUT)) | |
14347 | vty_out(vty, " neighbor %s distribute-list %s out\n", addr, | |
14348 | filter->dlist[FILTER_OUT].name); | |
14349 | ||
14350 | /* prefix-list. */ | |
14351 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14352 | FILTER_IN)) | |
14353 | vty_out(vty, " neighbor %s prefix-list %s in\n", addr, | |
14354 | filter->plist[FILTER_IN].name); | |
14355 | ||
14356 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_PREFIX_LIST, | |
14357 | FILTER_OUT)) | |
14358 | vty_out(vty, " neighbor %s prefix-list %s out\n", addr, | |
14359 | filter->plist[FILTER_OUT].name); | |
14360 | ||
14361 | /* route-map. */ | |
14362 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, RMAP_IN)) | |
14363 | vty_out(vty, " neighbor %s route-map %s in\n", addr, | |
14364 | filter->map[RMAP_IN].name); | |
14365 | ||
14366 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_ROUTE_MAP, | |
14367 | RMAP_OUT)) | |
14368 | vty_out(vty, " neighbor %s route-map %s out\n", addr, | |
14369 | filter->map[RMAP_OUT].name); | |
14370 | ||
14371 | /* unsuppress-map */ | |
14372 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_UNSUPPRESS_MAP, 0)) | |
14373 | vty_out(vty, " neighbor %s unsuppress-map %s\n", addr, | |
14374 | filter->usmap.name); | |
14375 | ||
14376 | /* filter-list. */ | |
14377 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14378 | FILTER_IN)) | |
14379 | vty_out(vty, " neighbor %s filter-list %s in\n", addr, | |
14380 | filter->aslist[FILTER_IN].name); | |
14381 | ||
14382 | if (peergroup_filter_check(peer, afi, safi, PEER_FT_FILTER_LIST, | |
14383 | FILTER_OUT)) | |
14384 | vty_out(vty, " neighbor %s filter-list %s out\n", addr, | |
14385 | filter->aslist[FILTER_OUT].name); | |
14386 | } | |
14387 | ||
14388 | /* BGP peer configuration display function. */ | |
14389 | static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp, | |
14390 | struct peer *peer) | |
14391 | { | |
14392 | struct peer *g_peer = NULL; | |
14393 | char buf[SU_ADDRSTRLEN]; | |
14394 | char *addr; | |
14395 | int if_pg_printed = false; | |
14396 | int if_ras_printed = false; | |
14397 | ||
14398 | /* Skip dynamic neighbors. */ | |
14399 | if (peer_dynamic_neighbor(peer)) | |
14400 | return; | |
14401 | ||
14402 | if (peer->conf_if) | |
14403 | addr = peer->conf_if; | |
14404 | else | |
14405 | addr = peer->host; | |
14406 | ||
14407 | /************************************ | |
14408 | ****** Global to the neighbor ****** | |
14409 | ************************************/ | |
14410 | if (peer->conf_if) { | |
14411 | if (CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
14412 | vty_out(vty, " neighbor %s interface v6only", addr); | |
14413 | else | |
14414 | vty_out(vty, " neighbor %s interface", addr); | |
14415 | ||
14416 | if (peer_group_active(peer)) { | |
14417 | vty_out(vty, " peer-group %s", peer->group->name); | |
14418 | if_pg_printed = true; | |
14419 | } else if (peer->as_type == AS_SPECIFIED) { | |
14420 | vty_out(vty, " remote-as %u", peer->as); | |
14421 | if_ras_printed = true; | |
14422 | } else if (peer->as_type == AS_INTERNAL) { | |
14423 | vty_out(vty, " remote-as internal"); | |
14424 | if_ras_printed = true; | |
14425 | } else if (peer->as_type == AS_EXTERNAL) { | |
14426 | vty_out(vty, " remote-as external"); | |
14427 | if_ras_printed = true; | |
14428 | } | |
14429 | ||
14430 | vty_out(vty, "\n"); | |
14431 | } | |
14432 | ||
14433 | /* remote-as and peer-group */ | |
14434 | /* peer is a member of a peer-group */ | |
14435 | if (peer_group_active(peer)) { | |
14436 | g_peer = peer->group->conf; | |
14437 | ||
14438 | if (g_peer->as_type == AS_UNSPECIFIED && !if_ras_printed) { | |
14439 | if (peer->as_type == AS_SPECIFIED) { | |
14440 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14441 | addr, peer->as); | |
14442 | } else if (peer->as_type == AS_INTERNAL) { | |
14443 | vty_out(vty, | |
14444 | " neighbor %s remote-as internal\n", | |
14445 | addr); | |
14446 | } else if (peer->as_type == AS_EXTERNAL) { | |
14447 | vty_out(vty, | |
14448 | " neighbor %s remote-as external\n", | |
14449 | addr); | |
14450 | } | |
14451 | } | |
14452 | ||
14453 | /* For swpX peers we displayed the peer-group | |
14454 | * via 'neighbor swpX interface peer-group PGNAME' */ | |
14455 | if (!if_pg_printed) | |
14456 | vty_out(vty, " neighbor %s peer-group %s\n", addr, | |
14457 | peer->group->name); | |
14458 | } | |
14459 | ||
14460 | /* peer is NOT a member of a peer-group */ | |
14461 | else { | |
14462 | /* peer is a peer-group, declare the peer-group */ | |
14463 | if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) { | |
14464 | vty_out(vty, " neighbor %s peer-group\n", addr); | |
14465 | } | |
14466 | ||
14467 | if (!if_ras_printed) { | |
14468 | if (peer->as_type == AS_SPECIFIED) { | |
14469 | vty_out(vty, " neighbor %s remote-as %u\n", | |
14470 | addr, peer->as); | |
14471 | } else if (peer->as_type == AS_INTERNAL) { | |
14472 | vty_out(vty, | |
14473 | " neighbor %s remote-as internal\n", | |
14474 | addr); | |
14475 | } else if (peer->as_type == AS_EXTERNAL) { | |
14476 | vty_out(vty, | |
14477 | " neighbor %s remote-as external\n", | |
14478 | addr); | |
14479 | } | |
14480 | } | |
14481 | } | |
14482 | ||
14483 | /* local-as */ | |
14484 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS)) { | |
14485 | vty_out(vty, " neighbor %s local-as %u", addr, | |
14486 | peer->change_local_as); | |
14487 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
14488 | vty_out(vty, " no-prepend"); | |
14489 | if (peergroup_flag_check(peer, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
14490 | vty_out(vty, " replace-as"); | |
14491 | vty_out(vty, "\n"); | |
14492 | } | |
14493 | ||
14494 | /* description */ | |
14495 | if (peer->desc) { | |
14496 | vty_out(vty, " neighbor %s description %s\n", addr, peer->desc); | |
14497 | } | |
14498 | ||
14499 | /* shutdown */ | |
14500 | if (peergroup_flag_check(peer, PEER_FLAG_SHUTDOWN)) { | |
14501 | if (peer->tx_shutdown_message) | |
14502 | vty_out(vty, " neighbor %s shutdown message %s\n", addr, | |
14503 | peer->tx_shutdown_message); | |
14504 | else | |
14505 | vty_out(vty, " neighbor %s shutdown\n", addr); | |
14506 | } | |
14507 | ||
14508 | /* bfd */ | |
14509 | if (peer->bfd_info) { | |
14510 | if (!peer_group_active(peer) || !g_peer->bfd_info) { | |
14511 | bgp_bfd_peer_config_write(vty, peer, addr); | |
14512 | } | |
14513 | } | |
14514 | ||
14515 | /* password */ | |
14516 | if (peergroup_flag_check(peer, PEER_FLAG_PASSWORD)) | |
14517 | vty_out(vty, " neighbor %s password %s\n", addr, | |
14518 | peer->password); | |
14519 | ||
14520 | /* neighbor solo */ | |
14521 | if (CHECK_FLAG(peer->flags, PEER_FLAG_LONESOUL)) { | |
14522 | if (!peer_group_active(peer)) { | |
14523 | vty_out(vty, " neighbor %s solo\n", addr); | |
14524 | } | |
14525 | } | |
14526 | ||
14527 | /* BGP port */ | |
14528 | if (peer->port != BGP_PORT_DEFAULT) { | |
14529 | vty_out(vty, " neighbor %s port %d\n", addr, peer->port); | |
14530 | } | |
14531 | ||
14532 | /* Local interface name */ | |
14533 | if (peer->ifname) { | |
14534 | vty_out(vty, " neighbor %s interface %s\n", addr, peer->ifname); | |
14535 | } | |
14536 | ||
14537 | /* passive */ | |
14538 | if (peergroup_flag_check(peer, PEER_FLAG_PASSIVE)) | |
14539 | vty_out(vty, " neighbor %s passive\n", addr); | |
14540 | ||
14541 | /* ebgp-multihop */ | |
14542 | if (peer->sort != BGP_PEER_IBGP && peer->ttl != BGP_DEFAULT_TTL | |
e2521429 DA |
14543 | && !(peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED |
14544 | && peer->ttl == MAXTTL)) { | |
dd65f45e DL |
14545 | if (!peer_group_active(peer) || g_peer->ttl != peer->ttl) { |
14546 | vty_out(vty, " neighbor %s ebgp-multihop %d\n", addr, | |
14547 | peer->ttl); | |
14548 | } | |
14549 | } | |
14550 | ||
14551 | /* ttl-security hops */ | |
e2521429 | 14552 | if (peer->gtsm_hops != BGP_GTSM_HOPS_DISABLED) { |
dd65f45e DL |
14553 | if (!peer_group_active(peer) |
14554 | || g_peer->gtsm_hops != peer->gtsm_hops) { | |
14555 | vty_out(vty, " neighbor %s ttl-security hops %d\n", | |
14556 | addr, peer->gtsm_hops); | |
14557 | } | |
14558 | } | |
14559 | ||
14560 | /* disable-connected-check */ | |
14561 | if (peergroup_flag_check(peer, PEER_FLAG_DISABLE_CONNECTED_CHECK)) | |
14562 | vty_out(vty, " neighbor %s disable-connected-check\n", addr); | |
14563 | ||
14564 | /* enforce-first-as */ | |
14565 | if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS)) | |
14566 | vty_out(vty, " neighbor %s enforce-first-as\n", addr); | |
14567 | ||
14568 | /* update-source */ | |
14569 | if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) { | |
14570 | if (peer->update_source) | |
14571 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14572 | sockunion2str(peer->update_source, buf, | |
14573 | SU_ADDRSTRLEN)); | |
14574 | else if (peer->update_if) | |
14575 | vty_out(vty, " neighbor %s update-source %s\n", addr, | |
14576 | peer->update_if); | |
14577 | } | |
14578 | ||
14579 | /* advertisement-interval */ | |
14580 | if (peergroup_flag_check(peer, PEER_FLAG_ROUTEADV)) | |
14581 | vty_out(vty, " neighbor %s advertisement-interval %u\n", addr, | |
14582 | peer->routeadv); | |
14583 | ||
14584 | /* timers */ | |
14585 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER)) | |
14586 | vty_out(vty, " neighbor %s timers %u %u\n", addr, | |
14587 | peer->keepalive, peer->holdtime); | |
14588 | ||
14589 | /* timers connect */ | |
14590 | if (peergroup_flag_check(peer, PEER_FLAG_TIMER_CONNECT)) | |
14591 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14592 | peer->connect); | |
5d5393b9 DL |
14593 | /* need special-case handling for changed default values due to |
14594 | * config profile / version (because there is no "timers bgp connect" | |
14595 | * command, we need to save this per-peer :/) | |
14596 | */ | |
14597 | else if (!peer_group_active(peer) && !peer->connect && | |
14598 | peer->bgp->default_connect_retry != SAVE_BGP_CONNECT_RETRY) | |
14599 | vty_out(vty, " neighbor %s timers connect %u\n", addr, | |
14600 | peer->bgp->default_connect_retry); | |
dd65f45e DL |
14601 | |
14602 | /* capability dynamic */ | |
14603 | if (peergroup_flag_check(peer, PEER_FLAG_DYNAMIC_CAPABILITY)) | |
14604 | vty_out(vty, " neighbor %s capability dynamic\n", addr); | |
14605 | ||
14606 | /* capability extended-nexthop */ | |
14607 | if (peergroup_flag_check(peer, PEER_FLAG_CAPABILITY_ENHE)) { | |
14608 | if (!peer->conf_if) { | |
14609 | if (CHECK_FLAG(peer->flags_invert, | |
14610 | PEER_FLAG_CAPABILITY_ENHE)) | |
14611 | vty_out(vty, | |
14612 | " no neighbor %s capability extended-nexthop\n", | |
14613 | addr); | |
14614 | else | |
14615 | vty_out(vty, | |
14616 | " neighbor %s capability extended-nexthop\n", | |
14617 | addr); | |
14618 | } | |
14619 | } | |
14620 | ||
14621 | /* dont-capability-negotiation */ | |
14622 | if (peergroup_flag_check(peer, PEER_FLAG_DONT_CAPABILITY)) | |
14623 | vty_out(vty, " neighbor %s dont-capability-negotiate\n", addr); | |
14624 | ||
14625 | /* override-capability */ | |
14626 | if (peergroup_flag_check(peer, PEER_FLAG_OVERRIDE_CAPABILITY)) | |
14627 | vty_out(vty, " neighbor %s override-capability\n", addr); | |
14628 | ||
14629 | /* strict-capability-match */ | |
14630 | if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH)) | |
14631 | vty_out(vty, " neighbor %s strict-capability-match\n", addr); | |
14632 | ||
14633 | /* Sender side AS path loop detection. */ | |
14634 | if (peer->as_path_loop_detection) | |
14635 | vty_out(vty, " neighbor %s sender-as-path-loop-detection\n", | |
14636 | addr); | |
cfd47646 | 14637 | |
14638 | if (!CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14639 | PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) { |
cfd47646 | 14640 | |
14641 | if (CHECK_FLAG(peer->peer_gr_new_status_flag, | |
13909c4f | 14642 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) { |
cfd47646 | 14643 | vty_out(vty, |
14644 | " neighbor %s graceful-restart-helper\n", addr); | |
13909c4f DS |
14645 | } else if (CHECK_FLAG( |
14646 | peer->peer_gr_new_status_flag, | |
14647 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)) { | |
cfd47646 | 14648 | vty_out(vty, |
14649 | " neighbor %s graceful-restart\n", addr); | |
13909c4f DS |
14650 | } else if ( |
14651 | (!(CHECK_FLAG(peer->peer_gr_new_status_flag, | |
14652 | PEER_GRACEFUL_RESTART_NEW_STATE_HELPER)) | |
14653 | && !(CHECK_FLAG( | |
14654 | peer->peer_gr_new_status_flag, | |
14655 | PEER_GRACEFUL_RESTART_NEW_STATE_RESTART)))) { | |
14656 | vty_out(vty, " neighbor %s graceful-restart-disable\n", | |
14657 | addr); | |
cfd47646 | 14658 | } |
14659 | } | |
dd65f45e DL |
14660 | } |
14661 | ||
14662 | /* BGP peer configuration display function. */ | |
14663 | static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, | |
14664 | struct peer *peer, afi_t afi, safi_t safi) | |
14665 | { | |
14666 | struct peer *g_peer = NULL; | |
14667 | char *addr; | |
14668 | bool flag_scomm, flag_secomm, flag_slcomm; | |
14669 | ||
14670 | /* Skip dynamic neighbors. */ | |
14671 | if (peer_dynamic_neighbor(peer)) | |
14672 | return; | |
14673 | ||
14674 | if (peer->conf_if) | |
14675 | addr = peer->conf_if; | |
14676 | else | |
14677 | addr = peer->host; | |
14678 | ||
14679 | /************************************ | |
14680 | ****** Per AF to the neighbor ****** | |
14681 | ************************************/ | |
14682 | if (peer_group_active(peer)) { | |
14683 | g_peer = peer->group->conf; | |
14684 | ||
14685 | /* If the peer-group is active but peer is not, print a 'no | |
14686 | * activate' */ | |
14687 | if (g_peer->afc[afi][safi] && !peer->afc[afi][safi]) { | |
14688 | vty_out(vty, " no neighbor %s activate\n", addr); | |
14689 | } | |
14690 | ||
14691 | /* If the peer-group is not active but peer is, print an | |
14692 | 'activate' */ | |
14693 | else if (!g_peer->afc[afi][safi] && peer->afc[afi][safi]) { | |
14694 | vty_out(vty, " neighbor %s activate\n", addr); | |
14695 | } | |
14696 | } else { | |
14697 | if (peer->afc[afi][safi]) { | |
14698 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14699 | if (CHECK_FLAG(bgp->flags, |
14700 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14701 | vty_out(vty, " neighbor %s activate\n", |
14702 | addr); | |
14703 | } | |
14704 | } else | |
14705 | vty_out(vty, " neighbor %s activate\n", addr); | |
14706 | } else { | |
14707 | if ((afi == AFI_IP) && (safi == SAFI_UNICAST)) { | |
892fedb6 DA |
14708 | if (!CHECK_FLAG(bgp->flags, |
14709 | BGP_FLAG_NO_DEFAULT_IPV4)) { | |
dd65f45e DL |
14710 | vty_out(vty, |
14711 | " no neighbor %s activate\n", | |
14712 | addr); | |
14713 | } | |
14714 | } | |
14715 | } | |
14716 | } | |
14717 | ||
14718 | /* addpath TX knobs */ | |
14719 | if (peergroup_af_addpath_check(peer, afi, safi)) { | |
14720 | switch (peer->addpath_type[afi][safi]) { | |
14721 | case BGP_ADDPATH_ALL: | |
14722 | vty_out(vty, " neighbor %s addpath-tx-all-paths\n", | |
14723 | addr); | |
14724 | break; | |
14725 | case BGP_ADDPATH_BEST_PER_AS: | |
14726 | vty_out(vty, | |
14727 | " neighbor %s addpath-tx-bestpath-per-AS\n", | |
14728 | addr); | |
14729 | break; | |
14730 | case BGP_ADDPATH_MAX: | |
14731 | case BGP_ADDPATH_NONE: | |
14732 | break; | |
14733 | } | |
14734 | } | |
14735 | ||
14736 | /* ORF capability. */ | |
14737 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ORF_PREFIX_SM) | |
14738 | || peergroup_af_flag_check(peer, afi, safi, | |
14739 | PEER_FLAG_ORF_PREFIX_RM)) { | |
14740 | vty_out(vty, " neighbor %s capability orf prefix-list", addr); | |
14741 | ||
14742 | if (peergroup_af_flag_check(peer, afi, safi, | |
14743 | PEER_FLAG_ORF_PREFIX_SM) | |
14744 | && peergroup_af_flag_check(peer, afi, safi, | |
14745 | PEER_FLAG_ORF_PREFIX_RM)) | |
14746 | vty_out(vty, " both"); | |
14747 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14748 | PEER_FLAG_ORF_PREFIX_SM)) | |
14749 | vty_out(vty, " send"); | |
14750 | else | |
14751 | vty_out(vty, " receive"); | |
14752 | vty_out(vty, "\n"); | |
14753 | } | |
14754 | ||
14755 | /* BGP flag dampening. */ | |
14756 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
14757 | BGP_CONFIG_DAMPENING)) | |
14758 | bgp_config_write_damp(vty, afi, safi); | |
14759 | ||
14760 | /* Route reflector client. */ | |
14761 | if (peergroup_af_flag_check(peer, afi, safi, | |
14762 | PEER_FLAG_REFLECTOR_CLIENT)) { | |
14763 | vty_out(vty, " neighbor %s route-reflector-client\n", addr); | |
14764 | } | |
14765 | ||
14766 | /* next-hop-self force */ | |
14767 | if (peergroup_af_flag_check(peer, afi, safi, | |
14768 | PEER_FLAG_FORCE_NEXTHOP_SELF)) { | |
14769 | vty_out(vty, " neighbor %s next-hop-self force\n", addr); | |
14770 | } | |
14771 | ||
14772 | /* next-hop-self */ | |
14773 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)) { | |
14774 | vty_out(vty, " neighbor %s next-hop-self\n", addr); | |
14775 | } | |
14776 | ||
14777 | /* remove-private-AS */ | |
14778 | if (peergroup_af_flag_check(peer, afi, safi, | |
14779 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) { | |
14780 | vty_out(vty, " neighbor %s remove-private-AS all replace-AS\n", | |
14781 | addr); | |
14782 | } | |
14783 | ||
14784 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14785 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) { | |
14786 | vty_out(vty, " neighbor %s remove-private-AS replace-AS\n", | |
14787 | addr); | |
14788 | } | |
14789 | ||
14790 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14791 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) { | |
14792 | vty_out(vty, " neighbor %s remove-private-AS all\n", addr); | |
14793 | } | |
14794 | ||
14795 | else if (peergroup_af_flag_check(peer, afi, safi, | |
14796 | PEER_FLAG_REMOVE_PRIVATE_AS)) { | |
14797 | vty_out(vty, " neighbor %s remove-private-AS\n", addr); | |
14798 | } | |
14799 | ||
14800 | /* as-override */ | |
14801 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_AS_OVERRIDE)) { | |
14802 | vty_out(vty, " neighbor %s as-override\n", addr); | |
14803 | } | |
14804 | ||
14805 | /* send-community print. */ | |
14806 | flag_scomm = peergroup_af_flag_check(peer, afi, safi, | |
14807 | PEER_FLAG_SEND_COMMUNITY); | |
14808 | flag_secomm = peergroup_af_flag_check(peer, afi, safi, | |
14809 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
14810 | flag_slcomm = peergroup_af_flag_check(peer, afi, safi, | |
14811 | PEER_FLAG_SEND_LARGE_COMMUNITY); | |
14812 | ||
14813 | if (flag_scomm && flag_secomm && flag_slcomm) { | |
14814 | vty_out(vty, " no neighbor %s send-community all\n", addr); | |
14815 | } else { | |
14816 | if (flag_scomm) | |
14817 | vty_out(vty, " no neighbor %s send-community\n", addr); | |
14818 | if (flag_secomm) | |
14819 | vty_out(vty, | |
14820 | " no neighbor %s send-community extended\n", | |
14821 | addr); | |
14822 | ||
14823 | if (flag_slcomm) | |
14824 | vty_out(vty, " no neighbor %s send-community large\n", | |
14825 | addr); | |
14826 | } | |
14827 | ||
14828 | /* Default information */ | |
14829 | if (peergroup_af_flag_check(peer, afi, safi, | |
14830 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
14831 | vty_out(vty, " neighbor %s default-originate", addr); | |
14832 | ||
14833 | if (peer->default_rmap[afi][safi].name) | |
14834 | vty_out(vty, " route-map %s", | |
14835 | peer->default_rmap[afi][safi].name); | |
14836 | ||
14837 | vty_out(vty, "\n"); | |
14838 | } | |
14839 | ||
14840 | /* Soft reconfiguration inbound. */ | |
14841 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_SOFT_RECONFIG)) { | |
14842 | vty_out(vty, " neighbor %s soft-reconfiguration inbound\n", | |
14843 | addr); | |
14844 | } | |
14845 | ||
14846 | /* maximum-prefix. */ | |
14847 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX)) { | |
14848 | vty_out(vty, " neighbor %s maximum-prefix %" PRIu32, addr, | |
14849 | peer->pmax[afi][safi]); | |
14850 | ||
14851 | if (peer->pmax_threshold[afi][safi] | |
14852 | != MAXIMUM_PREFIX_THRESHOLD_DEFAULT) | |
14853 | vty_out(vty, " %u", peer->pmax_threshold[afi][safi]); | |
14854 | if (peer_af_flag_check(peer, afi, safi, | |
14855 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
14856 | vty_out(vty, " warning-only"); | |
14857 | if (peer->pmax_restart[afi][safi]) | |
14858 | vty_out(vty, " restart %u", | |
14859 | peer->pmax_restart[afi][safi]); | |
14860 | ||
14861 | vty_out(vty, "\n"); | |
14862 | } | |
14863 | ||
fde246e8 DA |
14864 | /* maximum-prefix-out */ |
14865 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_MAX_PREFIX_OUT)) | |
14866 | vty_out(vty, " neighbor %s maximum-prefix-out %" PRIu32 "\n", | |
14867 | addr, peer->pmax_out[afi][safi]); | |
14868 | ||
dd65f45e DL |
14869 | /* Route server client. */ |
14870 | if (peergroup_af_flag_check(peer, afi, safi, | |
14871 | PEER_FLAG_RSERVER_CLIENT)) { | |
14872 | vty_out(vty, " neighbor %s route-server-client\n", addr); | |
14873 | } | |
14874 | ||
14875 | /* Nexthop-local unchanged. */ | |
14876 | if (peergroup_af_flag_check(peer, afi, safi, | |
14877 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED)) { | |
14878 | vty_out(vty, " neighbor %s nexthop-local unchanged\n", addr); | |
14879 | } | |
14880 | ||
14881 | /* allowas-in <1-10> */ | |
14882 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_ALLOWAS_IN)) { | |
14883 | if (peer_af_flag_check(peer, afi, safi, | |
14884 | PEER_FLAG_ALLOWAS_IN_ORIGIN)) { | |
14885 | vty_out(vty, " neighbor %s allowas-in origin\n", addr); | |
14886 | } else if (peer->allowas_in[afi][safi] == 3) { | |
14887 | vty_out(vty, " neighbor %s allowas-in\n", addr); | |
14888 | } else { | |
14889 | vty_out(vty, " neighbor %s allowas-in %d\n", addr, | |
14890 | peer->allowas_in[afi][safi]); | |
14891 | } | |
14892 | } | |
14893 | ||
14894 | /* weight */ | |
14895 | if (peergroup_af_flag_check(peer, afi, safi, PEER_FLAG_WEIGHT)) | |
14896 | vty_out(vty, " neighbor %s weight %lu\n", addr, | |
14897 | peer->weight[afi][safi]); | |
14898 | ||
14899 | /* Filter. */ | |
14900 | bgp_config_write_filter(vty, peer, afi, safi); | |
14901 | ||
14902 | /* atribute-unchanged. */ | |
14903 | if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) | |
14904 | || (safi != SAFI_EVPN | |
14905 | && peer_af_flag_check(peer, afi, safi, | |
14906 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
14907 | || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { | |
14908 | ||
14909 | if (!peer_group_active(peer) | |
14910 | || peergroup_af_flag_check(peer, afi, safi, | |
14911 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14912 | || peergroup_af_flag_check(peer, afi, safi, | |
14913 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14914 | || peergroup_af_flag_check(peer, afi, safi, | |
14915 | PEER_FLAG_MED_UNCHANGED)) { | |
14916 | ||
14917 | vty_out(vty, | |
14918 | " neighbor %s attribute-unchanged%s%s%s\n", | |
14919 | addr, | |
14920 | peer_af_flag_check(peer, afi, safi, | |
14921 | PEER_FLAG_AS_PATH_UNCHANGED) | |
14922 | ? " as-path" | |
14923 | : "", | |
14924 | peer_af_flag_check(peer, afi, safi, | |
14925 | PEER_FLAG_NEXTHOP_UNCHANGED) | |
14926 | ? " next-hop" | |
14927 | : "", | |
14928 | peer_af_flag_check(peer, afi, safi, | |
14929 | PEER_FLAG_MED_UNCHANGED) | |
14930 | ? " med" | |
14931 | : ""); | |
14932 | } | |
14933 | } | |
14934 | } | |
14935 | ||
14936 | /* Address family based peer configuration display. */ | |
14937 | static void bgp_config_write_family(struct vty *vty, struct bgp *bgp, afi_t afi, | |
14938 | safi_t safi) | |
14939 | { | |
14940 | struct peer *peer; | |
14941 | struct peer_group *group; | |
14942 | struct listnode *node, *nnode; | |
14943 | ||
14944 | ||
14945 | vty_frame(vty, " !\n address-family "); | |
14946 | if (afi == AFI_IP) { | |
14947 | if (safi == SAFI_UNICAST) | |
14948 | vty_frame(vty, "ipv4 unicast"); | |
14949 | else if (safi == SAFI_LABELED_UNICAST) | |
14950 | vty_frame(vty, "ipv4 labeled-unicast"); | |
14951 | else if (safi == SAFI_MULTICAST) | |
14952 | vty_frame(vty, "ipv4 multicast"); | |
14953 | else if (safi == SAFI_MPLS_VPN) | |
14954 | vty_frame(vty, "ipv4 vpn"); | |
14955 | else if (safi == SAFI_ENCAP) | |
14956 | vty_frame(vty, "ipv4 encap"); | |
14957 | else if (safi == SAFI_FLOWSPEC) | |
14958 | vty_frame(vty, "ipv4 flowspec"); | |
14959 | } else if (afi == AFI_IP6) { | |
14960 | if (safi == SAFI_UNICAST) | |
14961 | vty_frame(vty, "ipv6 unicast"); | |
14962 | else if (safi == SAFI_LABELED_UNICAST) | |
14963 | vty_frame(vty, "ipv6 labeled-unicast"); | |
14964 | else if (safi == SAFI_MULTICAST) | |
14965 | vty_frame(vty, "ipv6 multicast"); | |
14966 | else if (safi == SAFI_MPLS_VPN) | |
14967 | vty_frame(vty, "ipv6 vpn"); | |
14968 | else if (safi == SAFI_ENCAP) | |
14969 | vty_frame(vty, "ipv6 encap"); | |
14970 | else if (safi == SAFI_FLOWSPEC) | |
14971 | vty_frame(vty, "ipv6 flowspec"); | |
14972 | } else if (afi == AFI_L2VPN) { | |
14973 | if (safi == SAFI_EVPN) | |
14974 | vty_frame(vty, "l2vpn evpn"); | |
14975 | } | |
14976 | vty_frame(vty, "\n"); | |
14977 | ||
14978 | bgp_config_write_distance(vty, bgp, afi, safi); | |
14979 | ||
14980 | bgp_config_write_network(vty, bgp, afi, safi); | |
14981 | ||
14982 | bgp_config_write_redistribute(vty, bgp, afi, safi); | |
14983 | ||
14984 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) | |
14985 | bgp_config_write_peer_af(vty, bgp, group->conf, afi, safi); | |
14986 | ||
14987 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
14988 | /* Skip dynamic neighbors. */ | |
14989 | if (peer_dynamic_neighbor(peer)) | |
14990 | continue; | |
14991 | ||
14992 | /* Do not display doppelganger peers */ | |
14993 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
14994 | bgp_config_write_peer_af(vty, bgp, peer, afi, safi); | |
14995 | } | |
14996 | ||
14997 | bgp_config_write_maxpaths(vty, bgp, afi, safi); | |
14998 | bgp_config_write_table_map(vty, bgp, afi, safi); | |
14999 | ||
15000 | if (safi == SAFI_EVPN) | |
15001 | bgp_config_write_evpn_info(vty, bgp, afi, safi); | |
15002 | ||
15003 | if (safi == SAFI_FLOWSPEC) | |
15004 | bgp_fs_config_write_pbr(vty, bgp, afi, safi); | |
15005 | ||
15006 | if (safi == SAFI_UNICAST) { | |
15007 | bgp_vpn_policy_config_write_afi(vty, bgp, afi); | |
15008 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15009 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT)) { | |
15010 | ||
15011 | vty_out(vty, " export vpn\n"); | |
15012 | } | |
15013 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15014 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
15015 | ||
15016 | vty_out(vty, " import vpn\n"); | |
15017 | } | |
15018 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
15019 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
15020 | char *name; | |
15021 | ||
15022 | for (ALL_LIST_ELEMENTS_RO( | |
15023 | bgp->vpn_policy[afi].import_vrf, node, | |
15024 | name)) | |
15025 | vty_out(vty, " import vrf %s\n", name); | |
15026 | } | |
15027 | } | |
15028 | ||
15029 | vty_endframe(vty, " exit-address-family\n"); | |
15030 | } | |
15031 | ||
15032 | int bgp_config_write(struct vty *vty) | |
15033 | { | |
15034 | struct bgp *bgp; | |
15035 | struct peer_group *group; | |
15036 | struct peer *peer; | |
15037 | struct listnode *node, *nnode; | |
15038 | struct listnode *mnode, *mnnode; | |
15039 | ||
15040 | if (bm->rmap_update_timer != RMAP_DEFAULT_UPDATE_TIMER) | |
15041 | vty_out(vty, "bgp route-map delay-timer %u\n", | |
15042 | bm->rmap_update_timer); | |
15043 | ||
15044 | /* BGP configuration. */ | |
15045 | for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) { | |
15046 | ||
15047 | /* skip all auto created vrf as they dont have user config */ | |
15048 | if (CHECK_FLAG(bgp->vrf_flags, BGP_VRF_AUTO)) | |
15049 | continue; | |
15050 | ||
15051 | /* Router bgp ASN */ | |
15052 | vty_out(vty, "router bgp %u", bgp->as); | |
15053 | ||
15054 | if (bgp->name) | |
15055 | vty_out(vty, " %s %s", | |
15056 | (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
15057 | ? "view" : "vrf", bgp->name); | |
15058 | vty_out(vty, "\n"); | |
15059 | ||
15060 | /* BGP fast-external-failover. */ | |
15061 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER)) | |
15062 | vty_out(vty, " no bgp fast-external-failover\n"); | |
15063 | ||
15064 | /* BGP router ID. */ | |
15065 | if (bgp->router_id_static.s_addr != 0) | |
15066 | vty_out(vty, " bgp router-id %s\n", | |
15067 | inet_ntoa(bgp->router_id_static)); | |
15068 | ||
15069 | /* BGP log-neighbor-changes. */ | |
892fedb6 | 15070 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LOG_NEIGHBOR_CHANGES) |
5d5393b9 | 15071 | != SAVE_BGP_LOG_NEIGHBOR_CHANGES) |
dd65f45e | 15072 | vty_out(vty, " %sbgp log-neighbor-changes\n", |
892fedb6 DA |
15073 | CHECK_FLAG(bgp->flags, |
15074 | BGP_FLAG_LOG_NEIGHBOR_CHANGES) | |
dd65f45e DL |
15075 | ? "" |
15076 | : "no "); | |
15077 | ||
15078 | /* BGP configuration. */ | |
892fedb6 | 15079 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ALWAYS_COMPARE_MED)) |
dd65f45e DL |
15080 | vty_out(vty, " bgp always-compare-med\n"); |
15081 | ||
15082 | /* RFC8212 default eBGP policy. */ | |
1d3fdccf DA |
15083 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_EBGP_REQUIRES_POLICY) |
15084 | != SAVE_BGP_EBGP_REQUIRES_POLICY) | |
15085 | vty_out(vty, " %sbgp ebgp-requires-policy\n", | |
15086 | CHECK_FLAG(bgp->flags, | |
15087 | BGP_FLAG_EBGP_REQUIRES_POLICY) | |
15088 | ? "" | |
15089 | : "no "); | |
dd65f45e DL |
15090 | |
15091 | /* draft-ietf-idr-deprecate-as-set-confed-set */ | |
7f972cd8 | 15092 | if (bgp->reject_as_sets) |
dd65f45e DL |
15093 | vty_out(vty, " bgp reject-as-sets\n"); |
15094 | ||
15095 | /* BGP default ipv4-unicast. */ | |
892fedb6 | 15096 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_DEFAULT_IPV4)) |
dd65f45e DL |
15097 | vty_out(vty, " no bgp default ipv4-unicast\n"); |
15098 | ||
15099 | /* BGP default local-preference. */ | |
15100 | if (bgp->default_local_pref != BGP_DEFAULT_LOCAL_PREF) | |
15101 | vty_out(vty, " bgp default local-preference %u\n", | |
15102 | bgp->default_local_pref); | |
15103 | ||
15104 | /* BGP default show-hostname */ | |
892fedb6 | 15105 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
5d5393b9 | 15106 | != SAVE_BGP_SHOW_HOSTNAME) |
dd65f45e | 15107 | vty_out(vty, " %sbgp default show-hostname\n", |
892fedb6 | 15108 | CHECK_FLAG(bgp->flags, BGP_FLAG_SHOW_HOSTNAME) |
dd65f45e DL |
15109 | ? "" |
15110 | : "no "); | |
15111 | ||
15112 | /* BGP default subgroup-pkt-queue-max. */ | |
15113 | if (bgp->default_subgroup_pkt_queue_max | |
15114 | != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX) | |
15115 | vty_out(vty, " bgp default subgroup-pkt-queue-max %u\n", | |
15116 | bgp->default_subgroup_pkt_queue_max); | |
15117 | ||
15118 | /* BGP client-to-client reflection. */ | |
892fedb6 | 15119 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_NO_CLIENT_TO_CLIENT)) |
dd65f45e DL |
15120 | vty_out(vty, " no bgp client-to-client reflection\n"); |
15121 | ||
15122 | /* BGP cluster ID. */ | |
15123 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CLUSTER_ID)) | |
15124 | vty_out(vty, " bgp cluster-id %s\n", | |
15125 | inet_ntoa(bgp->cluster_id)); | |
15126 | ||
15127 | /* Disable ebgp connected nexthop check */ | |
892fedb6 | 15128 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_DISABLE_NH_CONNECTED_CHK)) |
dd65f45e DL |
15129 | vty_out(vty, |
15130 | " bgp disable-ebgp-connected-route-check\n"); | |
15131 | ||
15132 | /* Confederation identifier*/ | |
15133 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
15134 | vty_out(vty, " bgp confederation identifier %u\n", | |
15135 | bgp->confed_id); | |
15136 | ||
15137 | /* Confederation peer */ | |
15138 | if (bgp->confed_peers_cnt > 0) { | |
15139 | int i; | |
15140 | ||
15141 | vty_out(vty, " bgp confederation peers"); | |
15142 | ||
15143 | for (i = 0; i < bgp->confed_peers_cnt; i++) | |
15144 | vty_out(vty, " %u", bgp->confed_peers[i]); | |
15145 | ||
15146 | vty_out(vty, "\n"); | |
15147 | } | |
15148 | ||
15149 | /* BGP deterministic-med. */ | |
892fedb6 | 15150 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_DETERMINISTIC_MED) |
5d5393b9 | 15151 | != SAVE_BGP_DETERMINISTIC_MED) |
dd65f45e | 15152 | vty_out(vty, " %sbgp deterministic-med\n", |
892fedb6 DA |
15153 | CHECK_FLAG(bgp->flags, |
15154 | BGP_FLAG_DETERMINISTIC_MED) | |
dd65f45e DL |
15155 | ? "" |
15156 | : "no "); | |
15157 | ||
15158 | /* BGP update-delay. */ | |
15159 | bgp_config_write_update_delay(vty, bgp); | |
15160 | ||
15161 | if (bgp->v_maxmed_onstartup | |
15162 | != BGP_MAXMED_ONSTARTUP_UNCONFIGURED) { | |
15163 | vty_out(vty, " bgp max-med on-startup %u", | |
15164 | bgp->v_maxmed_onstartup); | |
15165 | if (bgp->maxmed_onstartup_value | |
15166 | != BGP_MAXMED_VALUE_DEFAULT) | |
15167 | vty_out(vty, " %u", | |
15168 | bgp->maxmed_onstartup_value); | |
15169 | vty_out(vty, "\n"); | |
15170 | } | |
15171 | if (bgp->v_maxmed_admin != BGP_MAXMED_ADMIN_UNCONFIGURED) { | |
15172 | vty_out(vty, " bgp max-med administrative"); | |
15173 | if (bgp->maxmed_admin_value != BGP_MAXMED_VALUE_DEFAULT) | |
15174 | vty_out(vty, " %u", bgp->maxmed_admin_value); | |
15175 | vty_out(vty, "\n"); | |
15176 | } | |
15177 | ||
15178 | /* write quanta */ | |
15179 | bgp_config_write_wpkt_quanta(vty, bgp); | |
15180 | /* read quanta */ | |
15181 | bgp_config_write_rpkt_quanta(vty, bgp); | |
15182 | ||
15183 | /* coalesce time */ | |
15184 | bgp_config_write_coalesce_time(vty, bgp); | |
15185 | ||
15186 | /* BGP graceful-restart. */ | |
15187 | if (bgp->stalepath_time != BGP_DEFAULT_STALEPATH_TIME) | |
15188 | vty_out(vty, | |
15189 | " bgp graceful-restart stalepath-time %u\n", | |
15190 | bgp->stalepath_time); | |
cfd47646 | 15191 | |
dd65f45e DL |
15192 | if (bgp->restart_time != BGP_DEFAULT_RESTART_TIME) |
15193 | vty_out(vty, " bgp graceful-restart restart-time %u\n", | |
15194 | bgp->restart_time); | |
cfd47646 | 15195 | |
15196 | if (bgp->select_defer_time != BGP_DEFAULT_SELECT_DEFERRAL_TIME) | |
15197 | vty_out(vty, | |
15198 | " bgp graceful-restart select-defer-time %u\n", | |
15199 | bgp->select_defer_time); | |
15200 | ||
15201 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_GR) | |
dd65f45e DL |
15202 | vty_out(vty, " bgp graceful-restart\n"); |
15203 | ||
cfd47646 | 15204 | if (bgp_global_gr_mode_get(bgp) == GLOBAL_DISABLE) |
15205 | vty_out(vty, " bgp graceful-restart-disable\n"); | |
15206 | ||
dd65f45e | 15207 | /* BGP graceful-shutdown */ |
892fedb6 | 15208 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GRACEFUL_SHUTDOWN)) |
dd65f45e DL |
15209 | vty_out(vty, " bgp graceful-shutdown\n"); |
15210 | ||
15211 | /* BGP graceful-restart Preserve State F bit. */ | |
892fedb6 | 15212 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_GR_PRESERVE_FWD)) |
dd65f45e DL |
15213 | vty_out(vty, |
15214 | " bgp graceful-restart preserve-fw-state\n"); | |
15215 | ||
dc95985f | 15216 | /* Stale timer for RIB */ |
15217 | if (bgp->rib_stale_time != BGP_DEFAULT_RIB_STALE_TIME) | |
15218 | vty_out(vty, | |
15219 | " bgp graceful-restart rib-stale-time %u\n", | |
15220 | bgp->rib_stale_time); | |
15221 | ||
dd65f45e | 15222 | /* BGP bestpath method. */ |
892fedb6 | 15223 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_IGNORE)) |
dd65f45e | 15224 | vty_out(vty, " bgp bestpath as-path ignore\n"); |
892fedb6 | 15225 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_CONFED)) |
dd65f45e DL |
15226 | vty_out(vty, " bgp bestpath as-path confed\n"); |
15227 | ||
892fedb6 DA |
15228 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { |
15229 | if (CHECK_FLAG(bgp->flags, | |
15230 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) { | |
dd65f45e DL |
15231 | vty_out(vty, |
15232 | " bgp bestpath as-path multipath-relax as-set\n"); | |
15233 | } else { | |
15234 | vty_out(vty, | |
15235 | " bgp bestpath as-path multipath-relax\n"); | |
15236 | } | |
15237 | } | |
15238 | ||
892fedb6 | 15239 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
dd65f45e DL |
15240 | vty_out(vty, |
15241 | " bgp route-reflector allow-outbound-policy\n"); | |
15242 | } | |
892fedb6 | 15243 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_COMPARE_ROUTER_ID)) |
dd65f45e | 15244 | vty_out(vty, " bgp bestpath compare-routerid\n"); |
892fedb6 DA |
15245 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED) |
15246 | || CHECK_FLAG(bgp->flags, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
dd65f45e | 15247 | vty_out(vty, " bgp bestpath med"); |
892fedb6 | 15248 | if (CHECK_FLAG(bgp->flags, BGP_FLAG_MED_CONFED)) |
dd65f45e | 15249 | vty_out(vty, " confed"); |
892fedb6 DA |
15250 | if (CHECK_FLAG(bgp->flags, |
15251 | BGP_FLAG_MED_MISSING_AS_WORST)) | |
dd65f45e DL |
15252 | vty_out(vty, " missing-as-worst"); |
15253 | vty_out(vty, "\n"); | |
15254 | } | |
15255 | ||
f7e1c681 | 15256 | /* Link bandwidth handling. */ |
15257 | if (bgp->lb_handling == BGP_LINK_BW_IGNORE_BW) | |
15258 | vty_out(vty, " bgp bestpath bandwidth ignore\n"); | |
15259 | else if (bgp->lb_handling == BGP_LINK_BW_SKIP_MISSING) | |
15260 | vty_out(vty, " bgp bestpath bandwidth skip-missing\n"); | |
15261 | else if (bgp->lb_handling == BGP_LINK_BW_DEFWT_4_MISSING) | |
15262 | vty_out(vty, " bgp bestpath bandwidth default-weight-for-missing\n"); | |
15263 | ||
dd65f45e | 15264 | /* BGP network import check. */ |
892fedb6 | 15265 | if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
5d5393b9 | 15266 | != SAVE_BGP_IMPORT_CHECK) |
dd65f45e | 15267 | vty_out(vty, " %sbgp network import-check\n", |
892fedb6 | 15268 | CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK) |
dd65f45e DL |
15269 | ? "" |
15270 | : "no "); | |
15271 | ||
15272 | /* BGP timers configuration. */ | |
5d5393b9 DL |
15273 | if (bgp->default_keepalive != SAVE_BGP_KEEPALIVE |
15274 | && bgp->default_holdtime != SAVE_BGP_HOLDTIME) | |
dd65f45e DL |
15275 | vty_out(vty, " timers bgp %u %u\n", |
15276 | bgp->default_keepalive, bgp->default_holdtime); | |
15277 | ||
15278 | /* peer-group */ | |
15279 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
15280 | bgp_config_write_peer_global(vty, bgp, group->conf); | |
15281 | } | |
15282 | ||
15283 | /* Normal neighbor configuration. */ | |
15284 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
15285 | if (CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
15286 | bgp_config_write_peer_global(vty, bgp, peer); | |
15287 | } | |
15288 | ||
15289 | /* listen range and limit for dynamic BGP neighbors */ | |
15290 | bgp_config_write_listen(vty, bgp); | |
15291 | ||
15292 | /* | |
15293 | * BGP default autoshutdown neighbors | |
15294 | * | |
15295 | * This must be placed after any peer and peer-group | |
15296 | * configuration, to avoid setting all peers to shutdown after | |
15297 | * a daemon restart, which is undesired behavior. (see #2286) | |
15298 | */ | |
15299 | if (bgp->autoshutdown) | |
15300 | vty_out(vty, " bgp default shutdown\n"); | |
15301 | ||
15302 | /* IPv4 unicast configuration. */ | |
15303 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_UNICAST); | |
15304 | ||
15305 | /* IPv4 multicast configuration. */ | |
15306 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MULTICAST); | |
15307 | ||
15308 | /* IPv4 labeled-unicast configuration. */ | |
15309 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_LABELED_UNICAST); | |
15310 | ||
15311 | /* IPv4 VPN configuration. */ | |
15312 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_MPLS_VPN); | |
15313 | ||
15314 | /* ENCAPv4 configuration. */ | |
15315 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_ENCAP); | |
15316 | ||
15317 | /* FLOWSPEC v4 configuration. */ | |
15318 | bgp_config_write_family(vty, bgp, AFI_IP, SAFI_FLOWSPEC); | |
15319 | ||
15320 | /* IPv6 unicast configuration. */ | |
15321 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_UNICAST); | |
15322 | ||
15323 | /* IPv6 multicast configuration. */ | |
15324 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MULTICAST); | |
15325 | ||
15326 | /* IPv6 labeled-unicast configuration. */ | |
15327 | bgp_config_write_family(vty, bgp, AFI_IP6, | |
15328 | SAFI_LABELED_UNICAST); | |
15329 | ||
15330 | /* IPv6 VPN configuration. */ | |
15331 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_MPLS_VPN); | |
15332 | ||
15333 | /* ENCAPv6 configuration. */ | |
15334 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_ENCAP); | |
15335 | ||
15336 | /* FLOWSPEC v6 configuration. */ | |
15337 | bgp_config_write_family(vty, bgp, AFI_IP6, SAFI_FLOWSPEC); | |
15338 | ||
15339 | /* EVPN configuration. */ | |
15340 | bgp_config_write_family(vty, bgp, AFI_L2VPN, SAFI_EVPN); | |
15341 | ||
15342 | hook_call(bgp_inst_config_write, bgp, vty); | |
15343 | ||
49e5a4a0 | 15344 | #ifdef ENABLE_BGP_VNC |
dd65f45e DL |
15345 | bgp_rfapi_cfg_write(vty, bgp); |
15346 | #endif | |
15347 | ||
15348 | vty_out(vty, "!\n"); | |
15349 | } | |
15350 | return 0; | |
15351 | } | |
15352 | ||
ddb5b488 | 15353 | |
718e3744 | 15354 | /* BGP node structure. */ |
d62a17ae | 15355 | static struct cmd_node bgp_node = { |
f4b8291f | 15356 | .name = "bgp", |
62b346ee | 15357 | .node = BGP_NODE, |
24389580 | 15358 | .parent_node = CONFIG_NODE, |
62b346ee | 15359 | .prompt = "%s(config-router)# ", |
612c2c15 | 15360 | .config_write = bgp_config_write, |
718e3744 | 15361 | }; |
15362 | ||
d62a17ae | 15363 | static struct cmd_node bgp_ipv4_unicast_node = { |
f4b8291f | 15364 | .name = "bgp ipv4 unicast", |
62b346ee | 15365 | .node = BGP_IPV4_NODE, |
24389580 | 15366 | .parent_node = BGP_NODE, |
62b346ee | 15367 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15368 | }; |
15369 | ||
d62a17ae | 15370 | static struct cmd_node bgp_ipv4_multicast_node = { |
f4b8291f | 15371 | .name = "bgp ipv4 multicast", |
62b346ee | 15372 | .node = BGP_IPV4M_NODE, |
24389580 | 15373 | .parent_node = BGP_NODE, |
62b346ee | 15374 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15375 | }; |
15376 | ||
d62a17ae | 15377 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
f4b8291f | 15378 | .name = "bgp ipv4 labeled unicast", |
62b346ee | 15379 | .node = BGP_IPV4L_NODE, |
24389580 | 15380 | .parent_node = BGP_NODE, |
62b346ee | 15381 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15382 | }; |
15383 | ||
d62a17ae | 15384 | static struct cmd_node bgp_ipv6_unicast_node = { |
f4b8291f | 15385 | .name = "bgp ipv6", |
62b346ee | 15386 | .node = BGP_IPV6_NODE, |
24389580 | 15387 | .parent_node = BGP_NODE, |
62b346ee | 15388 | .prompt = "%s(config-router-af)# ", |
718e3744 | 15389 | }; |
15390 | ||
d62a17ae | 15391 | static struct cmd_node bgp_ipv6_multicast_node = { |
f4b8291f | 15392 | .name = "bgp ipv6 multicast", |
62b346ee | 15393 | .node = BGP_IPV6M_NODE, |
24389580 | 15394 | .parent_node = BGP_NODE, |
62b346ee | 15395 | .prompt = "%s(config-router-af)# ", |
25ffbdc1 | 15396 | }; |
15397 | ||
d62a17ae | 15398 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
f4b8291f | 15399 | .name = "bgp ipv6 labeled unicast", |
62b346ee | 15400 | .node = BGP_IPV6L_NODE, |
24389580 | 15401 | .parent_node = BGP_NODE, |
62b346ee | 15402 | .prompt = "%s(config-router-af)# ", |
f51bae9c DS |
15403 | }; |
15404 | ||
62b346ee | 15405 | static struct cmd_node bgp_vpnv4_node = { |
f4b8291f | 15406 | .name = "bgp vpnv4", |
62b346ee | 15407 | .node = BGP_VPNV4_NODE, |
24389580 | 15408 | .parent_node = BGP_NODE, |
62b346ee | 15409 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15410 | }; |
6b0655a2 | 15411 | |
62b346ee | 15412 | static struct cmd_node bgp_vpnv6_node = { |
f4b8291f | 15413 | .name = "bgp vpnv6", |
62b346ee | 15414 | .node = BGP_VPNV6_NODE, |
24389580 | 15415 | .parent_node = BGP_NODE, |
62b346ee | 15416 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15417 | }; |
8ecd3266 | 15418 | |
62b346ee | 15419 | static struct cmd_node bgp_evpn_node = { |
f4b8291f | 15420 | .name = "bgp evpn", |
62b346ee | 15421 | .node = BGP_EVPN_NODE, |
24389580 | 15422 | .parent_node = BGP_NODE, |
62b346ee | 15423 | .prompt = "%s(config-router-evpn)# ", |
62b346ee | 15424 | }; |
4e0b7b6d | 15425 | |
62b346ee | 15426 | static struct cmd_node bgp_evpn_vni_node = { |
f4b8291f | 15427 | .name = "bgp evpn vni", |
62b346ee | 15428 | .node = BGP_EVPN_VNI_NODE, |
24389580 | 15429 | .parent_node = BGP_EVPN_NODE, |
62b346ee | 15430 | .prompt = "%s(config-router-af-vni)# ", |
62b346ee | 15431 | }; |
90e60aa7 | 15432 | |
62b346ee | 15433 | static struct cmd_node bgp_flowspecv4_node = { |
f4b8291f | 15434 | .name = "bgp ipv4 flowspec", |
62b346ee | 15435 | .node = BGP_FLOWSPECV4_NODE, |
24389580 | 15436 | .parent_node = BGP_NODE, |
62b346ee | 15437 | .prompt = "%s(config-router-af)# ", |
62b346ee | 15438 | }; |
7c40bf39 | 15439 | |
62b346ee | 15440 | static struct cmd_node bgp_flowspecv6_node = { |
f4b8291f | 15441 | .name = "bgp ipv6 flowspec", |
62b346ee | 15442 | .node = BGP_FLOWSPECV6_NODE, |
24389580 | 15443 | .parent_node = BGP_NODE, |
62b346ee | 15444 | .prompt = "%s(config-router-af-vpnv6)# ", |
62b346ee | 15445 | }; |
7c40bf39 | 15446 | |
d62a17ae | 15447 | static void community_list_vty(void); |
1f8ae70b | 15448 | |
d62a17ae | 15449 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 15450 | { |
d62a17ae | 15451 | struct bgp *bgp; |
15452 | struct peer *peer; | |
d62a17ae | 15453 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 15454 | |
d62a17ae | 15455 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
15456 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
15457 | /* only provide suggestions on the appropriate input | |
15458 | * token type, | |
15459 | * they'll otherwise show up multiple times */ | |
15460 | enum cmd_token_type match_type; | |
15461 | char *name = peer->host; | |
d48ed3e0 | 15462 | |
d62a17ae | 15463 | if (peer->conf_if) { |
15464 | match_type = VARIABLE_TKN; | |
15465 | name = peer->conf_if; | |
15466 | } else if (strchr(peer->host, ':')) | |
15467 | match_type = IPV6_TKN; | |
15468 | else | |
15469 | match_type = IPV4_TKN; | |
d48ed3e0 | 15470 | |
d62a17ae | 15471 | if (token->type != match_type) |
15472 | continue; | |
d48ed3e0 | 15473 | |
d62a17ae | 15474 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
15475 | } | |
d62a17ae | 15476 | } |
b8a815e5 DL |
15477 | } |
15478 | ||
15479 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 15480 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
15481 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 15482 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 15483 | {.completions = NULL}}; |
15484 | ||
47a306a0 DS |
15485 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
15486 | { | |
15487 | struct bgp *bgp; | |
15488 | struct peer_group *group; | |
15489 | struct listnode *lnbgp, *lnpeer; | |
15490 | ||
15491 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
15492 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
15493 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
15494 | group->name)); | |
15495 | } | |
15496 | } | |
15497 | ||
15498 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
15499 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
15500 | {.completions = NULL} }; | |
15501 | ||
d62a17ae | 15502 | void bgp_vty_init(void) |
15503 | { | |
15504 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 15505 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 15506 | |
15507 | /* Install bgp top node. */ | |
612c2c15 DL |
15508 | install_node(&bgp_node); |
15509 | install_node(&bgp_ipv4_unicast_node); | |
15510 | install_node(&bgp_ipv4_multicast_node); | |
15511 | install_node(&bgp_ipv4_labeled_unicast_node); | |
15512 | install_node(&bgp_ipv6_unicast_node); | |
15513 | install_node(&bgp_ipv6_multicast_node); | |
15514 | install_node(&bgp_ipv6_labeled_unicast_node); | |
15515 | install_node(&bgp_vpnv4_node); | |
15516 | install_node(&bgp_vpnv6_node); | |
15517 | install_node(&bgp_evpn_node); | |
15518 | install_node(&bgp_evpn_vni_node); | |
15519 | install_node(&bgp_flowspecv4_node); | |
15520 | install_node(&bgp_flowspecv6_node); | |
d62a17ae | 15521 | |
15522 | /* Install default VTY commands to new nodes. */ | |
15523 | install_default(BGP_NODE); | |
15524 | install_default(BGP_IPV4_NODE); | |
15525 | install_default(BGP_IPV4M_NODE); | |
15526 | install_default(BGP_IPV4L_NODE); | |
15527 | install_default(BGP_IPV6_NODE); | |
15528 | install_default(BGP_IPV6M_NODE); | |
15529 | install_default(BGP_IPV6L_NODE); | |
15530 | install_default(BGP_VPNV4_NODE); | |
15531 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 15532 | install_default(BGP_FLOWSPECV4_NODE); |
15533 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 15534 | install_default(BGP_EVPN_NODE); |
15535 | install_default(BGP_EVPN_VNI_NODE); | |
15536 | ||
8029b216 AK |
15537 | /* "bgp local-mac" hidden commands. */ |
15538 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
15539 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
15540 | ||
d62a17ae | 15541 | /* bgp route-map delay-timer commands. */ |
15542 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15543 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15544 | ||
15545 | /* Dummy commands (Currently not supported) */ | |
15546 | install_element(BGP_NODE, &no_synchronization_cmd); | |
15547 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
15548 | ||
15549 | /* "router bgp" commands. */ | |
15550 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
15551 | ||
15552 | /* "no router bgp" commands. */ | |
15553 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
15554 | ||
15555 | /* "bgp router-id" commands. */ | |
15556 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
15557 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
15558 | ||
15559 | /* "bgp cluster-id" commands. */ | |
15560 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
15561 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
15562 | ||
15563 | /* "bgp confederation" commands. */ | |
15564 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
15565 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
15566 | ||
15567 | /* "bgp confederation peers" commands. */ | |
15568 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
15569 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
15570 | ||
15571 | /* bgp max-med command */ | |
15572 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
15573 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
15574 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
15575 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
15576 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
15577 | ||
15578 | /* bgp disable-ebgp-connected-nh-check */ | |
15579 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
15580 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
15581 | ||
15582 | /* bgp update-delay command */ | |
15583 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
15584 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
15585 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
15586 | ||
15587 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
555e09d4 | 15588 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
d62a17ae | 15589 | |
15590 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
15591 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
15592 | ||
15593 | /* "maximum-paths" commands. */ | |
15594 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
15595 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
15596 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
15597 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
15598 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
15599 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
15600 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
15601 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
15602 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
15603 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
15604 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15605 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15606 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
15607 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15608 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15609 | ||
15610 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
15611 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
15612 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
15613 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
15614 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
15615 | ||
15616 | /* "timers bgp" commands. */ | |
15617 | install_element(BGP_NODE, &bgp_timers_cmd); | |
15618 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
15619 | ||
15620 | /* route-map delay-timer commands - per instance for backwards compat. | |
15621 | */ | |
15622 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
15623 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
15624 | ||
15625 | /* "bgp client-to-client reflection" commands */ | |
15626 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
15627 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
15628 | ||
15629 | /* "bgp always-compare-med" commands */ | |
15630 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
15631 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
15632 | ||
9dac9fc8 DA |
15633 | /* bgp ebgp-requires-policy */ |
15634 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
15635 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
15636 | ||
fb29348a DA |
15637 | /* bgp reject-as-sets */ |
15638 | install_element(BGP_NODE, &bgp_reject_as_sets_cmd); | |
15639 | install_element(BGP_NODE, &no_bgp_reject_as_sets_cmd); | |
15640 | ||
d62a17ae | 15641 | /* "bgp deterministic-med" commands */ |
15642 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
15643 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
15644 | ||
055679e9 | 15645 | /* "bgp graceful-restart" command */ |
36235319 QY |
15646 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); |
15647 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
055679e9 | 15648 | |
15649 | /* "bgp graceful-restart-disable" command */ | |
36235319 QY |
15650 | install_element(BGP_NODE, &bgp_graceful_restart_disable_cmd); |
15651 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_cmd); | |
055679e9 | 15652 | |
15653 | /* "neighbor a:b:c:d graceful-restart" command */ | |
36235319 QY |
15654 | install_element(BGP_NODE, &bgp_neighbor_graceful_restart_set_cmd); |
15655 | install_element(BGP_NODE, &no_bgp_neighbor_graceful_restart_set_cmd); | |
055679e9 | 15656 | |
15657 | /* "neighbor a:b:c:d graceful-restart-disable" command */ | |
15658 | install_element(BGP_NODE, | |
15659 | &bgp_neighbor_graceful_restart_disable_set_cmd); | |
15660 | install_element(BGP_NODE, | |
15661 | &no_bgp_neighbor_graceful_restart_disable_set_cmd); | |
15662 | ||
15663 | /* "neighbor a:b:c:d graceful-restart-helper" command */ | |
15664 | install_element(BGP_NODE, | |
15665 | &bgp_neighbor_graceful_restart_helper_set_cmd); | |
15666 | install_element(BGP_NODE, | |
15667 | &no_bgp_neighbor_graceful_restart_helper_set_cmd); | |
15668 | ||
d62a17ae | 15669 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
15670 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
15671 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
15672 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
cfd47646 | 15673 | install_element(BGP_NODE, &bgp_graceful_restart_select_defer_time_cmd); |
f009ff26 | 15674 | install_element(BGP_NODE, |
15675 | &no_bgp_graceful_restart_select_defer_time_cmd); | |
d62a17ae | 15676 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
15677 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
15678 | ||
d6e3c15b | 15679 | install_element(BGP_NODE, &bgp_graceful_restart_disable_eor_cmd); |
15680 | install_element(BGP_NODE, &no_bgp_graceful_restart_disable_eor_cmd); | |
dc95985f | 15681 | install_element(BGP_NODE, &bgp_graceful_restart_rib_stale_time_cmd); |
15682 | install_element(BGP_NODE, &no_bgp_graceful_restart_rib_stale_time_cmd); | |
d6e3c15b | 15683 | |
7f323236 DW |
15684 | /* "bgp graceful-shutdown" commands */ |
15685 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
15686 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
15687 | ||
d62a17ae | 15688 | /* "bgp fast-external-failover" commands */ |
15689 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
15690 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
15691 | ||
d62a17ae | 15692 | /* "bgp bestpath compare-routerid" commands */ |
15693 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
15694 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
15695 | ||
15696 | /* "bgp bestpath as-path ignore" commands */ | |
15697 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
15698 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
15699 | ||
15700 | /* "bgp bestpath as-path confed" commands */ | |
15701 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
15702 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
15703 | ||
15704 | /* "bgp bestpath as-path multipath-relax" commands */ | |
15705 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
15706 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
15707 | ||
15708 | /* "bgp log-neighbor-changes" commands */ | |
15709 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
15710 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
15711 | ||
15712 | /* "bgp bestpath med" commands */ | |
15713 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
15714 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
15715 | ||
f7e1c681 | 15716 | /* "bgp bestpath bandwidth" commands */ |
15717 | install_element(BGP_NODE, &bgp_bestpath_bw_cmd); | |
15718 | ||
d62a17ae | 15719 | /* "no bgp default ipv4-unicast" commands. */ |
15720 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
15721 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
15722 | ||
15723 | /* "bgp network import-check" commands. */ | |
15724 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
15725 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
15726 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
15727 | ||
15728 | /* "bgp default local-preference" commands. */ | |
15729 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
15730 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
15731 | ||
15732 | /* bgp default show-hostname */ | |
15733 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
15734 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
15735 | ||
15736 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
15737 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
15738 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
15739 | ||
15740 | /* bgp ibgp-allow-policy-mods command */ | |
15741 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
15742 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
15743 | ||
15744 | /* "bgp listen limit" commands. */ | |
15745 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
15746 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
15747 | ||
15748 | /* "bgp listen range" commands. */ | |
15749 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
15750 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
15751 | ||
8175f54a | 15752 | /* "bgp default shutdown" command */ |
f26845f9 QY |
15753 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
15754 | ||
d62a17ae | 15755 | /* "neighbor remote-as" commands. */ |
15756 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
15757 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
15758 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
15759 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
15760 | install_element(BGP_NODE, | |
15761 | &neighbor_interface_v6only_config_remote_as_cmd); | |
15762 | install_element(BGP_NODE, &no_neighbor_cmd); | |
15763 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
15764 | ||
15765 | /* "neighbor peer-group" commands. */ | |
15766 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
15767 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
15768 | install_element(BGP_NODE, | |
15769 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
15770 | ||
15771 | /* "neighbor local-as" commands. */ | |
15772 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
15773 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
15774 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
15775 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
15776 | ||
15777 | /* "neighbor solo" commands. */ | |
15778 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
15779 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
15780 | ||
15781 | /* "neighbor password" commands. */ | |
15782 | install_element(BGP_NODE, &neighbor_password_cmd); | |
15783 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
15784 | ||
15785 | /* "neighbor activate" commands. */ | |
15786 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
15787 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
15788 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
15789 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
15790 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
15791 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
15792 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
15793 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
15794 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 15795 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
15796 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 15797 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
15798 | ||
15799 | /* "no neighbor activate" commands. */ | |
15800 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
15801 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
15802 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
15803 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
15804 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
15805 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
15806 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
15807 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
15808 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 15809 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
15810 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 15811 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
15812 | ||
15813 | /* "neighbor peer-group" set commands. */ | |
15814 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
15815 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15816 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15817 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15818 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15819 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15820 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
15821 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15822 | install_element(BGP_FLOWSPECV4_NODE, |
15823 | &neighbor_set_peer_group_hidden_cmd); | |
15824 | install_element(BGP_FLOWSPECV6_NODE, | |
15825 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15826 | |
15827 | /* "no neighbor peer-group unset" commands. */ | |
15828 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
15829 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15830 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15831 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15832 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15833 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15834 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
15835 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 15836 | install_element(BGP_FLOWSPECV4_NODE, |
15837 | &no_neighbor_set_peer_group_hidden_cmd); | |
15838 | install_element(BGP_FLOWSPECV6_NODE, | |
15839 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 15840 | |
15841 | /* "neighbor softreconfiguration inbound" commands.*/ | |
15842 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
15843 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
15844 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15845 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15846 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15847 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15848 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15849 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15850 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15851 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15852 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
15853 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15854 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
15855 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15856 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
15857 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
15858 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
15859 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 15860 | install_element(BGP_FLOWSPECV4_NODE, |
15861 | &neighbor_soft_reconfiguration_cmd); | |
15862 | install_element(BGP_FLOWSPECV4_NODE, | |
15863 | &no_neighbor_soft_reconfiguration_cmd); | |
15864 | install_element(BGP_FLOWSPECV6_NODE, | |
15865 | &neighbor_soft_reconfiguration_cmd); | |
15866 | install_element(BGP_FLOWSPECV6_NODE, | |
15867 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
15868 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
15869 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 15870 | |
15871 | /* "neighbor attribute-unchanged" commands. */ | |
15872 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
15873 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
15874 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
15875 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15876 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
15877 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15878 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
15879 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15880 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
15881 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15882 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
15883 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
15884 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
15885 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
15886 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
15887 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
15888 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
15889 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
15890 | ||
15891 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
15892 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
15893 | ||
15894 | /* "nexthop-local unchanged" commands */ | |
15895 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
15896 | install_element(BGP_IPV6_NODE, | |
15897 | &no_neighbor_nexthop_local_unchanged_cmd); | |
15898 | ||
15899 | /* "neighbor next-hop-self" commands. */ | |
15900 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
15901 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
15902 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
15903 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15904 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
15905 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
15906 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
15907 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
15908 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
15909 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
15910 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
15911 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
15912 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
15913 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
15914 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
15915 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
15916 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
15917 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
15918 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
15919 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 15920 | |
15921 | /* "neighbor next-hop-self force" commands. */ | |
15922 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
15923 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
15924 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15925 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15926 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
15927 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15928 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15929 | install_element(BGP_IPV4_NODE, | |
15930 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15931 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); |
15932 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15933 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15934 | install_element(BGP_IPV4M_NODE, | |
15935 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15936 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); |
15937 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15938 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15939 | install_element(BGP_IPV4L_NODE, | |
15940 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15941 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); |
15942 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15943 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15944 | install_element(BGP_IPV6_NODE, | |
15945 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15946 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); |
15947 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15948 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15949 | install_element(BGP_IPV6M_NODE, | |
15950 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15951 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); |
15952 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15953 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15954 | install_element(BGP_IPV6L_NODE, | |
15955 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15956 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); |
15957 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15958 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15959 | install_element(BGP_VPNV4_NODE, | |
15960 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15961 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
15962 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
2d94b6d1 DA |
15963 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
15964 | install_element(BGP_VPNV6_NODE, | |
15965 | &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 15966 | |
15967 | /* "neighbor as-override" commands. */ | |
15968 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
15969 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
15970 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
15971 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
15972 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
15973 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
15974 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
15975 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
15976 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
15977 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
15978 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
15979 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
15980 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
15981 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
15982 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
15983 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
15984 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
15985 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
15986 | ||
15987 | /* "neighbor remove-private-AS" commands. */ | |
15988 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
15989 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
15990 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
15991 | install_element(BGP_NODE, | |
15992 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
15993 | install_element(BGP_NODE, | |
15994 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
15995 | install_element(BGP_NODE, | |
15996 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
15997 | install_element(BGP_NODE, | |
15998 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
15999 | install_element( | |
16000 | BGP_NODE, | |
16001 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
16002 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
16003 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16004 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16005 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16006 | install_element(BGP_IPV4_NODE, | |
16007 | &neighbor_remove_private_as_replace_as_cmd); | |
16008 | install_element(BGP_IPV4_NODE, | |
16009 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16010 | install_element(BGP_IPV4_NODE, | |
16011 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16012 | install_element(BGP_IPV4_NODE, | |
16013 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16014 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
16015 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
16016 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
16017 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16018 | install_element(BGP_IPV4M_NODE, | |
16019 | &neighbor_remove_private_as_replace_as_cmd); | |
16020 | install_element(BGP_IPV4M_NODE, | |
16021 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16022 | install_element(BGP_IPV4M_NODE, | |
16023 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16024 | install_element(BGP_IPV4M_NODE, | |
16025 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16026 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
16027 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
16028 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
16029 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16030 | install_element(BGP_IPV4L_NODE, | |
16031 | &neighbor_remove_private_as_replace_as_cmd); | |
16032 | install_element(BGP_IPV4L_NODE, | |
16033 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16034 | install_element(BGP_IPV4L_NODE, | |
16035 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16036 | install_element(BGP_IPV4L_NODE, | |
16037 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16038 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
16039 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16040 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16041 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16042 | install_element(BGP_IPV6_NODE, | |
16043 | &neighbor_remove_private_as_replace_as_cmd); | |
16044 | install_element(BGP_IPV6_NODE, | |
16045 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16046 | install_element(BGP_IPV6_NODE, | |
16047 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16048 | install_element(BGP_IPV6_NODE, | |
16049 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16050 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
16051 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
16052 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
16053 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16054 | install_element(BGP_IPV6M_NODE, | |
16055 | &neighbor_remove_private_as_replace_as_cmd); | |
16056 | install_element(BGP_IPV6M_NODE, | |
16057 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16058 | install_element(BGP_IPV6M_NODE, | |
16059 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16060 | install_element(BGP_IPV6M_NODE, | |
16061 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16062 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
16063 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
16064 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
16065 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16066 | install_element(BGP_IPV6L_NODE, | |
16067 | &neighbor_remove_private_as_replace_as_cmd); | |
16068 | install_element(BGP_IPV6L_NODE, | |
16069 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16070 | install_element(BGP_IPV6L_NODE, | |
16071 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16072 | install_element(BGP_IPV6L_NODE, | |
16073 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16074 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
16075 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
16076 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
16077 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16078 | install_element(BGP_VPNV4_NODE, | |
16079 | &neighbor_remove_private_as_replace_as_cmd); | |
16080 | install_element(BGP_VPNV4_NODE, | |
16081 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16082 | install_element(BGP_VPNV4_NODE, | |
16083 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16084 | install_element(BGP_VPNV4_NODE, | |
16085 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16086 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
16087 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
16088 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
16089 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
16090 | install_element(BGP_VPNV6_NODE, | |
16091 | &neighbor_remove_private_as_replace_as_cmd); | |
16092 | install_element(BGP_VPNV6_NODE, | |
16093 | &no_neighbor_remove_private_as_replace_as_cmd); | |
16094 | install_element(BGP_VPNV6_NODE, | |
16095 | &neighbor_remove_private_as_all_replace_as_cmd); | |
16096 | install_element(BGP_VPNV6_NODE, | |
16097 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
16098 | ||
16099 | /* "neighbor send-community" commands.*/ | |
16100 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
16101 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
16102 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
16103 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
16104 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
16105 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
16106 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
16107 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
16108 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
16109 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
16110 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
16111 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
16112 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
16113 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
16114 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
16115 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
16116 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
16117 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
16118 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
16119 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
16120 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
16121 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
16122 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
16123 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
16124 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
16125 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
16126 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
16127 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
16128 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
16129 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
16130 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
16131 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
16132 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
16133 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
16134 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
16135 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
16136 | ||
16137 | /* "neighbor route-reflector" commands.*/ | |
16138 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
16139 | install_element(BGP_NODE, | |
16140 | &no_neighbor_route_reflector_client_hidden_cmd); | |
16141 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
16142 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
16143 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
16144 | install_element(BGP_IPV4M_NODE, | |
16145 | &no_neighbor_route_reflector_client_cmd); | |
16146 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
16147 | install_element(BGP_IPV4L_NODE, | |
16148 | &no_neighbor_route_reflector_client_cmd); | |
16149 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
16150 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
16151 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
16152 | install_element(BGP_IPV6M_NODE, | |
16153 | &no_neighbor_route_reflector_client_cmd); | |
16154 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
16155 | install_element(BGP_IPV6L_NODE, | |
16156 | &no_neighbor_route_reflector_client_cmd); | |
16157 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
16158 | install_element(BGP_VPNV4_NODE, | |
16159 | &no_neighbor_route_reflector_client_cmd); | |
16160 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
16161 | install_element(BGP_VPNV6_NODE, | |
16162 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 16163 | install_element(BGP_FLOWSPECV4_NODE, |
16164 | &neighbor_route_reflector_client_cmd); | |
16165 | install_element(BGP_FLOWSPECV4_NODE, | |
16166 | &no_neighbor_route_reflector_client_cmd); | |
16167 | install_element(BGP_FLOWSPECV6_NODE, | |
16168 | &neighbor_route_reflector_client_cmd); | |
16169 | install_element(BGP_FLOWSPECV6_NODE, | |
16170 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 16171 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
16172 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
16173 | ||
16174 | /* "neighbor route-server" commands.*/ | |
16175 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
16176 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
16177 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
16178 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
16179 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
16180 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
16181 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
16182 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
16183 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
16184 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
16185 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
16186 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
16187 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
16188 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
16189 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
16190 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
16191 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
16192 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
16193 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
16194 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 16195 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
16196 | install_element(BGP_FLOWSPECV4_NODE, | |
16197 | &no_neighbor_route_server_client_cmd); | |
16198 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
16199 | install_element(BGP_FLOWSPECV6_NODE, | |
16200 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 16201 | |
16202 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
16203 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
16204 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
16205 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16206 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16207 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16208 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16209 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16210 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16211 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16212 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16213 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16214 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16215 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16216 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16217 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16218 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16219 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
16220 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
16221 | ||
16222 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
16223 | install_element(BGP_NODE, | |
16224 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16225 | install_element(BGP_NODE, | |
16226 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
16227 | install_element(BGP_IPV4_NODE, | |
16228 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16229 | install_element(BGP_IPV4_NODE, | |
16230 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16231 | install_element(BGP_IPV4M_NODE, | |
16232 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16233 | install_element(BGP_IPV4M_NODE, | |
16234 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16235 | install_element(BGP_IPV4L_NODE, | |
16236 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16237 | install_element(BGP_IPV4L_NODE, | |
16238 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16239 | install_element(BGP_IPV6_NODE, | |
16240 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16241 | install_element(BGP_IPV6_NODE, | |
16242 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16243 | install_element(BGP_IPV6M_NODE, | |
16244 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16245 | install_element(BGP_IPV6M_NODE, | |
16246 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16247 | install_element(BGP_IPV6L_NODE, | |
16248 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16249 | install_element(BGP_IPV6L_NODE, | |
16250 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16251 | install_element(BGP_VPNV4_NODE, | |
16252 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16253 | install_element(BGP_VPNV4_NODE, | |
16254 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16255 | install_element(BGP_VPNV6_NODE, | |
16256 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
16257 | install_element(BGP_VPNV6_NODE, | |
16258 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
16259 | ||
2b31007c RZ |
16260 | /* "neighbor sender-as-path-loop-detection" commands. */ |
16261 | install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd); | |
16262 | install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd); | |
16263 | ||
d62a17ae | 16264 | /* "neighbor passive" commands. */ |
16265 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
16266 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
16267 | ||
16268 | ||
16269 | /* "neighbor shutdown" commands. */ | |
16270 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
16271 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
16272 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
16273 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
16274 | ||
16275 | /* "neighbor capability extended-nexthop" commands.*/ | |
16276 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
16277 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
16278 | ||
16279 | /* "neighbor capability orf prefix-list" commands.*/ | |
16280 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
16281 | install_element(BGP_NODE, | |
16282 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
16283 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
16284 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16285 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16286 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16287 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16288 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16289 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
16290 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16291 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
16292 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16293 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
16294 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
16295 | ||
16296 | /* "neighbor capability dynamic" commands.*/ | |
16297 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
16298 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
16299 | ||
16300 | /* "neighbor dont-capability-negotiate" commands. */ | |
16301 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
16302 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
16303 | ||
16304 | /* "neighbor ebgp-multihop" commands. */ | |
16305 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
16306 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
16307 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
16308 | ||
16309 | /* "neighbor disable-connected-check" commands. */ | |
16310 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
16311 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
16312 | ||
47cbc09b PM |
16313 | /* "neighbor enforce-first-as" commands. */ |
16314 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
16315 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
16316 | ||
d62a17ae | 16317 | /* "neighbor description" commands. */ |
16318 | install_element(BGP_NODE, &neighbor_description_cmd); | |
16319 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 16320 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 16321 | |
16322 | /* "neighbor update-source" commands. "*/ | |
16323 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
16324 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
16325 | ||
16326 | /* "neighbor default-originate" commands. */ | |
16327 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
16328 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
16329 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
16330 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
16331 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
16332 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
16333 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
16334 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
16335 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
16336 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
16337 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
16338 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
16339 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
16340 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
16341 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
16342 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
16343 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
16344 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
16345 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
16346 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
16347 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
16348 | ||
16349 | /* "neighbor port" commands. */ | |
16350 | install_element(BGP_NODE, &neighbor_port_cmd); | |
16351 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
16352 | ||
16353 | /* "neighbor weight" commands. */ | |
16354 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
16355 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
16356 | ||
16357 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
16358 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
16359 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
16360 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
16361 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
16362 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
16363 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
16364 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
16365 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
16366 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
16367 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
16368 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
16369 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
16370 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
16371 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
16372 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
16373 | ||
16374 | /* "neighbor override-capability" commands. */ | |
16375 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
16376 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
16377 | ||
16378 | /* "neighbor strict-capability-match" commands. */ | |
16379 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
16380 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
16381 | ||
16382 | /* "neighbor timers" commands. */ | |
16383 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
16384 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
16385 | ||
16386 | /* "neighbor timers connect" commands. */ | |
16387 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
16388 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
16389 | ||
16390 | /* "neighbor advertisement-interval" commands. */ | |
16391 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
16392 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
16393 | ||
16394 | /* "neighbor interface" commands. */ | |
16395 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
16396 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
16397 | ||
16398 | /* "neighbor distribute" commands. */ | |
16399 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
16400 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
16401 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
16402 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
16403 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
16404 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
16405 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
16406 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
16407 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
16408 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
16409 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
16410 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
16411 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
16412 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
16413 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
16414 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
16415 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
16416 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
16417 | ||
16418 | /* "neighbor prefix-list" commands. */ | |
16419 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
16420 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
16421 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
16422 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
16423 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
16424 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
16425 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
16426 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
16427 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
16428 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
16429 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
16430 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
16431 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
16432 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
16433 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
16434 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
16435 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
16436 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 16437 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
16438 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
16439 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
16440 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 16441 | |
16442 | /* "neighbor filter-list" commands. */ | |
16443 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
16444 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
16445 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
16446 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
16447 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
16448 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
16449 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
16450 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
16451 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
16452 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
16453 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
16454 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
16455 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
16456 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
16457 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
16458 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
16459 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
16460 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 16461 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
16462 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
16463 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
16464 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 16465 | |
16466 | /* "neighbor route-map" commands. */ | |
16467 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
16468 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
16469 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
16470 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
16471 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
16472 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
16473 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
16474 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
16475 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
16476 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
16477 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
16478 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
16479 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
16480 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
16481 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
16482 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
16483 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
16484 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 16485 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
16486 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
16487 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
16488 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
16489 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
16490 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 16491 | |
16492 | /* "neighbor unsuppress-map" commands. */ | |
16493 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
16494 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
16495 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
16496 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16497 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
16498 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16499 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
16500 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16501 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
16502 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16503 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
16504 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
16505 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
16506 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
16507 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
16508 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
16509 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
16510 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
16511 | ||
fde246e8 DA |
16512 | /* neighbor maximum-prefix-out commands. */ |
16513 | install_element(BGP_NODE, &neighbor_maximum_prefix_out_cmd); | |
16514 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16515 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16516 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16517 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16518 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16519 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16520 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16521 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16522 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16523 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_out_cmd); | |
16524 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16525 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_out_cmd); | |
16526 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16527 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_out_cmd); | |
16528 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16529 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_out_cmd); | |
16530 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_out_cmd); | |
16531 | ||
d62a17ae | 16532 | /* "neighbor maximum-prefix" commands. */ |
16533 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
16534 | install_element(BGP_NODE, | |
16535 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
16536 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
16537 | install_element(BGP_NODE, | |
16538 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
16539 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
16540 | install_element(BGP_NODE, | |
16541 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
16542 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
16543 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
16544 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16545 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16546 | install_element(BGP_IPV4_NODE, | |
16547 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16548 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16549 | install_element(BGP_IPV4_NODE, | |
16550 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16551 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16552 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
16553 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16554 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16555 | install_element(BGP_IPV4M_NODE, | |
16556 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16557 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16558 | install_element(BGP_IPV4M_NODE, | |
16559 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16560 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16561 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
16562 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16563 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16564 | install_element(BGP_IPV4L_NODE, | |
16565 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16566 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16567 | install_element(BGP_IPV4L_NODE, | |
16568 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16569 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16570 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
16571 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16572 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16573 | install_element(BGP_IPV6_NODE, | |
16574 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16575 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16576 | install_element(BGP_IPV6_NODE, | |
16577 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16578 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16579 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
16580 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16581 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16582 | install_element(BGP_IPV6M_NODE, | |
16583 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16584 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16585 | install_element(BGP_IPV6M_NODE, | |
16586 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16587 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
16588 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
16589 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16590 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16591 | install_element(BGP_IPV6L_NODE, | |
16592 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16593 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16594 | install_element(BGP_IPV6L_NODE, | |
16595 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16596 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
16597 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
16598 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16599 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16600 | install_element(BGP_VPNV4_NODE, | |
16601 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16602 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16603 | install_element(BGP_VPNV4_NODE, | |
16604 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16605 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
16606 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
16607 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
16608 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
16609 | install_element(BGP_VPNV6_NODE, | |
16610 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
16611 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
16612 | install_element(BGP_VPNV6_NODE, | |
16613 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
16614 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
16615 | ||
16616 | /* "neighbor allowas-in" */ | |
16617 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
16618 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
16619 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
16620 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
16621 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
16622 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
16623 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
16624 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
16625 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
16626 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
16627 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
16628 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
16629 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
16630 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
16631 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
16632 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
16633 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
16634 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
16635 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
16636 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
16637 | ||
16638 | /* address-family commands. */ | |
16639 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
16640 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 16641 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 16642 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
16643 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 16644 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 16645 | |
d62a17ae | 16646 | install_element(BGP_NODE, &address_family_evpn_cmd); |
16647 | ||
16648 | /* "exit-address-family" command. */ | |
16649 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
16650 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
16651 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
16652 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
16653 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
16654 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
16655 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
16656 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 16657 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
16658 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 16659 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
16660 | ||
16661 | /* "clear ip bgp commands" */ | |
16662 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
16663 | ||
16664 | /* clear ip bgp prefix */ | |
16665 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
16666 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
16667 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
16668 | ||
16669 | /* "show [ip] bgp summary" commands. */ | |
16670 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 16671 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 16672 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 16673 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 16674 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
16675 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 16676 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
16677 | ||
16678 | /* "show [ip] bgp neighbors" commands. */ | |
16679 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
16680 | ||
36235319 | 16681 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_graceful_restart_cmd); |
2986cac2 | 16682 | |
d62a17ae | 16683 | /* "show [ip] bgp peer-group" commands. */ |
16684 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
16685 | ||
16686 | /* "show [ip] bgp paths" commands. */ | |
16687 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
16688 | ||
16689 | /* "show [ip] bgp community" commands. */ | |
16690 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
16691 | ||
16692 | /* "show ip bgp large-community" commands. */ | |
16693 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
16694 | /* "show [ip] bgp attribute-info" commands. */ | |
16695 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 16696 | /* "show [ip] bgp route-leak" command */ |
16697 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 16698 | |
16699 | /* "redistribute" commands. */ | |
16700 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
16701 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
16702 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
16703 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
16704 | install_element(BGP_NODE, | |
16705 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
16706 | install_element(BGP_NODE, | |
16707 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
16708 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16709 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
16710 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
16711 | install_element(BGP_NODE, | |
16712 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
16713 | install_element(BGP_NODE, | |
16714 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
16715 | install_element(BGP_NODE, | |
16716 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
16717 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
16718 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
16719 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
16720 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
16721 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
16722 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
16723 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
16724 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
16725 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
16726 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
16727 | install_element(BGP_IPV4_NODE, | |
16728 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
16729 | install_element(BGP_IPV4_NODE, | |
16730 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
16731 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
16732 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
16733 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
16734 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
16735 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
16736 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
16737 | ||
b9c7bc5a PZ |
16738 | /* import|export vpn [route-map WORD] */ |
16739 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
16740 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 16741 | |
12a844a5 DS |
16742 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
16743 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
16744 | ||
d62a17ae | 16745 | /* ttl_security commands */ |
16746 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
16747 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
16748 | ||
16749 | /* "show [ip] bgp memory" commands. */ | |
16750 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
16751 | ||
acf71666 MK |
16752 | /* "show bgp martian next-hop" */ |
16753 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
16754 | ||
48ecf8f5 DS |
16755 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
16756 | ||
d62a17ae | 16757 | /* "show [ip] bgp views" commands. */ |
16758 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
16759 | ||
16760 | /* "show [ip] bgp vrfs" commands. */ | |
16761 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
16762 | ||
16763 | /* Community-list. */ | |
16764 | community_list_vty(); | |
ddb5b488 PZ |
16765 | |
16766 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
16767 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
16768 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
16769 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
16770 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
16771 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
16772 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
16773 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
16774 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
16775 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
16776 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16777 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
16778 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 16779 | |
301ad80a PG |
16780 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
16781 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
16782 | ||
b9c7bc5a PZ |
16783 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
16784 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
16785 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
16786 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
b9c7bc5a PZ |
16787 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); |
16788 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
16789 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
16790 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
16791 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
16792 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 16793 | } |
6b0655a2 | 16794 | |
718e3744 | 16795 | #include "memory.h" |
16796 | #include "bgp_regex.h" | |
16797 | #include "bgp_clist.h" | |
16798 | #include "bgp_ecommunity.h" | |
16799 | ||
16800 | /* VTY functions. */ | |
16801 | ||
16802 | /* Direction value to string conversion. */ | |
d62a17ae | 16803 | static const char *community_direct_str(int direct) |
16804 | { | |
16805 | switch (direct) { | |
16806 | case COMMUNITY_DENY: | |
16807 | return "deny"; | |
16808 | case COMMUNITY_PERMIT: | |
16809 | return "permit"; | |
16810 | default: | |
16811 | return "unknown"; | |
16812 | } | |
718e3744 | 16813 | } |
16814 | ||
16815 | /* Display error string. */ | |
d62a17ae | 16816 | static void community_list_perror(struct vty *vty, int ret) |
16817 | { | |
16818 | switch (ret) { | |
16819 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
16820 | vty_out(vty, "%% Can't find community-list\n"); | |
16821 | break; | |
16822 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
16823 | vty_out(vty, "%% Malformed community-list value\n"); | |
16824 | break; | |
16825 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
16826 | vty_out(vty, | |
16827 | "%% Community name conflict, previously defined as standard community\n"); | |
16828 | break; | |
16829 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
16830 | vty_out(vty, | |
16831 | "%% Community name conflict, previously defined as expanded community\n"); | |
16832 | break; | |
16833 | } | |
718e3744 | 16834 | } |
16835 | ||
5bf15956 DW |
16836 | /* "community-list" keyword help string. */ |
16837 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
16838 | ||
7336e101 SP |
16839 | /*community-list standard */ |
16840 | DEFUN (community_list_standard, | |
16841 | bgp_community_list_standard_cmd, | |
2f8cc0e5 | 16842 | "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 16843 | BGP_STR |
718e3744 | 16844 | COMMUNITY_LIST_STR |
16845 | "Community list number (standard)\n" | |
5bf15956 | 16846 | "Add an standard community-list entry\n" |
718e3744 | 16847 | "Community list name\n" |
2f8cc0e5 DA |
16848 | "Sequence number of an entry\n" |
16849 | "Sequence number\n" | |
718e3744 | 16850 | "Specify community to reject\n" |
16851 | "Specify community to accept\n" | |
16852 | COMMUNITY_VAL_STR) | |
16853 | { | |
d62a17ae | 16854 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16855 | char *seq = NULL; |
d62a17ae | 16856 | int direct = 0; |
16857 | int style = COMMUNITY_LIST_STANDARD; | |
d62a17ae | 16858 | int idx = 0; |
7336e101 | 16859 | |
2f8cc0e5 DA |
16860 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16861 | if (idx) | |
16862 | seq = argv[idx]->arg; | |
16863 | ||
16864 | idx = 0; | |
d62a17ae | 16865 | argv_find(argv, argc, "(1-99)", &idx); |
16866 | argv_find(argv, argc, "WORD", &idx); | |
16867 | cl_name_or_number = argv[idx]->arg; | |
16868 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16869 | : COMMUNITY_DENY; | |
16870 | argv_find(argv, argc, "AA:NN", &idx); | |
16871 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16872 | |
2f8cc0e5 DA |
16873 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16874 | direct, style); | |
42f914d4 | 16875 | |
d62a17ae | 16876 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16877 | |
d62a17ae | 16878 | if (ret < 0) { |
16879 | /* Display error string. */ | |
16880 | community_list_perror(vty, ret); | |
16881 | return CMD_WARNING_CONFIG_FAILED; | |
16882 | } | |
42f914d4 | 16883 | |
d62a17ae | 16884 | return CMD_SUCCESS; |
718e3744 | 16885 | } |
16886 | ||
7336e101 SP |
16887 | DEFUN (no_community_list_standard_all, |
16888 | no_bgp_community_list_standard_all_cmd, | |
2f8cc0e5 | 16889 | "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16890 | NO_STR |
16891 | BGP_STR | |
16892 | COMMUNITY_LIST_STR | |
16893 | "Community list number (standard)\n" | |
16894 | "Add an standard community-list entry\n" | |
16895 | "Community list name\n" | |
2f8cc0e5 DA |
16896 | "Sequence number of an entry\n" |
16897 | "Sequence number\n" | |
7336e101 SP |
16898 | "Specify community to reject\n" |
16899 | "Specify community to accept\n" | |
16900 | COMMUNITY_VAL_STR) | |
718e3744 | 16901 | { |
d62a17ae | 16902 | char *cl_name_or_number = NULL; |
174b5cb9 | 16903 | char *str = NULL; |
d62a17ae | 16904 | int direct = 0; |
16905 | int style = COMMUNITY_LIST_STANDARD; | |
2f8cc0e5 | 16906 | char *seq = NULL; |
d62a17ae | 16907 | int idx = 0; |
7336e101 | 16908 | |
2f8cc0e5 DA |
16909 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16910 | if (idx) | |
16911 | seq = argv[idx]->arg; | |
16912 | ||
16913 | idx = 0; | |
174b5cb9 DA |
16914 | argv_find(argv, argc, "permit", &idx); |
16915 | argv_find(argv, argc, "deny", &idx); | |
16916 | ||
16917 | if (idx) { | |
16918 | direct = argv_find(argv, argc, "permit", &idx) | |
16919 | ? COMMUNITY_PERMIT | |
16920 | : COMMUNITY_DENY; | |
16921 | ||
16922 | idx = 0; | |
16923 | argv_find(argv, argc, "AA:NN", &idx); | |
16924 | str = argv_concat(argv, argc, idx); | |
16925 | } | |
16926 | ||
16927 | idx = 0; | |
d62a17ae | 16928 | argv_find(argv, argc, "(1-99)", &idx); |
16929 | argv_find(argv, argc, "WORD", &idx); | |
16930 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 16931 | |
2f8cc0e5 | 16932 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 16933 | direct, style); |
42f914d4 | 16934 | |
d62a17ae | 16935 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 16936 | |
d62a17ae | 16937 | if (ret < 0) { |
16938 | community_list_perror(vty, ret); | |
16939 | return CMD_WARNING_CONFIG_FAILED; | |
16940 | } | |
42f914d4 | 16941 | |
d62a17ae | 16942 | return CMD_SUCCESS; |
718e3744 | 16943 | } |
7336e101 | 16944 | |
174b5cb9 DA |
16945 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
16946 | "no bgp community-list <(1-99)|standard WORD>", | |
16947 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
16948 | "Community list number (standard)\n" | |
16949 | "Add an standard community-list entry\n" | |
16950 | "Community list name\n") | |
16951 | ||
7336e101 SP |
16952 | /*community-list expanded */ |
16953 | DEFUN (community_list_expanded_all, | |
16954 | bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 16955 | "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
16956 | BGP_STR |
16957 | COMMUNITY_LIST_STR | |
718e3744 | 16958 | "Community list number (expanded)\n" |
5bf15956 | 16959 | "Add an expanded community-list entry\n" |
718e3744 | 16960 | "Community list name\n" |
2f8cc0e5 DA |
16961 | "Sequence number of an entry\n" |
16962 | "Sequence number\n" | |
718e3744 | 16963 | "Specify community to reject\n" |
16964 | "Specify community to accept\n" | |
16965 | COMMUNITY_VAL_STR) | |
16966 | { | |
d62a17ae | 16967 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 16968 | char *seq = NULL; |
d62a17ae | 16969 | int direct = 0; |
16970 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 16971 | int idx = 0; |
7b9a4750 | 16972 | |
2f8cc0e5 DA |
16973 | argv_find(argv, argc, "(1-4294967295)", &idx); |
16974 | if (idx) | |
16975 | seq = argv[idx]->arg; | |
16976 | ||
16977 | idx = 0; | |
16978 | ||
d62a17ae | 16979 | argv_find(argv, argc, "(100-500)", &idx); |
16980 | argv_find(argv, argc, "WORD", &idx); | |
16981 | cl_name_or_number = argv[idx]->arg; | |
16982 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
16983 | : COMMUNITY_DENY; | |
16984 | argv_find(argv, argc, "AA:NN", &idx); | |
16985 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 16986 | |
2f8cc0e5 DA |
16987 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, seq, |
16988 | direct, style); | |
42f914d4 | 16989 | |
d62a17ae | 16990 | XFREE(MTYPE_TMP, str); |
42f914d4 | 16991 | |
d62a17ae | 16992 | if (ret < 0) { |
16993 | /* Display error string. */ | |
16994 | community_list_perror(vty, ret); | |
16995 | return CMD_WARNING_CONFIG_FAILED; | |
16996 | } | |
42f914d4 | 16997 | |
d62a17ae | 16998 | return CMD_SUCCESS; |
718e3744 | 16999 | } |
17000 | ||
7336e101 SP |
17001 | DEFUN (no_community_list_expanded_all, |
17002 | no_bgp_community_list_expanded_all_cmd, | |
2f8cc0e5 | 17003 | "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17004 | NO_STR |
17005 | BGP_STR | |
17006 | COMMUNITY_LIST_STR | |
17007 | "Community list number (expanded)\n" | |
17008 | "Add an expanded community-list entry\n" | |
17009 | "Community list name\n" | |
2f8cc0e5 DA |
17010 | "Sequence number of an entry\n" |
17011 | "Sequence number\n" | |
7336e101 SP |
17012 | "Specify community to reject\n" |
17013 | "Specify community to accept\n" | |
17014 | COMMUNITY_VAL_STR) | |
718e3744 | 17015 | { |
d62a17ae | 17016 | char *cl_name_or_number = NULL; |
2f8cc0e5 | 17017 | char *seq = NULL; |
174b5cb9 | 17018 | char *str = NULL; |
d62a17ae | 17019 | int direct = 0; |
17020 | int style = COMMUNITY_LIST_EXPANDED; | |
d62a17ae | 17021 | int idx = 0; |
174b5cb9 | 17022 | |
2f8cc0e5 DA |
17023 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17024 | if (idx) | |
17025 | seq = argv[idx]->arg; | |
17026 | ||
17027 | idx = 0; | |
174b5cb9 DA |
17028 | argv_find(argv, argc, "permit", &idx); |
17029 | argv_find(argv, argc, "deny", &idx); | |
17030 | ||
17031 | if (idx) { | |
17032 | direct = argv_find(argv, argc, "permit", &idx) | |
17033 | ? COMMUNITY_PERMIT | |
17034 | : COMMUNITY_DENY; | |
17035 | ||
17036 | idx = 0; | |
17037 | argv_find(argv, argc, "AA:NN", &idx); | |
17038 | str = argv_concat(argv, argc, idx); | |
7336e101 | 17039 | } |
174b5cb9 DA |
17040 | |
17041 | idx = 0; | |
d62a17ae | 17042 | argv_find(argv, argc, "(100-500)", &idx); |
17043 | argv_find(argv, argc, "WORD", &idx); | |
17044 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 17045 | |
2f8cc0e5 | 17046 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, seq, |
7298a8e1 | 17047 | direct, style); |
42f914d4 | 17048 | |
d62a17ae | 17049 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 17050 | |
d62a17ae | 17051 | if (ret < 0) { |
17052 | community_list_perror(vty, ret); | |
17053 | return CMD_WARNING_CONFIG_FAILED; | |
17054 | } | |
42f914d4 | 17055 | |
d62a17ae | 17056 | return CMD_SUCCESS; |
718e3744 | 17057 | } |
17058 | ||
174b5cb9 DA |
17059 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
17060 | "no bgp community-list <(100-500)|expanded WORD>", | |
17061 | NO_STR IP_STR COMMUNITY_LIST_STR | |
17062 | "Community list number (expanded)\n" | |
17063 | "Add an expanded community-list entry\n" | |
17064 | "Community list name\n") | |
17065 | ||
8d9b8ed9 PM |
17066 | /* Return configuration string of community-list entry. */ |
17067 | static const char *community_list_config_str(struct community_entry *entry) | |
17068 | { | |
17069 | const char *str; | |
17070 | ||
17071 | if (entry->any) | |
17072 | str = ""; | |
17073 | else { | |
17074 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
17075 | str = community_str(entry->u.com, false); | |
17076 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
17077 | str = lcommunity_str(entry->u.lcom, false); | |
17078 | else | |
17079 | str = entry->config; | |
17080 | } | |
17081 | return str; | |
17082 | } | |
17083 | ||
d62a17ae | 17084 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17085 | { |
d62a17ae | 17086 | struct community_entry *entry; |
718e3744 | 17087 | |
d62a17ae | 17088 | for (entry = list->head; entry; entry = entry->next) { |
17089 | if (entry == list->head) { | |
17090 | if (all_digit(list->name)) | |
17091 | vty_out(vty, "Community %s list %s\n", | |
17092 | entry->style == COMMUNITY_LIST_STANDARD | |
17093 | ? "standard" | |
17094 | : "(expanded) access", | |
17095 | list->name); | |
17096 | else | |
17097 | vty_out(vty, "Named Community %s list %s\n", | |
17098 | entry->style == COMMUNITY_LIST_STANDARD | |
17099 | ? "standard" | |
17100 | : "expanded", | |
17101 | list->name); | |
17102 | } | |
17103 | if (entry->any) | |
17104 | vty_out(vty, " %s\n", | |
17105 | community_direct_str(entry->direct)); | |
17106 | else | |
17107 | vty_out(vty, " %s %s\n", | |
17108 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17109 | community_list_config_str(entry)); |
d62a17ae | 17110 | } |
718e3744 | 17111 | } |
17112 | ||
7336e101 SP |
17113 | DEFUN (show_community_list, |
17114 | show_bgp_community_list_cmd, | |
17115 | "show bgp community-list", | |
718e3744 | 17116 | SHOW_STR |
7336e101 | 17117 | BGP_STR |
718e3744 | 17118 | "List community-list\n") |
17119 | { | |
d62a17ae | 17120 | struct community_list *list; |
17121 | struct community_list_master *cm; | |
718e3744 | 17122 | |
d62a17ae | 17123 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
17124 | if (!cm) | |
17125 | return CMD_SUCCESS; | |
718e3744 | 17126 | |
d62a17ae | 17127 | for (list = cm->num.head; list; list = list->next) |
17128 | community_list_show(vty, list); | |
718e3744 | 17129 | |
d62a17ae | 17130 | for (list = cm->str.head; list; list = list->next) |
17131 | community_list_show(vty, list); | |
718e3744 | 17132 | |
d62a17ae | 17133 | return CMD_SUCCESS; |
718e3744 | 17134 | } |
17135 | ||
7336e101 SP |
17136 | DEFUN (show_community_list_arg, |
17137 | show_bgp_community_list_arg_cmd, | |
960b69b9 | 17138 | "show bgp community-list <(1-500)|WORD> detail", |
7336e101 SP |
17139 | SHOW_STR |
17140 | BGP_STR | |
718e3744 | 17141 | "List community-list\n" |
17142 | "Community-list number\n" | |
960b69b9 | 17143 | "Community-list name\n" |
17144 | "Detailed information on community-list\n") | |
718e3744 | 17145 | { |
d62a17ae | 17146 | int idx_comm_list = 3; |
17147 | struct community_list *list; | |
718e3744 | 17148 | |
e237b0d2 | 17149 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17150 | COMMUNITY_LIST_MASTER); |
17151 | if (!list) { | |
17152 | vty_out(vty, "%% Can't find community-list\n"); | |
17153 | return CMD_WARNING; | |
17154 | } | |
718e3744 | 17155 | |
d62a17ae | 17156 | community_list_show(vty, list); |
718e3744 | 17157 | |
d62a17ae | 17158 | return CMD_SUCCESS; |
718e3744 | 17159 | } |
6b0655a2 | 17160 | |
57d187bc JS |
17161 | /* |
17162 | * Large Community code. | |
17163 | */ | |
d62a17ae | 17164 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
17165 | struct cmd_token **argv, int style, | |
17166 | int reject_all_digit_name) | |
17167 | { | |
17168 | int ret; | |
17169 | int direct; | |
17170 | char *str; | |
17171 | int idx = 0; | |
17172 | char *cl_name; | |
2f8cc0e5 DA |
17173 | char *seq = NULL; |
17174 | ||
17175 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17176 | if (idx) | |
17177 | seq = argv[idx]->arg; | |
d62a17ae | 17178 | |
2f8cc0e5 | 17179 | idx = 0; |
d62a17ae | 17180 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17181 | : COMMUNITY_DENY; | |
17182 | ||
17183 | /* All digit name check. */ | |
17184 | idx = 0; | |
17185 | argv_find(argv, argc, "WORD", &idx); | |
17186 | argv_find(argv, argc, "(1-99)", &idx); | |
17187 | argv_find(argv, argc, "(100-500)", &idx); | |
17188 | cl_name = argv[idx]->arg; | |
17189 | if (reject_all_digit_name && all_digit(cl_name)) { | |
17190 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
17191 | return CMD_WARNING_CONFIG_FAILED; | |
17192 | } | |
17193 | ||
17194 | idx = 0; | |
17195 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
17196 | argv_find(argv, argc, "LINE", &idx); | |
17197 | /* Concat community string argument. */ | |
17198 | if (idx) | |
17199 | str = argv_concat(argv, argc, idx); | |
17200 | else | |
17201 | str = NULL; | |
17202 | ||
2f8cc0e5 | 17203 | ret = lcommunity_list_set(bgp_clist, cl_name, str, seq, direct, style); |
d62a17ae | 17204 | |
17205 | /* Free temporary community list string allocated by | |
17206 | argv_concat(). */ | |
0a22ddfb | 17207 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17208 | |
17209 | if (ret < 0) { | |
17210 | community_list_perror(vty, ret); | |
17211 | return CMD_WARNING_CONFIG_FAILED; | |
17212 | } | |
17213 | return CMD_SUCCESS; | |
17214 | } | |
17215 | ||
17216 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
17217 | struct cmd_token **argv, int style) | |
17218 | { | |
17219 | int ret; | |
17220 | int direct = 0; | |
17221 | char *str = NULL; | |
17222 | int idx = 0; | |
2f8cc0e5 | 17223 | char *seq = NULL; |
d62a17ae | 17224 | |
2f8cc0e5 DA |
17225 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17226 | if (idx) | |
17227 | seq = argv[idx]->arg; | |
d62a17ae | 17228 | |
2f8cc0e5 | 17229 | idx = 0; |
d62a17ae | 17230 | argv_find(argv, argc, "permit", &idx); |
17231 | argv_find(argv, argc, "deny", &idx); | |
17232 | ||
17233 | if (idx) { | |
17234 | /* Check the list direct. */ | |
17235 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
17236 | direct = COMMUNITY_PERMIT; | |
17237 | else | |
17238 | direct = COMMUNITY_DENY; | |
17239 | ||
17240 | idx = 0; | |
17241 | argv_find(argv, argc, "LINE", &idx); | |
17242 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
17243 | /* Concat community string argument. */ | |
17244 | str = argv_concat(argv, argc, idx); | |
17245 | } | |
17246 | ||
17247 | idx = 0; | |
17248 | argv_find(argv, argc, "(1-99)", &idx); | |
17249 | argv_find(argv, argc, "(100-500)", &idx); | |
17250 | argv_find(argv, argc, "WORD", &idx); | |
17251 | ||
17252 | /* Unset community list. */ | |
2f8cc0e5 | 17253 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, seq, direct, |
d62a17ae | 17254 | style); |
17255 | ||
17256 | /* Free temporary community list string allocated by | |
17257 | argv_concat(). */ | |
0a22ddfb | 17258 | XFREE(MTYPE_TMP, str); |
d62a17ae | 17259 | |
17260 | if (ret < 0) { | |
17261 | community_list_perror(vty, ret); | |
17262 | return CMD_WARNING_CONFIG_FAILED; | |
17263 | } | |
17264 | ||
17265 | return CMD_SUCCESS; | |
57d187bc JS |
17266 | } |
17267 | ||
17268 | /* "large-community-list" keyword help string. */ | |
17269 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
17270 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
17271 | ||
7336e101 SP |
17272 | DEFUN (lcommunity_list_standard, |
17273 | bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17274 | "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17275 | BGP_STR |
17276 | LCOMMUNITY_LIST_STR | |
17277 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17278 | "Sequence number of an entry\n" |
17279 | "Sequence number\n" | |
7336e101 SP |
17280 | "Specify large community to reject\n" |
17281 | "Specify large community to accept\n" | |
17282 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17283 | { |
d62a17ae | 17284 | return lcommunity_list_set_vty(vty, argc, argv, |
17285 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
17286 | } |
17287 | ||
7336e101 SP |
17288 | DEFUN (lcommunity_list_expanded, |
17289 | bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17290 | "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17291 | BGP_STR |
17292 | LCOMMUNITY_LIST_STR | |
17293 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17294 | "Sequence number of an entry\n" |
17295 | "Sequence number\n" | |
7336e101 SP |
17296 | "Specify large community to reject\n" |
17297 | "Specify large community to accept\n" | |
17298 | "An ordered list as a regular-expression\n") | |
57d187bc | 17299 | { |
d62a17ae | 17300 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17301 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
17302 | } |
17303 | ||
7336e101 SP |
17304 | DEFUN (lcommunity_list_name_standard, |
17305 | bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17306 | "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...", |
7336e101 SP |
17307 | BGP_STR |
17308 | LCOMMUNITY_LIST_STR | |
17309 | "Specify standard large-community-list\n" | |
17310 | "Large Community list name\n" | |
2f8cc0e5 DA |
17311 | "Sequence number of an entry\n" |
17312 | "Sequence number\n" | |
7336e101 SP |
17313 | "Specify large community to reject\n" |
17314 | "Specify large community to accept\n" | |
17315 | LCOMMUNITY_VAL_STR) | |
52951b63 | 17316 | { |
d62a17ae | 17317 | return lcommunity_list_set_vty(vty, argc, argv, |
17318 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
17319 | } |
17320 | ||
7336e101 SP |
17321 | DEFUN (lcommunity_list_name_expanded, |
17322 | bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17323 | "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17324 | BGP_STR |
17325 | LCOMMUNITY_LIST_STR | |
17326 | "Specify expanded large-community-list\n" | |
17327 | "Large Community list name\n" | |
2f8cc0e5 DA |
17328 | "Sequence number of an entry\n" |
17329 | "Sequence number\n" | |
7336e101 SP |
17330 | "Specify large community to reject\n" |
17331 | "Specify large community to accept\n" | |
17332 | "An ordered list as a regular-expression\n") | |
57d187bc | 17333 | { |
d62a17ae | 17334 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 17335 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
17336 | } |
17337 | ||
4378f57c DA |
17338 | DEFUN (no_lcommunity_list_all, |
17339 | no_bgp_lcommunity_list_all_cmd, | |
7336e101 SP |
17340 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", |
17341 | NO_STR | |
17342 | BGP_STR | |
17343 | LCOMMUNITY_LIST_STR | |
17344 | "Large Community list number (standard)\n" | |
17345 | "Large Community list number (expanded)\n" | |
17346 | "Large Community list name\n") | |
57d187bc | 17347 | { |
7336e101 SP |
17348 | return lcommunity_list_unset_vty(vty, argc, argv, |
17349 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
17350 | } |
17351 | ||
4378f57c DA |
17352 | DEFUN (no_lcommunity_list_name_standard_all, |
17353 | no_bgp_lcommunity_list_name_standard_all_cmd, | |
17354 | "no bgp large-community-list standard WORD", | |
17355 | NO_STR | |
17356 | BGP_STR | |
17357 | LCOMMUNITY_LIST_STR | |
17358 | "Specify standard large-community-list\n" | |
17359 | "Large Community list name\n") | |
17360 | { | |
17361 | return lcommunity_list_unset_vty(vty, argc, argv, | |
17362 | LARGE_COMMUNITY_LIST_STANDARD); | |
17363 | } | |
17364 | ||
7336e101 SP |
17365 | DEFUN (no_lcommunity_list_name_expanded_all, |
17366 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
17367 | "no bgp large-community-list expanded WORD", | |
17368 | NO_STR | |
17369 | BGP_STR | |
17370 | LCOMMUNITY_LIST_STR | |
17371 | "Specify expanded large-community-list\n" | |
17372 | "Large Community list name\n") | |
57d187bc | 17373 | { |
d62a17ae | 17374 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17375 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17376 | } |
17377 | ||
7336e101 SP |
17378 | DEFUN (no_lcommunity_list_standard, |
17379 | no_bgp_lcommunity_list_standard_cmd, | |
2f8cc0e5 | 17380 | "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17381 | NO_STR |
17382 | BGP_STR | |
17383 | LCOMMUNITY_LIST_STR | |
17384 | "Large Community list number (standard)\n" | |
2f8cc0e5 DA |
17385 | "Sequence number of an entry\n" |
17386 | "Sequence number\n" | |
7336e101 SP |
17387 | "Specify large community to reject\n" |
17388 | "Specify large community to accept\n" | |
17389 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17390 | { |
d62a17ae | 17391 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17392 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17393 | } |
17394 | ||
7336e101 SP |
17395 | DEFUN (no_lcommunity_list_expanded, |
17396 | no_bgp_lcommunity_list_expanded_cmd, | |
2f8cc0e5 | 17397 | "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17398 | NO_STR |
17399 | BGP_STR | |
17400 | LCOMMUNITY_LIST_STR | |
17401 | "Large Community list number (expanded)\n" | |
2f8cc0e5 DA |
17402 | "Sequence number of an entry\n" |
17403 | "Sequence number\n" | |
7336e101 SP |
17404 | "Specify large community to reject\n" |
17405 | "Specify large community to accept\n" | |
17406 | "An ordered list as a regular-expression\n") | |
57d187bc | 17407 | { |
d62a17ae | 17408 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17409 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17410 | } |
17411 | ||
7336e101 SP |
17412 | DEFUN (no_lcommunity_list_name_standard, |
17413 | no_bgp_lcommunity_list_name_standard_cmd, | |
2f8cc0e5 | 17414 | "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...", |
7336e101 SP |
17415 | NO_STR |
17416 | BGP_STR | |
17417 | LCOMMUNITY_LIST_STR | |
17418 | "Specify standard large-community-list\n" | |
17419 | "Large Community list name\n" | |
2f8cc0e5 DA |
17420 | "Sequence number of an entry\n" |
17421 | "Sequence number\n" | |
7336e101 SP |
17422 | "Specify large community to reject\n" |
17423 | "Specify large community to accept\n" | |
17424 | LCOMMUNITY_VAL_STR) | |
57d187bc | 17425 | { |
d62a17ae | 17426 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17427 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
17428 | } |
17429 | ||
7336e101 SP |
17430 | DEFUN (no_lcommunity_list_name_expanded, |
17431 | no_bgp_lcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17432 | "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17433 | NO_STR |
17434 | BGP_STR | |
17435 | LCOMMUNITY_LIST_STR | |
17436 | "Specify expanded large-community-list\n" | |
17437 | "Large community list name\n" | |
2f8cc0e5 DA |
17438 | "Sequence number of an entry\n" |
17439 | "Sequence number\n" | |
7336e101 SP |
17440 | "Specify large community to reject\n" |
17441 | "Specify large community to accept\n" | |
17442 | "An ordered list as a regular-expression\n") | |
57d187bc | 17443 | { |
d62a17ae | 17444 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 17445 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
17446 | } |
17447 | ||
d62a17ae | 17448 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) |
17449 | { | |
17450 | struct community_entry *entry; | |
17451 | ||
17452 | for (entry = list->head; entry; entry = entry->next) { | |
17453 | if (entry == list->head) { | |
17454 | if (all_digit(list->name)) | |
17455 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 17456 | entry->style == |
17457 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17458 | ? "standard" |
17459 | : "(expanded) access", | |
17460 | list->name); | |
17461 | else | |
17462 | vty_out(vty, | |
17463 | "Named large community %s list %s\n", | |
169b72c8 | 17464 | entry->style == |
17465 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 17466 | ? "standard" |
17467 | : "expanded", | |
17468 | list->name); | |
17469 | } | |
17470 | if (entry->any) | |
17471 | vty_out(vty, " %s\n", | |
17472 | community_direct_str(entry->direct)); | |
17473 | else | |
17474 | vty_out(vty, " %s %s\n", | |
17475 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17476 | community_list_config_str(entry)); |
d62a17ae | 17477 | } |
57d187bc JS |
17478 | } |
17479 | ||
7336e101 SP |
17480 | DEFUN (show_lcommunity_list, |
17481 | show_bgp_lcommunity_list_cmd, | |
17482 | "show bgp large-community-list", | |
57d187bc | 17483 | SHOW_STR |
7336e101 | 17484 | BGP_STR |
57d187bc JS |
17485 | "List large-community list\n") |
17486 | { | |
d62a17ae | 17487 | struct community_list *list; |
17488 | struct community_list_master *cm; | |
57d187bc | 17489 | |
d62a17ae | 17490 | cm = community_list_master_lookup(bgp_clist, |
17491 | LARGE_COMMUNITY_LIST_MASTER); | |
17492 | if (!cm) | |
17493 | return CMD_SUCCESS; | |
57d187bc | 17494 | |
d62a17ae | 17495 | for (list = cm->num.head; list; list = list->next) |
17496 | lcommunity_list_show(vty, list); | |
57d187bc | 17497 | |
d62a17ae | 17498 | for (list = cm->str.head; list; list = list->next) |
17499 | lcommunity_list_show(vty, list); | |
57d187bc | 17500 | |
d62a17ae | 17501 | return CMD_SUCCESS; |
57d187bc JS |
17502 | } |
17503 | ||
7336e101 SP |
17504 | DEFUN (show_lcommunity_list_arg, |
17505 | show_bgp_lcommunity_list_arg_cmd, | |
960b69b9 | 17506 | "show bgp large-community-list <(1-500)|WORD> detail", |
7336e101 SP |
17507 | SHOW_STR |
17508 | BGP_STR | |
57d187bc | 17509 | "List large-community list\n" |
960b69b9 | 17510 | "Large-community-list number\n" |
17511 | "Large-community-list name\n" | |
17512 | "Detailed information on large-community-list\n") | |
57d187bc | 17513 | { |
d62a17ae | 17514 | struct community_list *list; |
57d187bc | 17515 | |
e237b0d2 | 17516 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 17517 | LARGE_COMMUNITY_LIST_MASTER); |
17518 | if (!list) { | |
960b69b9 | 17519 | vty_out(vty, "%% Can't find large-community-list\n"); |
d62a17ae | 17520 | return CMD_WARNING; |
17521 | } | |
57d187bc | 17522 | |
d62a17ae | 17523 | lcommunity_list_show(vty, list); |
57d187bc | 17524 | |
d62a17ae | 17525 | return CMD_SUCCESS; |
57d187bc JS |
17526 | } |
17527 | ||
718e3744 | 17528 | /* "extcommunity-list" keyword help string. */ |
17529 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
17530 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
17531 | ||
7336e101 SP |
17532 | DEFUN (extcommunity_list_standard, |
17533 | bgp_extcommunity_list_standard_cmd, | |
2f8cc0e5 | 17534 | "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 | 17535 | BGP_STR |
718e3744 | 17536 | EXTCOMMUNITY_LIST_STR |
17537 | "Extended Community list number (standard)\n" | |
718e3744 | 17538 | "Specify standard extcommunity-list\n" |
5bf15956 | 17539 | "Community list name\n" |
2f8cc0e5 DA |
17540 | "Sequence number of an entry\n" |
17541 | "Sequence number\n" | |
718e3744 | 17542 | "Specify community to reject\n" |
17543 | "Specify community to accept\n" | |
17544 | EXTCOMMUNITY_VAL_STR) | |
17545 | { | |
d62a17ae | 17546 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17547 | int direct = 0; | |
17548 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17549 | char *seq = NULL; |
42f914d4 | 17550 | |
d62a17ae | 17551 | int idx = 0; |
7b9a4750 | 17552 | |
d62a17ae | 17553 | argv_find(argv, argc, "(1-99)", &idx); |
17554 | argv_find(argv, argc, "WORD", &idx); | |
17555 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17556 | |
17557 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17558 | if (idx) | |
17559 | seq = argv[idx]->arg; | |
17560 | ||
d62a17ae | 17561 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17562 | : COMMUNITY_DENY; | |
17563 | argv_find(argv, argc, "AA:NN", &idx); | |
17564 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17565 | |
2f8cc0e5 | 17566 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17567 | direct, style); |
42f914d4 | 17568 | |
d62a17ae | 17569 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17570 | |
d62a17ae | 17571 | if (ret < 0) { |
17572 | community_list_perror(vty, ret); | |
17573 | return CMD_WARNING_CONFIG_FAILED; | |
17574 | } | |
42f914d4 | 17575 | |
d62a17ae | 17576 | return CMD_SUCCESS; |
718e3744 | 17577 | } |
17578 | ||
7336e101 SP |
17579 | DEFUN (extcommunity_list_name_expanded, |
17580 | bgp_extcommunity_list_name_expanded_cmd, | |
2f8cc0e5 | 17581 | "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17582 | BGP_STR |
17583 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 17584 | "Extended Community list number (expanded)\n" |
718e3744 | 17585 | "Specify expanded extcommunity-list\n" |
17586 | "Extended Community list name\n" | |
2f8cc0e5 DA |
17587 | "Sequence number of an entry\n" |
17588 | "Sequence number\n" | |
718e3744 | 17589 | "Specify community to reject\n" |
17590 | "Specify community to accept\n" | |
17591 | "An ordered list as a regular-expression\n") | |
17592 | { | |
d62a17ae | 17593 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17594 | int direct = 0; | |
17595 | char *cl_number_or_name = NULL; | |
2f8cc0e5 | 17596 | char *seq = NULL; |
d62a17ae | 17597 | int idx = 0; |
7336e101 | 17598 | |
d62a17ae | 17599 | argv_find(argv, argc, "(100-500)", &idx); |
17600 | argv_find(argv, argc, "WORD", &idx); | |
17601 | cl_number_or_name = argv[idx]->arg; | |
2f8cc0e5 DA |
17602 | |
17603 | argv_find(argv, argc, "(1-4294967295)", &idx); | |
17604 | if (idx) | |
17605 | seq = argv[idx]->arg; | |
17606 | ||
d62a17ae | 17607 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
17608 | : COMMUNITY_DENY; | |
17609 | argv_find(argv, argc, "LINE", &idx); | |
17610 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 17611 | |
2f8cc0e5 | 17612 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, seq, |
d62a17ae | 17613 | direct, style); |
42f914d4 | 17614 | |
d62a17ae | 17615 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17616 | |
d62a17ae | 17617 | if (ret < 0) { |
17618 | community_list_perror(vty, ret); | |
17619 | return CMD_WARNING_CONFIG_FAILED; | |
17620 | } | |
42f914d4 | 17621 | |
d62a17ae | 17622 | return CMD_SUCCESS; |
718e3744 | 17623 | } |
17624 | ||
7336e101 SP |
17625 | DEFUN (no_extcommunity_list_standard_all, |
17626 | no_bgp_extcommunity_list_standard_all_cmd, | |
2f8cc0e5 | 17627 | "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...", |
7336e101 SP |
17628 | NO_STR |
17629 | BGP_STR | |
17630 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 17631 | "Extended Community list number (standard)\n" |
718e3744 | 17632 | "Specify standard extcommunity-list\n" |
5bf15956 | 17633 | "Community list name\n" |
2f8cc0e5 DA |
17634 | "Sequence number of an entry\n" |
17635 | "Sequence number\n" | |
718e3744 | 17636 | "Specify community to reject\n" |
17637 | "Specify community to accept\n" | |
17638 | EXTCOMMUNITY_VAL_STR) | |
17639 | { | |
d62a17ae | 17640 | int style = EXTCOMMUNITY_LIST_STANDARD; |
17641 | int direct = 0; | |
17642 | char *cl_number_or_name = NULL; | |
d4455c89 | 17643 | char *str = NULL; |
2f8cc0e5 | 17644 | char *seq = NULL; |
d62a17ae | 17645 | int idx = 0; |
d4455c89 | 17646 | |
2f8cc0e5 DA |
17647 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17648 | if (idx) | |
17649 | seq = argv[idx]->arg; | |
17650 | ||
17651 | idx = 0; | |
d4455c89 DA |
17652 | argv_find(argv, argc, "permit", &idx); |
17653 | argv_find(argv, argc, "deny", &idx); | |
d4455c89 DA |
17654 | if (idx) { |
17655 | direct = argv_find(argv, argc, "permit", &idx) | |
17656 | ? COMMUNITY_PERMIT | |
17657 | : COMMUNITY_DENY; | |
17658 | ||
17659 | idx = 0; | |
17660 | argv_find(argv, argc, "AA:NN", &idx); | |
17661 | str = argv_concat(argv, argc, idx); | |
17662 | } | |
17663 | ||
17664 | idx = 0; | |
d62a17ae | 17665 | argv_find(argv, argc, "(1-99)", &idx); |
17666 | argv_find(argv, argc, "WORD", &idx); | |
17667 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17668 | |
d62a17ae | 17669 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17670 | seq, direct, style); |
42f914d4 | 17671 | |
d62a17ae | 17672 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17673 | |
d62a17ae | 17674 | if (ret < 0) { |
17675 | community_list_perror(vty, ret); | |
17676 | return CMD_WARNING_CONFIG_FAILED; | |
17677 | } | |
42f914d4 | 17678 | |
d62a17ae | 17679 | return CMD_SUCCESS; |
718e3744 | 17680 | } |
17681 | ||
d4455c89 DA |
17682 | ALIAS(no_extcommunity_list_standard_all, |
17683 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
17684 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
17685 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17686 | "Extended Community list number (standard)\n" | |
17687 | "Specify standard extcommunity-list\n" | |
17688 | "Community list name\n") | |
17689 | ||
7336e101 SP |
17690 | DEFUN (no_extcommunity_list_expanded_all, |
17691 | no_bgp_extcommunity_list_expanded_all_cmd, | |
2f8cc0e5 | 17692 | "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...", |
7336e101 SP |
17693 | NO_STR |
17694 | BGP_STR | |
17695 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 17696 | "Extended Community list number (expanded)\n" |
718e3744 | 17697 | "Specify expanded extcommunity-list\n" |
5bf15956 | 17698 | "Extended Community list name\n" |
2f8cc0e5 DA |
17699 | "Sequence number of an entry\n" |
17700 | "Sequence number\n" | |
718e3744 | 17701 | "Specify community to reject\n" |
17702 | "Specify community to accept\n" | |
17703 | "An ordered list as a regular-expression\n") | |
17704 | { | |
d62a17ae | 17705 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
17706 | int direct = 0; | |
17707 | char *cl_number_or_name = NULL; | |
d4455c89 | 17708 | char *str = NULL; |
2f8cc0e5 | 17709 | char *seq = NULL; |
d62a17ae | 17710 | int idx = 0; |
d4455c89 | 17711 | |
2f8cc0e5 DA |
17712 | argv_find(argv, argc, "(1-4294967295)", &idx); |
17713 | if (idx) | |
17714 | seq = argv[idx]->arg; | |
17715 | ||
17716 | idx = 0; | |
d4455c89 DA |
17717 | argv_find(argv, argc, "permit", &idx); |
17718 | argv_find(argv, argc, "deny", &idx); | |
17719 | ||
17720 | if (idx) { | |
17721 | direct = argv_find(argv, argc, "permit", &idx) | |
17722 | ? COMMUNITY_PERMIT | |
17723 | : COMMUNITY_DENY; | |
17724 | ||
17725 | idx = 0; | |
17726 | argv_find(argv, argc, "LINE", &idx); | |
17727 | str = argv_concat(argv, argc, idx); | |
17728 | } | |
17729 | ||
17730 | idx = 0; | |
d62a17ae | 17731 | argv_find(argv, argc, "(100-500)", &idx); |
17732 | argv_find(argv, argc, "WORD", &idx); | |
17733 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 17734 | |
d62a17ae | 17735 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
2f8cc0e5 | 17736 | seq, direct, style); |
42f914d4 | 17737 | |
d62a17ae | 17738 | XFREE(MTYPE_TMP, str); |
42f914d4 | 17739 | |
d62a17ae | 17740 | if (ret < 0) { |
17741 | community_list_perror(vty, ret); | |
17742 | return CMD_WARNING_CONFIG_FAILED; | |
17743 | } | |
42f914d4 | 17744 | |
d62a17ae | 17745 | return CMD_SUCCESS; |
718e3744 | 17746 | } |
17747 | ||
d4455c89 DA |
17748 | ALIAS(no_extcommunity_list_expanded_all, |
17749 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
17750 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
17751 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
17752 | "Extended Community list number (expanded)\n" | |
17753 | "Specify expanded extcommunity-list\n" | |
17754 | "Extended Community list name\n") | |
17755 | ||
d62a17ae | 17756 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 17757 | { |
d62a17ae | 17758 | struct community_entry *entry; |
718e3744 | 17759 | |
d62a17ae | 17760 | for (entry = list->head; entry; entry = entry->next) { |
17761 | if (entry == list->head) { | |
17762 | if (all_digit(list->name)) | |
17763 | vty_out(vty, "Extended community %s list %s\n", | |
17764 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17765 | ? "standard" | |
17766 | : "(expanded) access", | |
17767 | list->name); | |
17768 | else | |
17769 | vty_out(vty, | |
17770 | "Named extended community %s list %s\n", | |
17771 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
17772 | ? "standard" | |
17773 | : "expanded", | |
17774 | list->name); | |
17775 | } | |
17776 | if (entry->any) | |
17777 | vty_out(vty, " %s\n", | |
17778 | community_direct_str(entry->direct)); | |
17779 | else | |
17780 | vty_out(vty, " %s %s\n", | |
17781 | community_direct_str(entry->direct), | |
8d9b8ed9 | 17782 | community_list_config_str(entry)); |
d62a17ae | 17783 | } |
718e3744 | 17784 | } |
17785 | ||
7336e101 SP |
17786 | DEFUN (show_extcommunity_list, |
17787 | show_bgp_extcommunity_list_cmd, | |
17788 | "show bgp extcommunity-list", | |
718e3744 | 17789 | SHOW_STR |
7336e101 | 17790 | BGP_STR |
718e3744 | 17791 | "List extended-community list\n") |
17792 | { | |
d62a17ae | 17793 | struct community_list *list; |
17794 | struct community_list_master *cm; | |
718e3744 | 17795 | |
d62a17ae | 17796 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
17797 | if (!cm) | |
17798 | return CMD_SUCCESS; | |
718e3744 | 17799 | |
d62a17ae | 17800 | for (list = cm->num.head; list; list = list->next) |
17801 | extcommunity_list_show(vty, list); | |
718e3744 | 17802 | |
d62a17ae | 17803 | for (list = cm->str.head; list; list = list->next) |
17804 | extcommunity_list_show(vty, list); | |
718e3744 | 17805 | |
d62a17ae | 17806 | return CMD_SUCCESS; |
718e3744 | 17807 | } |
17808 | ||
7336e101 SP |
17809 | DEFUN (show_extcommunity_list_arg, |
17810 | show_bgp_extcommunity_list_arg_cmd, | |
960b69b9 | 17811 | "show bgp extcommunity-list <(1-500)|WORD> detail", |
7336e101 SP |
17812 | SHOW_STR |
17813 | BGP_STR | |
718e3744 | 17814 | "List extended-community list\n" |
17815 | "Extcommunity-list number\n" | |
960b69b9 | 17816 | "Extcommunity-list name\n" |
17817 | "Detailed information on extcommunity-list\n") | |
718e3744 | 17818 | { |
d62a17ae | 17819 | int idx_comm_list = 3; |
17820 | struct community_list *list; | |
718e3744 | 17821 | |
e237b0d2 | 17822 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 17823 | EXTCOMMUNITY_LIST_MASTER); |
17824 | if (!list) { | |
17825 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
17826 | return CMD_WARNING; | |
17827 | } | |
718e3744 | 17828 | |
d62a17ae | 17829 | extcommunity_list_show(vty, list); |
718e3744 | 17830 | |
d62a17ae | 17831 | return CMD_SUCCESS; |
718e3744 | 17832 | } |
6b0655a2 | 17833 | |
718e3744 | 17834 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 17835 | static int community_list_config_write(struct vty *vty) |
17836 | { | |
17837 | struct community_list *list; | |
17838 | struct community_entry *entry; | |
17839 | struct community_list_master *cm; | |
17840 | int write = 0; | |
17841 | ||
17842 | /* Community-list. */ | |
17843 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
17844 | ||
17845 | for (list = cm->num.head; list; list = list->next) | |
17846 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17847 | vty_out(vty, |
17848 | "bgp community-list %s seq %" PRId64 " %s %s\n", | |
17849 | list->name, entry->seq, | |
d62a17ae | 17850 | community_direct_str(entry->direct), |
17851 | community_list_config_str(entry)); | |
17852 | write++; | |
17853 | } | |
17854 | for (list = cm->str.head; list; list = list->next) | |
17855 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17856 | vty_out(vty, |
17857 | "bgp community-list %s %s seq %" PRId64 " %s %s\n", | |
d62a17ae | 17858 | entry->style == COMMUNITY_LIST_STANDARD |
17859 | ? "standard" | |
17860 | : "expanded", | |
2f8cc0e5 DA |
17861 | list->name, entry->seq, |
17862 | community_direct_str(entry->direct), | |
d62a17ae | 17863 | community_list_config_str(entry)); |
17864 | write++; | |
17865 | } | |
17866 | ||
17867 | /* Extcommunity-list. */ | |
17868 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
17869 | ||
17870 | for (list = cm->num.head; list; list = list->next) | |
17871 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17872 | vty_out(vty, |
17873 | "bgp extcommunity-list %s seq %" PRId64 " %s %s\n", | |
17874 | list->name, entry->seq, | |
17875 | community_direct_str(entry->direct), | |
d62a17ae | 17876 | community_list_config_str(entry)); |
17877 | write++; | |
17878 | } | |
17879 | for (list = cm->str.head; list; list = list->next) | |
17880 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17881 | vty_out(vty, |
17882 | "bgp extcommunity-list %s %s seq %" PRId64 | |
17883 | " %s %s\n", | |
d62a17ae | 17884 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
17885 | ? "standard" | |
17886 | : "expanded", | |
2f8cc0e5 DA |
17887 | list->name, entry->seq, |
17888 | community_direct_str(entry->direct), | |
d62a17ae | 17889 | community_list_config_str(entry)); |
17890 | write++; | |
17891 | } | |
17892 | ||
17893 | ||
17894 | /* lcommunity-list. */ | |
17895 | cm = community_list_master_lookup(bgp_clist, | |
17896 | LARGE_COMMUNITY_LIST_MASTER); | |
17897 | ||
17898 | for (list = cm->num.head; list; list = list->next) | |
17899 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17900 | vty_out(vty, |
17901 | "bgp large-community-list %s seq %" PRId64 | |
17902 | " %s %s\n", | |
17903 | list->name, entry->seq, | |
17904 | community_direct_str(entry->direct), | |
d62a17ae | 17905 | community_list_config_str(entry)); |
17906 | write++; | |
17907 | } | |
17908 | for (list = cm->str.head; list; list = list->next) | |
17909 | for (entry = list->head; entry; entry = entry->next) { | |
2f8cc0e5 DA |
17910 | vty_out(vty, |
17911 | "bgp large-community-list %s %s seq %" PRId64 | |
17912 | " %s %s\n", | |
17913 | ||
d62a17ae | 17914 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
17915 | ? "standard" | |
17916 | : "expanded", | |
2f8cc0e5 | 17917 | list->name, entry->seq, community_direct_str(entry->direct), |
d62a17ae | 17918 | community_list_config_str(entry)); |
17919 | write++; | |
17920 | } | |
17921 | ||
17922 | return write; | |
17923 | } | |
17924 | ||
612c2c15 | 17925 | static int community_list_config_write(struct vty *vty); |
d62a17ae | 17926 | static struct cmd_node community_list_node = { |
f4b8291f | 17927 | .name = "community list", |
62b346ee DL |
17928 | .node = COMMUNITY_LIST_NODE, |
17929 | .prompt = "", | |
612c2c15 | 17930 | .config_write = community_list_config_write, |
718e3744 | 17931 | }; |
17932 | ||
d62a17ae | 17933 | static void community_list_vty(void) |
17934 | { | |
612c2c15 | 17935 | install_node(&community_list_node); |
d62a17ae | 17936 | |
17937 | /* Community-list. */ | |
7336e101 SP |
17938 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
17939 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
17940 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 17941 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 17942 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 17943 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
17944 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
17945 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 17946 | |
17947 | /* Extcommunity-list. */ | |
7336e101 SP |
17948 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
17949 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
17950 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
17951 | install_element(CONFIG_NODE, |
17952 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 17953 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
17954 | install_element(CONFIG_NODE, |
17955 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
17956 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
17957 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 17958 | |
17959 | /* Large Community List */ | |
7336e101 | 17960 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
7336e101 SP |
17961 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); |
17962 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
7336e101 | 17963 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); |
4378f57c DA |
17964 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_all_cmd); |
17965 | install_element(CONFIG_NODE, | |
17966 | &no_bgp_lcommunity_list_name_standard_all_cmd); | |
7336e101 SP |
17967 | install_element(CONFIG_NODE, |
17968 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
17969 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
17970 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
17971 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
17972 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
17973 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
17974 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
5bf15956 | 17975 | } |